From 95a9a7f135a2413b5b07d16bfee93f62660a203b Mon Sep 17 00:00:00 2001 From: Super User Date: Sun, 18 May 2008 09:23:10 +0200 Subject: [PATCH] work on chan_lcr modified: action.cpp modified: apppbx.cpp modified: bchannel.c modified: chan_lcr.c modified: mISDN.cpp modified: message.h modified: route.c modified: route.h --- action.cpp | 15 ++-- apppbx.cpp | 3 +- bchannel.c | 52 ++++++++---- chan_lcr.c | 266 ++++++++++++++++++++++++++++++++++++++++++++++++------------- mISDN.cpp | 23 +++++- message.h | 2 +- route.c | 7 +- route.h | 3 +- 8 files changed, 284 insertions(+), 87 deletions(-) diff --git a/action.cpp b/action.cpp index ab8e586..4eb340a 100644 --- a/action.cpp +++ b/action.cpp @@ -74,7 +74,7 @@ void EndpointAppPBX::action_init_remote(void) struct caller_info callerinfo; struct redir_info redirinfo; struct dialing_info dialinginfo; - char exten[128] = ""; + char context[128] = ""; char remote[32]; if (!(rparam = routeparam(e_action, PARAM_APPLICATION))) @@ -95,23 +95,28 @@ void EndpointAppPBX::action_init_remote(void) memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo)); memset(&dialinginfo, 0, sizeof(dialinginfo)); + if ((rparam = routeparam(e_action, PARAM_CONTEXT))) + { + SCPY(context, rparam->string_value); + } if ((rparam = routeparam(e_action, PARAM_EXTEN))) { - SCPY(exten, rparam->string_value); + SCPY(dialinginfo.id, rparam->string_value); + dialinginfo.ntype = INFO_NTYPE_UNKNOWN; } /* send setup to remote */ trace_header("ACTION remote (setup)", DIRECTION_NONE); add_trace("number", NULL, dialinginfo.id); add_trace("remote", NULL, remote); - if (exten[0]) - add_trace("exten", NULL, remote); + if (context[0]) + add_trace("context", NULL, context); end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP); memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info)); memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info)); memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info)); - SCPY(message->param.setup.exten, exten); + SCPY(message->param.setup.context, context); message_put(message); } diff --git a/apppbx.cpp b/apppbx.cpp index 3d31f8e..cc9effe 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -2766,6 +2766,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un break; #if 0 + kann nach dem test gelöscht werden, da eine direkte funktion im join und im mISDN zum austausch der message existiert /* port assigns bchannel */ case MESSAGE_BCHANNEL: /* bchannel assignment messafe */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received bchannel message %d from port.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->bchannel.type); @@ -3429,8 +3430,8 @@ void EndpointAppPBX::ea_message_join(unsigned long join_id, int message_type, un join_mISDNsignal(portlist, message_type, param); break; -#warning was ist hiermit #if 0 + kann nach dem test gelöscht werden, da eine direkte funktion im join und im mISDN zum austausch der message existiert /* JOIN requests bchannel */ case MESSAGE_BCHANNEL: /* indicates the need of own bchannel access */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received bchannel assignment %d from join.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->bchannel.type); diff --git a/bchannel.c b/bchannel.c index 5aa2cb6..42831d8 100644 --- a/bchannel.c +++ b/bchannel.c @@ -210,6 +210,9 @@ int bchannel_create(struct bchannel *bchannel) return(0); } + /* default tx_dejitter */ + bchannel->b_tx_dejitter = 1; + /* open socket */ channel->b_sock = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_L2DSP); if (bchannel->b_sock < 0) @@ -380,33 +383,33 @@ static void bchannel_activated(struct bchannel *bchannel) /* set dsp features */ if (bchannel->b_txdata) - ph_control(handle, (bchannel->b_txdata)?CMX_TXDATA_ON:CMX_TXDATA_OFF, 0, "DSP-TXDATA", bchannel->b_txdata); + ph_control(handle, (bchannel->b_txdata)?DSP_TXDATA_ON:DSP_TXDATA_OFF, 0, "DSP-TXDATA", bchannel->b_txdata); if (bchannel->b_delay) - ph_control(handle, CMX_DELAY, bchannel->b_delay, "DSP-DELAY", bchannel->b_delay); + ph_control(handle, DSP_DELAY, bchannel->b_delay, "DSP-DELAY", bchannel->b_delay); if (bchannel->b_tx_dejitter) - ph_control(handle, (bchannel->b_tx_dejitter)?CMX_TX_DEJITTER:CMX_TX_DEJ_OFF, 0, "DSP-DELAY", bchannel->b_tx_dejitter); + ph_control(handle, (bchannel->b_tx_dejitter)?DSP_TX_DEJITTER:DSP_TX_DEJ_OFF, 0, "DSP-TX_DEJITTER", bchannel->b_tx_dejitter); if (bchannel->b_tx_gain) - ph_control(handle, VOL_CHANGE_TX, bchannel->b_tx_gain, "DSP-TX_GAIN", bchannel->b_tx_gain); + ph_control(handle, DSP_VOL_CHANGE_TX, bchannel->b_tx_gain, "DSP-TX_GAIN", bchannel->b_tx_gain); if (bchannel->b_rx_gain) - ph_control(handle, VOL_CHANGE_RX, bchannel->b_rx_gain, "DSP-RX_GAIN", bchannel->b_rx_gain); + ph_control(handle, DSP_VOL_CHANGE_RX, bchannel->b_rx_gain, "DSP-RX_GAIN", bchannel->b_rx_gain); if (bchannel->b_pipeline[0]) ph_control_block(handle, PIPELINE_CFG, bchannel->b_pipeline, strlen(bchannel->b_pipeline)+1, "DSP-PIPELINE", 0); if (bchannel->b_conf) - ph_control(handle, CMX_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); + ph_control(handle, DSP_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); if (bchannel->b_echo) - ph_control(handle, CMX_ECHO_ON, 0, "DSP-ECHO", 1); + ph_control(handle, DSP_ECHO_ON, 0, "DSP-ECHO", 1); if (bchannel->b_tone) - ph_control(handle, TONE_PATT_ON, bchannel->b_tone, "DSP-TONE", bchannel->b_tone); + ph_control(handle, DSP_TONE_PATT_ON, bchannel->b_tone, "DSP-TONE", bchannel->b_tone); if (bchannel->b_rxoff) - ph_control(handle, CMX_RECEIVE_OFF, 0, "DSP-RXOFF", 1); + ph_control(handle, DSP_RECEIVE_OFF, 0, "DSP-RXOFF", 1); // if (bchannel->b_txmix) -// ph_control(handle, CMX_MIX_ON, 0, "DSP-MIX", 1); +// ph_control(handle, DSP_MIX_ON, 0, "DSP-MIX", 1); if (bchannel->b_dtmf) ph_control(handle, DTMF_TONE_START, 0, "DSP-DTMF", 1); if (bchannel->b_crypt_len) - ph_control_block(handle, BF_ENABLE_KEY, bchannel->b_crypt_key, bchannel->b_crypt_len, "DSP-CRYPT", bchannel->b_crypt_len); + ph_control_block(handle, DSP_BF_ENABLE_KEY, bchannel->b_crypt_key, bchannel->b_crypt_len, "DSP-CRYPT", bchannel->b_crypt_len); if (bchannel->b_conf) - ph_control(handle, CMX_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); + ph_control(handle, DSP_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); bchannel->b_state = BSTATE_ACTIVE; } @@ -550,8 +553,17 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi return; } - if (bchannel->rx_data) - bchannel->rx_data(bchannel, data, len); + if (!bchannel->call) + { + PDEBUG("PmISDN(%s) ignoring data, because no call associated with bchannel\n", p_name); + return; + } + len = write(bchannel->call->pipe[1], data, len); + if (len < 0) + { + PDEBUG("PmISDN(%s) broken pipe on bchannel pipe\n", p_name); + return; + } } @@ -596,12 +608,18 @@ void bchannel_join(struct bchannel *bchannel, unsigned short id) handle = bchannel->b_addr; #endif - if (id) + if (id) { bchannel->b_conf = (id<<16) + bchannel_pid; - else + bchannel->b_rxoff = 1; + } else { bchannel->b_conf = 0; + bchannel->b_rxoff = 0; + } if (bchannel->b_state == BSTATE_ACTIVE) - ph_control(handle, CMX_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); + { + ph_control(handle, DSP_RX_OFF, bchannel->b_rxoff, "DSP-RX_OFF", bchannel->b_conf); + ph_control(handle, DSP_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf); + } } diff --git a/chan_lcr.c b/chan_lcr.c index c72ed83..f33d917 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -79,11 +79,13 @@ If the ref is 0 and the state is CHAN_LCR_STATE_RELEASE, see the proceedure */ +u_char flip_bits[256]; + +#warning TODO: bchannel oeffnen und aktivieren (wer macht das?:) #warning reconnect after socket closed, release all calls. #warning debug of call handling #warning ausloesen beim socket-verlust - #include #include #include @@ -205,9 +207,14 @@ struct chan_call *alloc_call(void) *callp = (struct chan_call *)malloc(sizeof(struct chan_call)); if (*callp) memset(*callp, 0, sizeof(struct chan_call)); + if (pipe((*callp)->pipe) < 0) { + free_call(*callp); + return; + } return(*callp); } + void free_call(struct chan_call *call) { struct chan_call **temp = &call_first; @@ -217,15 +224,23 @@ void free_call(struct chan_call *call) if (*temp == call) { *temp = (*temp)->next; + if (call->pipe[0]) + close(call->pipe[0]); + if (call->pipe[1]) + close(call->pipe[1]); if (call->bchannel) { if (call->bchannel->call) call->bchannel->call = NULL; + else + warnung } if (call->bridge_call) { if (call->bridge_call->bridge_call) call->bridge_call->bridge_call = NULL; + else + warnung } free(call); return; @@ -382,7 +397,83 @@ static void bridge_message_if_bridged(struct chan_call *call, int message_type, /* check bridge */ if (!call) return; if (!call->bridge_call) return; - send_message(MESSAGE_RELEASE, call->bridge_call->ref, param); + send_message(message_type, call->bridge_call->ref, param); +} + +/* + * check if extension matches and start asterisk + * if it can match, proceed + * if not, release + */ +static void lcr_setup_pbx(struct chan_call *call, struct ast_channel *ast, int complete) +{ + int cause; + + if (complete) + { + /* if not match */ + if (!ast_canmatch_extension(ast, ast->context, call->dad, 1, call->oad)) + { + cause = 1; + goto release; + if (!ast_exists_extension(ast, ast->context, call->dad, 1, call->oad)) + { + cause = 28; + goto release; + } + /* send setup acknowledge to lcr */ + memset(&newparam, 0, sizeof(union parameter)); + send_message(MESSAGE_PROCEEDING, call->ref, &newparam); + + /* change state */ + call->state = CHAN_LCR_STATE_IN_PROCEEDING; + + goto start; + } + + if (ast_canmatch_extension(ast, ast->context, dad, 1, oad)) + { + /* send setup acknowledge to lcr */ + memset(&newparam, 0, sizeof(union parameter)); + send_message(MESSAGE_OVERLAP, call->ref, &newparam); + + /* change state */ + call->state = CHAN_LCR_STATE_IN_DIALING; + + /* if match, start pbx */ + if (ast_exists_extension(ast, ast->context, dad, 1, oad)) + goto start; + + /* if can match */ + return; + } + + /* if not match */ + cause = 1; + release: + /* release lcr */ + memset(&newparam, 0, sizeof(union parameter)); + newparam.disconnectinfo.cause = cause; + newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL; + send_message(MESSAGE_RELEASE, call->ref, &newparam); + call->ref = 0; + /* release asterisk */ + ast->hangupcause = call->cause; + ast_queue_hangup(ast); + /* change to release state */ + call->state = CHAN_LCR_STATE_RELEASE; + return; + + start: + /* send setup to asterisk */ + ret = ast_pbx_start(ast); + if (ret < 0) + { + cause = (ret==-2)?34:27; + goto release; + } + call->pbx_started = 1; + return; } /* @@ -394,9 +485,8 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet union parameter newparam; /* create asterisk channel instrance */ -#warning anstatt vom lcr "setup.exten" zu bekommen, sollten wir den context übertragen, der dann in der channel.conf zu dem richtigen ruleset führt. ast = ast_channel_alloc(1, AST_STATE_RESERVED, NULL, NULL, "", NULL, "", 0, "%s/%d", lcr_type, ++glob_channel); - if (!call->ast) + if (!ast) { /* release */ memset(&newparam, 0, sizeof(union parameter)); @@ -411,10 +501,13 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet call->ast = ast; ast->tech_pvt = call; ast->tech = &lcr_tech; + ast->fds[0] = call->pipe[0]; /* fill setup information */ - if (param->setup.exten[0]) - strncpy(ast->exten, param->setup.exten, AST_MAX_EXTENSION); + if (param->setup.dialinginfo.id) + strncpy(ast->exten, param->setup.dialinginfo.id, AST_MAX_EXTENSION-1); + if (param->setup.context[0]) + strncpy(ast->context, param->setup.exten, AST_MAX_CONTEXT-1); if (param->setup.callerinfo.id[0]) ast->cid.cid_num = strdup(param->setup.callerinfo.id); if (param->setup.callerinfo.name[0]) @@ -422,7 +515,7 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet #warning todo #if 0 if (param->setup.redirinfo.id[0]) - ast->cid.cid_name = strdup(numberrize_callerinfo(param->setup.callerinfo.name, param->setup.callerinfo.ntype, configfile->prefix_nat, configfile->prefix_inter)); + ast->cid.cid_name = strdup(numberrize_callerinfo(param->setup.callerinfo.id, param->setup.callerinfo.ntype, configfile->prefix_nat, configfile->prefix_inter)); #endif switch (param->setup.callerinfo.present) { @@ -450,6 +543,8 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet ast->cid.cid_ton = 0; } ast->transfercapability = param->setup.capainfo.bearer_capa; + strcpy(call->dad, param->setup.dialinginfo.id); + strcpy(call->oad, numberrize_callerinfo(param->setup.callerinfo.id, param->setup.callerinfo.ntype, configfile->prefix_nat, configfile->prefix_inter)); /* configure channel */ #warning todo @@ -463,15 +558,7 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet /* change state */ call->state = CHAN_LCR_STATE_IN_SETUP; - /* send setup to asterisk */ - ast_pbx_start(ast); - - /* send setup acknowledge to lcr */ - memset(&newparam, 0, sizeof(union parameter)); - send_message(MESSAGE_OVERLAP, call->ref, &newparam); - - /* change state */ - call->state = CHAN_LCR_STATE_IN_DIALING; + lcr_start_pbx(call, ast, param->setup.dialinginfo.complete); } /* @@ -539,6 +626,9 @@ static void lcr_in_disconnect(struct chan_call *call, int message_type, union pa /* save cause */ call->cause = param->disconnectinfo.cause; call->location = param->disconnectinfo.location; +per option + +wenn setup raus geht, pointer /* if bridge, forward disconnect and return */ if (call->bridge_call) { @@ -595,6 +685,14 @@ static void lcr_in_information(struct chan_call *call, int message_type, union p char *p; if (!call->ast) return; + + /* pbx not started */ + if (!call->pbx_started) + { + strncat(ast->exten, param->information.id, AST_MAX_EXTENSION-1); + lcr_start_pbx(call, ast, param->information.complete); + return; + } /* copy digits */ p = param->information.id; @@ -996,6 +1094,7 @@ void close_socket(int sock) static void *chan_thread(void *arg) { int work; + int ret; ast_mutex_lock(&chan_lock); @@ -1004,7 +1103,7 @@ static void *chan_thread(void *arg) work = 0; /* handle socket */ - int ret = handle_socket(); + ret = handle_socket(); if (ret < 0) break; if (ret) @@ -1085,11 +1184,15 @@ static struct ast_channel *lcr_request(const char *type, int format, void *data, */ static int lcr_call(struct ast_channel *ast, char *dest, int timeout) { - struct chan_call *call=ast->tech_pvt; - - if (!call) return -1; + struct chan_call *call; ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } + #warning hier muss noch #if 0 @@ -1112,17 +1215,20 @@ static int lcr_call(struct ast_channel *ast, char *dest, int timeout) static int lcr_digit(struct ast_channel *ast, char digit) { - struct chan_call *call = ast->tech_pvt; + struct chan_call *call; union parameter newparam; char buf[]="x"; - if (!call) return -1; - /* only pass IA5 number space */ if (digit > 126 || digit < 32) return 0; ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } /* send information or queue them */ if (call->ref && call->state == CHAN_LCR_STATE_OUT_DIALING) @@ -1147,12 +1253,15 @@ static int lcr_digit(struct ast_channel *ast, char digit) static int lcr_answer(struct ast_channel *ast) { union parameter newparam; - struct chan_call *call = ast->tech_pvt; - - if (!call) return -1; + struct chan_call *call; ast_mutex_lock(&chan_lock); - + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } + /* copy connectinfo, if bridged */ if (call->bridge_call) memcpy(&call->connectinfo, &call->bridge_call->connectinfo, sizeof(struct connect_info)); @@ -1170,14 +1279,18 @@ static int lcr_answer(struct ast_channel *ast) static int lcr_hangup(struct ast_channel *ast) { union parameter newparam; - struct chan_call *call = ast->tech_pvt; - - if (!call) - return 0; + struct chan_call *call; ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } + /* disconnect asterisk, maybe not required */ ast->tech_pvt = NULL; + ast->fds[0] = -1; if (call->ref) { /* release */ @@ -1208,9 +1321,24 @@ static int lcr_hangup(struct ast_channel *ast) static int lcr_write(struct ast_channel *ast, struct ast_frame *f) { - struct chan_call *call = ast->tech_pvt; - if (!call) return 0; + struct chan_call *call; + unsigned char *buffer[1024], *s, *d = buffer; + ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } + if (call->bchannel && ((ii = f->samples))) + { + if (ii > sizeof(buffer)) + ii = buffer; + s = f->data; + for (i = 0, i < ii, i++) + *d++ = flip_bits[*s++]; + bchannel_transmit(call->bchannel, buffer, ii); + } ast_mutex_unlock(&chan_lock); return 0; } @@ -1218,22 +1346,50 @@ static int lcr_write(struct ast_channel *ast, struct ast_frame *f) static struct ast_frame *lcr_read(struct ast_channel *ast) { - struct chan_call *call = ast->tech_pvt; - if (!call) return 0; + struct chan_call *call; + int i, len; + unsigned char *p; + ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } + len = read(call->pipe[0], call->read_buf, sizeof(call->read_buf)); + if (len <= 0) + return NULL; + + p = call->read_buf; + for (i = 0, i < len, i++) { + *d = flip_bits[*d]; + d++; + } + + call->read_fr.frametype = AST_FRAME_SPEECH; +#warning todo + call->read_fr.subtype = AST_FORMAT_ALAW; + call->read_fr.datalen = len; + call->read_fr.samples = len; + call->read_fr.delivery = ast_tv(0,0); + call->read_fr.data = call->read_buf; ast_mutex_unlock(&chan_lock); - return 0; + + return &call->read_fr; } static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen) { - struct chan_call *call = ast->tech_pvt; union parameter newparam; int res = -1; - - if (!call) return -1; + struct chan_call *call; ast_mutex_lock(&chan_lock); + call = ast->tech_pvt; + if (!call) { + ast_mutex_unlock(&chan_lock); + return -1; + } switch (cond) { case AST_CONTROL_BUSY: @@ -1308,35 +1464,24 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, struct ast_frame *f; int bridge_id; -#if 0 - if (config nobridge) { - ast_log(LOG_NOTICE, "Falling back to Asterisk bridging\n"); - return AST_BRIDGE_FAILED; - } - - if (! (flags&AST_BRIDGE_DTMF_CHANNEL_0) ) - call1->ignore_dtmf=1; - - if (! (flags&AST_BRIDGE_DTMF_CHANNEL_1) ) - call2->ignore_dtmf=1; -#endif - /* join via dsp (if the channels are currently open) */ - bridge_id = new_bridge_id(); ast_mutex_lock(&chan_lock); + bridge_id = new_bridge_id(); call1 = ast1->tech_pvt; call2 = ast2->tech_pvt; - if (call1) + if (call1 && call2) { call1->bridge_id = bridge_id; if (call1->bchannel) bchannel_join(call1->bchannel, bridge_id); + call1->bridge_call = call2; } if (call2) { call2->bridge_id = bridge_id; if (call2->bchannel) bchannel_join(call2->bchannel, bridge_id); + call2->bridge_call = call1; } ast_mutex_unlock(&chan_lock); @@ -1388,12 +1533,18 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, call1->bridge_id = 0; if (call1->bchannel) bchannel_join(call1->bchannel, 0); + if (call1->bridge_call) + call1->bridge_call->bridge_call = NULL; + call1->bridge_call = NULL; } if (call2) { call2->bridge_id = 0; if (call2->bchannel) bchannel_join(call2->bchannel, 0); + if (call2->bridge_call) + call2->bridge_call->bridge_call = NULL; + call2->bridge_call = NULL; } ast_mutex_unlock(&chan_lock); @@ -1403,6 +1554,7 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, static struct ast_channel_tech lcr_tech = { .type=lcr_type, .description="Channel driver for connecting to Linux-Call-Router", +#warning todo .capabilities=AST_FORMAT_ALAW, .requester=lcr_request, .send_digit_begin=lcr_digit, @@ -1512,9 +1664,11 @@ static struct ast_cli_entry cli_port_unload = */ int load_module(void) { -// ast_mutex_init(&release_lock); + int i; -// lcr_cfg_update_ptp(); + for (i = 0, i < 256, i++) + flip_bits[i] = (i>>7) | ((i>>5)&2) | ((i>>3)&4) | ((i>>1)&8) + || = (i<<7) | ((i&2)<<5) | ((i&4)<<3) | ((i&8)<<1); ast_mutex_init(&chan_lock); diff --git a/mISDN.cpp b/mISDN.cpp index 6a9e569..b44049f 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -1746,11 +1746,8 @@ void PmISDN::bchannel_receive(iframe_t *frm) #endif { #ifndef OLD_MISDN -#ifdef SOCKET_MISDN - case DSP_TX_DATA: -#else +#ifndef SOCKET_MISDN case CMX_TX_DATA: -#endif if (!p_m_txdata) { /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */ @@ -1766,6 +1763,7 @@ void PmISDN::bchannel_receive(iframe_t *frm) record(data, len, 1); // from up break; #endif +#endif default: chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN); @@ -1779,6 +1777,23 @@ void PmISDN::bchannel_receive(iframe_t *frm) return; } #ifdef SOCKET_MISDN + if (hh->prim == PH_DATA_REQ || hh->prim == DL_DATA_REQ) + { + if (!p_m_txdata) + { + /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */ + PDEBUG(DEBUG_BCHANNEL, "PmISDN(%s) ignoring tx data, because 'txdata' is turned off\n", p_name); + return; + } + /* see below (same condition) */ + if (p_state!=PORT_STATE_CONNECT + && !p_m_mISDNport->tones) + return; +// printf(".");fflush(stdout);return; + if (p_record) + record(data, len, 1); // from up + return; + } if (hh->prim != PH_DATA_IND && hh->prim != DL_DATA_IND) { PERROR("Bchannel received unknown primitve: 0x%x\n", hh->prim); diff --git a/message.h b/message.h index f1b4e30..b248f6a 100644 --- a/message.h +++ b/message.h @@ -257,7 +257,7 @@ struct message_setup { struct redir_info redirinfo; /* info on redirection (to the calling user) */ struct capa_info capainfo; /* info on l2,l3 capability */ struct useruser_info useruser; /* user-user */ - char exten[128]; /* asterisk extension */ + char context[128]; /* asterisk context */ }; /* call-info structure PARK */ diff --git a/route.c b/route.c index f4dcd26..8f1e3bb 100644 --- a/route.c +++ b/route.c @@ -231,9 +231,12 @@ struct param_defs param_defs[] = { { PARAM_APPLICATION, "application",PARAM_TYPE_STRING, "application=", "Name of remote application to make call to."}, + { PARAM_CONTEXT, + "exten", PARAM_TYPE_STRING, + "exten=", "Give context parameter to the remote application."}, { PARAM_EXTEN, "exten", PARAM_TYPE_STRING, - "exten=", "Give exten parameter to the remote application."}, + "exten=", "Give exten parameter to the remote application. (overrides dialed number)"}, { 0, NULL, 0, NULL, NULL} }; @@ -252,7 +255,7 @@ struct action_defs action_defs[] = { "Same as 'extern'"}, { ACTION_REMOTE, "remote", &EndpointAppPBX::action_init_remote, &EndpointAppPBX::action_dialing_remote, &EndpointAppPBX::action_hangup_call, - PARAM_CONNECT | PARAM_APPLICATION | PARAM_EXTEN | PARAM_TIMEOUT, + PARAM_CONNECT | PARAM_APPLICATION | PARAM_CONTEXT | PARAM_EXTEN | PARAM_TIMEOUT, "Call is routed to Remote application, like Asterisk."}, { ACTION_VBOX_RECORD, "vbox-record",&EndpointAppPBX::action_init_call, &EndpointAppPBX::action_dialing_vbox_record, &EndpointAppPBX::action_hangup_call, diff --git a/route.h b/route.h index 551363a..9549f49 100644 --- a/route.h +++ b/route.h @@ -136,7 +136,8 @@ enum { /* how to parse text file during startup */ #define PARAM_NOPASSWORD (1LL<<42) #define PARAM_STRIP (1LL<<43) #define PARAM_APPLICATION (1LL<<44) -#define PARAM_EXTEN (1LL<<45) +#define PARAM_CONTEXT (1LL<<45) +#define PARAM_EXTEN (1LL<<46) /* action index -- 2.13.6