本文整理汇总了Python中KSR.setflag方法的典型用法代码示例。如果您正苦于以下问题:Python KSR.setflag方法的具体用法?Python KSR.setflag怎么用?Python KSR.setflag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KSR
的用法示例。
在下文中一共展示了KSR.setflag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ksr_route_natdetect
# 需要导入模块: import KSR [as 别名]
# 或者: from KSR import setflag [as 别名]
def ksr_route_natdetect(self, msg):
KSR.force_rport();
if KSR.nathelper.nat_uac_test(19)>0 :
if KSR.pv.get("$rm")=="REGISTER" :
KSR.nathelper.fix_nated_register();
elif KSR.siputils.is_first_hop()>0 :
KSR.nathelper.set_contact_alias();
KSR.setflag(FLT_NATS);
return 1;
示例2: ksr_route_location
# 需要导入模块: import KSR [as 别名]
# 或者: from KSR import setflag [as 别名]
def ksr_route_location(self, msg):
rc = KSR.registrar.lookup("location");
if rc<0 :
KSR.tm.t_newtran();
if rc==-1 or rc==-3 :
KSR.sl.send_reply(404, "Not Found");
return -255;
elif rc==-2 :
KSR.sl.send_reply(405, "Method Not Allowed");
return -255;
# when routing via usrloc, log the missed calls also
if KSR.pv.get("$rm")=="INVITE" :
KSR.setflag(FLT_ACCMISSED);
self.ksr_route_relay(msg);
return -255;
示例3: ksr_route_withindlg
# 需要导入模块: import KSR [as 别名]
# 或者: from KSR import setflag [as 别名]
def ksr_route_withindlg(self, msg):
if KSR.siputils.has_totag()<0 :
return 1;
# sequential request withing a dialog should
# take the path determined by record-routing
if KSR.rr.loose_route()>0 :
if self.ksr_route_dlguri(msg)==-255 :
return -255;
if KSR.pv.get("$rm")=="BYE" :
# do accounting ...
KSR.setflag(FLT_ACC);
# ... even if the transaction fails
KSR.setflag(FLT_ACCFAILED);
elif KSR.pv.get("$rm")=="ACK" :
# ACK is forwarded statelessly
if self.ksr_route_natmanage(msg)==-255 :
return -255;
elif KSR.pv.get("$rm")=="NOTIFY" :
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
KSR.rr.record_route();
self.ksr_route_relay(msg);
return -255;
if KSR.pv.get("$rm")=="ACK" :
if KSR.tm.t_check_trans() >0 :
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
self.ksr_route_relay(msg);
return -255;
else:
# ACK without matching transaction ... ignore and discard
return -255;
KSR.sl.sl_send_reply(404, "Not here");
return -255;
示例4: ksr_request_route
# 需要导入模块: import KSR [as 别名]
# 或者: from KSR import setflag [as 别名]
def ksr_request_route(self, msg):
# KSR.info("===== request - from kamailio python script\n");
# KSR.info("===== method [%s] r-uri [%s]\n" % (KSR.pv.get("$rm"),KSR.pv.get("$ru")));
# per request initial checks
if self.ksr_route_reqinit(msg)==-255 :
return 1;
# NAT detection
if self.ksr_route_natdetect(msg)==-255 :
return 1;
# CANCEL processing
if KSR.pv.get("$rm") == "CANCEL" :
if KSR.tm.t_check_trans()>0 :
self.ksr_route_relay(msg);
return 1;
# handle requests within SIP dialogs
if self.ksr_route_withindlg(msg)==-255 :
return 1;
# -- only initial requests (no To tag)
# handle retransmissions
if KSR.tmx.t_precheck_trans()>0 :
KSR.tm.t_check_trans();
return 1;
if KSR.tm.t_check_trans()==0 :
return 1;
# authentication
if self.ksr_route_auth(msg)==-255 :
return 1
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
KSR.hdr.remove("Route");
if "INVITE|SUBSCRIBE".find(KSR.pv.get("$rm"))!=-1 :
KSR.rr.record_route();
# account only INVITEs
if KSR.pv.get("$rm")=="INVITE" :
KSR.setflag(FLT_ACC); # do accounting
# dispatch requests to foreign domains
if self.ksr_route_sipout(msg)==-255 :
return 1;
# # requests for my local domains
# handle registrations
if self.ksr_route_registrar(msg)==-255 :
return 1;
if KSR.pv.is_null("$rU") :
# request with no Username in RURI
KSR.sl.sl_send_reply(484,"Address Incomplete");
return 1;
# user location service
self.ksr_route_location(msg);
return 1;