[asterisk-commits] trunk r17562 - in /trunk/channels: ./ misdn/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 5 07:51:53 MST 2006


Author: crichter
Date: Wed Apr  5 09:51:48 2006
New Revision: 17562

URL: http://svn.digium.com/view/asterisk?rev=17562&view=rev
Log:
* advanced the error Handling routine for wrong frames from mISDN
* added more code for connected party number handling
* fixed the portinfo program, it can now be used to test mISDN again


Modified:
    trunk/channels/chan_misdn.c
    trunk/channels/misdn/Makefile
    trunk/channels/misdn/isdn_lib.c
    trunk/channels/misdn/isdn_lib.h
    trunk/channels/misdn/isdn_msg_parser.c
    trunk/channels/misdn/portinfo.c

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Wed Apr  5 09:51:48 2006
@@ -1687,6 +1687,12 @@
 	}
 	
 	p->state = MISDN_CONNECTED;
+
+	if ( ast_strlen_zero(p->bc->cad) ) {
+		chan_misdn_log(2,p->bc->port," --> empty cad using dad\n");
+		ast_copy_string(p->bc->cad,p->bc->dad,sizeof(p->bc->cad));
+	}
+
 	misdn_lib_send_event( p->bc, EVENT_CONNECT);
 	start_bc_tones(p);
 	
@@ -2131,7 +2137,7 @@
 		case BCHAN_BRIDGED:
 			break;
 		default:
-		chan_misdn_log(5, ch->bc->port, "BC not active (nor bridged) droping: %d frames addr:%x\n",frame->samples,ch->bc->addr);
+		chan_misdn_log(5, ch->bc->port, "BC not active (nor bridged) droping: %d frames addr:%x exten:%s cid:%s ch->state:%s\n",frame->samples,ch->bc->addr, ast->exten, ast->cid.cid_num,misdn_get_ch_state( ch));
 		return 0;
 	}
 	
@@ -3493,7 +3499,21 @@
 	}
 	break;
 	case EVENT_CONNECT:
+	{
 		misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
+	
+		struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
+		
+		if (bridged && strcasecmp(bridged->tech->type,"mISDN")) {
+			struct chan_list *bridged_ch=MISDN_ASTERISK_TECH_PVT(bridged);
+
+			chan_misdn_log(1,bc->port," --> copying cpndialplan:%d and cad:%s to the A-Channel\n",bc->cpnnumplan,bc->cad);
+
+			bridged_ch->bc->cpnnumplan=bc->cpnnumplan;
+			ast_copy_string(bridged_ch->bc->cad,bc->cad,sizeof(bc->cad));
+		}
+	}
+
 	case EVENT_CONNECT_ACKNOWLEDGE:
 	{
 		ch->l3id=bc->l3_id;

Modified: trunk/channels/misdn/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/Makefile?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/misdn/Makefile (original)
+++ trunk/channels/misdn/Makefile Wed Apr  5 09:51:48 2006
@@ -18,9 +18,13 @@
 %.o: %.c
 	$(CC) $(CFLAGS) -o $@ $<
 
-
 chan_misdn_lib.a:	$(OBJS)
 	ar crv $@ $(OBJS)
 
+
+portinfo: portinfo.o
+	$(CC) -L/usr/lib -o $@ $^ -lisdnnet -lmISDN -lpthread
+
+
 clean: 
-	rm -rf *.a *.o *.so
+	rm -rf *.a *.o *.so portinfo

Modified: trunk/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.c?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.c (original)
+++ trunk/channels/misdn/isdn_lib.c Wed Apr  5 09:51:48 2006
@@ -563,6 +563,7 @@
 	bc->info_dad[0] = 0;
 	bc->display[0] = 0;
 	bc->infos_pending[0] = 0;
+	bc->cad[0] = 0;
 	bc->oad[0] = 0;
 	bc->dad[0] = 0;
 	bc->rad[0] = 0;
@@ -1362,6 +1363,23 @@
 	}
 
 	
+	return NULL;
+}
+
+
+struct misdn_bchannel *find_bc_by_channel(int port, int channel)
+{
+	struct misdn_stack* stack=find_stack_by_port(port);
+	int i;
+
+	if (!stack) return NULL;	
+	
+	for (i=0; i< stack->b_num; i++) {
+		if ( stack->bc[i].channel== channel ) {
+			return &stack->bc[i];
+		}
+	}
+		
 	return NULL;
 }
 
