... | ... |
@@ -627,11 +627,11 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel) |
627 | 627 |
/* transaction lookup */ |
628 | 628 |
if ( p_msg->first_line.type==SIP_REQUEST ) { |
629 | 629 |
/* force parsing all the needed headers*/ |
630 |
- if (parse_headers(p_msg, HDR_EOH )==-1) |
|
630 |
+ if (parse_headers(p_msg, HDR_EOH, 0 )==-1) |
|
631 | 631 |
return -1; |
632 | 632 |
t_lookup_request( p_msg , 0 /* unlock before returning */ ); |
633 | 633 |
} else { |
634 |
- if ( parse_headers(p_msg, HDR_VIA1|HDR_TO|HDR_CSEQ )==-1 |
|
634 |
+ if ( parse_headers(p_msg, HDR_VIA1|HDR_TO|HDR_CSEQ, 0 )==-1 |
|
635 | 635 |
|| !p_msg->via1 || !p_msg->to || !p_msg->cseq ) |
636 | 636 |
return -1; |
637 | 637 |
t_reply_matching( p_msg , |
... | ... |
@@ -746,7 +746,7 @@ int t_newtran( struct sip_msg* p_msg ) |
746 | 746 |
T = T_UNDEFINED; |
747 | 747 |
/* transaction lookup */ |
748 | 748 |
/* force parsing all the needed headers*/ |
749 |
- if (parse_headers(p_msg, HDR_EOH )==-1) |
|
749 |
+ if (parse_headers(p_msg, HDR_EOH, 0 )==-1) |
|
750 | 750 |
return 0; |
751 | 751 |
lret = t_lookup_request( p_msg, 1 /* leave locked */ ); |
752 | 752 |
/* on error, pass the error in the stack ... */ |
... | ... |
@@ -166,7 +166,7 @@ char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,int *ret_len) |
166 | 166 |
p_msg = trans->uas.request; |
167 | 167 |
r_msg = rpl; |
168 | 168 |
|
169 |
- if ( parse_headers(rpl,HDR_TO)==-1 || !rpl->to ) |
|
169 |
+ if ( parse_headers(rpl,HDR_TO, 0)==-1 || !rpl->to ) |
|
170 | 170 |
{ |
171 | 171 |
LOG(L_ERR, "ERROR: t_build_ACK: " |
172 | 172 |
"cannot generate a HBH ACK if key HFs in reply missing\n"); |
... | ... |
@@ -679,7 +679,7 @@ char * build_res_buf_from_sip_req( unsigned int code, char *text, |
679 | 679 |
Via's in the reply and they may be scattered down to the |
680 | 680 |
end of header (non-block Vias are a really poor property |
681 | 681 |
of SIP :( ) */ |
682 |
- parse_headers( msg, HDR_EOH ); |
|
682 |
+ parse_headers( msg, HDR_EOH, 0 ); |
|
683 | 683 |
|
684 | 684 |
/* check if received needs to be added */ |
685 | 685 |
backup = msg->via1->host.s[msg->via1->host.len]; |
... | ... |
@@ -177,16 +177,22 @@ error: |
177 | 177 |
give you the first occurance of a header you are interested in, |
178 | 178 |
look at check_transaction_quadruple |
179 | 179 |
*/ |
180 |
-int parse_headers(struct sip_msg* msg, int flags) |
|
180 |
+int parse_headers(struct sip_msg* msg, int flags, int next) |
|
181 | 181 |
{ |
182 | 182 |
struct hdr_field* hf; |
183 | 183 |
char* tmp; |
184 | 184 |
char* rest; |
185 | 185 |
char* end; |
186 |
+ int orig_flag; |
|
186 | 187 |
|
187 | 188 |
end=msg->buf+msg->len; |
188 | 189 |
tmp=msg->unparsed; |
189 | 190 |
|
191 |
+ if (next) { |
|
192 |
+ orig_flag = msg->parsed_flag; |
|
193 |
+ msg->parsed_flag &= ~flags; |
|
194 |
+ } |
|
195 |
+ |
|
190 | 196 |
DBG("parse_headers: flags=%d\n", flags); |
191 | 197 |
while( tmp<end && (flags & msg->parsed_flag) != flags){ |
192 | 198 |
hf=pkg_malloc(sizeof(struct hdr_field)); |
... | ... |
@@ -329,6 +335,7 @@ skip: |
329 | 335 |
error: |
330 | 336 |
ser_error=E_BAD_REQ; |
331 | 337 |
if (hf) pkg_free(hf); |
338 |
+ if (next) msg->parsed_flag |= orig_flag; |
|
332 | 339 |
return -1; |
333 | 340 |
} |
334 | 341 |
|
... | ... |
@@ -386,7 +393,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg) |
386 | 393 |
/*find first Via: */ |
387 | 394 |
first_via=0; |
388 | 395 |
second_via=0; |
389 |
- if (parse_headers(msg, flags)==-1) goto error; |
|
396 |
+ if (parse_headers(msg, flags, 0)==-1) goto error; |
|
390 | 397 |
|
391 | 398 |
#ifdef EXTRA_DEBUG |
392 | 399 |
/* dump parsed data */ |
... | ... |
@@ -461,13 +468,13 @@ void free_sip_msg(struct sip_msg* msg) |
461 | 468 |
int check_transaction_quadruple( struct sip_msg* msg ) |
462 | 469 |
{ |
463 | 470 |
return |
464 |
- (parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && |
|
471 |
+ (parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ, 0)!=-1 && |
|
465 | 472 |
msg->from && msg->to && msg->callid && msg->cseq); |
466 | 473 |
/* replaced by me ( :) andrei) |
467 |
- ( (msg->from || (parse_headers( msg, HDR_FROM)!=-1 && msg->from)) && |
|
468 |
- (msg->to|| (parse_headers( msg, HDR_TO)!=-1 && msg->to)) && |
|
469 |
- (msg->callid|| (parse_headers( msg, HDR_CALLID)!=-1 && msg->callid)) && |
|
470 |
- (msg->cseq|| (parse_headers( msg, HDR_CSEQ)!=-1 && msg->cseq)) ) ? 1 : 0; |
|
474 |
+ ( (msg->from || (parse_headers( msg, HDR_FROM, 0)!=-1 && msg->from)) && |
|
475 |
+ (msg->to|| (parse_headers( msg, HDR_TO, 0)!=-1 && msg->to)) && |
|
476 |
+ (msg->callid|| (parse_headers( msg, HDR_CALLID, 0)!=-1 && msg->callid)) && |
|
477 |
+ (msg->cseq|| (parse_headers( msg, HDR_CSEQ, 0)!=-1 && msg->cseq)) ) ? 1 : 0; |
|
471 | 478 |
*/ |
472 | 479 |
|
473 | 480 |
} |
... | ... |
@@ -117,7 +117,7 @@ struct sip_msg { |
117 | 117 |
|
118 | 118 |
int parse_msg(char* buf, unsigned int len, struct sip_msg* msg); |
119 | 119 |
|
120 |
-int parse_headers(struct sip_msg* msg, int flags); |
|
120 |
+int parse_headers(struct sip_msg* msg, int flags, int next); |
|
121 | 121 |
|
122 | 122 |
void free_sip_msg(struct sip_msg* msg); |
123 | 123 |
|
... | ... |
@@ -126,18 +126,18 @@ void free_sip_msg(struct sip_msg* msg); |
126 | 126 |
*/ |
127 | 127 |
|
128 | 128 |
#define check_transaction_quadruple(msg ) \ |
129 |
- (parse_headers((msg), HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \ |
|
129 |
+ (parse_headers((msg), HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ, 0)!=-1 && \ |
|
130 | 130 |
(msg)->from && (msg)->to && (msg)->callid && (msg)->cseq) |
131 | 131 |
|
132 | 132 |
/* restored to the original double-check and put macro params |
133 | 133 |
in parenthesses -jiri */ |
134 | 134 |
/* re-reverted to the shorter version -andrei |
135 | 135 |
#define check_transaction_quadruple(msg ) \ |
136 |
- ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && \ |
|
137 |
- ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) && \ |
|
138 |
- ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\ |
|
139 |
- ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) && \ |
|
140 |
- ((msg)->via1|| (parse_headers( (msg), HDR_VIA)!=-1 && (msg)->via1)) ) |
|
136 |
+ ( ((msg)->from || (parse_headers( (msg), HDR_FROM, 0)!=-1 && (msg)->from)) && \ |
|
137 |
+ ((msg)->to|| (parse_headers( (msg), HDR_TO, 0)!=-1 && (msg)->to)) && \ |
|
138 |
+ ((msg)->callid|| (parse_headers( (msg), HDR_CALLID, 0)!=-1 && (msg)->callid)) &&\ |
|
139 |
+ ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ, 0)!=-1 && (msg)->cseq)) && \ |
|
140 |
+ ((msg)->via1|| (parse_headers( (msg), HDR_VIA, 0)!=-1 && (msg)->via1)) ) |
|
141 | 141 |
*/ |
142 | 142 |
|
143 | 143 |
#endif |