* removed pp_l2_check (fixed L2 bug in mISDNuser)

* added blocking flag to stack object. A port can be blocked/unblocked from the
  cli
* added EVENT_PORT_ALARM to send alarm infos to the chan_misdn.c layer (later	
  we can add a manager event for that)
* added block_on_alarm option, to block the port whenever a ALARM occurs
* added need_busy flag to indicate if we've sended a CONTROL_BUSY already
* changed a bunch of cb_log(-1,..) to cb_log(0,..) due to funny behaviour in 
  recent asterisk ast_log messages..
* fixed a few ETSI state violations, especially when finishing calls in 
  different seldom states
* changed debug levels a lot to make the log more readable in low debuglevels
* some first fixes for the HOLD/RETRIEVE stuff (doesn't work totally still)
* removed the PRECONNECTED state stuff
* added cause 27 when we get a CLEANUP directly after a outgoing SETUP, this
  creates a CHANISUNAVAIL instead of a NOANSWER
* removed the addr pointer from "misdn show stacks" that's not needed anymore 
  and makes the output more unreadable
* added cause saving on RELEASE/RELEASE_COMPLETE
* set cause to 16 on prepare_bc
* removed stack getting from ph_control functions, we don't really need it 
  there
* added beroec api



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38801 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Christian Richter
2006-08-03 16:38:00 +00:00
parent aac4712421
commit fc3d27cf6f
9 changed files with 495 additions and 210 deletions

View File

@@ -47,6 +47,11 @@ ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/mISDNuser/mISDNlib.h),)
C_MODS:=$(filter-out chan_misdn,$(C_MODS)) C_MODS:=$(filter-out chan_misdn,$(C_MODS))
endif endif
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libbnec.so),)
EC_CFLAGS=-DWITH_BEROEC
EC_LIBS=-lbnec
endif
ifndef OPENH323DIR ifndef OPENH323DIR
OPENH323DIR=$(HOME)/openh323 OPENH323DIR=$(HOME)/openh323
endif endif
@@ -94,9 +99,9 @@ endif
misdn/chan_misdn_lib.a: misdn/chan_misdn_lib.a:
make -C misdn make -C misdn
chan_misdn.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\" chan_misdn.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\" $(EC_CFLAGS)
misdn_config.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\" misdn_config.o: CFLAGS+=-Imisdn -DCHAN_MISDN_VERSION=\"0.3.0\" $(EC_CFLAGS)
chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a chan_misdn.so: chan_misdn.o misdn_config.o misdn/chan_misdn_lib.a
chan_misdn.so: LIBS+=-lisdnnet -lmISDN chan_misdn.so: LIBS+=-lisdnnet -lmISDN $(EC_LIBS)

View File

