def __cmp__(self, other): if not isinstance(other, Via): return -1 ret = 0 if self.protocol != other.protocol: ret += 1 if self.version != other.version: ret += 1 if self.transport != other.transport: ret += 1 if not compareHostNames(self.host, other.host): ret += 1 if self.port != other.port: if self.port is None: sp = int(5060) elif hasattr(self.port, "isdigit") and self.port.isdigit(): sp = int(self.port) else: sp = self.port if other.port is None: op = int(5060) elif hasattr(other.port, "isdigit") and other.port.isdigit(): op = int(other.port) else: op = other.port if sp != op: ret += 1 if self.ttl != other.ttl: ret += 1 if self.maddr != other.maddr: ret += 1 #Note: we can not compare received and rport because the values # are supposed to be change by the UAS if self.branch != other.branch: ret += 1 for i in self.params: if (i not in other.params) and (i.strip() not in other.params): eq = i.find("=") if eq == -1: ret += 1 else: j = i[:eq].strip() + "=" + i[eq+1:].strip() if j not in other.params: ret += 1 return ret
def __cmp__(self, other): if not isinstance(other, Via): return -1 ret = 0 if self.protocol != other.protocol: ret += 1 if self.version != other.version: ret += 1 if self.transport != other.transport: ret += 1 if not compareHostNames(self.host, other.host): ret += 1 if self.port != other.port: if self.port is None: sp = int(5060) elif hasattr(self.port, "isdigit") and self.port.isdigit(): sp = int(self.port) else: sp = self.port if other.port is None: op = int(5060) elif hasattr(other.port, "isdigit") and other.port.isdigit(): op = int(other.port) else: op = other.port if sp != op: ret += 1 if self.ttl != other.ttl: ret += 1 if self.maddr != other.maddr: ret += 1 #Note: we can not compare received and rport because the values # are supposed to be change by the UAS if self.branch != other.branch: ret += 1 for i in self.params: if (i not in other.params) and (i.strip() not in other.params): eq = i.find("=") if eq == -1: ret += 1 else: j = i[:eq].strip() + "=" + i[eq + 1:].strip() if j not in other.params: ret += 1 return ret
def __cmp__(self, other): ret = 0 if not isinstance(other, sip_uri): return -1 if self.protocol != other.protocol: ret = ret + 1 if self.username != other.username: ret = ret + 1 if self.password != other.password: ret = ret + 1 if not compareHostNames(self.host, other.host): ret = ret + 1 if self.ipv6 != other.ipv6: ret = ret + 1 if self.port != other.port: if self.port is None: sp = int(5060) elif hasattr(self.port, "isdigit") and self.port.isdigit(): sp = int(self.port) else: sp = self.port if other.port is None: op = int(5060) elif hasattr(other.port, "isdigit") and other.port.isdigit(): op = int(other.port) else: op = other.port if sp != op: ret = ret + 1 #FIXME params from other are not checked against self #FIXME params with default values could be omitted for i in self.params: if i not in other.params: ret = ret + 1 for j in self.headers: if j not in other.headers: ret = ret + 1 return ret