Module: sip-router Branch: master Commit: cec6ad973d08ed4c7c7b94ad17a0dddfe72cd2b3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cec6ad97...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Tue Mar 17 23:06:02 2009 +0100
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.
---
action.c | 5 +++++ route_struct.h | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/action.c b/action.c index 47d702c..2baa6cb 100644 --- a/action.c +++ b/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); diff --git a/route_struct.h b/route_struct.h index 288b67e..06c0a10 100644 --- a/route_struct.h +++ b/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,