From: Super User Date: Fri, 6 Jun 2008 17:15:14 +0000 (+0200) Subject: free bchannels on broken pipe of remote application X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=7d16259958e7b3e17d7bcb2c1c296f56f9096bf1 free bchannels on broken pipe of remote application work modified: chan_lcr.c modified: mISDN.cpp modified: mISDN.h modified: socket_server.c --- diff --git a/chan_lcr.c b/chan_lcr.c index fc49cf9..a1ba8ae 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -302,6 +302,12 @@ unsigned short new_bridge_id(void) return(id); } +/* + * apply options (in locked state) + */ +void apply_opt(struct chan_call *call, char *opt) +{ +} /* * enque message to LCR @@ -1359,8 +1365,7 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c struct chan_call *call; ast_mutex_lock(&chan_lock); - - CDEBUG(NULL, NULL, "Received request from Asterisk. data=%s\n", (char *)data); + CDEBUG(NULL, NULL, "Received request from Asterisk. (data=%s)\n", (char *)data); /* if socket is closed */ if (lcr_sock < 0) @@ -1399,7 +1404,6 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c call->ast = ast; ast->tech_pvt = call; ast->fds[0] = call->pipe[0]; - ast_mutex_unlock(&chan_lock); call->pbx_started = 0; /* set state */ call->state = CHAN_LCR_STATE_OUT_PREPARE; @@ -1427,9 +1431,9 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c } strncpy(call->interface, interface, sizeof(call->interface)-1); strncpy(call->dialstring, dial, sizeof(call->dialstring)-1); + apply_opt(call, (char *)opt); -#warning todo: parse options - + ast_mutex_unlock(&chan_lock); return ast; } @@ -1500,7 +1504,6 @@ static int lcr_digit(struct ast_channel *ast, char digit) } ast_mutex_unlock(&chan_lock); - return(0); } @@ -1913,9 +1916,8 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, call2->bridge_call->bridge_call = NULL; call2->bridge_call = NULL; } + ast_mutex_unlock(&chan_lock); - - return AST_BRIDGE_COMPLETE; } static struct ast_channel_tech lcr_tech = { @@ -2027,11 +2029,25 @@ static struct ast_cli_entry cli_port_unload = -static int lcr_config_exec(struct ast_channel *chan, void *data) +static int lcr_config_exec(struct ast_channel *ast, void *data) { - //FIXME: add your aplication code here - // SEPERATOR ':' - + struct chan_call *call; + + ast_mutex_lock(&chan_lock); + CDEBUG(NULL, ast, "Received lcr_config (data=%s)\n", (char *)data); + /* find channel */ + call = call_first; + while(call) { + if (call->ast == ast) + break; + call = call->next; + } + if (call) + apply_opt(call, (char *)data); + else + CERROR(NULL, ast, "lcr_config app not called by chan_lcr channel.\n"); + + ast_mutex_unlock(&chan_lock); return 0; } @@ -2075,53 +2091,32 @@ int load_module(void) } ast_register_application("lcr_config", lcr_config_exec, "lcr_config", - "lcr_config(::..):\n" + "lcr_config(:=::...):\n" "Sets LCR opts. and optargs\n" "\n" "The available options are:\n" " d - Send display text on called phone, text is the optparam\n" - " n - don't detect dtmf tones on called channel\n" - " h - make digital outgoing call\n" - " c - make crypted outgoing call, param is keyindex\n" - " e - perform echo cancelation on this channel,\n" - " takes taps as arguments (32,64,128,256)\n" - " s - send Non Inband DTMF as inband\n" + " n - Don't detect dtmf tones on called channel\n" + " h - Make digital outgoing call\n" + " c - Make crypted outgoing call, optarg is keyindex\n" + " e - Perform echo cancelation on this channel,\n" + " Takes taps as arguments (32,64,128,256)\n" + " s - Send Non Inband DTMF as inband\n" " vr - rxgain control\n" " vt - txgain control\n" + " Volume changes at factor 2 ^ optarg\n" + " pt - Disable all audio features (required for fax application)\n" ); #if 0 ast_cli_register(&cli_show_lcr); ast_cli_register(&cli_show_calls); - ast_cli_register(&cli_reload_routing); ast_cli_register(&cli_reload_interfaces); ast_cli_register(&cli_port_block); ast_cli_register(&cli_port_unblock); ast_cli_register(&cli_port_unload); - - ast_register_application("misdn_set_opt", misdn_set_opt_exec, "misdn_set_opt", - "misdn_set_opt(::..):\n" - "Sets mISDN opts. and optargs\n" - "\n" - "The available options are:\n" - " d - Send display text on called phone, text is the optparam\n" - " n - don't detect dtmf tones on called channel\n" - " h - make digital outgoing call\n" - " c - make crypted outgoing call, param is keyindex\n" - " e - perform echo cancelation on this channel,\n" - " takes taps as arguments (32,64,128,256)\n" - " s - send Non Inband DTMF as inband\n" - " vr - rxgain control\n" - " vt - txgain control\n" - ); - - - lcr_cfg_get( 0, LCR_GEN_TRACEFILE, global_tracefile, BUFFERSIZE); - -======= - //lcr_cfg_get( 0, LCR_GEN_TRACEFILE, global_tracefile, BUFFERSIZE); #endif quit = 0; diff --git a/mISDN.cpp b/mISDN.cpp index 6d9409b..c909bec 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -1167,7 +1167,7 @@ void message_bchannel_from_remote(class JoinRemote *joinremote, int type, unsign /* release */ isdnport = mISDNport->b_port[i]; chan_trace_header(mISDNport, isdnport, "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE); - add_trace("type", NULL, "export request"); + add_trace("type", NULL, "import request"); end_trace(); if (isdnport) { diff --git a/mISDN.h b/mISDN.h index f9bae48..d52ea06 100644 --- a/mISDN.h +++ b/mISDN.h @@ -53,7 +53,7 @@ struct mISDNport { int b_socket[128]; int b_state[128]; /* statemachine, 0 = IDLE */ double b_timer[128]; /* timer for state machine */ - unsigned long b_remote_id[128]; /* the socket currently exported */ + int b_remote_id[128]; /* the socket currently exported (0=none) */ unsigned long b_remote_ref[128]; /* the ref currently exported */ int locally; /* local causes are sent as local causes not remote */ int los, ais, rdi, slip_rx, slip_tx; diff --git a/socket_server.c b/socket_server.c index 4619f60..bf3bfcd 100644 --- a/socket_server.c +++ b/socket_server.c @@ -80,6 +80,8 @@ void free_connection(struct admin_list *admin) void *temp; union parameter param; class Join *join, *joinnext; + struct mISDNport *mISDNport; + int i, ii; /* free remote joins */ if (admin->remote_name[0]) @@ -94,6 +96,26 @@ void free_connection(struct admin_list *admin) "REMOTE APP release"); add_trace("app", "name", "%s", admin->remote_name); end_trace(); + /* release all exported channels */ + mISDNport = mISDNport_first; + while(mISDNport) + { + i = 0; + ii = mISDNport->b_num; + while(i < ii) + { + if (mISDNport->b_remote_id[i] == admin->sock) + { + mISDNport->b_state[i] = B_STATE_IDLE; + mISDNport->b_timer[i] = 0; + mISDNport->b_remote_id[i] = 0; + mISDNport->b_remote_ref[i] = 0; + } + i++; + } + mISDNport = mISDNport->next; + } + /* release join */ join = join_first; while(join) {