Beispiel #1
0
 def placeOriginate(self, args, conn_cbs):
     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:
         host = host.split(':', 1)
         if len(host) > 1:
             port = int(host[1])
         else:
             port = SipConf.default_port
         host = host[0]
     disc_cbs = []
     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'])
         self.acctO.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \
           parameters.get('bill-cld', cld), self.cGUID, self.cId, host, credit_time)
         print 'adding acct stop cb'
         disc_cbs.append(self.acctO.disc)
     else:
         self.acctO = None
     self.acctA.credit_time = credit_time
     ua = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, \
       (conn_cbs,), tuple(disc_cbs), tuple(disc_cbs), 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 and parameters.get('rtpp', True):
         ua.on_local_sdp_change = self.rtp_proxy_session.on_caller_sdp_change
         ua.on_remote_sdp_change = self.rtp_proxy_session.on_callee_sdp_change
         body = body.getCopy()
         body.content += 'a=nortpproxy:yes\r\n'
         self.proxied = True
     ua.kaInterval = self.global_config['ka_orig']
     if parameters.has_key('group_timeout'):
         timeout, skipto = parameters['group_timeout']
         Timeout(self.group_expires, timeout, 1, skipto)
     ua.recvEvent(CCEventTry((cId + '-b2b_%d' % rnum, cGUID, cli, cld, body, auth, \
       parameters.get('caller_name', self.caller_name))))
     return ua
Beispiel #2
0
 def placeAnswer(self, args):
     cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData() #TODO: move to a subroutine
     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:
         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.acctA = RadiusAccounting(self.global_config, 'answer', send_start = self.global_config['start_acct_enable'])
         self.acctA.setParams(parameters.get('bill-to', self.username), parameters.get('bill-cli', cli), \
           parameters.get('bill-cld', cld), self.cGUID, self.cId, host, credit_time)
         print 'adding acct stop cb'
     else:
         self.acctA = FakeAccounting()
     ua = UA(self.global_config, self.recvEvent, user, passw, (host, port), credit_time, \
       (self.aConnA,), (self.aDisc,), (self.aDisc,), dead_cbs = (self.aDead,), \
       expire_time = expires, no_progress_time = no_progress_expires, \
       extra_headers = parameters.get('extra_headers', None))
     if self.rtp_proxy_session and parameters.get('rtpp', True):
         print 'placeAnswer() registering on sdp change callbacks'
         ua.on_local_sdp_change = self.rtp_proxy_session.on_callee_sdp_change
         ua.on_remote_sdp_change = self.rtp_proxy_session.on_caller_sdp_change
         body = body.getCopy()
         body.content += 'a=nortpproxy:yes\r\n'
         self.proxied = True
     ua.kaInterval = self.global_config['ka_ans'] #TODO: is this okay for uaA?
     if parameters.has_key('group_timeout'):
         timeout, skipto = parameters['group_timeout']
         Timeout(self.group_expires, timeout, 1, skipto)
     ua.recvEvent(CCEventTry((cId + '-b2b_%d' % rnum, cGUID, cli, cld, body, auth, \
       parameters.get('caller_name', self.caller_name))))
     return ua