[asterisk-commits] rmudgett: branch group/issue8824 r140166 - in /team/group/issue8824/channels:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 26 12:57:37 CDT 2008


Author: rmudgett
Date: Tue Aug 26 12:57:36 2008
New Revision: 140166

URL: http://svn.digium.com/view/asterisk?view=rev&rev=140166
Log:
First installment of COLP/COLR feature for mISDN.

channels/chan_misdn.c
*  Added doxygen comments to struct chan_list definition.
*  Commented out unused chan_list elemetns.
*  Added presentation/screening conversion functions.
*  Collected dialed, caller, connected line, and redirecting endpoint
information in struct misdn_channel.
*  Added COLP/COLR exchange with Asterisk core.

channels/misdn/isdn_lib.c
*  Collected dialed, caller, connected line, and redirecting endpoint
information in struct misdn_channel.

channels/misdn/isdn_lib.h
*  Collected caller, connected, and redirecting endpoint information
in struct misdn_channel.
*  Collected dialed information in struct misdn_channel.
*  Added subaddress fields for future.

channels/misdn/isdn_lib_intern.h
* Deleted unused field in struct isdn_msg.

channels/misdn/isdn_msg_parser.c
*  parse_setup() was not recording the calling number screening
indicator field.  Added recording of redirecting number presentation
and screening information.
*  Made parse_connect() record the number presentation and screening
information.
*  Collected dialed, caller, connected line, and redirecting endpoint
information in struct misdn_channel.


Modified:
    team/group/issue8824/channels/chan_misdn.c
    team/group/issue8824/channels/misdn/isdn_lib.c
    team/group/issue8824/channels/misdn/isdn_lib.h
    team/group/issue8824/channels/misdn/isdn_lib_intern.h
    team/group/issue8824/channels/misdn/isdn_msg_parser.c

Modified: team/group/issue8824/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_misdn.c?view=diff&rev=140166&r1=140165&r2=140166
==============================================================================
--- team/group/issue8824/channels/chan_misdn.c (original)
+++ team/group/issue8824/channels/chan_misdn.c Tue Aug 26 12:57:36 2008
@@ -115,112 +115,293 @@
 
 enum misdn_chan_state {
 	MISDN_NOTHING=0,	/*!< at beginning */
-	MISDN_WAITING4DIGS, /*!<  when waiting for infos */
-	MISDN_EXTCANTMATCH, /*!<  when asterisk couldn't match our ext */
-	MISDN_INCOMING_SETUP, /*!<  for incoming setups*/
-	MISDN_DIALING, /*!<  when pbx_start */
-	MISDN_PROGRESS, /*!<  we got a progress */
-	MISDN_PROCEEDING, /*!<  we got a progress */
-	MISDN_CALLING, /*!<  when misdn_call is called */
-	MISDN_CALLING_ACKNOWLEDGE, /*!<  when we get SETUP_ACK */
-	MISDN_ALERTING, /*!<  when Alerting */
-	MISDN_BUSY, /*!<  when BUSY */
-	MISDN_CONNECTED, /*!<  when connected */
-	MISDN_PRECONNECTED, /*!<  when connected */
-	MISDN_DISCONNECTED, /*!<  when connected */
-	MISDN_RELEASED, /*!<  when connected */
-	MISDN_BRIDGED, /*!<  when bridged */
+	MISDN_WAITING4DIGS, /*!< when waiting for infos */
+	MISDN_EXTCANTMATCH, /*!< when asterisk couldn't match our ext */
+	MISDN_INCOMING_SETUP, /*!< for incoming setups */
+	MISDN_DIALING, /*!< when pbx_start */
+	MISDN_PROGRESS, /*!< we got a progress */
+	MISDN_PROCEEDING, /*!< we got a progress */
+	MISDN_CALLING, /*!< when misdn_call is called */
+	MISDN_CALLING_ACKNOWLEDGE, /*!< when we get SETUP_ACK */
+	MISDN_ALERTING, /*!< when Alerting */
+	MISDN_BUSY, /*!< when BUSY */
+	MISDN_CONNECTED, /*!< when connected */
+	MISDN_PRECONNECTED, /*!< when connected */
+	MISDN_DISCONNECTED, /*!< when connected */
+	MISDN_RELEASED, /*!< when connected */
+	MISDN_BRIDGED, /*!< when bridged */
 	MISDN_CLEANING, /*!< when hangup from * but we were connected before */
-	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  came from misdn */
+	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP came from misdn */
 	MISDN_HUNGUP_FROM_AST, /*!< when DISCONNECT/RELEASE/REL_COMP came out of misdn_hangup */
 	MISDN_HOLDED, /*!< if this chan is holded */
 	MISDN_HOLD_DISCONNECT, /*!< if this chan is holded */
-  
 };
 
 #define ORG_AST 1
 #define ORG_MISDN 2
 
 struct hold_info {
+	/*!
+	 * \brief Logical port the channel call record is HOLDED on 
+	 * because the B channel is no longer associated. 
+	 */
 	int port;
+
+	/*!
+	 * \brief Original B channel number the HOLDED call was using. 
+	 * \note Used only for debug display messages.
+	 */
 	int channel;
 };
 
