* removed unneeded bc->state field
* added statefullness for bchannel activation/deactivation * fixed a lot PCM bridging issues * some debugging logs are now on a higher loglevel git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17128 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
1b6d24a09e
commit
a096fbd87d
3 changed files with 355 additions and 127 deletions
|
@ -668,6 +668,7 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel
|
||||||
" --> bc_l3id: %x\n"
|
" --> bc_l3id: %x\n"
|
||||||
" --> display: %s\n"
|
" --> display: %s\n"
|
||||||
" --> activated: %d\n"
|
" --> activated: %d\n"
|
||||||
|
" --> state: %s\n"
|
||||||
" --> capability: %s\n"
|
" --> capability: %s\n"
|
||||||
" --> echo_cancel: %d\n"
|
" --> echo_cancel: %d\n"
|
||||||
" --> notone : rx %d tx:%d\n"
|
" --> notone : rx %d tx:%d\n"
|
||||||
|
@ -680,6 +681,7 @@ static void print_bc_info (int fd, struct chan_list* help, struct misdn_bchannel
|
||||||
bc->display,
|
bc->display,
|
||||||
|
|
||||||
bc->active,
|
bc->active,
|
||||||
|
bc_state2str(bc->bc_state),
|
||||||
bearer2str(bc->capability),
|
bearer2str(bc->capability),
|
||||||
bc->ec_enable,
|
bc->ec_enable,
|
||||||
help->norxtone,help->notxtone,
|
help->norxtone,help->notxtone,
|
||||||
|
@ -2032,6 +2034,14 @@ static struct ast_frame *misdn_read(struct ast_channel *ast)
|
||||||
|
|
||||||
len = misdn_ibuf_usedcount(tmp->bc->astbuf);
|
len = misdn_ibuf_usedcount(tmp->bc->astbuf);
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
chan_misdn_log(4,tmp->bc->port,"misdn_read: ZERO READ\n");
|
||||||
|
|
||||||
|
tmp->frame.frametype = AST_FRAME_NULL;
|
||||||
|
tmp->frame.subclass = 0;
|
||||||
|
return &tmp->frame;
|
||||||
|
}
|
||||||
|
|
||||||
/*shrinken len if necessary, we transmit at maximum 4k*/
|
/*shrinken len if necessary, we transmit at maximum 4k*/
|
||||||
len = len<=sizeof(tmp->ast_rd_buf)?len:sizeof(tmp->ast_rd_buf);
|
len = len<=sizeof(tmp->ast_rd_buf)?len:sizeof(tmp->ast_rd_buf);
|
||||||
|
|
||||||
|
@ -2080,7 +2090,7 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
|
||||||
|
|
||||||
|
|
||||||
if ( !frame->subclass) {
|
if ( !frame->subclass) {
|
||||||
chan_misdn_log(2, ch->bc->port, "misdn_write: * prods us\n");
|
chan_misdn_log(4, ch->bc->port, "misdn_write: * prods us\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2091,6 +2101,16 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( !frame->samples ) {
|
||||||
|
chan_misdn_log(4, ch->bc->port, "misdn_write: zero write\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! ch->bc->addr ) {
|
||||||
|
chan_misdn_log(4, ch->bc->port, "misdn_write: no addr for bc dropping:%d\n", frame->samples);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if MISDN_DEBUG
|
#if MISDN_DEBUG
|
||||||
{
|
{
|
||||||
int i, max=5>frame->samples?frame->samples:5;
|
int i, max=5>frame->samples?frame->samples:5;
|
||||||
|
@ -2103,8 +2123,12 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (!ch->bc->active) {
|
switch (ch->bc->bc_state) {
|
||||||
chan_misdn_log(5, ch->bc->port, "BC not active droping: %d frames\n",frame->samples);
|
case BCHAN_ACTIVATED:
|
||||||
|
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);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2166,13 +2190,13 @@ enum ast_bridge_result misdn_bridge (struct ast_channel *c0,
|
||||||
if ( !ecwb ) {
|
if ( !ecwb ) {
|
||||||
chan_misdn_log(2, ch1->bc->port, "Disabling Echo Cancellor when Bridged\n");
|
chan_misdn_log(2, ch1->bc->port, "Disabling Echo Cancellor when Bridged\n");
|
||||||
ch1->bc->ec_enable=0;
|
ch1->bc->ec_enable=0;
|
||||||
manager_ec_disable(ch1->bc);
|
/* manager_ec_disable(ch1->bc); */
|
||||||
}
|
}
|
||||||
misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
|
misdn_cfg_get( ch2->bc->port, MISDN_CFG_ECHOCANCELWHENBRIDGED, &ecwb, sizeof(int));
|
||||||
if ( !ecwb ) {
|
if ( !ecwb ) {
|
||||||
chan_misdn_log(2, ch2->bc->port, "Disabling Echo Cancellor when Bridged\n");
|
chan_misdn_log(2, ch2->bc->port, "Disabling Echo Cancellor when Bridged\n");
|
||||||
ch2->bc->ec_enable=0;
|
ch2->bc->ec_enable=0;
|
||||||
manager_ec_disable(ch2->bc);
|
/* manager_ec_disable(ch2->bc); */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* trying to make a mISDN_dsp conference */
|
/* trying to make a mISDN_dsp conference */
|
||||||
|
@ -2707,7 +2731,7 @@ static struct chan_list *find_chan_by_l3id(struct chan_list *list, unsigned long
|
||||||
if (help->l3id == l3id ) return help;
|
if (help->l3id == l3id ) return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan_misdn_log(4, list? (list->bc? list->bc->port : 0) : 0, "$$$ find_chan: No channel found with l3id:%x\n",l3id);
|
chan_misdn_log(6, list? (list->bc? list->bc->port : 0) : 0, "$$$ find_chan: No channel found with l3id:%x\n",l3id);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2719,7 +2743,7 @@ static struct chan_list *find_chan_by_bc(struct chan_list *list, struct misdn_bc
|
||||||
if (help->bc == bc) return help;
|
if (help->bc == bc) return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan_misdn_log(4, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n",bc->oad,bc->dad);
|
chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n",bc->oad,bc->dad);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2729,14 +2753,14 @@ static struct chan_list *find_holded(struct chan_list *list, struct misdn_bchann
|
||||||
{
|
{
|
||||||
struct chan_list *help=list;
|
struct chan_list *help=list;
|
||||||
|
|
||||||
chan_misdn_log(4, bc->port, "$$$ find_holded: channel:%d oad:%s dad:%s\n",bc->channel, bc->oad,bc->dad);
|
chan_misdn_log(6, bc->port, "$$$ find_holded: channel:%d oad:%s dad:%s\n",bc->channel, bc->oad,bc->dad);
|
||||||
for (;help; help=help->next) {
|
for (;help; help=help->next) {
|
||||||
chan_misdn_log(4, bc->port, "$$$ find_holded: --> holded:%d channel:%d\n",help->bc->holded, help->bc->channel);
|
chan_misdn_log(4, bc->port, "$$$ find_holded: --> holded:%d channel:%d\n",help->bc->holded, help->bc->channel);
|
||||||
if (help->bc->port == bc->port
|
if (help->bc->port == bc->port
|
||||||
&& help->bc->holded ) return help;
|
&& help->bc->holded ) return help;
|
||||||
}
|
}
|
||||||
|
|
||||||
chan_misdn_log(4, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n",bc->oad,bc->dad);
|
chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n",bc->oad,bc->dad);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -3068,6 +3092,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
||||||
if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /* Debug Only Non-Bchan */
|
if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /* Debug Only Non-Bchan */
|
||||||
chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad);
|
chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad);
|
||||||
misdn_lib_log_ies(bc);
|
misdn_lib_log_ies(bc);
|
||||||
|
chan_misdn_log(2,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event != EVENT_SETUP) {
|
if (event != EVENT_SETUP) {
|
||||||
|
@ -3468,8 +3493,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
||||||
misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
|
misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
|
||||||
case EVENT_CONNECT_ACKNOWLEDGE:
|
case EVENT_CONNECT_ACKNOWLEDGE:
|
||||||
{
|
{
|
||||||
bc->state=STATE_CONNECTED;
|
|
||||||
|
|
||||||
ch->l3id=bc->l3_id;
|
ch->l3id=bc->l3_id;
|
||||||
ch->addr=bc->addr;
|
ch->addr=bc->addr;
|
||||||
|
|
||||||
|
@ -3593,7 +3616,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
||||||
int len=bc->bframe_len;
|
int len=bc->bframe_len;
|
||||||
int free=misdn_ibuf_freecount(bc->astbuf);
|
int free=misdn_ibuf_freecount(bc->astbuf);
|
||||||
|
|
||||||
|
|
||||||
if (bc->bframe_len > free) {
|
if (bc->bframe_len > free) {
|
||||||
ast_log(LOG_DEBUG, "sbuf overflow!\n");
|
ast_log(LOG_DEBUG, "sbuf overflow!\n");
|
||||||
len=misdn_ibuf_freecount(bc->astbuf);
|
len=misdn_ibuf_freecount(bc->astbuf);
|
||||||
|
@ -3693,13 +3715,17 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
|
||||||
|
|
||||||
if (AST_BRIDGED_P(ch->ast)){
|
if (bridged){
|
||||||
|
struct chan_list *bridged_ch=MISDN_ASTERISK_TECH_PVT(bridged);
|
||||||
ch->state = MISDN_HOLDED;
|
ch->state = MISDN_HOLDED;
|
||||||
ch->l3id = bc->l3_id;
|
ch->l3id = bc->l3_id;
|
||||||
|
|
||||||
ast_moh_start(AST_BRIDGED_P(ch->ast), NULL);
|
bc->holded_bc=bridged_ch->bc;
|
||||||
misdn_lib_send_event(bc, EVENT_HOLD_ACKNOWLEDGE);
|
misdn_lib_send_event(bc, EVENT_HOLD_ACKNOWLEDGE);
|
||||||
|
|
||||||
|
ast_moh_start(bridged, NULL);
|
||||||
} else {
|
} else {
|
||||||
misdn_lib_send_event(bc, EVENT_HOLD_REJECT);
|
misdn_lib_send_event(bc, EVENT_HOLD_REJECT);
|
||||||
chan_misdn_log(0, bc->port, "We aren't bridged to anybody\n");
|
chan_misdn_log(0, bc->port, "We aren't bridged to anybody\n");
|
||||||
|
@ -3729,11 +3755,15 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
chan_misdn_log(1,bc->port," --> not yet handled\n");
|
chan_misdn_log(1, bc->port," --> not yet handled\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case EVENT_RESTART:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ast_log(LOG_WARNING, "Got Unknown Event\n");
|
ast_log(LOG_WARNING, "Got Unknown Event\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
#include "isdn_lib_intern.h"
|
#include "isdn_lib_intern.h"
|
||||||
#include <mISDNuser/isdn_debug.h>
|
#include <mISDNuser/isdn_debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
void misdn_join_conf(struct misdn_bchannel *bc, int conf_id);
|
||||||
|
void misdn_split_conf(struct misdn_bchannel *bc, int conf_id);
|
||||||
|
|
||||||
|
|
||||||
void misdn_free_ibuffer(void *ibuf)
|
void misdn_free_ibuffer(void *ibuf)
|
||||||
{
|
{
|
||||||
free_ibuffer((ibuffer_t*)ibuf);
|
free_ibuffer((ibuffer_t*)ibuf);
|
||||||
|
@ -389,7 +394,7 @@ void dump_chan_list(struct misdn_stack *stack)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i <stack->b_num; i++) {
|
for (i=0; i <stack->b_num; i++) {
|
||||||
cb_log(5, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
|
cb_log(8, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,16 +436,72 @@ int empty_chan_in_stack(struct misdn_stack *stack, int channel)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *bc_state2str(enum bchannel_state state) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
struct bchan_state_s {
|
||||||
|
char *n;
|
||||||
|
enum bchannel_state s;
|
||||||
|
} states[] = {
|
||||||
|
{"BCHAN_CLEANED", BCHAN_CLEANED },
|
||||||
|
{"BCHAN_EMPTY", BCHAN_EMPTY},
|
||||||
|
{"BCHAN_SETUP", BCHAN_SETUP},
|
||||||
|
{"BCHAN_SETUPED", BCHAN_SETUPED},
|
||||||
|
{"BCHAN_ACTIVE", BCHAN_ACTIVE},
|
||||||
|
{"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
|
||||||
|
{"BCHAN_BRIDGE", BCHAN_BRIDGE},
|
||||||
|
{"BCHAN_BRIDGED", BCHAN_BRIDGED},
|
||||||
|
{"BCHAN_RELEASE", BCHAN_RELEASE},
|
||||||
|
{"BCHAN_RELEASED", BCHAN_RELEASED},
|
||||||
|
{"BCHAN_CLEAN", BCHAN_CLEAN},
|
||||||
|
{"BCHAN_ERROR", BCHAN_ERROR}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
|
||||||
|
if ( states[i].s == state)
|
||||||
|
return states[i].n;
|
||||||
|
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
|
||||||
|
void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
|
||||||
|
{
|
||||||
|
cb_log(3,bc->port,"BC_STATE_CHANGE: from:%s to:%s\n",
|
||||||
|
bc_state2str(bc->bc_state),
|
||||||
|
bc_state2str(state) );
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case BCHAN_ACTIVATED:
|
||||||
|
if (bc->next_bc_state == BCHAN_BRIDGED) {
|
||||||
|
misdn_join_conf(bc, bc->conf_id);
|
||||||
|
bc->next_bc_state = BCHAN_EMPTY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
bc->bc_state=state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bc_next_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
|
||||||
|
{
|
||||||
|
cb_log(3,bc->port,"BC_NEXT_STATE_CHANGE: from:%s to:%s\n",
|
||||||
|
bc_state2str(bc->next_bc_state),
|
||||||
|
bc_state2str(state) );
|
||||||
|
|
||||||
|
bc->next_bc_state=state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void empty_bc(struct misdn_bchannel *bc)
|
void empty_bc(struct misdn_bchannel *bc)
|
||||||
{
|
{
|
||||||
bc->bframe_len=0;
|
bc->bframe_len=0;
|
||||||
|
|
||||||
bc->state=STATE_NOTHING;
|
|
||||||
|
|
||||||
bc->channel = 0;
|
bc->channel = 0;
|
||||||
bc->in_use = 0;
|
bc->in_use = 0;
|
||||||
|
|
||||||
|
bc->conf_id = 0;
|
||||||
|
|
||||||
bc->need_more_infos = 0;
|
bc->need_more_infos = 0;
|
||||||
|
|
||||||
bc->send_dtmf=0;
|
bc->send_dtmf=0;
|
||||||
|
@ -510,6 +571,11 @@ void empty_bc(struct misdn_bchannel *bc)
|
||||||
bc->fac_type=FACILITY_NONE;
|
bc->fac_type=FACILITY_NONE;
|
||||||
|
|
||||||
bc->te_choose_channel = 0;
|
bc->te_choose_channel = 0;
|
||||||
|
|
||||||
|
bc->holded_bc=NULL;
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_EMPTY);
|
||||||
|
bc_next_state_change(bc,BCHAN_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -519,42 +585,43 @@ int clean_up_bc(struct misdn_bchannel *bc)
|
||||||
unsigned char buff[32];
|
unsigned char buff[32];
|
||||||
struct misdn_stack * stack;
|
struct misdn_stack * stack;
|
||||||
|
|
||||||
|
cb_log(2, 0, "$$$ CLEANUP CALLED\n");
|
||||||
|
|
||||||
if (!bc ) return -1;
|
if (!bc ) return -1;
|
||||||
stack=get_stack_by_bc(bc);
|
stack=get_stack_by_bc(bc);
|
||||||
|
|
||||||
if (!stack) return -1;
|
if (!stack) return -1;
|
||||||
|
|
||||||
if (!bc->upset) {
|
switch (bc->bc_state ) {
|
||||||
|
|
||||||
|
case BCHAN_CLEANED:
|
||||||
cb_log(5, stack->port, "$$$ Already cleaned up bc with stid :%x\n", bc->b_stid);
|
cb_log(5, stack->port, "$$$ Already cleaned up bc with stid :%x\n", bc->b_stid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (bc->active) {
|
case BCHAN_ACTIVATED:
|
||||||
cb_log(2, stack->port, "$$$ bc still active, deactivatiing .. stid :%x\n", bc->b_stid);
|
cb_log(2, stack->port, "$$$ bc still active, deactivatiing .. stid :%x\n", bc->b_stid);
|
||||||
manager_bchannel_deactivate(bc);
|
manager_bchannel_deactivate(bc);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCHAN_BRIDGED:
|
||||||
|
cb_log(2, stack->port, "$$$ bc still bridged\n");
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_log(5, stack->port, "$$$ Cleaning up bc with stid :%x\n", bc->b_stid);
|
cb_log(5, stack->port, "$$$ Cleaning up bc with stid :%x\n", bc->b_stid);
|
||||||
|
|
||||||
|
|
||||||
if ( misdn_cap_is_speech(bc->capability) && bc->ec_enable) {
|
if ( misdn_cap_is_speech(bc->capability) && bc->ec_enable) {
|
||||||
manager_ec_disable(bc);
|
manager_ec_disable(bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cb_log(2, stack->port, "$$$ CLEARING STACK\n");
|
||||||
|
/*mISDN_clear_stack(stack->midev,bc->b_stid);*/
|
||||||
|
|
||||||
mISDN_write_frame(stack->midev, buff, bc->addr|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
|
mISDN_write_frame(stack->midev, buff, bc->addr|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
|
||||||
|
|
||||||
|
|
||||||
#ifdef ACK_HDLC
|
|
||||||
if (bc->ack_hdlc ) {
|
|
||||||
free(bc->ack_hdlc);
|
|
||||||
bc->ack_hdlc=NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bc->b_stid = 0;
|
bc->b_stid = 0;
|
||||||
|
bc_state_change(bc, BCHAN_CLEANED);
|
||||||
bc->upset=0;
|
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -818,14 +885,9 @@ int setup_bc(struct misdn_bchannel *bc)
|
||||||
int channel=bc->channel-1-(bc->channel>16);
|
int channel=bc->channel-1-(bc->channel>16);
|
||||||
int b_stid=stack->b_stids[channel>=0?channel:0];
|
int b_stid=stack->b_stids[channel>=0?channel:0];
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (bc->hdlc) {
|
|
||||||
clean_up_bc(bc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (bc->upset) {
|
if ( bc->bc_state != BCHAN_CLEANED) {
|
||||||
cb_log(4, stack->port, "$$$ bc already upsetted stid :%x\n", b_stid);
|
cb_log(4, stack->port, "$$$ bc already upsetted stid :%x (state:%s)\n", b_stid, bc_state2str(bc->bc_state) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,6 +896,7 @@ int setup_bc(struct misdn_bchannel *bc)
|
||||||
if (b_stid <= 0) {
|
if (b_stid <= 0) {
|
||||||
cb_log(-1, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);
|
cb_log(-1, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_ERROR);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,6 +946,7 @@ int setup_bc(struct misdn_bchannel *bc)
|
||||||
if (ret ) {
|
if (ret ) {
|
||||||
cb_log(-1, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno));
|
cb_log(-1, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno));
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_ERROR);
|
||||||
return(-EINVAL);
|
return(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,25 +994,18 @@ int setup_bc(struct misdn_bchannel *bc)
|
||||||
cb_log(5, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
|
cb_log(5, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
|
||||||
|
|
||||||
mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
|
mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_ERROR);
|
||||||
return(-EINVAL);
|
return(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
ret = mISDN_get_setstack_ind(midev, bc->layer_id );
|
|
||||||
|
|
||||||
if (ret){
|
bc_state_change(bc,BCHAN_SETUP);
|
||||||
cb_log(5, stack->port,"$$$ Get Set Stack Err: %d %s\n",ret,strerror(errno));
|
|
||||||
|
|
||||||
mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
|
|
||||||
return(-EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bc->upset=1;
|
/*manager_bchannel_deactivate(bc);*/
|
||||||
|
|
||||||
|
|
||||||
manager_bchannel_deactivate(bc);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -975,7 +1032,8 @@ int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int midev, in
|
||||||
|
|
||||||
|
|
||||||
empty_bc(bc);
|
empty_bc(bc);
|
||||||
bc->upset=0;
|
bc_state_change(bc, BCHAN_CLEANED);
|
||||||
|
|
||||||
bc->port=stack->port;
|
bc->port=stack->port;
|
||||||
bc->nt=stack->nt?1:0;
|
bc->nt=stack->nt?1:0;
|
||||||
|
|
||||||
|
@ -1378,7 +1436,7 @@ int handle_new_process(struct misdn_stack *stack, iframe_t *frm)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_log(4, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo);
|
cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo);
|
||||||
bc->l3_id=frm->dinfo;
|
bc->l3_id=frm->dinfo;
|
||||||
|
|
||||||
if (mypid>5000) mypid=0;
|
if (mypid>5000) mypid=0;
|
||||||
|
@ -1392,7 +1450,7 @@ int handle_cr ( struct misdn_stack *stack, iframe_t *frm)
|
||||||
|
|
||||||
switch (frm->prim) {
|
switch (frm->prim) {
|
||||||
case CC_NEW_CR|INDICATION:
|
case CC_NEW_CR|INDICATION:
|
||||||
cb_log(4, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
|
cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
|
||||||
handle_new_process(stack, frm);
|
handle_new_process(stack, frm);
|
||||||
return 1;
|
return 1;
|
||||||
case CC_NEW_CR|CONFIRM:
|
case CC_NEW_CR|CONFIRM:
|
||||||
|
@ -1721,16 +1779,8 @@ handle_event_nt(void *dat, void *arg)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CC_RELEASE|CONFIRM:
|
case CC_RELEASE|CONFIRM:
|
||||||
{
|
break;
|
||||||
/*struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
|
|
||||||
cb_log(3, stack->port, " --> RELEASE CONFIRM, doing nothin\n");
|
|
||||||
cb_event(EVENT_CLEANUP, bc, glob_mgr->user_data);
|
|
||||||
empty_chan_in_stack(stack,bc->channel);
|
|
||||||
empty_bc(bc);
|
|
||||||
free_msg(msg);
|
|
||||||
return 0;*/
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CC_RELEASE|INDICATION:
|
case CC_RELEASE|INDICATION:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1991,10 +2041,14 @@ int handle_bchan(msg_t *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (frm->prim) {
|
switch (frm->prim) {
|
||||||
|
|
||||||
|
case MGR_SETSTACK| CONFIRM:
|
||||||
|
cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|CONFIRM \n");
|
||||||
|
break;
|
||||||
|
|
||||||
case MGR_SETSTACK| INDICATION:
|
case MGR_SETSTACK| INDICATION:
|
||||||
cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|IND \n");
|
cb_log(2, stack->port, "BCHAN: MGR_SETSTACK|IND \n");
|
||||||
|
|
||||||
|
|
||||||
bc->addr = mISDN_get_layerid(stack->midev, bc->b_stid, bc->layer);
|
bc->addr = mISDN_get_layerid(stack->midev, bc->b_stid, bc->layer);
|
||||||
if (!bc->addr) {
|
if (!bc->addr) {
|
||||||
cb_log(0,stack->port,"$$$ Get Layer (%d) Id Error: %s\n",bc->layer,strerror(errno));
|
cb_log(0,stack->port,"$$$ Get Layer (%d) Id Error: %s\n",bc->layer,strerror(errno));
|
||||||
|
@ -2006,27 +2060,45 @@ int handle_bchan(msg_t *msg)
|
||||||
|
|
||||||
cb_log(4, stack->port," --> Got Adr %x\n", bc->addr);
|
cb_log(4, stack->port," --> Got Adr %x\n", bc->addr);
|
||||||
|
|
||||||
bc->upset=2;
|
|
||||||
|
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
|
|
||||||
|
if (bc->bc_state != BCHAN_SETUP) {
|
||||||
|
cb_log(4, stack->port," --> STATE WASN'T SETUP in SETSTACK|IND\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_SETUPED);
|
||||||
|
|
||||||
|
|
||||||
manager_bchannel_activate(bc);
|
manager_bchannel_activate(bc);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case MGR_DELLAYER| INDICATION:
|
||||||
|
cb_log(2, stack->port, "BCHAN: MGR_DELLAYER|IND\n");
|
||||||
|
break;
|
||||||
|
|
||||||
case MGR_DELLAYER| CONFIRM:
|
case MGR_DELLAYER| CONFIRM:
|
||||||
cb_log(2, stack->port, "BCHAN: MGR_DELLAYER|CNF \n");
|
cb_log(2, stack->port, "BCHAN: MGR_DELLAYER|CNF \n");
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_CLEANED);
|
||||||
|
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case PH_ACTIVATE | INDICATION:
|
case PH_ACTIVATE | INDICATION:
|
||||||
case DL_ESTABLISH | INDICATION:
|
case DL_ESTABLISH | INDICATION:
|
||||||
cb_log(4, stack->port, "BCHAN: ACT Ind\n");
|
cb_log(4, stack->port, "BCHAN: ACT Ind\n");
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_ACTIVATED);
|
||||||
|
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case PH_ACTIVATE | CONFIRM:
|
case PH_ACTIVATE | CONFIRM:
|
||||||
case DL_ESTABLISH | CONFIRM:
|
case DL_ESTABLISH | CONFIRM:
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_ACTIVATED);
|
||||||
|
|
||||||
cb_log(4, stack->port, "BCHAN: bchan ACT Confirm\n");
|
cb_log(4, stack->port, "BCHAN: bchan ACT Confirm\n");
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
|
|
||||||
|
@ -2035,12 +2107,16 @@ int handle_bchan(msg_t *msg)
|
||||||
case PH_DEACTIVATE | INDICATION:
|
case PH_DEACTIVATE | INDICATION:
|
||||||
case DL_RELEASE | INDICATION:
|
case DL_RELEASE | INDICATION:
|
||||||
cb_log (4, stack->port, "BCHAN: DeACT Ind\n");
|
cb_log (4, stack->port, "BCHAN: DeACT Ind\n");
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_RELEASED);
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case PH_DEACTIVATE | CONFIRM:
|
case PH_DEACTIVATE | CONFIRM:
|
||||||
case DL_RELEASE | CONFIRM:
|
case DL_RELEASE | CONFIRM:
|
||||||
cb_log(4, stack->port, "BCHAN: DeACT Conf\n");
|
cb_log(4, stack->port, "BCHAN: DeACT Conf\n");
|
||||||
|
|
||||||
|
bc_state_change(bc,BCHAN_RELEASED);
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -2091,12 +2167,24 @@ int handle_bchan(msg_t *msg)
|
||||||
flip_buf_bits(bc->bframe, bc->bframe_len);
|
flip_buf_bits(bc->bframe, bc->bframe_len);
|
||||||
|
|
||||||
|
|
||||||
|
if (!bc->bframe_len) {
|
||||||
|
cb_log(2, stack->port, "DL_DATA INDICATION bc->addr:%x frm->addr:%x\n", bc->addr, frm->addr);
|
||||||
|
free_msg(msg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (bc->addr&STACK_ID_MASK) != (frm->addr&STACK_ID_MASK) ) {
|
||||||
|
cb_log(2, stack->port, "DL_DATA INDICATION bc->addr:%x frm->addr:%x\n", bc->addr, frm->addr);
|
||||||
|
free_msg(msg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#if MISDN_DEBUG
|
#if MISDN_DEBUG
|
||||||
cb_log(-1, stack->port, "DL_DATA INDICATION Len %d\n", frm->len);
|
cb_log(-1, stack->port, "DL_DATA INDICATION Len %d\n", frm->len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bc->active && frm->len > 0) {
|
if ( (bc->bc_state == BCHAN_ACTIVATED) && frm->len > 0) {
|
||||||
if ( !do_tone(bc, frm->len) ) {
|
if ( !do_tone(bc, frm->len) ) {
|
||||||
|
|
||||||
if ( misdn_cap_is_speech(bc->capability)) {
|
if ( misdn_cap_is_speech(bc->capability)) {
|
||||||
|
@ -2107,7 +2195,7 @@ int handle_bchan(msg_t *msg)
|
||||||
|
|
||||||
int i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
|
int i=cb_event( EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
|
||||||
if (i<0) {
|
if (i<0) {
|
||||||
cb_log(5,stack->port,"cb_event returned <0\n");
|
cb_log(10,stack->port,"cb_event returned <0\n");
|
||||||
/*clean_up_bc(bc);*/
|
/*clean_up_bc(bc);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2116,6 +2204,12 @@ int handle_bchan(msg_t *msg)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case PH_CONTROL | CONFIRM:
|
||||||
|
cb_log(2, stack->port, "PH_CONTROL|CNF bc->addr:%x\n", frm->addr);
|
||||||
|
free_msg(msg);
|
||||||
|
return 1;
|
||||||
|
|
||||||
case PH_DATA | CONFIRM:
|
case PH_DATA | CONFIRM:
|
||||||
case DL_DATA|CONFIRM:
|
case DL_DATA|CONFIRM:
|
||||||
#if MISDN_DEBUG
|
#if MISDN_DEBUG
|
||||||
|
@ -2125,12 +2219,6 @@ int handle_bchan(msg_t *msg)
|
||||||
#endif
|
#endif
|
||||||
free_msg(msg);
|
free_msg(msg);
|
||||||
|
|
||||||
#ifdef ACK_HDLC
|
|
||||||
if (bc->hdlc) {
|
|
||||||
cb_log(4,stack->port,"Acknowledge Packet\n");
|
|
||||||
sem_post( (sem_t*)bc->ack_hdlc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
case DL_DATA|RESPONSE:
|
case DL_DATA|RESPONSE:
|
||||||
#if MISDN_DEBUG
|
#if MISDN_DEBUG
|
||||||
|
@ -2385,6 +2473,13 @@ int handle_mgmt(msg_t *msg)
|
||||||
struct misdn_stack * stack=find_stack_by_addr(frm->addr);
|
struct misdn_stack * stack=find_stack_by_addr(frm->addr);
|
||||||
|
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
|
if (frm->prim == (MGR_DELLAYER|CONFIRM)) {
|
||||||
|
cb_log(2, 0, "MGMT: DELLAYER|CONFIRM Addr: %x !\n",
|
||||||
|
frm->addr) ;
|
||||||
|
free(msg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2707,6 +2802,7 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_log(1, stack->port, "I SEND:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad);
|
cb_log(1, stack->port, "I SEND:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad);
|
||||||
|
cb_log(1, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
|
||||||
misdn_lib_log_ies(bc);
|
misdn_lib_log_ies(bc);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
@ -2782,14 +2878,22 @@ int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event )
|
||||||
stack_holder_add(stack,holded_bc);
|
stack_holder_add(stack,holded_bc);
|
||||||
|
|
||||||
if (stack->nt) {
|
if (stack->nt) {
|
||||||
|
if (bc->bc_state == BCHAN_BRIDGED) {
|
||||||
|
misdn_split_conf(bc,bc->conf_id);
|
||||||
|
misdn_split_conf(bc->holded_bc,bc->holded_bc->conf_id);
|
||||||
|
/*bc_state_change(bc,BCHAN_SETUPED);
|
||||||
|
manager_bchannel_activate(bc);*/
|
||||||
|
}
|
||||||
|
|
||||||
empty_chan_in_stack(stack,bc->channel);
|
empty_chan_in_stack(stack,bc->channel);
|
||||||
empty_bc(bc);
|
empty_bc(bc);
|
||||||
clean_up_bc(bc);
|
clean_up_bc(bc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** we set it up later at RETRIEVE_ACK again.**/
|
/** we set it up later at RETRIEVE_ACK again.**/
|
||||||
holded_bc->upset=0;
|
/*holded_bc->upset=0;
|
||||||
holded_bc->active=0;
|
holded_bc->active=0;*/
|
||||||
|
bc_state_change(holded_bc,BCHAN_CLEANED);
|
||||||
|
|
||||||
cb_event( EVENT_NEW_BC, holded_bc, glob_mgr->user_data);
|
cb_event( EVENT_NEW_BC, holded_bc, glob_mgr->user_data);
|
||||||
}
|
}
|
||||||
|
@ -3227,18 +3331,25 @@ void manager_bchannel_activate(struct misdn_bchannel *bc)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bc->upset != 2 ) {
|
|
||||||
cb_log(1, stack->port, "bchannel_activate: BC Not properly upsetted addr:%x\n", bc->addr);
|
switch (bc->bc_state) {
|
||||||
|
|
||||||
|
case BCHAN_SETUPED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cb_log(1, stack->port, "bchannel_activate: BC Not properly upsetted (state:%s) addr:%x\n", bc_state2str(bc->bc_state), bc->addr);
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frm=(iframe_t*)msg->data;
|
frm=(iframe_t*)msg->data;
|
||||||
/* we must activate if we are deactivated */
|
/* we must activate if we are deactivated */
|
||||||
clear_ibuffer(bc->astbuf);
|
clear_ibuffer(bc->astbuf);
|
||||||
|
|
||||||
if (bc->active) return;
|
|
||||||
|
|
||||||
cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
|
cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
|
||||||
|
|
||||||
/* activate bchannel */
|
/* activate bchannel */
|
||||||
|
@ -3250,7 +3361,7 @@ void manager_bchannel_activate(struct misdn_bchannel *bc)
|
||||||
msg_queue_tail(&glob_mgr->activatequeue, msg);
|
msg_queue_tail(&glob_mgr->activatequeue, msg);
|
||||||
sem_post(&glob_mgr->new_msg);
|
sem_post(&glob_mgr->new_msg);
|
||||||
|
|
||||||
bc->active=1;
|
bc_state_change(bc, BCHAN_ACTIVE);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
@ -3262,7 +3373,19 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc)
|
||||||
iframe_t dact;
|
iframe_t dact;
|
||||||
|
|
||||||
struct misdn_stack *stack=get_stack_by_bc(bc);
|
struct misdn_stack *stack=get_stack_by_bc(bc);
|
||||||
if (!bc->active) return;
|
|
||||||
|
|
||||||
|
switch (bc->bc_state) {
|
||||||
|
case BCHAN_ACTIVATED:
|
||||||
|
break;
|
||||||
|
case BCHAN_BRIDGED:
|
||||||
|
misdn_split_conf(bc,bc->conf_id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
|
||||||
|
return ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
|
cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
|
||||||
|
|
||||||
|
@ -3275,7 +3398,8 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc)
|
||||||
|
|
||||||
mISDN_write(stack->midev, &dact, mISDN_HEADER_LEN+dact.len, TIMEOUT_1SEC);
|
mISDN_write(stack->midev, &dact, mISDN_HEADER_LEN+dact.len, TIMEOUT_1SEC);
|
||||||
clear_ibuffer(bc->astbuf);
|
clear_ibuffer(bc->astbuf);
|
||||||
bc->active=0;
|
|
||||||
|
bc_state_change(bc,BCHAN_RELEASE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3284,7 +3408,15 @@ void manager_bchannel_deactivate(struct misdn_bchannel * bc)
|
||||||
int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len)
|
int misdn_lib_tx2misdn_frm(struct misdn_bchannel *bc, void *data, int len)
|
||||||
{
|
{
|
||||||
struct misdn_stack *stack=get_stack_by_bc(bc);
|
struct misdn_stack *stack=get_stack_by_bc(bc);
|
||||||
if (!bc->active) return -1;
|
|
||||||
|
switch (bc->bc_state) {
|
||||||
|
case BCHAN_ACTIVATED:
|
||||||
|
case BCHAN_BRIDGED:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
char buf[4096 + mISDN_HEADER_LEN];
|
char buf[4096 + mISDN_HEADER_LEN];
|
||||||
iframe_t *frm= (iframe_t*)buf;
|
iframe_t *frm= (iframe_t*)buf;
|
||||||
|
@ -3359,9 +3491,6 @@ void manager_clean_bc(struct misdn_bchannel *bc )
|
||||||
{
|
{
|
||||||
struct misdn_stack *stack=get_stack_by_bc(bc);
|
struct misdn_stack *stack=get_stack_by_bc(bc);
|
||||||
|
|
||||||
if (bc->state == STATE_CONNECTED)
|
|
||||||
misdn_lib_send_event(bc,EVENT_DISCONNECT);
|
|
||||||
|
|
||||||
empty_chan_in_stack(stack, bc->channel);
|
empty_chan_in_stack(stack, bc->channel);
|
||||||
empty_bc(bc);
|
empty_bc(bc);
|
||||||
|
|
||||||
|
@ -3491,21 +3620,72 @@ struct misdn_stack* get_misdn_stack() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2) {
|
void misdn_join_conf(struct misdn_bchannel *bc, int conf_id)
|
||||||
manager_ph_control(bc1, CMX_RECEIVE_OFF, 0);
|
{
|
||||||
manager_ph_control(bc2, CMX_RECEIVE_OFF, 0);
|
bc_state_change(bc,BCHAN_BRIDGED);
|
||||||
|
manager_ph_control(bc, CMX_RECEIVE_OFF, 0);
|
||||||
|
manager_ph_control(bc, CMX_CONF_JOIN, conf_id);
|
||||||
|
|
||||||
manager_ph_control(bc1, CMX_CONF_JOIN, (bc1->pid<<1) +1);
|
cb_log(1,bc->port, "Joining bc:%x in conf:%d\n",bc->addr,conf_id);
|
||||||
manager_ph_control(bc2, CMX_CONF_JOIN, (bc1->pid<<1) +1);
|
|
||||||
|
char data[16];
|
||||||
|
int len=15;
|
||||||
|
|
||||||
|
memset(data,0,15);
|
||||||
|
|
||||||
|
misdn_lib_tx2misdn_frm(bc, data, len);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void misdn_split_conf(struct misdn_bchannel *bc, int conf_id)
|
||||||
|
{
|
||||||
|
bc_state_change(bc,BCHAN_ACTIVATED);
|
||||||
|
manager_ph_control(bc, CMX_RECEIVE_ON, 0);
|
||||||
|
manager_ph_control(bc, CMX_CONF_SPLIT, conf_id);
|
||||||
|
|
||||||
|
cb_log(1,bc->port, "Splitting bc:%x in conf:%d\n",bc->addr,conf_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void misdn_lib_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2) {
|
||||||
|
int conf_id=(bc1->pid<<1) +1;
|
||||||
|
|
||||||
|
cb_log(1, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
|
||||||
|
|
||||||
|
struct misdn_bchannel *bc_list[]={
|
||||||
|
bc1,bc2,NULL
|
||||||
|
};
|
||||||
|
struct misdn_bchannel **bc;
|
||||||
|
|
||||||
|
for (bc=bc_list; *bc; *bc++) {
|
||||||
|
(*bc)->conf_id=conf_id;
|
||||||
|
cb_log(1, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
|
||||||
|
|
||||||
|
switch((*bc)->bc_state) {
|
||||||
|
case BCHAN_ACTIVATED:
|
||||||
|
misdn_join_conf(*bc,conf_id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bc_next_state_change(*bc,BCHAN_BRIDGED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2)
|
void misdn_lib_split_bridge( struct misdn_bchannel * bc1, struct misdn_bchannel *bc2)
|
||||||
{
|
{
|
||||||
|
|
||||||
manager_ph_control(bc1, CMX_RECEIVE_ON, 0) ;
|
struct misdn_bchannel *bc_list[]={
|
||||||
manager_ph_control(bc2, CMX_RECEIVE_ON, 0);
|
bc1,bc2,NULL
|
||||||
|
};
|
||||||
|
struct misdn_bchannel **bc;
|
||||||
|
|
||||||
manager_ph_control(bc1, CMX_CONF_SPLIT, (bc1->pid<<1) +1);
|
for (bc=bc_list; *bc; *bc++) {
|
||||||
manager_ph_control(bc2, CMX_CONF_SPLIT, (bc1->pid<<1) +1);
|
if ( (*bc)->bc_state == BCHAN_BRIDGED){
|
||||||
|
misdn_split_conf( *bc, (*bc)->conf_id);
|
||||||
|
} else {
|
||||||
|
cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,20 +23,27 @@
|
||||||
|
|
||||||
#define MAX_BCHANS 30
|
#define MAX_BCHANS 30
|
||||||
|
|
||||||
enum bc_state_e {
|
enum bchannel_state {
|
||||||
STATE_NOTHING=0,
|
BCHAN_CLEANED=0,
|
||||||
STATE_NULL,
|
BCHAN_EMPTY,
|
||||||
STATE_CALL_INIT,
|
BCHAN_SETUP,
|
||||||
STATE_CONNECTED,
|
BCHAN_SETUPED,
|
||||||
STATE_HOLD_ACKNOWLEDGE
|
BCHAN_ACTIVE,
|
||||||
|
BCHAN_ACTIVATED,
|
||||||
|
BCHAN_BRIDGE,
|
||||||
|
BCHAN_BRIDGED,
|
||||||
|
BCHAN_RELEASE,
|
||||||
|
BCHAN_RELEASED,
|
||||||
|
BCHAN_CLEAN,
|
||||||
|
BCHAN_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum misdn_err_e {
|
enum misdn_err_e {
|
||||||
ENOCHAN=1
|
ENOCHAN=1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum mISDN_NUMBER_PLAN {
|
enum mISDN_NUMBER_PLAN {
|
||||||
NUMPLAN_UNINITIALIZED=-1,
|
NUMPLAN_UNINITIALIZED=-1,
|
||||||
NUMPLAN_INTERNATIONAL=0x1,
|
NUMPLAN_INTERNATIONAL=0x1,
|
||||||
|
@ -54,7 +61,6 @@ enum event_response_e {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum event_e {
|
enum event_e {
|
||||||
EVENT_NOTHING,
|
EVENT_NOTHING,
|
||||||
EVENT_TONE_GENERATE,
|
EVENT_TONE_GENERATE,
|
||||||
|
@ -244,11 +250,16 @@ struct misdn_bchannel {
|
||||||
int generate_tone;
|
int generate_tone;
|
||||||
int tone_cnt;
|
int tone_cnt;
|
||||||
|
|
||||||
enum bc_state_e state;
|
enum bchannel_state bc_state;
|
||||||
|
enum bchannel_state next_bc_state;
|
||||||
|
|
||||||
|
int conf_id;
|
||||||
|
|
||||||
int holded;
|
int holded;
|
||||||
int stack_holder;
|
int stack_holder;
|
||||||
|
|
||||||
|
struct misdn_bchannel *holded_bc;
|
||||||
|
|
||||||
int pres;
|
int pres;
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
|
@ -390,4 +401,11 @@ int misdn_lib_is_ptp(int port);
|
||||||
#define PRI_TRANS_CAP_3_1K_AUDIO 0x10
|
#define PRI_TRANS_CAP_3_1K_AUDIO 0x10
|
||||||
#define PRI_TRANS_CAP_7K_AUDIO 0x11
|
#define PRI_TRANS_CAP_7K_AUDIO 0x11
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char *bc_state2str(enum bchannel_state state);
|
||||||
|
void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue