浏览代码

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 16 年之前
父节点
当前提交
cec6ad973d
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 5 0
      action.c
  2. 1 1
      route_struct.h

+ 5 - 0
action.c

@@ -490,6 +490,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 		case SET_HOST_T:
 		case SET_HOSTPORT_T:
 		case SET_HOSTPORTTRANS_T:
+		case SET_HOSTALL_T:
 		case SET_USER_T:
 		case SET_USERPASS_T:
 		case SET_PORT_T:
@@ -627,6 +628,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 				}
 				if ((a->type==SET_HOST_T)
 						|| (a->type==SET_HOSTPORT_T)
+						|| (a->type==SET_HOSTALL_T)
 						|| (a->type==SET_HOSTPORTTRANS_T)) {
 					tmp=a->val[0].u.string;
 					if (tmp) len = strlen(tmp);
@@ -639,6 +641,8 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 					if(crt+len>end) goto error_uri;
 					memcpy(crt,tmp,len);crt+=len;
 				}
+				if(a->type==SET_HOSTALL_T)
+					goto done_seturi;
 				/* port */
 				if ((a->type==SET_HOSTPORT_T)
 						|| (a->type==SET_HOSTPORTTRANS_T))
@@ -690,6 +694,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
 					*crt='?'; crt++;
 					memcpy(crt,tmp,len);crt+=len;
 				}
+	done_seturi:
 				*crt=0; /* null terminate the thing */
 				/* copy it to the msg */
 				if (msg->new_uri.s) pkg_free(msg->new_uri.s);

+ 1 - 1
route_struct.h

@@ -70,7 +70,7 @@ enum { METHOD_O=1, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
 
 enum { FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
 		SET_HOST_T, SET_HOSTPORT_T, SET_USER_T, SET_USERPASS_T,
-		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T,
+		SET_PORT_T, SET_URI_T, SET_HOSTPORTTRANS_T, SET_HOSTALL_T,
 		IF_T, SWITCH_T /* only until fixup*/,
 		BLOCK_T, EVAL_T, SWITCH_JT_T, SWITCH_COND_T, MATCH_COND_T, WHILE_T,
 		MODULE_T, MODULE3_T, MODULE4_T, MODULE5_T, MODULE6_T, MODULEX_T,