def genRequest(self, method, body = None, nonce = None, realm = None, SipXXXAuthorization = SipAuthorization, \ reason = None): if self.outbound_proxy != None: target = self.outbound_proxy else: target = self.rAddr req = SipRequest(method=method, ruri=self.rTarget, to=self.rUri, fr0m=self.lUri, cseq=self.lCSeq, callid=self.cId, contact=self.lContact, routes=self.routes, target=target, cguid=self.cGUID, user_agent=self.local_ua) if nonce != None and realm != None and self.username != None and self.password != None: auth = SipXXXAuthorization(realm=realm, nonce=nonce, method=method, uri=str(self.rTarget), username=self.username, password=self.password) req.appendHeader(SipHeader(body=auth)) if body != None: req.setBody(body) if self.extra_headers != None: req.appendHeaders(self.extra_headers) if reason != None: req.appendHeader(SipHeader(body=reason)) self.reqs[self.lCSeq] = req return req
def timerB(self, t): #print 'timerB', t t.teB = None if t.teA != None: t.teA.cancel() t.teA = None t.state = TERMINATED #print '2: Timeout(self.timerC, 32.0, 1, t)', t t.teC = Timeout(self.timerC, 32.0, 1, t) if t.resp_cb == None: return fake_resp = SipRequest(t.data).genResponse(408, 'Request Timeout') fake_resp.rtime = time() t.resp_cb(fake_resp)
def genRequest(self, method, body = None, nonce = None, realm = None, SipXXXAuthorization = SipAuthorization, \ reason = None): req = SipRequest(method = method, ruri = self.rTarget, to = self.rUri, fr0m = self.lUri, cseq = self.lCSeq, callid = self.cId, contact = self.lContact, routes = self.routes, target = self.rAddr, cguid = self.cGUID) if nonce != None and realm != None and self.username != None and self.password != None: auth = SipXXXAuthorization(realm = realm, nonce = nonce, method = method, uri = str(self.rTarget), username = self.username, password = self.password) req.appendHeader(SipHeader(body = auth)) if body != None: req.setBody(body) if self.extra_headers != None: req.appendHeaders(self.extra_headers) if reason != None: req.appendHeader(SipHeader(body = reason)) self.reqs[self.lCSeq] = req return req
return t = self.tclient[tid] if self.nat_traversal and resp.countHFs( 'contact') > 0 and not check1918(t.address[0]): cbody = resp.getHFBody('contact') if not cbody.asterisk: curl = cbody.getUrl() if check1918(curl.host): curl.host, curl.port = address resp.setSource(address) self.incomingResponse(resp, t, checksum) else: if self.req_cb == None: return try: req = SipRequest(data) tids = req.getTIds() except Exception, exception: print datetime.now( ), 'can\'t parse SIP request from %s:%d: %s:' % ( address[0], address[1], str(exception)) print '-' * 70 print_exc(file=sys.stdout) print '-' * 70 print data print '-' * 70 sys.stdout.flush() self.l1rcache[checksum] = (None, None, None) return req.rtime = rtime via0 = req.getHFBody('via')
if not self.tclient.has_key(tid): #print 'no transaction with tid of %s in progress' % str(tid) self.l1rcache[checksum] = (None, None) return t = self.tclient[tid] if self.nat_traversal and resp.countHFs('contact') > 0 and not check1918(t.address[0]): curl = resp.getHFBody('contact').getUrl() if check1918(curl.host): curl.host, curl.port = address resp.setSource(address) self.incomingResponse(resp, t, checksum) else: if self.req_cb == None: return try: req = SipRequest(data) tids = req.getTIds() except Exception, exception: print datetime.now(), 'can\'t parse SIP request from %s:%d: %s:' % (address[0], address[1], str(exception)) print '-' * 70 print_exc(file = sys.stdout) print '-' * 70 print data print '-' * 70 sys.stdout.flush() self.l1rcache[checksum] = (None, None) return req.rtime = rtime via0 = req.getHFBody('via') ahost, aport = via0.getAddr() rhost, rport = address