Browse Source

modules/sipt: make the digit terminator optional on set_destination

Torrey Searle 8 years ago
parent
commit
e4ee924b49
2 changed files with 24 additions and 4 deletions
  1. 4 2
      src/modules/sipt/doc/sipt_admin.xml
  2. 20 2
      src/modules/sipt/sipt.c

+ 4 - 2
src/modules/sipt/doc/sipt_admin.xml

@@ -38,11 +38,13 @@
     <section>
     <section>
 	<title>Functions</title>
 	<title>Functions</title>
 	<section id="sipt.f.sipt_destination">
 	<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>
 		<para>
 			updates the IAM in the body if it exists, setting the called party number to <quote>destination</quote>
 			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.
 			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>
 		</para>
 		<example>
 		<example>
 			<title><function moreinfo="none">sipt_destination(destination, hops, nai)</function> usage</title>
 			<title><function moreinfo="none">sipt_destination(destination, hops, nai)</function> usage</title>

+ 20 - 2
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_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_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_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_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);
 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,         /* */
 		fixup_str_str_str, fixup_free_str_str_str,         /* */
 		/* can be applied to original requests */
 		/* can be applied to original requests */
 		REQUEST_ROUTE|BRANCH_ROUTE}, 
 		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 */
 	{"sipt_set_calling", /* action name as in scripts */
 		(cmd_function)sipt_set_calling,  /* C function name */
 		(cmd_function)sipt_set_calling,  /* C function name */
 		4,          /* number of parameters */
 		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;
 	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;
 	str * str_hops = (str*)_hops;
 	unsigned int hops = 0;
 	unsigned int hops = 0;
@@ -574,6 +586,9 @@ static int sipt_destination(struct sip_msg *msg, char *_destination, char *_hops
 	str * nai = (str*)_nai;
 	str * nai = (str*)_nai;
 	unsigned int int_nai = 0;
 	unsigned int int_nai = 0;
 	str2int(nai, &int_nai);
 	str2int(nai, &int_nai);
+	str * terminator = (str*)_terminator;
+	unsigned int int_terminator;
+	str2int(terminator, &int_terminator);
 	str * destination = (str*)_destination;
 	str * destination = (str*)_destination;
 	struct sdp_mangler mangle;
 	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);
 	char * digits = calloc(1,destination->len+2);
 	memcpy(digits, destination->s, destination->len);
 	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);
 	int res = isup_update_destination(&mangle, digits, hops, int_nai, (unsigned char*)body.s, body.len);
 	free(digits);
 	free(digits);