[OpenSER-Devel] disable media/nathelper

Daniel-Constantin Mierla daniel at voice-system.ro
Tue Jul 31 14:49:38 CEST 2007


Hello,

can you try the attached patch? (it is for devel version).  Should be a 
quick fix, more has to be investigated where is the right place to do it.

Cheers,
Daniel


On 07/25/07 22:02, Aymeric Moizard wrote:
>
> Hi,
>
> I'm facing an issue with my openser. I checked the latest SVN
> code and it seems my issue is not solved even in the svn version.
>
> My UA is sending an SDP with 2 m lines: one for audio
> and one for video. In a re-INVITE, I want to disable video
> and I'm sending m=video 0 RTP/AVP..
>
> My openser is currently modifying the port number for the
> video line even if it's 0 which means it's disabled...
>
> I was not able to find a clean fix in nathelper.c and hope
> to get some help for proposing one... I guess it would be
> something close to:
>   if (oldport==0)
>      skip altering ip/port for media and continue;
> but I don't want to insert any mem leak or lost session...
>
> tks,
> Aymeric MOIZARD / ANTISIP
> amsip - http://www.antisip.com
> osip2 - http://www.osip.org
> eXosip2 - http://savannah.nongnu.org/projects/exosip/
>
>
> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
>
-------------- next part --------------
Index: modules/nathelper/nathelper.c
===================================================================
--- modules/nathelper/nathelper.c	(revision 2553)
+++ modules/nathelper/nathelper.c	(working copy)
@@ -2574,12 +2574,21 @@
 				newip.s = (argc < 2) ? str2 : argv[1];
 				newip.len = strlen(newip.s);
 			}
+			/* marker to double check : newport goes: str -> int -> str ?!?! */
 			newport.s = int2str(port, &newport.len); /* beware static buffer */
 			/* Alter port. */
 			body1.s = m1p;
 			body1.len = bodylimit - body1.s;
-			if (alter_mediaport(msg, &body1, &oldport, &newport, 0) == -1)
-				return -1;
+			/* do not do it if old port was 0 (means media disable)
+			 * - check if actually should be better done in rtpptoxy,
+			 *   by returning also 0
+			 * - or by not sending to rtpproxy the old port if 0
+			 */
+			if(oldport.len!=1 || oldport.s[0]!='0')
+			{
+				if (alter_mediaport(msg, &body1, &oldport, &newport, 0) == -1)
+					return -1;
+			}
 			/*
 			 * Alter IP. Don't alter IP common for the session
 			 * more than once.


More information about the Devel mailing list