From e4ee924b4919b3efd853c38506a3d2934797eaaa Mon Sep 17 00:00:00 2001 From: Torrey Searle Date: Tue, 28 Mar 2017 15:53:14 +0200 Subject: [PATCH] modules/sipt: make the digit terminator optional on set_destination --- src/modules/sipt/doc/sipt_admin.xml | 6 ++++-- src/modules/sipt/sipt.c | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/modules/sipt/doc/sipt_admin.xml b/src/modules/sipt/doc/sipt_admin.xml index ddd865d02bc..1f0361b8a57 100644 --- a/src/modules/sipt/doc/sipt_admin.xml +++ b/src/modules/sipt/doc/sipt_admin.xml @@ -38,11 +38,13 @@
Functions
- <function moreinfo="none">sipt_destination(destination, hops, nai)</function> + <function moreinfo="none">sipt_destination(destination, hops, nai[, terminator=1])</function> updates the IAM in the body if it exists, setting the called party number to destination with the nature address specified in nai and decrementing the hop counter value if present. - If the hop counter header is missing it will be added with the value of hops. + If the hop counter header is missing it will be added with the value of hops. If + terminator is set to 1, then F will be appened to digit string to indicate the number + is complete (default). <function moreinfo="none">sipt_destination(destination, hops, nai)</function> usage diff --git a/src/modules/sipt/sipt.c b/src/modules/sipt/sipt.c index 9045c77faf5..9825b68e8e8 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);