Module: sip-router
Branch: pd/websocket
Commit: 915894b15d9096388a0136d2d2bdf48ef65b4c4a
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=915894b15d9096388a0136d2d2bdf48ef65b4c4a

Author: Peter Dunkley <[email protected]>
Committer: Peter Dunkley <[email protected]>
Date:   Fri Jun 29 23:03:15 2012 +0100

modules_k/nathelper: Added nat_uac_test() check for WebSockets

- At the moment (and until Kamailio and _all_ WebSocket clients support
  outbound) we want to treat WebSocket UAs as behind NATs (even when they
  are not).
- This is so that the aliasing (which is good for TCP/TLS connection reuse
  as well as NAT traversal) can be used to make sure messages to WebSocket
  UAs are routed correctly.

---

 modules_k/nathelper/README                  |   41 ++++++++++++++-------------
 modules_k/nathelper/doc/nathelper_admin.xml |    4 ++
 modules_k/nathelper/nathelper.c             |    8 +++++
 3 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/modules_k/nathelper/README b/modules_k/nathelper/README
index c49aac4..cbf4256 100644
--- a/modules_k/nathelper/README
+++ b/modules_k/nathelper/README
@@ -472,6 +472,7 @@ fix_nated_register();
      * 16 - test if the source port is different from the port in Via
      * 32 - test if the source IP address of signaling is a RFC1918
        address
+     * 64 - test if the source connection of signaling is a WebSocket
 
    All flags can be bitwise combined, the test returns true if any of the
    tests identified a NAT.
@@ -593,38 +594,38 @@ Chapter 2. Frequently Asked Questions
 
    2.1.
 
-       What happend with “rtpproxy_disable” parameter?
+   What happend with “rtpproxy_disable” parameter?
 
-       It was removed as it became obsolete - now “rtpproxy_sock” can take
-       empty value to disable the rtpproxy functionality.
+   It was removed as it became obsolete - now “rtpproxy_sock” can take
+   empty value to disable the rtpproxy functionality.
 
    2.2.
 
-       Where can I find more about Kamailio?
+   Where can I find more about Kamailio?
 
-       Take a look at http://www.kamailio.org/.
+   Take a look at http://www.kamailio.org/.
 
    2.3.
 
-       Where can I post a question about this module?
+   Where can I post a question about this module?
 
-       First at all check if your question was already answered on one of our
-       mailing lists:
-         * User Mailing List -
-           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-         * Developer Mailing List -
-           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
+   First at all check if your question was already answered on one of our
+   mailing lists:
+     * User Mailing List -
+       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
+     * Developer Mailing List -
+       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
 
-       E-mails regarding any stable Kamailio release should be sent to
-       <[email protected]> and e-mails regarding development
-       versions should be sent to <[email protected]>.
+   E-mails regarding any stable Kamailio release should be sent to
+   <[email protected]> and e-mails regarding development
+   versions should be sent to <[email protected]>.
 
-       If you want to keep the mail private, send it to
-       <[email protected]>.
+   If you want to keep the mail private, send it to
+   <[email protected]>.
 
    2.4.
 
-       How can I report a bug?
+   How can I report a bug?
 
-       Please follow the guidelines provided at:
-       http://sip-router.org/tracker.
+   Please follow the guidelines provided at:
+   http://sip-router.org/tracker.
diff --git a/modules_k/nathelper/doc/nathelper_admin.xml 
b/modules_k/nathelper/doc/nathelper_admin.xml
index d57757a..8f49d03 100644
--- a/modules_k/nathelper/doc/nathelper_admin.xml
+++ b/modules_k/nathelper/doc/nathelper_admin.xml
@@ -540,6 +540,10 @@ fix_nated_register();
                        <emphasis>32</emphasis> -  test if the source IP 
address of
                        signaling is a RFC1918 address
                        </para></listitem>
+                       <listitem><para>
+                       <emphasis>64</emphasis> -  test if the source 
connection of
+                       signaling is a WebSocket
+                       </para></listitem>
                        </itemizedlist>
                <para>
                All flags can be bitwise combined, the test returns true if any 
of 
diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 4007004..4afae00 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/modules_k/nathelper/nathelper.c
@@ -241,6 +241,7 @@ MODULE_VERSION
 #define        NAT_UAC_TEST_S_1918     0x08
 #define        NAT_UAC_TEST_RPORT      0x10
 #define        NAT_UAC_TEST_O_1918     0x20
+#define NAT_UAC_TEST_WS                0x40
 
 
 #define DEFAULT_RTPP_SET_ID            0
@@ -1279,6 +1280,13 @@ nat_uac_test_f(struct sip_msg* msg, char* str1, char* 
str2)
        if ((tests & NAT_UAC_TEST_O_1918) && is1918addr_ip(&msg->rcv.src_ip))
                return 1;
 
+       /*
+        * tests prototype to check whether the message arrived on a WebSocket
+        */
+       if ((tests & NAT_UAC_TEST_WS)
+               && (msg->rcv.proto == PROTO_WS || msg->rcv.proto == PROTO_WSS))
+               return 1;
+
        /* no test succeeded */
        return -1;
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to