Module: kamailio Branch: master Commit: e4ee924b4919b3efd853c38506a3d2934797eaaa URL: https://github.com/kamailio/kamailio/commit/e4ee924b4919b3efd853c38506a3d293...
Author: Torrey Searle torrey@voxbone.com Committer: Torrey Searle torrey@voxbone.com Date: 2017-03-28T15:53:14+02:00
modules/sipt: make the digit terminator optional on set_destination
---
Modified: src/modules/sipt/doc/sipt_admin.xml Modified: src/modules/sipt/sipt.c
---
Diff: https://github.com/kamailio/kamailio/commit/e4ee924b4919b3efd853c38506a3d293... Patch: https://github.com/kamailio/kamailio/commit/e4ee924b4919b3efd853c38506a3d293...
---
diff --git a/src/modules/sipt/doc/sipt_admin.xml b/src/modules/sipt/doc/sipt_admin.xml index ddd865d..1f0361b 100644 --- a/src/modules/sipt/doc/sipt_admin.xml +++ b/src/modules/sipt/doc/sipt_admin.xml @@ -38,11 +38,13 @@ <section> <title>Functions</title> <section id="sipt.f.sipt_destination"> - <title><function moreinfo="none">sipt_destination(destination, hops, nai)</function></title> + <title><function moreinfo="none">sipt_destination(destination, hops, nai[, terminator=1])</function></title> <para> updates the IAM in the body if it exists, setting the called party number to <quote>destination</quote> with the nature address specified in <quote>nai</quote> and decrementing the hop counter value if present. - If the hop counter header is missing it will be added with the value of <quote>hops</quote>. + If the hop counter header is missing it will be added with the value of <quote>hops</quote>. If + <quote>terminator</quote> is set to 1, then F will be appened to digit string to indicate the number + is complete (default). </para> <example> <title><function moreinfo="none">sipt_destination(destination, hops, nai)</function> usage</title> diff --git a/src/modules/sipt/sipt.c b/src/modules/sipt/sipt.c index 9045c77..9825b68 100644 --- a/src/modules/sipt/sipt.c +++ b/src/modules/sipt/sipt.c @@ -40,6 +40,7 @@ MODULE_VERSION
static int sipt_set_bci_1(struct sip_msg *msg, char *_charge_indicator, char *_called_status, char * _called_category, char * _e2e_indicator); static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops, char * _nai); +static int sipt_destination2(struct sip_msg *msg, char *_destination, char *_hops, char * _nai, char * _terminator); static int sipt_set_calling(struct sip_msg *msg, char *_origin, char *_nai, char *_pres, char * _screen); static int sipt_get_hop_counter(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); static int sipt_get_event_info(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); @@ -132,6 +133,12 @@ static cmd_export_t cmds[]={ fixup_str_str_str, fixup_free_str_str_str, /* */ /* can be applied to original requests */ REQUEST_ROUTE|BRANCH_ROUTE}, + {"sipt_destination", /* action name as in scripts */ + (cmd_function)sipt_destination2, /* C function name */ + 4, /* number of parameters */ + fixup_str_str_str, fixup_free_str_str_str, /* */ + /* can be applied to original requests */ + REQUEST_ROUTE|BRANCH_ROUTE}, {"sipt_set_calling", /* action name as in scripts */ (cmd_function)sipt_set_calling, /* C function name */ 4, /* number of parameters */ @@ -566,7 +573,12 @@ static int sipt_set_bci_1(struct sip_msg *msg, char *_charge_indicator, char *_c return 1; }
-static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops, char * _nai) +static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops, char * _nai) { + str terminator = str_init("1"); + sipt_destination2(msg, _destination, _hops, _nai, &terminator); +} + +static int sipt_destination2(struct sip_msg *msg, char *_destination, char *_hops, char * _nai, char * _terminator) { str * str_hops = (str*)_hops; unsigned int hops = 0; @@ -574,6 +586,9 @@ static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops str * nai = (str*)_nai; unsigned int int_nai = 0; str2int(nai, &int_nai); + str * terminator = (str*)_terminator; + unsigned int int_terminator; + str2int(terminator, &int_terminator); str * destination = (str*)_destination; struct sdp_mangler mangle;
@@ -613,7 +628,10 @@ static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops
char * digits = calloc(1,destination->len+2); memcpy(digits, destination->s, destination->len); - digits[destination->len] = '#'; + + if (int_terminator) { + digits[destination->len] = '#'; + }
int res = isup_update_destination(&mangle, digits, hops, int_nai, (unsigned char*)body.s, body.len); free(digits);