+/*!
+ * \brief Channel call record structure
+ */
 struct chan_list {
-  
+	/*! 
+	 * \brief The "allowed_bearers" string read in from /etc/asterisk/misdn.conf
+	 */
 	char allowed_bearers[BUFFERSIZE + 1];
 	
+	/*! 
+	 * \brief State of the channel
+	 */
 	enum misdn_chan_state state;
+
+	/*! 
+     * \brief TRUE if a hangup needs to be queued 
+	 * \note This is a debug flag only used to catch calls to hangup_chan() that are already hungup.
+	 */
 	int need_queue_hangup;
+
+	/*!
+	 * \brief TRUE if a channel can be hung up by calling asterisk directly when done.
+	 */
 	int need_hangup;
+
+	/*!
+	 * \brief TRUE if we could send an AST_CONTROL_BUSY if needed.
+	 */
 	int need_busy;
 	
+	/*!
+	 * \brief Who originally created this channel. ORG_AST or ORG_MISDN
+	 */
 	int originator;
+
+	/*! 
+	 * \brief TRUE of we are not to respond immediately to a SETUP message.  Check the dialplan first.
+	 * \note The "noautorespond_on_setup" boolean read in from /etc/asterisk/misdn.conf
+	 */
 	int noautorespond_on_setup;
 	
-	int norxtone;
+	int norxtone;	/* Boolean assigned values but the value is not used. */
+
+	/*!
+	 * \brief TRUE if we are not to generate tones (Playtones)
+	 */
 	int notxtone; 
 
+	/*!
+	 * \brief TRUE if echo canceller is enabled.  Value is toggled.
+	 */
 	int toggle_ec;
 	
+	/*!
+	 * \brief TRUE if you want to send Tone Indications to an incoming
+	 * ISDN channel on a TE Port.
+	 * \note The "incoming_early_audio" boolean read in from /etc/asterisk/misdn.conf
+	 */
 	int incoming_early_audio;
 
+	/*!
+	 * \brief TRUE if DTMF digits are to be passed inband only.
+	 * \note It is settable by the misdn_set_opt() application.
+	 */
 	int ignore_dtmf;
 
+	/*!
+	 * \brief Pipe file descriptor handles array. 
+	 * Read from pipe[0], write to pipe[1] 
+	 */
 	int pipe[2];
+
+	/*!
+	 * \brief Read buffer for inbound audio from pipe[0]
+	 */
 	char ast_rd_buf[4096];
+
+	/*!
+	 * \brief Inbound audio frame returned by misdn_read().
+	 */
 	struct ast_frame frame;
 
-	int faxdetect; /*!<  0:no 1:yes 2:yes+nojump */
+	/*!
+	 * \brief Fax detection option. (0:no 1:yes 2:yes+nojump)
+	 * \note The "faxdetect" option string read in from /etc/asterisk/misdn.conf
+	 * \note It is settable by the misdn_set_opt() application.
+	 */
+	int faxdetect;
+
+	/*!
+	 * \brief Number of seconds to detect a Fax machine when detection enabled.
+	 * \note 0 disables the timeout.
+	 * \note The "faxdetect_timeout" value read in from /etc/asterisk/misdn.conf
+	 */
 	int faxdetect_timeout;
+
+	/*!
+	 * \brief Starting time of fax detection with timeout when nonzero.
+	 */
 	struct timeval faxdetect_tv;
+
+	/*!
+	 * \brief TRUE if a fax has been detected.
+	 */
 	int faxhandled;
 
+	/*!
+	 * \brief TRUE if we will use the Asterisk DSP to detect DTMF/Fax
+	 * \note The "astdtmf" boolean read in from /etc/asterisk/misdn.conf
+	 */
 	int ast_dsp;
 
+	/*!
+	 * \brief Jitterbuffer length
+	 * \note The "jitterbuffer" value read in from /etc/asterisk/misdn.conf
+	 */
 	int jb_len;
+
+	/*!
+	 * \brief Jitterbuffer upper threshold
+	 * \note The "jitterbuffer_upper_threshold" value read in from /etc/asterisk/misdn.conf
+	 */
 	int jb_upper_threshold;
+
+	/*!
+	 * \brief Allocated jitterbuffer controller
+	 * \note misdn_jb_init() creates the jitterbuffer.
+	 * \note Must use misdn_jb_destroy() to clean up. 
+	 */
 	struct misdn_jb *jb;
 	
+	/*!
+	 * \brief Allocated DSP controller
+	 * \note ast_dsp_new() creates the DSP controller.
+	 * \note Must use ast_dsp_free() to clean up. 
+	 */
 	struct ast_dsp *dsp;
+
+	/*!
+	 * \brief Allocated audio frame sample translator
+	 * \note ast_translator_build_path() creates the translator path.
+	 * \note Must use ast_translator_free_path() to clean up. 
+	 */
 	struct ast_trans_pvt *trans;
   
+	/*!
+	 * \brief Associated Asterisk channel structure.
+	 */
 	struct ast_channel * ast;
 
-	int dummy;
+	//int dummy;	/* Not used */
   
+	/*!
+	 * \brief Associated B channel structure.
+	 */
 	struct misdn_bchannel *bc;
 
+	/*!
+	 * \brief HOLDED channel information
+	 */
 	struct hold_info hold_info;
 
+	/*! 
+	 * \brief From associated B channel: Layer 3 process ID 
+	 * \note Used to find the HOLDED channel call record when retrieving a call. 
+	 */
 	unsigned int l3id;
+
+	/*! 
+	 * \brief From associated B channel: B Channel mISDN driver layer ID from mISDN_get_layerid()
+	 * \note Used only for debug display messages.
+	 */
 	int addr;
 
+	/*!
+	 * \brief Incoming call dialplan context identifier.
+	 * \note The "context" string read in from /etc/asterisk/misdn.conf
+	 */
 	char context[BUFFERSIZE];
 
-	int zero_read_cnt;
+	//int zero_read_cnt;	/* Not used */
+
+	/*!
+	 * \brief Number of outgoing audio frames dropped since last debug gripe message.
+	 */
 	int dropped_frame_cnt;
 
+	/*!
+	 * \brief TRUE if we must do the ringback tones.
+	 * \note The "far_alerting" boolean read in from /etc/asterisk/misdn.conf
+	 */
 	int far_alerting;
 
+	/*!
+	 * \brief TRUE if NT should disconnect an overlap dialing call when a timeout occurs.
+	 * \note The "nttimeout" boolean read in from /etc/asterisk/misdn.conf
+	 */
 	int nttimeout;
 
+	/*!
+	 * \brief Other channel call record PID 
+	 * \note Value imported from Asterisk environment variable MISDN_PID 
+	 */
 	int other_pid;
+
+	/*!
+	 * \brief Bridged other channel call record
+	 * \note Pointer set when other_pid imported from Asterisk environment 
+     * variable MISDN_PID by either side.
+	 */
 	struct chan_list *other_ch;
 
+	/*!
+	 * \brief Tone zone sound used for dialtone generation.
+	 * \note Used as a boolean.  Non-NULL to prod generation if enabled. 
+	 */
 	const struct ind_tone_zone_sound *ts;
 	
+	/*!
+	 * \brief Enables overlap dialing for the set amount of seconds.  (0 = Disabled)
+	 * \note The "overlapdial" value read in from /etc/asterisk/misdn.conf
+	 */
 	int overlap_dial;
+
+	/*!
+	 * \brief Overlap dialing timeout Task ID.  -1 if not running.
+	 */
 	int overlap_dial_task;
+
+	/*!
+	 * \brief overlap_tv access lock.
+	 */
 	ast_mutex_t overlap_tv_lock;
+
+	/*!
+	 * \brief Overlap timer start time.  Timer restarted for every digit received.
+	 */
 	struct timeval overlap_tv;
   
-	struct chan_list *peer;
+//	struct chan_list *peer;	/* Not used */
+
+	/*!
+	 * \brief Next channel call record in the list.
+	 */
 	struct chan_list *next;
-	struct chan_list *prev;
-	struct chan_list *first;
+	//struct chan_list *prev;		/* Not used */
+	//struct chan_list *first;	/* Not used */
 };
