Browse code

msg_cloner clones msg->from->parsed too if parsed.

Jan Janak authored on 23/01/2003 22:25:05
Showing 1 changed files
... ...
@@ -34,6 +34,10 @@
34 34
  * You should have received a copy of the GNU General Public License 
35 35
  * along with this program; if not, write to the Free Software 
36 36
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
37
+ *
38
+ * History:
39
+ * --------
40
+ * 2003-01-23 - msg_cloner clones msg->from->parsed too (janakj)
37 41
  */
38 42
 
39 43
 #include "defs.h"
... ...
@@ -181,13 +185,17 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
181 185
 			case HDR_CSEQ:
182 186
 				len+=ROUND4(sizeof(struct cseq_body));
183 187
 				break;
184
-			case HDR_TO:
185
-				len+=ROUND4(sizeof(struct to_body));
186
-				/*to param*/
187
-				to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
188
-				for(;to_prm;to_prm=to_prm->next)
189
-					len+=ROUND4(sizeof(struct to_param ));
190
-				break;
188
+		        case HDR_TO:
189
+		        case HDR_FROM:
190
+				     /* From header might be unparsed */
191
+				if (hdr->parsed) {
192
+					len+=ROUND4(sizeof(struct to_body));
193
+					     /*to param*/
194
+					to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
195
+					for(;to_prm;to_prm=to_prm->next)
196
+						len+=ROUND4(sizeof(struct to_param ));
197
+				}
198
+				break;				
191 199
 			case HDR_VIA:
192 200
 				for (via=(struct via_body*)hdr->parsed;via;via=via->next)
193 201
 				{
... ...
@@ -199,8 +207,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
199 207
 				break;
200 208
 			
201 209
 			case HDR_CALLID:
202
-			case HDR_FROM:
203
-			case HDR_CONTACT:
210
+		        case HDR_CONTACT:
204 211
 			case HDR_MAXFORWARDS:
205 212
 			case HDR_ROUTE:
206 213
 			case HDR_RECORDROUTE:
... ...
@@ -375,6 +382,15 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
375 382
 				new_msg->cseq = new_hdr;
376 383
 				break;
377 384
 			case HDR_TO:
385
+		        case HDR_FROM:
386
+				if (hdr->type == HDR_TO) {
387
+					new_msg->to = new_hdr;
388
+				} else {
389
+					new_msg->from = new_hdr;
390
+				}
391
+
392
+				     /* From header might be unparsed */
393
+				if (!hdr->parsed) break;
378 394
 				new_hdr->parsed = p;
379 395
 				p +=ROUND4(sizeof(struct to_body));
380 396
 				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct to_body));
... ...
@@ -412,14 +428,10 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
412 428
 					((struct to_body*)new_hdr->parsed)->last_param
413 429
 						= new_to_prm;
414 430
 				}
415
-				new_msg->to = new_hdr;
416 431
 				break;
417 432
 			case HDR_CALLID:
418 433
 				new_msg->callid = new_hdr;
419 434
 				break;
420
-			case HDR_FROM:
421
-				new_msg->from = new_hdr;
422
-				break;
423 435
 			case HDR_CONTACT:
424 436
 				new_msg->contact = new_hdr;
425 437
 				break;