]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-535: fix issue in is_lan_addr where 172.2 would match 172.250.x.x which is not...
authorBrian West <brian@freeswitch.org>
Wed, 24 Nov 2010 00:35:45 +0000 (18:35 -0600)
committerBrian West <brian@freeswitch.org>
Wed, 24 Nov 2010 00:51:17 +0000 (18:51 -0600)
src/mod/endpoints/mod_sofia/sofia.c
src/switch_utils.c

index 4d992b0ea1abc606d5e5cc10dc9d7b8a51555c02..4d9bd7fd7ba6a6a29b5002e3fadc291b3adf420f 100644 (file)
@@ -2173,7 +2173,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
 
                                register_host = sofia_glue_get_register_host(gateway->register_proxy);
 
-                               if (register_host && !sofia_glue_check_nat(profile, register_host)) {
+                               if (register_host && switch_is_lan_addr(register_host)) {
                                        sipip = profile->sipip;
                                }
 
index 75be02a31f453cb7f4a76cdc7fb781097e704701..1a29e2b7155edd746198b472c24f01408d9ad7e9 100644 (file)
@@ -726,18 +726,31 @@ SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip)
        if (zstr(ip))
                return SWITCH_FALSE;
 
-       return (strncmp(ip, "10.", 3) &&
-                       strncmp(ip, "192.168.", 8) &&
-                       strncmp(ip, "127.", 4) &&
+       return (strncmp(ip, "10.", 3) &&       /* 10.0.0.0        -   10.255.255.255  (10/8 prefix)       */
+                       strncmp(ip, "192.168.", 8) &&  /* 192.168.0.0     -   192.168.255.255 (192.168/16 prefix) */
+                       strncmp(ip, "127.", 4) &&      /* 127.0.0.0       -   127.255.255.255 (127/8 prefix)      */
                        strncmp(ip, "255.", 4) &&
-                       strncmp(ip, "0.", 2) &&
+                       strncmp(ip, "0.", 2) &&       
                        strncmp(ip, "1.", 2) &&
                        strncmp(ip, "2.", 2) &&
-                       strncmp(ip, "172.16.", 7) &&
+                       strncmp(ip, "172.16.", 7) &&   /* 172.16.0.0      -   172.31.255.255  (172.16/12 prefix)  */
                        strncmp(ip, "172.17.", 7) &&
                        strncmp(ip, "172.18.", 7) &&
                        strncmp(ip, "172.19.", 7) &&
-                       strncmp(ip, "172.2", 5) && strncmp(ip, "172.30.", 7) && strncmp(ip, "172.31.", 7) && strncmp(ip, "192.0.2.", 8) && strncmp(ip, "169.254.", 8)
+                       strncmp(ip, "172.20.", 7) &&
+                       strncmp(ip, "172.21.", 7) &&
+                       strncmp(ip, "172.22.", 7) &&
+                       strncmp(ip, "172.23.", 7) &&
+                       strncmp(ip, "172.24.", 7) &&
+                       strncmp(ip, "172.25.", 7) &&
+                       strncmp(ip, "172.26.", 7) &&
+                       strncmp(ip, "172.27.", 7) &&
+                       strncmp(ip, "172.28.", 7) &&
+                       strncmp(ip, "172.29.", 7) &&
+                       strncmp(ip, "172.30.", 7) &&
+                       strncmp(ip, "172.31.", 7) &&
+                       strncmp(ip, "192.0.2.", 8) &&  /* 192.0.2.0       -   192.0.2.255      (192.0.2/24 prefix) */
+                       strncmp(ip, "169.254.", 8)     /* 169.254.0.0     -   169.254.255.255  (169.254/16 prefix) */
                )? SWITCH_FALSE : SWITCH_TRUE;
 }