@@ -140,6 +140,7 @@ struct chan_list {
enum misdn_chan_state state; enum misdn_chan_state state;
int need_queue_hangup; int need_queue_hangup;
int need_hangup; int need_hangup;
int need_busy;
int holded; int holded;
int orginator; int orginator;
@@ -715,6 +716,35 @@ static int misdn_set_crypt_debug(int fd, int argc, char *argv[])
} }
static int misdn_port_block(int fd, int argc, char *argv[])
{
int port;
if (argc != 4)
return RESULT_SHOWUSAGE;
port = atoi(argv[3]);
misdn_lib_port_block(port);
return 0;
}
static int misdn_port_unblock(int fd, int argc, char *argv[])
{
int port;
if (argc != 4)
return RESULT_SHOWUSAGE;
port = atoi(argv[3]);
misdn_lib_port_unblock(port);
return 0;
}
static int misdn_restart_port (int fd, int argc, char *argv[]) static int misdn_restart_port (int fd, int argc, char *argv[])
{ {
int port; int port;
@@ -877,6 +907,7 @@ static struct state_struct state_array[] = {
{MISDN_ALERTING,"ALERTING"}, /* when Alerting */ {MISDN_ALERTING,"ALERTING"}, /* when Alerting */
{MISDN_BUSY,"BUSY"}, /* when BUSY */ {MISDN_BUSY,"BUSY"}, /* when BUSY */
{MISDN_CONNECTED,"CONNECTED"}, /* when connected */ {MISDN_CONNECTED,"CONNECTED"}, /* when connected */
{MISDN_PRECONNECTED,"PRECONNECTED"}, /* when connected */
{MISDN_DISCONNECTED,"DISCONNECTED"}, /* when connected */ {MISDN_DISCONNECTED,"DISCONNECTED"}, /* when connected */
{MISDN_RELEASED,"RELEASED"}, /* when connected */ {MISDN_RELEASED,"RELEASED"}, /* when connected */
{MISDN_BRIDGED,"BRIDGED"}, /* when bridged */ {MISDN_BRIDGED,"BRIDGED"}, /* when bridged */
@@ -909,7 +940,6 @@ static char *misdn_get_ch_state(struct chan_list *p)
static void reload_config(void) static void reload_config(void)
{ {
int i, cfg_debug; int i, cfg_debug;
chan_misdn_log(-1, 0, "Dynamic Crypting Activation is not support during reload at the moment\n");
free_robin_list(); free_robin_list();
misdn_cfg_reload(); misdn_cfg_reload();
@@ -1381,6 +1411,19 @@ static struct ast_cli_entry cli_show_cl =
complete_ch complete_ch
}; };
static struct ast_cli_entry cli_port_block=
{ {"misdn","port","block", NULL},
misdn_port_block,
"Blocks the given port",
"Usage: misdn port block\n"
};
static struct ast_cli_entry cli_port_unblock=
{ {"misdn","port","unblock", NULL},
misdn_port_unblock,
"Unblocks the given port",
"Usage: misdn port unblock\n"
};
static struct ast_cli_entry cli_restart_port = static struct ast_cli_entry cli_restart_port =
@@ -1559,12 +1602,12 @@ static void config_jitterbuffer(struct chan_list *ch)
} else { } else {
if (len <=100 || len > 8000) { if (len <=100 || len > 8000) {
chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n"); chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
len=1000; len=1000;
} }
if ( threshold > len ) { if ( threshold > len ) {
chan_misdn_log(-1,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n"); chan_misdn_log(0,bc->port,"config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
} }
if ( ch->jb) { if ( ch->jb) {
@@ -1676,21 +1719,38 @@ static int read_config(struct chan_list *ch, int orig) {
ast_copy_string (ast->context,ch->context,sizeof(ast->context)); ast_copy_string (ast->context,ch->context,sizeof(ast->context));
{ {
int ec, ectr; int ec;
misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int)); misdn_cfg_get( port, MISDN_CFG_ECHOCANCEL, &ec, sizeof(int));
misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
if (ec == 1 ) { if (ec == 1 ) {
bc->ec_enable=1; bc->ec_enable=1;
} else if ( ec > 1 ) { } else if ( ec > 1 ) {
bc->ec_enable=1; bc->ec_enable=1;
bc->ec_deftaps=ec; bc->ec_deftaps=ec;
} }
#ifdef WITH_ECHOTRAINING
int ectr;
misdn_cfg_get( port, MISDN_CFG_ECHOTRAINING, &ectr, sizeof(int));
if ( ectr >= 0 ) { if ( ectr >= 0 ) {
bc->ec_training=ectr; bc->ec_training=ectr;
} }
#endif
#ifdef WITH_BEROEC
misdn_cfg_get(port, MISDN_CFG_BNECHOCANCEL,&bc->bnec_tail, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_BNEC_ANTIHOWL, &bc->bnec_ah, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_BNEC_NLP, &bc->bnec_nlp, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_BNEC_TD, &bc->bnec_td, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_BNEC_ADAPT, &bc->bnec_adapt, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_BNEC_ZEROCOEFF, &bc->bnec_zero, sizeof(int));
if (bc->bnec_tail && bc->ec_enable) {
ast_log(LOG_WARNING,"Are you sure you wan't to mix BNEC with Zapec ? This might cause bad audio quality!\n");
bc->ec_enable=0;
}
#endif
} }
{ {
@@ -1839,7 +1899,7 @@ static int misdn_call(struct ast_channel *ast, char *dest, int timeout)
if (ext) { if (ext) {
opts=strtok_r(NULL,"/",&tokb); opts=strtok_r(NULL,"/",&tokb);
} else { } else {
chan_misdn_log(-1,0,"misdn_call: No Extension given!\n"); chan_misdn_log(0,0,"misdn_call: No Extension given!\n");
return -1; return -1;
} }
} }
@@ -2265,6 +2325,11 @@ static int misdn_hangup(struct ast_channel *ast)
return 0; return 0;
} }
p->need_hangup=0;
p->need_queue_hangup=0;
p->need_busy=0;
if (!p->bc->nt) if (!p->bc->nt)
stop_bc_tones(p); stop_bc_tones(p);
@@ -2295,13 +2360,8 @@ static int misdn_hangup(struct ast_channel *ast)
start_bc_tones(p); start_bc_tones(p);
hanguptone_indicate(p); hanguptone_indicate(p);
if (bc->nt) {
if (bc->need_disconnect) if (bc->need_disconnect)
misdn_lib_send_event( bc, EVENT_DISCONNECT); misdn_lib_send_event( bc, EVENT_DISCONNECT);
} else {
misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
p->state=MISDN_CLEANING;
}
break; break;
case MISDN_CALLING_ACKNOWLEDGE: case MISDN_CALLING_ACKNOWLEDGE:
@@ -2323,6 +2383,7 @@ static int misdn_hangup(struct ast_channel *ast)
misdn_lib_send_event( bc, EVENT_DISCONNECT); misdn_lib_send_event( bc, EVENT_DISCONNECT);
break; break;
case MISDN_CONNECTED: case MISDN_CONNECTED:
case MISDN_PRECONNECTED:
/* Alerting or Disconect */ /* Alerting or Disconect */
if (p->bc->nt) { if (p->bc->nt) {
start_bc_tones(p); start_bc_tones(p);
@@ -2755,6 +2816,7 @@ static struct chan_list *init_chan_list(int orig)
cl->orginator=orig; cl->orginator=orig;
cl->need_queue_hangup=1; cl->need_queue_hangup=1;
cl->need_hangup=1; cl->need_hangup=1;
cl->need_busy=1;
cl->overlap_dial_task=-1; cl->overlap_dial_task=-1;
return cl; return cl;
@@ -2844,18 +2906,19 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
if (!strcasecmp(cfg_group, group)) { if (!strcasecmp(cfg_group, group)) {
int port_up; int port_up;
int check,checkl2; int check;
misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int)); misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_PP_L2_CHECK, &checkl2, sizeof(int));
check=checkl2?2:check;
port_up = misdn_lib_port_up(port, check); port_up = misdn_lib_port_up(port, check);
if (check && !port_up) if (check && !port_up)
chan_misdn_log(1,port,"L1 is not Up on this Port\n"); chan_misdn_log(1,port,"L1 is not Up on this Port\n");
if (check && port_up<0) {
ast_log(LOG_WARNING,"This port (%d) is blocked\n", port);
}
if ( port_up ) {
if ( port_up>0 ) {
newbc = misdn_lib_get_free_bc(port, robin_channel); newbc = misdn_lib_get_free_bc(port, robin_channel);
if (newbc) { if (newbc) {
chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel); chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
@@ -2871,7 +2934,7 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
} while (!newbc && robin_channel != rr->channel); } while (!newbc && robin_channel != rr->channel);
if (!newbc) if (!newbc)
chan_misdn_log(4, port, " Failed! No free channel in group %d!", group); chan_misdn_log(-1, port, " Failed! No free channel in group %d!", group);
} }
else { else {
@@ -2883,15 +2946,13 @@ static struct ast_channel *misdn_request(const char *type, int format, void *dat
chan_misdn_log(3,port, "Group [%s] Port [%d]\n", group, port); chan_misdn_log(3,port, "Group [%s] Port [%d]\n", group, port);
if (!strcasecmp(cfg_group, group)) { if (!strcasecmp(cfg_group, group)) {
int port_up; int port_up;
int check,checkl2; int check;
misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int)); misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int));
misdn_cfg_get(port, MISDN_CFG_PP_L2_CHECK, &checkl2, sizeof(int));
check=checkl2?2:check;
port_up = misdn_lib_port_up(port, check); port_up = misdn_lib_port_up(port, check);
chan_misdn_log(4, port, "portup:%d\n", port_up); chan_misdn_log(4, port, "portup:%d\n", port_up);
if ( port_up ) { if ( port_up>0 ) {
newbc = misdn_lib_get_free_bc(port, 0); newbc = misdn_lib_get_free_bc(port, 0);
if (newbc) if (newbc)
break; break;
@@ -3178,9 +3239,11 @@ static void hangup_chan(struct chan_list *ch)
return; return;
} }
cb_log(1,ch->bc?ch->bc->port:0,"hangup_chan\n");
if (ch->need_hangup) if (ch->need_hangup)
{ {
cb_log(1,ch->bc->port,"-> hangup\n");
send_cause2ast(ch->ast,ch->bc,ch); send_cause2ast(ch->ast,ch->bc,ch);
ch->need_hangup=0; ch->need_hangup=0;
ch->need_queue_hangup=0; ch->need_queue_hangup=0;
@@ -3196,7 +3259,10 @@ static void hangup_chan(struct chan_list *ch)
ch->need_queue_hangup=0; ch->need_queue_hangup=0;
if (ch->ast) { if (ch->ast) {
send_cause2ast(ch->ast,ch->bc,ch); send_cause2ast(ch->ast,ch->bc,ch);
if (ch->ast)
ast_queue_hangup(ch->ast); ast_queue_hangup(ch->ast);
cb_log(1,ch->bc->port,"-> queue_hangup\n");
} else { } else {
cb_log(1,ch->bc->port,"Cannot hangup chan, no ast\n"); cb_log(1,ch->bc->port,"Cannot hangup chan, no ast\n");
} }
@@ -3385,11 +3451,20 @@ static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc, st
case 21: case 21:
case 17: /* user busy */ case 17: /* user busy */
chan_misdn_log(1, bc?bc->port:0, " --> * SEND: Queue Busy pid:%d\n", bc?bc->pid:-1);
ch->state=MISDN_BUSY; ch->state=MISDN_BUSY;
if (!ch->need_busy) {
chan_misdn_log(1,bc?bc->port:0, "Queued busy already\n");
break;
}
chan_misdn_log(1, bc?bc->port:0, " --> * SEND: Queue Busy pid:%d\n", bc?bc->pid:-1);
ast_queue_control(ast, AST_CONTROL_BUSY); ast_queue_control(ast, AST_CONTROL_BUSY);
ch->need_busy=0;
break; break;
} }
} }
@@ -3463,15 +3538,23 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
struct chan_list *ch=find_chan_by_bc(cl_te, bc); struct chan_list *ch=find_chan_by_bc(cl_te, bc);
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 pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch?misdn_get_ch_state(ch):"none"); int debuglevel=1;
if ( event==EVENT_CLEANUP && !user_data)
debuglevel=5;
chan_misdn_log(debuglevel, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch?misdn_get_ch_state(ch):"none");
if (debuglevel==1) {
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)); chan_misdn_log(4,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
}
} }
if (!ch) { if (!ch) {
switch(event) { switch(event) {
case EVENT_SETUP: case EVENT_SETUP:
case EVENT_DISCONNECT: case EVENT_DISCONNECT:
case EVENT_PORT_ALARM:
break; break;
case EVENT_RELEASE_COMPLETE: case EVENT_RELEASE_COMPLETE:
chan_misdn_log(1, bc->port, " --> no Ch, so we've already released.\n"); chan_misdn_log(1, bc->port, " --> no Ch, so we've already released.\n");
@@ -3510,7 +3593,16 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
switch (event) { switch (event) {
case EVENT_PORT_ALARM:
{
int boa=0;
misdn_cfg_get( bc->port, MISDN_CFG_ALARM_BLOCK, &boa, sizeof(int));
if (boa) {
cb_log(1,bc->port," --> blocking\n");
misdn_lib_port_block(bc->port);
}
}
break;
case EVENT_BCHAN_ACTIVATED: case EVENT_BCHAN_ACTIVATED:
break; break;
@@ -3521,21 +3613,11 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
case EVENT_NEW_L3ID: case EVENT_NEW_L3ID:
ch->l3id=bc->l3_id; ch->l3id=bc->l3_id;
ch->addr=bc->addr; ch->addr=bc->addr;
if (bc->nt && ch->state == MISDN_PRECONNECTED ) {
/* OK we've got the very new l3id so we can answer
now */
start_bc_tones(ch);
ch->state = MISDN_CONNECTED;
ast_queue_control(ch->ast, AST_CONTROL_ANSWER);
}
break; break;
case EVENT_NEW_BC: case EVENT_NEW_BC:
if (bc) if (bc)
ch->bc=bc; ch->bc=(struct misdn_bchannel*)user_data;
break; break;
case EVENT_DTMF_TONE: case EVENT_DTMF_TONE:
@@ -4002,6 +4084,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
break; break;
case EVENT_CONNECT: case EVENT_CONNECT:
{ {
/*we answer when we've got our very new L3 ID from the NT stack */
misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE); misdn_lib_send_event(bc,EVENT_CONNECT_ACKNOWLEDGE);
struct ast_channel *bridged=AST_BRIDGED_P(ch->ast); struct ast_channel *bridged=AST_BRIDGED_P(ch->ast);
@@ -4020,11 +4103,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
} }
} }
/*we answer when we've got our very new L3 ID from the NT stack */
if (bc->nt) {
ch->state=MISDN_PRECONNECTED;
break;
}
/* notice that we don't break here!*/ /* notice that we don't break here!*/
@@ -4045,9 +4123,6 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
if (ch) { if (ch) {
struct chan_list *holded_ch=find_holded(cl_te, bc); struct chan_list *holded_ch=find_holded(cl_te, bc);
if (ch->ast)
send_cause2ast(ch->ast,bc,ch);
chan_misdn_log(3,bc->port," --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->orginator, bc->nt, misdn_inband_avail(bc), ch->state); chan_misdn_log(3,bc->port," --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->orginator, bc->nt, misdn_inband_avail(bc), ch->state);
if ( ch->orginator==ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) { if ( ch->orginator==ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) {
/* If there's inband information available (e.g. a /* If there's inband information available (e.g. a
@@ -4064,12 +4139,13 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
/*Check for holded channel, to implement transfer*/ /*Check for holded channel, to implement transfer*/
if (holded_ch && ch->ast ) { if (holded_ch && ch->ast ) {
cb_log(1,bc->port," --> found holded ch\n");
if (ch->state == MISDN_CONNECTED ) { if (ch->state == MISDN_CONNECTED ) {
misdn_transfer_bc(ch, holded_ch) ; misdn_transfer_bc(ch, holded_ch) ;
}
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
break; break;
} }
}
stop_bc_tones(ch); stop_bc_tones(ch);
hangup_chan(ch); hangup_chan(ch);
@@ -4085,7 +4161,7 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
hangup_chan(ch); hangup_chan(ch);
release_chan(bc); release_chan(bc);
if (bc->cause >= 0 && bc->need_release_complete) if (bc->need_release_complete)
misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE); misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
} }
break; break;
@@ -4101,6 +4177,15 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data)
case EVENT_CLEANUP: case EVENT_CLEANUP:
{ {
stop_bc_tones(ch); stop_bc_tones(ch);
switch(ch->state) {
case MISDN_CALLING:
bc->cause=27; /* Destination out of order */
break;
default:
break;
}
hangup_chan(ch); hangup_chan(ch);
release_chan(bc); release_chan(bc);
} }
@@ -4378,6 +4463,8 @@ static int unload_module(void *mod)
ast_cli_unregister(&cli_show_port); ast_cli_unregister(&cli_show_port);
ast_cli_unregister(&cli_show_ports_stats); ast_cli_unregister(&cli_show_ports_stats);
ast_cli_unregister(&cli_show_stacks); ast_cli_unregister(&cli_show_stacks);
ast_cli_unregister(&cli_port_block);
ast_cli_unregister(&cli_port_unblock);
ast_cli_unregister(&cli_restart_port); ast_cli_unregister(&cli_restart_port);
ast_cli_unregister(&cli_port_up); ast_cli_unregister(&cli_port_up);
ast_cli_unregister(&cli_port_down); ast_cli_unregister(&cli_port_down);
@@ -4491,6 +4578,8 @@ static int load_module(void *mod)
ast_cli_register(&cli_show_stacks); ast_cli_register(&cli_show_stacks);
ast_cli_register(&cli_show_ports_stats); ast_cli_register(&cli_show_ports_stats);
ast_cli_register(&cli_port_block);
ast_cli_register(&cli_port_unblock);
ast_cli_register(&cli_restart_port); ast_cli_register(&cli_restart_port);
ast_cli_register(&cli_port_up); ast_cli_register(&cli_port_up);
ast_cli_register(&cli_port_down); ast_cli_register(&cli_port_down);
@@ -4722,6 +4811,10 @@ static int misdn_set_opt_exec(struct ast_channel *chan, void *data)
if (neglect) { if (neglect) {
chan_misdn_log(1, ch->bc->port, " --> disabled\n"); chan_misdn_log(1, ch->bc->port, " --> disabled\n");
ch->bc->ec_enable=0; ch->bc->ec_enable=0;
#ifdef WITH_BEROEC
ch->bc->bnec_tail=0;
#endif
} else { } else {
ch->bc->ec_enable=1; ch->bc->ec_enable=1;
ch->bc->orig=ch->orginator; ch->bc->orig=ch->orginator;
@@ -5001,6 +5094,7 @@ void chan_misdn_log(int level, int port, char *tmpl, ...)
if (level == -1) if (level == -1)
ast_log(LOG_WARNING, buf); ast_log(LOG_WARNING, buf);
else if (misdn_debug_only[port] ? else if (misdn_debug_only[port] ?
(level==1 && misdn_debug[port]) || (level==misdn_debug[port]) (level==1 && misdn_debug[port]) || (level==misdn_debug[port])
: level <= misdn_debug[port]) { : level <= misdn_debug[port]) {

View File

@@ -13,6 +13,13 @@ SOURCES = isdn_lib.c isdn_msg_parser.c
OBJDIR = . OBJDIR = .
OBJS = isdn_lib.o isdn_msg_parser.o fac.o OBJS = isdn_lib.o isdn_msg_parser.o fac.o
ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libbnec.so),)
CFLAGS+=-DBEROEC_VERSION=1
CFLAGS+=-DWITH_BEROEC
endif
all: chan_misdn_lib.a all: chan_misdn_lib.a
%.o: %.c %.o: %.c

View File

@@ -29,7 +29,7 @@ enum misdn_cfg_elements {
MISDN_CFG_TXGAIN, /* int */ MISDN_CFG_TXGAIN, /* int */
MISDN_CFG_TE_CHOOSE_CHANNEL, /* int (bool) */ MISDN_CFG_TE_CHOOSE_CHANNEL, /* int (bool) */
MISDN_CFG_PMP_L1_CHECK, /* int (bool) */ MISDN_CFG_PMP_L1_CHECK, /* int (bool) */
MISDN_CFG_PP_L2_CHECK, /* int (bool) */ MISDN_CFG_ALARM_BLOCK, /* int (bool) */
MISDN_CFG_HDLC, /* int (bool) */ MISDN_CFG_HDLC, /* int (bool) */
MISDN_CFG_CONTEXT, /* char[] */ MISDN_CFG_CONTEXT, /* char[] */
MISDN_CFG_LANGUAGE, /* char[] */ MISDN_CFG_LANGUAGE, /* char[] */
@@ -52,7 +52,18 @@ enum misdn_cfg_elements {
MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */ MISDN_CFG_INCOMING_EARLY_AUDIO, /* int (bool) */
MISDN_CFG_ECHOCANCEL, /* int */ MISDN_CFG_ECHOCANCEL, /* int */
MISDN_CFG_ECHOCANCELWHENBRIDGED, /* int (bool) */ MISDN_CFG_ECHOCANCELWHENBRIDGED, /* int (bool) */
#ifdef WITH_ECHOTRAINGING
MISDN_CFG_ECHOTRAINING, /* int (bool) */ MISDN_CFG_ECHOTRAINING, /* int (bool) */
#endif
#ifdef WITH_BEROEC
MISDN_CFG_BNECHOCANCEL,
MISDN_CFG_BNEC_ANTIHOWL,
MISDN_CFG_BNEC_NLP,
MISDN_CFG_BNEC_ZEROCOEFF,
MISDN_CFG_BNEC_TD,
MISDN_CFG_BNEC_ADAPT,
#endif
MISDN_CFG_NEED_MORE_INFOS, /* bool */ MISDN_CFG_NEED_MORE_INFOS, /* bool */
MISDN_CFG_JITTERBUFFER, /* int */ MISDN_CFG_JITTERBUFFER, /* int */
MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */ MISDN_CFG_JITTERBUFFER_UPPER_THRESHOLD, /* int */

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,30 @@
/* typedef int ie_nothing_t ;*/ /* typedef int ie_nothing_t ;*/
/** end of init usage **/ /** end of init usage **/
#ifdef WITH_BEROEC
typedef int beroec_t;
enum beroec_type {
BEROEC_FULLBAND=0,
BEROEC_SUBBAND,
BEROEC_FASTSUBBAND
};
void beroec_init(void);
void beroec_exit(void);
beroec_t *beroec_new(int tail, enum beroec_type type, int anti_howl,
int tonedisable, int zerocoeff, int adapt, int nlp);
void beroec_destroy(beroec_t *ec);
int beroec_cancel_alaw_chunk(beroec_t *ec,
char *send,
char *receive ,
int len);
int beroec_version(void);
#endif
enum tone_e { enum tone_e {
@@ -114,6 +138,7 @@ enum event_e {
EVENT_DTMF_TONE, EVENT_DTMF_TONE,
EVENT_NEW_L3ID, EVENT_NEW_L3ID,
EVENT_NEW_BC, EVENT_NEW_BC,
EVENT_PORT_ALARM,
EVENT_NEW_CHANNEL, EVENT_NEW_CHANNEL,
EVENT_UNKNOWN EVENT_UNKNOWN
}; };
@@ -327,6 +352,16 @@ struct misdn_bchannel {
int ec_whenbridged; int ec_whenbridged;
int ec_training; int ec_training;
#ifdef WITH_BEROEC
beroec_t *ec;
int bnec_tail;
int bnec_ah;
int bnec_nlp;
int bnec_td;
int bnec_adapt;
int bnec_zero;
#endif
int orig; int orig;
int txgain; int txgain;
@@ -375,6 +410,9 @@ void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2);
int misdn_lib_port_restart(int port); int misdn_lib_port_restart(int port);
int misdn_lib_get_port_info(int port); int misdn_lib_get_port_info(int port);
int misdn_lib_port_block(int port);
int misdn_lib_port_unblock(int port);
int misdn_lib_port_up(int port, int notcheck); int misdn_lib_port_up(int port, int notcheck);
int misdn_lib_get_port_down(int port); int misdn_lib_get_port_down(int port);

View File

@@ -61,6 +61,9 @@ struct misdn_stack {
int lower_id; int lower_id;
int upper_id; int upper_id;
int blocked;
int l2link; int l2link;
time_t l2establish; time_t l2establish;
@@ -95,4 +98,6 @@ struct misdn_stack {
struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc); struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc);
#endif #endif

View File

@@ -1211,6 +1211,7 @@ char EVENT_CLEAN_INFO[] = "CLEAN_UP";
char EVENT_DTMF_TONE_INFO[] = "DTMF_TONE"; char EVENT_DTMF_TONE_INFO[] = "DTMF_TONE";
char EVENT_NEW_L3ID_INFO[] = "NEW_L3ID"; char EVENT_NEW_L3ID_INFO[] = "NEW_L3ID";
char EVENT_NEW_BC_INFO[] = "NEW_BC"; char EVENT_NEW_BC_INFO[] = "NEW_BC";
char EVENT_PORT_ALARM_INFO[] = "ALARM";
char EVENT_NEW_CHANNEL_INFO[] = "NEW_CHANNEL"; char EVENT_NEW_CHANNEL_INFO[] = "NEW_CHANNEL";
char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA"; char EVENT_BCHAN_DATA_INFO[] = "BCHAN_DATA";
char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED"; char EVENT_BCHAN_ACTIVATED_INFO[] = "BCHAN_ACTIVATED";
@@ -1230,6 +1231,7 @@ char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
if (event == EVENT_BCHAN_DATA) return EVENT_BCHAN_DATA_INFO; if (event == EVENT_BCHAN_DATA) return EVENT_BCHAN_DATA_INFO;
if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO; if (event == EVENT_BCHAN_ACTIVATED) return EVENT_BCHAN_ACTIVATED_INFO;
if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO; if (event == EVENT_TONE_GENERATE) return EVENT_TONE_GENERATE_INFO;
if (event == EVENT_PORT_ALARM) return EVENT_PORT_ALARM_INFO;
return NULL; return NULL;
} }

View File

@@ -112,10 +112,9 @@ static const struct misdn_cfg_spec port_spec[] = {
"\tBut be aware! a broken or plugged off cable might be used for a group call\n" "\tBut be aware! a broken or plugged off cable might be used for a group call\n"
"\tas well, since chan_misdn has no chance to distinguish if the L1 is down\n" "\tas well, since chan_misdn has no chance to distinguish if the L1 is down\n"
"\tbecause of a lost Link or because the Provider shut it down..." }, "\tbecause of a lost Link or because the Provider shut it down..." },
{ "pp_l2_check", MISDN_CFG_PP_L2_CHECK, MISDN_CTYPE_BOOL, "no", NONE , { "block_on_alarm", MISDN_CFG_ALARM_BLOCK, MISDN_CTYPE_BOOL, "yes", NONE ,
"Some PBX's do not turn on the L2 automatically. Turn this to yes\n" "Block this port if we have an alarm on it.\n"
"and we'll ignore that and send out calls on that port anyways\n" "default: yes\n" },
"default: no\n" },
{ "hdlc", MISDN_CFG_HDLC, MISDN_CTYPE_BOOL, "no", NONE, { "hdlc", MISDN_CFG_HDLC, MISDN_CTYPE_BOOL, "no", NONE,
"Set this to yes, if you want to bridge a mISDN data channel to\n" "Set this to yes, if you want to bridge a mISDN data channel to\n"
"\tanother channel type or to an application." }, "\tanother channel type or to an application." },
@@ -239,12 +238,20 @@ static const struct misdn_cfg_spec port_spec[] = {
{ "echocancelwhenbridged", MISDN_CFG_ECHOCANCELWHENBRIDGED, MISDN_CTYPE_BOOL, "no", NONE, { "echocancelwhenbridged", MISDN_CFG_ECHOCANCELWHENBRIDGED, MISDN_CTYPE_BOOL, "no", NONE,
"This disables echocancellation when the call is bridged between\n" "This disables echocancellation when the call is bridged between\n"
"\tmISDN channels" }, "\tmISDN channels" },
{ "echotraining", MISDN_CFG_ECHOTRAINING, MISDN_CTYPE_BOOLINT, "0", 2000, #ifdef WITH_BEROEC
"Set this to no to disable echotraining. You can enter a number > 10.\n" { "bnechocancel", MISDN_CFG_BNECHOCANCEL, MISDN_CTYPE_BOOLINT, "yes", 64,
"\tThe value is a multiple of 0.125 ms.\n" "echotail in ms (1-200)\n"},
"\n" { "bnec_antihowl", MISDN_CFG_BNEC_ANTIHOWL, MISDN_CTYPE_INT, "0", NONE,
"\tyes = 2000\n" "Use antihowl\n"},
"\tno = 0" }, { "bnec_nlp", MISDN_CFG_BNEC_NLP, MISDN_CTYPE_BOOL, "yes", NONE,
"Nonlinear Processing (much faster adaption)"},
{ "bnec_zerocoeff", MISDN_CFG_BNEC_ZEROCOEFF, MISDN_CTYPE_BOOL, "no", NONE,
"ZeroCoeffeciens\n"},
{ "bnec_tonedisabler", MISDN_CFG_BNEC_TD, MISDN_CTYPE_BOOL, "no", NONE,
"Disable Tone\n"},
{ "bnec_adaption", MISDN_CFG_BNEC_ADAPT, MISDN_CTYPE_INT, "1", NONE,
"Adaption mode (0=no,1=full,2=fast)\n"},
#endif
{ "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE, { "need_more_infos", MISDN_CFG_NEED_MORE_INFOS, MISDN_CTYPE_BOOL, "0", NONE,
"Send Setup_Acknowledge on incoming calls anyway (instead of PROCEEDING),\n" "Send Setup_Acknowledge on incoming calls anyway (instead of PROCEEDING),\n"
"\tthis requests additional Infos, so we can waitfordigits without much\n" "\tthis requests additional Infos, so we can waitfordigits without much\n"