-
 
 
 void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch);
@@ -317,6 +498,9 @@
 
 struct chan_list dummy_cl;
 
+/*!
+ * \brief Global channel call record list head.
+ */
 struct chan_list *cl_te=NULL;
 ast_mutex_t cl_te_lock;
 
@@ -385,6 +569,221 @@
   
 	return NULL;
 }
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the mISDN presentation code to a string
+ *
+ * \param presentation mISDN number presentation restriction code.
+ *
+ * \return The mISDN presentation code as a string
+ */
+static const char *misdn_pres_to_str(int presentation)
+{
+	const char *str;
+
+	switch (presentation) {
+	case 0:
+		str = "Allowed";
+		break;
+
+	case 1:
+		str = "Restricted";
+		break;
+
+	case 2:
+		str = "Unavailable";
+		break;
+	
+	default:
+		str = "Unknown";
+		break;
+	}	/* end switch */
+
+	return str;
+}	/* end misdn_pres_to_str() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the mISDN presentation code to Asterisk presentation code
+ *
+ * \param presentation mISDN number presentation restriction code.
+ *
+ * \return Asterisk presentation code
+ */
+static int misdn_pres_to_ast_pres(int presentation)
+{
+	switch (presentation) {
+	default:
+	case 0:
+		presentation = AST_PRES_ALLOWED;
+		break;
+
+	case 1:
+		presentation = AST_PRES_RESTRICTED;
+		break;
+
+	case 2:
+		presentation = AST_PRES_UNAVAILABLE;
+		break;
+	}	/* end switch */
+
+	return presentation;
+}	/* end misdn_pres_to_ast_pres() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the Asterisk presentation code to mISDN presentation code
+ *
+ * \param presentation Asterisk number presentation restriction code.
+ *
+ * \return mISDN presentation code
+ */
+static int ast_pres_to_misdn_pres(int presentation)
+{
+	switch (presentation & AST_PRES_RESTRICTION) {
+	default:
+	case AST_PRES_ALLOWED:
+		presentation = 0;
+		break;
+
+	case AST_PRES_RESTRICTED:
+		presentation = 1;
+		break;
+
+	case AST_PRES_UNAVAILABLE:
+		presentation = 2;
+		break;
+	}	/* end switch */
+
+	return presentation;
+}	/* end ast_pres_to_misdn_pres() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the mISDN screening code to a string
+ *
+ * \param screening mISDN number screening code.
+ *
+ * \return The mISDN screening code as a string
+ */
+static const char *misdn_screen_to_str(int screening)
+{
+	const char *str;
+
+	switch (screening) {
+	case 0:
+		str = "Unscreened";
+		break;
+
+	case 1:
+		str = "Passed Screen";
+		break;
+
+	case 2:
+		str = "Failed Screen";
+		break;
+	
+	case 3:
+		str = "Network Number";
+		break;
+
+	default:
+		str = "Unknown";
+		break;
+	}	/* end switch */
+
+	return str;
+}	/* end misdn_screen_to_str() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the mISDN screening code to Asterisk screening code
+ *
+ * \param screening mISDN number screening code.
+ *
+ * \return Asterisk screening code
+ */
+static int misdn_screen_to_ast_screen(int screening)
+{
+	switch (screening) {
+	default:
+	case 0:
+		screening = AST_PRES_USER_NUMBER_UNSCREENED;
+		break;
+
+	case 1:
+		screening = AST_PRES_USER_NUMBER_PASSED_SCREEN;
+		break;
+
+	case 2:
+		screening = AST_PRES_USER_NUMBER_FAILED_SCREEN;
+		break;
+
+	case 3:
+		screening = AST_PRES_NETWORK_NUMBER;
+		break;
+	}	/* end switch */
+
+	return screening;
+}	/* end misdn_screen_to_ast_screen() */
+
+
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Convert the Asterisk screening code to mISDN screening code
+ *
+ * \param screening Asterisk number screening code.
+ *
+ * \return mISDN screening code
+ */
+static int ast_screen_to_misdn_screen(int screening)
+{
+	switch (screening & AST_PRES_NUMBER_TYPE) {
+	default:
+	case AST_PRES_USER_NUMBER_UNSCREENED:
+		screening = 0;
+		break;
+
+	case AST_PRES_USER_NUMBER_PASSED_SCREEN:
+		screening = 1;
+		break;
+
+	case AST_PRES_USER_NUMBER_FAILED_SCREEN:
+		screening = 2;
+		break;
+
+	case AST_PRES_NETWORK_NUMBER:
+		screening = 3;
+		break;
+	}	/* end switch */
+
+	return screening;
+}	/* end ast_screen_to_misdn_screen() */
+
 
 
 
