|
|
|
@ -79,37 +79,52 @@ route[PRESENCE_NAT_PING] |
|
|
|
{ |
|
|
|
$var(CallId) = $uuid(g); |
|
|
|
xlog("L_DEBUG", "$var(CallId)|$rtimer_worker|timer|SENDING PING FROM $(xavp(ra=>local_contact){uri.tosocket}) TO => $xavp(ra=>contact)\n"); |
|
|
|
t_uac_send("OPTIONS", "$xavp(ra=>contact)", "", "$(xavp(ra=>local_contact){uri.tosocket})", "CSeq: 1 OPTIONS\r\nFrom: PRESENCE_NAT_S_FROM_URI\r\nTo: $xavp(ra=>contact);nat_id=$xavp(ra=>id)\r\nContact: <$xavp(ra=>local_contact)>\r\nCall-ID: $var(CallId)\r\n", ""); |
|
|
|
|
|
|
|
$uac_req(method)="OPTIONS"; |
|
|
|
$uac_req(hdrs) = "X-TM-Local: PRESENCE_ROUTE_NAT_PING\r\nX-TM-Contact: " + $xavp(ra=>local_contact) + "\r\n"; |
|
|
|
$uac_req(turi) = $xavp(ra=>contact); |
|
|
|
$uac_req(ruri) = $xavp(ra=>contact); |
|
|
|
$uac_req(furi) = $_s(PRESENCE_NAT_S_FROM_URI;nat_id=$xavp(ra=>id)); |
|
|
|
$uac_req(ouri) = "sip:127.0.0.1:5090;transport=tcp"; |
|
|
|
$uac_req(callid) = $var(CallId); |
|
|
|
uac_req_send(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
onreply_route[PRESENCE_NAT_REPLY] |
|
|
|
{ |
|
|
|
xlog("L_DEBUG", "$ci|nat|NAT REPLY $(tu{nameaddr.uri})\n"); |
|
|
|
$var(Query) = $_s(UPDATE presence_nat SET selected = 0, time_sent = datetime('now') WHERE id = $(tu{uri.param,nat_id});); |
|
|
|
$var(Query) = $_s(UPDATE presence_nat SET selected = 0, time_sent = datetime('now') WHERE id = $(fu{uri.param,nat_id});); |
|
|
|
xlog("L_DEBUG", "$ci|nat|NAT UPDATE SQL => '$var(Query)'\n"); |
|
|
|
mq_add("presence_last_notity", "$uuid(g)", "$var(Query)"); |
|
|
|
t_drop(); |
|
|
|
} |
|
|
|
|
|
|
|
failure_route[PRESENCE_NAT_FAULT] |
|
|
|
{ |
|
|
|
xlog("L_WARNING", "$ci|nat|received error $T_reply_code $T_reply_reason from $(tu{nameaddr.uri})\n"); |
|
|
|
$var(Query) = $_s(DELETE FROM presence_nat WHERE id = $(tu{uri.param,nat_id});); |
|
|
|
$var(Query) = $_s(DELETE FROM presence_nat WHERE id = $(fu{uri.param,nat_id});); |
|
|
|
xlog("L_DEBUG", "$ci|nat|NAT REMOVE SQL => '$var(Query)'\n"); |
|
|
|
mq_add("presence_last_notity", "$uuid(g)", "$var(Query)"); |
|
|
|
t_drop(); |
|
|
|
} |
|
|
|
|
|
|
|
route[PRESENCE_LOCAL_REQ_NAT] |
|
|
|
route[PRESENCE_ROUTE_NAT_PING] |
|
|
|
{ |
|
|
|
#!ifdef NAT_TRAVERSAL_ROLE |
|
|
|
if($rm == "OPTIONS" && $fu == "PRESENCE_NAT_S_FROM_URI") { |
|
|
|
t_on_reply("PRESENCE_NAT_REPLY"); |
|
|
|
t_on_failure("PRESENCE_NAT_FAULT"); |
|
|
|
t_set_fr(0, PRESENCE_NAT_TIMEOUT); |
|
|
|
handle_ruri_alias(); |
|
|
|
record_route(); |
|
|
|
} |
|
|
|
#!endif |
|
|
|
return; |
|
|
|
$fs = $(hdr(X-TM-Contact){uri.tosocket}); |
|
|
|
remove_hf_re("^X-TM-Contact"); |
|
|
|
|
|
|
|
force_rport(); |
|
|
|
handle_ruri_alias(); |
|
|
|
record_route(); |
|
|
|
xlog("L_DEBUG", "$ci|local|sending nat keepalive from $fu to $ru => $du => $tu\n"); |
|
|
|
setflag(FLAG_LOCAL_ROUTE); |
|
|
|
|
|
|
|
t_on_reply("PRESENCE_NAT_REPLY"); |
|
|
|
t_on_failure("PRESENCE_NAT_FAULT"); |
|
|
|
t_set_fr(0, PRESENCE_NAT_TIMEOUT); |
|
|
|
|
|
|
|
t_relay(); |
|
|
|
} |
|
|
|
|
|
|
|
route[PRESENCE_NAT_ON_REGISTRATION] |
|
|
|
|