@@ -2763,16 +2781,17 @@
 
 	if (!stack) return;
 
-	cb_log(2, stack->port, " --> mode:%s cause:%d ocause:%d rad:%s\n", stack->nt?"NT":"TE", bc->cause, bc->out_cause, bc->rad);
+	cb_log(2, stack->port, " --> mode:%s cause:%d ocause:%d rad:%s cad:%s\n", stack->nt?"NT":"TE", bc->cause, bc->out_cause, bc->rad, bc->cad);
 	
 	cb_log(3, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_type),fac2str(bc->out_fac_type));
 	
 	cb_log(2, stack->port,
-	       " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c\n",
+	       " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
 	       bc->info_dad,
 	       bc->onumplan>=0?'0'+bc->onumplan:' ',
 	       bc->dnumplan>=0?'0'+bc->dnumplan:' ',
-	       bc->rnumplan>=0?'0'+bc->rnumplan:' '
+	       bc->rnumplan>=0?'0'+bc->rnumplan:' ',
+	       bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
 		);
 	cb_log(3, stack->port, " --> screen:%d --> pres:%d\n",
 			bc->screen, bc->pres);
@@ -2951,34 +2970,39 @@
 int handle_err(msg_t *msg)
 {
 	iframe_t *frm = (iframe_t*) msg->data;
-	unsigned char buff[32];
 	
 	switch (frm->prim) {
 		case DL_DATA|INDICATION:
-			{
-			struct misdn_stack *stack=find_stack_by_port( (frm->addr&MASTER_ID_MASK) >> 8);
-			if (!stack) {
-				cb_log(-1,0,"BCHAN DATA without having a Chan Object (addr:%x) probably we died before closing..\n",frm->addr);
-				return 0;
-			}
-			cb_log(-1,stack->port,"BCHAN DATA without having a Chan Object (addr:%x) probably we died before closing..\n",frm->addr);
-
-			if (stack->l1link)
-				misdn_lib_get_l1_down(stack);
-#if 0
-			iframe_t dact;
-			dact.prim = DL_RELEASE | REQUEST;
-			dact.addr = frm->addr | FLG_MSG_DOWN;
-			dact.dinfo = 0;
-			dact.len = 0;
-	
-			mISDN_write(glob_mgr->midev, &dact, mISDN_HEADER_LEN+dact.len, TIMEOUT_1SEC);
-
-			mISDN_write_frame(glob_mgr->midev, buff, frm->addr|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-#endif
-			free_msg(msg);
-			return 1;
-			}
+		{
+			int port=(frm->addr&MASTER_ID_MASK) >> 8;
+			int channel=(frm->addr&CHILD_ID_MASK) >> 16;
+
+			cb_log(3,0,"BCHAN DATA without BC: addr:%x port:%d channel:%d\n",frm->addr, port,channel);
+			
+			struct misdn_bchannel *bc=find_bc_by_channel( port , channel);
+
+			if (!bc) {
+				struct misdn_stack *stack=find_stack_by_port( port );
+
+				if (!stack) {
+					cb_log(-1,0," --> stack not found\n");
+					free_msg(msg);
+					return 1;
+				}
+				
+				cb_log(-1,0," --> bc not found by channel\n");
+				if (stack->l2link)
+					misdn_lib_get_l2_down(stack);
+
+				if (stack->l1link)
+					misdn_lib_get_l1_down(stack);
+
+				free_msg(msg);
+				return 1;
+			}
+			
+			cb_log(3,port," --> BC in state:%s\n", bc_state2str(bc->bc_state));
+		}
 	}
 
 	return 0;

Modified: trunk/channels/misdn/isdn_lib.h
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_lib.h?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_lib.h (original)
+++ trunk/channels/misdn/isdn_lib.h Wed Apr  5 09:51:48 2006
@@ -279,6 +279,7 @@
 	unsigned char oad[32];
 	unsigned char rad[32];
 	unsigned char dad[32];
+	unsigned char cad[32];
 	unsigned char orig_dad[32];
 	unsigned char keypad[32];
 

Modified: trunk/channels/misdn/isdn_msg_parser.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/isdn_msg_parser.c?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/misdn/isdn_msg_parser.c (original)
+++ trunk/channels/misdn/isdn_msg_parser.c Wed Apr  5 09:51:48 2006
@@ -159,7 +159,7 @@
 	{
 		int type,plan,present, screen;
 		char id[32];
-		dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, (unsigned char *)id, sizeof(id), nt,bc);
+		dec_ie_calling_pn(setup->CALLING_PN, qi, &type, &plan, &present, &screen, (unsigned char *)id, sizeof(id)-1, nt,bc);
 
 		bc->onumplan=type; 
 		strcpy(bc->oad, id);
@@ -183,13 +183,13 @@
 	{
 		int  type, plan;
 		char number[32]; 
-		dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)setup, &type, &plan, (unsigned char *)number, sizeof(number), nt,bc);
+		dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)setup, &type, &plan, (unsigned char *)number, sizeof(number)-1, nt,bc);
 		strcpy(bc->dad, number);
 		bc->dnumplan=type; 
 	}
 	{
 		char keypad[32];
-		dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)setup, (unsigned char *)keypad, sizeof(keypad), nt,bc);
+		dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)setup, (unsigned char *)keypad, sizeof(keypad)-1, nt,bc);
 		strcpy(bc->keypad, keypad);
 	}
 
