[OpenSIPS-Users] OpenSIPS as Teams SBC

James Hogbin james at ip-sentinel.com
Thu May 7 16:21:14 EST 2020


My set up

Teams <—> sbc.ip-sentinel.com <—> pbx.ip-sentinel.com

I can create a call with audio from Teams -> PBX
I can hang up that call from Teams but not the PBX
I cannot route a call from PBX to teams.  Although the initial TLS handshake does happen

I’m pretty sure it’s something basic to do with headers on ACK & BYE but I just cannot spot what I’ve done wrong

This is the initial outbound message from opensips to teams which looks OK

James Hogbin
Director 
 
IP Sentinel 
t. +44 (0)20 3011 4150
m. +44 7786910895
w. https://www.ip-sentinel.com

INVITE sip:+448435577721 at sip.pstnhub.microsoft.com:5061;transport=tls SIP/2.0
 Record-Route: <sip:sbc.ip-sentinel.com:5091;transport=tls;ftag=eect23Z290N9p;lr;r2=on>
 Record-Route: <sip:137.117.136.143:5060;ftag=eect23Z290N9p;lr;r2=on>
 Via: SIP/2.0/TLS 137.117.136.143:5091;branch=z9hG4bK48f8.81967713.0;i=e67586f7
 Via: SIP/2.0/TLS 13.80.245.144:5081;rport=41795;received=10.0.0.4;branch=z9hG4bKac61XQKeXDXHB
 Max-Forwards: 68
 From: "James Hogbin" <sip:opensips at 10.0.0.5:5091>;tag=eect23Z290N9p
 To: <sip:08435577721 at 10.0.0.5:5091>
 Call-ID: 0109ad37-0b1f-1239-bdba-000d3aada04e
 CSeq: 19879884 INVITE
 Contact: <sip:gw+c6ff36e8-d3de-4fe0-9f1b-9da2888c43a9 at 13.80.245.144:5081;transport=tls;transport=tls;gw=c6ff36e8-d3de-4fe0-9f1b-9da2888c43a9>
 User-Agent: FreeSWITCH
 Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
 Supported: timer, path, replaces
 Allow-Events: talk, hold, conference, refer
 Content-Type: application/sdp
 Content-Disposition: session
 Content-Length: 1339
 X-FS-Support: update_display,send_info
 Remote-Party-ID: "James Hogbin" <sip:+442030114146 at 10.0.0.5:5091>;party=calling;screen=yes;privacy=off
 #015
 v=0
 o=FreeSWITCH 1588835231 1588835232 IN IP4 137.117,136.143
 s=FreeSWITCH
 c=IN IP4 137.117,136.143
 t=0 0
 m=audio 10432 RTP/SAVP 9 0 8 101 13
 a=rtpmap:9 G722/8000
 a=rtpmap:0 PCMU/8000
 a=rtpmap:8 PCMA/8000
 a=rtpmap:101 telephone-event/8000
 a=fmtp:101 0-16
 a=rtpmap:13 CN/8000
[stuff removed]
 a=ptime:20
 m=audio 13446 RTP/AVP 9 0 8 101 13
 a=rtpmap:9 G722/8000
 a=rtpmap:0 PCMU/8000
 a=rtpmap:8 PCMA/8000
 a=rtpmap:101 telephone-event/8000
 a=fmtp:101 0-16
 a=rtpmap:13 CN/8000
 a=ptime:20
 a=nortpproxy:yes

opensips.cfg Source_address(0) is my PBX address= 

alias = tls:sbc.ip-sentinel.com:5091
alias = udp:sbc.ip-sentinel.com:5060
alias = tcp:sbc.ip-sentinel.com:5060
advertised_address=137.117.136.143
listen=udp:10.0.0.5:5060
listen=tcp:10.0.0.5:5060
listen=tls:10.0.0.5:5091

####### Routing Logic ########

# main request routing logic

