Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 01/03/2002 15:00:14
Showing 6 changed files
... ...
@@ -86,10 +86,9 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
86 86
 	 #-DNOSMP \
87 87
 	 #-DEXTRA_DEBUG 
88 88
 	 #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
89
-	 #-DDBG_QM_MALLOC #-DNO_DEBUG
89
+	 #-DDBG_QM_MALLOC 
90 90
 # -DUSE_SHM_MEM
91
-#-DNO_DEBUG
92
-#-DNO_DEBUG#-DSTATS -DNO_DEBUG
91
+#-DSTATS 
93 92
 #-DNO_LOG
94 93
 
95 94
 # arh. specific definitions
... ...
@@ -149,29 +149,32 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
149 149
       new_msg->first_line.u.reply.reason.s =  translate_pointer( new_msg->buf , org_msg->buf , org_msg->first_line.u.reply.reason.s );
150 150
     }
151 151
 
152
-   /*headers list*/
153
-   new_msg->via1=0;
154
-   new_msg->via2=0;
155
-   for( hdr=org_msg->headers,last_hdr=0 ; hdr ; hdr=hdr->next )
156
-   {
157
-      new_hdr = (struct hdr_field*)p;
158
-      memcpy(new_hdr, hdr, sizeof(struct hdr_field) );
159
-      p += ROUND4(sizeof( struct hdr_field));
160
-      new_hdr->name.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->name.s );
161
-      new_hdr->body.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->body.s );
162
-
163
-     switch (hdr->type)
164
-      {
165
-         case HDR_VIA:
166
-                if ( !new_msg->via1 )
167
-                   {
168
-                       new_msg->h_via1 = new_hdr;
169
-                       new_msg->via1 = via_body_cloner_2( new_msg->buf , org_msg->buf , (struct via_body*)hdr->parsed , &p);
170
-                       new_hdr->parsed  = (void*)new_msg->via1;
171
-                   if ( new_msg->via1->next )
172
-                            new_msg->via2 = new_msg->via1->next;
173
-                   }
174
-                else if ( !new_msg->via2 && new_msg->via1 )
152
+	/*headers list*/
153
+	new_msg->via1=0;
154
+	new_msg->via2=0;
155
+	for( hdr=org_msg->headers,last_hdr=0 ; hdr ; hdr=hdr->next )
156
+	{
157
+		new_hdr = (struct hdr_field*)p;
158
+		memcpy(new_hdr, hdr, sizeof(struct hdr_field) );
159
+		p += ROUND4(sizeof( struct hdr_field));
160
+		new_hdr->name.s = translate_pointer(new_msg->buf, org_msg->buf,
161
+			hdr->name.s);
162
+		new_hdr->body.s = translate_pointer(new_msg->buf, org_msg->buf,
163
+			hdr->body.s);
164
+
165
+		switch (hdr->type)
166
+		{
167
+			case HDR_VIA:
168
+				if ( !new_msg->via1 )
169
+				{
170
+					new_msg->h_via1 = new_hdr;
171
+					new_msg->via1 = via_body_cloner_2(new_msg->buf,
172
+						org_msg->buf, (struct via_body*)hdr->parsed, &p);
173
+					new_hdr->parsed  = (void*)new_msg->via1;
174
+					if ( new_msg->via1->next )
175
+						new_msg->via2 = new_msg->via1->next;
176
+				}
177
+				else if ( !new_msg->via2 && new_msg->via1 )
175 178
                    {
176 179
                        new_msg->h_via2 = new_hdr;
177 180
                        if ( new_msg->via1->next )
... ...
@@ -181,35 +184,41 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
181 184
                            new_hdr->parsed  = (void*)new_msg->via2;
182 185
                        }
183 186
                    }
184
-                else if ( new_msg->via2 && new_msg->via1 )
187
+				else if ( new_msg->via2 && new_msg->via1 )
185 188
                    {
186 189
                        new_hdr->parsed  = new_msg->via1 = via_body_cloner_2( new_msg->buf , org_msg->buf , (struct via_body*)hdr->parsed , &p);
187 190
                    }
188 191
                    break;
189
-         case HDR_CSEQ:
190
-                   new_hdr->parsed = p;
191
-                   p +=ROUND4(sizeof(struct cseq_body));
192
-                   memcpy( new_hdr->parsed , hdr->parsed , sizeof(struct cseq_body) );
193
-                   ((struct cseq_body*)new_hdr->parsed)->number.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->number.s );
194
-                   ((struct cseq_body*)new_hdr->parsed)->method.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->method.s );
195
-                   new_msg->cseq = new_hdr;
196
-                   break;
197
-         case HDR_TO:
198
-                   new_hdr->parsed = p;
199
-                   p +=ROUND4(sizeof(struct to_body));
200
-                   memcpy( new_hdr->parsed , hdr->parsed ,
201
-                    sizeof(struct to_body) );
202
-                   ((struct to_body*)new_hdr->parsed)->body.s =
203
-                        translate_pointer( new_msg->buf , org_msg->buf ,
204
-                        ((struct to_body*)hdr->parsed)->body.s );
205
-                   if ( ((struct to_body*)hdr->parsed)->tag_value.s )
206
-                         ((struct to_body*)new_hdr->parsed)->tag_value.s
207
-                         = translate_pointer( new_msg->buf , org_msg->buf ,
208
-                            ((struct to_body*)hdr->parsed)->tag_value.s );
209
-                    /*to params*/
210
-                   to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
211
-                   for(;to_prm;to_prm=to_prm->next)
212
-                   {
192
+			case HDR_CSEQ:
193
+				new_hdr->parsed = p;
194
+				p +=ROUND4(sizeof(struct cseq_body));
195
+				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct cseq_body));
196
+				((struct cseq_body*)new_hdr->parsed)->number.s =
197
+					translate_pointer(new_msg->buf ,org_msg->buf,
198
+					((struct cseq_body*)hdr->parsed)->number.s );
199
+				((struct cseq_body*)new_hdr->parsed)->method.s =
200
+					translate_pointer(new_msg->buf ,org_msg->buf,
201
+					((struct cseq_body*)hdr->parsed)->method.s );
202
+				new_msg->cseq = new_hdr;
203
+				break;
204
+			case HDR_TO:
205
+				new_hdr->parsed = p;
206
+				p +=ROUND4(sizeof(struct to_body));
207
+				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct to_body));
208
+				((struct to_body*)new_hdr->parsed)->body.s =
209
+					translate_pointer( new_msg->buf , org_msg->buf ,
210
+					((struct to_body*)hdr->parsed)->body.s );
211
+				((struct to_body*)new_hdr->parsed)->uri.s =
212
+					translate_pointer( new_msg->buf , org_msg->buf ,
213
+					((struct to_body*)hdr->parsed)->uri.s );
214
+				if ( ((struct to_body*)hdr->parsed)->tag_value.s )
215
+					((struct to_body*)new_hdr->parsed)->tag_value.s =
216
+						translate_pointer( new_msg->buf , org_msg->buf ,
217
+						((struct to_body*)hdr->parsed)->tag_value.s );
218
+				/*to params*/
219
+				to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
220
+				for(;to_prm;to_prm=to_prm->next)
221
+				{
213 222
                       /*alloc*/
214 223
                       new_to_prm = (struct to_param*)p;
215 224
                       p +=ROUND4(sizeof(struct to_param ));
... ...
@@ -229,22 +238,22 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
229 238
                             = new_to_prm;
230 239
                       ((struct to_body*)new_hdr->parsed)->last_param
231 240
                          = new_to_prm;
232
-                   }
233
-                   new_msg->to = new_hdr;
234
-                   break;
235
-         case HDR_CALLID:
236
-                   new_msg->callid = new_hdr;
237
-                   break;
238
-         case HDR_FROM:
241
+				}
242
+				new_msg->to = new_hdr;
243
+				break;
244
+			case HDR_CALLID:
245
+				new_msg->callid = new_hdr;
246
+				break;
247
+			case HDR_FROM:
239 248
                    new_msg->from = new_hdr;
