[asterisk-commits] rmudgett: branch group/v14_colp r168612 - in /team/group/v14_colp: ./ channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 14 14:28:48 CST 2009


Author: rmudgett
Date: Wed Jan 14 14:28:48 2009
New Revision: 168612

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168612
Log:
Merged from:
https://origsvn.digium.com/svn/asterisk/team/group/issue8824

..........
r168555 | rmudgett | 2009-01-13 12:47:57 -0600 (Tue, 13 Jan 2009) | 6 lines

Expand upon JIRA ABE-1747 in relation to AST-165
*  Added the following new parameters: unknownprefix, netspecificprefix,
subscriberprefix, and abbreviatedprefix in misdn.conf to prefix any
received number from the ISDN link if that number has the corresponding
Type-Of-Number.

Modified:
    team/group/v14_colp/CHANGES
    team/group/v14_colp/channels/chan_misdn.c
    team/group/v14_colp/channels/misdn/chan_misdn_config.h
    team/group/v14_colp/channels/misdn_config.c
    team/group/v14_colp/configs/misdn.conf.sample

Modified: team/group/v14_colp/CHANGES
URL: http://svn.digium.com/svn-view/asterisk/team/group/v14_colp/CHANGES?view=diff&rev=168612&r1=168611&r2=168612
==============================================================================
--- team/group/v14_colp/CHANGES (original)
+++ team/group/v14_colp/CHANGES Wed Jan 14 14:28:48 2009
@@ -29,6 +29,11 @@
   * Made use the nationalprefix and internationalprefix misdn.conf
     parameters to prefix any received number from the ISDN link if that
     number has the corresponding Type-Of-Number.
+  * Added the following new parameters: unknownprefix, netspecificprefix,
+    subscriberprefix, and abbreviatedprefix in misdn.conf to prefix any
+    received number from the ISDN link if that number has the corresponding
+    Type-Of-Number.
+
 
 SIP channel driver (chan_sip) changes
 -------------------------------------------

Modified: team/group/v14_colp/channels/chan_misdn.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/v14_colp/channels/chan_misdn.c?view=diff&rev=168612&r1=168611&r2=168612
==============================================================================
--- team/group/v14_colp/channels/chan_misdn.c (original)
+++ team/group/v14_colp/channels/chan_misdn.c Wed Jan 14 14:28:48 2009
@@ -1273,7 +1273,55 @@
 /* ******************************************************************* */
 /*!
  * \internal
- * \brief Add a confiured prefix to the given number.
+ * \brief Prefix a string to another string in place.
+ *
+ * \param str_prefix String to prefix to the main string.
+ * \param str_main String to get the prefix added to it.
+ * \param size Buffer size of the main string (Includes null terminator).
+ *
+ * \note The str_main buffer size must be greater than one.
+ *
+ * \return Nothing
+ */
+static void misdn_prefix_string(const char *str_prefix, char *str_main, size_t size)
+{
+	size_t len_over;
+	size_t len_total;
+	size_t len_main;
+	size_t len_prefix;
+
+	len_prefix = strlen(str_prefix);
+	if (!len_prefix) {
+		/* There is no prefix to prepend. */
+		return;
+	}
+	len_main = strlen(str_main);
+	len_total = len_prefix + len_main;
+	if (size <= len_total) {
+		/* We need to truncate since the buffer is too small. */
+		len_over = len_total + 1 - size;
+		if (len_over <= len_main) {
+			len_main -= len_over;
+		} else {
+			len_over -= len_main;
+			len_main = 0;
+			len_prefix -= len_over;
+		}
+	}
+	if (len_main) {
+		memmove(str_main + len_prefix, str_main, len_main);
+	}
+	memcpy(str_main, str_prefix, len_prefix);
+	str_main[len_prefix + len_main] = 0;
+}	/* end misdn_prefix_string() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Add a configured prefix to the given number.
  *
  * \param port Logical port number
  * \param number_type Type-of-number passed in.
@@ -1284,22 +1332,36 @@
  */
 static void misdn_add_number_prefix(int port, enum mISDN_NUMBER_TYPE number_type, char *number, size_t size)
 {
-	char prefix[MISDN_MAX_NUMBER_LEN];
-	char saved_number[MISDN_MAX_NUMBER_LEN];
-
-	prefix[0] = 0;
+	enum misdn_cfg_elements type_prefix;
+	char num_prefix[MISDN_MAX_NUMBER_LEN];
+
+	/* Get prefix string. */
 	switch (number_type) {
+	case NUMTYPE_UNKNOWN:
+		type_prefix = MISDN_CFG_TON_PREFIX_UNKNOWN;
+		break;
 	case NUMTYPE_INTERNATIONAL:
-		misdn_cfg_get(port, MISDN_CFG_INTERNATPREFIX, prefix, sizeof(prefix));
+		type_prefix = MISDN_CFG_TON_PREFIX_INTERNATIONAL;
 		break;
 	case NUMTYPE_NATIONAL:
-		misdn_cfg_get(port, MISDN_CFG_NATPREFIX, prefix, sizeof(prefix));
+		type_prefix = MISDN_CFG_TON_PREFIX_NATIONAL;
+		break;
+	case NUMTYPE_NETWORK_SPECIFIC:
+		type_prefix = MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC;
+		break;
+	case NUMTYPE_SUBSCRIBER:
+		type_prefix = MISDN_CFG_TON_PREFIX_SUBSCRIBER;
+		break;
+	case NUMTYPE_ABBREVIATED:
+		type_prefix = MISDN_CFG_TON_PREFIX_ABBREVIATED;
 		break;
 	default:
+		/* Type-of-number does not have a prefix that can be added. */
 		return;
-	}
-	ast_copy_string(saved_number, number, sizeof(saved_number));
-	snprintf(number, size, "%s%s", prefix, saved_number);
+	}	/* end switch */
+	misdn_cfg_get(port, type_prefix, num_prefix, sizeof(num_prefix));
+
+	misdn_prefix_string(num_prefix, number, size);
 }	/* end misdn_add_number_prefix() */
 
 static void export_aoc_vars(int originator, struct ast_channel *ast, struct misdn_bchannel *bc)