@@ -666,16 +1065,16 @@
 	diff = ast_tvdiff_ms(tv_end, tv_now);
 
 	if (diff <= 100) {
-		char *dad=ch->bc->dad, sexten[]="s";
+		char *dad=ch->bc->dialed.number, sexten[]="s";
 		/* if we are 100ms near the timeout, we are satisfied.. */
 		stop_indicate(ch);
 		
-		if (ast_strlen_zero(ch->bc->dad)) {
+		if (ast_strlen_zero(ch->bc->dialed.number)) {
 			dad=sexten;
 			strcpy(ch->ast->exten, sexten);
 		}
 
-		if (ast_exists_extension(ch->ast, ch->context, dad, 1, ch->bc->oad)) {
+		if (ast_exists_extension(ch->ast, ch->context, dad, 1, ch->bc->caller.number)) {
 			ch->state=MISDN_DIALING;
 			if (pbx_start_chan(ch) < 0) {
 				chan_misdn_log(-1, ch->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
@@ -1158,19 +1557,18 @@
 static void print_bc_info (int fd, struct chan_list *help, struct misdn_bchannel *bc)
 {
 	struct ast_channel *ast = help->ast;
+
 	ast_cli(fd,
 		"* 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->originator == ORG_AST ? "*" : "I",
-		ast ? ast->exten : NULL,
-		ast ? ast->cid.cid_num : NULL,
-		bc->rad,
-		ast ? ast->context : NULL,
-		misdn_get_ch_state(help)
-		);
-	if (misdn_debug[bc->port] > 0)
+		ast ? ast->exten : "",
+		(ast && ast->cid.cid_num) ? ast->cid.cid_num : "",
+		bc->redirecting.number,
+		ast ? ast->context : "",
+		misdn_get_ch_state(help));
+	if (misdn_debug[bc->port] > 0) {
 		ast_cli(fd,
 			"  --> astname: %s\n"
 			"  --> ch_l3id: %x\n"
@@ -1192,7 +1590,7 @@
 			help->l3id,
 			help->addr,
 			bc->addr,
-			bc ? bc->l3_id : -1,
+			bc->l3_id,
 			bc->display,
 			
 			bc->active,
@@ -1201,13 +1599,12 @@
 #ifdef MISDN_1_2
 			bc->pipeline,
 #else
- 			bc->ec_enable,
+			bc->ec_enable,
 #endif
 
 			help->norxtone, help->notxtone,
-			bc->holded
-			);
-
+			bc->holded);
+	}
 }
 
 static char *handle_cli_misdn_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -1755,6 +2152,7 @@
 	AST_CLI_DEFINE(handle_cli_misdn_toggle_echocancel, "Toggle EchoCancel on mISDN Channel"),
 };
 
+/*! \brief Updates caller ID information from config */
 static int update_config(struct chan_list *ch, int orig) 
 {
 	struct ast_channel *ast;
@@ -1798,43 +2196,14 @@
 	if (pres < 0 || screen < 0) {
 		chan_misdn_log(2, port, " --> pres: %x\n", ast->cid.cid_pres);
 			
-		switch (ast->cid.cid_pres & 0x60) {
-		case AST_PRES_RESTRICTED:
-			bc->pres = 1;
-			chan_misdn_log(2, port, " --> PRES: Restricted (1)\n");
-			break;
-		case AST_PRES_UNAVAILABLE:
-			bc->pres = 2;
-			chan_misdn_log(2, port, " --> PRES: Unavailable (2)\n");
-			break;
-		default:
-			bc->pres = 0;
-			chan_misdn_log(2, port, " --> PRES: Allowed (0)\n");
-			break;
-		}
-
-		switch (ast->cid.cid_pres & 0x3) {
-		default:
-		case AST_PRES_USER_NUMBER_UNSCREENED:
-			bc->screen = 0;
-			chan_misdn_log(2, port, " --> SCREEN: Unscreened (0)\n");
-			break;
-		case AST_PRES_USER_NUMBER_PASSED_SCREEN:
-			bc->screen = 1;
-			chan_misdn_log(2, port, " --> SCREEN: Passed Screen (1)\n");
-			break;
-		case AST_PRES_USER_NUMBER_FAILED_SCREEN:
-			bc->screen = 2;
-			chan_misdn_log(2, port, " --> SCREEN: Failed Screen (2)\n");
-			break;
-		case AST_PRES_NETWORK_NUMBER:
-			bc->screen = 3;
-			chan_misdn_log(2, port, " --> SCREEN: Network Nr. (3)\n");
-			break;
-		}
+		bc->caller.presentation = ast_pres_to_misdn_pres(ast->cid.cid_pres);
+		chan_misdn_log(2, port, " --> PRES: %s(%d)\n", misdn_pres_to_str(bc->caller.presentation), bc->caller.presentation);
+			
+		bc->caller.screening = ast_screen_to_misdn_screen(ast->cid.cid_pres);
+		chan_misdn_log(2, port, " --> SCREEN: %s(%d)\n", misdn_screen_to_str(bc->caller.screening), bc->caller.screening);
 	} else {
-		bc->screen = screen;
-		bc->pres = pres;
+		bc->caller.screening = screen;
+		bc->caller.presentation = pres;
 	}
 
 	return 0;
@@ -2042,15 +2411,15 @@
 		misdn_cfg_get(port, MISDN_CFG_CALLERID, callerid, sizeof(callerid));
 		if ( ! ast_strlen_zero(callerid) ) {
 			chan_misdn_log(1, port, " --> * Setting Cid to %s\n", callerid);
-			ast_copy_string(bc->oad, callerid, sizeof(bc->oad));
-		}
-
-		misdn_cfg_get(port, MISDN_CFG_DIALPLAN, &bc->dnumplan, sizeof(bc->dnumplan));
-		misdn_cfg_get(port, MISDN_CFG_LOCALDIALPLAN, &bc->onumplan, sizeof(bc->onumplan));
-		misdn_cfg_get(port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(bc->cpnnumplan));
-		debug_numplan(port, bc->dnumplan, "TON");
-		debug_numplan(port, bc->onumplan, "LTON");
-		debug_numplan(port, bc->cpnnumplan, "CTON");
+			ast_copy_string(bc->caller.number, callerid, sizeof(bc->caller.number));
+		}
+
+		misdn_cfg_get(port, MISDN_CFG_DIALPLAN, &bc->dialed.number_type, sizeof(bc->dialed.number_type));
+		misdn_cfg_get(port, MISDN_CFG_LOCALDIALPLAN, &bc->caller.number_type, sizeof(bc->caller.number_type));
+		misdn_cfg_get(port, MISDN_CFG_CPNDIALPLAN, &bc->connected.number_type, sizeof(bc->connected.number_type));
+		debug_numplan(port, bc->dialed.number_type, "TON");
+		debug_numplan(port, bc->caller.number_type, "LTON");
+		debug_numplan(port, bc->connected.number_type, "CTON");
 
 		ch->overlap_dial = 0;
 	} else { /** ORIGINATOR MISDN **/
@@ -2063,10 +2432,10 @@
  				ch->faxdetect = 1;
  		}
 
-		misdn_cfg_get(port, MISDN_CFG_CPNDIALPLAN, &bc->cpnnumplan, sizeof(bc->cpnnumplan));
-		debug_numplan(port, bc->cpnnumplan, "CTON");
-
-		switch (bc->onumplan) {
+		misdn_cfg_get(port, MISDN_CFG_CPNDIALPLAN, &bc->connected.number_type, sizeof(bc->connected.number_type));
+		debug_numplan(port, bc->connected.number_type, "CTON");
+
+		switch (bc->caller.number_type) {
 		case NUMPLAN_INTERNATIONAL:
 			misdn_cfg_get(bc->port, MISDN_CFG_INTERNATPREFIX, prefix, sizeof(prefix));
 			break;
@@ -2078,20 +2447,16 @@
 			break;
 		}
 
-		ast_copy_string(buf, bc->oad, sizeof(buf));
-		snprintf(bc->oad, sizeof(bc->oad), "%s%s", prefix, buf);
-
-		if (!ast_strlen_zero(bc->dad)) {
-			ast_copy_string(bc->orig_dad, bc->dad, sizeof(bc->orig_dad));
-		}
-
-		if ( ast_strlen_zero(bc->dad) && !ast_strlen_zero(bc->keypad)) {
-			ast_copy_string(bc->dad, bc->keypad, sizeof(bc->dad));
+		ast_copy_string(buf, bc->caller.number, sizeof(buf));
+		snprintf(bc->caller.number, sizeof(bc->caller.number), "%s%s", prefix, buf);
+
+		if ( ast_strlen_zero(bc->dialed.number) && !ast_strlen_zero(bc->keypad)) {
+			ast_copy_string(bc->dialed.number, bc->keypad, sizeof(bc->dialed.number));
 		}
 
 		prefix[0] = 0;
 
-		switch (bc->dnumplan) {
+		switch (bc->dialed.number_type) {
 		case NUMPLAN_INTERNATIONAL:
 			misdn_cfg_get(bc->port, MISDN_CFG_INTERNATPREFIX, prefix, sizeof(prefix));
 			break;
@@ -2102,19 +2467,19 @@
 			break;
 		}
 
-		ast_copy_string(buf, bc->dad, sizeof(buf));
-		snprintf(bc->dad, sizeof(bc->dad), "%s%s", prefix, buf);
-
-		if (strcmp(bc->dad, ast->exten)) {
-			ast_copy_string(ast->exten, bc->dad, sizeof(ast->exten));
-		}
-
-		ast_set_callerid(ast, bc->oad, NULL, bc->oad);
-
-		if ( !ast_strlen_zero(bc->rad) ) {
+		ast_copy_string(buf, bc->dialed.number, sizeof(buf));
+		snprintf(bc->dialed.number, sizeof(bc->dialed.number), "%s%s", prefix, buf);
+
+		if (strcmp(bc->dialed.number, ast->exten)) {
+			ast_copy_string(ast->exten, bc->dialed.number, sizeof(ast->exten));
+		}
+
+		ast_set_callerid(ast, bc->caller.number, NULL, bc->caller.number);
+
+		if ( !ast_strlen_zero(bc->redirecting.number) ) {
 			if (ast->cid.cid_rdnis)
 				ast_free(ast->cid.cid_rdnis);
-			ast->cid.cid_rdnis = ast_strdup(bc->rad);
+			ast->cid.cid_rdnis = ast_strdup(bc->redirecting.number);
 		}
 	
 		misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));
@@ -2144,6 +2509,37 @@
 }
 
 
+
+
+/* ******************************************************************* */
+/*!
+ * \internal
+ * \brief Notify peer that the connected line has changed.
+ *
+ * \param ast Current Asterisk channel
+ * \param bc Associated B channel
+ * \param data Asterisk indication data buffer frame containing the new connected line data
+ * \param datalen Length of the data buffer frame
+ *
+ * \return Nothing
+ */
+static void misdn_update_connectedline(struct ast_channel *ast, struct misdn_bchannel *bc, const void *data, size_t datalen)
+{
+	char lid_number[sizeof(bc->connected.number)];
+	char lid_name[80];
+	int lid_pres;
+
+	if (ast_parse_connectedline_data((unsigned char *) data, datalen, lid_number, sizeof(lid_number), lid_name, sizeof(lid_name), &lid_pres)) {
+		return;
+	}
+
+	ast_set_connectedline(ast, lid_number, lid_name, lid_pres);
+	strcpy(bc->connected.number, lid_number);
+	bc->connected.presentation = ast_pres_to_misdn_pres(lid_pres);
+	bc->connected.screening = ast_screen_to_misdn_screen(lid_pres);
+}	/* end misdn_update_connectedline() */
+
+
 /*****************************/
 /*** AST Indications Start ***/
 /*****************************/
@@ -2215,14 +2611,12 @@
 	chan_misdn_log(3, port, " --> * adding2newbc ext %s\n", ast->exten);
 	if (ast->exten) {
 		ast_copy_string(ast->exten, ext, sizeof(ast->exten));
-		ast_copy_string(newbc->dad, ext, sizeof(newbc->dad));
-	}
-
-	ast_copy_string(newbc->rad, S_OR(ast->cid.cid_rdnis, ""), sizeof(newbc->rad));
+		ast_copy_string(newbc->dialed.number, ext, sizeof(newbc->dialed.number));
+	}
 
 	chan_misdn_log(3, port, " --> * adding2newbc callerid %s\n", ast->cid.cid_num);
-	if (ast_strlen_zero(newbc->oad) && !ast_strlen_zero(ast->cid.cid_num)) {
-		ast_copy_string(newbc->oad, ast->cid.cid_num, sizeof(newbc->oad));
+	if (ast_strlen_zero(newbc->caller.number) && !ast_strlen_zero(ast->cid.cid_num)) {
+		ast_copy_string(newbc->caller.number, ast->cid.cid_num, sizeof(newbc->caller.number));
 	}
 
 	newbc->capability = ast->transfercapability;
@@ -2234,14 +2628,27 @@
 	/* update screening and presentation */ 
 	update_config(ch, ORG_AST);
 		
-	/* fill in some ies from channel vary*/
+	/* fill in some ies from channel dialplan variables */
 	import_ch(ast, newbc, ch);
 
 	/* Finally The Options Override Everything */
-	if (opts)
+	if (opts) {
 		misdn_set_opt_exec(ast, opts);
-	else
+	} else {
 		chan_misdn_log(2, port, "NO OPTS GIVEN\n");
+	}
+	if (newbc->set_presentation) {
+		newbc->caller.presentation = newbc->presentation;
+	}
+
+	/* 
+	 * XXX We should be getting all of the redirect parameters from the asterisk channel 
+	 * but its not supported now. 
+	 * Also need a redirecting reason parameter. 
+	 */
+	ast_copy_string(newbc->redirecting.number, S_OR(ast->cid.cid_rdnis, ""), sizeof(newbc->redirecting.number));
+	newbc->redirecting.presentation = newbc->caller.presentation;
+	newbc->redirecting.screening = newbc->caller.screening;
 
 	/*check for bridging*/
 	misdn_cfg_get(0, MISDN_GEN_BRIDGING, &bridging, sizeof(bridging));
@@ -2299,7 +2706,7 @@
 	}
 
 	if (!p->bc) {
-		chan_misdn_log(1, 0, " --> Got Answer, but theres no bc obj ??\n");
+		chan_misdn_log(1, 0, " --> Got Answer, but there is no bc obj ??\n");
 
 		ast_queue_hangup_with_cause(ast, AST_CAUSE_PROTOCOL_ERROR);
 	}
@@ -2324,9 +2731,12 @@
 	p->state = MISDN_CONNECTED;
 	stop_indicate(p);
 
-	if ( ast_strlen_zero(p->bc->cad) ) {
-		chan_misdn_log(2,p->bc->port," --> empty cad using dad\n");
-		ast_copy_string(p->bc->cad, p->bc->dad, sizeof(p->bc->cad));
+	if (ast_strlen_zero(p->bc->connected.number)) {
+		chan_misdn_log(2,p->bc->port," --> empty connected number using dialed number\n");
+		ast_copy_string(p->bc->connected.number, p->bc->dialed.number, sizeof(p->bc->connected.number));
+		p->bc->connected.number_type = p->bc->dialed.number_type;
+		p->bc->connected.presentation = p->bc->presentation;
+		p->bc->connected.screening = 0;	/* unscreened */
 	}
 
 	misdn_lib_send_event( p->bc, EVENT_CONNECT);
@@ -2364,9 +2774,9 @@
 		break;
 	case MISDN_CALLING_ACKNOWLEDGE:
 		ast_copy_string(bc->info_dad, buf, sizeof(bc->info_dad));
-		if (strlen(bc->dad) < sizeof(bc->dad) - 1)
-			strncat(bc->dad, buf, sizeof(bc->dad) - strlen(bc->dad) - 1);
-		ast_copy_string(p->ast->exten, bc->dad, sizeof(p->ast->exten));
+		if (strlen(bc->dialed.number) < sizeof(bc->dialed.number) - 1)
+			strncat(bc->dialed.number, buf, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
+		ast_copy_string(p->ast->exten, bc->dialed.number, sizeof(p->ast->exten));
 		misdn_lib_send_event( bc, EVENT_INFORMATION);
 		break;
 	default:	
@@ -2418,7 +2828,7 @@
 	
 	switch (cond) {
 	case AST_CONTROL_BUSY:
-		chan_misdn_log(1, p->bc->port, "* IND :\tbusy pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, "* IND :\tbusy pid:%d\n", p->bc->pid);
 		ast_setstate(ast, AST_STATE_BUSY);
 
 		p->bc->out_cause = AST_CAUSE_USER_BUSY;
@@ -2430,20 +2840,20 @@
 		}
 		return -1;
 	case AST_CONTROL_RING:
-		chan_misdn_log(1, p->bc->port, "* IND :\tring pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, "* IND :\tring pid:%d\n", p->bc->pid);
 		return -1;
 	case AST_CONTROL_RINGING:
-		chan_misdn_log(1, p->bc->port, "* IND :\tringing pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, "* IND :\tringing pid:%d\n", p->bc->pid);
 		switch (p->state) {
 		case MISDN_ALERTING:
-			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d but I was Ringing before, so ignoring it\n", p->bc ? p->bc->pid : -1);
+			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d but I was Ringing before, so ignoring it\n", p->bc->pid);
 			break;
 		case MISDN_CONNECTED:
-			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d but Connected, so just send TONE_ALERTING without state changes \n", p->bc ? p->bc->pid : -1);
+			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d but Connected, so just send TONE_ALERTING without state changes \n", p->bc->pid);
 			return -1;
 		default:
 			p->state = MISDN_ALERTING;
-			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d\n", p->bc ? p->bc->pid : -1);
+			chan_misdn_log(2, p->bc->port, " --> * IND :\tringing pid:%d\n", p->bc->pid);
 			misdn_lib_send_event( p->bc, EVENT_ALERTING);
 			
 			if (p->other_ch && p->other_ch->bc) {
@@ -2458,7 +2868,7 @@
 				}
 			}
 
-			chan_misdn_log(3, p->bc->port, " --> * SEND: State Ring pid:%d\n", p->bc ? p->bc->pid : -1);
+			chan_misdn_log(3, p->bc->port, " --> * SEND: State Ring pid:%d\n", p->bc->pid);
 			ast_setstate(ast, AST_STATE_RINGING);
 			
 			if ( !p->bc->nt && (p->originator == ORG_MISDN) && !p->incoming_early_audio ) 
@@ -2468,28 +2878,28 @@
 		}
 		break;
 	case AST_CONTROL_ANSWER:
-		chan_misdn_log(1, p->bc->port, " --> * IND :\tanswer pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * IND :\tanswer pid:%d\n", p->bc->pid);
 		start_bc_tones(p);
 		break;
 	case AST_CONTROL_TAKEOFFHOOK:
-		chan_misdn_log(1, p->bc->port, " --> *\ttakeoffhook pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> *\ttakeoffhook pid:%d\n", p->bc->pid);
 		return -1;
 	case AST_CONTROL_OFFHOOK:
-		chan_misdn_log(1, p->bc->port, " --> *\toffhook pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> *\toffhook pid:%d\n", p->bc->pid);
 		return -1;
 	case AST_CONTROL_FLASH:
-		chan_misdn_log(1, p->bc->port, " --> *\tflash pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> *\tflash pid:%d\n", p->bc->pid);
 		break;
 	case AST_CONTROL_PROGRESS:
-		chan_misdn_log(1, p->bc->port, " --> * IND :\tprogress pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * IND :\tprogress pid:%d\n", p->bc->pid);
 		misdn_lib_send_event( p->bc, EVENT_PROGRESS);
 		break;
 	case AST_CONTROL_PROCEEDING:
-		chan_misdn_log(1, p->bc->port, " --> * IND :\tproceeding pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * IND :\tproceeding pid:%d\n", p->bc->pid);
 		misdn_lib_send_event( p->bc, EVENT_PROCEEDING);
 		break;
 	case AST_CONTROL_CONGESTION:
-		chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * IND :\tcongestion pid:%d\n", p->bc->pid);
 
 		p->bc->out_cause = AST_CAUSE_SWITCH_CONGESTION;
 		start_bc_tones(p);
@@ -2500,7 +2910,7 @@
 		}
 		break;
 	case -1 :
-		chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! (stop indication) pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! (stop indication) pid:%d\n", p->bc->pid);
 
 		stop_indicate(p);
 
@@ -2509,14 +2919,19 @@
 		break;
 	case AST_CONTROL_HOLD:
 		ast_moh_start(ast,data,ast->musicclass); 
-		chan_misdn_log(1, p->bc->port, " --> *\tHOLD pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> *\tHOLD pid:%d\n", p->bc->pid);
 		break;
 	case AST_CONTROL_UNHOLD:
 		ast_moh_stop(ast);
-		chan_misdn_log(1, p->bc->port, " --> *\tUNHOLD pid:%d\n", p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> *\tUNHOLD pid:%d\n", p->bc->pid);
+		break;
+	case AST_CONTROL_CONNECTEDLINE:
+		chan_misdn_log(1, p->bc->port, "* IND :\tconnected line update pid:%d\n", p->bc->pid);
+		misdn_update_connectedline(ast, p->bc, data, datalen);
 		break;
 	default:
-		chan_misdn_log(1, p->bc->port, " --> * Unknown Indication:%d pid:%d\n", cond, p->bc ? p->bc->pid : -1);
+		chan_misdn_log(1, p->bc->port, " --> * Unknown Indication:%d pid:%d\n", cond, p->bc->pid);
+		break;
 	}
   
 	return 0;
@@ -3003,7 +3418,7 @@
 
 	ast_verb(3, "Native bridging %s and %s\n", c0->name, c1->name);
 
-	chan_misdn_log(1, ch1->bc->port, "* Making Native Bridge between %s and %s\n", ch1->bc->oad, ch2->bc->oad);
+	chan_misdn_log(1, ch1->bc->port, "* Making Native Bridge between %s and %s\n", ch1->bc->caller.number, ch2->bc->caller.number);
  
 	if (! (flags & AST_BRIDGE_DTMF_CHANNEL_0) )
 		ch1->ignore_dtmf = 1;
@@ -3496,7 +3911,7 @@
 		if (help->bc == bc) return help;
 	}
 
-	chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->oad, bc->dad);
+	chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->caller.number, bc->dialed.number);
 
 	return NULL;
 }
@@ -3519,14 +3934,14 @@
 
 	if (bc->pri) return NULL;
 
-	chan_misdn_log(6, bc->port, "$$$ find_holded: channel:%d oad:%s dad:%s\n", bc->channel, bc->oad, bc->dad);
+	chan_misdn_log(6, bc->port, "$$$ find_holded: channel:%d oad:%s dad:%s\n", bc->channel, bc->caller.number, bc->dialed.number);
 	for (;help; help = help->next) {
 		chan_misdn_log(4, bc->port, "$$$ find_holded: --> holded:%d channel:%d\n", help->state==MISDN_HOLDED, help->hold_info.channel);
 		if ( 	(help->state == MISDN_HOLDED) && 
 			(help->hold_info.port == bc->port) ) 
 			return help;
 	}
-	chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->oad, bc->dad);
+	chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->caller.number, bc->dialed.number);
 
 	return NULL;
 }
