[Devel] [patch] Nathelper - very minor bug

Glenn Dalgliesh glenn at routerboy.com
Wed Oct 12 21:58:02 CEST 2005


 I don't think this is a bug I think you are trying to apply fix_nated_sdp 
to all sip messages and not just the ones with SDP in them. For example you 
need to apply to INVITE & Session Progess but not trying OK and TRYING.
You need to pair down the messages that it gets applied to using if 
statements. Below is an example of one way to do this....

FYI: I think we meet at astricon last year in Atlanta. I work with David 
Troy, founder or ToadNet

 if(nat_uac_test("3"))
 {
  if((method == "REGISTER") || !(search("^Record-Route:")))
  {
   log("LOG:Someone trying to register from private IP, rewriting\n");

   fix_nated_contact();
   if(method == "INVITE")
   {
    fix_nated_sdp("1");
    force_rtp_proxy();
    t_on_reply("1");
   };
   force_rport();
   setflag(6);
  };
 };


onreply_route[1]
{
 if(status =~ "(183)|2[0-9][0-9]")
 {
  fix_nated_contact();
  force_rtp_proxy();
 };
}



1.5.2. fix_nated_sdp(mode)
Alters the SDP information in orer to facilitate NAT traversal. What changes 
to be performed may be controled via the "parameter".

The parameter value may be a bitwise OR of the following flags:


  a.. 0x01 - adds "a=direction:active" SDP line;

  b.. 0x02 - rewrite media IP address (c=) with source address of the 
message.

  c.. 0x04 - adds "a=nortpproxy:yes" SDP line;

  d.. 0x08 - rewrite IP from origin description (o=) with source address of 
the message.

Example 1-13. fix_nated_sdp usage

...
if (search("User-Agent: Cisco ATA.*") {fix_nated_sdp("3");};
...----- Original Message ----- 
From: "John Riordan" <john at junctionnetworks.com>
To: <devel at openser.org>
Cc: <john at junctionnetworks.com>
Sent: Saturday, October 08, 2005 10:48 AM
Subject: [Devel] [patch] Nathelper - very minor bug


> Hi,
>
> extract_mediaip is currently logging failure to find a c= line
> as an ERROR. However, the way this function is used (in replace_sdp_ip
> and elsewhere) the expectation is that failure may not be an ERROR,
> but simply an indication that all c= lines have been dealt with.
>
> The upshot is that an ERROR is getting logged whenever fix_nated_sdp
> is used - regardless of there being a c= line in the SDP or not.
>
> The error looks like:
>
> Oct  8 09:58:34 host /usr/local/sbin/openser[10370]: ERROR: 
> extract_mediaip: no `c=' in SDP
>
> The attached patch is simply changes the logged message to DBG.
>
> Regards,
>
> John
>


--------------------------------------------------------------------------------


> --- modules/nathelper/nathelper.c.~1.5.~ 2005-07-15 
> 00:26:56.000000000 -0400
> +++ modules/nathelper/nathelper.c 2005-10-08 10:14:59.252490355 -0400
> @@ -1020,7 +1020,7 @@
>  cp = cp1 + 2;
>  }
>  if (cp1 == NULL) {
> - LOG(L_ERR, "ERROR: extract_mediaip: no `%s' in SDP\n",line);
> + LOG(L_DBG, "DEBUG: extract_mediaip: no `%s' in SDP\n",line);
>  return -1;
>  }
>  mediaip->s = cp1 + 2;
>


--------------------------------------------------------------------------------


> _______________________________________________
> Devel mailing list
> Devel at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/devel
> 




More information about the Devel mailing list