def add_via(self, message, branch): via_hdr = message.get(VIA_HEADER) via = ViaHeader() via.sent_by = SentBy(host=self.local_addr, port=self.local_port) via.sent_protocol = SentProtocol(transport=self.transport, version='2.0', name='SIP') via.branch = branch via_hdr.add_topmost(via) message.set_header(via_hdr)
def check_via_match(self, via): if self.check_via_match_address(via) and self.check_via_match_transport(via): return ViaMatchResult(result=ViaMatchResult.MATCH) else: expected = ViaHeader() expected.sent_by = SentBy(host=self.local_addr, port=self.local_port) expected.sent_protocol = SentProtocol(transport=self.transport, version='2.0', name='SIP') expected_str = expected.assemble() actual_str = via.assemble() return ViaMatchResult(result=ViaMatchResult.MISMATCH, expected=expected_str, actual=actual_str)