240 249
                    break;
241
-         case HDR_CONTACT:
250
+			case HDR_CONTACT:
242 251
                    new_msg->contact = new_hdr;
243 252
                    break;
244
-         case HDR_MAXFORWARDS :
253
+			case HDR_MAXFORWARDS :
245 254
                   new_msg->maxforwards = new_hdr;
246 255
                break;
247
-        case HDR_ROUTE :
256
+			case HDR_ROUTE :
248 257
                   new_msg->route = new_hdr;
249 258
                break;
250 259
       }
... ...
@@ -133,7 +133,7 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
133 133
 			&& /*callid length*/ EQ_LEN(callid)
134 134
 			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
135 135
 			&& /*from length*/ EQ_LEN(from)
136
-			&& /*to body*/get_to(t_msg)->body.len==get_to(p_msg)->body.len
136
+			&& /*to uri*/get_to(t_msg)->uri.len==get_to(p_msg)->uri.len
137 137
 			&& /*to tag*/p_cell->tag->len==get_to(p_msg)->tag_value.len
138 138
 			&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_LEN )
139 139
 			&& /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1)) )
... ...
@@ -144,8 +144,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
144 144
 				&& /*cseq nr*/!memcmp(get_cseq(t_msg)->number.s,
145 145
 					get_cseq(p_msg)->number.s,get_cseq(p_msg)->number.len)
146 146
 				&& /*from*/EQ_STR(from)
147
-				&& /*to body*/!memcmp(get_to(t_msg)->body.s,
148
-					get_to(p_msg)->body.s,get_to(t_msg)->body.len)
147
+				&& /*to uri*/!memcmp(get_to(t_msg)->uri.s,
148
+					get_to(p_msg)->uri.s,get_to(t_msg)->uri.len)
149 149
 				&& /*to tag*/!memcmp(p_cell->tag->s,
150 150
 					get_to(p_msg)->tag_value.s,p_cell->tag->len)
