... | ... |
@@ -11,7 +11,6 @@ |
11 | 11 |
|
12 | 12 |
#define ROUND4(s) ((s)%4)?((s)+4)/4*4:(s) |
13 | 13 |
|
14 |
-char* translate_pointer( char* new_buf , char *org_buf , char* p); |
|
15 | 14 |
struct via_body* via_body_cloner( char* new_buf , char *org_buf , struct via_body *org_via); |
16 | 15 |
struct hdr_field* header_cloner( struct sip_msg *new_msg , struct sip_msg *org_msg, struct hdr_field *hdr); |
17 | 16 |
|
... | ... |
@@ -308,7 +307,7 @@ struct hdr_field* header_cloner( struct sip_msg *new_msg , struct sip_msg *org_m |
308 | 307 |
} |
309 | 308 |
|
310 | 309 |
|
311 |
- |
|
310 |
+ /* |
|
312 | 311 |
char* translate_pointer( char* new_buf , char *org_buf , char* p) |
313 | 312 |
{ |
314 | 313 |
if (!p) |
... | ... |
@@ -316,7 +315,7 @@ char* translate_pointer( char* new_buf , char *org_buf , char* p) |
316 | 315 |
else |
317 | 316 |
return new_buf + (p-org_buf); |
318 | 317 |
} |
319 |
- |
|
318 |
+*/ |
|
320 | 319 |
|
321 | 320 |
|
322 | 321 |
|
... | ... |
@@ -532,7 +531,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
532 | 531 |
break; |
533 | 532 |
} |
534 | 533 |
} |
535 |
- /* length of the data lump structures */ |
|
534 |
+ /* length of the data lump structures |
|
536 | 535 |
if (org_msg->first_line.type==SIP_REQUEST) |
537 | 536 |
lump_chain = org_msg->add_rm; |
538 | 537 |
else |
... | ... |
@@ -553,7 +552,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
553 | 552 |
lump_tmp = lump_tmp->after; |
554 | 553 |
} |
555 | 554 |
lump_chain = lump_chain->next; |
556 |
- } |
|
555 |
+ } */ |
|
557 | 556 |
|
558 | 557 |
p=(char *)sh_malloc(len); |
559 | 558 |
if (!p) |
... | ... |
@@ -678,7 +677,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
678 | 677 |
|
679 | 678 |
} |
680 | 679 |
|
681 |
- /* clonning data lump */ |
|
680 |
+ /* clonning data lump |
|
682 | 681 |
if (org_msg->first_line.type==SIP_REQUEST) { |
683 | 682 |
lump_chain = org_msg->add_rm; |
684 | 683 |
lump_anchor = &(new_msg->add_rm); |
... | ... |
@@ -689,7 +688,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
689 | 688 |
while (lump_chain) |
690 | 689 |
{ |
691 | 690 |
lump_clone( (*lump_anchor) , lump_chain , p ); |
692 |
- /*before list*/ |
|
691 |
+ /*before list/ |
|
693 | 692 |
lump_tmp = lump_chain->before; |
694 | 693 |
lump_anchor2 = &((*lump_anchor)->before); |
695 | 694 |
while ( lump_tmp ) |
... | ... |
@@ -698,7 +697,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
698 | 697 |
lump_anchor2 = &((*lump_anchor2)->before); |
699 | 698 |
lump_tmp = lump_tmp->before; |
700 | 699 |
} |
701 |
- /*after list*/ |
|
700 |
+ /*after list/ |
|
702 | 701 |
lump_tmp = lump_chain->after; |
703 | 702 |
lump_anchor2 = &((*lump_anchor)->after); |
704 | 703 |
while ( lump_tmp ) |
... | ... |
@@ -709,7 +708,7 @@ struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ) |
709 | 708 |
} |
710 | 709 |
lump_anchor = &((*lump_anchor)->next); |
711 | 710 |
lump_chain = lump_chain->next; |
712 |
- } |
|
711 |
+ } */ |
|
713 | 712 |
|
714 | 713 |
return new_msg; |
715 | 714 |
} |
... | ... |
@@ -13,15 +13,20 @@ |
13 | 13 |
#define sip_msg_cloner(p_msg) \ |
14 | 14 |
sip_msg_cloner_2(p_msg) |
15 | 15 |
|
16 |
-#define sip_msg_free(_p_msg) shm_free( (_p_msg )) |
|
17 |
-#define sip_msg_free_unsafe(_p_msg) shm_free_unsafe( (_p_msg) ) |
|
18 |
-/* sip_msg_free_2(p_msg) */ |
|
16 |
+#define sip_msg_free(_p_msg) shm_free( (_p_msg )) |
|
17 |
+#define sip_msg_free_unsafe(_p_msg) shm_free_unsafe( (_p_msg) ) |
|
18 |
+ |
|
19 |
+#define translate_pointer( _new_buf , _org_buf , _p) \ |
|
20 |
+ ( (_p)?(_new_buf + (_p-_org_buf)):(0) ) |
|
19 | 21 |
|
20 | 22 |
|
21 | 23 |
struct sip_msg* sip_msg_cloner_1( struct sip_msg *org_msg ); |
22 | 24 |
struct sip_msg* sip_msg_cloner_2( struct sip_msg *org_msg ); |
23 | 25 |
void sip_msg_free_1( struct sip_msg *org_msg ); |
24 |
-/* void sip_msg_free_2( struct sip_msg *org_msg ); */ |
|
26 |
+ |
|
27 |
+ |
|
28 |
+ |
|
29 |
+//char* translate_pointer( char* new_buf , char *org_buf , char* p); |
|
25 | 30 |
|
26 | 31 |
|
27 | 32 |
#endif |
... | ... |
@@ -194,7 +194,6 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int |
194 | 194 |
unsigned int len; |
195 | 195 |
char *buf, *shbuf; |
196 | 196 |
struct retrans_buff *rb; |
197 |
- struct cell *T_tmp; |
|
198 | 197 |
|
199 | 198 |
buf=NULL; |
200 | 199 |
shbuf = NULL; |
... | ... |
@@ -222,7 +221,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int |
222 | 221 |
* when forwarding an ACK, this condition will be all the time false because |
223 | 222 |
* the forwarded INVITE is in the retransmission buffer */ |
224 | 223 |
if ( T->outbound_request[branch]==NULL ) |
225 |
- { |
|
224 |
+{ |
|
226 | 225 |
DBG("DEBUG: t_forward: first time forwarding\n"); |
227 | 226 |
/* special case : CANCEL */ |
228 | 227 |
if ( p_msg->REQ_METHOD==METHOD_CANCEL ) |
... | ... |
@@ -230,12 +229,13 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int |
230 | 229 |
DBG("DEBUG: t_forward: it's CANCEL\n"); |
231 | 230 |
/* find original cancelled transaction; if found, use its |
232 | 231 |
next-hops; otherwise use those passed by script */ |
233 |
- T->T_canceled = t_lookupOriginalT( hash_table , p_msg ); |
|
232 |
+ if (T->T_canceled==T_UNDEFINED) |
|
233 |
+ T->T_canceled = t_lookupOriginalT( hash_table , p_msg ); |
|
234 | 234 |
/* if found */ |
235 | 235 |
if ( T->T_canceled!=T_NULL ) |
236 | 236 |
{ |
237 | 237 |
/* if in 1xx status, send to the same destination */ |
238 |
- if ( (T_tmp->status/100)==1 ) |
|
238 |
+ if ( (T->T_canceled->status/100)==1 ) |
|
239 | 239 |
{ |
240 | 240 |
DBG("DEBUG: t_forward: it's CANCEL and I will send " |
241 | 241 |
"to the same place where INVITE went\n"); |
... | ... |
@@ -11,12 +11,27 @@ |
11 | 11 |
#include "hash_func.h" |
12 | 12 |
#include "t_funcs.h" |
13 | 13 |
#include "config.h" |
14 |
+#include "sip_msg.h" |
|
14 | 15 |
|
15 | 16 |
|
16 | 17 |
#define EQ_LEN(_hf) (t_msg->_hf->body.len==p_msg->_hf->body.len) |
17 | 18 |
#define EQ_STR(_hf) (memcmp(t_msg->_hf->body.s, p_msg->_hf->body.s, \ |
18 |
- p_msg->_hf->body.len)==0) |
|
19 |
- |
|
19 |
+ p_msg->_hf->body.len)==0) |
|
20 |
+#define EQ_REQ_URI_LEN\ |
|
21 |
+ (p_msg->first_line.u.request.uri.len==t_msg->first_line.u.request.uri.len) |
|
22 |
+#define EQ_REQ_URI_STR\ |
|
23 |
+ ( memcmp( t_msg->first_line.u.request.uri.s,\ |
|
24 |
+ translate_pointer(p_msg->orig,p_msg->buf, p_msg->first_line.u.request.uri.s),\ |
|
25 |
+ p_msg->first_line.u.request.uri.len)==0) |
|
26 |
+#define EQ_VIA_LEN(_via)\ |
|
27 |
+ ( (p_msg->via1->bsize-(p_msg->_via->name.s-(p_msg->_via->hdr.s+p_msg->_via->hdr.len)))==\ |
|
28 |
+ (t_msg->via1->bsize-(t_msg->_via->name.s-(t_msg->_via->hdr.s+t_msg->_via->hdr.len))) ) |
|
29 |
+ |
|
30 |
+#define EQ_VIA_STR(_via)\ |
|
31 |
+ ( memcmp( t_msg->_via->name.s,\ |
|
32 |
+ translate_pointer(p_msg->orig,p_msg->buf,p_msg->_via->name.s),\ |
|
33 |
+ (t_msg->via1->bsize-(t_msg->_via->name.s-(t_msg->_via->hdr.s+t_msg->_via->hdr.len)))\ |
|
34 |
+ )==0 ) |
|
20 | 35 |
|
21 | 36 |
|
22 | 37 |
static int reverse_hex2int( char *c, int len ) |
... | ... |
@@ -78,7 +93,6 @@ int t_lookup_request( struct sip_msg* p_msg ) |
78 | 93 |
/* stop processing */ |
79 | 94 |
return 0; |
80 | 95 |
} |
81 |
- |
|
82 | 96 |
/* start searching into the table */ |
83 | 97 |
hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number ) ; |
84 | 98 |
isACK = p_msg->REQ_METHOD==METHOD_ACK; |
... | ... |
@@ -92,72 +106,47 @@ int t_lookup_request( struct sip_msg* p_msg ) |
92 | 106 |
tmp_cell = 0; |
93 | 107 |
while( p_cell ) |
94 | 108 |
{ |
95 |
-/* |
|
96 |
- int abba; |
|
97 |
- |
|
98 |
- t_msg = p_cell->inbound_request; |
|
99 |
- |
|
100 |
- |
|
101 |
- |
|
102 |
- if ( EQ_LEN(from) && EQ_LEN(callid) && |
|
103 |
- EQ_STR(callid) && EQ_STR(callid) && |
|
104 |
- /* we compare only numerical parts of CSEQ ... |
|
105 |
- the method name should be the same as in first line |
|
106 |
- memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , |
|
107 |
- get_cseq(p_msg)->number.len ) ==0 ) |
|
108 |
- { |
|
109 |
- if (!isACK) { |
|
110 |
- if (t_msg->REQ_METHOD == p_msg->REQ_METHOD && |
|
111 |
- EQ_LEN(to) && EQ_STR(to)) |
|
112 |
- goto found; |
|
113 |
- } else { /* ACK |
|
114 |
- if (t_msg->REQ_METHOD == METHOD_INVITE && |
|
115 |
- //p_cell->tag && p_cell->tag->len==p_msg->tag->body.len && |
|
116 |
- //if ( /*tag memcmp( p_cell->tag->s , p_msg->tag->body.s , |
|
117 |
- // p_msg->tag->body.len ) ==0 ) |
|
118 |
- EQ_STR( to ) ) { |
|
119 |
- goto found; |
|
120 |
- } |
|
121 |
- } /* ACK |
|
122 |
- } /* common HFs equal |
|
123 |
-*/ |
|
124 | 109 |
t_msg = p_cell->inbound_request; |
125 | 110 |
|
126 | 111 |
/* is it the wanted transaction ? */ |
127 | 112 |
if ( !isACK ) |
128 | 113 |
{ /* is not an ACK request */ |
129 | 114 |
/* first only the length are checked */ |
130 |
- if ( /*from length*/ EQ_LEN(from) ) |
|
131 |
- if ( /*to length*/ EQ_LEN(to) ) |
|
132 |
- if ( /*callid length*/ EQ_LEN(callid) ) |
|
133 |
- if ( /*cseq length*/ EQ_LEN(cseq) ) |
|
115 |
+ if ( EQ_LEN(callid) && EQ_LEN(cseq) ) |
|
116 |
+ if ( EQ_REQ_URI_LEN ) |
|
117 |
+ if ( EQ_VIA_LEN(via1) ) |
|
118 |
+ if ( EQ_LEN(from) && EQ_LEN(to) ) |
|
134 | 119 |
/* so far the lengths are the same -> let's check the contents */ |
135 |
- if ( /*from*/ EQ_STR(from) ) |
|
136 |
- if ( /*to*/ EQ_STR(to) ) |
|
137 |
- if ( /*callid*/ EQ_STR(callid) ) |
|
138 |
- if ( /*cseq*/ EQ_STR(cseq) ) |
|
139 |
- { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
140 |
- goto found; |
|
141 |
- } |
|
120 |
+ if ( EQ_STR(callid) && EQ_STR(cseq) ) |
|
121 |
+ if ( EQ_REQ_URI_STR ) |
|
122 |
+ if ( EQ_VIA_STR(via1) ) |
|
123 |
+ if ( EQ_STR(from) && EQ_STR(to) ) |
|
124 |
+ { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
125 |
+ goto found; |
|
126 |
+ } |
|
142 | 127 |
} |
143 | 128 |
else |
144 | 129 |
{ /* it's a ACK request*/ |
145 | 130 |
/* first only the length are checked */ |
146 |
- if ( /*from length*/ EQ_LEN(from) ) |
|
147 |
- //if ( /*to length*/ p_cell->inbound_request->to->body.len == p_msg->to->body.len ) |
|
148 |
- if ( /*callid length*/ EQ_LEN(callid) ) |
|
149 |
- if ( /*cseq_nr length*/ get_cseq(t_msg)->number.len == get_cseq(p_msg)->number.len ) |
|
150 |
- if ( /*cseq_method type*/ t_msg->first_line.u.request.method_value == METHOD_INVITE ) |
|
151 |
- //if ( /*tag length*/ p_cell->tag && p_cell->tag->len==p_msg->tag->body.len ) |
|
131 |
+ if ( t_msg->first_line.u.request.method_value==METHOD_INVITE) |
|
132 |
+ if ( /*callid length*/ EQ_LEN(callid) ) |
|
133 |
+ if ( get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len ) |
|
134 |
+ if ( EQ_REQ_URI_LEN ) |
|
135 |
+ if (/*VIA1 len*/ EQ_VIA_LEN(via1) ) |
|
136 |
+ if ( /*from length*/ EQ_LEN(from) ) |
|
137 |
+ //if ( /*to length*/ p_cell->inbound_request->to->body.len == p_msg->to->body.len ) |
|
138 |
+ //if ( /*tag length*/ p_cell->tag && p_cell->tag->len==p_msg->tag->body.len ) |
|
152 | 139 |
/* so far the lengths are the same -> let's check the contents */ |
153 |
- if ( /*from*/ EQ_STR(from) ) |
|
154 |
- //if ( /*to*/ !memcmp( p_cell->inbound_request->to->body.s , p_msg->to->body.s , p_msg->to->body.len) ) |
|
155 |
- //if ( /*tag*/ !memcmp( p_cell->tag->s , p_msg->tag->body.s , p_msg->tag->body.len ) ) |
|
156 |
- if ( /*callid*/ !memcmp( t_msg->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) ) |
|
157 |
- if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) ) |
|
158 |
- { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
159 |
- goto found; |
|
160 |
- } |
|
140 |
+ if ( /*callid*/ !memcmp( t_msg->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) ) |
|
141 |
+ if ( /*cseq_nr*/ !memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) ) |
|
142 |
+ if (/*URI len*/ EQ_REQ_URI_STR ) |
|
143 |
+ if (/*VIA1*/ EQ_VIA_STR(via1) ) |
|
144 |
+ if ( /*from*/ EQ_STR(from) ) |
|
145 |
+ //if ( /*to*/ !memcmp( p_cell->inbound_request->to->body.s , p_msg->to->body.s , p_msg->to->body.len) ) |
|
146 |
+ //if ( /*tag*/ !memcmp( p_cell->tag->s , p_msg->tag->body.s , p_msg->tag->body.len ) ) |
|
147 |
+ { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
148 |
+ goto found; |
|
149 |
+ } |
|
161 | 150 |
} |
162 | 151 |
/* next transaction */ |
163 | 152 |
tmp_cell = p_cell; |
... | ... |
@@ -188,9 +177,10 @@ found: |
188 | 177 |
*/ |
189 | 178 |
struct cell* t_lookupOriginalT( struct s_table* hash_table , struct sip_msg* p_msg ) |
190 | 179 |
{ |
191 |
- struct cell *p_cell; |
|
192 |
- struct cell *tmp_cell; |
|
193 |
- unsigned int hash_index=0; |
|
180 |
+ struct cell *p_cell; |
|
181 |
+ struct cell *tmp_cell; |
|
182 |
+ unsigned int hash_index=0; |
|
183 |
+ struct sip_msg *t_msg; |
|
194 | 184 |
|
195 | 185 |
/* it's a CANCEL request for sure */ |
196 | 186 |
|
... | ... |
@@ -203,23 +193,26 @@ struct cell* t_lookupOriginalT( struct s_table* hash_table , struct sip_msg* p_ |
203 | 193 |
tmp_cell = 0; |
204 | 194 |
while( p_cell ) |
205 | 195 |
{ |
196 |
+ t_msg = p_cell->inbound_request; |
|
197 |
+ |
|
206 | 198 |
/* is it the wanted transaction ? */ |
207 | 199 |
/* first only the length are checked */ |
208 |
- if ( /*from length*/ p_cell->inbound_request->from->body.len == p_msg->from->body.len ) |
|
209 |
- if ( /*to length*/ p_cell->inbound_request->to->body.len == p_msg->to->body.len ) |
|
210 |
- //if ( /*tag length*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && p_cell->inbound_request->tag->body.len == p_msg->tag->body.len) ) |
|
211 |
- if ( /*callid length*/ p_cell->inbound_request->callid->body.len == p_msg->callid->body.len ) |
|
212 |
- if ( /*cseq_nr length*/ get_cseq(p_cell->inbound_request)->number.len == get_cseq(p_msg)->number.len ) |
|
213 |
- if ( /*cseq_method type*/ p_cell->inbound_request->REQ_METHOD!=METHOD_CANCEL ) |
|
214 |
- if ( /*req_uri length*/ p_cell->inbound_request->first_line.u.request.uri.len == p_msg->first_line.u.request.uri.len ) |
|
215 |
- /* so far the lengths are the same -> let's check the contents */ |
|
216 |
- if ( /*from*/ memcmp( p_cell->inbound_request->from->body.s , p_msg->from->body.s , p_msg->from->body.len )==0 ) |
|
217 |
- if ( /*to*/ memcmp( p_cell->inbound_request->to->body.s , p_msg->to->body.s , p_msg->to->body.len)==0 ) |
|
218 |
- //if ( /*tag*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && memcmp( p_cell->inbound_request->tag->body.s , p_msg->tag->body.s , p_msg->tag->body.len )==0) ) |
|
219 |
- if ( /*callid*/ memcmp( p_cell->inbound_request->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len )==0 ) |
|
220 |
- if ( /*cseq_nr*/ memcmp( get_cseq(p_cell->inbound_request)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len )==0 ) |
|
221 |
- if ( /*req_uri*/ memcmp( p_cell->inbound_request->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.len )==0 ) |
|
222 |
- { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
200 |
+ if ( p_cell->inbound_request->REQ_METHOD!=METHOD_CANCEL ) |
|
201 |
+ if ( /*callid length*/ EQ_LEN(callid) ) |
|
202 |
+ if ( get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len ) |
|
203 |
+ if ( EQ_REQ_URI_LEN ) |
|
204 |
+ if ( EQ_VIA_LEN(via1) ) |
|
205 |
+ if ( EQ_LEN(from) && EQ_LEN(to) ) |
|
206 |
+ //if ( /*tag length*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && p_cell->inbound_request->tag->body.len == p_msg->tag->body.len) ) |
|
207 |
+ /* so far the lengths are the same -> let's check the contents */ |
|
208 |
+ if ( /*callid*/ EQ_STR(callid) ) |
|
209 |
+ if ( /*cseq_nr*/ memcmp( get_cseq(t_msg)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len )==0 ) |
|
210 |
+ if ( EQ_REQ_URI_STR ) |
|
211 |
+ if ( EQ_VIA_STR(via1) ) |
|
212 |
+ if ( EQ_STR(from) && EQ_STR(to) ) |
|
213 |
+ //if ( /*tag*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && memcmp( p_cell->inbound_request->tag->body.s , p_msg->tag->body.s , p_msg->tag->body.len )==0) ) |
|
214 |
+ { /* WE FOUND THE GOLDEN EGG !!!! */ |
|
215 |
+ DBG("DEBUG: t_lookupOriginalT: canceled transaction found (%x)! \n",p_cell ); |
|
223 | 216 |
return p_cell; |
224 | 217 |
} |
225 | 218 |
/* next transaction */ |
... | ... |
@@ -228,6 +221,7 @@ struct cell* t_lookupOriginalT( struct s_table* hash_table , struct sip_msg* p_ |
228 | 221 |
} |
229 | 222 |
|
230 | 223 |
/* no transaction found */ |
224 |
+ DBG("DEBUG: t_lookupOriginalT: no CANCEL maching found! \n" ); |
|
231 | 225 |
return 0; |
232 | 226 |
} |
233 | 227 |
|
... | ... |
@@ -28,7 +28,7 @@ |
28 | 28 |
(_mystr).len--; \ |
29 | 29 |
}) |
30 | 30 |
|
31 |
-/* converts a str to an u. short, returns the u. short and sets *err on |
|
31 |
+/* converts a str to an u. short, returns the u. short and sets *err on |
|
32 | 32 |
* error and if err!=null |
33 | 33 |
* */ |
34 | 34 |
static inline unsigned short str2s(unsigned char* str, unsigned int len, |
... | ... |
@@ -38,12 +38,12 @@ static inline unsigned short str2s(unsigned char* str, unsigned int len, |
38 | 38 |
int i; |
39 | 39 |
unsigned char *limit; |
40 | 40 |
unsigned char *init; |
41 |
- |
|
41 |
+ |
|
42 | 42 |
/*init*/ |
43 | 43 |
ret=i=0; |
44 | 44 |
limit=str+len; |
45 | 45 |
init=str; |
46 |
- |
|
46 |
+ |
|
47 | 47 |
for(;str<limit ;str++){ |
48 | 48 |
if ( (*str <= '9' ) && (*str >= '0') ){ |
49 | 49 |
ret=ret*10+*str-'0'; |
... | ... |
@@ -56,7 +56,7 @@ static inline unsigned short str2s(unsigned char* str, unsigned int len, |
56 | 56 |
} |
57 | 57 |
if (err) *err=0; |
58 | 58 |
return ret; |
59 |
- |
|
59 |
+ |
|
60 | 60 |
error_digits: |
61 | 61 |
DBG("str2s: ERROR: too many letters in [%s]\n", init); |
62 | 62 |
if (err) *err=1; |
... | ... |
@@ -84,7 +84,7 @@ static inline unsigned int str2ip(unsigned char* str, unsigned int len, |
84 | 84 |
ret=i=0; |
85 | 85 |
limit=str+len; |
86 | 86 |
init=str; |
87 |
- |
|
87 |
+ |
|
88 | 88 |
for(;str<limit ;str++){ |
89 | 89 |
if (*str=='.'){ |
90 | 90 |
i++; |
... | ... |
@@ -99,7 +99,7 @@ static inline unsigned int str2ip(unsigned char* str, unsigned int len, |
99 | 99 |
} |
100 | 100 |
if (err) *err=0; |
101 | 101 |
return ret; |
102 |
- |
|
102 |
+ |
|
103 | 103 |
error_dots: |
104 | 104 |
DBG("str2ip: ERROR: too many dots in [%s]\n", init); |
105 | 105 |
if (err) *err=1; |
... | ... |
@@ -112,8 +112,22 @@ error_char: |
112 | 112 |
|
113 | 113 |
|
114 | 114 |
|
115 |
-/* faster memchr version */ |
|
115 |
+static inline int btostr( char *p, unsigned char val) |
|
116 |
+{ |
|
117 |
+ unsigned int a,b,i =0; |
|
116 | 118 |
|
119 |
+ if ( (a=val/100)!=0 ) |
|
120 |
+ *(p+(i++)) = a+'0'; /*first digit*/ |
|
121 |
+ if ( (b=val%100/10)!=0 || a) |
|
122 |
+ *(p+(i++)) = b+'0'; /*second digit*/ |
|
123 |
+ *(p+(i++)) = '0'+val%10; /*third digit*/ |
|
124 |
+ |
|
125 |
+ return i; |
|
126 |
+} |
|
127 |
+ |
|
128 |
+ |
|
129 |
+ |
|
130 |
+/* faster memchr version */ |
|
117 | 131 |
static inline char* q_memchr(char* p, int c, unsigned int size) |
118 | 132 |
{ |
119 | 133 |
char* end; |