route{
	#xlog("L_INFO", "route SIP Message $mb");
	force_rport();

	if (!mf_process_maxfwd_header(10)) {
		send_reply(483,"Too Many Hops");
		exit;
	}

	if (is_method("OPTIONS")) {
		#xlog("[MS TEAMS] OPTIONS In\n");
		send_reply(200, "OK");
		exit;
	}

	# CANCEL processing
	if (is_method("CANCEL")) {
		if (t_check_trans())
			t_relay();
		exit;
	}

	# absorb retransmissions, but do not create transaction
	t_check_trans();

	if (has_totag()) {

        # sequential request within a dialog should
        # take the path determined by record-routing

	if(is_method("INVITE") && !check_source_address(0)) {
            xlog("[INFO] In dialog Method=$rm, RURI=$ruri, SI=$si ,DU=$du\n");
            t_relay();
        }
        if ( !loose_route() ) {
            # we do record-routing for all our traffic, so we should not
            # receive any sequential requests without Route hdr.
	    send_reply(404, "Not here");
            exit;
        }
        # route it out to whatever destination was set by loose_route()
        # in $du (destination URI).
        route(relay);
        exit;
        }

	# account only INVITEs
	if (is_method("INVITE")) {
		do_accounting("log");
	}

	if (is_method("INVITE") && !has_totag() && check_source_address(0)) {
     		xlog("[ROUTE]Incoming call to MS: RURI=$ruri, SI=$si, M=$rm\n");
       		strip(1);
        	prefix("+44");
        	record_route_preset("sbc.ip-sentinel.com:5091;transport=tls", "137.117.136.143:5060");
        	add_rr_param(";r2=on");
                $rd="sip.pstnhub.microsoft.com";
                $rp=5061;
        	route(relay);
    	} else if (is_method("INVITE") && ! has_totag() && !check_source_address(0)) {
        	record_route();
        	xlog("[ROUTE]Incoming call from MS: RURI=$ruri, SI=$si, M=$rm\n");
        	$rd="pbx.ip-sentinel.com";
        	$rp=5081;
        	route(relay);
    	}

	if (!is_myself("$rd")) {
        	append_hf("P-hint: outbound\r\n");
       		route(relay);
	}

	# requests for my domain
	if (is_method("PUBLISH|SUBSCRIBE")) {
		send_reply(503, "Service Unavailable");
		exit;
	}

	if ($rU==NULL) {
		# request with no Username in RURI
		send_reply(484,"Address Incomplete");
		exit;
	}

	# do lookup with method filtering
	if (!lookup("location","m")) {
		t_reply(404, "Not Found");
		exit;
	}

	# when routing via usrloc, log the missed calls also
	do_accounting("log","missed");
	route(relay);
}

route[relay] {
	xlog("[INFO] route[relay] SIP Message \n$mb\n");
	# for INVITEs enable some additional helper routes
	if (is_method("INVITE") && ! has_totag() )  {

		t_newtran();
		t_on_reply("handle_nat");
		t_on_failure("missed_call");

		# if we have an application/sdp on our body, so we execute
                # the rtpproxy_offer
		if(has_body("application/sdp")){
			xlog("[RTPPROXY] route[relay] we have sdp on this message\n$rm\n");
			rtpproxy_offer("co", "137.117,136.143");
		}

	}

	xlog("[INFO] Method=$rm, RURI=$ruri, SI=$si ,DU=$du\n");
	if (!t_relay()) {
		send_reply(500,"Internal Error");
	}
	exit;
}

onreply_route[handle_nat] {
	xlog("[INFO] onreply_route[handle_nat]: RR=$rr, RS=$rs, SI=$si\n$mb\n");
	# we receive a reply, we need to check about application/sdp
        # on our body, if we have, we answer that
	if(is_method("ACK") && has_body("application/sdp")){
		xlog("[RTPPROXY] onreply_route[handle_nat] ACK rtpproxy_answer\n");
		rtpproxy_answer("co", "137.117,136.143");
	}
}

failure_route[missed_call] {
	if (t_was_cancelled()) {
		exit;
	}
}

local_route {
	$var(dst) = "pstnhub.microsoft.com";
    	if (is_method("OPTIONS") && ($(ru{s.index, $var(dst)}) != NULL)) {
        	append_hf("Contact: <sip:sbc.ip-sentinel.com:5091;transport=tls>\r\n");
                #xlog("[MS TEAMS] OPTIONS Out\n");
	}
}

IP Sentinel Disclaimer 
This communication is for the information of the person to whom it has been delivered and neither it nor any of its contents should be passed on to or used by any other person. IP Sentinel Ltd is a limited company registered in England and Wales under Registered Number 08648097. Registered Office: Newnhams Wood, Horsted Keynes, West Sussex, RH17 7BT. 
Disclaimer: Q3dhRSrm_disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200507/9a1536c7/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 120050717211700129.png
Type: image/png
Size: 3317 bytes
Desc: not available
URL: <http://lists.opensips.org/pipermail/users/attachments/20200507/9a1536c7/attachment-0001.png>


More information about the Users mailing list