def placeOriginate(self, oroute): cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData() cld = oroute.cld self.huntstop_scodes = oroute.params.get('huntstop_scodes', ()) if 'static_tr_out' in self.global_config: cld = re_replace(self.global_config['static_tr_out'], cld) if oroute.hostport == 'sip-ua': host = self.source[0] nh_address, same_af = self.source, True else: host = oroute.hostonly nh_address, same_af = oroute.getNHAddr(self.source) if not oroute.forward_on_fail and self.global_config['acct_enable']: self.acctO = RadiusAccounting(self.global_config, 'originate', \ send_start = self.global_config['start_acct_enable'], lperiod = \ self.global_config.getdefault('alive_acct_int', None)) self.acctO.ms_precision = self.global_config.getdefault( 'precise_acct', False) self.acctO.setParams(oroute.params.get('bill-to', self.username), oroute.params.get('bill-cli', oroute.cli), \ oroute.params.get('bill-cld', cld), self.cGUID, self.cId, host) else: self.acctO = None self.acctA.credit_time = oroute.credit_time conn_handlers = [self.oConn] disc_handlers = [] if not oroute.forward_on_fail and self.global_config['acct_enable']: disc_handlers.append(self.acctO.disc) self.uaO = UA(self.global_config, self.recvEvent, oroute.user, oroute.passw, nh_address, oroute.credit_time, tuple(conn_handlers), \ tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = oroute.expires, \ no_progress_time = oroute.no_progress_expires, extra_headers = oroute.extra_headers) self.uaO.local_ua = self.global_config['_uaname'] self.uaO.no_reply_time = oroute.no_reply_expires if self.source != oroute.params.get('outbound_proxy', None): self.uaO.outbound_proxy = oroute.params.get('outbound_proxy', None) if self.rtp_proxy_session != None and oroute.params.get('rtpp', True): self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change self.rtp_proxy_session.caller.raddress = nh_address if body != None: body = body.getCopy() self.proxied = True self.uaO.kaInterval = self.global_config['keepalive_orig'] if 'group_timeout' in oroute.params: timeout, skipto = oroute.params['group_timeout'] Timeout(self.group_expires, timeout, 1, skipto) if self.global_config.getdefault('hide_call_id', False): cId = SipCallId( md5(str(cId).encode()).hexdigest() + ('-b2b_%d' % oroute.rnum)) else: cId += '-b2b_%d' % oroute.rnum event = CCEventTry((cId, cGUID, oroute.cli, cld, body, auth, \ oroute.params.get('caller_name', self.caller_name))) if self.eTry.max_forwards != None: event.max_forwards = self.eTry.max_forwards - 1 if event.max_forwards <= 0: self.uaA.recvEvent(CCEventFail((483, 'Too Many Hops'))) self.state = CCStateDead return event.reason = self.eTry.reason self.uaO.recvEvent(event)
def placeOriginate(self, oroute): cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData() cld = oroute.cld self.huntstop_scodes = oroute.params.get('huntstop_scodes', ()) if 'static_tr_out' in self.global_config: cld = re_replace(self.global_config['static_tr_out'], cld) if oroute.hostport == 'sip-ua': host = self.source[0] nh_address, same_af = self.source, True else: host = oroute.hostonly nh_address, same_af = oroute.getNHAddr(self.source) if not oroute.forward_on_fail and self.global_config['acct_enable']: self.acctO = RadiusAccounting(self.global_config, 'originate', \ send_start = self.global_config['start_acct_enable'], lperiod = \ self.global_config.getdefault('alive_acct_int', None)) self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False) self.acctO.setParams(oroute.params.get('bill-to', self.username), oroute.params.get('bill-cli', oroute.cli), \ oroute.params.get('bill-cld', cld), self.cGUID, self.cId, host) else: self.acctO = None self.acctA.credit_time = oroute.credit_time conn_handlers = [self.oConn] disc_handlers = [] if not oroute.forward_on_fail and self.global_config['acct_enable']: disc_handlers.append(self.acctO.disc) self.uaO = UA(self.global_config, self.recvEvent, oroute.user, oroute.passw, nh_address, oroute.credit_time, tuple(conn_handlers), \ tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = oroute.expires, \ no_progress_time = oroute.no_progress_expires, extra_headers = oroute.extra_headers) self.uaO.local_ua = self.global_config['_uaname'] if self.source != oroute.params.get('outbound_proxy', None): self.uaO.outbound_proxy = oroute.params.get('outbound_proxy', None) if self.rtp_proxy_session != None and oroute.params.get('rtpp', True): self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change self.rtp_proxy_session.caller.raddress = nh_address if body != None: body = body.getCopy() self.proxied = True self.uaO.kaInterval = self.global_config['keepalive_orig'] if 'group_timeout' in oroute.params: timeout, skipto = oroute.params['group_timeout'] Timeout(self.group_expires, timeout, 1, skipto) if self.global_config.getdefault('hide_call_id', False): cId = SipCallId(md5(str(cId).encode()).hexdigest() + ('-b2b_%d' % oroute.rnum)) else: cId += '-b2b_%d' % oroute.rnum event = CCEventTry((cId, cGUID, oroute.cli, cld, body, auth, \ oroute.params.get('caller_name', self.caller_name))) if self.eTry.max_forwards != None: event.max_forwards = self.eTry.max_forwards - 1 if event.max_forwards <= 0: self.uaA.recvEvent(CCEventFail((483, 'Too Many Hops'))) self.state = CCStateDead return event.reason = self.eTry.reason self.uaO.recvEvent(event)
def __init__(self, global_config, body, done_cb, portrange): uaO = UA(global_config, event_cb = self.recvEvent, nh_address = ('127.0.0.1', 5060), \ conn_cbs = (self.connected,), disc_cbs = (self.disconnected,), fail_cbs = (self.disconnected,), \ dead_cbs = (self.alldone,)) uaO.godead_timeout = 10 uaO.compact_sip = self.compact_sip event = CCEventTry((SipCallId(), SipCiscoGUID(), self.cli, self.cld, body, \ None, 'Alice Smith')) uaO.recvEvent(event) self.done_cb = done_cb self.portrange = portrange
def __init__(self, tccfg): self.tccfg = tccfg if tccfg.cli != None: self.cli = tccfg.cli uaO = UA(tccfg.global_config, event_cb = self.recvEvent, nh_address = tccfg.nh_address, \ conn_cbs = (self.connected,), disc_cbs = (self.disconnected,), fail_cbs = (self.disconnected,), \ dead_cbs = (self.alldone,), ltag = gen_test_tag()) uaO.godead_timeout = self.godead_timeout uaO.compact_sip = self.compact_sip self.call_id = SipCallId(body=gen_test_cid()) event = CCEventTry((self.call_id, SipCiscoGUID(), self.cli, self.cld, tccfg.body, \ None, 'Alice Smith')) self.run(uaO, event)
def placeOriginate(self, args): cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData() rnum, host, cld, credit_time, expires, no_progress_expires, forward_on_fail, user, passw, cli, \ parameters = args self.huntstop_scodes = parameters.get('huntstop_scodes', ()) if self.global_config.has_key('static_tr_out'): cld = re_replace(self.global_config['static_tr_out'], cld) if host == 'sip-ua': host = self.source[0] port = self.source[1] else: if host.startswith('['): # IPv6 host = host.split(']', 1) port = host[1].split(':', 1) host = host[0] + ']' if len(port) > 1: port = int(port[1]) else: port = SipConf.default_port else: # IPv4 host = host.split(':', 1) if len(host) > 1: port = int(host[1]) else: port = SipConf.default_port host = host[0] if not forward_on_fail and self.global_config['acct_enable']: self.acctO = RadiusAccounting(self.global_config, 'originate', \ send_start = self.global_config['start_acct_enable'], lperiod = \ self.global_config.getdefault('alive_acct_int', None)) self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False) self.acctO.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \ parameters.get('bill-cld', cld), self.cGUID, self.cId, host) else: self.acctO = None self.acctA.credit_time = credit_time conn_handlers = [self.oConn] disc_handlers = [] if not forward_on_fail and self.global_config['acct_enable']: disc_handlers.append(self.acctO.disc) self.uaO = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, tuple(conn_handlers), \ tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = expires, \ no_progress_time = no_progress_expires, extra_headers = parameters.get('extra_headers', None)) if self.rtp_proxy_session != None and parameters.get('rtpp', True): self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change self.rtp_proxy_session.caller_raddress = (host, port) body = body.getCopy() body.content += 'a=nortpproxy:yes\r\n' self.proxied = True self.uaO.kaInterval = self.global_config['keepalive_orig'] if parameters.has_key('group_timeout'): timeout, skipto = parameters['group_timeout'] Timeout(self.group_expires, timeout, 1, skipto) if self.global_config.getdefault('hide_call_id', False): cId = SipCallId(md5(str(cId)).hexdigest() + ('-b2b_%d' % rnum)) else: cId += '-b2b_%d' % rnum event = CCEventTry((cId, cGUID, cli, cld, body, auth, \ parameters.get('caller_name', self.caller_name))) event.reason = self.eTry.reason self.uaO.recvEvent(event)
def placeOriginate(self, args): cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData() rnum, host, cld, credit_time, expires, no_progress_expires, forward_on_fail, user, passw, cli, \ parameters = args self.huntstop_scodes = parameters.get('huntstop_scodes', ()) if self.global_config.has_key('static_tr_out'): cld = re_replace(self.global_config['static_tr_out'], cld) if host == 'sip-ua': host = self.source[0] port = self.source[1] else: if host.startswith('['): # IPv6 host = host.split(']', 1) port = host[1].split(':', 1) host = host[0] + ']' if len(port) > 1: port = int(port[1]) else: port = SipConf.default_port else: # IPv4 host = host.split(':', 1) if len(host) > 1: port = int(host[1]) else: port = SipConf.default_port host = host[0] if not forward_on_fail and self.global_config['acct_enable']: self.acctO = RadiusAccounting(self.global_config, 'originate', \ send_start = self.global_config['start_acct_enable'], lperiod = \ self.global_config.getdefault('alive_acct_int', None)) self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False) self.acctO.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \ parameters.get('bill-cld', cld), self.cGUID, self.cId, host) else: self.acctO = None self.acctA.credit_time = credit_time conn_handlers = [self.oConn] disc_handlers = [] if not forward_on_fail and self.global_config['acct_enable']: disc_handlers.append(self.acctO.disc) self.uaO = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, tuple(conn_handlers), \ tuple(disc_handlers), tuple(disc_handlers), dead_cbs = (self.oDead,), expire_time = expires, \ no_progress_time = no_progress_expires, extra_headers = parameters.get('extra_headers', None)) if self.source != parameters.get('outbound_proxy', None): self.uaO.outbound_proxy = parameters.get('outbound_proxy', None) if self.rtp_proxy_session != None and parameters.get('rtpp', True): self.uaO.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change self.uaO.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change self.rtp_proxy_session.caller_raddress = (host, port) if body != None: body = body.getCopy() body.content += 'a=nortpproxy:yes\r\n' self.proxied = True self.uaO.kaInterval = self.global_config['keepalive_orig'] if parameters.has_key('group_timeout'): timeout, skipto = parameters['group_timeout'] Timeout(self.group_expires, timeout, 1, skipto) if self.global_config.getdefault('hide_call_id', False): cId = SipCallId(md5(str(cId)).hexdigest() + ('-b2b_%d' % rnum)) else: cId += '-b2b_%d' % rnum event = CCEventTry((cId, cGUID, cli, cld, body, auth, \ parameters.get('caller_name', self.caller_name))) event.reason = self.eTry.reason self.uaO.recvEvent(event)
def recvEvent(self, event, ua): who = 'uaA' if ua == self.uaA else 'uaO' print who, 'received event', event, 'in state', self.state.sname if self.uaA: print 'self.uaA.state:', self.uaA.state if self.uaO: print 'self.uaO.state:', self.uaO.state if ua == self.uaA: if self.state == CCStateIdle: if not isinstance(event, CCEventTry): # Some weird event received self.uaA.recvEvent(CCEventDisconnect(rtime = event.rtime)) return self.cId, cGUID, self.cli, self.cld, body, auth, self.caller_name = event.getData() print 'auth:', auth self.cGUID = cGUID.hexForm() if not self.cld: self.uaA.recvEvent(CCEventFail((500, 'Internal Server Error (1)'), rtime = event.rtime)) self.state = CCStateDead return if not body: self.uaA.recvEvent(CCEventFail((500, 'Body-less INVITE is not supported'), rtime = event.rtime)) self.state = CCStateDead return if self.global_config.has_key('allowed_pts'): try: body.parse() except: self.uaA.recvEvent(CCEventFail((400, 'Malformed SDP Body'), rtime = event.rtime)) self.state = CCStateDead return allowed_pts = self.global_config['allowed_pts'] mbody = body.content.sections[0].m_header if mbody.transport.lower() == 'rtp/avp': mbody.formats = [x for x in mbody.formats if x in allowed_pts] if not mbody.formats: self.uaA.recvEvent(CCEventFail((488, 'Not Acceptable Here'))) self.state = CCStateDead return if self.cld.startswith('nat-'): self.cld = self.cld[4:] body.content += 'a=nated:yes\r\n' event = CCEventTry((self.cId, cGUID, self.cli, self.cld, body, auth, self.caller_name), \ rtime = event.rtime, origin = event.origin) if self.global_config.has_key('static_tr_in'): self.cld = re_replace(self.global_config['static_tr_in'], self.cld) event = CCEventTry((self.cId, cGUID, self.cli, self.cld, body, auth, self.caller_name), \ rtime = event.rtime, origin = event.origin) if self.global_config.has_key('rtp_proxy_clients'): self.rtp_proxy_session = Rtp_proxy_session(self.global_config, call_id = self.cId, \ notify_socket = global_config['b2bua_socket'], \ notify_tag = quote('r %s' % str(self.id))) self.eTry = event self.state = CCStateWaitRoute if not self.global_config['auth_enable']: self.username = self.remote_ip self.rDone(((), 0)) elif not auth or not auth.username: print 'setting username to remote ip ', self.remote_ip self.username = self.remote_ip self.auth_proc = self.global_config['radius_client'].do_auth(self.remote_ip, self.cli, self.cld, self.cGUID, \ self.cId, self.remote_ip, self.rDone) else: print 'setting username auth username ', auth.username self.username = auth.username self.auth_proc = self.global_config['radius_client'].do_auth(auth.username, self.cli, self.cld, self.cGUID, self.cId, self.remote_ip, self.rDone, auth.realm, auth.nonce, auth.uri, auth.response) return if self.state == CCStateUpdatingA and isinstance(event, CCEventConnect): self.state = CCStateConnected #TODO: rad acct start if self.state == CCStateWaitRouteA and isinstance(event, CCEventConnect): # Command 'make call'. # The left phone answered. # An INVITE should be sent to the right phone. #TODO: move to a subroutine self.cli, self.cld = self.cld, self.cli body = self.uaA.rSDP #TODO: a get method()? print 'body:\n', body self.cId = SipCallId() self.caller_name = self.cli auth = None ev = CCEventTry((self.cId, self.cGUID, self.cli, self.cld, body, auth, self.cli), origin = self.cld) self.eTry = ev self.state = CCStateWaitRouteO if self.global_config['auth_enable']: self.auth_proc = self.global_config['radius_client'].do_auth(self.cli, self.cli, self.cld, self.cGUID, \ self.cId, self.remote_ip, self.rDone) else: self.rDone(((), 0)) if self.state == CCStateDead and (isinstance(event, CCEventFail) or (isinstance(event, CCEventDisconnect))) and self.routes: if isinstance(event, CCEventFail): code = event.getData()[0] else: code = None if not code or code not in self.huntstop_scodes: self.state = CCStateWaitRouteA self.uaA = self.placeAnswer(self.routes.pop(0)) if self.state not in (CCStateARComplete, CCStateConnected, CCStateDisconnecting) or not self.uaO: return self.uaO.recvEvent(event) else: if self.state == CCStateARComplete and isinstance(event, CCEventConnect) and not isinstance(self.uaO.state, UaStateConnected): if not self.global_config.has_key('rtp_proxy_clients'): self.state = CCStateUpdatingA body = self.uaO.rSDP #TODO: a get method()? event = CCEventUpdate(body) self.uaO.delayed_remote_sdp_update(event, body) else: self.state = CCStateConnected return elif (isinstance(event, CCEventFail) or isinstance(event, CCEventDisconnect)) and self.state == CCStateARComplete and \ (isinstance(self.uaA.state, UasStateTrying) or isinstance(self.uaA.state, UasStateRinging) \ or isinstance(self.uaA.state, UaStateConnected)) and self.routes: if isinstance(event, CCEventFail): code = event.getData()[0] else: code = None if not code or code not in self.huntstop_scodes: cb = self.oConnA if isinstance(self.uaA.state, UaStateConnected) else self.oConn self.uaO = self.placeOriginate(self.routes.pop(0), cb) return self.uaA.recvEvent(event)
def recvRequest(self, req): if req.getMethod() != 'INVITE': #print 'wrong request %s in the Trying state' % req.getMethod() return None self.ua.origin = 'caller' #print 'INVITE received in the Idle state, going to the Trying state' if req.countHFs('cisco-guid') != 0: try: self.ua.cGUID = req.getHFBody('cisco-guid').getCopy() except: self.ua.cGUID = SipCiscoGUID() elif req.countHFs('h323-conf-id') != 0: try: self.ua.cGUID = req.getHFBody('h323-conf-id').getCopy() except: self.ua.cGUID = SipCiscoGUID() else: pass # self.ua.cGUID = SipCiscoGUID() self.ua.uasResp = req.genResponse(100, 'Trying', server=self.ua.local_ua) self.ua.lCSeq = 100 # XXX: 100 for debugging so that incorrect CSeq generation will be easily spotted if self.ua.lContact == None: self.ua.lContact = SipContact() self.ua.rTarget = req.getHFBody('contact').getUrl().getCopy() self.ua.routes = [ x.getCopy() for x in self.ua.uasResp.getHFBodys('record-route') ] if len(self.ua.routes) > 0: if not self.ua.routes[0].getUrl().lr: self.ua.routes.append( SipRoute(address=SipAddress(url=self.ua.rTarget))) self.ua.rTarget = self.ua.routes.pop(0).getUrl() self.ua.rAddr = self.ua.rTarget.getAddr() elif self.ua.outbound_proxy != None: self.ua.routes.append( SipRoute(address=SipAddress(url=self.ua.rTarget))) self.ua.rTarget = self.ua.routes[0].getUrl().getCopy() self.ua.rTarget.lr = False self.ua.rTarget.other = tuple() self.ua.rTarget.headers = tuple() else: self.ua.rAddr = self.ua.routes[0].getAddr() else: self.ua.rAddr = self.ua.rTarget.getAddr() self.ua.rAddr0 = self.ua.rAddr self.ua.global_config['_sip_tm'].sendResponse( self.ua.uasResp, lossemul=self.ua.uas_lossemul) self.ua.uasResp.getHFBody('to').setTag(self.ua.lTag) self.ua.lUri = SipFrom( address=self.ua.uasResp.getHFBody('to').getUri()) self.ua.rUri = SipTo( address=self.ua.uasResp.getHFBody('from').getUri()) self.ua.cId = self.ua.uasResp.getHFBody('call-id') self.ua.global_config['_sip_tm'].regConsumer( self.ua, str(self.ua.cId), compact=self.ua.compact_sip) if req.countHFs('authorization') == 0: auth = None else: auth = req.getHFBody('authorization').getCopy() body = req.getBody() self.ua.branch = req.getHFBody('via').getBranch() event = CCEventTry((self.ua.cId, self.ua.cGUID, self.ua.rUri.getUrl().username, req.getRURI().username, body, auth, \ self.ua.rUri.getUri().name), rtime = req.rtime, origin = self.ua.origin) try: event.reason = req.getHFBody('reason') except: pass try: event.max_forwards = req.getHFBody('max-forwards').getNum() except: pass if self.ua.expire_time != None: self.ua.expire_time += event.rtime if self.ua.no_progress_time != None: self.ua.no_progress_time += event.rtime if self.ua.expire_time != None and self.ua.no_progress_time >= self.ua.expire_time: self.ua.no_progress_time = None if self.ua.no_progress_time != None: self.ua.no_progress_timer = TimeoutAbsMono( self.ua.no_progress_expires, self.ua.no_progress_time) elif self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change( body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.setup_ts = req.rtime return (UasStateTrying, ) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.setup_ts = req.rtime return (UasStateTrying, )
def recvRequest(self, req): if req.getMethod() != 'INVITE': #print 'wrong request %s in the Trying state' % req.getMethod() return None self.ua.origin = 'caller' #print 'INVITE received in the Idle state, going to the Trying state' if req.countHFs('cisco-guid') != 0: try: self.ua.cGUID = req.getHFBody('cisco-guid').getCopy() except: self.ua.cGUID = SipCiscoGUID() elif req.countHFs('h323-conf-id') != 0: try: self.ua.cGUID = req.getHFBody('h323-conf-id').getCopy() except: self.ua.cGUID = SipCiscoGUID() else: self.ua.cGUID = SipCiscoGUID() self.ua.uasResp = req.genResponse(100, 'Trying', server = self.ua.local_ua) self.ua.lCSeq = 100 # XXX: 100 for debugging so that incorrect CSeq generation will be easily spotted if self.ua.lContact == None: self.ua.lContact = SipContact() self.ua.rTarget = req.getHFBody('contact').getUrl().getCopy() self.ua.routes = [x.getCopy() for x in self.ua.uasResp.getHFBodys('record-route')] if len(self.ua.routes) > 0: if not self.ua.routes[0].getUrl().lr: self.ua.routes.append(SipRoute(address = SipAddress(url = self.ua.rTarget))) self.ua.rTarget = self.ua.routes.pop(0).getUrl() self.ua.rAddr = self.ua.rTarget.getAddr() elif self.ua.outbound_proxy != None: self.ua.routes.append(SipRoute(address = SipAddress(url = self.ua.rTarget))) self.ua.rTarget = self.ua.routes[0].getUrl().getCopy() self.ua.rTarget.lr = False self.ua.rTarget.other = tuple() self.ua.rTarget.headers = tuple() else: self.ua.rAddr = self.ua.routes[0].getAddr() else: self.ua.rAddr = self.ua.rTarget.getAddr() self.ua.rAddr0 = self.ua.rAddr self.ua.global_config['_sip_tm'].sendResponse(self.ua.uasResp, lossemul = self.ua.uas_lossemul) self.ua.uasResp.getHFBody('to').setTag(self.ua.lTag) self.ua.lUri = SipFrom(address = self.ua.uasResp.getHFBody('to').getUri()) self.ua.rUri = SipTo(address = self.ua.uasResp.getHFBody('from').getUri()) self.ua.cId = self.ua.uasResp.getHFBody('call-id') self.ua.global_config['_sip_tm'].regConsumer(self.ua, str(self.ua.cId), compact = self.ua.compact_sip) if req.countHFs('authorization') == 0: auth = None else: auth = req.getHFBody('authorization').getCopy() body = req.getBody() self.ua.branch = req.getHFBody('via').getBranch() event = CCEventTry((self.ua.cId, self.ua.cGUID, self.ua.rUri.getUrl().username, req.getRURI().username, body, auth, \ self.ua.rUri.getUri().name), rtime = req.rtime, origin = self.ua.origin) try: event.reason = req.getHFBody('reason') except: pass try: event.max_forwards = req.getHFBody('max-forwards').getNum() except: pass if self.ua.expire_time != None: self.ua.expire_time += event.rtime if self.ua.no_progress_time != None: self.ua.no_progress_time += event.rtime if self.ua.expire_time != None and self.ua.no_progress_time >= self.ua.expire_time: self.ua.no_progress_time = None if self.ua.no_progress_time != None: self.ua.no_progress_timer = TimeoutAbsMono(self.ua.no_progress_expires, self.ua.no_progress_time) elif self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_time) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.setup_ts = req.rtime return (UasStateTrying,) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.setup_ts = req.rtime return (UasStateTrying,)