#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 467 of file isdn_lib.h.
#define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 468 of file isdn_lib.h.
#define PRI_TRANS_CAP_DIGITAL 0x08 |
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 466 of file isdn_lib.h.
#define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 464 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 |
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 553 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().
00553 { 00554 int i; 00555 00556 struct bchan_state_s { 00557 char *n; 00558 enum bchannel_state s; 00559 } states[] = { 00560 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00561 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00562 {"BCHAN_SETUP", BCHAN_SETUP}, 00563 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00564 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00565 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00566 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00567 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00568 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00569 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00570 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00571 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00572 {"BCHAN_ERROR", BCHAN_ERROR} 00573 }; 00574 00575 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00576 if ( states[i].s == state) 00577 return states[i].n; 00578 00579 return "UNKNOWN"; 00580 }
void bc_state_change | ( | struct misdn_bchannel * | bc, | |
enum bchannel_state | state | |||
) |
Definition at line 582 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(), and misdn_split_conf().
00583 { 00584 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00585 bc->l3_id, 00586 bc_state2str(bc->bc_state), 00587 bc_state2str(state) ); 00588 00589 switch (state) { 00590 case BCHAN_ACTIVATED: 00591 if (bc->next_bc_state == BCHAN_BRIDGED) { 00592 misdn_join_conf(bc, bc->conf_id); 00593 bc->next_bc_state = BCHAN_EMPTY; 00594 return; 00595 } 00596 default: 00597 bc->bc_state=state; 00598 break; 00599 } 00600 }
void get_show_stack_details | ( | int | port, | |
char * | buf | |||
) |
Definition at line 135 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by misdn_show_port(), and misdn_show_stacks().
00136 { 00137 struct misdn_stack *stack=get_misdn_stack(); 00138 00139 for ( ; stack; stack=stack->next) { 00140 if (stack->port == port) break; 00141 } 00142 00143 if (stack) { 00144 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); 00145 00146 } else { 00147 buf[0]=0; 00148 } 00149 00150 }
void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4266 of file isdn_lib.c.
References misdn_stack::bc, and manager_ph_control().
Referenced by process_ast_dsp().
04267 { 04268 manager_ph_control(bc, DTMF_TONE_STOP, 0); 04269 }
void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4254 of file isdn_lib.c.
References misdn_stack::bc, misdn_bchannel::ec_enable, manager_ec_disable(), and manager_ec_enable().
Referenced by process_ast_dsp().
04255 { 04256 #ifdef MISDN_1_2 04257 if (*bc->pipeline) 04258 #else 04259 if (bc->ec_enable) 04260 #endif 04261 manager_ec_enable(bc); 04262 else 04263 manager_ec_disable(bc); 04264 }
void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4244 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
04245 { 04246 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 04247 }
void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4249 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
04250 { 04251 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 04252 }
void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4125 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_stack::bc, cb_log, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.
04126 { 04127 char buf[128]; 04128 04129 struct misdn_stack *stack=get_stack_by_bc(bc); 04130 04131 if (!stack) { 04132 cb_log(0, bc->port, "bchannel_activate: Stack not found !"); 04133 return ; 04134 } 04135 04136 /* we must activate if we are deactivated */ 04137 clear_ibuffer(bc->astbuf); 04138 04139 cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); 04140 04141 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); 04142 04143 return ; 04144 }
void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4147 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_stack::bc, 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().
04148 { 04149 char buf[128]; 04150 iframe_t dact; 04151 struct misdn_stack *stack=get_stack_by_bc(bc); 04152 04153 switch (bc->bc_state) { 04154 case BCHAN_ACTIVATED: 04155 break; 04156 case BCHAN_BRIDGED: 04157 misdn_split_conf(bc,bc->conf_id); 04158 break; 04159 default: 04160 cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n"); 04161 return ; 04162 04163 } 04164 04165 cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); 04166 04167 bc->generate_tone=0; 04168 04169 dact.prim = DL_RELEASE | REQUEST; 04170 dact.addr = bc->addr | FLG_MSG_DOWN; 04171 dact.dinfo = 0; 04172 dact.len = 0; 04173 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); 04174 04175 clear_ibuffer(bc->astbuf); 04176 04177 bc_state_change(bc,BCHAN_RELEASE); 04178 04179 return; 04180 }
void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4488 of file isdn_lib.c.
References misdn_stack::bc, 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().
04489 { 04490 struct misdn_stack *stack=get_stack_by_bc(bc); 04491 04492 cb_log(4, stack?stack->port:0," --> ec_disable\n"); 04493 04494 if (!misdn_cap_is_speech(bc->capability)) { 04495 cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); 04496 return; 04497 } 04498 04499 #ifdef MISDN_1_2 04500 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); 04501 #else 04502 if ( ! bc->ec_enable) { 04503 cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); 04504 manager_ph_control(bc, ECHOCAN_OFF, 0); 04505 } 04506 #endif 04507 }
void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4439 of file isdn_lib.c.
References misdn_stack::bc, 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().
04440 { 04441 struct misdn_stack *stack=get_stack_by_bc(bc); 04442 04443 cb_log(4, stack?stack->port:0,"ec_enable\n"); 04444 04445 if (!misdn_cap_is_speech(bc->capability)) { 04446 cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); 04447 } else { 04448 04449 #ifdef MISDN_1_2 04450 if (*bc->pipeline) { 04451 cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); 04452 manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); 04453 } 04454 #else 04455 int ec_arr[2]; 04456 04457 if (bc->ec_enable) { 04458 cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); 04459 04460 switch (bc->ec_deftaps) { 04461 case 4: 04462 case 8: 04463 case 16: 04464 case 32: 04465 case 64: 04466 case 128: 04467 case 256: 04468 case 512: 04469 case 1024: 04470 cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); 04471 break; 04472 default: 04473 cb_log(0, stack->port, "Taps should be power of 2\n"); 04474 bc->ec_deftaps=128; 04475 } 04476 04477 ec_arr[0]=bc->ec_deftaps; 04478 ec_arr[1]=0; 04479 04480 manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); 04481 } 04482 #endif 04483 } 04484 }
char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 4120 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
04121 { 04122 return isdn_get_info(msgs_g , event, 0); 04123 }
void manager_ph_control | ( | struct misdn_bchannel * | bc, | |
int | c1, | |||
int | c2 | |||
) |
Definition at line 4223 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::bc, glob_mgr, 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().
04224 { 04225 unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; 04226 iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ 04227 unsigned int *d = (unsigned int*)&ctrl->data.p; 04228 /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ 04229 04230 cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); 04231 04232 ctrl->prim = PH_CONTROL | REQUEST; 04233 ctrl->addr = bc->addr | FLG_MSG_DOWN; 04234 ctrl->dinfo = 0; 04235 ctrl->len = sizeof(unsigned int)*2; 04236 *d++ = c1; 04237 *d++ = c2; 04238 mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); 04239 }
int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 411 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(), and misdn_lib_tx2misdn_frm().
00413 { 00414 if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && 00415 (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; 00416 return 0; 00417 }
void misdn_dump_chanlist | ( | void | ) |
Definition at line 447 of file isdn_lib.c.
References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.
Referenced by misdn_show_cls().
00448 { 00449 struct misdn_stack *stack=get_misdn_stack(); 00450 for ( ; stack; stack=stack->next) { 00451 dump_chan_list(stack); 00452 } 00453 00454 }
int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 419 of file isdn_lib.c.
References misdn_stack::bc, 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().
00420 { 00421 00422 /*if ! early_bconnect we have never inband available*/ 00423 if ( ! bc->early_bconnect ) return 0; 00424 00425 switch (bc->progress_indicator) { 00426 case INFO_PI_INBAND_AVAILABLE: 00427 case INFO_PI_CALL_NOT_E2E_ISDN: 00428 case INFO_PI_CALLED_NOT_ISDN: 00429 return 1; 00430 default: 00431 return 0; 00432 } 00433 return 0; 00434 }
void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4542 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().
04543 { 04544 int conf_id=bc1->pid +1; 04545 struct misdn_bchannel *bc_list[]={ 04546 bc1,bc2,NULL 04547 }; 04548 struct misdn_bchannel **bc; 04549 04550 cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); 04551 04552 for (bc=bc_list; *bc; bc++) { 04553 (*bc)->conf_id=conf_id; 04554 cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); 04555 04556 switch((*bc)->bc_state) { 04557 case BCHAN_ACTIVATED: 04558 misdn_join_conf(*bc,conf_id); 04559 break; 04560 default: 04561 bc_next_state_change(*bc,BCHAN_BRIDGED); 04562 break; 04563 } 04564 } 04565 }
void misdn_lib_destroy | ( | void | ) |
Definition at line 4087 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, glob_mgr, 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().
04088 { 04089 struct misdn_stack *help; 04090 int i; 04091 04092 for ( help=glob_mgr->stack_list; help; help=help->next ) { 04093 for(i=0;i<=help->b_num; i++) { 04094 char buf[1024]; 04095 mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 04096 help->bc[i].addr = 0; 04097 } 04098 cb_log (1, help->port, "Destroying this port.\n"); 04099 stack_destroy(help); 04100 } 04101 04102 if (global_state == MISDN_INITIALIZED) { 04103 cb_log(4, 0, "Killing Handler Thread\n"); 04104 if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { 04105 cb_log(4, 0, "Joining Handler Thread\n"); 04106 pthread_join(glob_mgr->event_handler_thread, NULL); 04107 } 04108 04109 cb_log(4, 0, "Killing Main Thread\n"); 04110 if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { 04111 cb_log(4, 0, "Joining Main Thread\n"); 04112 pthread_join(glob_mgr->event_thread, NULL); 04113 } 04114 } 04115 04116 cb_log(1, 0, "Closing mISDN device\n"); 04117 te_lib_destroy(glob_mgr->midev); 04118 }
void misdn_lib_echo | ( | struct misdn_bchannel * | bc, | |
int | onoff | |||
) |
Definition at line 4587 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
04588 { 04589 cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); 04590 manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); 04591 }
struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, | |
int | channel, | |||
int | inout, | |||
int | dec | |||
) |
Definition at line 3161 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, glob_mgr, MAX_BCHANS, misdn_stack::next, misdn_stack::port, prepare_bc(), misdn_stack::pri, misdn_stack::ptp, misdn_lib::stack_list, and test_inuse().
Referenced by handle_cr(), handle_event_nt(), and misdn_request().
03162 { 03163 struct misdn_stack *stack; 03164 int i; 03165 03166 if (channel < 0 || channel > MAX_BCHANS) { 03167 cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); 03168 return NULL; 03169 } 03170 03171 usleep(1000); 03172 03173 for (stack=glob_mgr->stack_list; stack; stack=stack->next) { 03174 03175 if (stack->port == port) { 03176 int maxnum; 03177 if (stack->blocked) { 03178 cb_log(0,port,"Port is blocked\n"); 03179 return NULL; 03180 } 03181 03182 if (channel > 0) { 03183 if (channel <= stack->b_num) { 03184 for (i = 0; i < stack->b_num; i++) { 03185 if ( stack->bc[i].channel == channel) { 03186 if (test_inuse(&stack->bc[i])) { 03187 cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); 03188 return NULL; 03189 03190 } else { 03191 prepare_bc(&stack->bc[i], channel); 03192 return &stack->bc[i]; 03193 } 03194 } 03195 } 03196 } else { 03197 cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); 03198 return NULL; 03199 } 03200 } 03201 03202 maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num; 03203 03204 if (dec) { 03205 for (i = maxnum-1; i>=0; i--) { 03206 if (!test_inuse(&stack->bc[i])) { 03207 /* 3. channel on bri means CW*/ 03208 if (!stack->pri && i==stack->b_num) 03209 stack->bc[i].cw=1; 03210 03211 prepare_bc(&stack->bc[i], channel); 03212 stack->bc[i].dec=1; 03213 return &stack->bc[i]; 03214 } 03215 } 03216 } else { 03217 for (i = 0; i <maxnum; i++) { 03218 if (!test_inuse(&stack->bc[i])) { 03219 /* 3. channel on bri means CW*/ 03220 if (!stack->pri && i==stack->b_num) 03221 stack->bc[i].cw=1; 03222 03223 prepare_bc(&stack->bc[i], channel); 03224 return &stack->bc[i]; 03225 } 03226 } 03227 } 03228 03229 cb_log(1,port,"There is no free channel on port (%d)\n",port); 03230 return NULL; 03231 } 03232 } 03233 03234 cb_log(0,port,"Port is not configured (%d)\n",port); 03235 return NULL; 03236 }
int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 103 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
00104 { 00105 struct misdn_stack *stack=get_misdn_stack(); 00106 for ( ; stack; stack=stack->next) { 00107 if (stack->port == port) { 00108 if (stack->pri) 00109 return 30; 00110 else 00111 return 2; 00112 } 00113 } 00114 return -1; 00115 }
int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1724 of file isdn_lib.c.
References glob_mgr, 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().
01725 { /* Pull Down L1 */ 01726 struct misdn_stack *stack; 01727 for (stack=glob_mgr->stack_list; 01728 stack; 01729 stack=stack->next) { 01730 if (stack->port == port) { 01731 if (stack->l2link) 01732 misdn_lib_get_l2_down(stack); 01733 misdn_lib_get_l1_down(stack); 01734 return 0; 01735 } 01736 } 01737 return 0; 01738 }
int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3693 of file isdn_lib.c.
References misdn_lib::activatequeue, cb_log, find_stack_by_port(), glob_mgr, misdn_lib::new_msg, and misdn_stack::upper_id.
03694 { 03695 msg_t *msg=alloc_msg(MAX_MSG_SIZE); 03696 iframe_t *frm; 03697 struct misdn_stack *stack=find_stack_by_port(port); 03698 if (!msg) { 03699 cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n"); 03700 return -1; 03701 } 03702 frm=(iframe_t*)msg->data; 03703 if (!stack ) { 03704 cb_log(0, port, "There is no Stack for this port.\n"); 03705 return -1; 03706 } 03707 /* activate bchannel */ 03708 frm->prim = CC_STATUS_ENQUIRY | REQUEST; 03709 03710 frm->addr = stack->upper_id| FLG_MSG_DOWN; 03711 03712 frm->dinfo = 0; 03713 frm->len = 0; 03714 03715 msg_queue_tail(&glob_mgr->activatequeue, msg); 03716 sem_post(&glob_mgr->new_msg); 03717 03718 03719 return 0; 03720 }
int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1702 of file isdn_lib.c.
References glob_mgr, 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().
01703 { /* Pull Up L1 */ 01704 struct misdn_stack *stack; 01705 01706 for (stack=glob_mgr->stack_list; 01707 stack; 01708 stack=stack->next) { 01709 01710 if (stack->port == port) { 01711 01712 if (!stack->l1link) 01713 misdn_lib_get_l1_up(stack); 01714 if (!stack->l2link) 01715 misdn_lib_get_l2_up(stack); 01716 01717 return 0; 01718 } 01719 } 01720 return 0; 01721 }
int misdn_lib_init | ( | char * | portlist, | |
struct misdn_lib_iface * | iface, | |||
void * | user_data | |||
) |
Definition at line 3979 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, cb_log, misdn_lib_iface::cb_log, flip_buf_bits(), glob_mgr, init_bc(), init_flip_bits(), misdn_stack::mgr, misdn_stack::midev, misdn_lib::midev, misdn_lib_nt_debug_init(), misdn_lib::new_msg, misdn_stack::next, misdn_stack::port, ptp, stack_init(), te_lib_init(), tone_425_flip, and tone_silence_flip.
Referenced by load_module().
03980 { 03981 struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); 03982 char *tok, *tokb; 03983 char plist[1024]; 03984 int midev; 03985 int port_count=0; 03986 03987 cb_log = iface->cb_log; 03988 cb_event = iface->cb_event; 03989 cb_jb_empty = iface->cb_jb_empty; 03990 03991 glob_mgr = mgr; 03992 03993 msg_init(); 03994 03995 misdn_lib_nt_debug_init(0,NULL); 03996 03997 if (!portlist || (*portlist == 0) ) return 1; 03998 03999 init_flip_bits(); 04000 04001 { 04002 strncpy(plist,portlist, 1024); 04003 plist[1023] = 0; 04004 } 04005 04006 memcpy(tone_425_flip,tone_425,TONE_425_SIZE); 04007 flip_buf_bits(tone_425_flip,TONE_425_SIZE); 04008 04009 memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); 04010 flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); 04011 04012 midev=te_lib_init(); 04013 mgr->midev=midev; 04014 04015 port_count=mISDN_get_stack_count(midev); 04016 04017 msg_queue_init(&mgr->activatequeue); 04018 04019 if (sem_init(&mgr->new_msg, 1, 0)<0) 04020 sem_init(&mgr->new_msg, 0, 0); 04021 04022 for (tok=strtok_r(plist," ,",&tokb ); 04023 tok; 04024 tok=strtok_r(NULL," ,",&tokb)) { 04025 int port = atoi(tok); 04026 struct misdn_stack *stack; 04027 static int first=1; 04028 int ptp=0; 04029 04030 if (strstr(tok, "ptp")) 04031 ptp=1; 04032 04033 if (port > port_count) { 04034 cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); 04035 exit(1); 04036 } 04037 stack=stack_init(midev, port, ptp); 04038 04039 if (!stack) { 04040 perror("init_stack"); 04041 exit(1); 04042 } 04043 04044 { 04045 int i; 04046 for(i=0;i<=stack->b_num; i++) { 04047 int r; 04048 if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { 04049 cb_log(0, port, "Got Err @ init_bc :%d\n",r); 04050 exit(1); 04051 } 04052 } 04053 } 04054 04055 if (stack && first) { 04056 mgr->stack_list=stack; 04057 first=0; 04058 continue; 04059 } 04060 04061 if (stack) { 04062 struct misdn_stack * help; 04063 for ( help=mgr->stack_list; help; help=help->next ) 04064 if (help->next == NULL) break; 04065 help->next=stack; 04066 } 04067 04068 } 04069 04070 if (sem_init(&handler_started, 1, 0)<0) 04071 sem_init(&handler_started, 0, 0); 04072 04073 cb_log(8, 0, "Starting Event Handler\n"); 04074 pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); 04075 04076 sem_wait(&handler_started) ; 04077 cb_log(8, 0, "Starting Event Catcher\n"); 04078 pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); 04079 04080 cb_log(8, 0, "Event Catcher started\n"); 04081 04082 global_state= MISDN_INITIALIZED; 04083 04084 return (mgr == NULL); 04085 }
int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 83 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
00084 { 00085 struct misdn_stack *stack=get_misdn_stack(); 00086 for ( ; stack; stack=stack->next) { 00087 if (stack->port == port) { 00088 return stack->blocked; 00089 } 00090 } 00091 return -1; 00092 }
int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 94 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().
00095 { 00096 struct misdn_stack *stack=get_misdn_stack(); 00097 for ( ; stack; stack=stack->next) { 00098 if (stack->port == port) return stack->ptp; 00099 } 00100 return -1; 00101 }
void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 2986 of file isdn_lib.c.
References cb_log, glob_mgr, 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().
02987 { 02988 struct misdn_stack *stack; 02989 02990 for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) 02991 ; 02992 02993 if (stack) { 02994 cb_log(4, port, "Checking L1 State\n"); 02995 if (!stack->l1link) { 02996 cb_log(4, port, "L1 State Down, trying to get it up again\n"); 02997 misdn_lib_get_short_status(stack); 02998 misdn_lib_get_l1_up(stack); 02999 misdn_lib_get_l2_up(stack); 03000 } 03001 } 03002 }
void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3257 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::b_stid, misdn_stack::bc, 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().
03258 { 03259 struct misdn_stack *stack; 03260 if (!bc) return; 03261 03262 stack=get_stack_by_bc(bc); 03263 03264 if (!stack) return; 03265 03266 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); 03267 03268 cb_log(2, stack->port, 03269 " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", 03270 bc->info_dad, 03271 bc->onumplan>=0?'0'+bc->onumplan:' ', 03272 bc->dnumplan>=0?'0'+bc->dnumplan:' ', 03273 bc->rnumplan>=0?'0'+bc->rnumplan:' ', 03274 bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' 03275 ); 03276 03277 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); 03278 cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", 03279 bc->screen, bc->pres); 03280 03281 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); 03282 03283 cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); 03284 03285 cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); 03286 03287 cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); 03288 }
int misdn_lib_maxports_get | ( | void | ) |
Definition at line 3931 of file isdn_lib.c.
Referenced by load_module().
03931 { /** BE AWARE WE HAVE NO CB_LOG HERE! **/ 03932 03933 int i = mISDN_open(); 03934 int max=0; 03935 03936 if (i<0) 03937 return -1; 03938 03939 max = mISDN_get_stack_count(i); 03940 03941 mISDN_close(i); 03942 03943 return max; 03944 }
void misdn_lib_nt_debug_init | ( | int | flags, | |
char * | file | |||
) |
Definition at line 3959 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
03960 { 03961 int static init=0; 03962 char *f; 03963 03964 if (!flags) 03965 f=NULL; 03966 else 03967 f=file; 03968 03969 if (!init) { 03970 debug_init( flags , f, f, f); 03971 init=1; 03972 } else { 03973 debug_close(); 03974 debug_init( flags , f, f, f); 03975 } 03976 }
void misdn_lib_nt_keepcalls | ( | int | kc | ) |
Definition at line 3947 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::nst.
Referenced by load_module().
03948 { 03949 #ifdef FEATURE_NET_KEEPCALLS 03950 if (kc) { 03951 struct misdn_stack *stack=get_misdn_stack(); 03952 for ( ; stack; stack=stack->next) { 03953 stack->nst.feature |= FEATURE_NET_KEEPCALLS; 03954 } 03955 } 03956 #endif 03957 }
int misdn_lib_pid_restart | ( | int | pid | ) |
int misdn_lib_port_block | ( | int | port | ) |
Definition at line 57 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().
00058 { 00059 struct misdn_stack *stack=get_misdn_stack(); 00060 for ( ; stack; stack=stack->next) { 00061 if (stack->port == port) { 00062 stack->blocked=1; 00063 return 0; 00064 } 00065 } 00066 return -1; 00067 00068 }
int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 35 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().
00036 { 00037 struct misdn_stack *stack=get_misdn_stack(); 00038 for ( ; stack; stack=stack->next) { 00039 if (stack->port == port) { 00040 return stack->pri; 00041 } 00042 } 00043 00044 return -1; 00045 }
int misdn_lib_port_restart | ( | int | port | ) |
int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 70 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by misdn_port_unblock().
00071 { 00072 struct misdn_stack *stack=get_misdn_stack(); 00073 for ( ; stack; stack=stack->next) { 00074 if (stack->port == port) { 00075 stack->blocked=0; 00076 return 0; 00077 } 00078 } 00079 return -1; 00080 00081 }
int misdn_lib_port_up | ( | int | port, | |
int | notcheck | |||
) |
Definition at line 1740 of file isdn_lib.c.
References misdn_stack::blocked, cb_log, glob_mgr, 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().
01741 { 01742 struct misdn_stack *stack; 01743 01744 01745 for (stack=glob_mgr->stack_list; 01746 stack; 01747 stack=stack->next) { 01748 01749 if (stack->port == port) { 01750 01751 if (stack->blocked) { 01752 cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); 01753 return -1; 01754 } 01755 01756 if (stack->ptp ) { 01757 01758 if (stack->l1link && stack->l2link) { 01759 return 1; 01760 } else { 01761 cb_log(1,port, "Port Down L2:%d L1:%d\n", 01762 stack->l2link, stack->l1link); 01763 return 0; 01764 } 01765 } else { 01766 if ( !check || stack->l1link ) 01767 return 1; 01768 else { 01769 cb_log(1,port, "Port down PMP\n"); 01770 return 0; 01771 } 01772 } 01773 } 01774 } 01775 01776 return -1; 01777 }
void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4595 of file isdn_lib.c.
References misdn_stack::blocked, misdn_stack::d_stid, find_stack_by_port(), glob_mgr, 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().
04596 { 04597 struct misdn_stack *stack=find_stack_by_port(port); 04598 04599 if (stack) { 04600 stack->l2link=0; 04601 stack->blocked=0; 04602 04603 cleanup_Isdnl3(&stack->nst); 04604 cleanup_Isdnl2(&stack->nst); 04605 04606 04607 memset(&stack->nst, 0, sizeof(net_stack_t)); 04608 memset(&stack->mgr, 0, sizeof(manager_t)); 04609 04610 stack->mgr.nst = &stack->nst; 04611 stack->nst.manager = &stack->mgr; 04612 04613 stack->nst.l3_manager = handle_event_nt; 04614 stack->nst.device = glob_mgr->midev; 04615 stack->nst.cardnr = port; 04616 stack->nst.d_stid = stack->d_stid; 04617 04618 stack->nst.feature = FEATURE_NET_HOLD; 04619 if (stack->ptp) 04620 stack->nst.feature |= FEATURE_NET_PTP; 04621 if (stack->pri) 04622 stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; 04623 04624 stack->nst.l1_id = stack->lower_id; 04625 stack->nst.l2_id = stack->upper_id; 04626 04627 msg_queue_init(&stack->nst.down_queue); 04628 04629 Isdnl2Init(&stack->nst); 04630 Isdnl3Init(&stack->nst); 04631 04632 if (!stack->ptp) 04633 misdn_lib_get_l1_up(stack); 04634 misdn_lib_get_l2_up(stack); 04635 } 04636 }
void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1682 of file isdn_lib.c.
References misdn_stack::bc, 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().
01683 { 01684 struct misdn_stack *stack=get_stack_by_bc(bc); 01685 01686 if (!stack) { 01687 cb_log(1,0,"misdn_release: No Stack found\n"); 01688 return; 01689 } 01690 01691 if (bc->channel>0) 01692 empty_chan_in_stack(stack,bc->channel); 01693 01694 empty_bc(bc); 01695 clean_up_bc(bc); 01696 bc->in_use=0; 01697 }
int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, | |
enum event_e | event | |||
) |
Definition at line 3309 of file isdn_lib.c.
References misdn_stack::bc, 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(), glob_mgr, 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().
03310 { 03311 msg_t *msg; 03312 struct misdn_stack *stack; 03313 int retval=0; 03314 03315 if (!bc) RETURN(-1,OUT_POST_UNLOCK); 03316 03317 stack=get_stack_by_bc(bc); 03318 03319 if (!stack) { 03320 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); 03321 RETURN(-1,OUT); 03322 } 03323 03324 misdn_send_lock(bc); 03325 03326 03327 cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id); 03328 03329 if ( stack->nt && !stack->l1link) { 03330 /** Queue Event **/ 03331 bc->evq=event; 03332 cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); 03333 misdn_lib_get_l1_up(stack); 03334 RETURN(0,OUT); 03335 } 03336 03337 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); 03338 cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); 03339 misdn_lib_log_ies(bc); 03340 03341 switch (event) { 03342 case EVENT_SETUP: 03343 if (create_process(glob_mgr->midev, bc)<0) { 03344 cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); 03345 03346 RETURN(-ENOCHAN,OUT); 03347 } 03348 break; 03349 03350 case EVENT_PROGRESS: 03351 case EVENT_ALERTING: 03352 case EVENT_PROCEEDING: 03353 case EVENT_SETUP_ACKNOWLEDGE: 03354 case EVENT_CONNECT: 03355 if (!stack->nt) break; 03356 03357 case EVENT_RETRIEVE_ACKNOWLEDGE: 03358 03359 if (stack->nt) { 03360 if (bc->channel <=0 ) { /* else we have the channel already */ 03361 if (find_free_chan_in_stack(stack, bc, 0, 0)<0) { 03362 cb_log(0, stack->port, " No free channel at the moment\n"); 03363 /*FIXME: add disconnect*/ 03364 RETURN(-ENOCHAN,OUT); 03365 } 03366 } 03367 /* Its that i generate channels */ 03368 } 03369 03370 retval=setup_bc(bc); 03371 if (retval == -EINVAL) { 03372 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03373 } 03374 03375 if (misdn_cap_is_speech(bc->capability)) { 03376 if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { 03377 if ( *bc->crypt_key ) { 03378 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); 03379 03380 manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); 03381 } 03382 03383 if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03384 manager_ec_enable(bc); 03385 03386 if (bc->txgain != 0) { 03387 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03388 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03389 } 03390 03391 if ( bc->rxgain != 0 ) { 03392 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03393 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03394 } 03395 } 03396 } 03397 break; 03398 03399 case EVENT_HOLD_ACKNOWLEDGE: 03400 { 03401 struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel)); 03402 if (!holded_bc) { 03403 cb_log(0,bc->port, "Could not allocate holded_bc!!!\n"); 03404 RETURN(-1,OUT); 03405 } 03406 03407 /*backup the bc*/ 03408 memcpy(holded_bc,bc,sizeof(struct misdn_bchannel)); 03409 holded_bc->holded=1; 03410 bc_state_change(holded_bc,BCHAN_CLEANED); 03411 03412 stack_holder_add(stack,holded_bc); 03413 03414 /*kill the bridge and clean the bchannel*/ 03415 if (stack->nt) { 03416 int channel; 03417 if (bc->bc_state == BCHAN_BRIDGED) { 03418 struct misdn_bchannel *bc2; 03419 misdn_split_conf(bc,bc->conf_id); 03420 bc2=find_bc_by_confid(bc->conf_id); 03421 if (!bc2) { 03422 cb_log(0,bc->port,"We have no second bc in bridge???\n"); 03423 } else { 03424 misdn_split_conf(bc2,bc->conf_id); 03425 } 03426 } 03427 03428 channel=bc->channel; 03429 03430 empty_bc(bc); 03431 clean_up_bc(bc); 03432 03433 if (channel>0) 03434 empty_chan_in_stack(stack,channel); 03435 03436 bc->in_use=0; 03437 } 03438 03439 } 03440 break; 03441 03442 /* finishing the channel eh ? */ 03443 case EVENT_DISCONNECT: 03444 if (!bc->need_disconnect) { 03445 cb_log(0,bc->port," --> we have already send Disconnect\n"); 03446 RETURN(-1,OUT); 03447 } 03448 03449 bc->need_disconnect=0; 03450 break; 03451 case EVENT_RELEASE: 03452 if (!bc->need_release) { 03453 cb_log(0,bc->port," --> we have already send Release\n"); 03454 RETURN(-1,OUT); 03455 } 03456 bc->need_disconnect=0; 03457 bc->need_release=0; 03458 break; 03459 case EVENT_RELEASE_COMPLETE: 03460 if (!bc->need_release_complete) { 03461 cb_log(0,bc->port," --> we have already send Release_complete\n"); 03462 RETURN(-1,OUT); 03463 } 03464 bc->need_disconnect=0; 03465 bc->need_release=0; 03466 bc->need_release_complete=0; 03467 03468 if (!stack->nt) { 03469 /*create clenaup in TE*/ 03470 int channel=bc->channel; 03471 03472 int tmpcause=bc->cause; 03473 int tmp_out_cause=bc->out_cause; 03474 empty_bc(bc); 03475 bc->cause=tmpcause; 03476 bc->out_cause=tmp_out_cause; 03477 clean_up_bc(bc); 03478 03479 if (channel>0) 03480 empty_chan_in_stack(stack,channel); 03481 03482 bc->in_use=0; 03483 } 03484 break; 03485 03486 case EVENT_CONNECT_ACKNOWLEDGE: 03487 03488 if ( bc->nt || misdn_cap_is_speech(bc->capability)) { 03489 int retval=setup_bc(bc); 03490 if (retval == -EINVAL){ 03491 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03492 03493 } 03494 } 03495 03496 if (misdn_cap_is_speech(bc->capability)) { 03497 if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03498 manager_ec_enable(bc); 03499 03500 if ( bc->txgain != 0 ) { 03501 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03502 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03503 } 03504 if ( bc->rxgain != 0 ) { 03505 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03506 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03507 } 03508 } 03509 break; 03510 03511 default: 03512 break; 03513 } 03514 03515 /* Later we should think about sending bchannel data directly to misdn. */ 03516 msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); 03517 msg_queue_tail(&stack->downqueue, msg); 03518 sem_post(&glob_mgr->new_msg); 03519 03520 OUT: 03521 misdn_send_unlock(bc); 03522 03523 OUT_POST_UNLOCK: 03524 return retval; 03525 }
int misdn_lib_send_restart | ( | int | port, | |
int | channel | |||
) |
Definition at line 3759 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().
03760 { 03761 struct misdn_bchannel dummybc; 03762 struct misdn_stack *stack=find_stack_by_port(port); 03763 cb_log(0, port, "Sending Restarts on this port.\n"); 03764 03765 make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); 03766 03767 /*default is all channels*/ 03768 if (channel <0) { 03769 dummybc.channel=-1; 03770 cb_log(0, port, "Restarting and all Interfaces\n"); 03771 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03772 03773 return 0; 03774 } 03775 03776 /*if a channel is specified we restart only this one*/ 03777 if (channel >0) { 03778 int cnt; 03779 dummybc.channel=channel; 03780 cb_log(0, port, "Restarting and cleaning channel %d\n",channel); 03781 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03782 /* clean up chan in stack, to be sure we don't think it's 03783 * in use anymore */ 03784 for (cnt=0; cnt<=stack->b_num; cnt++) { 03785 if (stack->bc[cnt].channel == channel) { 03786 empty_bc(&stack->bc[cnt]); 03787 clean_up_bc(&stack->bc[cnt]); 03788 stack->bc[cnt].in_use=0; 03789 } 03790 } 03791 } 03792 03793 return 0; 03794 }
void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, | |
enum tone_e | tone | |||
) |
Definition at line 4404 of file isdn_lib.c.
References misdn_bchannel::addr, glob_mgr, manager_ph_control(), misdn_lib::midev, TONE_ALERTING, TONE_DIAL, TONE_HANGUP, and TONE_NONE.
Referenced by hanguptone_indicate().
04405 { 04406 char buf[mISDN_HEADER_LEN+128]; 04407 iframe_t *frm; 04408 04409 switch(tone) { 04410 case TONE_DIAL: 04411 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 04412 break; 04413 04414 case TONE_ALERTING: 04415 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); 04416 break; 04417 04418 case TONE_HANGUP: 04419 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); 04420 break; 04421 04422 case TONE_NONE: 04423 default: 04424 manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); 04425 } 04426 04427 frm=(iframe_t*)buf; 04428 memset(buf,0,mISDN_HEADER_LEN+128); 04429 04430 frm->prim=DL_DATA|REQUEST; 04431 frm->addr=bc->addr|FLG_MSG_DOWN; 04432 frm->dinfo=0; 04433 frm->len=128; 04434 04435 mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); 04436 }
void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 945 of file isdn_lib.c.
References misdn_stack::bc, clean_up_bc(), and setup_bc().
00946 { 00947 clean_up_bc(bc); 00948 setup_bc(bc); 00949 }
void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4567 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
04568 { 04569 04570 struct misdn_bchannel *bc_list[]={ 04571 bc1,bc2,NULL 04572 }; 04573 struct misdn_bchannel **bc; 04574 04575 for (bc=bc_list; *bc; bc++) { 04576 if ( (*bc)->bc_state == BCHAN_BRIDGED){ 04577 misdn_split_conf( *bc, (*bc)->conf_id); 04578 } else { 04579 cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); 04580 } 04581 } 04582 04583 }
void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2184 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by misdn_write().
02185 { 02186 bc->generate_tone=1; 02187 }
void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2189 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
02190 { 02191 bc->generate_tone=0; 02192 }
void misdn_lib_transfer | ( | struct misdn_bchannel * | holded_bc | ) |
Definition at line 3093 of file isdn_lib.c.
References misdn_bchannel::holded.
03094 { 03095 holded_bc->holded=0; 03096 }
int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, | |
void * | data, | |||
int | len | |||
) |
Definition at line 4183 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::bc, 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().
04184 { 04185 char buf[4096 + mISDN_HEADER_LEN]; 04186 iframe_t *frm; 04187 int r; 04188 struct misdn_stack *stack=get_stack_by_bc(bc); 04189 04190 switch (bc->bc_state) { 04191 case BCHAN_ACTIVATED: 04192 case BCHAN_BRIDGED: 04193 break; 04194 default: 04195 cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); 04196 return -1; 04197 } 04198 04199 frm= (iframe_t*)buf; 04200 04201 frm->prim = DL_DATA|REQUEST; 04202 frm->dinfo = 0; 04203 frm->addr = bc->addr | FLG_MSG_DOWN ; 04204 04205 frm->len = len; 04206 memcpy(&buf[mISDN_HEADER_LEN], data,len); 04207 04208 if ( misdn_cap_is_speech(bc->capability) ) 04209 flip_buf_bits( &buf[mISDN_HEADER_LEN], len); 04210 else 04211 cb_log(6, stack->port, "Writing %d data bytes\n",len); 04212 04213 cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); 04214 r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); 04215 return 0; 04216 }
enum event_response_e(*) cb_event(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
Definition at line 373 of file isdn_lib.h.
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(), and set_channel().
int(*) cb_jb_empty(struct misdn_bchannel *bc, char *buffer, int len) |
void(*) cb_log(int level, int port, char *tmpl,...) |
Definition at line 374 of file isdn_lib.h.
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(), 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(), 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(), te_lib_destroy(), and test_inuse().