Modified: team/group/v14_colp/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/v14_colp/channels/misdn/chan_misdn_config.h?view=diff&rev=168612&r1=168611&r2=168612
==============================================================================
--- team/group/v14_colp/channels/misdn/chan_misdn_config.h (original)
+++ team/group/v14_colp/channels/misdn/chan_misdn_config.h Wed Jan 14 14:28:48 2009
@@ -46,8 +46,12 @@
 	MISDN_CFG_DIALPLAN,            /* int */
 	MISDN_CFG_LOCALDIALPLAN,       /* int */
 	MISDN_CFG_CPNDIALPLAN,       /* int */
-	MISDN_CFG_NATPREFIX,           /* char[] */
-	MISDN_CFG_INTERNATPREFIX,      /* char[] */
+	MISDN_CFG_TON_PREFIX_UNKNOWN,         /* char[] */
+	MISDN_CFG_TON_PREFIX_INTERNATIONAL,   /* char[] */
+	MISDN_CFG_TON_PREFIX_NATIONAL,        /* char[] */
+	MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC,/* char[] */
+	MISDN_CFG_TON_PREFIX_SUBSCRIBER,      /* char[] */
+	MISDN_CFG_TON_PREFIX_ABBREVIATED,     /* char[] */
 	MISDN_CFG_PRES,                /* int */
 	MISDN_CFG_SCREEN,              /* int */
 	MISDN_CFG_DISPLAY_CONNECTED,   /* int */

Modified: team/group/v14_colp/channels/misdn_config.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/v14_colp/channels/misdn_config.c?view=diff&rev=168612&r1=168611&r2=168612
==============================================================================
--- team/group/v14_colp/channels/misdn_config.c (original)
+++ team/group/v14_colp/channels/misdn_config.c Wed Jan 14 14:28:48 2009
@@ -191,12 +191,24 @@
 		"\t1 - International\n"
 		"\t2 - National\n"
 		"\t4 - Subscriber" },
-	{ "nationalprefix", MISDN_CFG_NATPREFIX, MISDN_CTYPE_STR, "0", NONE,
-		"Prefix for national, this is put before the\n"
-		"\toad if an according dialplan is set by the other end." },
-	{ "internationalprefix", MISDN_CFG_INTERNATPREFIX, MISDN_CTYPE_STR, "00", NONE,
-		"Prefix for international, this is put before the\n"
-		"\toad if an according dialplan is set by the other end." },
+	{ "unknownprefix", MISDN_CFG_TON_PREFIX_UNKNOWN, MISDN_CTYPE_STR, "", NONE,
+		"Prefix for unknown numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is unknown." },
+	{ "internationalprefix", MISDN_CFG_TON_PREFIX_INTERNATIONAL, MISDN_CTYPE_STR, "00", NONE,
+		"Prefix for international numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is international." },
+	{ "nationalprefix", MISDN_CFG_TON_PREFIX_NATIONAL, MISDN_CTYPE_STR, "0", NONE,
+		"Prefix for national numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is national." },
+	{ "netspecificprefix", MISDN_CFG_TON_PREFIX_NETWORK_SPECIFIC, MISDN_CTYPE_STR, "", NONE,
+		"Prefix for network-specific numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is network-specific." },
+	{ "subscriberprefix", MISDN_CFG_TON_PREFIX_SUBSCRIBER, MISDN_CTYPE_STR, "", NONE,
+		"Prefix for subscriber numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is subscriber." },
+	{ "abbreviatedprefix", MISDN_CFG_TON_PREFIX_ABBREVIATED, MISDN_CTYPE_STR, "", NONE,
+		"Prefix for abbreviated numbers, this is put before an incoming number\n"
+		"\tif its type-of-number is abbreviated." },
 	{ "presentation", MISDN_CFG_PRES, MISDN_CTYPE_INT, "-1", NONE,
 		"These (presentation and screen) are the exact isdn screening and presentation\n"
 		"\tindicators.\n"

Modified: team/group/v14_colp/configs/misdn.conf.sample
URL: http://svn.digium.com/svn-view/asterisk/team/group/v14_colp/configs/misdn.conf.sample?view=diff&rev=168612&r1=168611&r2=168612
==============================================================================
--- team/group/v14_colp/configs/misdn.conf.sample (original)
+++ team/group/v14_colp/configs/misdn.conf.sample Wed Jan 14 14:28:48 2009
@@ -196,11 +196,20 @@
 ; correspondng Type-Of-Number.
 ; See the dialplan options.
 ;
-; default values: nationalprefix      : 0
-;                 internationalprefix : 00
-;
+; default values:
+;    unknownprefix=
+;    internationalprefix=00
+;    nationalprefix=0
+;    netspecificprefix=
+;    subscriberprefix=
+;    abbreviatedprefix=
+;
+;unknownprefix=
+internationalprefix=00
 nationalprefix=0
-internationalprefix=00
+;netspecificprefix=
+;subscriberprefix=
+;abbreviatedprefix=
 
 ; set rx/tx gains between -8 and 8 to change the RX/TX Gain
 ;
@@ -301,7 +310,9 @@
 ; 0 - unknown
 ; 1 - International
 ; 2 - National
+; 3 - Network-Specific
 ; 4 - Subscriber
+; 5 - Abbreviated
 ;
 ; default value: 0
 ;




More information about the asterisk-commits mailing list