Browse code

- fixup for outgoing processing -> add sip: to the default URi in loc. set - fixup for outgoing default -> instead of breaking the script, it should continue

Bogdan-Andrei Iancu authored on 01/12/2003 13:02:49
Showing 3 changed files
... ...
@@ -423,26 +423,37 @@ static int cpl_exit(void)
423 423
 
424 424
 
425 425
 
426
+#define BUILD_UH_SHM      (1<<0)
427
+#define BUILD_UH_ADDSIP   (1<<1)
428
+
426 429
 static inline int build_userhost(struct sip_uri *uri, str *uh, int flg)
427 430
 {
428 431
 	static char buf[MAX_USERHOST_LEN];
432
+	int len;
429 433
 
430
-	if (flg) {
431
-		uh->s = (char*)shm_malloc(uri->user.len+1+uri->host.len+1);
434
+	len = uri->user.len+1+uri->host.len+1+4*((flg&BUILD_UH_ADDSIP)!=0);
435
+	if (flg&BUILD_UH_SHM) {
436
+		uh->s = (char*)shm_malloc( len );
432 437
 		if (!uh->s) {
433 438
 			LOG(L_ERR,"ERROR:cpl-c:build_userhost: no more shm memory.\n");
434 439
 			return -1;
435 440
 		}
436 441
 	} else {
437 442
 		uh->s = buf;
438
-		if (uri->user.len+1+uri->host.len+1>MAX_USERHOST_LEN) {
443
+		if ( len > MAX_USERHOST_LEN ) {
439 444
 			LOG(L_ERR,"ERROR:cpl-c:build_userhost: user+host longer than %d\n",
440 445
 				MAX_USERHOST_LEN);
441 446
 			return -1;
442 447
 		}
443 448
 	}
444
-	memcpy( uh->s, uri->user.s, uri->user.len);
445
-	uh->len = uri->user.len;
449
+	if (flg&BUILD_UH_ADDSIP) {
450
+		memcpy( uh->s, "sip:", 4);
451
+		uh->len = 4;
452
+	} else {
453
+		uh->len = 0;
454
+	}
455
+	memcpy( uh->s+uh->len, uri->user.s, uri->user.len);
456
+	uh->len += uri->user.len;
446 457
 	uh->s[uh->len++] = '@';
447 458
 	memcpy( uh->s+uh->len, uri->host.s, uri->host.len);
448 459
 	uh->len += uri->host.len;
... ...
@@ -518,11 +529,11 @@ static int cpl_invoke_script(struct sip_msg* msg, char* str1, char* str2)
518 529
 	/* get the user_name */
519 530
 	if ( ((unsigned int)str1)&CPL_RUN_INCOMING ) {
520 531
 		/* if it's incoming -> get the destination user name */
521
-		if (get_dest_user( msg, &user, 1)==-1)
532
+		if (get_dest_user( msg, &user, BUILD_UH_SHM)==-1)
522 533
 			goto error0;
523 534
 	} else {
524 535
 		/* if it's outgoing -> get the origin user name */
525
-		if (get_orig_user( msg, &user, 1)==-1)
536
+		if (get_orig_user( msg, &user, BUILD_UH_SHM)==-1)
526 537
 			goto error0;
527 538
 	}
528 539
 
... ...
@@ -547,7 +558,7 @@ static int cpl_invoke_script(struct sip_msg* msg, char* str1, char* str2)
547 558
 	/* for OUTGOING we need also the destination user for init. with him
548 559
 	 * the location set */
549 560
 	if ( ((unsigned int)str1)&CPL_RUN_OUTGOING ) {
550
-		if (get_dest_user( msg, &loc,0)==-1)
561
+		if (get_dest_user( msg, &loc,BUILD_UH_ADDSIP)==-1)
551 562
 			goto error3;
552 563
 		if (add_location( &(cpl_intr->loc_set), &loc,10,CPL_LOC_DUPL)==-1)
553 564
 			goto error3;
... ...
@@ -891,7 +891,7 @@ static inline int run_default( struct cpl_interpreter *intr )
891 891
 				 * Proxy the call to the address in the location set.
892 892
 				 * With other words, let ser to continue processing the
893 893
 				 * request as nothing happened */
894
-				return SCRIPT_END;
894
+				return SCRIPT_DEFAULT;
895 895
 			}
896 896
 		} else {
897 897
 			/* case 3 : location modifications performed, no signalling 
... ...
@@ -40,7 +40,7 @@
40 40
 
41 41
 
42 42
 #define CPL_LOC_DUPL    (1<<0)
43
-#define CPL_LOC_NATED   (1<<0)
43
+#define CPL_LOC_NATED   (1<<1)
44 44
 
45 45
 
46 46
 struct location {