| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Chan_Misdn -- Channel Driver for Asterisk | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Interface to mISDN | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2004, Christian Richter | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Christian Richter <crich@beronet.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software, distributed under the terms of | 
					
						
							|  |  |  |  * the GNU General Public License | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2008-02-15 17:29:08 +00:00
										 |  |  |  * \brief Interface to mISDN - message parser | 
					
						
							| 
									
										
										
										
											2007-12-11 22:20:22 +00:00
										 |  |  |  * \author Christian Richter <crich@beronet.com> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-15 16:20:16 +00:00
										 |  |  | /*** MODULEINFO
 | 
					
						
							|  |  |  | 	<support_level>extended</support_level> | 
					
						
							|  |  |  |  ***/ | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | #include "isdn_lib_intern.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #include "isdn_lib.h"
 | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #include "ie.c"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Build the name, number, name/number display message string | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param display Display buffer to fill in | 
					
						
							|  |  |  |  * \param display_length Length of the display buffer to fill in | 
					
						
							|  |  |  |  * \param display_format Display format enumeration | 
					
						
							|  |  |  |  * \param name Name string to use | 
					
						
							|  |  |  |  * \param number Number string to use | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Nothing | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void build_display_str(char *display, size_t display_length, int display_format, const char *name, const char *number) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	display[0] = 0; | 
					
						
							|  |  |  | 	switch (display_format) { | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	case 0:		/* none */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 1:		/* name */ | 
					
						
							|  |  |  | 		snprintf(display, display_length, "%s", name); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 2:		/* number */ | 
					
						
							|  |  |  | 		snprintf(display, display_length, "%s", number); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case 3:		/* both */ | 
					
						
							|  |  |  | 		if (name[0] || number[0]) { | 
					
						
							|  |  |  | 			snprintf(display, display_length, "\"%s\" <%s>", name, number); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Encode the Facility IE and put it into the message structure. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param ntmode Where the encoded facility was put when in NT mode. | 
					
						
							|  |  |  |  * \param msg General message structure | 
					
						
							|  |  |  |  * \param fac Data to encode into the facility ie. | 
					
						
							|  |  |  |  * \param nt TRUE if in NT mode. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Nothing | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void enc_ie_facility(unsigned char **ntmode, msg_t *msg, struct FacParm *fac, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int len; | 
					
						
							|  |  |  | 	Q931_info_t *qi; | 
					
						
							|  |  |  | 	unsigned char *p; | 
					
						
							|  |  |  | 	unsigned char buf[256]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	len = encodeFac(buf, fac); | 
					
						
							|  |  |  | 	if (len <= 0) { | 
					
						
							|  |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * mISDN does not know how to build the requested facility structure | 
					
						
							|  |  |  | 		 * Clear facility information | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		fac->Function = Fac_None; | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	p = msg_put(msg, len); | 
					
						
							|  |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		*ntmode = p + 1; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		qi = (Q931_info_t *) (msg->data + mISDN_HEADER_LEN); | 
					
						
							|  |  |  | 		qi->QI_ELEMENT(facility) = p - (unsigned char *) qi - sizeof(Q931_info_t); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	memcpy(p, buf, len); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Clear facility information */ | 
					
						
							|  |  |  | 	fac->Function = Fac_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Decode the Facility IE. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param p Encoded facility ie data to decode. (NT mode) | 
					
						
							|  |  |  |  * \param qi Encoded facility ie data to decode. (TE mode) | 
					
						
							|  |  |  |  * \param fac Where to put the decoded facility ie data if it is available. | 
					
						
							|  |  |  |  * \param nt TRUE if in NT mode. | 
					
						
							|  |  |  |  * \param bc Associated B channel | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Nothing | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void dec_ie_facility(unsigned char *p, Q931_info_t *qi, struct FacParm *fac, int nt, struct misdn_bchannel *bc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	fac->Function = Fac_None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!nt) { | 
					
						
							|  |  |  | 		p = NULL; | 
					
						
							|  |  |  | 		if (qi->QI_ELEMENT(facility)) { | 
					
						
							|  |  |  | 			p = (unsigned char *) qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(facility) + 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!p) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (decodeFac(p, fac)) { | 
					
						
							|  |  |  | 		cb_log(3, bc->port, "Decoding facility ie failed! Unrecognized facility message?\n"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static void set_channel(struct misdn_bchannel *bc, int channel) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	cb_log(3,bc->port,"set_channel: bc->channel:%d channel:%d\n", bc->channel, channel); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 	if (channel==0xff) { | 
					
						
							|  |  |  | 		/* any channel */ | 
					
						
							|  |  |  | 		channel=-1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 	/*  ALERT: is that everytime true ?  */ | 
					
						
							|  |  |  | 	if (channel > 0 && bc->nt ) { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		if (bc->channel && ( bc->channel != 0xff) ) { | 
					
						
							|  |  |  | 			cb_log(0,bc->port,"We already have a channel (%d)\n", bc->channel); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			bc->channel = channel; | 
					
						
							| 
									
										
										
										
											2006-05-24 23:21:03 +00:00
										 |  |  | 			cb_event(EVENT_NEW_CHANNEL,bc,NULL); | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-05-24 23:21:03 +00:00
										 |  |  | 	if (channel > 0 && !bc->nt ) { | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		bc->channel = channel; | 
					
						
							| 
									
										
										
										
											2006-05-24 23:21:03 +00:00
										 |  |  | 		cb_event(EVENT_NEW_CHANNEL,bc,NULL); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_proceeding (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	CALL_PROCEEDING_t *proceeding = (CALL_PROCEEDING_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 	//struct misdn_stack *stack=get_stack_by_bc(bc);
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		int  exclusive, channel; | 
					
						
							|  |  |  | 		dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)proceeding, &exclusive, &channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		set_channel(bc,channel); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)proceeding, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(proceeding->FACILITY, (Q931_info_t *) proceeding, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* dec_ie_redir_dn */ | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing PROCEEDING Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static msg_t *build_proceeding (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	CALL_PROCEEDING_t *proceeding; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING,  bc?bc->l3_id:-1, sizeof(CALL_PROCEEDING_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	proceeding=(CALL_PROCEEDING_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enc_ie_channel_id(&proceeding->CHANNEL_ID, msg, 1,bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		enc_ie_progress(&proceeding->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&proceeding->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* enc_ie_redir_dn */ | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building PROCEEDING Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_alerting (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	ALERTING_t *alerting = (ALERTING_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	//Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(alerting->FACILITY, (Q931_info_t *) alerting, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* dec_ie_redir_dn */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)alerting, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing ALERTING Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_alerting (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	ALERTING_t *alerting; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING,  bc?bc->l3_id:-1, sizeof(ALERTING_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	alerting=(ALERTING_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	enc_ie_channel_id(&alerting->CHANNEL_ID, msg, 1,bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		enc_ie_progress(&alerting->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&alerting->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* enc_ie_redir_dn */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building ALERTING Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_progress (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	PROGRESS_t *progress = (PROGRESS_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	//Q931_info_t *qi=(Q931_info_t*)(msg->data+HEADER_LEN);
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(progress->PROGRESS, (Q931_info_t *)progress, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(progress->FACILITY, (Q931_info_t *) progress, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing PROGRESS Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_progress (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	PROGRESS_t *progress; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_PROGRESS | REQUEST, MT_PROGRESS,  bc?bc->l3_id:-1, sizeof(PROGRESS_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	progress=(PROGRESS_t*)((msg->data+HEADER_LEN)); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-10 22:12:52 +00:00
										 |  |  | 	enc_ie_progress(&progress->PROGRESS, msg, 0, nt ? 1 : 5, 8, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&progress->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building PROGRESS Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Extract the SETUP message's BC, HLC, and LLC encoded ie contents. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param setup Indexed setup message contents | 
					
						
							|  |  |  |  * \param nt TRUE if in NT mode. | 
					
						
							|  |  |  |  * \param bc Associated B channel | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Nothing | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void extract_setup_Bc_Hlc_Llc(SETUP_t *setup, int nt, struct misdn_bchannel *bc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	__u8 *p; | 
					
						
							|  |  |  | 	Q931_info_t *qi; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	qi = (Q931_info_t *) setup; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Extract Bearer Capability */ | 
					
						
							|  |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		p = (__u8 *) setup->BEARER; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (qi->QI_ELEMENT(bearer_capability)) { | 
					
						
							|  |  |  | 			p = (__u8 *) qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(bearer_capability) + 1; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			p = NULL; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!p || *p == 0 || sizeof(bc->setup_bc_hlc_llc.Bc.Contents) < *p) { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Bc.Length = 0; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Bc.Length = *p; | 
					
						
							|  |  |  | 		memcpy(bc->setup_bc_hlc_llc.Bc.Contents, p + 1, *p); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Extract Low Layer Compatibility */ | 
					
						
							|  |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		p = (__u8 *) setup->LLC; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (qi->QI_ELEMENT(llc)) { | 
					
						
							|  |  |  | 			p = (__u8 *) qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(llc) + 1; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			p = NULL; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!p || *p == 0 || sizeof(bc->setup_bc_hlc_llc.Llc.Contents) < *p) { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Llc.Length = 0; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Llc.Length = *p; | 
					
						
							|  |  |  | 		memcpy(bc->setup_bc_hlc_llc.Llc.Contents, p + 1, *p); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Extract High Layer Compatibility */ | 
					
						
							|  |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		p = (__u8 *) setup->HLC; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (qi->QI_ELEMENT(hlc)) { | 
					
						
							|  |  |  | 			p = (__u8 *) qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(hlc) + 1; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			p = NULL; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!p || *p == 0 || sizeof(bc->setup_bc_hlc_llc.Hlc.Contents) < *p) { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Hlc.Length = 0; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->setup_bc_hlc_llc.Hlc.Length = *p; | 
					
						
							|  |  |  | 		memcpy(bc->setup_bc_hlc_llc.Hlc.Contents, p + 1, *p); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	SETUP_t *setup = (SETUP_t *) (msg->data + HEADER_LEN); | 
					
						
							|  |  |  | 	Q931_info_t *qi = (Q931_info_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	int type; | 
					
						
							|  |  |  | 	int plan; | 
					
						
							|  |  |  | 	int present; | 
					
						
							|  |  |  | 	int screen; | 
					
						
							|  |  |  | 	int reason; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing SETUP Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, bc->caller.number, sizeof(bc->caller.number), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	bc->caller.number_type = type; | 
					
						
							|  |  |  | 	bc->caller.number_plan = plan; | 
					
						
							|  |  |  | 	switch (present) { | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 		bc->caller.presentation = 0;	/* presentation allowed */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 1: | 
					
						
							|  |  |  | 		bc->caller.presentation = 1;	/* presentation restricted */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							|  |  |  | 		bc->caller.presentation = 2;	/* Number not available */ | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (0 <= screen) { | 
					
						
							|  |  |  | 		bc->caller.screening = screen; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->caller.screening = 0;	/* Unscreened */ | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(setup->FACILITY, (Q931_info_t *) setup, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *) setup, &type, &plan, bc->dialed.number, sizeof(bc->dialed.number), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	bc->dialed.number_type = type; | 
					
						
							|  |  |  | 	bc->dialed.number_plan = plan; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_keypad(setup->KEYPAD, (Q931_info_t *) setup, bc->keypad, sizeof(bc->keypad), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_complete(setup->COMPLETE, (Q931_info_t *) setup, &bc->sending_complete, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *) setup, &type, &plan, &present, &screen, &reason, bc->redirecting.from.number, sizeof(bc->redirecting.from.number), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	bc->redirecting.from.number_type = type; | 
					
						
							|  |  |  | 	bc->redirecting.from.number_plan = plan; | 
					
						
							|  |  |  | 	switch (present) { | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 		bc->redirecting.from.presentation = 0;	/* presentation allowed */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 1: | 
					
						
							|  |  |  | 		bc->redirecting.from.presentation = 1;	/* presentation restricted */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							|  |  |  | 		bc->redirecting.from.presentation = 2;	/* Number not available */ | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (0 <= screen) { | 
					
						
							|  |  |  | 		bc->redirecting.from.screening = screen; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->redirecting.from.screening = 0;	/* Unscreened */ | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (0 <= reason) { | 
					
						
							|  |  |  | 		bc->redirecting.reason = reason; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->redirecting.reason = mISDN_REDIRECTING_REASON_UNKNOWN; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		int  coding, capability, mode, rate, multi, user, async, urate, stopbits, dbits, parity; | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		dec_ie_bearer(setup->BEARER, (Q931_info_t *)setup, &coding, &capability, &mode, &rate, &multi, &user, &async, &urate, &stopbits, &dbits, &parity, nt,bc); | 
					
						
							|  |  |  | 		switch (capability) { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 		case -1: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case 0: bc->capability=INFO_CAPABILITY_SPEECH; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2006-06-01 12:51:41 +00:00
										 |  |  | 		case 18: bc->capability=INFO_CAPABILITY_VIDEO; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		case 8: bc->capability=INFO_CAPABILITY_DIGITAL_UNRESTRICTED; | 
					
						
							|  |  |  | 			bc->user1 = user; | 
					
						
							|  |  |  | 			bc->urate = urate; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			bc->rate = rate; | 
					
						
							|  |  |  | 			bc->mode = mode; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 9: bc->capability=INFO_CAPABILITY_DIGITAL_RESTRICTED; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		switch(user) { | 
					
						
							|  |  |  | 		case 2: | 
					
						
							|  |  |  | 			bc->law=INFO_CODEC_ULAW; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 3: | 
					
						
							|  |  |  | 			bc->law=INFO_CODEC_ALAW; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			bc->law=INFO_CODEC_ALAW; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		bc->capability=capability; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int  exclusive, channel; | 
					
						
							|  |  |  | 		dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)setup, &exclusive, &channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		set_channel(bc,channel); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												Merged revisions 58825-58826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:31:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int  protocol ; | 
					
						
							|  |  |  | 		dec_ie_useruser(setup->USER_USER, (Q931_info_t *)setup, &protocol, bc->uu, &bc->uulen, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		if (bc->uulen) cb_log(1, bc->port, "USERUSERINFO:%s\n", bc->uu); | 
					
						
							| 
									
										
											  
											
												Merged revisions 58825-58826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:31:27 +00:00
										 |  |  | 		else | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		cb_log(1, bc->port, "NO USERUSERINFO\n"); | 
					
						
							| 
									
										
											  
											
												Merged revisions 58825-58826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:31:27 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(setup->PROGRESS, (Q931_info_t *)setup, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	extract_setup_Bc_Hlc_Llc(setup, nt, bc); | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | #define ANY_CHANNEL 0xff /* IE attribute for 'any channel' */
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_setup (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	SETUP_t *setup; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_SETUP | REQUEST, MT_SETUP,  bc?bc->l3_id:-1, sizeof(SETUP_t) ,nt); | 
					
						
							| 
									
										
										
										
											2010-11-29 20:54:27 +00:00
										 |  |  | 	int is_ptp; | 
					
						
							|  |  |  | 	enum FacFunction fac_type; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	setup=(SETUP_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if (bc->channel == 0 || bc->channel == ANY_CHANNEL || bc->channel==-1) | 
					
						
							|  |  |  | 		enc_ie_channel_id(&setup->CHANNEL_ID, msg, 0, bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	else | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		enc_ie_channel_id(&setup->CHANNEL_ID, msg, 1, bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-29 20:54:27 +00:00
										 |  |  | 	fac_type = bc->fac_out.Function; | 
					
						
							|  |  |  | 	if (fac_type != Fac_None) { | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 		enc_ie_facility(&setup->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	enc_ie_calling_pn(&setup->CALLING_PN, msg, bc->caller.number_type, bc->caller.number_plan, | 
					
						
							|  |  |  | 		bc->caller.presentation, bc->caller.screening, bc->caller.number, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (bc->dialed.number[0]) { | 
					
						
							|  |  |  | 		enc_ie_called_pn(&setup->CALLED_PN, msg, bc->dialed.number_type, bc->dialed.number_plan, bc->dialed.number, nt, bc); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-02-24 17:38:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 	switch (bc->outgoing_colp) { | 
					
						
							|  |  |  | 	case 0:/* pass */ | 
					
						
							|  |  |  | 	case 1:/* restricted */ | 
					
						
							| 
									
										
										
										
											2010-11-29 20:54:27 +00:00
										 |  |  | 		is_ptp = misdn_lib_is_ptp(bc->port); | 
					
						
							|  |  |  | 		if (bc->redirecting.from.number[0] | 
					
						
							|  |  |  | 			&& ((!is_ptp && nt) | 
					
						
							|  |  |  | 				|| (is_ptp | 
					
						
							|  |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 					/*
 | 
					
						
							|  |  |  | 					 * There is no need to send out this ie when we are also sending | 
					
						
							|  |  |  | 					 * a Fac_DivertingLegInformation2 as well.  The | 
					
						
							|  |  |  | 					 * Fac_DivertingLegInformation2 supercedes the information in | 
					
						
							|  |  |  | 					 * this ie. | 
					
						
							|  |  |  | 					 */ | 
					
						
							|  |  |  | 					&& fac_type != Fac_DivertingLegInformation2 | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 			))) { | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if 1
 | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 			/* ETSI and Q.952 do not define the screening field */ | 
					
						
							|  |  |  | 			enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, | 
					
						
							|  |  |  | 				bc->redirecting.from.number_plan, bc->redirecting.from.presentation, 0, | 
					
						
							|  |  |  | 				bc->redirecting.reason, bc->redirecting.from.number, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 			/* Q.931 defines the screening field */ | 
					
						
							|  |  |  | 			enc_ie_redir_nr(&setup->REDIR_NR, msg, bc->redirecting.from.number_type, | 
					
						
							|  |  |  | 				bc->redirecting.from.number_plan, bc->redirecting.from.presentation, | 
					
						
							|  |  |  | 				bc->redirecting.from.screening, bc->redirecting.reason, | 
					
						
							|  |  |  | 				bc->redirecting.from.number, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							| 
									
										
										
										
											2006-02-24 17:38:43 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (bc->keypad[0]) { | 
					
						
							|  |  |  | 		enc_ie_keypad(&setup->KEYPAD, msg, bc->keypad, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 62912 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r62912 | crichter | 2007-05-03 16:36:32 +0200 (Do, 03 Mai 2007) | 17 lines
Merged revisions 61357,61770,62885 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r61357 | crichter | 2007-04-11 14:05:57 +0200 (Mi, 11 Apr 2007) | 1 line
some fixes for PMP Hold/Retrieve, it should work now, when briding=no
........
r61770 | crichter | 2007-04-24 15:50:05 +0200 (Di, 24 Apr 2007) | 1 line
added lock for sending messages to avoid double sending. shuffled some empty_chans after the cb_event calls, this avoids that a release_complete from a quite different call releases a fresh created setup by accident.
........
r62885 | crichter | 2007-05-03 15:59:00 +0200 (Do, 03 Mai 2007) | 1 line
fixed the problem that misdn_write did not return -1 when called with 0 samples in a frame this resultet in a deadlock in some circumstances, when the call ended because of a busy extension.  added encoding of keypad.
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:50:33 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if (*bc->display) { | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 		enc_ie_display(&setup->DISPLAY, msg, bc->display, nt, bc); | 
					
						
							|  |  |  | 	} else if (nt && bc->caller.presentation == 0) { | 
					
						
							|  |  |  | 		char display[sizeof(bc->display)]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Presentation is allowed */ | 
					
						
							|  |  |  | 		build_display_str(display, sizeof(display), bc->display_setup, bc->caller.name, bc->caller.number); | 
					
						
							|  |  |  | 		if (display[0]) { | 
					
						
							|  |  |  | 			enc_ie_display(&setup->DISPLAY, msg, display, nt, bc); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 		int coding = 0; | 
					
						
							|  |  |  | 		int capability; | 
					
						
							|  |  |  | 		int mode = 0;	/* 2 for packet! */ | 
					
						
							|  |  |  | 		int user; | 
					
						
							|  |  |  | 		int rate = 0x10; | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		switch (bc->law) { | 
					
						
							|  |  |  | 		case INFO_CODEC_ULAW: user=2; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case INFO_CODEC_ALAW: user=3; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			user=3; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		switch (bc->capability) { | 
					
						
							|  |  |  | 		case INFO_CAPABILITY_SPEECH: capability = 0; | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case INFO_CAPABILITY_DIGITAL_UNRESTRICTED: capability = 8; | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 			user=-1; | 
					
						
							| 
									
										
										
										
											2006-02-22 21:59:46 +00:00
										 |  |  | 			mode=bc->mode; | 
					
						
							|  |  |  | 			rate=bc->rate; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case INFO_CAPABILITY_DIGITAL_RESTRICTED: capability = 9; | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 			user=-1; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 			capability=bc->capability; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		enc_ie_bearer(&setup->BEARER, msg, coding, capability, mode, rate, -1, user, nt,bc); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												Merged revisions 49313 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE. 
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
  when 2 mISDN channels are involved and when bridging is set. That lead
  to a kernel panic before under different situations, because we switched 
  about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
  work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-01-03 11:15:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->sending_complete) { | 
					
						
							| 
									
										
										
										
											2007-05-18 12:43:59 +00:00
										 |  |  | 		enc_ie_complete(&setup->COMPLETE,msg, bc->sending_complete, nt, bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 49313 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r49313 | crichter | 2007-01-03 10:06:50 +0100 (Mi, 03 Jan 2007) | 41 lines
Merged revisions 48319,48321,48467,48552,48576,49135,49303 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r48319 | crichter | 2006-12-06 15:35:25 +0100 (Mi, 06 Dez 2006) | 1 line
changed a few debugs to higher debug levels
........
r48321 | crichter | 2006-12-06 16:48:45 +0100 (Mi, 06 Dez 2006) | 1 line
added the export and import of the MISDN_ADDRESS_COMPLETE Variable to inidcate wether the extension is already completely dialed or if there might come additional digits by information elements. also added some docs for that.
........
r48467 | crichter | 2006-12-14 14:03:49 +0100 (Do, 14 Dez 2006) | 1 line
removed FIXUP state. added check for channel allocation conflict when we create a setup while the other site creates a setup on the same channel, besides the check we resolve this conflict.
........
r48552 | crichter | 2006-12-18 11:19:39 +0100 (Mo, 18 Dez 2006) | 1 line
when our PTP Partner sends us a SETUP with a preselected channel we just accept it, even when we're NT. added some checks for segfaults.
........
r48576 | crichter | 2006-12-19 14:08:51 +0100 (Di, 19 Dez 2006) | 1 line
when we reject a channel, because it's in use already, we shouldn't process the setup anymore. made the channel allocation a bit easier and more understandable, removed a few unused lines
........
r49135 | crichter | 2007-01-02 11:07:22 +0100 (Di, 02 Jan 2007) | 1 line
added check for channel ranges in the set/empty channel functions. set pmp_l1_check default to no. added misdn restart pid cli command. added cleaning of channel when we send a RELEASE_COMPLETE. 
........
r49303 | crichter | 2007-01-03 09:24:00 +0100 (Mi, 03 Jan 2007) | 9 lines
* Added check for bridging in misdn_call to avoid setting echocancellation
  when 2 mISDN channels are involved and when bridging is set. That lead
  to a kernel panic before under different situations, because we switched 
  about 2 times between hardware bridging and echocancelation
* readded MISDN_URATE variable which got lost before, this should make app_v110
  work again
* fixed typo
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-01-03 11:15:02 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-18 12:43:59 +00:00
										 |  |  | 	if (bc->uulen) { | 
					
						
							| 
									
										
											  
											
												Merged revisions 58825-58826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:31:27 +00:00
										 |  |  | 		int  protocol=4; | 
					
						
							|  |  |  | 		enc_ie_useruser(&setup->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu); | 
					
						
							| 
									
										
											  
											
												Merged revisions 58825-58826 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r58825 | crichter | 2007-03-12 13:43:24 +0100 (Mo, 12 Mär 2007) | 1 line
added UU transceiving and corect handling for rdnis
................
r58826 | crichter | 2007-03-12 14:08:06 +0100 (Mo, 12 Mär 2007) | 21 lines
Merged revisions 57034,57523,57753,58558 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r57034 | crichter | 2007-02-28 17:09:27 +0100 (Mi, 28 Feb 2007) | 1 line
fixed bugs.digium.com bugs: #9157 and bugs.beronet.com bugs: #302, #303, #304
........
r57523 | crichter | 2007-03-02 19:32:51 +0100 (Fr, 02 Mar 2007) | 1 line
fixed typo
........
r57753 | crichter | 2007-03-04 11:39:50 +0100 (So, 04 Mar 2007) | 1 line
fixed another place where the out_cause was hardcoded to 16
........
r58558 | crichter | 2007-03-09 15:43:58 +0100 (Fr, 09 Mar 2007) | 1 line
we can free channel 31 as well, since we can occupy it
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@64951 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2007-05-18 09:31:27 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	extract_setup_Bc_Hlc_Llc(setup, nt, bc); | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building SETUP Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	CONNECT_t *connect = (CONNECT_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	int type; | 
					
						
							|  |  |  | 	int plan; | 
					
						
							|  |  |  | 	int pres; | 
					
						
							|  |  |  | 	int screen; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	bc->ces = connect->ces; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_progress(connect->PROGRESS, (Q931_info_t *)connect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2006-04-04 19:09:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	dec_ie_connected_pn(connect->CONNECT_PN, (Q931_info_t *) connect, &type, &plan, | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 		&pres, &screen, bc->connected.number, sizeof(bc->connected.number), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	bc->connected.number_type = type; | 
					
						
							|  |  |  | 	bc->connected.number_plan = plan; | 
					
						
							|  |  |  | 	switch (pres) { | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 	case 0: | 
					
						
							|  |  |  | 		bc->connected.presentation = 0;	/* presentation allowed */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 1: | 
					
						
							|  |  |  | 		bc->connected.presentation = 1;	/* presentation restricted */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case 2: | 
					
						
							|  |  |  | 		bc->connected.presentation = 2;	/* Number not available */ | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (0 <= screen) { | 
					
						
							|  |  |  | 		bc->connected.screening = screen; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->connected.screening = 0;	/* Unscreened */ | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-04 19:09:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(connect->FACILITY, (Q931_info_t *) connect, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-05 14:51:48 +00:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 		cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type); | 
					
						
							|  |  |  | 	*/ | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing CONNECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	CONNECT_t *connect; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT,  bc?bc->l3_id:-1, sizeof(CONNECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-08 16:10:21 +00:00
										 |  |  | 	cb_log(6,bc->port,"BUILD_CONNECT: bc:%p bc->l3id:%d, nt:%d\n",bc,bc->l3_id,nt); | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	connect=(CONNECT_t*)((msg->data+HEADER_LEN)); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		time_t now; | 
					
						
							|  |  |  | 		time(&now); | 
					
						
							|  |  |  | 		enc_ie_date(&connect->DATE, msg, now, nt,bc); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 	switch (bc->outgoing_colp) { | 
					
						
							|  |  |  | 	case 0:/* pass */ | 
					
						
							|  |  |  | 	case 1:/* restricted */ | 
					
						
							|  |  |  | 		enc_ie_connected_pn(&connect->CONNECT_PN, msg, bc->connected.number_type, | 
					
						
							|  |  |  | 			bc->connected.number_plan, bc->connected.presentation, | 
					
						
							|  |  |  | 			bc->connected.screening, bc->connected.number, nt, bc); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (nt && bc->connected.presentation == 0) { | 
					
						
							|  |  |  | 		char display[sizeof(bc->display)]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Presentation is allowed */ | 
					
						
							|  |  |  | 		build_display_str(display, sizeof(display), bc->display_connected, bc->connected.name, bc->connected.number); | 
					
						
							|  |  |  | 		if (display[0]) { | 
					
						
							|  |  |  | 			enc_ie_display(&connect->DISPLAY, msg, display, nt, bc); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&connect->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building CONNECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_setup_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	SETUP_ACKNOWLEDGE_t *setup_acknowledge = (SETUP_ACKNOWLEDGE_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		int  exclusive, channel; | 
					
						
							|  |  |  | 		dec_ie_channel_id(setup_acknowledge->CHANNEL_ID, (Q931_info_t *)setup_acknowledge, &exclusive, &channel, nt,bc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 		set_channel(bc, channel); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)setup_acknowledge, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_facility(setup_acknowledge->FACILITY, (Q931_info_t *) setup_acknowledge, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing SETUP_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_setup_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	SETUP_ACKNOWLEDGE_t *setup_acknowledge; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE,  bc?bc->l3_id:-1, sizeof(SETUP_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	setup_acknowledge=(SETUP_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, msg, 1,bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		enc_ie_progress(&setup_acknowledge->PROGRESS, msg, 0, nt?1:5, 8, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&setup_acknowledge->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building SETUP_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_connect_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing CONNECT_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_connect_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	CONNECT_ACKNOWLEDGE_t *connect_acknowledge; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT,  bc?bc->l3_id:-1, sizeof(CONNECT_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	connect_acknowledge=(CONNECT_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building CONNECT_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_user_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing USER_INFORMATION Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_user_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_USER_INFORMATION | REQUEST, MT_USER_INFORMATION,  bc?bc->l3_id:-1, sizeof(USER_INFORMATION_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building USER_INFORMATION Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_suspend_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing SUSPEND_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_suspend_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT,  bc?bc->l3_id:-1, sizeof(SUSPEND_REJECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building SUSPEND_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_resume_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RESUME_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_resume_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT,  bc?bc->l3_id:-1, sizeof(RESUME_REJECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RESUME_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_hold (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing HOLD Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_hold (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_HOLD | REQUEST, MT_HOLD,  bc?bc->l3_id:-1, sizeof(HOLD_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building HOLD Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_suspend (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing SUSPEND Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_suspend (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND | REQUEST, MT_SUSPEND,  bc?bc->l3_id:-1, sizeof(SUSPEND_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building SUSPEND Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_resume (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RESUME Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_resume (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RESUME | REQUEST, MT_RESUME,  bc?bc->l3_id:-1, sizeof(RESUME_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RESUME Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_hold_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing HOLD_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_hold_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE,  bc?bc->l3_id:-1, sizeof(HOLD_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building HOLD_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_suspend_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing SUSPEND_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_suspend_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE,  bc?bc->l3_id:-1, sizeof(SUSPEND_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building SUSPEND_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_resume_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RESUME_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_resume_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE,  bc?bc->l3_id:-1, sizeof(RESUME_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RESUME_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_hold_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing HOLD_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_hold_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT,  bc?bc->l3_id:-1, sizeof(HOLD_REJECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building HOLD_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_retrieve (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RETRIEVE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_retrieve (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE | REQUEST, MT_RETRIEVE,  bc?bc->l3_id:-1, sizeof(RETRIEVE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RETRIEVE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_retrieve_acknowledge (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RETRIEVE_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_retrieve_acknowledge (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE,  bc?bc->l3_id:-1, sizeof(RETRIEVE_ACKNOWLEDGE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	retrieve_acknowledge=(RETRIEVE_ACKNOWLEDGE_t*)((msg->data+HEADER_LEN)); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, msg, 1, bc->channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RETRIEVE_ACKNOWLEDGE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_retrieve_reject (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RETRIEVE_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_retrieve_reject (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT,  bc?bc->l3_id:-1, sizeof(RETRIEVE_REJECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RETRIEVE_REJECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_disconnect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	DISCONNECT_t *disconnect = (DISCONNECT_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	int location; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  |  	int cause; | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)(disconnect), &location, &cause, nt,bc); | 
					
						
							|  |  |  | 	if (cause>0) bc->cause=cause; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(disconnect->FACILITY, (Q931_info_t *) disconnect, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)disconnect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing DISCONNECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_disconnect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	DISCONNECT_t *disconnect; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT,  bc?bc->l3_id:-1, sizeof(DISCONNECT_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	disconnect=(DISCONNECT_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	enc_ie_cause(&disconnect->CAUSE, msg, (nt)?1:0, bc->out_cause,nt,bc); | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		enc_ie_progress(&disconnect->PROGRESS, msg, 0, nt ? 1 : 5, 8, nt, bc); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&disconnect->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->uulen) { | 
					
						
							|  |  |  | 		int  protocol=4; | 
					
						
							|  |  |  | 		enc_ie_useruser(&disconnect->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu); | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building DISCONNECT Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_restart (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	RESTART_t *restart = (RESTART_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-11-01 22:04:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct misdn_stack *stack=get_stack_by_bc(bc); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	printf("Parsing RESTART Msg\n"); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2007-07-02 09:23:08 +00:00
										 |  |  | 		int  exclusive; | 
					
						
							| 
									
										
										
										
											2006-06-01 12:51:41 +00:00
										 |  |  | 		dec_ie_channel_id(restart->CHANNEL_ID, (Q931_info_t *)restart, &exclusive, &bc->restart_channel, nt,bc); | 
					
						
							| 
									
										
										
										
											2007-07-02 09:23:08 +00:00
										 |  |  | 		cb_log(3, stack->port, "CC_RESTART Request on channel:%d on this port.\n", bc->restart_channel); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_restart (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	RESTART_t *restart; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RESTART | REQUEST, MT_RESTART,  bc?bc->l3_id:-1, sizeof(RESTART_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	restart=(RESTART_t*)((msg->data+HEADER_LEN)); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RESTART Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2007-11-12 13:33:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->channel > 0) { | 
					
						
							|  |  |  | 		enc_ie_channel_id(&restart->CHANNEL_ID, msg, 1,bc->channel, nt,bc); | 
					
						
							|  |  |  | 		enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x80, nt, bc); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		enc_ie_restart_ind(&restart->RESTART_IND, msg, 0x87, nt, bc); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-06-11 11:40:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	cb_log(0,bc->port, "Restarting channel %d\n", bc->channel); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_release (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	RELEASE_t *release = (RELEASE_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	int location; | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	int cause; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	dec_ie_cause(release->CAUSE, (Q931_info_t *)(release), &location, &cause, nt,bc); | 
					
						
							|  |  |  | 	if (cause>0) bc->cause=cause; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_facility(release->FACILITY, (Q931_info_t *) release, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RELEASE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_release (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	RELEASE_t *release; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE,  bc?bc->l3_id:-1, sizeof(RELEASE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	release=(RELEASE_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-22 16:48:25 +00:00
										 |  |  | 	if (bc->out_cause>= 0) | 
					
						
							|  |  |  | 		enc_ie_cause(&release->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc); | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&release->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 	if (bc->uulen) { | 
					
						
							|  |  |  | 		int  protocol=4; | 
					
						
							|  |  |  | 		enc_ie_useruser(&release->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu); | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RELEASE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_release_complete (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	RELEASE_COMPLETE_t *release_complete = (RELEASE_COMPLETE_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	int location; | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	int cause; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	iframe_t *frm = (iframe_t*) msg->data; | 
					
						
							| 
									
										
										
										
											2005-11-01 22:04:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	struct misdn_stack *stack=get_stack_by_bc(bc); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	mISDNuser_head_t *hh; | 
					
						
							|  |  |  | 	hh=(mISDNuser_head_t*)msg->data; | 
					
						
							| 
									
										
										
										
											2006-02-08 16:10:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/*hh=(mISDN_head_t*)msg->data;
 | 
					
						
							|  |  |  | 	mISDN_head_t *hh;*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if (nt) { | 
					
						
							|  |  |  | 		if (hh->prim == (CC_RELEASE_COMPLETE|CONFIRM)) { | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 			cb_log(0, stack->port, "CC_RELEASE_COMPLETE|CONFIRM [NT] \n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		if (frm->prim == (CC_RELEASE_COMPLETE|CONFIRM)) { | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 			cb_log(0, stack->port, "CC_RELEASE_COMPLETE|CONFIRM [TE] \n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)(release_complete), &location, &cause, nt,bc); | 
					
						
							|  |  |  | 	if (cause>0) bc->cause=cause; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_facility(release_complete->FACILITY, (Q931_info_t *) release_complete, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing RELEASE_COMPLETE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_release_complete (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	RELEASE_COMPLETE_t *release_complete; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE,  bc?bc->l3_id:-1, sizeof(RELEASE_COMPLETE_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	release_complete=(RELEASE_COMPLETE_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	enc_ie_cause(&release_complete->CAUSE, msg, nt?1:0, bc->out_cause, nt,bc); | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(&release_complete->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 	if (bc->uulen) { | 
					
						
							|  |  |  | 		int  protocol=4; | 
					
						
							|  |  |  | 		enc_ie_useruser(&release_complete->USER_USER, msg, protocol, bc->uu, bc->uulen, nt,bc); | 
					
						
							| 
									
										
											  
											
												Merged revisions 374515-374535 from
https://origsvn.digium.com/svn/asterisk/be/branches/C.3-bier
................
  r374515 | rmudgett | 2012-10-04 17:52:36 -0500 (Thu, 04 Oct 2012) | 10 lines
  chan_misdn: Remove some deadcode
  * Made setup_bc() static.
  Patches:
	patch1_unused-code.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374516 | rmudgett | 2012-10-04 18:01:01 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused bchan states
  Patches:
	patch2_unused-states.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374517 | rmudgett | 2012-10-04 18:17:51 -0500 (Thu, 04 Oct 2012) | 16 lines
  chan_misdn: Remove unnecessary null pointer checks and checks for stack->nt
  * cleanup_bc() is always called with valid bc (or it would've crashed
  before).
  * Value of stack->nt is known in advance at some places.
  * Rename handle_event() to handle_event_te(), handle_frm() to
  handle_frm_te().
  Patches:
	patch3_checks.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified
  JIRA ABE-2882
................
  r374518 | rmudgett | 2012-10-04 18:21:59 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Fix spelling in log messages
  Patches:
	patch4_spelling.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374519 | rmudgett | 2012-10-04 18:31:59 -0500 (Thu, 04 Oct 2012) | 15 lines
  chan_misdn: Don't cleanup a bc twice.
  In handle_frm_te() after calling misdn_lib_send_event(bc,
  EVENT_RELEASE_COMPLETE) bc is emptied, cleaned and set not in use,
  although misdn_lib_send_event() already did the same.  This is bad.  When
  it's not in use we are not allowed to touch it.
  * Moved log message in front of the resulting actions and fixed it to
  match the case.
  Patches:
	patch5_bccleanup.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374520 | rmudgett | 2012-10-04 18:43:56 -0500 (Thu, 04 Oct 2012) | 12 lines
  chan_misdn: Fix memory leaks, bc, chan not cleaned up etc., really bad stuff.
  * Fix return codes of cb_events() for EVENT_SETUP to use caller's cleanup
  mechanisms.
  * Move cl_queue_chan() call after bearer check.
  Patches:
	patch6_leaks.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374521 | rmudgett | 2012-10-04 18:48:38 -0500 (Thu, 04 Oct 2012) | 11 lines
  chan_misdn: We must initialize cause on sending a DISCONNECT.
  We must initialize cause on sending a DISCONNECT, so it is later correctly
  indicated to ast_channel in case the answer (RELEASE/RELEASE_COMPLETE)
  does not include one.
  Patches:
	patch7_hangupcause.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374522 | rmudgett | 2012-10-04 19:03:56 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Remove unused code for upqueue
  Patches:
	patch8_unused-upqueue.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374523 | rmudgett | 2012-10-04 19:11:50 -0500 (Thu, 04 Oct 2012) | 7 lines
  chan_misdn: Improve debugging (port number, messages fixed, dups removed)
  Patches:
	patch9_debug.diff (license #6372) patch uploaded by Guenther Kelleter
  JIRA ABE-2882
................
  r374533 | rmudgett | 2012-10-05 12:17:18 -0500 (Fri, 05 Oct 2012) | 8 lines
  chan_misdn: Better debug: we can print_bc_info even if there's no ast leg.
  Patches:
	patch10_debug-bc-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2882
................
  r374534 | rmudgett | 2012-10-05 12:34:10 -0500 (Fri, 05 Oct 2012) | 16 lines
  chan_misdn: setup_bc() is called too early for an incoming SETUP on TE.
  This prevents the B channel from being setup for HDLC mode when requested
  by the bearer capability and config option hdlc=yes.  It violates
  ETS300102 Ch.5.2.3.2: "The user, in any case, must not connect to the
  channel until a CONNECT ACKNOWLEDGE message has been received."
  * Call setup_bc() on receipt of CONNECT_ACKNOWLEGDE for PTMP, and on first
  response to SETUP for PTP.
  Patches:
	abe-2881-2.diff (license #6372) patch uploaded by Guenther Kelleter
	Modified.
  JIRA ABE-2881
................
  r374535 | rmudgett | 2012-10-05 12:41:05 -0500 (Fri, 05 Oct 2012) | 2 lines
  chan_misdn: Remove some more deadcode.
................
........
Merged revisions 374536 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 374537 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 374538 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@374539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
											
										 
											2012-10-05 18:42:14 +00:00
										 |  |  | 		cb_log(1, bc->port, "ENCODING USERUSERINFO:%s\n", bc->uu); | 
					
						
							| 
									
										
										
										
											2007-08-15 11:27:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building RELEASE_COMPLETE Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_facility (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	int HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	FACILITY_t *facility = (FACILITY_t*)(msg->data+HEADER_LEN); | 
					
						
							|  |  |  | 	Q931_info_t *qi = (Q931_info_t*)(msg->data+HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	unsigned char *p = NULL; | 
					
						
							| 
									
										
										
										
											2010-09-15 20:56:21 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	int description_code; | 
					
						
							|  |  |  | 	int type; | 
					
						
							|  |  |  | 	int plan; | 
					
						
							|  |  |  | 	int present; | 
					
						
							|  |  |  | 	char number[sizeof(bc->redirecting.to.number)]; | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing FACILITY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	bc->fac_in.Function = Fac_None; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	if (!bc->nt) { | 
					
						
							|  |  |  | 		if (qi->QI_ELEMENT(facility)) | 
					
						
							|  |  |  | 			p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->QI_ELEMENT(facility) + 1; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		p = facility->FACILITY; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!p) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	if (decodeFac(p, &bc->fac_in)) { | 
					
						
							|  |  |  | 		cb_log(3, bc->port, "Decoding facility ie failed! Unrecognized facility message?\n"); | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-09-15 20:56:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	dec_ie_notify(facility->NOTIFY, qi, &description_code, nt, bc); | 
					
						
							|  |  |  | 	if (description_code < 0) { | 
					
						
							|  |  |  | 		bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->notify_description_code = description_code; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_redir_dn(facility->REDIR_DN, qi, &type, &plan, &present, number, sizeof(number), nt, bc); | 
					
						
							|  |  |  | 	if (0 <= type) { | 
					
						
							|  |  |  | 		bc->redirecting.to_changed = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		bc->redirecting.to.number_type = type; | 
					
						
							|  |  |  | 		bc->redirecting.to.number_plan = plan; | 
					
						
							|  |  |  | 		switch (present) { | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 		case 0: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 0;	/* presentation allowed */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 1: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 1;	/* presentation restricted */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 2: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 2;	/* Number not available */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		bc->redirecting.to.screening = 0;	/* Unscreened */ | 
					
						
							|  |  |  | 		strcpy(bc->redirecting.to.number, number); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_facility (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	int len; | 
					
						
							|  |  |  | 	int HEADER_LEN; | 
					
						
							|  |  |  | 	unsigned char *ie_fac; | 
					
						
							|  |  |  | 	unsigned char fac_tmp[256]; | 
					
						
							|  |  |  | 	msg_t *msg; | 
					
						
							|  |  |  | 	FACILITY_t *facility; | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	Q931_info_t *qi; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building FACILITY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-16 13:19:54 +00:00
										 |  |  | 	len = encodeFac(fac_tmp, &(bc->fac_out)); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	if (len <= 0) { | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * mISDN does not know how to build the requested facility structure | 
					
						
							|  |  |  | 		 * Clear facility information | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		bc->fac_out.Function = Fac_None; | 
					
						
							| 
									
										
										
										
											2010-09-15 20:56:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 		/* Clear other one shot information. */ | 
					
						
							|  |  |  | 		bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; | 
					
						
							|  |  |  | 		bc->redirecting.to_changed = 0; | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	msg = (msg_t *) create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, bc ? bc->l3_id : -1, sizeof(FACILITY_t), nt); | 
					
						
							|  |  |  | 	HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	facility = (FACILITY_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ie_fac = msg_put(msg, len); | 
					
						
							|  |  |  | 	if (bc->nt) { | 
					
						
							|  |  |  | 		facility->FACILITY = ie_fac + 1; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); | 
					
						
							|  |  |  | 		qi->QI_ELEMENT(facility) = ie_fac - (unsigned char *)qi - sizeof(Q931_info_t); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	memcpy(ie_fac, fac_tmp, len); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	/* Clear facility information */ | 
					
						
							|  |  |  | 	bc->fac_out.Function = Fac_None; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 	if (*bc->display) { | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 		printf("Sending %s as Display\n", bc->display); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2006-08-15 16:49:26 +00:00
										 |  |  | 		enc_ie_display(&facility->DISPLAY, msg, bc->display, nt,bc); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-15 20:56:21 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	if (bc->notify_description_code != mISDN_NOTIFY_CODE_INVALID) { | 
					
						
							|  |  |  | 		enc_ie_notify(&facility->NOTIFY, msg, bc->notify_description_code, nt, bc); | 
					
						
							|  |  |  | 		bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->redirecting.to_changed) { | 
					
						
							|  |  |  | 		bc->redirecting.to_changed = 0; | 
					
						
							|  |  |  | 		switch (bc->outgoing_colp) { | 
					
						
							|  |  |  | 		case 0:/* pass */ | 
					
						
							|  |  |  | 		case 1:/* restricted */ | 
					
						
							|  |  |  | 			enc_ie_redir_dn(&facility->REDIR_DN, msg, bc->redirecting.to.number_type, | 
					
						
							|  |  |  | 				bc->redirecting.to.number_plan, bc->redirecting.to.presentation, | 
					
						
							|  |  |  | 				bc->redirecting.to.number, nt, bc); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Parse a received REGISTER message | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param msgs Search table entry that called us. | 
					
						
							|  |  |  |  * \param msg Received message contents | 
					
						
							|  |  |  |  * \param bc Associated B channel | 
					
						
							|  |  |  |  * \param nt TRUE if in NT mode. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Nothing | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void parse_register(struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN; | 
					
						
							|  |  |  | 	REGISTER_t *reg; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	reg = (REGISTER_t *) (msg->data + HEADER_LEN); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * A facility ie is optional. | 
					
						
							|  |  |  | 	 * The peer may just be establishing a connection to send | 
					
						
							|  |  |  | 	 * messages later. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	dec_ie_facility(reg->FACILITY, (Q931_info_t *) reg, &bc->fac_in, nt, bc); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | /*!
 | 
					
						
							|  |  |  |  * \internal | 
					
						
							|  |  |  |  * \brief Construct a REGISTER message | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \param msgs Search table entry that called us. | 
					
						
							|  |  |  |  * \param bc Associated B channel | 
					
						
							|  |  |  |  * \param nt TRUE if in NT mode. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \return Allocated built message | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static msg_t *build_register(struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN; | 
					
						
							|  |  |  | 	REGISTER_t *reg; | 
					
						
							|  |  |  | 	msg_t *msg; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	msg = (msg_t *) create_l3msg(CC_REGISTER | REQUEST, MT_REGISTER,  bc ? bc->l3_id : -1, sizeof(REGISTER_t), nt); | 
					
						
							|  |  |  | 	HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	reg = (REGISTER_t *) (msg->data + HEADER_LEN); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->fac_out.Function != Fac_None) { | 
					
						
							|  |  |  | 		enc_ie_facility(®->FACILITY, msg, &bc->fac_out, nt); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return msg; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_notify (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	int HEADER_LEN = nt ? mISDNUSER_HEAD_SIZE : mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	NOTIFY_t *notify = (NOTIFY_t *) (msg->data + HEADER_LEN); | 
					
						
							|  |  |  | 	int description_code; | 
					
						
							|  |  |  | 	int type; | 
					
						
							|  |  |  | 	int plan; | 
					
						
							|  |  |  | 	int present; | 
					
						
							|  |  |  | 	char number[sizeof(bc->redirecting.to.number)]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing NOTIFY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_notify(notify->NOTIFY, (Q931_info_t *) notify, &description_code, nt, bc); | 
					
						
							|  |  |  | 	if (description_code < 0) { | 
					
						
							|  |  |  | 		bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		bc->notify_description_code = description_code; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dec_ie_redir_dn(notify->REDIR_DN, (Q931_info_t *) notify, &type, &plan, &present, number, sizeof(number), nt, bc); | 
					
						
							|  |  |  | 	if (0 <= type) { | 
					
						
							|  |  |  | 		bc->redirecting.to_changed = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		bc->redirecting.to.number_type = type; | 
					
						
							|  |  |  | 		bc->redirecting.to.number_plan = plan; | 
					
						
							|  |  |  | 		switch (present) { | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 		case 0: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 0;	/* presentation allowed */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 1: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 1;	/* presentation restricted */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case 2: | 
					
						
							|  |  |  | 			bc->redirecting.to.presentation = 2;	/* Number not available */ | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		bc->redirecting.to.screening = 0;	/* Unscreened */ | 
					
						
							|  |  |  | 		strcpy(bc->redirecting.to.number, number); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_notify (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	NOTIFY_t *notify; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY,  bc?bc->l3_id:-1, sizeof(NOTIFY_t) ,nt); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building NOTIFY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	notify = (NOTIFY_t *) (msg->data + HEADER_LEN); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enc_ie_notify(¬ify->NOTIFY, msg, bc->notify_description_code, nt, bc); | 
					
						
							| 
									
										
										
										
											2010-09-15 20:56:21 +00:00
										 |  |  | 	bc->notify_description_code = mISDN_NOTIFY_CODE_INVALID; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (bc->redirecting.to_changed) { | 
					
						
							|  |  |  | 		bc->redirecting.to_changed = 0; | 
					
						
							| 
									
										
										
										
											2009-05-14 22:03:49 +00:00
										 |  |  | 		switch (bc->outgoing_colp) { | 
					
						
							|  |  |  | 		case 0:/* pass */ | 
					
						
							|  |  |  | 		case 1:/* restricted */ | 
					
						
							|  |  |  | 			enc_ie_redir_dn(¬ify->REDIR_DN, msg, bc->redirecting.to.number_type, | 
					
						
							|  |  |  | 				bc->redirecting.to.number_plan, bc->redirecting.to.presentation, | 
					
						
							|  |  |  | 				bc->redirecting.to.number, nt, bc); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_status_enquiry (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing STATUS_ENQUIRY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_status_enquiry (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_STATUS_ENQUIRY | REQUEST, MT_STATUS_ENQUIRY,  bc?bc->l3_id:-1, sizeof(STATUS_ENQUIRY_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building STATUS_ENQUIRY Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	INFORMATION_t *information = (INFORMATION_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	int type, plan; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *) information, &type, &plan, bc->info_dad, sizeof(bc->info_dad), nt, bc); | 
					
						
							|  |  |  | 	dec_ie_keypad(information->KEYPAD, (Q931_info_t *) information, bc->keypad, sizeof(bc->keypad), nt, bc); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing INFORMATION Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_information (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							|  |  |  | 	INFORMATION_t *information; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION,  bc?bc->l3_id:-1, sizeof(INFORMATION_t) ,nt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	information=(INFORMATION_t*)((msg->data+HEADER_LEN)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	enc_ie_called_pn(&information->CALLED_PN, msg, 0, 1, bc->info_dad, nt,bc); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if (*bc->display) { | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			printf("Sending %s as Display\n", bc->display); | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			enc_ie_display(&information->DISPLAY, msg, bc->display, nt,bc); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building INFORMATION Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_status (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | 	STATUS_t *status = (STATUS_t *) (msg->data + HEADER_LEN); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	int location; | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	int cause; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-13 08:23:41 +00:00
										 |  |  | 	dec_ie_cause(status->CAUSE, (Q931_info_t *)(status), &location, &cause, nt,bc); | 
					
						
							|  |  |  | 	if (cause>0) bc->cause=cause; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing STATUS Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_status (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS,  bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building STATUS Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static void parse_timeout (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Parsing STATUS Msg\n"); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | static msg_t *build_timeout (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	msg_t *msg =(msg_t*)create_l3msg(CC_STATUS | REQUEST, MT_STATUS,  bc?bc->l3_id:-1, sizeof(STATUS_t) ,nt); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | #ifdef DEBUG
 | 
					
						
							|  |  |  | 	printf("Building STATUS Msg\n"); | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	return msg; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** Msg Array **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct isdn_msg msgs_g[] = { | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | /* *INDENT-OFF* */ | 
					
						
							|  |  |  | 	/* misdn_msg,               event,                      msg_parser,                 msg_builder,                info */ | 
					
						
							|  |  |  | 	{ CC_PROCEEDING,            EVENT_PROCEEDING,           parse_proceeding,           build_proceeding,           "PROCEEDING" }, | 
					
						
							|  |  |  | 	{ CC_ALERTING,              EVENT_ALERTING,             parse_alerting,             build_alerting,             "ALERTING" }, | 
					
						
							|  |  |  | 	{ CC_PROGRESS,              EVENT_PROGRESS,             parse_progress,             build_progress,             "PROGRESS" }, | 
					
						
							|  |  |  | 	{ CC_SETUP,                 EVENT_SETUP,                parse_setup,                build_setup,                "SETUP" }, | 
					
						
							| 
									
										
										
										
											2009-04-21 17:44:01 +00:00
										 |  |  | #if defined(AST_MISDN_ENHANCEMENTS)
 | 
					
						
							|  |  |  | 	{ CC_REGISTER,              EVENT_REGISTER,             parse_register,             build_register,             "REGISTER" }, | 
					
						
							|  |  |  | #endif	/* defined(AST_MISDN_ENHANCEMENTS) */
 | 
					
						
							| 
									
										
										
										
											2009-04-03 22:41:46 +00:00
										 |  |  | 	{ CC_CONNECT,               EVENT_CONNECT,              parse_connect,              build_connect,              "CONNECT" }, | 
					
						
							|  |  |  | 	{ CC_SETUP_ACKNOWLEDGE,     EVENT_SETUP_ACKNOWLEDGE,    parse_setup_acknowledge,    build_setup_acknowledge,    "SETUP_ACKNOWLEDGE" }, | 
					
						
							|  |  |  | 	{ CC_CONNECT_ACKNOWLEDGE,   EVENT_CONNECT_ACKNOWLEDGE,  parse_connect_acknowledge,  build_connect_acknowledge,  "CONNECT_ACKNOWLEDGE " }, | 
					
						
							|  |  |  | 	{ CC_USER_INFORMATION,      EVENT_USER_INFORMATION,     parse_user_information,     build_user_information,     "USER_INFORMATION" }, | 
					
						
							|  |  |  | 	{ CC_SUSPEND_REJECT,        EVENT_SUSPEND_REJECT,       parse_suspend_reject,       build_suspend_reject,       "SUSPEND_REJECT" }, | 
					
						
							|  |  |  | 	{ CC_RESUME_REJECT,         EVENT_RESUME_REJECT,        parse_resume_reject,        build_resume_reject,        "RESUME_REJECT" }, | 
					
						
							|  |  |  | 	{ CC_HOLD,                  EVENT_HOLD,                 parse_hold,                 build_hold,                 "HOLD" }, | 
					
						
							|  |  |  | 	{ CC_SUSPEND,               EVENT_SUSPEND,              parse_suspend,              build_suspend,              "SUSPEND" }, | 
					
						
							|  |  |  | 	{ CC_RESUME,                EVENT_RESUME,               parse_resume,               build_resume,               "RESUME" }, | 
					
						
							|  |  |  | 	{ CC_HOLD_ACKNOWLEDGE,      EVENT_HOLD_ACKNOWLEDGE,     parse_hold_acknowledge,     build_hold_acknowledge,     "HOLD_ACKNOWLEDGE" }, | 
					
						
							|  |  |  | 	{ CC_SUSPEND_ACKNOWLEDGE,   EVENT_SUSPEND_ACKNOWLEDGE,  parse_suspend_acknowledge,  build_suspend_acknowledge,  "SUSPEND_ACKNOWLEDGE" }, | 
					
						
							|  |  |  | 	{ CC_RESUME_ACKNOWLEDGE,    EVENT_RESUME_ACKNOWLEDGE,   parse_resume_acknowledge,   build_resume_acknowledge,   "RESUME_ACKNOWLEDGE" }, | 
					
						
							|  |  |  | 	{ CC_HOLD_REJECT,           EVENT_HOLD_REJECT,          parse_hold_reject,          build_hold_reject,          "HOLD_REJECT" }, | 
					
						
							|  |  |  | 	{ CC_RETRIEVE,              EVENT_RETRIEVE,             parse_retrieve,             build_retrieve,             "RETRIEVE" }, | 
					
						
							|  |  |  | 	{ CC_RETRIEVE_ACKNOWLEDGE,  EVENT_RETRIEVE_ACKNOWLEDGE, parse_retrieve_acknowledge, build_retrieve_acknowledge, "RETRIEVE_ACKNOWLEDGE" }, | 
					
						
							|  |  |  | 	{ CC_RETRIEVE_REJECT,       EVENT_RETRIEVE_REJECT,      parse_retrieve_reject,      build_retrieve_reject,      "RETRIEVE_REJECT" }, | 
					
						
							|  |  |  | 	{ CC_DISCONNECT,            EVENT_DISCONNECT,           parse_disconnect,           build_disconnect,           "DISCONNECT" }, | 
					
						
							|  |  |  | 	{ CC_RESTART,               EVENT_RESTART,              parse_restart,              build_restart,              "RESTART" }, | 
					
						
							|  |  |  | 	{ CC_RELEASE,               EVENT_RELEASE,              parse_release,              build_release,              "RELEASE" }, | 
					
						
							|  |  |  | 	{ CC_RELEASE_COMPLETE,      EVENT_RELEASE_COMPLETE,     parse_release_complete,     build_release_complete,     "RELEASE_COMPLETE" }, | 
					
						
							|  |  |  | 	{ CC_FACILITY,              EVENT_FACILITY,             parse_facility,             build_facility,             "FACILITY" }, | 
					
						
							|  |  |  | 	{ CC_NOTIFY,                EVENT_NOTIFY,               parse_notify,               build_notify,               "NOTIFY" }, | 
					
						
							|  |  |  | 	{ CC_STATUS_ENQUIRY,        EVENT_STATUS_ENQUIRY,       parse_status_enquiry,       build_status_enquiry,       "STATUS_ENQUIRY" }, | 
					
						
							|  |  |  | 	{ CC_INFORMATION,           EVENT_INFORMATION,          parse_information,          build_information,          "INFORMATION" }, | 
					
						
							|  |  |  | 	{ CC_STATUS,                EVENT_STATUS,               parse_status,               build_status,               "STATUS" }, | 
					
						
							|  |  |  | 	{ CC_TIMEOUT,               EVENT_TIMEOUT,              parse_timeout,              build_timeout,              "TIMEOUT" }, | 
					
						
							|  |  |  | 	{ 0, 0, NULL, NULL, NULL } | 
					
						
							|  |  |  | /* *INDENT-ON* */ | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define msgs_max (sizeof(msgs_g)/sizeof(struct isdn_msg))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** INTERFACE FCTS ***/ | 
					
						
							|  |  |  | int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (nt){ | 
					
						
							|  |  |  | 		mISDNuser_head_t *hh = (mISDNuser_head_t*)msg->data; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 		for (i=0; i< msgs_max -1; i++) { | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			if ( (hh->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i; | 
					
						
							| 
									
										
										
										
											2005-12-09 11:01:18 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		iframe_t *frm = (iframe_t*)msg->data; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		for (i=0; i< msgs_max -1; i++) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 			if ( (frm->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 	for (i=0; i< msgs_max; i++) | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 		if ( event == msgs[i].event) return i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 	cb_log(10,0, "get_index: event not found!\n"); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *msg, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i=isdn_msg_get_index(msgs, msg, nt); | 
					
						
							|  |  |  | 	if(i>=0) return msgs[i].event; | 
					
						
							|  |  |  | 	return EVENT_UNKNOWN; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i=isdn_msg_get_index(msgs, msg, nt); | 
					
						
							|  |  |  | 	if(i>=0) return msgs[i].info; | 
					
						
							|  |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | char EVENT_CLEAN_INFO[] = "CLEAN_UP"; | 
					
						
							|  |  |  | char EVENT_DTMF_TONE_INFO[] = "DTMF_TONE"; | 
					
						
							|  |  |  | char EVENT_NEW_L3ID_INFO[] = "NEW_L3ID"; | 
					
						
							|  |  |  | char EVENT_NEW_BC_INFO[] = "NEW_BC"; | 
					
						
							| 
									
										
										
										
											2006-08-03 16:38:00 +00:00
										 |  |  | char EVENT_PORT_ALARM_INFO[] = "ALARM"; | 
					
						
							| 
									
										
										
										
											2006-05-24 23:21:03 +00:00
										 |  |  | char EVENT_NEW_CHANNEL_INFO[] = "NEW_CHANNEL"; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA"; | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED"; | 
					
						
							|  |  |  | char EVENT_TONE_GENERATE_INFO[] = "TONE_GENERATE"; | 
					
						
							| 
									
										
										
										
											2006-10-27 11:18:32 +00:00
										 |  |  | char EVENT_BCHAN_ERROR_INFO[] = "BCHAN_ERROR"; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i=isdn_msg_get_index_by_event(msgs, event, nt); | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if(i>=0) return msgs[i].info; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if (event == EVENT_CLEANUP) return EVENT_CLEAN_INFO; | 
					
						
							|  |  |  | 	if (event == EVENT_DTMF_TONE) return EVENT_DTMF_TONE_INFO; | 
					
						
							|  |  |  | 	if (event == EVENT_NEW_L3ID) return EVENT_NEW_L3ID_INFO; | 
					
						
							|  |  |  | 	if (event == EVENT_NEW_BC) return EVENT_NEW_BC_INFO; | 
					
						
							| 
									
										
										
										
											2006-05-24 23:21:03 +00:00
										 |  |  | 	if (event == EVENT_NEW_CHANNEL) return EVENT_NEW_CHANNEL_INFO; | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	if (event == EVENT_BCHAN_DATA) return EVENT_BCHAN_DATA_INFO; | 
					
						
							| 
									
										
										
										
											2006-02-02 21:15:34 +00:00
										 |  |  | 	if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO; | 
					
						
							|  |  |  | 	if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO; | 
					
						
							| 
									
										
										
										
											2006-08-03 16:38:00 +00:00
										 |  |  | 	if (event == EVENT_PORT_ALARM) return EVENT_PORT_ALARM_INFO; | 
					
						
							| 
									
										
										
										
											2006-10-27 11:18:32 +00:00
										 |  |  | 	if (event == EVENT_BCHAN_ERROR) return EVENT_BCHAN_ERROR_INFO; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	return NULL; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i=isdn_msg_get_index(msgs, msg, nt); | 
					
						
							|  |  |  | 	if(i<0) return -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	msgs[i].msg_parser(msgs, msg, bc, nt); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i=isdn_msg_get_index_by_event(msgs, event, nt); | 
					
						
							|  |  |  | 	if(i<0) return NULL; | 
					
						
							| 
									
										
										
										
											2009-03-23 22:35:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-31 23:30:09 +00:00
										 |  |  | 	return  msgs[i].msg_builder(msgs, bc, nt); | 
					
						
							|  |  |  | } |