Module: sip-router Branch: master Commit: f6e2325aa6770840c25dbb64afd405f73077fc79 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f6e2325a...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Mon Dec 6 00:05:46 2010 +0100
pv: $snd(id) broken in $sndto(id) and $sndfrom(id)
- $snd(id) is aliased to $sndto(id) - $sndto(id) points to next hop address - $sndfrom(id) points to local socket to be used for sending
---
modules_k/pv/pv.c | 8 ++++++-- modules_k/pv/pv_branch.c | 40 +++++++++++++++++++++++++++++++++++++++- modules_k/pv/pv_branch.h | 4 +++- 3 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/modules_k/pv/pv.c b/modules_k/pv/pv.c index efeb7ee..3e21fc9 100644 --- a/modules_k/pv/pv.c +++ b/modules_k/pv/pv.c @@ -70,8 +70,12 @@ static pv_export_t mod_pvs[] = { { {"sel", sizeof("sel")-1}, /* select */ PVT_OTHER, pv_get_select, 0, pv_parse_select_name, 0, 0, 0 }, - {{"snd", (sizeof("snd")-1)}, PVT_OTHER, pv_get_snd, 0, - pv_parse_snd_name, 0, 0, 0}, + { {"snd", (sizeof("snd")-1)}, PVT_OTHER, pv_get_sndto, 0, + pv_parse_snd_name, 0, 0, 0 }, + { {"sndto", (sizeof("sndto")-1)}, PVT_OTHER, pv_get_sndto, 0, + pv_parse_snd_name, 0, 0, 0 }, + { {"sndfrom", (sizeof("sndfrom")-1)}, PVT_OTHER, pv_get_sndfrom, 0, + pv_parse_snd_name, 0, 0, 0 }, #ifdef WITH_XAVP { {"xavp", sizeof("xavp")-1}, /* xavp */ PVT_OTHER, pv_get_xavp, pv_set_xavp, diff --git a/modules_k/pv/pv_branch.c b/modules_k/pv/pv_branch.c index 0831bd5..a9dd1bc 100644 --- a/modules_k/pv/pv_branch.c +++ b/modules_k/pv/pv_branch.c @@ -328,7 +328,7 @@ error: return -1; }
-int pv_get_snd(struct sip_msg *msg, pv_param_t *param, +int pv_get_sndfrom(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) { struct onsend_info* snd_inf; @@ -365,6 +365,44 @@ int pv_get_snd(struct sip_msg *msg, pv_param_t *param, return 0; }
+int pv_get_sndto(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res) +{ + struct onsend_info* snd_inf; + str s; + + snd_inf=get_onsend_info(); + if (! likely(snd_inf && snd_inf->send_sock)) + return pv_get_null(msg, param, res); + + switch(param->pvn.u.isname.name.n) + { + case 1: /* af */ + return pv_get_uintval(msg, param, res, + (int)snd_inf->send_sock->address.af); + case 2: /* port */ + return pv_get_uintval(msg, param, res, + (int)su_getport(snd_inf->to)); + case 3: /* proto */ + return pv_get_uintval(msg, param, res, + (int)snd_inf->send_sock->proto); + case 4: /* buf */ + s.s = snd_inf->buf; + s.len = snd_inf->len; + return pv_get_strval(msg, param, res, &s); + case 5: /* len */ + return pv_get_uintval(msg, param, res, + (int)snd_inf->len); + default: + /* 0 - ip */ + s.s = su2a(snd_inf->to, sizeof(*snd_inf->to)); + s.len = strlen(s.s); + return pv_get_strval(msg, param, res, &s); + } + + return 0; +} + int pv_parse_snd_name(pv_spec_p sp, str *in) { if(sp==NULL || in==NULL || in->len<=0) diff --git a/modules_k/pv/pv_branch.h b/modules_k/pv/pv_branch.h index d8e3fbc..b10d877 100644 --- a/modules_k/pv/pv_branch.h +++ b/modules_k/pv/pv_branch.h @@ -31,7 +31,9 @@ int pv_set_branchx(struct sip_msg* msg, pv_param_t *param, int op, pv_value_t *val); int pv_parse_branchx_name(pv_spec_p sp, str *in);
-int pv_get_snd(struct sip_msg *msg, pv_param_t *param, +int pv_get_sndto(struct sip_msg *msg, pv_param_t *param, + pv_value_t *res); +int pv_get_sndfrom(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); int pv_parse_snd_name(pv_spec_p sp, str *in);