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 628
 				}
628 629
 				if ((a->type==SET_HOST_T)
629 630
 						|| (a->type==SET_HOSTPORT_T)
631
+						|| (a->type==SET_HOSTALL_T)
630 632
 						|| (a->type==SET_HOSTPORTTRANS_T)) {
631 633
 					tmp=a->val[0].u.string;
632 634
 					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 641
 					if(crt+len>end) goto error_uri;
640 642
 					memcpy(crt,tmp,len);crt+=len;
641 643
 				}
644
+				if(a->type==SET_HOSTALL_T)
645
+					goto done_seturi;
642 646
 				/* port */
643 647
 				if ((a->type==SET_HOSTPORT_T)
644 648
 						|| (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 694
 					*crt='?'; crt++;
691 695
 					memcpy(crt,tmp,len);crt+=len;
692 696
 				}
697
+	done_seturi:
693 698
 				*crt=0; /* null terminate the thing */
694 699
 				/* copy it to the msg */
695 700
 				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,