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
This commit is contained in:
Christian Richter
2006-12-18 10:19:39 +00:00
parent c3b8d9f510
commit 7716c778e4
2 changed files with 27 additions and 14 deletions

View File

@@ -2393,6 +2393,10 @@ static int dialtone_indicate(struct chan_list *cl)
const struct tone_zone_sound *ts= NULL; const struct tone_zone_sound *ts= NULL;
struct ast_channel *ast=cl->ast; 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; int nd=0;
misdn_cfg_get( cl->bc->port, MISDN_CFG_NODIALTONE, &nd, sizeof(nd)); 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) static int stop_indicate(struct chan_list *cl)
{ {
struct ast_channel *ast=cl->ast; 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"); chan_misdn_log(3,cl->bc->port," --> None\n");
misdn_lib_tone_generator_stop(cl->bc); misdn_lib_tone_generator_stop(cl->bc);
ast_playtones_stop(ast); ast_playtones_stop(ast);

View File

@@ -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); cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
dump_chan_list(stack);
if (channel >=1 ) { if (channel >=1 ) {
if (!stack->channels[channel-1]) if (!stack->channels[channel-1])
stack->channels[channel-1] = 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"); cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
break; break;
} }
} } else {
if (bc->channel >0 && bc->channel<255) { if (bc->channel >0 && bc->channel<255) {
int ret=set_chan_in_stack(stack ,bc->channel); int ret=set_chan_in_stack(stack ,bc->channel);
if (event == EVENT_SETUP && ret<0){ if (event == EVENT_SETUP && ret<0){
/* empty bchannel */ /* empty bchannel */
bc->channel=0; bc->channel=0;
bc->out_cause=44; bc->out_cause=44;
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); 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); cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
bc->l3_id=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; break;
@@ -2035,6 +2031,13 @@ handle_event_nt(void *dat, void *arg)
switch (event) { switch (event) {
case EVENT_SETUP: 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 (bc->channel>0 && bc->channel<255) {
if (stack->ptp) { if (stack->ptp) {
int ret=set_chan_in_stack(stack, bc->channel); int ret=set_chan_in_stack(stack, bc->channel);