Hello,
I am trying to set up a WebRTC2SIP Gateway by using Kamailio and rtpengine. So far, everything is working fine, I'm able to register an extension and make a call, but for some reason, when i'm trying to call a WebRTC extension from any SIP Extension Kamailio is sending INVITE, WebRTC extension is sending back 200 OK, and then Kamailio is trying to send an ACK through UDP protocol, and not through wss, as it's supposed to do. This is how invite is looking:
INVITE sip:nl7oe4ss@vjbh7r4im6j7.invalid;transport=wss SIP/2.0 Record-Route: sip:my-company.net ;transport=udp;ftag=as1789445c;lr=on;nat=yes Via: SIP/2.0/WSS 123.123.123.123:10443 ;branch=z9hG4bKe655.29d7c135a302f3eb803902d4f5a8da7e.0 Via: SIP/2.0/UDP 192.168.50.237:5060 ;received=192.168.50.237;branch=z9hG4bK7d2e534e;rport=5060 Max-Forwards: 70 From: "WebRTC" sip:11@my-company.net;tag=as1789445c To: sip:15@192.168.50.210:5060 Contact: sip:11@192.168.50.237:5060 Call-ID: 7fc800de060197fa2315c93763873092@my-company.net CSeq: 102 INVITE User-Agent: Proxy Date: Wed, 03 Apr 2019 17:11:41 GMT Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE Supported: replaces, timer Alert-Info: Content-Type: application/sdp Content-Length: 596 Server: SIP Proxy
and then WebRTC app is replying with 200 OK:
SIP/2.0 200 OK Record-Route: sip:my-company.net ;transport=udp;ftag=as1789445c;lr=on;nat=yes Via: SIP/2.0/WSS 123.123.123.123:10443 ;branch=z9hG4bKe655.29d7c135a302f3eb803902d4f5a8da7e.0 Via: SIP/2.0/UDP 192.168.50.237:5060 ;received=192.168.50.237;branch=z9hG4bK7d2e534e;rport=5060 To: sip:15@192.168.50.210:5060;tag=dk4fa8ftt6 From: "WebRTC" sip:11@my-company.net;tag=as1789445c Call-ID: 7fc800de060197fa2315c93763873092@my-company.net CSeq: 102 INVITE Contact: sip:nl7oe4ss@vjbh7r4im6j7.invalid;transport=wss Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER Supported: outbound User-Agent: Proxy-WEBRTC Content-Type: application/sdp Content-Length: 901
and finally, Kamailio is trying to send this ack through UDP protocol:
ACK sip:nl7oe4ss@22.22.22.22:57421;transport=wss SIP/2.0 Via: SIP/2.0/UDP 192.168.50.237:5060;branch=z9hG4bK56363ddf;rport Route: sip:my-company.net;transport=udp;ftag=as1789445c;lr=on;nat=yes Max-Forwards: 70 From: "WebRTC" sip:11@my-company.net;tag=as1789445c To: sip:15@192.168.50.210:5060;tag=dk4fa8ftt6 Contact: sip:11@192.168.50.237:5060 Call-ID: 7fc800de060197fa2315c93763873092@my-company.net CSeq: 102 ACK User-Agent: Proxy Content-Length: 0
If i'm trying to force it through TLS, i'm receiving error: get_send_socket2(): protocol/port mismatch (forced tls:123.123.123.123:10443, to udp:22.22.22.22:23317)
Can someone point me in the right direction, please? Thank you.
Can you share your config file?
From: sr-users [mailto:sr-users-bounces@lists.kamailio.org] On Behalf Of Ilie Soltanici Sent: quarta-feira, 3 de abril de 2019 14:34 To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] WebRTC ACK Protocol
Hello,
I am trying to set up a WebRTC2SIP Gateway by using Kamailio and rtpengine. So far, everything is working fine, I'm able to register an extension and make a call, but for some reason, when i'm trying to call a WebRTC extension from any SIP Extension Kamailio is sending INVITE, WebRTC extension is sending back 200 OK, and then Kamailio is trying to send an ACK through UDP protocol, and not through wss, as it's supposed to do. This is how invite is looking:
INVITE sip:nl7oe4ss@vjbh7r4im6j7.invalid;transport=wss SIP/2.0
Record-Route: <sip:my-company.net http://my-company.net ;transport=udp;ftag=as1789445c;lr=on;nat=yes>
Via: SIP/2.0/WSS 123.123.123.123:10443;branch=z9hG4bKe655.29d7c135a302f3eb803902d4f5a8da7e.0
Via: SIP/2.0/UDP 192.168.50.237:5060;received=192.168.50.237;branch=z9hG4bK7d2e534e;rport=5060
Max-Forwards: 70
From: "WebRTC" <sip:11@my-company.net mailto:sip%3A11@my-company.net >;tag=as1789445c
To: <sip:15@192.168.50.210:5060 http://sip:15@192.168.50.210:5060 >
Contact: <sip:11@192.168.50.237:5060 http://sip:11@192.168.50.237:5060 >
Call-ID: 7fc800de060197fa2315c93763873092@my-company.net mailto:7fc800de060197fa2315c93763873092@my-company.net
CSeq: 102 INVITE
User-Agent: Proxy
Date: Wed, 03 Apr 2019 17:11:41 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Alert-Info:
Content-Type: application/sdp
Content-Length: 596
Server: SIP Proxy
and then WebRTC app is replying with 200 OK:
SIP/2.0 200 OK
Record-Route: <sip:my-company.net http://my-company.net ;transport=udp;ftag=as1789445c;lr=on;nat=yes>
Via: SIP/2.0/WSS 123.123.123.123:10443;branch=z9hG4bKe655.29d7c135a302f3eb803902d4f5a8da7e.0
Via: SIP/2.0/UDP 192.168.50.237:5060;received=192.168.50.237;branch=z9hG4bK7d2e534e;rport=5060
To: <sip:15@192.168.50.210:5060 http://sip:15@192.168.50.210:5060 >;tag=dk4fa8ftt6
From: "WebRTC" <sip:11@my-company.net mailto:sip%3A11@my-company.net >;tag=as1789445c
Call-ID: 7fc800de060197fa2315c93763873092@my-company.net mailto:7fc800de060197fa2315c93763873092@my-company.net
CSeq: 102 INVITE
Contact: sip:nl7oe4ss@vjbh7r4im6j7.invalid;transport=wss
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound
User-Agent: Proxy-WEBRTC
Content-Type: application/sdp
Content-Length: 901
and finally, Kamailio is trying to send this ack through UDP protocol:
ACK sip:nl7oe4ss@22.22.22.22:57421;transport=wss SIP/2.0
Via: SIP/2.0/UDP 192.168.50.237:5060;branch=z9hG4bK56363ddf;rport
Route: <sip:my-company.net http://my-company.net ;transport=udp;ftag=as1789445c;lr=on;nat=yes>
Max-Forwards: 70
From: "WebRTC" <sip:11@my-company.net mailto:sip%3A11@my-company.net >;tag=as1789445c
To: <sip:15@192.168.50.210:5060 http://sip:15@192.168.50.210:5060 >;tag=dk4fa8ftt6
Contact: <sip:11@192.168.50.237:5060 http://sip:11@192.168.50.237:5060 >
Call-ID: 7fc800de060197fa2315c93763873092@my-company.net mailto:7fc800de060197fa2315c93763873092@my-company.net
CSeq: 102 ACK
User-Agent: Proxy
Content-Length: 0
If i'm trying to force it through TLS, i'm receiving error:
get_send_socket2(): protocol/port mismatch (forced tls:123.123.123.123:10443 http://123.123.123.123:10443 , to udp:22.22.22.22:23317 http://22.22.22.22:23317 )
Can someone point me in the right direction, please?
Thank you.
Hello,
Config is more or less like the standard one:
route[WITHINDLG] { if (!has_totag()) return; if (loose_route()) { route(RURIALIAS); if ( is_method("ACK") ) { xlogl("L_INFO", "[$cfg(route)] ACK is forwarded statelessy\n"); route(NATMANAGE); } else if (is_method("NOTIFY") ) { # Add Record-Route for in-dialog NOTIFY as per RFC 6665. route(RECORD_ROUTE); } xlogl("L_INFO", "[$cfg(route)] In Dialog loose_route, Relaying\n"); route(RELAY); exit; };
if (is_method("SUBSCRIBE") && uri == myself) { xlogl("L_INFO", "[$cfg(route)] in-dialog subscribe requests, Checking Dialog.\n"); route(PRESENCE); exit; }
if ( is_method("ACK") ) { if ( t_check_trans() ) { xlogl("L_INFO", "[$cfg(route)] ACK in transaction. Relaying\n"); route(RELAY); exit; } else { xlogl("L_WARN", "[$cfg(route)] ACK without matching transaction ... ignore and discard\n"); sl_send_reply("606", "Not Acceptable"); exit; } }
xlogl("L_WARN", "[$cfg(route)] Unknown Dialog\n"); sl_send_reply("404","Not Found"); exit; }
route[RURIALIAS] { if(isdsturiset() || ($du != "")) { xlogl("L_INFO", "[$cfg(route)]: Destination URI is set, no un-aliasing is needed\n"); return; }
xlogl("L_INFO", "[$cfg(route)] --Start Route--\n"); xlogl("L_INFO", "[$cfg(route)]: Route using R-URI, any alias on R-URI ('$ru')?\n");
handle_ruri_alias(); switch ($rc) { case -1: xlogl("L_WARN", "[$cfg(route)]: Failed to handle alias of R-URI $ru\n"); send_reply("400","Bad Request"); exit; case 1: xlogl("L_INFO", "[$cfg(route)]: Alias parsed, routing $rm from $fu to $du\n"); break; case 2: xlogl("L_INFO", "[$cfg(route)]: Alias not found, routing $rm from $fu to $ru\n"); break; };
return; }
route[NATMANAGE] { if(has_body("application/sdp")) { route(RTPMANAGE); }
# Set FLB_NATB? Only in within-dialog request with nat=yes on Route header initiated by AS if (is_request() && has_totag() && check_route_param("nat=yes") && isflagset(FLS_FROM_ASTERISK)) { setbflag(FLB_NATB); }
# Return unless FLT_NATS or FLB_NATB are set if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) { xlogl("L_INFO", "[$cfg(route)] No endpoint is behind NAT, return\n"); if(nat_uac_test("1")) { xlogl("L_INFO", "[$cfg(route)] Contact is behind NAT, Fixing\n"); fix_nated_contact(); } return; } else { xlogl("L_INFO", "[$cfg(route)] One or both endpoints are behind NAT, continue!\n"); }
# Add nat=yes in record-route? Only in initial requests when called from branch_route if (is_request() && !has_totag() && t_is_branch_route()) { xlogl("L_INFO", "[$cfg(route)] Add nat=yes to record-route (reason: initial request called from branch route)\n"); add_rr_param(";nat=yes"); }
if (is_reply()) { if(isbflagset(FLB_NATB)) { fix_nated_contact(); } } }
route[RELAY] { route(SETUP_BY_TRANSPORT);
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) { if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH"); } if (is_method("INVITE|SUBSCRIBE|UPDATE")) { if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY"); } if (is_method("INVITE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); }
if (!t_relay()) { sl_reply_error(); } exit; }
}
route[SETUP_BY_TRANSPORT] {
if ($ru =~ "transport=ws") { xlogl("L_INFO","[$cfg(route)] Request going to WS"); if(sdp_with_transport("RTP/SAVPF")) { xlogl("L_INFO","[$cfg(route)] Request going from WS to WS"); rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); t_on_reply("REPLY_WS_TO_WS"); return; } xlogl("L_INFO","[$cfg(route)] Request going to WS from AS"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF"); force_send_socket(tls:MY_EXTERNAL_IP_ADDR:10443); t_on_reply("REPLY_FROM_WS"); } else if ($proto =~ "ws") { xlog("L_INFO", "Request coming from WS"); rtpengine_manage("rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP"); t_on_reply("REPLY_TO_WS"); } else { xlog("L_INFO", "This is a classic phone call"); rtpengine_manage("replace-origin replace-session-connection"); t_on_reply("MANAGE_CLASSIC_REPLY"); } }
onreply_route[REPLY_TO_WS] {
xlog("L_INFO", "Reply from softphone: $rs");
if (t_check_status("183")) { change_reply_status("180", "Ringing"); remove_body(); exit; }
if(!(status=~"[12][0-9][0-9]")) return;
# rtpengine_manage("froc+SP"); xlogl("L_INFO","Fixing ICE/SAVPF Parameters"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF");
}
onreply_route[REPLY_FROM_WS] {
xlog("L_INFO", "Reply from webrtc client: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=remove RTP/AVP"); # rtpengine_manage("froc-sp"); route(NATMANAGE); } }
onreply_route[MANAGE_CLASSIC_REPLY] { xlog("L_INFO", "Boring reply from softphone: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("replace-origin replace-session-connection"); # rtpengine_manage("co"); route(NATMANAGE); } }
onreply_route[REPLY_WS_TO_WS] { xlog("L_INFO", "WS to WS"); if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); route(NATMANAGE); } }
Thank you.
Adding Contact alias in 200 OK, fixed the issue:
if (nat_uac_test(64)) { add_contact_alias(); }
Thank You.
În mie., 3 apr. 2019 la 23:58, Ilie Soltanici iliusha.md@gmail.com a scris:
Hello,
Config is more or less like the standard one:
route[WITHINDLG] { if (!has_totag()) return; if (loose_route()) { route(RURIALIAS); if ( is_method("ACK") ) { xlogl("L_INFO", "[$cfg(route)] ACK is forwarded statelessy\n"); route(NATMANAGE); } else if (is_method("NOTIFY") ) { # Add Record-Route for in-dialog NOTIFY as per RFC 6665. route(RECORD_ROUTE); } xlogl("L_INFO", "[$cfg(route)] In Dialog loose_route, Relaying\n"); route(RELAY); exit; };
if (is_method("SUBSCRIBE") && uri == myself) { xlogl("L_INFO", "[$cfg(route)] in-dialog subscribe requests,
Checking Dialog.\n"); route(PRESENCE); exit; }
if ( is_method("ACK") ) { if ( t_check_trans() ) { xlogl("L_INFO", "[$cfg(route)] ACK in transaction. Relaying\n"); route(RELAY); exit; } else { xlogl("L_WARN", "[$cfg(route)] ACK without matching transaction
... ignore and discard\n"); sl_send_reply("606", "Not Acceptable"); exit; } }
xlogl("L_WARN", "[$cfg(route)] Unknown Dialog\n"); sl_send_reply("404","Not Found"); exit;
}
route[RURIALIAS] { if(isdsturiset() || ($du != "")) { xlogl("L_INFO", "[$cfg(route)]: Destination URI is set, no un-aliasing is needed\n"); return; }
xlogl("L_INFO", "[$cfg(route)] --Start Route--\n"); xlogl("L_INFO", "[$cfg(route)]: Route using R-URI, any alias on R-URI
('$ru')?\n");
handle_ruri_alias(); switch ($rc) { case -1: xlogl("L_WARN", "[$cfg(route)]: Failed to handle alias of R-URI
$ru\n"); send_reply("400","Bad Request"); exit; case 1: xlogl("L_INFO", "[$cfg(route)]: Alias parsed, routing $rm from $fu to $du\n"); break; case 2: xlogl("L_INFO", "[$cfg(route)]: Alias not found, routing $rm from $fu to $ru\n"); break; };
return;
}
route[NATMANAGE] { if(has_body("application/sdp")) { route(RTPMANAGE); }
# Set FLB_NATB? Only in within-dialog request with nat=yes on Route
header initiated by AS if (is_request() && has_totag() && check_route_param("nat=yes") && isflagset(FLS_FROM_ASTERISK)) { setbflag(FLB_NATB); }
# Return unless FLT_NATS or FLB_NATB are set if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) { xlogl("L_INFO", "[$cfg(route)] No endpoint is behind NAT,
return\n"); if(nat_uac_test("1")) { xlogl("L_INFO", "[$cfg(route)] Contact is behind NAT, Fixing\n"); fix_nated_contact(); } return; } else { xlogl("L_INFO", "[$cfg(route)] One or both endpoints are behind NAT, continue!\n"); }
# Add nat=yes in record-route? Only in initial requests when called
from branch_route if (is_request() && !has_totag() && t_is_branch_route()) { xlogl("L_INFO", "[$cfg(route)] Add nat=yes to record-route (reason: initial request called from branch route)\n"); add_rr_param(";nat=yes"); }
if (is_reply()) { if(isbflagset(FLB_NATB)) { fix_nated_contact(); } } }
route[RELAY] { route(SETUP_BY_TRANSPORT);
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) { if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH"); } if (is_method("INVITE|SUBSCRIBE|UPDATE")) { if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY"); } if (is_method("INVITE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); }
if (!t_relay()) { sl_reply_error(); } exit; }
}
route[SETUP_BY_TRANSPORT] {
if ($ru =~ "transport=ws") { xlogl("L_INFO","[$cfg(route)] Request going to WS"); if(sdp_with_transport("RTP/SAVPF")) { xlogl("L_INFO","[$cfg(route)] Request going from WS to WS"); rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); t_on_reply("REPLY_WS_TO_WS"); return; } xlogl("L_INFO","[$cfg(route)] Request going to WS from AS"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF"); force_send_socket(tls:MY_EXTERNAL_IP_ADDR:10443); t_on_reply("REPLY_FROM_WS"); } else if ($proto =~ "ws") { xlog("L_INFO", "Request coming from WS"); rtpengine_manage("rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP"); t_on_reply("REPLY_TO_WS"); } else { xlog("L_INFO", "This is a classic phone call"); rtpengine_manage("replace-origin replace-session-connection"); t_on_reply("MANAGE_CLASSIC_REPLY"); } }
onreply_route[REPLY_TO_WS] {
xlog("L_INFO", "Reply from softphone: $rs");
if (t_check_status("183")) { change_reply_status("180", "Ringing"); remove_body(); exit; }
if(!(status=~"[12][0-9][0-9]")) return;
# rtpengine_manage("froc+SP"); xlogl("L_INFO","Fixing ICE/SAVPF Parameters"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF");
}
onreply_route[REPLY_FROM_WS] {
xlog("L_INFO", "Reply from webrtc client: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=remove RTP/AVP"); # rtpengine_manage("froc-sp"); route(NATMANAGE); } }
onreply_route[MANAGE_CLASSIC_REPLY] { xlog("L_INFO", "Boring reply from softphone: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("replace-origin replace-session-connection"); # rtpengine_manage("co"); route(NATMANAGE); } }
onreply_route[REPLY_WS_TO_WS] { xlog("L_INFO", "WS to WS"); if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); route(NATMANAGE); } }
Thank you.
Hi, Just a suggestion to put the contact alias function under the "is_first_hop()" condition. That'll help you in case multiple Kamailios are in the call path.
if(is_first_hop()){ add_contact_alias(); }
Regards, Sammy
On Thu, Apr 4, 2019 at 6:07 AM Ilie Soltanici iliusha.md@gmail.com wrote:
Adding Contact alias in 200 OK, fixed the issue:
if (nat_uac_test(64)) { add_contact_alias(); }
Thank You.
În mie., 3 apr. 2019 la 23:58, Ilie Soltanici iliusha.md@gmail.com a scris:
Hello,
Config is more or less like the standard one:
route[WITHINDLG] { if (!has_totag()) return; if (loose_route()) { route(RURIALIAS); if ( is_method("ACK") ) { xlogl("L_INFO", "[$cfg(route)] ACK is forwarded statelessy\n"); route(NATMANAGE); } else if (is_method("NOTIFY") ) { # Add Record-Route for in-dialog NOTIFY as per RFC 6665. route(RECORD_ROUTE); } xlogl("L_INFO", "[$cfg(route)] In Dialog loose_route, Relaying\n"); route(RELAY); exit; };
if (is_method("SUBSCRIBE") && uri == myself) { xlogl("L_INFO", "[$cfg(route)] in-dialog subscribe requests,
Checking Dialog.\n"); route(PRESENCE); exit; }
if ( is_method("ACK") ) { if ( t_check_trans() ) { xlogl("L_INFO", "[$cfg(route)] ACK in transaction. Relaying\n"); route(RELAY); exit; } else { xlogl("L_WARN", "[$cfg(route)] ACK without matching transaction
... ignore and discard\n"); sl_send_reply("606", "Not Acceptable"); exit; } }
xlogl("L_WARN", "[$cfg(route)] Unknown Dialog\n"); sl_send_reply("404","Not Found"); exit;
}
route[RURIALIAS] { if(isdsturiset() || ($du != "")) { xlogl("L_INFO", "[$cfg(route)]: Destination URI is set, no un-aliasing is needed\n"); return; }
xlogl("L_INFO", "[$cfg(route)] --Start Route--\n"); xlogl("L_INFO", "[$cfg(route)]: Route using R-URI, any alias on R-URI
('$ru')?\n");
handle_ruri_alias(); switch ($rc) { case -1: xlogl("L_WARN", "[$cfg(route)]: Failed to handle alias of R-URI
$ru\n"); send_reply("400","Bad Request"); exit; case 1: xlogl("L_INFO", "[$cfg(route)]: Alias parsed, routing $rm from $fu to $du\n"); break; case 2: xlogl("L_INFO", "[$cfg(route)]: Alias not found, routing $rm from $fu to $ru\n"); break; };
return;
}
route[NATMANAGE] { if(has_body("application/sdp")) { route(RTPMANAGE); }
# Set FLB_NATB? Only in within-dialog request with nat=yes on Route
header initiated by AS if (is_request() && has_totag() && check_route_param("nat=yes") && isflagset(FLS_FROM_ASTERISK)) { setbflag(FLB_NATB); }
# Return unless FLT_NATS or FLB_NATB are set if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) { xlogl("L_INFO", "[$cfg(route)] No endpoint is behind NAT,
return\n"); if(nat_uac_test("1")) { xlogl("L_INFO", "[$cfg(route)] Contact is behind NAT, Fixing\n"); fix_nated_contact(); } return; } else { xlogl("L_INFO", "[$cfg(route)] One or both endpoints are behind NAT, continue!\n"); }
# Add nat=yes in record-route? Only in initial requests when called
from branch_route if (is_request() && !has_totag() && t_is_branch_route()) { xlogl("L_INFO", "[$cfg(route)] Add nat=yes to record-route (reason: initial request called from branch route)\n"); add_rr_param(";nat=yes"); }
if (is_reply()) { if(isbflagset(FLB_NATB)) { fix_nated_contact(); } } }
route[RELAY] { route(SETUP_BY_TRANSPORT);
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) { if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH"); } if (is_method("INVITE|SUBSCRIBE|UPDATE")) { if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY"); } if (is_method("INVITE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); }
if (!t_relay()) { sl_reply_error(); } exit; }
}
route[SETUP_BY_TRANSPORT] {
if ($ru =~ "transport=ws") { xlogl("L_INFO","[$cfg(route)] Request going to WS"); if(sdp_with_transport("RTP/SAVPF")) { xlogl("L_INFO","[$cfg(route)] Request going from WS to WS"); rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); t_on_reply("REPLY_WS_TO_WS"); return; } xlogl("L_INFO","[$cfg(route)] Request going to WS from AS"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF"); force_send_socket(tls:MY_EXTERNAL_IP_ADDR:10443); t_on_reply("REPLY_FROM_WS"); } else if ($proto =~ "ws") { xlog("L_INFO", "Request coming from WS"); rtpengine_manage("rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP"); t_on_reply("REPLY_TO_WS"); } else { xlog("L_INFO", "This is a classic phone call"); rtpengine_manage("replace-origin replace-session-connection"); t_on_reply("MANAGE_CLASSIC_REPLY"); } }
onreply_route[REPLY_TO_WS] {
xlog("L_INFO", "Reply from softphone: $rs");
if (t_check_status("183")) { change_reply_status("180", "Ringing"); remove_body(); exit; }
if(!(status=~"[12][0-9][0-9]")) return;
# rtpengine_manage("froc+SP"); xlogl("L_INFO","Fixing ICE/SAVPF Parameters"); rtpengine_manage("rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF");
}
onreply_route[REPLY_FROM_WS] {
xlog("L_INFO", "Reply from webrtc client: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=remove RTP/AVP"); # rtpengine_manage("froc-sp"); route(NATMANAGE); } }
onreply_route[MANAGE_CLASSIC_REPLY] { xlog("L_INFO", "Boring reply from softphone: $rs");
if(status=~"[12][0-9][0-9]") { rtpengine_manage("replace-origin replace-session-connection"); # rtpengine_manage("co"); route(NATMANAGE); } }
onreply_route[REPLY_WS_TO_WS] { xlog("L_INFO", "WS to WS"); if(status=~"[12][0-9][0-9]") { rtpengine_manage("force trust-address replace-origin replace-session-connection ICE=force"); route(NATMANAGE); } }
Thank you.
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users