@@ -3846,6 +4261,7 @@
 }
 
 
+/*! \brief Import parameters from the dialplan environment variables */
 void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 {
 	const char *tmp = pbx_builtin_getvar_helper(chan, "MISDN_PID");
@@ -3876,6 +4292,7 @@
 		ast_copy_string(bc->keypad, tmp, sizeof(bc->keypad));
 }
 
+/*! \brief Export parameters to the dialplan environment variables */
 void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 {
 	char tmp[32];
@@ -3946,7 +4363,7 @@
 static void wait_for_digits(struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan) {
 	ch->state=MISDN_WAITING4DIGS;
 	misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
-	if (bc->nt && !bc->dad[0])
+	if (bc->nt && !bc->dialed.number[0])
 		dialtone_indicate(ch);
 }
 
@@ -3964,7 +4381,7 @@
 		if ( event == EVENT_CLEANUP && !user_data)
 			debuglevel = 5;
 
-		chan_misdn_log(debuglevel, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch ? misdn_get_ch_state(ch) : "none");
+		chan_misdn_log(debuglevel, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->caller.number, bc->dialed.number, bc->pid, ch ? misdn_get_ch_state(ch) : "none");
 		if (debuglevel == 1) {
 			misdn_lib_log_ies(bc);
 			chan_misdn_log(4, bc->port, " --> bc_state:%s\n", bc_state2str(bc->bc_state));
@@ -4092,8 +4509,8 @@
 				ast_copy_string(bc->info_dad, bc->keypad, sizeof(bc->info_dad));
 			}
 
-			strncat(bc->dad,bc->info_dad, sizeof(bc->dad) - strlen(bc->dad) - 1);
-			ast_copy_string(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
+			strncat(bc->dialed.number,bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
+			ast_copy_string(ch->ast->exten, bc->dialed.number, sizeof(ch->ast->exten));
 
 			/* Check for Pickup Request first */
 			if (!strcmp(ch->ast->exten, ast_pickup_ext())) {
@@ -4109,8 +4526,8 @@
 				}
 			}
 			
-			if (!ast_canmatch_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
-				if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->oad)) {
+			if (!ast_canmatch_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
+				if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->caller.number)) {
 					ast_log(LOG_WARNING, "Extension can never match, So jumping to 'i' extension. port(%d)\n", bc->port);
 					strcpy(ch->ast->exten, "i");
 
@@ -4143,7 +4560,7 @@
 				break;
 			}
 
-			if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad))  {
+			if (ast_exists_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number))  {
 				
 				ch->state = MISDN_DIALING;
 				start_pbx(ch, bc, ch->ast);
@@ -4166,8 +4583,8 @@
 			misdn_cfg_get(0, MISDN_GEN_APPEND_DIGITS2EXTEN, &digits, sizeof(digits));
 			if (ch->state != MISDN_CONNECTED ) {
 				if (digits) {
-					strncat(bc->dad, bc->info_dad, sizeof(bc->dad) - strlen(bc->dad) - 1);
-					ast_copy_string(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
+					strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
+					ast_copy_string(ch->ast->exten, bc->dialed.number, sizeof(ch->ast->exten));
 					ast_cdr_update(ch->ast);
 				}
 				
@@ -4179,7 +4596,7 @@
 	case EVENT_SETUP:
 	{
 		struct chan_list *ch = find_chan_by_bc(cl_te, bc);
-		int msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dad);
+		int msn_valid = misdn_cfg_is_msn_valid(bc->port, bc->dialed.number);
 		struct ast_channel *chan;
 		int exceed;
 		int pres,screen;
@@ -4239,7 +4656,7 @@
 		ch->addr = bc->addr;
 		ch->originator = ORG_MISDN;
 
-		chan = misdn_new(ch, AST_STATE_RESERVED, bc->dad, bc->oad, AST_FORMAT_ALAW, bc->port, bc->channel);
+		chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, AST_FORMAT_ALAW, bc->port, bc->channel);
 
 		if (!chan) {
 			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
@@ -4262,40 +4679,11 @@
 		ch->ast->rings = 1;
 		ast_setstate(ch->ast, AST_STATE_RINGING);
 
-		switch (bc->pres) {
-		case 1:
-			pres = AST_PRES_RESTRICTED;
-			chan_misdn_log(2, bc->port, " --> PRES: Restricted (1)\n");
-			break;
-		case 2:
-			pres = AST_PRES_UNAVAILABLE;
-			chan_misdn_log(2, bc->port, " --> PRES: Unavailable (2)\n");
-			break;
-		default:
-			pres = AST_PRES_ALLOWED;
-			chan_misdn_log(2, bc->port, " --> PRES: Allowed (%d)\n", bc->pres);
-			break;
-		}
-
-		switch (bc->screen) {
-		default:
-		case 0:
-			screen = AST_PRES_USER_NUMBER_UNSCREENED;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
-			break;
-		case 1:
-			screen = AST_PRES_USER_NUMBER_PASSED_SCREEN;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Passed screen (1)\n");
-			break;
-		case 2:
-			screen = AST_PRES_USER_NUMBER_FAILED_SCREEN;
-			chan_misdn_log(2, bc->port, " --> SCREEN: failed screen (2)\n");
-			break;
-		case 3:
-			screen = AST_PRES_NETWORK_NUMBER;
-			chan_misdn_log(2, bc->port, " --> SCREEN: Network Number (3)\n");
-			break;
-		}
+		chan_misdn_log(2, bc->port, " --> PRES: %s(%d)\n", misdn_pres_to_str(bc->caller.presentation), bc->caller.presentation);
+		pres = misdn_pres_to_ast_pres(bc->caller.presentation);
+
+		chan_misdn_log(2, bc->port, " --> SCREEN: %s(%d)\n", misdn_screen_to_str(bc->caller.screening), bc->caller.screening);
+		screen = misdn_screen_to_ast_screen(bc->caller.screening);
 
 		chan->cid.cid_pres = pres | screen;
 
@@ -4371,14 +4759,14 @@
 
 		/* check if we should jump into s when we have no dad */
 		misdn_cfg_get(bc->port, MISDN_CFG_IMMEDIATE, &im, sizeof(im));
-		if (im && ast_strlen_zero(bc->dad)) {
+		if (im && ast_strlen_zero(bc->dialed.number)) {
 			do_immediate_setup(bc, ch, chan);
 			break;
 		}
 
 		chan_misdn_log(5, bc->port, "CONTEXT:%s\n", ch->context);
-		if(!ast_canmatch_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
-			if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->oad)) {

[... 901 lines stripped ...]



More information about the asterisk-commits mailing list