aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcrichter <crichter@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-05 14:51:48 +0000
committercrichter <crichter@f38db490-d61c-443f-a65b-d21fe96a405b>2006-04-05 14:51:48 +0000
commitb441bcd68788eee7dd8031146ab88ad2ee3b73ba (patch)
tree4382736e1c240261b6c52c72fce02f055559140c
parentbdfb487b8cbcddad6b9016e0224fd6f8ad9b6c3f (diff)
* 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 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@17562 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_misdn.c22
-rw-r--r--channels/misdn/Makefile8
-rw-r--r--channels/misdn/isdn_lib.c74
-rw-r--r--channels/misdn/isdn_lib.h1
-rw-r--r--channels/misdn/isdn_msg_parser.c23
-rw-r--r--channels/misdn/portinfo.c1
6 files changed, 90 insertions, 39 deletions
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 0ab599de1..9987cbd3d 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -1687,6 +1687,12 @@ static int misdn_answer(struct ast_channel *ast)
}
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 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
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 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
}
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;
diff --git a/channels/misdn/Makefile b/channels/misdn/Makefile
index e0e63d7fe..b24159c6c 100644
--- a/channels/misdn/Makefile
+++ b/channels/misdn/Makefile
@@ -18,9 +18,13 @@ all: chan_misdn_lib.a
%.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
diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c
index e1eb61a8c..3f8dbe6b9 100644
--- a/channels/misdn/isdn_lib.c
+++ b/channels/misdn/isdn_lib.c
@@ -563,6 +563,7 @@ void empty_bc(struct misdn_bchannel *bc)
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;
@@ -1366,6 +1367,23 @@ struct misdn_bchannel *find_bc_by_addr(unsigned long addr)
}
+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 @@ void misdn_lib_log_ies(struct misdn_bchannel *bc)
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 misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
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);
+ {
+ int port=(frm->addr&MASTER_ID_MASK) >> 8;
+ int channel=(frm->addr&CHILD_ID_MASK) >> 16;
- 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);
+ 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);
- 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;
+ 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;
diff --git a/channels/misdn/isdn_lib.h b/channels/misdn/isdn_lib.h
index 1e94c7896..444ae62ff 100644
--- a/channels/misdn/isdn_lib.h
+++ b/channels/misdn/isdn_lib.h
@@ -279,6 +279,7 @@ struct misdn_bchannel {
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];
diff --git a/channels/misdn/isdn_msg_parser.c b/channels/misdn/isdn_msg_parser.c
index c22575540..9bba56c70 100644
--- a/channels/misdn/isdn_msg_parser.c
+++ b/channels/misdn/isdn_msg_parser.c
@@ -159,7 +159,7 @@ void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc,
{
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 @@ void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc,
{
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 @@ void parse_setup (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *bc,
{
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 @@ void parse_connect (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchannel *b
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);
+ 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);
+ /*
+ 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 @@ msg_t *build_connect (struct isdn_msg msgs[], struct misdn_bchannel *bc, int nt)
{
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 @@ void parse_information (struct isdn_msg msgs[], msg_t *msg, struct misdn_bchanne
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);
}
diff --git a/channels/misdn/portinfo.c b/channels/misdn/portinfo.c
index c7add95fb..bcb9f0313 100644
--- a/channels/misdn/portinfo.c
+++ b/channels/misdn/portinfo.c
@@ -1,6 +1,7 @@
#include "isdn_lib.h"
+#include "isdn_lib_intern.h"
/*