151 151
 				&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR)
... ...
@@ -264,7 +264,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
264 264
 			hdr->parsed=to_b;
265 265
 			hdr->body.len=tmp-hdr->body.s;
266 266
 			DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
267
-				hdr->name.s, hdr->body.len, to_b->body.s,to_b->body.len);
267
+				hdr->name.s, hdr->body.len, to_b->uri.s,to_b->uri.len);
268
+			DBG("to <%s>.len=%d\n",to_b->body.s,to_b->body.len);
268 269
 			break;
269 270
 		case HDR_FROM:
270 271
 		case HDR_CALLID:
... ...
@@ -156,6 +156,7 @@ struct to_param{
156 156
 struct to_body{
157 157
 	int error;
158 158
 	str body;
159
+	str uri;
159 160
 	str tag_value;
160 161
 	struct to_param *param_lst;
161 162
 	struct to_param *last_param;
... ...
@@ -409,8 +409,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
409 409
 						status=saved_status;
410 410
 						break;
411 411
 					case URI_ENCLOSED:
412
-						to_b->body.len = tmp - to_b->body.s;
413
-						*tmp = 0;
412
+						to_b->uri.len = tmp - to_b->uri.s;
413
+						//*tmp = 0;
414 414
 						status = E_URI_ENCLOSED;
415 415
 						break;
416 416
 					case URI_OR_TOKEN:
... ...
@@ -490,6 +490,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
490 490
 				switch (status)
491 491
 				{
492 492
 					case START_TO:
493
+						to_b->body.s=tmp;
493 494
 						status = S_URI_ENCLOSED;
494 495
 						break;
495 496
 					case DISPLAY_QUOTED:
... ...
@@ -517,9 +518,9 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
517 518
 					case DISPLAY_QUOTED:
518 519
 						break;
519 520
 					case URI_ENCLOSED:
520
-						*tmp = 0;
521
+						//*tmp = 0;
521 522
 					case E_URI_ENCLOSED:
522
-						to_b->body.len = tmp - to_b->body.s;
523
+						to_b->uri.len = tmp - to_b->uri.s;
523 524
 						status = END;
524 525
 						foo = 0;
525 526
 						break;
... ...
@@ -538,6 +539,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
538 539
 				switch (status)
539 540
 				{
540 541
 					case START_TO:
542
+						to_b->body.s = tmp;
541 543
 						status = DISPLAY_QUOTED;
542 544
 						break;
543 545
 					case DISPLAY_QUOTED:
... ...
@@ -563,10 +565,11 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
563 565
 					case URI_OR_TOKEN:
564 566
 						foo = tmp;
565 567
 					case MAYBE_URI_END:
566
-						to_b->body.len = foo - to_b->body.s;
568
+						to_b->uri.len = foo - to_b->uri.s;
567 569
 					case END:
570
+						to_b->body.len = tmp-to_b->body.s;
568 571
 						tmp = parse_to_param(tmp,end,to_b,&saved_status);
569
-						if (foo) *foo=0;
572
+						//if (foo) *foo=0;
570 573
 						goto endofheader;
571 574
 					case F_CRLF:
572 575
 					case F_LF:
... ...
@@ -583,11 +586,11 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
583 586
 				switch (status)
584 587
 				{
585 588
 					case START_TO:
586
-						to_b->body.s=tmp;
589
+						to_b->uri.s = to_b->body.s = tmp;
587 590
 						status = URI_OR_TOKEN;;
588 591
 						break;
589 592
 					case S_URI_ENCLOSED:
590
-						to_b->body.s=tmp;
593
+						to_b->uri.s=tmp;
591 594
 						status=URI_ENCLOSED;
592 595
 						break;
593 596
 					case MAYBE_URI_END:
... ...
@@ -603,7 +606,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
603 606
 						/*previous=crlf and now !=' '*/
604 607
 						goto endofheader;
605 608
 					default:
606
-						DBG("DEBUG: parse_to: spitting out [%c] in status %d\n",
609
+						DBG("DEBUG:parse_to: spitting out [%c] in status %d\n",
607 610
 						*tmp,status );
608 611
 						goto error;
609 612
 				}
... ...
@@ -617,10 +620,11 @@ endofheader:
617 620
 	/* check if error*/
618 621
 	switch(status){
619 622
 		case MAYBE_URI_END:
620
-			*foo=0;
621
-			to_b->body.len = foo - to_b->body.s;
623
+			//*foo=0;
624
+			to_b->uri.len = foo - to_b->uri.s;
622 625
 		case END:
623
-		case E_PARA_VALUE:
626
+			to_b->body.len = tmp - to_b->body.s;
627
+	case E_PARA_VALUE:
624 628
 			*(tmp-1)=0;
625 629
 			break;
626 630
 		default: