From 8e7dd5269540d6a2bf3f3687d85e270cbb1d8753 Mon Sep 17 00:00:00 2001
From: Christian Richter <christian.richter@beronet.com>
Date: Thu, 9 Mar 2006 18:01:27 +0000
Subject: [PATCH] added option to change the connected party number dialplan
 (ton)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@12481 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_misdn.c              | 34 ++++++++++++++++++++++++------
 channels/misdn/chan_misdn_config.h |  1 +
 channels/misdn/isdn_lib.c          |  1 +
 channels/misdn/isdn_lib.h          |  1 +
 channels/misdn/isdn_msg_parser.c   |  2 +-
 channels/misdn_config.c            |  1 +
 configs/misdn.conf.sample          |  7 ++++++
 7 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index d4a314bbbe..4290a30e12 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -648,13 +648,14 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel
 {
 	struct ast_channel *ast=help->ast;
 	ast_cli(fd,
-		"* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s ctx:%s state:%s\n",
+		"* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
 
 		bc->pid, bc->port, bc->channel,
 		bc->nt?"NT":"TE",
 		help->orginator == ORG_AST?"*":"I",
 		ast?ast->exten:NULL,
 		ast?AST_CID_P(ast):NULL,
+		bc->rad,
 		ast?ast->context:NULL,
 		misdn_get_ch_state(help)
 		);
@@ -1340,26 +1341,47 @@ static int read_config(struct chan_list *ch, int orig) {
 			misdn_cfg_get( port, MISDN_CFG_LOCALDIALPLAN, &bc->onumplan, sizeof(int));
 			switch (bc->onumplan) {
 			case NUMPLAN_INTERNATIONAL:
-				chan_misdn_log(2, port, " --> TON: International\n");
+				chan_misdn_log(2, port, " --> LTON: International\n");
 				break;
 			case NUMPLAN_NATIONAL:
-				chan_misdn_log(2, port, " --> TON: National\n");
+				chan_misdn_log(2, port, " --> LTON: National\n");
 				break;
 			case NUMPLAN_SUBSCRIBER:
-				chan_misdn_log(2, port, " --> TON: Subscriber\n");
+				chan_misdn_log(2, port, " --> LTON: Subscriber\n");
 				break;
 			case NUMPLAN_UNKNOWN:
-				chan_misdn_log(2, port, " --> TON: Unknown\n");
+				chan_misdn_log(2, port, " --> LTON: Unknown\n");
 				break;
 				/* Maybe we should cut off the prefix if present ? */
 			default:
 					chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
 					break;
 			}
+
+			misdn_cfg_get( port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(int));
+
+			switch (bc->cpnnumplan) {
+			case NUMPLAN_INTERNATIONAL:
+				chan_misdn_log(2, port, " --> CTON: International\n");
+				break;
+			case NUMPLAN_NATIONAL:
+				chan_misdn_log(2, port, " --> CTON: National\n");
+				break;
+			case NUMPLAN_SUBSCRIBER:
+				chan_misdn_log(2, port, " --> CTON: Subscriber\n");
+				break;
+			case NUMPLAN_UNKNOWN:
+				chan_misdn_log(2, port, " --> CTON: Unknown\n");
+				break;
+				/* Maybe we should cut off the prefix if present ? */
+			default:
+					chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
+					break;
+			}
+
 		}
 
 		
-				
 		
 	} else { /** ORIGINATOR MISDN **/
 		
diff --git a/channels/misdn/chan_misdn_config.h b/channels/misdn/chan_misdn_config.h
index 1c6bb106d1..d30e1482c2 100644
--- a/channels/misdn/chan_misdn_config.h
+++ b/channels/misdn/chan_misdn_config.h
@@ -34,6 +34,7 @@ enum misdn_cfg_elements {
 	MISDN_CFG_METHOD,              /* char[] */
 	MISDN_CFG_DIALPLAN,            /* int */
 	MISDN_CFG_LOCALDIALPLAN,       /* int */
+	MISDN_CFG_CPNDIALPLAN,       /* int */
 	MISDN_CFG_NATPREFIX,           /* char[] */
 	MISDN_CFG_INTERNATPREFIX,      /* char[] */
 	MISDN_CFG_PRES,                /* int */
diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c
index 37f0bfbe91..a699d7f8a3 100644
--- a/channels/misdn/isdn_lib.c
+++ b/channels/misdn/isdn_lib.c
@@ -463,6 +463,7 @@ void empty_bc(struct misdn_bchannel *bc)
 	bc->dnumplan=NUMPLAN_UNKNOWN;
 	bc->onumplan=NUMPLAN_UNKNOWN;
 	bc->rnumplan=NUMPLAN_UNKNOWN;
+	bc->cpnnumplan=NUMPLAN_UNKNOWN;
 	
 
 	bc->active = 0;
diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h
index 4b5d17db68..2c99d946ba 100644
--- a/channels/misdn/isdn_lib.h
+++ b/channels/misdn/isdn_lib.h
@@ -210,6 +210,7 @@ struct misdn_bchannel {
 	enum mISDN_NUMBER_PLAN dnumplan;
 	enum mISDN_NUMBER_PLAN rnumplan;
 	enum mISDN_NUMBER_PLAN onumplan;
+	enum mISDN_NUMBER_PLAN cpnnumplan;
 
 	int progress_coding;
 	int progress_location;
diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c
index 5eb7e1f683..7ae9a53693 100644
--- a/channels/misdn/isdn_msg_parser.c
+++ b/channels/misdn/isdn_msg_parser.c
@@ -359,7 +359,7 @@ msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
 	}
   
 	{
-		int type=0, plan=1, present=2, screen=0;
+		int type=bc->cpnnumplan, plan=1, present=2, screen=0;
 		enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, (unsigned char*) bc->dad , nt , bc);
 	}
 
diff --git a/channels/misdn_config.c b/channels/misdn_config.c
index 5936429593..fa712d523c 100644
--- a/channels/misdn_config.c
+++ b/channels/misdn_config.c
@@ -95,6 +95,7 @@ static const struct misdn_cfg_spec port_spec[] = {
 	{ "method", MISDN_CFG_METHOD, MISDN_CTYPE_STR, "standard", NONE },
 	{ "dialplan", MISDN_CFG_DIALPLAN, MISDN_CTYPE_INT, "0", NONE },
 	{ "localdialplan", MISDN_CFG_LOCALDIALPLAN, MISDN_CTYPE_INT, "0", NONE },
+	{ "cpndialplan", MISDN_CFG_CPNDIALPLAN, MISDN_CTYPE_INT, "0", NONE },
 	{ "nationalprefix", MISDN_CFG_NATPREFIX, MISDN_CTYPE_STR, "0", NONE },
 	{ "internationalprefix", MISDN_CFG_INTERNATPREFIX, MISDN_CTYPE_STR, "00", NONE },
 	{ "presentation", MISDN_CFG_PRES, MISDN_CTYPE_INT, "-1", NONE },
diff --git a/configs/misdn.conf.sample b/configs/misdn.conf.sample
index 8418230351..d69e063980 100644
--- a/configs/misdn.conf.sample
+++ b/configs/misdn.conf.sample
@@ -176,6 +176,12 @@ method=standard
 ;
 ; dialplan means Type Of Number in ISDN Terms (for outgoing calls)
 ;
+; there are different types of the dialplan:
+;
+; dialplan -> outgoing Number
+; localdialplan -> callerid
+; cpndialplan -> connected party number
+;
 ; dialplan options: 
 ;
 ; 0 - unknown
@@ -189,6 +195,7 @@ method=standard
 ;
 dialplan=0
 localdialplan=0
+cpndialplan=0
 
 
 
-- 
GitLab