Recompile Asterisk in FreePBX distro to modify res_pjsip_nat.c for MS Teams Integration

Hi guys,

I need to integrate MS Teams with my freepbx and for that I need to recompile the asterisk to modify the res_pjsip_nat.c .

how to do it and is it safe to do it.

I don’t know any reason it wouldn’t be safe to compile your own.

Thanks for sharing.

I have done installing the Asterisk core on debian and compiled it’s headers for Pjsip_nat.c
I want to use it for FreePBX where we have a lot of options with respect to asterisk and I want to save my self for extensive coding.

That’s why I am looking to integrate FreePBX with MsTeams.

If any other suggestions available, your are more than welcome.

can we do this modification for res_pjsip_nat.c for MS Teams Integration in the Freepbx distro to integrate with MS Teams and use it via direct routing.

--- res/res_pjsip_nat.c	2021-12-09 17:44:54.000000000 +0100
+++ ../asterisk-18.9.0-modified/res/res_pjsip_nat.c	2022-01-02 22:28:30.399394130 +0100
@@ -445,7 +445,7 @@
 			pjsip_method_cmp(&cseq->method, &pjsip_register_method)) {
 			/* We can only rewrite the URI when one is present */
 			if (uri || (uri = nat_get_contact_sip_uri(tdata))) {
-				pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
+				pj_strdup2(tdata->pool, &uri->host, "my.teams.sbc.hostname");
 				if (transport->external_signaling_port) {
 					uri->port = transport->external_signaling_port;
 					ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port);
@@ -455,7 +455,7 @@
 		/* Update the via header if relevant */
 		if ((tdata->msg->type == PJSIP_REQUEST_MSG) && (via || (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL)))) {
-			pj_strdup2(tdata->pool, &via->, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
+			pj_strdup2(tdata->pool, &via->, "my.teams.sbc.hostname");
 			if (transport->external_signaling_port) {
 				via->sent_by.port = transport->external_signaling_port;

This is from one of the post who guide how to use MS Teams Direct Routing with asterisk. So I want to implement for FreePBX where I have the liberty to do much more than using a blank asterisk.

This is a feature request and I think the best way to submit feature requests is documented here.

What you are doing will work. but beware when m$ changes stuff it could break. I would suggest that you use a SBC that is on the approved List. Anynode for example costs a 100/ channel for a license fee.

Now if your not in an enterprise go for it. I just wouldn’t recommend it for real production usage where jobs are on the line.

for now I am just testing as lot of people around successfully integrated FreePBX and asterisk to work with MS Teams.

If you know any good guide which can elaborate the Freepbx PJSIP end to create a successful trunk with MS Teams. will be very helpful.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.