Hello Jeremie,

not to loose the patch, please register it to the tracker.

http://sourceforge.net/tracker/?atid=743022&group_id=139143&func=browse

We will check it. Right now you can enable/disable "a=nortpproxy:yes" 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=nortpproxy: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=sdpmangled: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,
------------------------------------------------------------------------

diff -urNp openser-1.1.0-notls/modules/nathelper/doc/nathelper_user.sgml 
openser-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-07 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", </programlisting>
                </example>
        </section>
+       <section>
+               <title><varname>nortpproxy_str</varname> (string)</title>
+               <para>
+               The parameter sets the SDP attribute used by nathelper to mark
+               the packet SDP informations have already been mangled.
+               </para>
+               <para>
+               <emphasis>
+                       Default value is <quote>a=nortpproxy:yes\r\n</quote>.
+               </emphasis>
+               </para>
+               <example>
+               <title>Set <varname>nortpproxy_str</varname> parameter</title>
+               <programlisting format="linespecific">
+...
+modparam("nathelper", "nortpproxy_str", "a=sdpmangled:yes")
+...
+</programlisting>
+               </example>
+       </section>
        </section>
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.000000000 +0200
+++ openser-1.1.0-notls-nortpproxy_str/modules/nathelper/nathelper.c    
2006-09-01 20:31:47.000000000 +0200
@@ -286,6 +286,15 @@ static pid_t mypid;
 static unsigned int myseqn = 0;
 static int rcv_avp_no = 42;
+/*
+ * This should have been defined right above replace_sdp_ip() but
+ * it is needed here.
+ */
+#define        ANORTPPROXY     "a=nortpproxy:yes\r\n"
+#define        ANORTPPROXY_LEN (sizeof(ANORTPPROXY) - 1)
+static str nortpproxy_str = { ANORTPPROXY, ANORTPPROXY_LEN };
+static char *nortpproxy = NULL;
+
struct rtpp_head {
        struct rtpp_node        *rn_first;
@@ -336,6 +345,7 @@ static cmd_export_t cmds[] = {
 static param_export_t params[] = {
        {"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=grep_sock_info(&socket_str,0,0);
        }
+ if (nortpproxy != NULL) {
+               nortpproxy_str.s = nortpproxy;
+               nortpproxy_str.len = strlen(nortpproxy);
+       }
+
        if (natping_interval > 0) {
                bind_usrloc = (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=oldmediaport:"
 #define        AOLDMEDPRT_LEN  (sizeof(AOLDMEDPRT) - 1)
-#define ANORTPPROXY "a=nortpproxy:yes\r\n"
-#define        ANORTPPROXY_LEN (sizeof(ANORTPPROXY) - 1)
-
static inline int 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 = pkg_malloc(ANORTPPROXY_LEN * sizeof(char));
+                       buf = pkg_malloc(nortpproxy_str.len * sizeof(char));
                        if (buf == 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)==NULL) {
+                       memcpy(buf, nortpproxy_str.s, nortpproxy_str.len);
+                       if (insert_new_lump_after(anchor, buf, 
nortpproxy_str.len, 0)==NULL) {
                                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, to_tag = tmp;
        }
        proxied = 0;
-       for (cp = body.s; (len = body.s + body.len - cp) >= ANORTPPROXY_LEN;) {
-               cp1 = ser_memmem(cp, ANORTPPROXY, len, ANORTPPROXY_LEN);
+       for (cp = body.s; (len = body.s + body.len - cp) >= 
nortpproxy_str.len;) {
+               cp1 = ser_memmem(cp, nortpproxy_str.s, len, nortpproxy_str.len);
                if (cp1 == NULL)
                        break;
                if (cp1[-1] == '\n' || cp1[-1] == '\r') {
                        proxied = 1;
                        break;
                }
-               cp = cp1 + ANORTPPROXY_LEN;
+               cp = cp1 + nortpproxy_str.len;
        }
        if (proxied != 0 && force == 0)
                return -1;
@@ -2037,7 +2049,7 @@ force_rtp_proxy2_f(struct sip_msg* msg, } /* Iterate sessions */ if (proxied == 0) {
-               cp = pkg_malloc(ANORTPPROXY_LEN * sizeof(char));
+               cp = pkg_malloc(nortpproxy_str.len * sizeof(char));
                if (cp == 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, pkg_free(cp);
                        return -1;
                }
-               memcpy(cp, ANORTPPROXY, ANORTPPROXY_LEN);
-               if (insert_new_lump_after(anchor, cp, ANORTPPROXY_LEN, 0) == 
NULL) {
+               memcpy(cp, nortpproxy_str.s, nortpproxy_str.len);
+               if (insert_new_lump_after(anchor, cp, nortpproxy_str.len, 0) == 
NULL) {
                        LOG(L_ERR, "ERROR: force_rtp_proxy2: insert_new_lump_after 
failed\n");
                        pkg_free(cp);
                        return -1;
------------------------------------------------------------------------

_______________________________________________
Users mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/users

Reply via email to