Interface to mISDN. More...
#include <mISDNuser/suppserv.h>
Go to the source code of this file.
Interface to mISDN.
Definition in file isdn_lib.h.
#define MAX_BCHANS 31 |
Definition at line 76 of file isdn_lib.h.
Referenced by empty_chan_in_stack(), find_free_chan_in_stack(), misdn_lib_get_free_bc(), set_chan_in_stack(), and stack_init().
#define PRI_TRANS_CAP_3_1K_AUDIO 0x10 |
Definition at line 668 of file isdn_lib.h.
#define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 669 of file isdn_lib.h.
#define PRI_TRANS_CAP_DIGITAL 0x08 |
Definition at line 666 of file isdn_lib.h.
Referenced by dahdi_call().
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 667 of file isdn_lib.h.
#define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 665 of file isdn_lib.h.
anonymous enum |
Definition at line 169 of file isdn_lib.h.
{ /* bearer capability */ INFO_CAPABILITY_SPEECH=0, INFO_CAPABILITY_AUDIO_3_1K=0x10 , INFO_CAPABILITY_AUDIO_7K=0x11 , INFO_CAPABILITY_VIDEO =0x18, INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8, INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09, INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES };
anonymous enum |
Definition at line 179 of file isdn_lib.h.
{ /* progress indicators */ INFO_PI_CALL_NOT_E2E_ISDN =0x01, INFO_PI_CALLED_NOT_ISDN =0x02, INFO_PI_CALLER_NOT_ISDN =0x03, INFO_PI_CALLER_RETURNED_TO_ISDN =0x04, INFO_PI_INBAND_AVAILABLE =0x08, INFO_PI_DELAY_AT_INTERF =0x0a, INFO_PI_INTERWORKING_WITH_PUBLIC =0x10, INFO_PI_INTERWORKING_NO_RELEASE =0x11, INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12, INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13 };
anonymous enum |
Definition at line 192 of file isdn_lib.h.
{ /*CODECS*/ INFO_CODEC_ULAW=2, INFO_CODEC_ALAW=3 };
enum bchannel_state |
BCHAN_CLEANED | |
BCHAN_EMPTY | |
BCHAN_SETUP | |
BCHAN_SETUPED | |
BCHAN_ACTIVE | |
BCHAN_ACTIVATED | |
BCHAN_BRIDGE | |
BCHAN_BRIDGED | |
BCHAN_RELEASE | |
BCHAN_RELEASED | |
BCHAN_CLEAN | |
BCHAN_CLEAN_REQUEST | |
BCHAN_ERROR |
Definition at line 78 of file isdn_lib.h.
enum event_e |
Definition at line 118 of file isdn_lib.h.
{ EVENT_NOTHING, EVENT_TONE_GENERATE, EVENT_BCHAN_DATA, EVENT_BCHAN_ACTIVATED, EVENT_BCHAN_ERROR, EVENT_CLEANUP, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_SETUP, EVENT_ALERTING, EVENT_CONNECT, EVENT_SETUP_ACKNOWLEDGE, EVENT_CONNECT_ACKNOWLEDGE , EVENT_USER_INFORMATION, EVENT_SUSPEND_REJECT, EVENT_RESUME_REJECT, EVENT_HOLD, EVENT_SUSPEND, EVENT_RESUME, EVENT_HOLD_ACKNOWLEDGE, EVENT_SUSPEND_ACKNOWLEDGE, EVENT_RESUME_ACKNOWLEDGE, EVENT_HOLD_REJECT, EVENT_RETRIEVE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_RETRIEVE_REJECT, EVENT_DISCONNECT, EVENT_RESTART, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_FACILITY, EVENT_NOTIFY, EVENT_STATUS_ENQUIRY, EVENT_INFORMATION, EVENT_STATUS, EVENT_TIMEOUT, EVENT_DTMF_TONE, EVENT_NEW_L3ID, EVENT_NEW_BC, EVENT_PORT_ALARM, EVENT_NEW_CHANNEL, EVENT_UNKNOWN };
enum event_response_e |
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE | |
RESPONSE_IGNORE_SETUP | |
RESPONSE_RELEASE_SETUP | |
RESPONSE_ERR | |
RESPONSE_OK |
Definition at line 109 of file isdn_lib.h.
enum ie_name_e |
enum layer_e |
enum misdn_err_e |
enum mISDN_NUMBER_PLAN |
NUMPLAN_UNINITIALIZED | |
NUMPLAN_INTERNATIONAL | |
NUMPLAN_NATIONAL | |
NUMPLAN_SUBSCRIBER | |
NUMPLAN_UNKNOWN |
Definition at line 100 of file isdn_lib.h.
{ NUMPLAN_UNINITIALIZED=-1, NUMPLAN_INTERNATIONAL=0x1, NUMPLAN_NATIONAL=0x2, NUMPLAN_SUBSCRIBER=0x4, NUMPLAN_UNKNOWN=0x0 };
enum tone_e |
For initialization usage end of init usage
TONE_NONE | |
TONE_DIAL | |
TONE_ALERTING | |
TONE_FAR_ALERTING | |
TONE_BUSY | |
TONE_HANGUP | |
TONE_CUSTOM | |
TONE_FILE |
Definition at line 63 of file isdn_lib.h.
char* bc_state2str | ( | enum bchannel_state | state | ) |
Definition at line 597 of file isdn_lib.c.
References BCHAN_ACTIVATED, BCHAN_ACTIVE, BCHAN_BRIDGE, BCHAN_BRIDGED, BCHAN_CLEAN, BCHAN_CLEAN_REQUEST, BCHAN_CLEANED, BCHAN_EMPTY, BCHAN_ERROR, BCHAN_RELEASE, BCHAN_RELEASED, BCHAN_SETUP, BCHAN_SETUPED, and s.
Referenced by bc_next_state_change(), bc_state_change(), cb_events(), handle_bchan(), handle_err(), misdn_lib_send_event(), misdn_lib_split_bridge(), misdn_lib_tx2misdn_frm(), print_bc_info(), and setup_bc().
{ 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_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, {"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 | ||
) |
Definition at line 626 of file isdn_lib.c.
References misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_EMPTY, cb_log, misdn_bchannel::conf_id, misdn_bchannel::l3_id, misdn_join_conf(), misdn_bchannel::next_bc_state, and misdn_bchannel::port.
Referenced by clean_up_bc(), handle_bchan(), handle_frm(), init_bc(), manager_bchannel_deactivate(), misdn_join_conf(), misdn_lib_send_event(), misdn_split_conf(), and setup_bc().
{ cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", bc->l3_id, 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 get_show_stack_details | ( | int | port, |
char * | buf | ||
) |
Definition at line 170 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::l1link, misdn_stack::l2link, misdn_stack::next, misdn_stack::nt, misdn_stack::port, and misdn_stack::ptp.
Referenced by handle_cli_misdn_show_port(), and handle_cli_misdn_show_stacks().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) break; } if (stack) { sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d", stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP", stack->l2link ? "UP" : "DOWN", stack->l1link ? "UP" : "DOWN", stack->blocked); } else { buf[0]=0; } }
void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4387 of file isdn_lib.c.
References manager_ph_control().
Referenced by process_ast_dsp().
{ manager_ph_control(bc, DTMF_TONE_STOP, 0); }
void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4375 of file isdn_lib.c.
References misdn_bchannel::ec_enable, manager_ec_disable(), and manager_ec_enable().
Referenced by process_ast_dsp().
{ #ifdef MISDN_1_2 if (*bc->pipeline) #else if (bc->ec_enable) #endif manager_ec_enable(bc); else manager_ec_disable(bc); }
void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4365 of file isdn_lib.c.
References manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
{ manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); }
void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4370 of file isdn_lib.c.
References manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
{ manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); }
void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4248 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, buf, cb_log, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.
Referenced by setup_bc().
{ char buf[128]; struct misdn_stack *stack=get_stack_by_bc(bc); if (!stack) { cb_log(0, bc->port, "bchannel_activate: Stack not found !"); return ; } /* we must activate if we are deactivated */ clear_ibuffer(bc->astbuf); cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); return ; }
void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4270 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_bchannel::bc_state, bc_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_RELEASE, buf, cb_log, misdn_bchannel::conf_id, misdn_bchannel::generate_tone, get_stack_by_bc(), misdn_stack::midev, misdn_split_conf(), misdn_stack::port, and misdn_bchannel::port.
Referenced by clean_up_bc().
{ struct misdn_stack *stack=get_stack_by_bc(bc); iframe_t dact; char buf[128]; 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); bc->generate_tone=0; dact.prim = DL_RELEASE | REQUEST; dact.addr = bc->addr | FLG_MSG_DOWN; dact.dinfo = 0; dact.len = 0; mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); clear_ibuffer(bc->astbuf); bc_state_change(bc,BCHAN_RELEASE); return; }
void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4603 of file isdn_lib.c.
References misdn_bchannel::capability, cb_log, misdn_bchannel::ec_enable, ECHOCAN_OFF, get_stack_by_bc(), manager_ph_control(), manager_ph_control_block(), misdn_cap_is_speech(), and misdn_stack::port.
Referenced by clean_up_bc(), handle_cli_misdn_toggle_echocancel(), and isdn_lib_update_ec().
{ struct misdn_stack *stack=get_stack_by_bc(bc); cb_log(4, stack?stack->port:0," --> ec_disable\n"); if (!misdn_cap_is_speech(bc->capability)) { cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); return; } #ifdef MISDN_1_2 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); #else if ( ! bc->ec_enable) { cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); manager_ph_control(bc, ECHOCAN_OFF, 0); } #endif }
void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4554 of file isdn_lib.c.
References misdn_bchannel::capability, cb_log, misdn_bchannel::ec_deftaps, misdn_bchannel::ec_enable, ECHOCAN_ON, get_stack_by_bc(), manager_ph_control_block(), misdn_cap_is_speech(), and misdn_stack::port.
Referenced by handle_cli_misdn_toggle_echocancel(), handle_event(), isdn_lib_update_ec(), and misdn_lib_send_event().
{ struct misdn_stack *stack=get_stack_by_bc(bc); cb_log(4, stack?stack->port:0,"ec_enable\n"); if (!misdn_cap_is_speech(bc->capability)) { cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); } else { #ifdef MISDN_1_2 if (*bc->pipeline) { cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); } #else int ec_arr[2]; if (bc->ec_enable) { cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); switch (bc->ec_deftaps) { case 4: case 8: case 16: case 32: case 64: case 128: case 256: case 512: case 1024: cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); break; default: cb_log(0, stack->port, "Taps should be power of 2\n"); bc->ec_deftaps=128; } ec_arr[0]=bc->ec_deftaps; ec_arr[1]=0; manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); } #endif } }
char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 4243 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
{ return isdn_get_info(msgs_g , event, 0); }
void manager_ph_control | ( | struct misdn_bchannel * | bc, |
int | c1, | ||
int | c2 | ||
) |
Definition at line 4344 of file isdn_lib.c.
References misdn_bchannel::addr, cb_log, misdn_lib::midev, and misdn_bchannel::port.
Referenced by handle_event(), isdn_lib_stop_dtmf(), isdn_lib_update_rxgain(), isdn_lib_update_txgain(), manager_ec_disable(), misdn_join_conf(), misdn_lib_echo(), misdn_lib_send_event(), misdn_lib_send_tone(), and misdn_split_conf().
{ unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ unsigned int *d = (unsigned int*)&ctrl->data.p; /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); ctrl->prim = PH_CONTROL | REQUEST; ctrl->addr = bc->addr | FLG_MSG_DOWN; ctrl->dinfo = 0; ctrl->len = sizeof(unsigned int)*2; *d++ = c1; *d++ = c2; mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); }
int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 438 of file isdn_lib.c.
References INFO_CAPABILITY_DIGITAL_RESTRICTED, and INFO_CAPABILITY_DIGITAL_UNRESTRICTED.
Referenced by cb_events(), handle_bchan(), handle_event(), manager_ec_disable(), manager_ec_enable(), misdn_lib_send_event(), misdn_lib_tx2misdn_frm(), and misdn_write().
{ if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; return 0; }
void misdn_dump_chanlist | ( | void | ) |
Definition at line 476 of file isdn_lib.c.
References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.
Referenced by handle_cli_misdn_show_channels().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { dump_chan_list(stack); } }
int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 446 of file isdn_lib.c.
References misdn_bchannel::early_bconnect, INFO_PI_CALL_NOT_E2E_ISDN, INFO_PI_CALLED_NOT_ISDN, INFO_PI_INBAND_AVAILABLE, and misdn_bchannel::progress_indicator.
Referenced by cb_events(), and misdn_indication().
{ if (!bc->early_bconnect) { /* We have opted to never receive any available inband recorded messages */ return 0; } switch (bc->progress_indicator) { case INFO_PI_INBAND_AVAILABLE: case INFO_PI_CALL_NOT_E2E_ISDN: case INFO_PI_CALLED_NOT_ISDN: return 1; default: return 0; } return 0; }
void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, |
struct misdn_bchannel * | bc2 | ||
) |
Definition at line 4653 of file isdn_lib.c.
References bc_next_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, misdn_join_conf(), misdn_bchannel::pid, and misdn_bchannel::port.
Referenced by misdn_bridge().
{ int conf_id = bc1->pid + 1; struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL }; struct misdn_bchannel **bc; cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); for (bc=bc_list; *bc; bc++) { (*bc)->conf_id=conf_id; cb_log(4, (*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_destroy | ( | void | ) |
Definition at line 4210 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::b_num, misdn_stack::bc, buf, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, misdn_lib::midev, misdn_stack::midev, MISDN_INITIALIZED, misdn_stack::next, misdn_stack::port, stack_destroy(), misdn_lib::stack_list, and te_lib_destroy().
Referenced by unload_module().
{ struct misdn_stack *help; int i; for ( help=glob_mgr->stack_list; help; help=help->next ) { for(i=0;i<=help->b_num; i++) { char buf[1024]; mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); help->bc[i].addr = 0; } cb_log (1, help->port, "Destroying this port.\n"); stack_destroy(help); } if (global_state == MISDN_INITIALIZED) { cb_log(4, 0, "Killing Handler Thread\n"); if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { cb_log(4, 0, "Joining Handler Thread\n"); pthread_join(glob_mgr->event_handler_thread, NULL); } cb_log(4, 0, "Killing Main Thread\n"); if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { cb_log(4, 0, "Joining Main Thread\n"); pthread_join(glob_mgr->event_thread, NULL); } } cb_log(1, 0, "Closing mISDN device\n"); te_lib_destroy(glob_mgr->midev); }
void misdn_lib_echo | ( | struct misdn_bchannel * | bc, |
int | onoff | ||
) |
Definition at line 4696 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
{ cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); }
struct misdn_bchannel* misdn_lib_find_held_bc | ( | int | port, |
int | l3_id | ||
) | [read] |
Find a held call's B channel record.
port | Port the call is on. |
l3_id | mISDN Layer 3 ID of held call. |
Definition at line 4506 of file isdn_lib.c.
References misdn_stack::bc, get_misdn_stack(), misdn_stack::next, misdn_stack::port, and stack_holder_find().
Referenced by misdn_hangup().
{ struct misdn_bchannel *bc; struct misdn_stack *stack; bc = NULL; for (stack = get_misdn_stack(); stack; stack = stack->next) { if (stack->port == port) { bc = stack_holder_find(stack, l3_id); break; } } return bc; }
struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, |
int | channel, | ||
int | inout, | ||
int | dec | ||
) | [read] |
Definition at line 3249 of file isdn_lib.c.
References misdn_stack::b_num, misdn_stack::bc, misdn_stack::blocked, cb_log, misdn_bchannel::channel, misdn_bchannel::cw, misdn_bchannel::dec, MAX_BCHANS, misdn_stack::next, misdn_stack::port, prepare_bc(), misdn_stack::pri, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, misdn_stack::st_lock, misdn_lib::stack_list, and test_inuse().
Referenced by handle_cr(), handle_event_nt(), and misdn_request().
{ struct misdn_stack *stack; int i; if (channel < 0 || channel > MAX_BCHANS) { cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); return NULL; } for (stack=glob_mgr->stack_list; stack; stack=stack->next) { if (stack->port == port) { int maxnum; if (stack->blocked) { cb_log(0,port,"Port is blocked\n"); return NULL; } pthread_mutex_lock(&stack->st_lock); if (channel > 0) { if (channel <= stack->b_num) { for (i = 0; i < stack->b_num; i++) { if ( stack->bc[i].channel == channel) { if (test_inuse(&stack->bc[i])) { pthread_mutex_unlock(&stack->st_lock); cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); return NULL; } else { prepare_bc(&stack->bc[i], channel); pthread_mutex_unlock(&stack->st_lock); return &stack->bc[i]; } } } } else { pthread_mutex_unlock(&stack->st_lock); cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); return NULL; } } maxnum = inout && !stack->pri && !stack->ptp ? stack->b_num + 1 : stack->b_num; if (dec) { for (i = maxnum-1; i>=0; i--) { if (!test_inuse(&stack->bc[i])) { /* 3. channel on bri means CW*/ if (!stack->pri && i==stack->b_num) stack->bc[i].cw=1; prepare_bc(&stack->bc[i], channel); stack->bc[i].dec=1; pthread_mutex_unlock(&stack->st_lock); return &stack->bc[i]; } } } else { for (i = 0; i <maxnum; i++) { if (!test_inuse(&stack->bc[i])) { /* 3. channel on bri means CW*/ if (!stack->pri && i==stack->b_num) stack->bc[i].cw=1; prepare_bc(&stack->bc[i], channel); pthread_mutex_unlock(&stack->st_lock); return &stack->bc[i]; } } } pthread_mutex_unlock(&stack->st_lock); cb_log(1,port,"There is no free channel on port (%d)\n",port); return NULL; } } cb_log(0,port,"Port is not configured (%d)\n",port); return NULL; }
int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 139 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { if (stack->pri) return 30; else return 2; } } return -1; }
int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1786 of file isdn_lib.c.
References misdn_stack::l2link, misdn_lib_get_l1_down(), misdn_lib_get_l2_down(), misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.
Referenced by handle_cli_misdn_port_down().
{ /* Pull Down L1 */ struct misdn_stack *stack; for (stack=glob_mgr->stack_list; stack; stack=stack->next) { if (stack->port == port) { if (stack->l2link) misdn_lib_get_l2_down(stack); misdn_lib_get_l1_down(stack); return 0; } } return 0; }
int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3807 of file isdn_lib.c.
References misdn_lib::activatequeue, cb_log, find_stack_by_port(), misdn_lib::new_msg, and misdn_stack::upper_id.
{ msg_t *msg=alloc_msg(MAX_MSG_SIZE); iframe_t *frm; struct misdn_stack *stack=find_stack_by_port(port); if (!msg) { cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n"); return -1; } frm=(iframe_t*)msg->data; if (!stack ) { cb_log(0, port, "There is no Stack for this port.\n"); return -1; } /* activate bchannel */ frm->prim = CC_STATUS_ENQUIRY | REQUEST; frm->addr = stack->upper_id| FLG_MSG_DOWN; frm->dinfo = 0; frm->len = 0; msg_queue_tail(&glob_mgr->activatequeue, msg); sem_post(&glob_mgr->new_msg); return 0; }
int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1764 of file isdn_lib.c.
References misdn_stack::l1link, misdn_stack::l2link, misdn_lib_get_l1_up(), misdn_lib_get_l2_up(), misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.
Referenced by handle_cli_misdn_port_up(), and misdn_check_l2l1().
{ /* Pull Up L1 */ struct misdn_stack *stack; for (stack=glob_mgr->stack_list; stack; stack=stack->next) { if (stack->port == port) { if (!stack->l1link) misdn_lib_get_l1_up(stack); if (!stack->l2link) misdn_lib_get_l2_up(stack); return 0; } } return 0; }
int misdn_lib_init | ( | char * | portlist, |
struct misdn_lib_iface * | iface, | ||
void * | user_data | ||
) |
Definition at line 4102 of file isdn_lib.c.
References misdn_lib::activatequeue, misdn_stack::b_num, misdn_stack::bc, calloc, misdn_lib_iface::cb_event, cb_event, misdn_lib_iface::cb_jb_empty, cb_jb_empty, misdn_lib_iface::cb_log, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, first, flip_buf_bits(), init_bc(), init_flip_bits(), manager_event_handler(), misdn_stack::midev, misdn_lib::midev, MISDN_INITIALIZED, misdn_lib_isdn_event_catcher(), misdn_lib_nt_debug_init(), misdn_lib::new_msg, misdn_stack::next, pthread_create, ptp, stack_init(), misdn_lib::stack_list, and te_lib_init().
Referenced by load_module().
{ struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); char *tok, *tokb; char plist[1024]; int midev; int port_count=0; cb_log = iface->cb_log; cb_event = iface->cb_event; cb_jb_empty = iface->cb_jb_empty; glob_mgr = mgr; msg_init(); misdn_lib_nt_debug_init(0,NULL); if (!portlist || (*portlist == 0) ) return 1; init_flip_bits(); { strncpy(plist,portlist, 1024); plist[1023] = 0; } memcpy(tone_425_flip,tone_425,TONE_425_SIZE); flip_buf_bits(tone_425_flip,TONE_425_SIZE); memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); midev=te_lib_init(); mgr->midev=midev; port_count=mISDN_get_stack_count(midev); msg_queue_init(&mgr->activatequeue); if (sem_init(&mgr->new_msg, 1, 0)<0) sem_init(&mgr->new_msg, 0, 0); for (tok=strtok_r(plist," ,",&tokb ); tok; tok=strtok_r(NULL," ,",&tokb)) { int port = atoi(tok); struct misdn_stack *stack; static int first=1; int ptp=0; if (strstr(tok, "ptp")) ptp=1; if (port > port_count) { cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); exit(1); } stack=stack_init(midev, port, ptp); if (!stack) { perror("stack_init"); exit(1); } { int i; for(i=0;i<=stack->b_num; i++) { int r; if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { cb_log(0, port, "Got Err @ init_bc :%d\n",r); exit(1); } } } if (stack && first) { mgr->stack_list=stack; first=0; continue; } if (stack) { struct misdn_stack * help; for ( help=mgr->stack_list; help; help=help->next ) if (help->next == NULL) break; help->next=stack; } } if (sem_init(&handler_started, 1, 0)<0) sem_init(&handler_started, 0, 0); cb_log(8, 0, "Starting Event Handler\n"); pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); sem_wait(&handler_started) ; cb_log(8, 0, "Starting Event Catcher\n"); pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); cb_log(8, 0, "Event Catcher started\n"); global_state= MISDN_INITIALIZED; return (mgr == NULL); }
int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 119 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { return stack->blocked; } } return -1; }
int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 130 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::ptp.
Referenced by cb_events(), and do_immediate_setup().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) return stack->ptp; } return -1; }
void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 3088 of file isdn_lib.c.
References cb_log, misdn_stack::l1link, misdn_lib_get_l1_up(), misdn_lib_get_l2_up(), misdn_lib_get_short_status(), misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.
Referenced by misdn_l1_task().
{ struct misdn_stack *stack; for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) ; if (stack) { cb_log(4, port, "Checking L1 State\n"); if (!stack->l1link) { cb_log(4, port, "L1 State Down, trying to get it up again\n"); misdn_lib_get_short_status(stack); misdn_lib_get_l1_up(stack); misdn_lib_get_l2_up(stack); } } }
void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3371 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::b_stid, bearer2str(), misdn_bchannel::cad, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::cpnnumplan, misdn_bchannel::dnumplan, fac2str(), misdn_bchannel::fac_in, misdn_bchannel::fac_out, get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::info_dad, misdn_bchannel::keypad, misdn_bchannel::l3_id, misdn_bchannel::layer_id, misdn_bchannel::mode, misdn_stack::nt, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_stack::port, misdn_bchannel::pres, misdn_bchannel::progress_indicator, misdn_bchannel::rad, misdn_bchannel::rate, misdn_bchannel::rnumplan, misdn_bchannel::screen, misdn_bchannel::sending_complete, misdn_bchannel::stack_holder, misdn_bchannel::urate, and misdn_bchannel::user1.
Referenced by cb_events(), and misdn_lib_send_event().
{ struct misdn_stack *stack; if (!bc) return; stack = get_stack_by_bc(bc); if (!stack) return; cb_log(2, stack->port, " --> channel:%d mode:%s cause:%d ocause:%d rad:%s cad:%s\n", bc->channel, stack->nt?"NT":"TE", bc->cause, bc->out_cause, bc->rad, bc->cad); cb_log(2, stack->port, " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", bc->info_dad, bc->onumplan>=0?'0'+bc->onumplan:' ', bc->dnumplan>=0?'0'+bc->dnumplan:' ', bc->rnumplan>=0?'0'+bc->rnumplan:' ', bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' ); cb_log(3, stack->port, " --> caps:%s pi:%x keypad:%s sending_complete:%d\n", bearer2str(bc->capability),bc->progress_indicator, bc->keypad, bc->sending_complete); cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", bc->screen, bc->pres); cb_log(4, stack->port, " --> addr:%x l3id:%x b_stid:%x layer_id:%x\n", bc->addr, bc->l3_id, bc->b_stid, bc->layer_id); cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); }
int misdn_lib_maxports_get | ( | void | ) |
Definition at line 4053 of file isdn_lib.c.
Referenced by load_module().
{ /* BE AWARE WE HAVE NO cb_log() HERE! */ int i = mISDN_open(); int max=0; if (i<0) return -1; max = mISDN_get_stack_count(i); mISDN_close(i); return max; }
void misdn_lib_nt_debug_init | ( | int | flags, |
char * | file | ||
) |
Definition at line 4083 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
{ static int init=0; char *f; if (!flags) f=NULL; else f=file; if (!init) { debug_init( flags , f, f, f); init=1; } else { debug_close(); debug_init( flags , f, f, f); } }
void misdn_lib_nt_keepcalls | ( | int | kc | ) |
Definition at line 4071 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::nst.
Referenced by load_module().
{ #ifdef FEATURE_NET_KEEPCALLS if (kc) { struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { stack->nst.feature |= FEATURE_NET_KEEPCALLS; } } #endif }
int misdn_lib_pid_restart | ( | int | pid | ) |
Definition at line 3862 of file isdn_lib.c.
References manager_clean_bc(), and manager_find_bc_by_pid().
Referenced by handle_cli_misdn_restart_pid().
{ struct misdn_bchannel *bc=manager_find_bc_by_pid(pid); if (bc) { manager_clean_bc(bc); } return 0; }
int misdn_lib_port_block | ( | int | port | ) |
Definition at line 93 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by cb_events(), and handle_cli_misdn_port_block().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { stack->blocked=1; return 0; } } return -1; }
int misdn_lib_port_is_nt | ( | int | port | ) |
Definition at line 67 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::nt, and misdn_stack::port.
Referenced by handle_cli_misdn_send_facility().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { return stack->nt; } } return -1; }
int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 55 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_new(), test_inuse(), and update_name().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { return stack->pri; } } return -1; }
int misdn_lib_port_restart | ( | int | port | ) |
Definition at line 3912 of file isdn_lib.c.
References misdn_lib::activatequeue, cb_log, clear_l3(), find_stack_by_port(), misdn_lib_reinit_nt_stack(), misdn_lib::new_msg, misdn_stack::nt, misdn_stack::port, and misdn_stack::upper_id.
Referenced by handle_cli_misdn_restart_port().
{ struct misdn_stack *stack=find_stack_by_port(port); cb_log(0, port, "Restarting this port.\n"); if (stack) { cb_log(0, port, "Stack:%p\n",stack); clear_l3(stack); { msg_t *msg=alloc_msg(MAX_MSG_SIZE); iframe_t *frm; if (!msg) { cb_log(0, port, "port_restart: alloc_msg failed\n"); return -1; } frm=(iframe_t*)msg->data; /* we must activate if we are deactivated */ /* activate bchannel */ frm->prim = DL_RELEASE | REQUEST; frm->addr = stack->upper_id | FLG_MSG_DOWN; frm->dinfo = 0; frm->len = 0; msg_queue_tail(&glob_mgr->activatequeue, msg); sem_post(&glob_mgr->new_msg); } if (stack->nt) misdn_lib_reinit_nt_stack(stack->port); } return 0; }
int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 106 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by handle_cli_misdn_port_unblock().
{ struct misdn_stack *stack=get_misdn_stack(); for ( ; stack; stack=stack->next) { if (stack->port == port) { stack->blocked=0; return 0; } } return -1; }
int misdn_lib_port_up | ( | int | port, |
int | notcheck | ||
) |
Definition at line 1802 of file isdn_lib.c.
References misdn_stack::blocked, cb_log, misdn_stack::l1link, misdn_stack::l2link, misdn_stack::next, misdn_stack::port, misdn_stack::ptp, and misdn_lib::stack_list.
Referenced by misdn_check_l2l1(), and misdn_request().
{ struct misdn_stack *stack; for (stack=glob_mgr->stack_list; stack; stack=stack->next) { if (stack->port == port) { if (stack->blocked) { cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); return -1; } if (stack->ptp ) { if (stack->l1link && stack->l2link) { return 1; } else { cb_log(1,port, "Port Down L2:%d L1:%d\n", stack->l2link, stack->l1link); return 0; } } else { if ( !check || stack->l1link ) return 1; else { cb_log(1,port, "Port down PMP\n"); return 0; } } } } return -1; }
void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4704 of file isdn_lib.c.
References misdn_stack::blocked, misdn_stack::d_stid, find_stack_by_port(), handle_event_nt(), misdn_stack::l2link, misdn_stack::lower_id, misdn_stack::mgr, misdn_lib::midev, misdn_lib_get_l1_up(), misdn_lib_get_l2_up(), misdn_stack::nst, misdn_stack::port, misdn_stack::pri, misdn_stack::ptp, and misdn_stack::upper_id.
Referenced by handle_event_nt(), and misdn_lib_port_restart().
{ struct misdn_stack *stack=find_stack_by_port(port); if (stack) { stack->l2link=0; stack->blocked=0; cleanup_Isdnl3(&stack->nst); cleanup_Isdnl2(&stack->nst); memset(&stack->nst, 0, sizeof(net_stack_t)); memset(&stack->mgr, 0, sizeof(manager_t)); stack->mgr.nst = &stack->nst; stack->nst.manager = &stack->mgr; stack->nst.l3_manager = handle_event_nt; stack->nst.device = glob_mgr->midev; stack->nst.cardnr = port; stack->nst.d_stid = stack->d_stid; stack->nst.feature = FEATURE_NET_HOLD; if (stack->ptp) stack->nst.feature |= FEATURE_NET_PTP; if (stack->pri) stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; stack->nst.l1_id = stack->lower_id; stack->nst.l2_id = stack->upper_id; msg_queue_init(&stack->nst.down_queue); Isdnl2Init(&stack->nst); Isdnl3Init(&stack->nst); if (!stack->ptp) misdn_lib_get_l1_up(stack); misdn_lib_get_l2_up(stack); } }
void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1742 of file isdn_lib.c.
References cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), empty_chan_in_stack(), get_stack_by_bc(), and misdn_bchannel::in_use.
Referenced by misdn_hangup().
{ int channel; struct misdn_stack *stack=get_stack_by_bc(bc); if (!stack) { cb_log(1,0,"misdn_release: No Stack found\n"); return; } channel = bc->channel; empty_bc(bc); clean_up_bc(bc); if (channel > 0) { empty_chan_in_stack(stack, channel); } bc->in_use=0; }
int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, |
enum event_e | event | ||
) |
Queue Event
Definition at line 3422 of file isdn_lib.c.
References misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_BRIDGED, BCHAN_CLEANED, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::channel_found, misdn_bchannel::channel_preselected, clean_up_bc(), misdn_bchannel::conf_id, create_process(), misdn_bchannel::crypt_key, misdn_bchannel::dad, misdn_bchannel::dnumplan, misdn_stack::downqueue, empty_bc(), empty_chan_in_stack(), ENOCHAN, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_HOLD_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), msg, msgs_g, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_bchannel::nt, misdn_stack::nt, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, RETURN, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.
Referenced by cb_events(), do_immediate_setup(), handle_cli_misdn_send_display(), handle_cli_misdn_send_facility(), handle_event(), handle_event_nt(), handle_frm(), handle_l1(), misdn_answer(), misdn_call(), misdn_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_lib_send_restart(), misdn_overlap_dial_task(), misdn_send_text(), start_pbx(), and wait_for_digits().
{ msg_t *msg; int retval=0; struct misdn_stack *stack; struct misdn_bchannel *held_bc; if (!bc) RETURN(-1,OUT_POST_UNLOCK); stack = get_stack_by_bc(bc); if (!stack) { cb_log(0,bc->port,"SENDEVENT: no Stack for event:%s oad:%s dad:%s \n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad); RETURN(-1,OUT); } misdn_send_lock(bc); cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->upperid:%x\n",stack->nt, stack->upper_id); if ( stack->nt && !stack->l1link) { /** Queue Event **/ bc->evq=event; cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); misdn_lib_get_l1_up(stack); RETURN(0,OUT); } cb_log(1, stack->port, "I SEND:%s oad:%s dad:%s pid:%d\n", isdn_get_info(msgs_g, event, 0), bc->oad, bc->dad, bc->pid); cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); misdn_lib_log_ies(bc); switch (event) { case EVENT_SETUP: if (create_process(glob_mgr->midev, bc)<0) { cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); RETURN(-ENOCHAN,OUT); } break; case EVENT_PROGRESS: case EVENT_ALERTING: case EVENT_PROCEEDING: case EVENT_SETUP_ACKNOWLEDGE: case EVENT_CONNECT: if (!stack->nt) break; case EVENT_RETRIEVE_ACKNOWLEDGE: if (stack->nt) { if (bc->channel <=0 ) { /* else we have the channel already */ if (find_free_chan_in_stack(stack, bc, 0, 0)<0) { cb_log(0, stack->port, " No free channel at the moment\n"); /*FIXME: add disconnect*/ RETURN(-ENOCHAN,OUT); } } /* Its that i generate channels */ } retval=setup_bc(bc); if (retval == -EINVAL) { cb_log(0,bc->port,"send_event: setup_bc failed\n"); } if (misdn_cap_is_speech(bc->capability)) { if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { if ( *bc->crypt_key ) { cb_log(4, stack->port, " --> ENABLING BLOWFISH channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad); manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); } if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); manager_ec_enable(bc); if (bc->txgain != 0) { cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); } if ( bc->rxgain != 0 ) { cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); } } } break; case EVENT_HOLD_ACKNOWLEDGE: held_bc = malloc(sizeof(struct misdn_bchannel)); if (!held_bc) { cb_log(0, bc->port, "Could not allocate held_bc!!!\n"); RETURN(-1,OUT); } /* backup the bc and put it in storage */ *held_bc = *bc; held_bc->holded = 1; held_bc->channel = 0;/* A held call does not have a channel anymore. */ held_bc->channel_preselected = 0; held_bc->channel_found = 0; bc_state_change(held_bc, BCHAN_CLEANED); stack_holder_add(stack, held_bc); /* kill the bridge and clean the real b-channel record */ if (stack->nt) { int channel; if (bc->bc_state == BCHAN_BRIDGED) { struct misdn_bchannel *bc2; misdn_split_conf(bc,bc->conf_id); bc2 = find_bc_by_confid(bc->conf_id); if (!bc2) { cb_log(0,bc->port,"We have no second bc in bridge???\n"); } else { misdn_split_conf(bc2,bc->conf_id); } } channel = bc->channel; empty_bc(bc); clean_up_bc(bc); if (channel>0) empty_chan_in_stack(stack,channel); bc->in_use=0; } break; /* finishing the channel eh ? */ case EVENT_DISCONNECT: if (!bc->need_disconnect) { cb_log(0,bc->port," --> we have already send Disconnect\n"); RETURN(-1,OUT); } bc->need_disconnect=0; break; case EVENT_RELEASE: if (!bc->need_release) { cb_log(0,bc->port," --> we have already send Release\n"); RETURN(-1,OUT); } bc->need_disconnect=0; bc->need_release=0; break; case EVENT_RELEASE_COMPLETE: if (!bc->need_release_complete) { cb_log(0,bc->port," --> we have already send Release_complete\n"); RETURN(-1,OUT); } bc->need_disconnect=0; bc->need_release=0; bc->need_release_complete=0; if (!stack->nt) { /*create cleanup in TE*/ int channel=bc->channel; int tmpcause=bc->cause; int tmp_out_cause=bc->out_cause; empty_bc(bc); bc->cause=tmpcause; bc->out_cause=tmp_out_cause; clean_up_bc(bc); if (channel>0) empty_chan_in_stack(stack,channel); bc->in_use=0; } break; case EVENT_CONNECT_ACKNOWLEDGE: if ( bc->nt || misdn_cap_is_speech(bc->capability)) { int retval=setup_bc(bc); if (retval == -EINVAL){ cb_log(0,bc->port,"send_event: setup_bc failed\n"); } } if (misdn_cap_is_speech(bc->capability)) { if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); manager_ec_enable(bc); if ( bc->txgain != 0 ) { cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); } if ( bc->rxgain != 0 ) { cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); } } break; default: break; } /* Later we should think about sending bchannel data directly to misdn. */ msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); msg_queue_tail(&stack->downqueue, msg); sem_post(&glob_mgr->new_msg); OUT: misdn_send_unlock(bc); OUT_POST_UNLOCK: return retval; }
int misdn_lib_send_restart | ( | int | port, |
int | channel | ||
) |
Definition at line 3873 of file isdn_lib.c.
References misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), EVENT_RESTART, find_stack_by_port(), misdn_bchannel::in_use, misdn_lib_send_event(), misdn_make_dummy(), misdn_stack::nt, and misdn_stack::port.
Referenced by handle_cli_misdn_send_restart(), handle_event_nt(), and handle_frm().
{ struct misdn_stack *stack=find_stack_by_port(port); struct misdn_bchannel dummybc; /*default is all channels*/ cb_log(0, port, "Sending Restarts on this port.\n"); misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); /*default is all channels*/ if (channel <0) { dummybc.channel=-1; cb_log(0, port, "Restarting and all Interfaces\n"); misdn_lib_send_event(&dummybc, EVENT_RESTART); return 0; } /*if a channel is specified we restart only this one*/ if (channel >0) { int cnt; dummybc.channel=channel; cb_log(0, port, "Restarting and cleaning channel %d\n",channel); misdn_lib_send_event(&dummybc, EVENT_RESTART); /* clean up chan in stack, to be sure we don't think it's * in use anymore */ for (cnt=0; cnt<=stack->b_num; cnt++) { if (stack->bc[cnt].in_use && stack->bc[cnt].channel == channel) { empty_bc(&stack->bc[cnt]); clean_up_bc(&stack->bc[cnt]); stack->bc[cnt].in_use=0; } } } return 0; }
void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, |
enum tone_e | tone | ||
) |
Definition at line 4522 of file isdn_lib.c.
References misdn_bchannel::addr, buf, manager_ph_control(), misdn_lib::midev, TONE_ALERTING, TONE_DIAL, TONE_HANGUP, and TONE_NONE.
Referenced by hanguptone_indicate().
{ char buf[mISDN_HEADER_LEN + 128] = ""; iframe_t *frm = (iframe_t*)buf; switch(tone) { case TONE_DIAL: manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); break; case TONE_ALERTING: manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); break; case TONE_HANGUP: manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); break; case TONE_NONE: default: manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); } frm->prim=DL_DATA|REQUEST; frm->addr=bc->addr|FLG_MSG_DOWN; frm->dinfo=0; frm->len=128; mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); }
void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 999 of file isdn_lib.c.
References clean_up_bc(), and setup_bc().
{ clean_up_bc(bc); setup_bc(bc); }
void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, |
struct misdn_bchannel * | bc2 | ||
) |
Definition at line 4676 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
{ struct misdn_bchannel *bc_list[]={ bc1,bc2,NULL }; struct misdn_bchannel **bc; for (bc=bc_list; *bc; bc++) { 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)); } } }
void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2272 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by misdn_write().
{ bc->generate_tone=1; }
void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2277 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
{ bc->generate_tone=0; }
int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, |
void * | data, | ||
int | len | ||
) |
Definition at line 4306 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, buf, misdn_bchannel::capability, cb_log, flip_buf_bits(), get_stack_by_bc(), len(), misdn_stack::midev, misdn_cap_is_speech(), misdn_stack::port, and misdn_bchannel::port.
Referenced by misdn_join_conf(), and misdn_write().
{ struct misdn_stack *stack=get_stack_by_bc(bc); char buf[4096 + mISDN_HEADER_LEN]; iframe_t *frm = (iframe_t*)buf; int r; 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; } frm->prim = DL_DATA|REQUEST; frm->dinfo = 0; frm->addr = bc->addr | FLG_MSG_DOWN ; frm->len = len; memcpy(&buf[mISDN_HEADER_LEN], data,len); if ( misdn_cap_is_speech(bc->capability) ) flip_buf_bits( &buf[mISDN_HEADER_LEN], len); else cb_log(6, stack->port, "Writing %d data bytes\n",len); cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); return 0; }
void misdn_make_dummy | ( | struct misdn_bchannel * | dummybc, |
int | port, | ||
int | l3id, | ||
int | nt, | ||
int | channel | ||
) |
Definition at line 79 of file isdn_lib.c.
References misdn_bchannel::channel, misdn_bchannel::dummy, misdn_bchannel::l3_id, misdn_stack::nt, misdn_bchannel::nt, misdn_stack::port, and misdn_bchannel::port.
Referenced by handle_cli_misdn_send_facility(), handle_cr(), handle_event_nt(), handle_frm(), manager_event_handler(), misdn_lib_send_restart(), and release_cr().
enum event_response_e(* cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
Definition at line 28 of file isdn_lib.c.
Referenced by clear_l3(), do_tone(), handle_bchan(), handle_cr(), handle_event_nt(), handle_frm(), handle_l1(), handle_l2(), manager_clean_bc(), misdn_lib_init(), set_channel(), and setup_bc().
int(* cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len) |
Definition at line 33 of file isdn_lib.c.
Referenced by misdn_lib_init(), and misdn_tx_jitter().
void(* cb_log)(int level, int port, char *tmpl,...) |
Definition at line 30 of file isdn_lib.c.
Referenced by bc_next_state_change(), bc_state_change(), build_connect(), build_disconnect(), build_release(), build_release_complete(), build_restart(), build_setup(), cb_events(), clean_up_bc(), config_jitterbuffer(), create_process(), dump_chan_list(), empty_chan_in_stack(), fetch_msg(), find_free_chan_in_stack(), handle_bchan(), handle_cr(), handle_err(), handle_event(), handle_event_nt(), handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), handle_mgmt(), handle_timers(), hangup_chan(), init_bc(), isdn_msg_get_index_by_event(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_ec_disable(), manager_ec_enable(), manager_event_handler(), manager_isdn_handler(), manager_ph_control(), misdn_join_conf(), misdn_lib_bridge(), misdn_lib_destroy(), misdn_lib_echo(), misdn_lib_get_free_bc(), misdn_lib_get_l1_down(), misdn_lib_get_port_info(), misdn_lib_init(), misdn_lib_isdn_event_catcher(), misdn_lib_isdn_l1watcher(), misdn_lib_log_ies(), misdn_lib_port_restart(), misdn_lib_port_up(), misdn_lib_release(), misdn_lib_send_event(), misdn_lib_send_restart(), misdn_lib_split_bridge(), misdn_lib_tx2misdn_frm(), misdn_split_conf(), misdn_tasks_destroy(), misdn_tx_jitter(), misdn_write(), parse_facility(), parse_release_complete(), parse_restart(), parse_setup(), queue_cleanup_bc(), release_cr(), send_msg(), set_chan_in_stack(), set_channel(), setup_bc(), stack_holder_add(), stack_holder_find(), stack_holder_remove(), stack_init(), te_lib_destroy(), and test_inuse().