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/branches/1.4@49313 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Christian Richter
2007-01-03 09:06:50 +00:00
parent 8332521122
commit fb52698667
8 changed files with 152 additions and 84 deletions

View File

@@ -193,6 +193,7 @@ int setup_bc(struct misdn_bchannel *bc);
int manager_isdn_handler(iframe_t *frm ,msg_t *msg);
int misdn_lib_port_restart(int port);
int misdn_lib_pid_restart(int pid);
extern struct isdn_msg msgs_g[];
@@ -447,7 +448,6 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan
if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 Dchannel ;) and work with chan preselection */
if (!stack->channels[i]) {
cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
stack->channels[i] = 1;
bc->channel=i+1;
cb_event(EVENT_NEW_CHANNEL, bc, NULL);
return i+1;
@@ -463,8 +463,8 @@ static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchan
static int empty_chan_in_stack(struct misdn_stack *stack, int channel)
{
if (channel<=0) {
cb_log(0,stack?stack->port:0, "empty_chan_inst_stack: cannot empty channel %d\n",channel);
if (channel<=0 || channel>=MAX_BCHANS) {
cb_log(0,stack?stack->port:0, "empty_chan_in_stack: cannot empty channel %d\n",channel);
return -1;
}
@@ -682,10 +682,17 @@ static int set_chan_in_stack(struct misdn_stack *stack, int channel)
{
cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
if (channel >=1 ) {
stack->channels[channel-1] = 1;
dump_chan_list(stack);
if (channel >=1 && channel <= MAX_BCHANS) {
if (!stack->channels[channel-1])
stack->channels[channel-1] = 1;
else {
cb_log(0,stack->port,"channel already in use:%d\n", channel );
return -1;
}
} else {
cb_log(0,stack->port,"couldn't set channel %d in\n", channel );
return -1;
}
return 0;
@@ -831,6 +838,8 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
if (!find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0))
return -1;
/*bc->channel=free_chan;*/
if (set_chan_in_stack(stack ,bc->channel)<0) return -1;
cb_log(4,stack->port, " --> found channel: %d\n", bc->channel);
@@ -862,6 +871,7 @@ static int create_process (int midev, struct misdn_bchannel *bc) {
return -1;
/*bc->channel=free_chan;*/
cb_log(2,stack->port, " --> found channel: %d\n", bc->channel);
if (set_chan_in_stack(stack ,bc->channel)<0) return -1;
} else {
/* other phones could have made a call also on this port (ptmp) */
bc->channel=0xff;
@@ -1494,26 +1504,26 @@ static int handle_event ( struct misdn_bchannel *bc, enum event_e event, iframe_
setup_bc(bc);
case EVENT_SETUP:
{
if (bc->channel == 0xff) {
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
break;
bc->out_cause=34;
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
return -1;
}
}
}
if (bc->channel >0 && bc->channel<255) {
set_chan_in_stack(stack ,bc->channel);
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);
return -1;
}
}
#if 0
int ret=setup_bc(bc);
if (ret == -EINVAL){
cb_log(0,bc->port,"handle_event: setup_bc failed\n");
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
}
#endif
}
break;
@@ -1795,11 +1805,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) {
if (!find_free_chan_in_stack(stack, bc, 0))
goto ERR_NO_CHANNEL;
}
}
break;
@@ -2027,32 +2032,22 @@ handle_event_nt(void *dat, void *arg)
switch (event) {
case EVENT_SETUP:
if (bc->channel>0 && bc->channel<255) {
if (bc->channel<=0 || bc->channel==0xff) {
bc->channel=find_free_chan_in_stack(stack,bc, 0);
if (bc->channel<=0)
goto ERR_NO_CHANNEL;
} else if (!stack->ptp)
cb_log(3,stack->port," --> PTMP but channel requested\n");
if (stack->ptp)
set_chan_in_stack(stack, bc->channel);
else
cb_log(3,stack->port," --> PTMP but channel requested\n");
} else {
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, " No free channel at the moment\n");
msg_t *dmsg;
cb_log(0, stack->port, "Releaseing call %x (No free Chan for you..)\n", hh->dinfo);
dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
stack->nst.manager_l3(&stack->nst, dmsg);
free_msg(msg);
return 0;
}
}
#if 0
setup_bc(bc);
#endif
int ret=set_chan_in_stack(stack, bc->channel);
if (event==EVENT_SETUP && ret<0){
/* empty bchannel */
bc->channel=0;
bc->out_cause=44;
goto ERR_NO_CHANNEL;
}
break;
case EVENT_RELEASE:
case EVENT_RELEASE_COMPLETE:
@@ -2597,7 +2592,12 @@ handle_frm_bc:
isdn_msg_parse_event(msgs_g,msg,bc, 0);
/** Preprocess some Events **/
handle_event(bc, event, frm);
int ret=handle_event(bc, event, frm);
if (ret<0) {
cb_log(0,stack->port,"couldn't handle event\n");
free_msg(msg);
return 1;
}
/* shoot up event to App: */
cb_log(5, stack->port, "lib Got Prim: Addr %x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
@@ -3227,7 +3227,13 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
if (bc->channel <=0 ) { /* else we have the channel already */
if (!find_free_chan_in_stack(stack, bc, 0)) {
cb_log(0, stack->port, " No free channel at the moment\n");
/*FIXME: add disconnect*/
err=-ENOCHAN;
goto ERR;
}
if (set_chan_in_stack(stack ,bc->channel)<0) {
/*FIXME: add disconnect*/
err=-ENOCHAN;
goto ERR;
}
@@ -3324,6 +3330,16 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
bc->need_disconnect=0;
bc->need_release=0;
bc->need_release_complete=0;
if (!stack->nt) {
/*create clenaup in TE*/
if (bc->channel>0)
empty_chan_in_stack(stack,bc->channel);
int tmpcause=bc->cause;
empty_bc(bc);
bc->cause=tmpcause;
clean_up_bc(bc);
}
break;
case EVENT_CONNECT_ACKNOWLEDGE:
@@ -3577,6 +3593,16 @@ int queue_cleanup_bc(struct misdn_bchannel *bc)
}
int misdn_lib_pid_restart(int pid)
{
struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
if (bc) {
manager_clean_bc(bc);
}
return 0;
}
int misdn_lib_port_restart(int port)
{
struct misdn_stack *stack=find_stack_by_port(port);
@@ -4074,7 +4100,7 @@ void manager_clean_bc(struct misdn_bchannel *bc )
empty_chan_in_stack(stack, bc->channel);
empty_bc(bc);
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
cb_event(EVENT_CLEANUP, bc, NULL);
}