From daniel@voice-system.ro Mon Sep 4 12:24:02 2006 From: Daniel-Constantin Mierla To: sr-users@lists.kamailio.org Subject: Re: [Users] Configurable nathelper nortpproxy string Date: Mon, 04 Sep 2006 13:26:03 +0300 Message-ID: <44FBFF3B.6030106@voice-system.ro> In-Reply-To: <20060901185634.GQ15761@obiwan.tataz.chchile.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1874086651==" --===============1874086651== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello Jeremie, not to loose the patch, please register it to the tracker. http://sourceforge.net/tracker/?atid=3D743022&group_id=3D139143&func=3Dbrowse We will check it. Right now you can enable/disable "a=3Dnortpproxy:yes"=20 when using fix_nated_sdp(): http://www.openser.org/docs/modules/1.1.x/nathelper.html#AEN229 Cheers, Daniel On 09/01/06 21:56, Jeremie Le Hen wrote: > Hi list, > > I have made a small patch to the nathelper module, that allows to > configure the "a=3Dnortpproxy:yes\r\n" string. > > Basically, as noticed in user documentation, you can add this to your > configuration file, once the patch is applied and OpenSER recompiled : > > % modparam("nathelper", "nortpproxy_str", "a=3Dsdpmangled:yes") > > > I needed to do this because I have the following setup: > > SoftPhone1_ > \____ > ____NATing Proxy_______Registrar Proxy_______(outside) > _/ > SoftPhone2 > > > For some reason, the registrar also uses nathelper/rtpproxy. I first used > the "f" flag for force_rtp_proxy() in my NATing proxy, in order to > circumvent the nortpproxy flag that the registrar proxy has set. This > worked perfectly except if softphone1 tries to call softphone2. In this > case my NATing proxy would replace the SDP twice. With my patch, I simply > turn the nortpproxy string to something else that only my NATing proxy > cares about. > > Please, commit it if you find it worth enough. > > Thank you. > Best regards, > =20 > ------------------------------------------------------------------------ > > diff -urNp openser-1.1.0-notls/modules/nathelper/doc/nathelper_user.sgml op= enser-1.1.0-notls-nortpproxy_str/modules/nathelper/doc/nathelper_user.sgml > --- openser-1.1.0-notls/modules/nathelper/doc/nathelper_user.sgml 2006-06-0= 7 15:29:07.000000000 +0200 > +++ openser-1.1.0-notls-nortpproxy_str/modules/nathelper/doc/nathelper_user= .sgml 2006-09-01 20:31:53.000000000 +0200 > @@ -344,6 +344,26 @@ modparam("nathelper", "sipping_method",=20 > > > > +
> + <varname>nortpproxy_str</varname> (string) > + > + The parameter sets the SDP attribute used by nathelper to mark > + the packet SDP informations have already been mangled. > + > + > + > + Default value is a=3Dnortpproxy:yes\r\n. > + > + > + > + Set <varname>nortpproxy_str</varname> parameter > + > +... > +modparam("nathelper", "nortpproxy_str", "a=3Dsdpmangled:yes") > +... > + > + > +
> > =20 > =20 > diff -urNp openser-1.1.0-notls/modules/nathelper/nathelper.c openser-1.1.0-= notls-nortpproxy_str/modules/nathelper/nathelper.c > --- openser-1.1.0-notls/modules/nathelper/nathelper.c 2006-06-07 15:52:44.0= 00000000 +0200 > +++ openser-1.1.0-notls-nortpproxy_str/modules/nathelper/nathelper.c 2006-0= 9-01 20:31:47.000000000 +0200 > @@ -286,6 +286,15 @@ static pid_t mypid; > static unsigned int myseqn =3D 0; > static int rcv_avp_no =3D 42; > =20 > +/* > + * This should have been defined right above replace_sdp_ip() but > + * it is needed here. > + */ > +#define ANORTPPROXY "a=3Dnortpproxy:yes\r\n" > +#define ANORTPPROXY_LEN (sizeof(ANORTPPROXY) - 1) > +static str nortpproxy_str =3D { ANORTPPROXY, ANORTPPROXY_LEN }; > +static char *nortpproxy =3D NULL; > + > =20 > struct rtpp_head { > struct rtpp_node *rn_first; > @@ -336,6 +345,7 @@ static cmd_export_t cmds[] =3D { > static param_export_t params[] =3D { > {"natping_interval", INT_PARAM, &natping_interval }, > {"ping_nated_only", INT_PARAM, &ping_nated_only }, > + {"nortpproxy_str", STR_PARAM, &nortpproxy }, > {"rtpproxy_sock", STR_PARAM, &rtpproxy_sock }, > {"rtpproxy_disable", INT_PARAM, &rtpproxy_disable }, > {"rtpproxy_disable_tout", INT_PARAM, &rtpproxy_disable_tout }, > @@ -400,6 +410,11 @@ mod_init(void) > force_socket=3Dgrep_sock_info(&socket_str,0,0); > } > =20 > + if (nortpproxy !=3D NULL) { > + nortpproxy_str.s =3D nortpproxy; > + nortpproxy_str.len =3D strlen(nortpproxy); > + } > + > if (natping_interval > 0) { > bind_usrloc =3D (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); > if (!bind_usrloc) { > @@ -936,9 +951,6 @@ nat_uac_test_f(struct sip_msg* msg, char > #define AOLDMEDPRT "a=3Doldmediaport:" > #define AOLDMEDPRT_LEN (sizeof(AOLDMEDPRT) - 1) > =20 > -#define ANORTPPROXY "a=3Dnortpproxy:yes\r\n" > -#define ANORTPPROXY_LEN (sizeof(ANORTPPROXY) - 1) > - > =20 > static inline int=20 > replace_sdp_ip(struct sip_msg* msg, str *org_body, char *line, str *ip) > @@ -1031,13 +1043,13 @@ fix_nated_sdp_f(struct sip_msg* msg, cha > } > } > if (level & ADD_ANORTPPROXY) { > - buf =3D pkg_malloc(ANORTPPROXY_LEN * sizeof(char)); > + buf =3D pkg_malloc(nortpproxy_str.len * sizeof(char)); > if (buf =3D=3D NULL) { > LOG(L_ERR, "ERROR: fix_nated_sdp: out of memory\n"); > return -1; > } > - memcpy(buf, ANORTPPROXY, ANORTPPROXY_LEN); > - if (insert_new_lump_after(anchor, buf, ANORTPPROXY_LEN, 0)=3D=3DNULL) { > + memcpy(buf, nortpproxy_str.s, nortpproxy_str.len); > + if (insert_new_lump_after(anchor, buf, nortpproxy_str.len, 0)=3D=3DNULL= ) { > LOG(L_ERR, "ERROR: fix_nated_sdp: insert_new_lump_after " > "failed\n"); > pkg_free(buf); > @@ -1811,15 +1823,15 @@ force_rtp_proxy2_f(struct sip_msg* msg,=20 > to_tag =3D tmp; > } > proxied =3D 0; > - for (cp =3D body.s; (len =3D body.s + body.len - cp) >=3D ANORTPPROXY_LEN= ;) { > - cp1 =3D ser_memmem(cp, ANORTPPROXY, len, ANORTPPROXY_LEN); > + for (cp =3D body.s; (len =3D body.s + body.len - cp) >=3D nortpproxy_str.= len;) { > + cp1 =3D ser_memmem(cp, nortpproxy_str.s, len, nortpproxy_str.len); > if (cp1 =3D=3D NULL) > break; > if (cp1[-1] =3D=3D '\n' || cp1[-1] =3D=3D '\r') { > proxied =3D 1; > break; > } > - cp =3D cp1 + ANORTPPROXY_LEN; > + cp =3D cp1 + nortpproxy_str.len; > } > if (proxied !=3D 0 && force =3D=3D 0) > return -1; > @@ -2037,7 +2049,7 @@ force_rtp_proxy2_f(struct sip_msg* msg,=20 > } /* Iterate sessions */ > =20 > if (proxied =3D=3D 0) { > - cp =3D pkg_malloc(ANORTPPROXY_LEN * sizeof(char)); > + cp =3D pkg_malloc(nortpproxy_str.len * sizeof(char)); > if (cp =3D=3D NULL) { > LOG(L_ERR, "ERROR: force_rtp_proxy2: out of memory\n"); > return -1; > @@ -2048,8 +2060,8 @@ force_rtp_proxy2_f(struct sip_msg* msg,=20 > pkg_free(cp); > return -1; > } > - memcpy(cp, ANORTPPROXY, ANORTPPROXY_LEN); > - if (insert_new_lump_after(anchor, cp, ANORTPPROXY_LEN, 0) =3D=3D NULL) { > + memcpy(cp, nortpproxy_str.s, nortpproxy_str.len); > + if (insert_new_lump_after(anchor, cp, nortpproxy_str.len, 0) =3D=3D NULL= ) { > LOG(L_ERR, "ERROR: force_rtp_proxy2: insert_new_lump_after failed\n"); > pkg_free(cp); > return -1; > =20 > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users(a)openser.org > http://openser.org/cgi-bin/mailman/listinfo/users > =20 --===============1874086651==--