[asterisk-dev] Patch to enable specifying SDP RTP IP address

Jon Schøpzinsky jos at detele.dk
Mon Oct 16 08:59:36 MST 2006


Hello List

I just got into a problem, where, due to a firewall, had to specify the RTP source address in the SDP section, so I thought I would make it a general configurable feature.

I don't normally code in C, so that will probably show on my implementation, but here is the patch for Asterisk 1.2.12.1 in diff -u format. It seems to work beautifully.

--- chan_sip.c  2006-10-16 16:46:08.000000000 +0200
+++ chan_sip_old.c      2006-09-09 13:14:04.000000000 +0200
@@ -344,8 +344,6 @@

 static char default_fromdomain[AST_MAX_EXTENSION] = "";

-static char global_rtpip[AST_MAX_EXTENSION] = "";
-
 #define DEFAULT_NOTIFYMIME "application/simple-message-summary"
 static char default_notifymime[AST_MAX_EXTENSION] = DEFAULT_NOTIFYMIME;

@@ -366,7 +364,6 @@

 static int relaxdtmf = 0;

-
 static int global_rtptimeout = 0;

 static int global_rtpholdtimeout = 0;
@@ -4489,19 +4486,11 @@
        /* We break with the "recommendation" and send our IP, in order that our
           peer doesn't have to ast_gethostbyname() us */

-       if(strlen(global_rtpip)>0) {
-               snprintf(v, sizeof(v), "v=0\r\n");
-               snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion,global_rtpip);
-               snprintf(s, sizeof(s), "s=session\r\n");
-               snprintf(c, sizeof(c), "c=IN IP4 %s\r\n",global_rtpip);
-               snprintf(t, sizeof(t), "t=0 0\r\n");
-       } else {
-               snprintf(v, sizeof(v), "v=0\r\n");
-               snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
-               snprintf(s, sizeof(s), "s=session\r\n");
-               snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
-               snprintf(t, sizeof(t), "t=0 0\r\n");
-       }
+       snprintf(v, sizeof(v), "v=0\r\n");
+       snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
+       snprintf(s, sizeof(s), "s=session\r\n");
+       snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
+       snprintf(t, sizeof(t), "t=0 0\r\n");

        ast_build_string(&m_audio_next, &m_audio_left, "m=audio %d RTP/AVP", ntohs(dest.sin_port));
        ast_build_string(&m_video_next, &m_video_left, "m=video %d RTP/AVP", ntohs(vdest.sin_port));
@@ -12660,8 +12649,6 @@
                                ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d.  Using default.\n", v->value, v->lineno);
                                global_rtpkeepalive = 0;
                        }
-               } else if (!strcasecmp(v->name, "rtpip")) {
-                       ast_copy_string(global_rtpip, v->value, sizeof(global_rtpip));
                } else if (!strcasecmp(v->name, "videosupport")) {
                        videosupport = ast_true(v->value);
                } else if (!strcasecmp(v->name, "compactheaders")) {

 
Kind Regards

Jon Leren Schøpzinsky

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.4/476 - Release Date: 14-10-2006
 


More information about the asterisk-dev mailing list