@@ -201,7 +201,7 @@
 	{
 		int  type, plan, present, screen, reason;
 		char id[32]; 
-		dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)setup, &type, &plan, &present, &screen, &reason, (unsigned char *)id, sizeof(id), nt,bc);
+		dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)setup, &type, &plan, &present, &screen, &reason, (unsigned char *)id, sizeof(id)-1, nt,bc);
     
 		strcpy(bc->rad, id);
 		bc->rnumplan=type; 
@@ -333,17 +333,18 @@
 	int HEADER_LEN = nt?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
 	CONNECT_t *connect=(CONNECT_t*)((unsigned long)(msg->data+HEADER_LEN));
   
-	int type,plan,pres,screen;
-	char connected_pn[32];
+	int plan,pres,screen;
 	
 	bc->ces = connect->ces;
 	bc->ces = connect->ces;
 
 	dec_ie_progress(connect->PROGRESS, (Q931_info_t *)connect, &bc->progress_coding, &bc->progress_location, &bc->progress_indicator, nt, bc);
 
-	dec_ie_connected_pn(connect->CONNECT_PN,(Q931_info_t *)connect, &type, &plan, &pres, &screen, connected_pn, 31, nt, bc);
-
-	cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type);
+	dec_ie_connected_pn(connect->CONNECT_PN,(Q931_info_t *)connect, &bc->cpnnumplan, &plan, &pres, &screen, bc->cad, 31, nt, bc);
+
+	/*
+		cb_log(1,bc->port,"CONNETED PN: %s cpn_dialplan:%d\n", connected_pn, type);
+	*/
 	
 #if DEBUG 
 	printf("Parsing CONNECT Msg\n"); 
@@ -367,7 +368,7 @@
   
 	{
 		int type=bc->cpnnumplan, plan=1, present=2, screen=0;
-		enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, (unsigned char*) bc->dad , nt , bc);
+		enc_ie_connected_pn(&connect->CONNECT_PN, msg, type,plan, present, screen, (unsigned char*) bc->cad, nt , bc);
 	}
 
 #if DEBUG 
@@ -961,8 +962,8 @@
 		int  type, plan;
 		char number[32];
 		char keypad[32];
-		dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)information, &type, &plan, (unsigned char *)number, sizeof(number), nt, bc);
-		dec_ie_keypad(information->KEYPAD, (Q931_info_t *)information, (unsigned char *)keypad, sizeof(keypad), nt, bc);
+		dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)information, &type, &plan, (unsigned char *)number, sizeof(number)-1, nt, bc);
+		dec_ie_keypad(information->KEYPAD, (Q931_info_t *)information, (unsigned char *)keypad, sizeof(keypad)-1, nt, bc);
 		strcpy(bc->info_dad, number);
 		strcpy(bc->keypad,keypad);
 	}

Modified: trunk/channels/misdn/portinfo.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/misdn/portinfo.c?rev=17562&r1=17561&r2=17562&view=diff
==============================================================================
--- trunk/channels/misdn/portinfo.c (original)
+++ trunk/channels/misdn/portinfo.c Wed Apr  5 09:51:48 2006
@@ -1,6 +1,7 @@
 
 
 #include "isdn_lib.h"
+#include "isdn_lib_intern.h"
 
 
 /*



More information about the asterisk-commits mailing list