... | ... |
@@ -23,13 +23,12 @@ |
23 | 23 |
* |
24 | 24 |
*/ |
25 | 25 |
|
26 |
-#include "detailed_ip_type.h" |
|
27 |
- |
|
28 | 26 |
#include <stdio.h> |
29 | 27 |
#include <stdlib.h> |
30 | 28 |
#include <arpa/inet.h> |
31 | 29 |
#include <string.h> |
32 | 30 |
#include "../../str.h" |
31 |
+#include "detailed_ip_type.h" |
|
33 | 32 |
|
34 | 33 |
static ip4_node IPv4ranges[IPv4RANGES_SIZE] = { |
35 | 34 |
{ 0xffffffff, "BROADCAST", 0xffffffff }, // 255.255.255.255/32 |
... | ... |
@@ -62,16 +61,24 @@ static ip6_node IPv6ranges[IPv6RANGES_SIZE] = { |
62 | 61 |
{ {0x20020000, 0x00000000, 0x00000000, 0x00000000} , "6TO4", {0xFFFF0000, 0x00000000, 0x00000000, 0x00000000} }, //2002::/16 |
63 | 62 |
{ {0xFE800000, 0x00000000, 0x00000000, 0x00000000} , "LINK-LOCAL-UNICAST", {0xFFC00000, 0x00000000, 0x00000000, 0x00000000} }, //FE80::/10 |
64 | 63 |
{ {0xFEC00000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFFC00000, 0x00000000, 0x00000000, 0x00000000} }, //FEC0::/10 |
64 |
+ { {0xFE800000, 0x00000000, 0x00000000, 0x00000000} , "LINK-LOCAL-UNICAST", {0xFFc00000, 0x00000000, 0x00000000, 0x00000000} }, // FE80::/10 |
|
65 |
+ { {0xFEC00000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFFc00000, 0x00000000, 0x00000000, 0x00000000} }, // FEC0::/10 |
|
65 | 66 |
{ {0xFE000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFF800000, 0x00000000, 0x00000000, 0x00000000} }, //FE00::/9 |
67 |
+ { {0xFE000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFF800000, 0x00000000, 0x00000000, 0x00000000} }, // FE00::/9 |
|
66 | 68 |
{ {0x00000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFF000000, 0x00000000, 0x00000000, 0x00000000} }, //::/8 |
67 | 69 |
{ {0x01000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFF000000, 0x00000000, 0x00000000, 0x00000000} }, //0100::/8 |
68 | 70 |
{ {0xFF000000, 0x00000000, 0x00000000, 0x00000000} , "MULTICAST", {0xFF000000, 0x00000000, 0x00000000, 0x00000000} }, //FF00::/8 |
71 |
+ { {0xFF000000, 0x00000000, 0x00000000, 0x00000000} , "MULTICAST", {0xFF000000, 0x00000000, 0x00000000, 0x00000000} }, // FF00::/8 |
|
69 | 72 |
{ {0x02000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFE000000, 0x00000000, 0x00000000, 0x00000000} }, //0200::/7 |
70 | 73 |
{ {0xFC000000, 0x00000000, 0x00000000, 0x00000000} , "UNIQUE-LOCAL-UNICAST",{0xFE000000, 0x00000000, 0x00000000, 0x00000000} }, //FC00::/7 |
74 |
+ { {0xFC000000, 0x00000000, 0x00000000, 0x00000000} , "UNIQUE-LOCAL-UNICAST",{0xFE000000, 0x00000000, 0x00000000, 0x00000000} }, // FC00::/7 |
|
71 | 75 |
{ {0x04000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFC000000, 0x00000000, 0x00000000, 0x00000000} }, //400::/6 |
72 | 76 |
{ {0xF8000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFC000000, 0x00000000, 0x00000000, 0x00000000} }, //F800::/6 |
73 |
- { {0x08000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xF8000000, 0x00000000, 0x00000000, 0x00000000} } //0800::/5 |
|
74 |
- //more to come here soon |
|
77 |
+ { {0xF8000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xFC000000, 0x00000000, 0x00000000, 0x00000000} }, // F800::/6 |
|
78 |
+ { {0x08000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xF8000000, 0x00000000, 0x00000000, 0x00000000} }, //0800::/5 |
|
79 |
+ { {0xF0000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xF8000000, 0x00000000, 0x00000000, 0x00000000} }, // F000::/5 |
|
80 |
+ { {0xE0000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xF0000000, 0x00000000, 0x00000000, 0x00000000} }, // E000::/4 |
|
81 |
+ { {0xC0000000, 0x00000000, 0x00000000, 0x00000000} , "RESERVED", {0xE0000000, 0x00000000, 0x00000000, 0x00000000} } // C000::/3 |
|
75 | 82 |
}; |
76 | 83 |
|
77 | 84 |
|
... | ... |
@@ -94,7 +94,8 @@ static int w_is_ip_rfc1918(struct sip_msg*, char*); |
94 | 94 |
static int w_ip_is_in_subnet(struct sip_msg*, char*, char*); |
95 | 95 |
static int w_dns_sys_match_ip(sip_msg_t*, char*, char*); |
96 | 96 |
static int w_dns_int_match_ip(sip_msg_t*, char*, char*); |
97 |
-static int fixup_detailed_ipv6_type(void** param, int param_no); |
|
97 |
+static int fixup_detailed_ip_type(void** param, int param_no); |
|
98 |
+static int fixup_free_detailed_ip_type(void** param, int param_no); |
|
98 | 99 |
static int w_dns_query(struct sip_msg* msg, char* str1, char* str2); |
99 | 100 |
static int mod_init(void); |
100 | 101 |
|
... | ... |
@@ -121,10 +122,10 @@ static cmd_export_t cmds[] = |
121 | 122 |
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE }, |
122 | 123 |
{ "ip_type", (cmd_function)w_ip_type, 1, fixup_spve_null, 0, |
123 | 124 |
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE }, |
124 |
- { "detailed_ipv4_type", (cmd_function)w_detailed_ipv4_type, 2, fixup_detailed_ipv6_type, 0, |
|
125 |
- ANY_ROUTE }, |
|
126 |
- { "detailed_ipv6_type", (cmd_function)w_detailed_ipv6_type, 2, fixup_detailed_ipv6_type, 0, |
|
127 |
- ANY_ROUTE }, |
|
125 |
+ { "detailed_ipv4_type", (cmd_function)w_detailed_ipv4_type, 2, |
|
126 |
+ fixup_detailed_ip_type, fixup_free_detailed_ip_type, ANY_ROUTE }, |
|
127 |
+ { "detailed_ipv6_type", (cmd_function)w_detailed_ipv6_type, 2, |
|
128 |
+ fixup_detailed_ip_type, fixup_free_detailed_ip_type, ANY_ROUTE }, |
|
128 | 129 |
{ "compare_ips", (cmd_function)w_compare_ips, 2, fixup_spve_spve, 0, |
129 | 130 |
REQUEST_ROUTE|FAILURE_ROUTE|ONREPLY_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE }, |
130 | 131 |
{ "compare_pure_ips", (cmd_function)w_compare_pure_ips, 2, fixup_spve_spve, 0, |
... | ... |
@@ -185,7 +186,7 @@ static int mod_init(void) { |
185 | 186 |
/* |
186 | 187 |
* Fix detailed_ipv6_type param: result (writable pvar). |
187 | 188 |
*/ |
188 |
-static int fixup_detailed_ipv6_type(void** param, int param_no) |
|
189 |
+static int fixup_detailed_ip_type(void** param, int param_no) |
|
189 | 190 |
{ |
190 | 191 |
if (param_no == 1) { |
191 | 192 |
return fixup_spve_null(param, 1); |
... | ... |
@@ -207,7 +208,20 @@ static int fixup_detailed_ipv6_type(void** param, int param_no) |
207 | 208 |
return -1; |
208 | 209 |
} |
209 | 210 |
|
211 |
+static int fixup_free_detailed_ip_type(void** param, int param_no) |
|
212 |
+{ |
|
213 |
+ if (param_no == 1) { |
|
214 |
+ LM_WARN("free function has not been defined for spve\n"); |
|
215 |
+ return 0; |
|
216 |
+ } |
|
217 |
+ |
|
218 |
+ if (param_no == 2) { |
|
219 |
+ return fixup_free_pvar_null(param, 1); |
|
220 |
+ } |
|
210 | 221 |
|
222 |
+ LM_ERR("invalid parameter number <%d>\n", param_no); |
|
223 |
+ return -1; |
|
224 |
+} |
|
211 | 225 |
/* |
212 | 226 |
* Module internal functions |
213 | 227 |
*/ |
... | ... |
@@ -497,7 +511,6 @@ static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg, char* _s, |
497 | 511 |
return -3; |
498 | 512 |
} |
499 | 513 |
|
500 |
- LM_ERR("!!!!!!! ip to change is %.*s\n", string.len, string.s); |
|
501 | 514 |
switch (_type) { |
502 | 515 |
case AF_INET: |
503 | 516 |
if (!ip4_iptype(string, &res)) { |
... | ... |
@@ -511,7 +524,6 @@ static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg, char* _s, |
511 | 524 |
string.s++; |
512 | 525 |
string.len -= 2; |
513 | 526 |
} |
514 |
- LM_ERR("!!!!!!! hi 1 \n"); |
|
515 | 527 |
if (!ip6_iptype(string, &res)) { |
516 | 528 |
LM_ERR("bad ip parameter\n"); |
517 | 529 |
return -1; |
... | ... |
@@ -526,7 +538,6 @@ static int _detailed_ip_type(unsigned int _type, struct sip_msg* _msg, char* _s, |
526 | 538 |
val.flags = PV_VAL_STR; |
527 | 539 |
dst = (pv_spec_t *)_dst; |
528 | 540 |
dst->setf(_msg, &dst->pvp, (int)EQ_T, &val); |
529 |
- LM_ERR("!!!!!!! hi 2 \n"); |
|
530 | 541 |
return 1; |
531 | 542 |
} |
532 | 543 |
|