#include <mISDNuser/suppserv.h>
Go to the source code of this file.
#define MAX_BCHANS 31 |
Definition at line 70 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 466 of file isdn_lib.h.
#define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 467 of file isdn_lib.h.
#define PRI_TRANS_CAP_DIGITAL 0x08 |
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 465 of file isdn_lib.h.
#define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 463 of file isdn_lib.h.
anonymous enum |
Definition at line 163 of file isdn_lib.h.
00163 { /* bearer capability */ 00164 INFO_CAPABILITY_SPEECH=0, 00165 INFO_CAPABILITY_AUDIO_3_1K=0x10 , 00166 INFO_CAPABILITY_AUDIO_7K=0x11 , 00167 INFO_CAPABILITY_VIDEO =0x18, 00168 INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8, 00169 INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09, 00170 INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES 00171 };
anonymous enum |
Definition at line 173 of file isdn_lib.h.
00173 { /* progress indicators */ 00174 INFO_PI_CALL_NOT_E2E_ISDN =0x01, 00175 INFO_PI_CALLED_NOT_ISDN =0x02, 00176 INFO_PI_CALLER_NOT_ISDN =0x03, 00177 INFO_PI_CALLER_RETURNED_TO_ISDN =0x04, 00178 INFO_PI_INBAND_AVAILABLE =0x08, 00179 INFO_PI_DELAY_AT_INTERF =0x0a, 00180 INFO_PI_INTERWORKING_WITH_PUBLIC =0x10, 00181 INFO_PI_INTERWORKING_NO_RELEASE =0x11, 00182 INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12, 00183 INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13 00184 };
anonymous enum |
Definition at line 186 of file isdn_lib.h.
00186 { /*CODECS*/ 00187 INFO_CODEC_ULAW=2, 00188 INFO_CODEC_ALAW=3 00189 };
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 72 of file isdn_lib.h.
00072 { 00073 BCHAN_CLEANED=0, 00074 BCHAN_EMPTY, 00075 BCHAN_SETUP, 00076 BCHAN_SETUPED, 00077 BCHAN_ACTIVE, 00078 BCHAN_ACTIVATED, 00079 BCHAN_BRIDGE, 00080 BCHAN_BRIDGED, 00081 BCHAN_RELEASE, 00082 BCHAN_RELEASED, 00083 BCHAN_CLEAN, 00084 BCHAN_CLEAN_REQUEST, 00085 BCHAN_ERROR 00086 };
enum event_e |
Definition at line 112 of file isdn_lib.h.
00112 { 00113 EVENT_NOTHING, 00114 EVENT_TONE_GENERATE, 00115 EVENT_BCHAN_DATA, 00116 EVENT_BCHAN_ACTIVATED, 00117 EVENT_BCHAN_ERROR, 00118 EVENT_CLEANUP, 00119 EVENT_PROCEEDING, 00120 EVENT_PROGRESS, 00121 EVENT_SETUP, 00122 EVENT_ALERTING, 00123 EVENT_CONNECT, 00124 EVENT_SETUP_ACKNOWLEDGE, 00125 EVENT_CONNECT_ACKNOWLEDGE , 00126 EVENT_USER_INFORMATION, 00127 EVENT_SUSPEND_REJECT, 00128 EVENT_RESUME_REJECT, 00129 EVENT_HOLD, 00130 EVENT_SUSPEND, 00131 EVENT_RESUME, 00132 EVENT_HOLD_ACKNOWLEDGE, 00133 EVENT_SUSPEND_ACKNOWLEDGE, 00134 EVENT_RESUME_ACKNOWLEDGE, 00135 EVENT_HOLD_REJECT, 00136 EVENT_RETRIEVE, 00137 EVENT_RETRIEVE_ACKNOWLEDGE, 00138 EVENT_RETRIEVE_REJECT, 00139 EVENT_DISCONNECT, 00140 EVENT_RESTART, 00141 EVENT_RELEASE, 00142 EVENT_RELEASE_COMPLETE, 00143 EVENT_FACILITY, 00144 EVENT_NOTIFY, 00145 EVENT_STATUS_ENQUIRY, 00146 EVENT_INFORMATION, 00147 EVENT_STATUS, 00148 EVENT_TIMEOUT, 00149 EVENT_DTMF_TONE, 00150 EVENT_NEW_L3ID, 00151 EVENT_NEW_BC, 00152 EVENT_PORT_ALARM, 00153 EVENT_NEW_CHANNEL, 00154 EVENT_UNKNOWN 00155 };
enum event_response_e |
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE | |
RESPONSE_IGNORE_SETUP | |
RESPONSE_RELEASE_SETUP | |
RESPONSE_ERR | |
RESPONSE_OK |
Definition at line 103 of file isdn_lib.h.
00103 { 00104 RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, 00105 RESPONSE_IGNORE_SETUP, 00106 RESPONSE_RELEASE_SETUP, 00107 RESPONSE_ERR, 00108 RESPONSE_OK 00109 };
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 94 of file isdn_lib.h.
00094 { 00095 NUMPLAN_UNINITIALIZED=-1, 00096 NUMPLAN_INTERNATIONAL=0x1, 00097 NUMPLAN_NATIONAL=0x2, 00098 NUMPLAN_SUBSCRIBER=0x4, 00099 NUMPLAN_UNKNOWN=0x0 00100 };
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 57 of file isdn_lib.h.
00057 { 00058 TONE_NONE=0, 00059 TONE_DIAL, 00060 TONE_ALERTING, 00061 TONE_FAR_ALERTING, 00062 TONE_BUSY, 00063 TONE_HANGUP, 00064 TONE_CUSTOM, 00065 TONE_FILE 00066 };
char* bc_state2str | ( | enum bchannel_state | state | ) |
Definition at line 552 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().
00552 { 00553 int i; 00554 00555 struct bchan_state_s { 00556 char *n; 00557 enum bchannel_state s; 00558 } states[] = { 00559 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00560 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00561 {"BCHAN_SETUP", BCHAN_SETUP}, 00562 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00563 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00564 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00565 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00566 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00567 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00568 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00569 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00570 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00571 {"BCHAN_ERROR", BCHAN_ERROR} 00572 }; 00573 00574 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00575 if ( states[i].s == state) 00576 return states[i].n; 00577 00578 return "UNKNOWN"; 00579 }
void bc_state_change | ( | struct misdn_bchannel * | bc, | |
enum bchannel_state | state | |||
) |
Definition at line 581 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().
00582 { 00583 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00584 bc->l3_id, 00585 bc_state2str(bc->bc_state), 00586 bc_state2str(state) ); 00587 00588 switch (state) { 00589 case BCHAN_ACTIVATED: 00590 if (bc->next_bc_state == BCHAN_BRIDGED) { 00591 misdn_join_conf(bc, bc->conf_id); 00592 bc->next_bc_state = BCHAN_EMPTY; 00593 return; 00594 } 00595 default: 00596 bc->bc_state=state; 00597 break; 00598 } 00599 }
void get_show_stack_details | ( | int | port, | |
char * | buf | |||
) |
Definition at line 134 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 misdn_show_port(), and misdn_show_stacks().
00135 { 00136 struct misdn_stack *stack=get_misdn_stack(); 00137 00138 for ( ; stack; stack=stack->next) { 00139 if (stack->port == port) break; 00140 } 00141 00142 if (stack) { 00143 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); 00144 00145 } else { 00146 buf[0]=0; 00147 } 00148 00149 }
void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4202 of file isdn_lib.c.
References manager_ph_control().
Referenced by process_ast_dsp().
04203 { 04204 manager_ph_control(bc, DTMF_TONE_STOP, 0); 04205 }
void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4190 of file isdn_lib.c.
References misdn_bchannel::ec_enable, manager_ec_disable(), and manager_ec_enable().
Referenced by process_ast_dsp().
04191 { 04192 #ifdef MISDN_1_2 04193 if (*bc->pipeline) 04194 #else 04195 if (bc->ec_enable) 04196 #endif 04197 manager_ec_enable(bc); 04198 else 04199 manager_ec_disable(bc); 04200 }
void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4180 of file isdn_lib.c.
References manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
04181 { 04182 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 04183 }
void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4185 of file isdn_lib.c.
References manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
04186 { 04187 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 04188 }
void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4061 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, cb_log, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.
Referenced by setup_bc().
04062 { 04063 char buf[128]; 04064 04065 struct misdn_stack *stack=get_stack_by_bc(bc); 04066 04067 if (!stack) { 04068 cb_log(0, bc->port, "bchannel_activate: Stack not found !"); 04069 return ; 04070 } 04071 04072 /* we must activate if we are deactivated */ 04073 clear_ibuffer(bc->astbuf); 04074 04075 cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); 04076 04077 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); 04078 04079 return ; 04080 }
void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4083 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, 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().
04084 { 04085 char buf[128]; 04086 iframe_t dact; 04087 struct misdn_stack *stack=get_stack_by_bc(bc); 04088 04089 switch (bc->bc_state) { 04090 case BCHAN_ACTIVATED: 04091 break; 04092 case BCHAN_BRIDGED: 04093 misdn_split_conf(bc,bc->conf_id); 04094 break; 04095 default: 04096 cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n"); 04097 return ; 04098 04099 } 04100 04101 cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); 04102 04103 bc->generate_tone=0; 04104 04105 dact.prim = DL_RELEASE | REQUEST; 04106 dact.addr = bc->addr | FLG_MSG_DOWN; 04107 dact.dinfo = 0; 04108 dact.len = 0; 04109 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); 04110 04111 clear_ibuffer(bc->astbuf); 04112 04113 bc_state_change(bc,BCHAN_RELEASE); 04114 04115 return; 04116 }
void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4424 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(), isdn_lib_update_ec(), and misdn_toggle_echocancel().
04425 { 04426 struct misdn_stack *stack=get_stack_by_bc(bc); 04427 04428 cb_log(4, stack?stack->port:0," --> ec_disable\n"); 04429 04430 if (!misdn_cap_is_speech(bc->capability)) { 04431 cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); 04432 return; 04433 } 04434 04435 #ifdef MISDN_1_2 04436 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); 04437 #else 04438 if ( ! bc->ec_enable) { 04439 cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); 04440 manager_ph_control(bc, ECHOCAN_OFF, 0); 04441 } 04442 #endif 04443 }
void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4375 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_event(), isdn_lib_update_ec(), misdn_lib_send_event(), and misdn_toggle_echocancel().
04376 { 04377 struct misdn_stack *stack=get_stack_by_bc(bc); 04378 04379 cb_log(4, stack?stack->port:0,"ec_enable\n"); 04380 04381 if (!misdn_cap_is_speech(bc->capability)) { 04382 cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); 04383 } else { 04384 04385 #ifdef MISDN_1_2 04386 if (*bc->pipeline) { 04387 cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); 04388 manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); 04389 } 04390 #else 04391 int ec_arr[2]; 04392 04393 if (bc->ec_enable) { 04394 cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); 04395 04396 switch (bc->ec_deftaps) { 04397 case 4: 04398 case 8: 04399 case 16: 04400 case 32: 04401 case 64: 04402 case 128: 04403 case 256: 04404 case 512: 04405 case 1024: 04406 cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); 04407 break; 04408 default: 04409 cb_log(0, stack->port, "Taps should be power of 2\n"); 04410 bc->ec_deftaps=128; 04411 } 04412 04413 ec_arr[0]=bc->ec_deftaps; 04414 ec_arr[1]=0; 04415 04416 manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); 04417 } 04418 #endif 04419 } 04420 }
char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 4056 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
04057 { 04058 return isdn_get_info(msgs_g , event, 0); 04059 }
void manager_ph_control | ( | struct misdn_bchannel * | bc, | |
int | c1, | |||
int | c2 | |||
) |
Definition at line 4159 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().
04160 { 04161 unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; 04162 iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ 04163 unsigned int *d = (unsigned int*)&ctrl->data.p; 04164 /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ 04165 04166 cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); 04167 04168 ctrl->prim = PH_CONTROL | REQUEST; 04169 ctrl->addr = bc->addr | FLG_MSG_DOWN; 04170 ctrl->dinfo = 0; 04171 ctrl->len = sizeof(unsigned int)*2; 04172 *d++ = c1; 04173 *d++ = c2; 04174 mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); 04175 }
int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 410 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().
00412 { 00413 if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && 00414 (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; 00415 return 0; 00416 }
void misdn_dump_chanlist | ( | void | ) |
Definition at line 446 of file isdn_lib.c.
References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.
Referenced by misdn_show_cls().
00447 { 00448 struct misdn_stack *stack=get_misdn_stack(); 00449 for ( ; stack; stack=stack->next) { 00450 dump_chan_list(stack); 00451 } 00452 00453 }
int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 418 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().
00419 { 00420 00421 /*if ! early_bconnect we have never inband available*/ 00422 if ( ! bc->early_bconnect ) return 0; 00423 00424 switch (bc->progress_indicator) { 00425 case INFO_PI_INBAND_AVAILABLE: 00426 case INFO_PI_CALL_NOT_E2E_ISDN: 00427 case INFO_PI_CALLED_NOT_ISDN: 00428 return 1; 00429 default: 00430 return 0; 00431 } 00432 return 0; 00433 }
void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4478 of file isdn_lib.c.
References bc_next_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, cb_log, misdn_join_conf(), misdn_bchannel::pid, and misdn_bchannel::port.
Referenced by misdn_bridge().
04479 { 04480 int conf_id=bc1->pid +1; 04481 struct misdn_bchannel *bc_list[]={ 04482 bc1,bc2,NULL 04483 }; 04484 struct misdn_bchannel **bc; 04485 04486 cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); 04487 04488 for (bc=bc_list; *bc; bc++) { 04489 (*bc)->conf_id=conf_id; 04490 cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); 04491 04492 switch((*bc)->bc_state) { 04493 case BCHAN_ACTIVATED: 04494 misdn_join_conf(*bc,conf_id); 04495 break; 04496 default: 04497 bc_next_state_change(*bc,BCHAN_BRIDGED); 04498 break; 04499 } 04500 } 04501 }
void misdn_lib_destroy | ( | void | ) |
Definition at line 4023 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, global_state, 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().
04024 { 04025 struct misdn_stack *help; 04026 int i; 04027 04028 for ( help=glob_mgr->stack_list; help; help=help->next ) { 04029 for(i=0;i<=help->b_num; i++) { 04030 char buf[1024]; 04031 mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 04032 help->bc[i].addr = 0; 04033 } 04034 cb_log (1, help->port, "Destroying this port.\n"); 04035 stack_destroy(help); 04036 } 04037 04038 if (global_state == MISDN_INITIALIZED) { 04039 cb_log(4, 0, "Killing Handler Thread\n"); 04040 if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { 04041 cb_log(4, 0, "Joining Handler Thread\n"); 04042 pthread_join(glob_mgr->event_handler_thread, NULL); 04043 } 04044 04045 cb_log(4, 0, "Killing Main Thread\n"); 04046 if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { 04047 cb_log(4, 0, "Joining Main Thread\n"); 04048 pthread_join(glob_mgr->event_thread, NULL); 04049 } 04050 } 04051 04052 cb_log(1, 0, "Closing mISDN device\n"); 04053 te_lib_destroy(glob_mgr->midev); 04054 }
void misdn_lib_echo | ( | struct misdn_bchannel * | bc, | |
int | onoff | |||
) |
Definition at line 4523 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
04524 { 04525 cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); 04526 manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); 04527 }
struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, | |
int | channel, | |||
int | inout, | |||
int | dec | |||
) | [read] |
Definition at line 3115 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, misdn_bchannel::in_use, MAX_BCHANS, misdn_stack::next, misdn_stack::port, prepare_bc(), misdn_stack::pri, misdn_stack::ptp, and misdn_lib::stack_list.
Referenced by handle_cr(), handle_event_nt(), and misdn_request().
03116 { 03117 struct misdn_stack *stack; 03118 int i; 03119 03120 if (channel < 0 || channel > MAX_BCHANS) { 03121 cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); 03122 return NULL; 03123 } 03124 03125 for (stack=glob_mgr->stack_list; stack; stack=stack->next) { 03126 03127 if (stack->port == port) { 03128 int maxnum; 03129 if (stack->blocked) { 03130 cb_log(0,port,"Port is blocked\n"); 03131 return NULL; 03132 } 03133 03134 if (channel > 0) { 03135 if (channel <= stack->b_num) { 03136 for (i = 0; i < stack->b_num; i++) { 03137 if (stack->bc[i].in_use && stack->bc[i].channel == channel) { 03138 cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); 03139 return NULL; 03140 } 03141 } 03142 } else { 03143 cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); 03144 return NULL; 03145 } 03146 } 03147 03148 maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num; 03149 03150 if (dec) { 03151 for (i = maxnum-1; i>=0; i--) { 03152 if (!stack->bc[i].in_use) { 03153 /* 3. channel on bri means CW*/ 03154 if (!stack->pri && i==stack->b_num) 03155 stack->bc[i].cw=1; 03156 03157 prepare_bc(&stack->bc[i], channel); 03158 stack->bc[i].dec=1; 03159 return &stack->bc[i]; 03160 } 03161 } 03162 } else { 03163 for (i = 0; i <maxnum; i++) { 03164 if (!stack->bc[i].in_use) { 03165 /* 3. channel on bri means CW*/ 03166 if (!stack->pri && i==stack->b_num) 03167 stack->bc[i].cw=1; 03168 03169 prepare_bc(&stack->bc[i], channel); 03170 return &stack->bc[i]; 03171 } 03172 } 03173 } 03174 03175 cb_log(1,port,"There is no free channel on port (%d)\n",port); 03176 return NULL; 03177 } 03178 } 03179 03180 cb_log(0,port,"Port is not configured (%d)\n",port); 03181 return NULL; 03182 }
int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 102 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
00103 { 00104 struct misdn_stack *stack=get_misdn_stack(); 00105 for ( ; stack; stack=stack->next) { 00106 if (stack->port == port) { 00107 if (stack->pri) 00108 return 30; 00109 else 00110 return 2; 00111 } 00112 } 00113 return -1; 00114 }
int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1711 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 misdn_port_down().
01712 { /* Pull Down L1 */ 01713 struct misdn_stack *stack; 01714 for (stack=glob_mgr->stack_list; 01715 stack; 01716 stack=stack->next) { 01717 if (stack->port == port) { 01718 if (stack->l2link) 01719 misdn_lib_get_l2_down(stack); 01720 misdn_lib_get_l1_down(stack); 01721 return 0; 01722 } 01723 } 01724 return 0; 01725 }
int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3629 of file isdn_lib.c.
References misdn_lib::activatequeue, cb_log, find_stack_by_port(), misdn_lib::new_msg, and misdn_stack::upper_id.
03630 { 03631 msg_t *msg=alloc_msg(MAX_MSG_SIZE); 03632 iframe_t *frm; 03633 struct misdn_stack *stack=find_stack_by_port(port); 03634 if (!msg) { 03635 cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n"); 03636 return -1; 03637 } 03638 frm=(iframe_t*)msg->data; 03639 if (!stack ) { 03640 cb_log(0, port, "There is no Stack for this port.\n"); 03641 return -1; 03642 } 03643 /* activate bchannel */ 03644 frm->prim = CC_STATUS_ENQUIRY | REQUEST; 03645 03646 frm->addr = stack->upper_id| FLG_MSG_DOWN; 03647 03648 frm->dinfo = 0; 03649 frm->len = 0; 03650 03651 msg_queue_tail(&glob_mgr->activatequeue, msg); 03652 sem_post(&glob_mgr->new_msg); 03653 03654 03655 return 0; 03656 }
int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1689 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 misdn_check_l2l1(), and misdn_port_up().
01690 { /* Pull Up L1 */ 01691 struct misdn_stack *stack; 01692 01693 for (stack=glob_mgr->stack_list; 01694 stack; 01695 stack=stack->next) { 01696 01697 if (stack->port == port) { 01698 01699 if (!stack->l1link) 01700 misdn_lib_get_l1_up(stack); 01701 if (!stack->l2link) 01702 misdn_lib_get_l2_up(stack); 01703 01704 return 0; 01705 } 01706 } 01707 return 0; 01708 }
int misdn_lib_init | ( | char * | portlist, | |
struct misdn_lib_iface * | iface, | |||
void * | user_data | |||
) |
Definition at line 3915 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, flip_buf_bits(), global_state, 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, te_lib_init(), tone_425_flip, and tone_silence_flip.
Referenced by load_module().
03916 { 03917 struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); 03918 char *tok, *tokb; 03919 char plist[1024]; 03920 int midev; 03921 int port_count=0; 03922 03923 cb_log = iface->cb_log; 03924 cb_event = iface->cb_event; 03925 cb_jb_empty = iface->cb_jb_empty; 03926 03927 glob_mgr = mgr; 03928 03929 msg_init(); 03930 03931 misdn_lib_nt_debug_init(0,NULL); 03932 03933 if (!portlist || (*portlist == 0) ) return 1; 03934 03935 init_flip_bits(); 03936 03937 { 03938 strncpy(plist,portlist, 1024); 03939 plist[1023] = 0; 03940 } 03941 03942 memcpy(tone_425_flip,tone_425,TONE_425_SIZE); 03943 flip_buf_bits(tone_425_flip,TONE_425_SIZE); 03944 03945 memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); 03946 flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); 03947 03948 midev=te_lib_init(); 03949 mgr->midev=midev; 03950 03951 port_count=mISDN_get_stack_count(midev); 03952 03953 msg_queue_init(&mgr->activatequeue); 03954 03955 if (sem_init(&mgr->new_msg, 1, 0)<0) 03956 sem_init(&mgr->new_msg, 0, 0); 03957 03958 for (tok=strtok_r(plist," ,",&tokb ); 03959 tok; 03960 tok=strtok_r(NULL," ,",&tokb)) { 03961 int port = atoi(tok); 03962 struct misdn_stack *stack; 03963 static int first=1; 03964 int ptp=0; 03965 03966 if (strstr(tok, "ptp")) 03967 ptp=1; 03968 03969 if (port > port_count) { 03970 cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); 03971 exit(1); 03972 } 03973 stack=stack_init(midev, port, ptp); 03974 03975 if (!stack) { 03976 perror("init_stack"); 03977 exit(1); 03978 } 03979 03980 { 03981 int i; 03982 for(i=0;i<=stack->b_num; i++) { 03983 int r; 03984 if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { 03985 cb_log(0, port, "Got Err @ init_bc :%d\n",r); 03986 exit(1); 03987 } 03988 } 03989 } 03990 03991 if (stack && first) { 03992 mgr->stack_list=stack; 03993 first=0; 03994 continue; 03995 } 03996 03997 if (stack) { 03998 struct misdn_stack * help; 03999 for ( help=mgr->stack_list; help; help=help->next ) 04000 if (help->next == NULL) break; 04001 help->next=stack; 04002 } 04003 04004 } 04005 04006 if (sem_init(&handler_started, 1, 0)<0) 04007 sem_init(&handler_started, 0, 0); 04008 04009 cb_log(8, 0, "Starting Event Handler\n"); 04010 pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); 04011 04012 sem_wait(&handler_started) ; 04013 cb_log(8, 0, "Starting Event Catcher\n"); 04014 pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); 04015 04016 cb_log(8, 0, "Event Catcher started\n"); 04017 04018 global_state= MISDN_INITIALIZED; 04019 04020 return (mgr == NULL); 04021 }
int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 82 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
00083 { 00084 struct misdn_stack *stack=get_misdn_stack(); 00085 for ( ; stack; stack=stack->next) { 00086 if (stack->port == port) { 00087 return stack->blocked; 00088 } 00089 } 00090 return -1; 00091 }
int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 93 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().
00094 { 00095 struct misdn_stack *stack=get_misdn_stack(); 00096 for ( ; stack; stack=stack->next) { 00097 if (stack->port == port) return stack->ptp; 00098 } 00099 return -1; 00100 }
void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 2960 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().
02961 { 02962 struct misdn_stack *stack; 02963 02964 for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) 02965 ; 02966 02967 if (stack) { 02968 cb_log(4, port, "Checking L1 State\n"); 02969 if (!stack->l1link) { 02970 cb_log(4, port, "L1 State Down, trying to get it up again\n"); 02971 misdn_lib_get_short_status(stack); 02972 misdn_lib_get_l1_up(stack); 02973 misdn_lib_get_l2_up(stack); 02974 } 02975 } 02976 }
void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3203 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().
03204 { 03205 struct misdn_stack *stack; 03206 if (!bc) return; 03207 03208 stack=get_stack_by_bc(bc); 03209 03210 if (!stack) return; 03211 03212 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); 03213 03214 cb_log(2, stack->port, 03215 " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", 03216 bc->info_dad, 03217 bc->onumplan>=0?'0'+bc->onumplan:' ', 03218 bc->dnumplan>=0?'0'+bc->dnumplan:' ', 03219 bc->rnumplan>=0?'0'+bc->rnumplan:' ', 03220 bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' 03221 ); 03222 03223 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); 03224 cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", 03225 bc->screen, bc->pres); 03226 03227 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); 03228 03229 cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); 03230 03231 cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); 03232 03233 cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); 03234 }
int misdn_lib_maxports_get | ( | void | ) |
BE AWARE WE HAVE NO CB_LOG HERE!
Definition at line 3867 of file isdn_lib.c.
Referenced by load_module().
03867 { /** BE AWARE WE HAVE NO CB_LOG HERE! **/ 03868 03869 int i = mISDN_open(); 03870 int max=0; 03871 03872 if (i<0) 03873 return -1; 03874 03875 max = mISDN_get_stack_count(i); 03876 03877 mISDN_close(i); 03878 03879 return max; 03880 }
void misdn_lib_nt_debug_init | ( | int | flags, | |
char * | file | |||
) |
Definition at line 3895 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
03896 { 03897 int static init=0; 03898 char *f; 03899 03900 if (!flags) 03901 f=NULL; 03902 else 03903 f=file; 03904 03905 if (!init) { 03906 debug_init( flags , f, f, f); 03907 init=1; 03908 } else { 03909 debug_close(); 03910 debug_init( flags , f, f, f); 03911 } 03912 }
void misdn_lib_nt_keepcalls | ( | int | kc | ) |
Definition at line 3883 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::nst.
Referenced by load_module().
03884 { 03885 #ifdef FEATURE_NET_KEEPCALLS 03886 if (kc) { 03887 struct misdn_stack *stack=get_misdn_stack(); 03888 for ( ; stack; stack=stack->next) { 03889 stack->nst.feature |= FEATURE_NET_KEEPCALLS; 03890 } 03891 } 03892 #endif 03893 }
int misdn_lib_pid_restart | ( | int | pid | ) |
int misdn_lib_port_block | ( | int | port | ) |
Definition at line 56 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by cb_events(), and misdn_port_block().
00057 { 00058 struct misdn_stack *stack=get_misdn_stack(); 00059 for ( ; stack; stack=stack->next) { 00060 if (stack->port == port) { 00061 stack->blocked=1; 00062 return 0; 00063 } 00064 } 00065 return -1; 00066 00067 }
int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 34 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_new(), and update_name().
00035 { 00036 struct misdn_stack *stack=get_misdn_stack(); 00037 for ( ; stack; stack=stack->next) { 00038 if (stack->port == port) { 00039 return stack->pri; 00040 } 00041 } 00042 00043 return -1; 00044 }
int misdn_lib_port_restart | ( | int | port | ) |
int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 69 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by misdn_port_unblock().
00070 { 00071 struct misdn_stack *stack=get_misdn_stack(); 00072 for ( ; stack; stack=stack->next) { 00073 if (stack->port == port) { 00074 stack->blocked=0; 00075 return 0; 00076 } 00077 } 00078 return -1; 00079 00080 }
int misdn_lib_port_up | ( | int | port, | |
int | notcheck | |||
) |
Definition at line 1727 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().
01728 { 01729 struct misdn_stack *stack; 01730 01731 01732 for (stack=glob_mgr->stack_list; 01733 stack; 01734 stack=stack->next) { 01735 01736 if (stack->port == port) { 01737 01738 if (stack->blocked) { 01739 cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); 01740 return -1; 01741 } 01742 01743 if (stack->ptp ) { 01744 01745 if (stack->l1link && stack->l2link) { 01746 return 1; 01747 } else { 01748 cb_log(1,port, "Port Down L2:%d L1:%d\n", 01749 stack->l2link, stack->l1link); 01750 return 0; 01751 } 01752 } else { 01753 if ( !check || stack->l1link ) 01754 return 1; 01755 else { 01756 cb_log(1,port, "Port down PMP\n"); 01757 return 0; 01758 } 01759 } 01760 } 01761 } 01762 01763 return -1; 01764 }
void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4531 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::pri, misdn_stack::ptp, and misdn_stack::upper_id.
Referenced by handle_event_nt(), and misdn_lib_port_restart().
04532 { 04533 struct misdn_stack *stack=find_stack_by_port(port); 04534 04535 if (stack) { 04536 stack->l2link=0; 04537 stack->blocked=0; 04538 04539 cleanup_Isdnl3(&stack->nst); 04540 cleanup_Isdnl2(&stack->nst); 04541 04542 04543 memset(&stack->nst, 0, sizeof(net_stack_t)); 04544 memset(&stack->mgr, 0, sizeof(manager_t)); 04545 04546 stack->mgr.nst = &stack->nst; 04547 stack->nst.manager = &stack->mgr; 04548 04549 stack->nst.l3_manager = handle_event_nt; 04550 stack->nst.device = glob_mgr->midev; 04551 stack->nst.cardnr = port; 04552 stack->nst.d_stid = stack->d_stid; 04553 04554 stack->nst.feature = FEATURE_NET_HOLD; 04555 if (stack->ptp) 04556 stack->nst.feature |= FEATURE_NET_PTP; 04557 if (stack->pri) 04558 stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; 04559 04560 stack->nst.l1_id = stack->lower_id; 04561 stack->nst.l2_id = stack->upper_id; 04562 04563 msg_queue_init(&stack->nst.down_queue); 04564 04565 Isdnl2Init(&stack->nst); 04566 Isdnl3Init(&stack->nst); 04567 04568 if (!stack->ptp) 04569 misdn_lib_get_l1_up(stack); 04570 misdn_lib_get_l2_up(stack); 04571 } 04572 }
void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1669 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().
01670 { 01671 struct misdn_stack *stack=get_stack_by_bc(bc); 01672 01673 if (!stack) { 01674 cb_log(1,0,"misdn_release: No Stack found\n"); 01675 return; 01676 } 01677 01678 if (bc->channel>0) 01679 empty_chan_in_stack(stack,bc->channel); 01680 01681 empty_bc(bc); 01682 clean_up_bc(bc); 01683 bc->in_use=0; 01684 }
int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, | |
enum event_e | event | |||
) |
Queue Event
Definition at line 3255 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, 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(), 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_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_cd(), misdn_send_display(), misdn_send_text(), start_pbx(), and wait_for_digits().
03256 { 03257 msg_t *msg; 03258 struct misdn_stack *stack; 03259 int retval=0; 03260 03261 if (!bc) RETURN(-1,OUT_POST_UNLOCK); 03262 03263 stack=get_stack_by_bc(bc); 03264 03265 if (!stack) { 03266 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); 03267 RETURN(-1,OUT); 03268 } 03269 03270 misdn_send_lock(bc); 03271 03272 03273 cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id); 03274 03275 if ( stack->nt && !stack->l1link) { 03276 /** Queue Event **/ 03277 bc->evq=event; 03278 cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); 03279 misdn_lib_get_l1_up(stack); 03280 RETURN(0,OUT); 03281 } 03282 03283 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); 03284 cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); 03285 misdn_lib_log_ies(bc); 03286 03287 switch (event) { 03288 case EVENT_SETUP: 03289 if (create_process(glob_mgr->midev, bc)<0) { 03290 cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); 03291 03292 RETURN(-ENOCHAN,OUT); 03293 } 03294 break; 03295 03296 case EVENT_PROGRESS: 03297 case EVENT_ALERTING: 03298 case EVENT_PROCEEDING: 03299 case EVENT_SETUP_ACKNOWLEDGE: 03300 case EVENT_CONNECT: 03301 if (!stack->nt) break; 03302 03303 case EVENT_RETRIEVE_ACKNOWLEDGE: 03304 03305 if (stack->nt) { 03306 if (bc->channel <=0 ) { /* else we have the channel already */ 03307 if (find_free_chan_in_stack(stack, bc, 0, 0)<0) { 03308 cb_log(0, stack->port, " No free channel at the moment\n"); 03309 /*FIXME: add disconnect*/ 03310 RETURN(-ENOCHAN,OUT); 03311 } 03312 } 03313 /* Its that i generate channels */ 03314 } 03315 03316 retval=setup_bc(bc); 03317 if (retval == -EINVAL) { 03318 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03319 } 03320 03321 if (misdn_cap_is_speech(bc->capability)) { 03322 if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { 03323 if ( *bc->crypt_key ) { 03324 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); 03325 03326 manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); 03327 } 03328 03329 if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03330 manager_ec_enable(bc); 03331 03332 if (bc->txgain != 0) { 03333 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03334 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03335 } 03336 03337 if ( bc->rxgain != 0 ) { 03338 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03339 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03340 } 03341 } 03342 } 03343 break; 03344 03345 case EVENT_HOLD_ACKNOWLEDGE: 03346 { 03347 struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel)); 03348 if (!holded_bc) { 03349 cb_log(0,bc->port, "Could not allocate holded_bc!!!\n"); 03350 RETURN(-1,OUT); 03351 } 03352 03353 /*backup the bc*/ 03354 memcpy(holded_bc,bc,sizeof(struct misdn_bchannel)); 03355 holded_bc->holded=1; 03356 bc_state_change(holded_bc,BCHAN_CLEANED); 03357 03358 stack_holder_add(stack,holded_bc); 03359 03360 /*kill the bridge and clean the bchannel*/ 03361 if (stack->nt) { 03362 int channel; 03363 if (bc->bc_state == BCHAN_BRIDGED) { 03364 struct misdn_bchannel *bc2; 03365 misdn_split_conf(bc,bc->conf_id); 03366 bc2=find_bc_by_confid(bc->conf_id); 03367 if (!bc2) { 03368 cb_log(0,bc->port,"We have no second bc in bridge???\n"); 03369 } else { 03370 misdn_split_conf(bc2,bc->conf_id); 03371 } 03372 } 03373 03374 channel=bc->channel; 03375 03376 empty_bc(bc); 03377 clean_up_bc(bc); 03378 03379 if (channel>0) 03380 empty_chan_in_stack(stack,channel); 03381 03382 bc->in_use=0; 03383 } 03384 03385 } 03386 break; 03387 03388 /* finishing the channel eh ? */ 03389 case EVENT_DISCONNECT: 03390 if (!bc->need_disconnect) { 03391 cb_log(0,bc->port," --> we have already send Disconnect\n"); 03392 RETURN(-1,OUT); 03393 } 03394 03395 bc->need_disconnect=0; 03396 break; 03397 case EVENT_RELEASE: 03398 if (!bc->need_release) { 03399 cb_log(0,bc->port," --> we have already send Release\n"); 03400 RETURN(-1,OUT); 03401 } 03402 bc->need_disconnect=0; 03403 bc->need_release=0; 03404 break; 03405 case EVENT_RELEASE_COMPLETE: 03406 if (!bc->need_release_complete) { 03407 cb_log(0,bc->port," --> we have already send Release_complete\n"); 03408 RETURN(-1,OUT); 03409 } 03410 bc->need_disconnect=0; 03411 bc->need_release=0; 03412 bc->need_release_complete=0; 03413 03414 if (!stack->nt) { 03415 /*create clenaup in TE*/ 03416 int channel=bc->channel; 03417 03418 int tmpcause=bc->cause; 03419 int tmp_out_cause=bc->out_cause; 03420 empty_bc(bc); 03421 bc->cause=tmpcause; 03422 bc->out_cause=tmp_out_cause; 03423 clean_up_bc(bc); 03424 03425 if (channel>0) 03426 empty_chan_in_stack(stack,channel); 03427 03428 bc->in_use=0; 03429 } 03430 break; 03431 03432 case EVENT_CONNECT_ACKNOWLEDGE: 03433 03434 if ( bc->nt || misdn_cap_is_speech(bc->capability)) { 03435 int retval=setup_bc(bc); 03436 if (retval == -EINVAL){ 03437 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03438 03439 } 03440 } 03441 03442 if (misdn_cap_is_speech(bc->capability)) { 03443 if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03444 manager_ec_enable(bc); 03445 03446 if ( bc->txgain != 0 ) { 03447 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03448 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03449 } 03450 if ( bc->rxgain != 0 ) { 03451 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03452 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03453 } 03454 } 03455 break; 03456 03457 default: 03458 break; 03459 } 03460 03461 /* Later we should think about sending bchannel data directly to misdn. */ 03462 msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); 03463 msg_queue_tail(&stack->downqueue, msg); 03464 sem_post(&glob_mgr->new_msg); 03465 03466 OUT: 03467 misdn_send_unlock(bc); 03468 03469 OUT_POST_UNLOCK: 03470 return retval; 03471 }
int misdn_lib_send_restart | ( | int | port, | |
int | channel | |||
) |
Definition at line 3695 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, make_dummy(), misdn_lib_send_event(), misdn_stack::nt, and misdn_stack::port.
Referenced by handle_event_nt(), handle_frm(), and misdn_send_restart().
03696 { 03697 struct misdn_bchannel dummybc; 03698 struct misdn_stack *stack=find_stack_by_port(port); 03699 cb_log(0, port, "Sending Restarts on this port.\n"); 03700 03701 make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); 03702 03703 /*default is all channels*/ 03704 if (channel <0) { 03705 dummybc.channel=-1; 03706 cb_log(0, port, "Restarting and all Interfaces\n"); 03707 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03708 03709 return 0; 03710 } 03711 03712 /*if a channel is specified we restart only this one*/ 03713 if (channel >0) { 03714 int cnt; 03715 dummybc.channel=channel; 03716 cb_log(0, port, "Restarting and cleaning channel %d\n",channel); 03717 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03718 /* clean up chan in stack, to be sure we don't think it's 03719 * in use anymore */ 03720 for (cnt=0; cnt<=stack->b_num; cnt++) { 03721 if (stack->bc[cnt].channel == channel) { 03722 empty_bc(&stack->bc[cnt]); 03723 clean_up_bc(&stack->bc[cnt]); 03724 stack->bc[cnt].in_use=0; 03725 } 03726 } 03727 } 03728 03729 return 0; 03730 }
void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, | |
enum tone_e | tone | |||
) |
Definition at line 4340 of file isdn_lib.c.
References misdn_bchannel::addr, manager_ph_control(), misdn_lib::midev, TONE_ALERTING, TONE_DIAL, TONE_HANGUP, and TONE_NONE.
Referenced by hanguptone_indicate().
04341 { 04342 char buf[mISDN_HEADER_LEN+128]; 04343 iframe_t *frm; 04344 04345 switch(tone) { 04346 case TONE_DIAL: 04347 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 04348 break; 04349 04350 case TONE_ALERTING: 04351 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); 04352 break; 04353 04354 case TONE_HANGUP: 04355 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); 04356 break; 04357 04358 case TONE_NONE: 04359 default: 04360 manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); 04361 } 04362 04363 frm=(iframe_t*)buf; 04364 memset(buf,0,mISDN_HEADER_LEN+128); 04365 04366 frm->prim=DL_DATA|REQUEST; 04367 frm->addr=bc->addr|FLG_MSG_DOWN; 04368 frm->dinfo=0; 04369 frm->len=128; 04370 04371 mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); 04372 }
void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 942 of file isdn_lib.c.
References clean_up_bc(), and setup_bc().
00943 { 00944 clean_up_bc(bc); 00945 setup_bc(bc); 00946 }
void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4503 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
04504 { 04505 04506 struct misdn_bchannel *bc_list[]={ 04507 bc1,bc2,NULL 04508 }; 04509 struct misdn_bchannel **bc; 04510 04511 for (bc=bc_list; *bc; bc++) { 04512 if ( (*bc)->bc_state == BCHAN_BRIDGED){ 04513 misdn_split_conf( *bc, (*bc)->conf_id); 04514 } else { 04515 cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); 04516 } 04517 } 04518 04519 }
void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2171 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by misdn_write().
02172 { 02173 bc->generate_tone=1; 02174 }
void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2176 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
02177 { 02178 bc->generate_tone=0; 02179 }
void misdn_lib_transfer | ( | struct misdn_bchannel * | holded_bc | ) |
Definition at line 3067 of file isdn_lib.c.
References misdn_bchannel::holded.
03068 { 03069 holded_bc->holded=0; 03070 }
int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, | |
void * | data, | |||
int | len | |||
) |
Definition at line 4119 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, misdn_bchannel::capability, cb_log, flip_buf_bits(), get_stack_by_bc(), misdn_stack::midev, misdn_cap_is_speech(), misdn_stack::port, and misdn_bchannel::port.
Referenced by misdn_join_conf(), and misdn_write().
04120 { 04121 char buf[4096 + mISDN_HEADER_LEN]; 04122 iframe_t *frm; 04123 int r; 04124 struct misdn_stack *stack=get_stack_by_bc(bc); 04125 04126 switch (bc->bc_state) { 04127 case BCHAN_ACTIVATED: 04128 case BCHAN_BRIDGED: 04129 break; 04130 default: 04131 cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); 04132 return -1; 04133 } 04134 04135 frm= (iframe_t*)buf; 04136 04137 frm->prim = DL_DATA|REQUEST; 04138 frm->dinfo = 0; 04139 frm->addr = bc->addr | FLG_MSG_DOWN ; 04140 04141 frm->len = len; 04142 memcpy(&buf[mISDN_HEADER_LEN], data,len); 04143 04144 if ( misdn_cap_is_speech(bc->capability) ) 04145 flip_buf_bits( &buf[mISDN_HEADER_LEN], len); 04146 else 04147 cb_log(6, stack->port, "Writing %d data bytes\n",len); 04148 04149 cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); 04150 r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); 04151 return 0; 04152 }
enum event_response_e(* cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
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) |
Referenced by misdn_lib_init(), and misdn_tx_jitter().
void(* cb_log)(int level, int port, char *tmpl,...) |
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_find_bychan(), stack_holder_remove(), stack_init(), and te_lib_destroy().