From: Christian Richter Date: Mon, 18 Dec 2006 10:19:39 +0000 (+0000) Subject: when our PTP Partner sends us a SETUP with a preselected channel we just accept it... X-Git-Tag: 1.2.15~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7716c778e4689165ee904185b862ea23d79ef5a1;p=thirdparty%2Fasterisk.git 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@48552 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index a40735236f..65c15a1667 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -2393,6 +2393,10 @@ static int dialtone_indicate(struct chan_list *cl) const struct tone_zone_sound *ts= NULL; struct ast_channel *ast=cl->ast; + if (!ast) { + chan_misdn_log(0,cl->bc->port,"No Ast in dialtone_indicate\n"); + return -1; + } int nd=0; misdn_cfg_get( cl->bc->port, MISDN_CFG_NODIALTONE, &nd, sizeof(nd)); @@ -2426,6 +2430,12 @@ static int hanguptone_indicate(struct chan_list *cl) static int stop_indicate(struct chan_list *cl) { struct ast_channel *ast=cl->ast; + + if (!ast) { + chan_misdn_log(0,cl->bc->port,"No Ast in stop_indicate\n"); + return -1; + } + chan_misdn_log(3,cl->bc->port," --> None\n"); misdn_lib_tone_generator_stop(cl->bc); ast_playtones_stop(ast); diff --git a/channels/misdn/isdn_lib.c b/channels/misdn/isdn_lib.c index 46be979543..89cf942e49 100644 --- a/channels/misdn/isdn_lib.c +++ b/channels/misdn/isdn_lib.c @@ -666,6 +666,7 @@ int set_chan_in_stack(struct misdn_stack *stack, int channel) { cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel); + dump_chan_list(stack); if (channel >=1 ) { if (!stack->channels[channel-1]) stack->channels[channel-1] = 1; @@ -1482,15 +1483,16 @@ int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_t *frm) cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n"); break; } - } - - if (bc->channel >0 && bc->channel<255) { - int ret=set_chan_in_stack(stack ,bc->channel); - if (event == EVENT_SETUP && ret<0){ - /* empty bchannel */ - bc->channel=0; - bc->out_cause=44; - misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); + } else { + + if (bc->channel >0 && bc->channel<255) { + int ret=set_chan_in_stack(stack ,bc->channel); + if (event == EVENT_SETUP && ret<0){ + /* empty bchannel */ + bc->channel=0; + bc->out_cause=44; + misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); + } } } @@ -1802,12 +1804,6 @@ handle_event_nt(void *dat, void *arg) cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo); bc->l3_id=hh->dinfo; - if (bc->channel<=0) { - bc->channel=find_free_chan_in_stack(stack,0); - - if (bc->channel<=0) - goto ERR_NO_CHANNEL; - } } break; @@ -2035,6 +2031,13 @@ handle_event_nt(void *dat, void *arg) switch (event) { case EVENT_SETUP: + if (bc->channel<=0) { + bc->channel=find_free_chan_in_stack(stack,0); + + if (bc->channel<=0) + goto ERR_NO_CHANNEL; + } + if (bc->channel>0 && bc->channel<255) { if (stack->ptp) { int ret=set_chan_in_stack(stack, bc->channel);