Browse code

Add support for SET_HOSTALL_T action.

This patch adds support for SET_HOSTALL_T action which can be used to
rewrite the hostname, port, parameters, and headers parts of the
Request-URI, all at once.

Jan Janak authored on 17/03/2009 22:06:02
Showing 2 changed files
... ...
@@ -490,6 +490,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
490 490
 		case SET_HOST_T:
491 491
 		case SET_HOSTPORT_T:
492 492
 		case SET_HOSTPORTTRANS_T:
493
+		case SET_HOSTALL_T:
493 494
 		case SET_USER_T:
494 495
 		case SET_USERPASS_T:
495 496
 		case SET_PORT_T:
... ...
@@ -627,6 +628,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
627 627
 				}
628 628
 				if ((a->type==SET_HOST_T)
629 629
 						|| (a->type==SET_HOSTPORT_T)
630
+						|| (a->type==SET_HOSTALL_T)
630 631
 						|| (a->type==SET_HOSTPORTTRANS_T)) {
631 632
 					tmp=a->val[0].u.string;
632 633
 					if (tmp) len = strlen(tmp);
... ...
@@ -639,6 +641,8 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
639 639
 					if(crt+len>end) goto error_uri;
640 640
 					memcpy(crt,tmp,len);crt+=len;
641 641
 				}
642
+				if(a->type==SET_HOSTALL_T)
643
+					goto done_seturi;
642 644
 				/* port */
643 645
 				if ((a->type==SET_HOSTPORT_T)
644 646
 						|| (a->type==SET_HOSTPORTTRANS_T))
... ...
@@ -690,6 +694,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
690 690
 					*crt='?'; crt++;
691 691
 					memcpy(crt,tmp,len);crt+=len;
692 692
 				}
693
+	done_seturi:
693 694
 				*crt=0; /* null terminate the thing */
694 695
 				/* copy it to the msg */
695 696
 				if (msg->new_uri.s) pkg_free(msg->new_uri.s);
... ...
@@ -70,7 +70,7 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
70 70
 
71 71
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
72 72
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
73
-		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
73
+		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
74 74
 		IF_T, SWITCH_T /* only until fixup*/,
75 75
 		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
76 76
 		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,