Module: sip-router Branch: master Commit: 221cdf8497c2375133dd73ff0bed44ed6180245b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=221cdf84...
Author: Hugh Waite hugh.waite@crocodile-rcs.com Committer: Hugh Waite hugh.waite@crocodile-rcs.com Date: Tue Jan 7 11:11:23 2014 +0000
rtpproxy: Allow any pvar for rtpproxy instance
---
modules/rtpproxy/README | 20 ++++++------ modules/rtpproxy/doc/rtpproxy_admin.xml | 10 +++--- modules/rtpproxy/rtpproxy.c | 49 +++++++++++++++---------------- modules/rtpproxy/rtpproxy.h | 2 + modules/rtpproxy/rtpproxy_db.c | 1 + modules/rtpproxy/rtpproxy_stream.c | 2 + 6 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/modules/rtpproxy/README b/modules/rtpproxy/README index 8979560..82ecd1e 100644 --- a/modules/rtpproxy/README +++ b/modules/rtpproxy/README @@ -63,7 +63,7 @@ Carsten Bock 4.8. extra_id_pv (string) 4.9. db_url (string) 4.10. table_name (string) - 4.11. rtp_inst_avp (string) + 4.11. rtp_inst_pvar (string)
5. Functions
@@ -102,7 +102,7 @@ Carsten Bock 1.8. Set extra_id_pv parameter 1.9. Set db_url parameter 1.10. Set table_name parameter - 1.11. Set rtp_inst_avp parameter + 1.11. Set rtp_inst_pvar parameter 1.12. set_rtp_proxy_set usage 1.13. rtpproxy_offer usage 1.14. rtpproxy_answer usage @@ -137,7 +137,7 @@ Chapter 1. Admin Guide 4.8. extra_id_pv (string) 4.9. db_url (string) 4.10. table_name (string) - 4.11. rtp_inst_avp (string) + 4.11. rtp_inst_pvar (string)
5. Functions
@@ -225,7 +225,7 @@ Chapter 1. Admin Guide 4.8. extra_id_pv (string) 4.9. db_url (string) 4.10. table_name (string) - 4.11. rtp_inst_avp (string) + 4.11. rtp_inst_pvar (string)
4.1. rtpproxy_sock (string)
@@ -381,17 +381,17 @@ modparam("rtpproxy", "db_url", "mysql://user:passwb@localhost/database") modparam("rtpproxy", "table_name", "my_rtpp_sets") ...
-4.11. rtp_inst_avp (string) +4.11. rtp_inst_pvar (string)
- An avp to store the chosen RTPProxy IP address. If this parameter is - set, the IP address and port of the instance chosen in a - rtpproxy_manage() call will be stored in the given AVP. + A pseudo variable to store the chosen RTPProxy IP address. If this + parameter is set, the IP address and port of the instance chosen will + be stored in the given variable.
By default, this parameter is not set.
- Example 1.11. Set rtp_inst_avp parameter + Example 1.11. Set rtp_inst_pvar parameter ... -modparam("rtpproxy", "rtp_inst_avp", "$avp(RTP_INSTANCE)") +modparam("rtpproxy", "rtp_inst_pvar", "$avp(RTP_INSTANCE)") ...
5. Functions diff --git a/modules/rtpproxy/doc/rtpproxy_admin.xml b/modules/rtpproxy/doc/rtpproxy_admin.xml index c4f2c86..db206f7 100644 --- a/modules/rtpproxy/doc/rtpproxy_admin.xml +++ b/modules/rtpproxy/doc/rtpproxy_admin.xml @@ -322,19 +322,19 @@ modparam("rtpproxy", "table_name", "my_rtpp_sets") </example> </section> <section> - <title><varname>rtp_inst_avp</varname> (string)</title> + <title><varname>rtp_inst_pvar</varname> (string)</title> <para> - An avp to store the chosen RTPProxy IP address. - If this parameter is set, the IP address and port of the instance chosen in a rtpproxy_manage() call will be stored in the given AVP. + A pseudo variable to store the chosen RTPProxy IP address. + If this parameter is set, the IP address and port of the instance chosen will be stored in the given variable. </para> <para> By default, this parameter is not set. </para> <example> - <title>Set <varname>rtp_inst_avp</varname> parameter</title> + <title>Set <varname>rtp_inst_pvar</varname> parameter</title> <programlisting format="linespecific"> ... -modparam("rtpproxy", "rtp_inst_avp", "$avp(RTP_INSTANCE)") +modparam("rtpproxy", "rtp_inst_pvar", "$avp(RTP_INSTANCE)") ... </programlisting> </example> diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c index 8cea776..073d954 100644 --- a/modules/rtpproxy/rtpproxy.c +++ b/modules/rtpproxy/rtpproxy.c @@ -308,8 +308,6 @@ static int mod_init(void); static int child_init(int); static void mod_destroy(void);
-static int set_rtp_inst_avp(const str * const uri); - /* Pseudo-Variables */ static int pv_get_rtpstat_f(struct sip_msg *, pv_param_t *, pv_value_t *);
@@ -339,9 +337,8 @@ struct rtpp_set * default_rtpp_set=0; static char *ice_candidate_priority_avp_param = NULL; static int ice_candidate_priority_avp_type; static int_str ice_candidate_priority_avp; -static char *rtp_inst_avp_param = NULL; -static int rtp_inst_avp_type; -static int_str rtp_inst_avp; +static str rtp_inst_pv_param = {NULL, 0}; +static pv_spec_t *rtp_inst_pvar = NULL;
/* array with the sockets used by rtpporxy (per process)*/ static unsigned int rtpp_no = 0; @@ -442,7 +439,7 @@ static param_export_t params[] = { {"extra_id_pv", STR_PARAM, &extra_id_pv_param.s }, {"db_url", STR_PARAM, &rtpp_db_url.s }, {"table_name", STR_PARAM, &rtpp_table_name.s }, - {"rtp_inst_avp", STR_PARAM, &rtp_inst_avp_param }, + {"rtp_inst_pvar", STR_PARAM, &rtp_inst_pv_param.s }, {0, 0, 0} };
@@ -976,17 +973,16 @@ mod_init(void) ice_candidate_priority_avp_type = avp_flags; }
- if (rtp_inst_avp_param) { - s.s = rtp_inst_avp_param; s.len = strlen(s.s); - if (pv_parse_spec(&s, &avp_spec) == 0 || avp_spec.type != PVT_AVP) { - LM_ERR("malformed or non AVP definition <%s>\n", rtp_inst_avp_param); - return -1; - } - if (pv_get_avp_name(0, &(avp_spec.pvp), &rtp_inst_avp, &avp_flags) != 0) { - LM_ERR("invalid AVP definition <%s>\n", rtp_inst_avp_param); + if (rtp_inst_pv_param.s) { + rtp_inst_pv_param.len = strlen(rtp_inst_pv_param.s); + rtp_inst_pvar = pv_cache_get(&rtp_inst_pv_param); + if ((rtp_inst_pvar == NULL) || + ((rtp_inst_pvar->type != PVT_AVP) && + (rtp_inst_pvar->type != PVT_XAVP) && + (rtp_inst_pvar->type != PVT_SCRIPTVAR))) { + LM_ERR("Invalid pvar name <%.*s>\n", rtp_inst_pv_param.len, rtp_inst_pv_param.s); return -1; } - rtp_inst_avp_type = avp_flags; }
if (extra_id_pv_param.s && *extra_id_pv_param.s) { @@ -1780,9 +1776,6 @@ select_rtpp_node(str callid, int do_test) node = selected_rtpp_set->rn_first; if (node->rn_disabled && node->rn_recheck_ticks <= get_ticks()) node->rn_disabled = rtpp_test(node, 1, 0); - if (!node->rn_disabled) { - set_rtp_inst_avp(&node->rn_url); - } return node->rn_disabled ? NULL : node; }
@@ -1833,7 +1826,6 @@ found: if (node->rn_disabled) goto retry; } - set_rtp_inst_avp(&node->rn_url); return node; }
@@ -1983,6 +1975,7 @@ unforce_rtp_proxy(struct sip_msg* msg, char* flags) LM_ERR("no available proxies\n"); return -1; } + set_rtp_inst_pvar(msg, &node->rn_url); send_rtpp_command(node, v, (to_tag.len > 0) ? 10 : 8);
return 1; @@ -2654,6 +2647,7 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int offer, int forc LM_ERR("no available proxies\n"); FORCE_RTP_PROXY_RET (-3); } + set_rtp_inst_pvar(msg, &node->rn_url); if (rep_opts.oidx > 0) { if (node->rn_rep_supported == 0) { LM_WARN("re-packetization is requested but is not " @@ -2933,6 +2927,7 @@ static int start_recording_f(struct sip_msg* msg, char *foo, char *bar) LM_ERR("no available proxies\n"); return -1; } + set_rtp_inst_pvar(msg, &node->rn_url);
nitems = 8; if (msg->first_line.type == SIP_REPLY) { @@ -2991,6 +2986,7 @@ pv_get_rtpstat_f(struct sip_msg *msg, pv_param_t *param, LM_ERR("no available proxies\n"); return -1; } + set_rtp_inst_pvar(msg, &node->rn_url); nitems = 8; if (msg->first_line.type == SIP_REPLY) { if (to_tag.len == 0) @@ -3010,16 +3006,19 @@ pv_get_rtpstat_f(struct sip_msg *msg, pv_param_t *param, return pv_get_strval(msg, param, res, &ret_val); }
-static int set_rtp_inst_avp(const str * const uri) { - int_str avp_val; - avp_val.s = *uri; +int set_rtp_inst_pvar(struct sip_msg *msg, const str * const uri) { + pv_value_t val;
- if (rtp_inst_avp_param == NULL) + if (rtp_inst_pvar == NULL) return 0;
- if (add_avp(AVP_VAL_STR | rtp_inst_avp_type, rtp_inst_avp, avp_val) != 0) + memset(&val, 0, sizeof(pv_value_t)); + val.flags = PV_VAL_STR; + val.rs = *uri; + + if (rtp_inst_pvar->setf(msg, &rtp_inst_pvar->pvp, (int)EQ_T, &val) < 0) { - LM_ERR("Failed to add RTPProxy URI to avp\n"); + LM_ERR("Failed to add RTPProxy URI to pvar\n"); return -1; } return 0; diff --git a/modules/rtpproxy/rtpproxy.h b/modules/rtpproxy/rtpproxy.h index 8672926..d15a58b 100644 --- a/modules/rtpproxy/rtpproxy.h +++ b/modules/rtpproxy/rtpproxy.h @@ -72,6 +72,8 @@ char *send_rtpp_command(struct rtpp_node *, struct iovec *, int); struct rtpp_set *get_rtpp_set(str *set_name); int insert_rtpp_node(struct rtpp_set *const rtpp_list, const str *const url, const int weight, const int disabled);
+int set_rtp_inst_pvar(struct sip_msg *msg, const str * const uri); + int init_rtpproxy_db(void);
extern str rtpp_db_url; diff --git a/modules/rtpproxy/rtpproxy_db.c b/modules/rtpproxy/rtpproxy_db.c index 2d3e374..cacac30 100644 --- a/modules/rtpproxy/rtpproxy_db.c +++ b/modules/rtpproxy/rtpproxy_db.c @@ -24,6 +24,7 @@ #include "../../lib/srdb1/db.h" #include "../../lib/srdb1/db_res.h"
+#include "../../parser/msg_parser.h" #include "rtpproxy.h"
#define RTPP_TABLE_VERSION 1 diff --git a/modules/rtpproxy/rtpproxy_stream.c b/modules/rtpproxy/rtpproxy_stream.c index 20693e0..944c8d2 100644 --- a/modules/rtpproxy/rtpproxy_stream.c +++ b/modules/rtpproxy/rtpproxy_stream.c @@ -119,6 +119,7 @@ rtpproxy_stream(struct sip_msg* msg, str *pname, int count, int stream2uac) "node. Please upgrade the RTPproxy and try again.\n"); return -1; } + set_rtp_inst_pvar(msg, &node->rn_url); nitems = 11; if (stream2uac == 0) { if (to_tag.len == 0) @@ -202,6 +203,7 @@ rtpproxy_stop_stream(struct sip_msg* msg, int stream2uac) "node. Please upgrade the RTPproxy and try again.\n"); return -1; } + set_rtp_inst_pvar(msg, &node->rn_url); nitems = 9; if (stream2uac == 0) { if (to_tag.len == 0)
7 jan 2014 kl. 12:58 skrev Hugh Waite hugh.waite@crocodile-rcs.com:
- A pseudo variable to store the chosen RTPProxy IP address. If this
- parameter is set, the IP address and port of the instance chosen will
- be stored in the given variable.
Please give examples for IPv4, IPv6 and other possible address families :-)
THanks, /O
Hi, The feature actually stores the raw 'URL' string used to connect to rtpproxy, as given in the rtpproxy_sock modparam or the database. I've clarified the README and added a usage example. The readme currently doesn't have examples for unix sockets or IPv6 (in the rtpproxy_sock modparam section) and I don't want to put in an incorrect example, so for now my usage example reuses the existing udp:localhost:12221 entry.
Regards, Hugh
On 07/01/2014 12:15, Olle E. Johansson wrote:
7 jan 2014 kl. 12:58 skrev Hugh Waite <hugh.waite@crocodile-rcs.com mailto:hugh.waite@crocodile-rcs.com>:
- A pseudo variable to store the chosen RTPProxy IP address. If
this
- parameter is set, the IP address and port of the instance chosen
will
- be stored in the given variable.
Please give examples for IPv4, IPv6 and other possible address families :-)
THanks, /O
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev