#include <mISDNuser/suppserv.h>
Include dependency graph for isdn_lib.h:
This graph shows which files directly or indirectly include this file:
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 464 of file isdn_lib.h.
#define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 465 of file isdn_lib.h.
#define PRI_TRANS_CAP_DIGITAL 0x08 |
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 463 of file isdn_lib.h.
#define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 461 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 548 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().
00548 { 00549 int i; 00550 00551 struct bchan_state_s { 00552 char *n; 00553 enum bchannel_state s; 00554 } states[] = { 00555 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00556 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00557 {"BCHAN_SETUP", BCHAN_SETUP}, 00558 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00559 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00560 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00561 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00562 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00563 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00564 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00565 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00566 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00567 {"BCHAN_ERROR", BCHAN_ERROR} 00568 }; 00569 00570 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00571 if ( states[i].s == state) 00572 return states[i].n; 00573 00574 return "UNKNOWN"; 00575 }
void bc_state_change | ( | struct misdn_bchannel * | bc, | |
enum bchannel_state | state | |||
) |
Definition at line 577 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().
00578 { 00579 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00580 bc->l3_id, 00581 bc_state2str(bc->bc_state), 00582 bc_state2str(state) ); 00583 00584 switch (state) { 00585 case BCHAN_ACTIVATED: 00586 if (bc->next_bc_state == BCHAN_BRIDGED) { 00587 misdn_join_conf(bc, bc->conf_id); 00588 bc->next_bc_state = BCHAN_EMPTY; 00589 return; 00590 } 00591 default: 00592 bc->bc_state=state; 00593 break; 00594 } 00595 }
void get_show_stack_details | ( | int | port, | |
char * | buf | |||
) |
Definition at line 132 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().
00133 { 00134 struct misdn_stack *stack=get_misdn_stack(); 00135 00136 for ( ; stack; stack=stack->next) { 00137 if (stack->port == port) break; 00138 } 00139 00140 if (stack) { 00141 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); 00142 00143 } else { 00144 buf[0]=0; 00145 } 00146 00147 }
void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4160 of file isdn_lib.c.
References misdn_stack::bc, and manager_ph_control().
Referenced by process_ast_dsp().
04161 { 04162 manager_ph_control(bc, DTMF_TONE_STOP, 0); 04163 }
void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4148 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().
04149 { 04150 #ifdef MISDN_1_2 04151 if (*bc->pipeline) 04152 #else 04153 if (bc->ec_enable) 04154 #endif 04155 manager_ec_enable(bc); 04156 else 04157 manager_ec_disable(bc); 04158 }
void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4138 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
04139 { 04140 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 04141 }
void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4143 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
04144 { 04145 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 04146 }
void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4018 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.
04019 { 04020 char buf[128]; 04021 04022 struct misdn_stack *stack=get_stack_by_bc(bc); 04023 04024 if (!stack) { 04025 cb_log(0, bc->port, "bchannel_activate: Stack not found !"); 04026 return ; 04027 } 04028 04029 /* we must activate if we are deactivated */ 04030 clear_ibuffer(bc->astbuf); 04031 04032 cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); 04033 04034 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); 04035 04036 return ; 04037 }
void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4040 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().
04041 { 04042 04043 struct misdn_stack *stack=get_stack_by_bc(bc); 04044 04045 04046 switch (bc->bc_state) { 04047 case BCHAN_ACTIVATED: 04048 break; 04049 case BCHAN_BRIDGED: 04050 misdn_split_conf(bc,bc->conf_id); 04051 break; 04052 default: 04053 cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n"); 04054 return ; 04055 04056 } 04057 04058 cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); 04059 04060 bc->generate_tone=0; 04061 04062 iframe_t dact; 04063 dact.prim = DL_RELEASE | REQUEST; 04064 dact.addr = bc->addr | FLG_MSG_DOWN; 04065 dact.dinfo = 0; 04066 dact.len = 0; 04067 char buf[128]; 04068 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); 04069 04070 clear_ibuffer(bc->astbuf); 04071 04072 bc_state_change(bc,BCHAN_RELEASE); 04073 04074 return; 04075 }
void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4381 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().
04382 { 04383 struct misdn_stack *stack=get_stack_by_bc(bc); 04384 04385 cb_log(4, stack?stack->port:0," --> ec_disable\n"); 04386 04387 if (!misdn_cap_is_speech(bc->capability)) { 04388 cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); 04389 return; 04390 } 04391 04392 #ifdef MISDN_1_2 04393 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); 04394 #else 04395 if ( ! bc->ec_enable) { 04396 cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); 04397 manager_ph_control(bc, ECHOCAN_OFF, 0); 04398 } 04399 #endif 04400 }
void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4332 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().
04333 { 04334 struct misdn_stack *stack=get_stack_by_bc(bc); 04335 04336 cb_log(4, stack?stack->port:0,"ec_enable\n"); 04337 04338 if (!misdn_cap_is_speech(bc->capability)) { 04339 cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); 04340 } else { 04341 04342 #ifdef MISDN_1_2 04343 if (*bc->pipeline) { 04344 cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); 04345 manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); 04346 } 04347 #else 04348 int ec_arr[2]; 04349 04350 if (bc->ec_enable) { 04351 cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); 04352 04353 switch (bc->ec_deftaps) { 04354 case 4: 04355 case 8: 04356 case 16: 04357 case 32: 04358 case 64: 04359 case 128: 04360 case 256: 04361 case 512: 04362 case 1024: 04363 cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); 04364 break; 04365 default: 04366 cb_log(0, stack->port, "Taps should be power of 2\n"); 04367 bc->ec_deftaps=128; 04368 } 04369 04370 ec_arr[0]=bc->ec_deftaps; 04371 ec_arr[1]=0; 04372 04373 manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); 04374 } 04375 #endif 04376 } 04377 }
char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 4013 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
04014 { 04015 return isdn_get_info(msgs_g , event, 0); 04016 }
void manager_ph_control | ( | struct misdn_bchannel * | bc, | |
int | c1, | |||
int | c2 | |||
) |
Definition at line 4117 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().
04118 { 04119 unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; 04120 iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ 04121 unsigned int *d = (unsigned int*)&ctrl->data.p; 04122 /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ 04123 04124 cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); 04125 04126 ctrl->prim = PH_CONTROL | REQUEST; 04127 ctrl->addr = bc->addr | FLG_MSG_DOWN; 04128 ctrl->dinfo = 0; 04129 ctrl->len = sizeof(unsigned int)*2; 04130 *d++ = c1; 04131 *d++ = c2; 04132 mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); 04133 }
int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 407 of file isdn_lib.c.
References INFO_CAPABILITY_DIGITAL_RESTRICTED, and INFO_CAPABILITY_DIGITAL_UNRESTRICTED.
Referenced by handle_bchan(), handle_event(), manager_ec_disable(), manager_ec_enable(), misdn_lib_send_event(), and misdn_lib_tx2misdn_frm().
00409 { 00410 if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && 00411 (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; 00412 return 0; 00413 }
void misdn_dump_chanlist | ( | void | ) |
Definition at line 443 of file isdn_lib.c.
References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.
00444 { 00445 struct misdn_stack *stack=get_misdn_stack(); 00446 for ( ; stack; stack=stack->next) { 00447 dump_chan_list(stack); 00448 } 00449 00450 }
int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 415 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 misdn_indication().
00416 { 00417 00418 /*if ! early_bconnect we have never inband available*/ 00419 if ( ! bc->early_bconnect ) return 0; 00420 00421 switch (bc->progress_indicator) { 00422 case INFO_PI_INBAND_AVAILABLE: 00423 case INFO_PI_CALL_NOT_E2E_ISDN: 00424 case INFO_PI_CALLED_NOT_ISDN: 00425 return 1; 00426 default: 00427 return 0; 00428 } 00429 return 0; 00430 }
void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4435 of file isdn_lib.c.
References bc_next_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, misdn_join_conf(), misdn_bchannel::pid, and misdn_bchannel::port.
Referenced by misdn_bridge().
04435 { 04436 int conf_id=bc1->pid +1; 04437 04438 cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); 04439 04440 struct misdn_bchannel *bc_list[]={ 04441 bc1,bc2,NULL 04442 }; 04443 struct misdn_bchannel **bc; 04444 04445 for (bc=bc_list; *bc; bc++) { 04446 (*bc)->conf_id=conf_id; 04447 cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); 04448 04449 switch((*bc)->bc_state) { 04450 case BCHAN_ACTIVATED: 04451 misdn_join_conf(*bc,conf_id); 04452 break; 04453 default: 04454 bc_next_state_change(*bc,BCHAN_BRIDGED); 04455 break; 04456 } 04457 } 04458 }
void misdn_lib_destroy | ( | void | ) |
Definition at line 3980 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().
03981 { 03982 struct misdn_stack *help; 03983 int i; 03984 03985 for ( help=glob_mgr->stack_list; help; help=help->next ) { 03986 for(i=0;i<=help->b_num; i++) { 03987 char buf[1024]; 03988 mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 03989 help->bc[i].addr = 0; 03990 } 03991 cb_log (1, help->port, "Destroying this port.\n"); 03992 stack_destroy(help); 03993 } 03994 03995 if (global_state == MISDN_INITIALIZED) { 03996 cb_log(4, 0, "Killing Handler Thread\n"); 03997 if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { 03998 cb_log(4, 0, "Joining Handler Thread\n"); 03999 pthread_join(glob_mgr->event_handler_thread, NULL); 04000 } 04001 04002 cb_log(4, 0, "Killing Main Thread\n"); 04003 if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { 04004 cb_log(4, 0, "Joining Main Thread\n"); 04005 pthread_join(glob_mgr->event_thread, NULL); 04006 } 04007 } 04008 04009 cb_log(1, 0, "Closing mISDN device\n"); 04010 te_lib_destroy(glob_mgr->midev); 04011 }
void misdn_lib_echo | ( | struct misdn_bchannel * | bc, | |
int | onoff | |||
) |
Definition at line 4480 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
04481 { 04482 cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); 04483 manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); 04484 }
struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, | |
int | channel, | |||
int | inout, | |||
int | dec | |||
) |
Definition at line 3089 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, 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().
03090 { 03091 struct misdn_stack *stack; 03092 int i; 03093 03094 if (channel < 0 || channel > MAX_BCHANS) { 03095 cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); 03096 return NULL; 03097 } 03098 03099 for (stack=glob_mgr->stack_list; stack; stack=stack->next) { 03100 03101 if (stack->port == port) { 03102 if (stack->blocked) { 03103 cb_log(0,port,"Port is blocked\n"); 03104 return NULL; 03105 } 03106 03107 if (channel > 0) { 03108 if (channel <= stack->b_num) { 03109 for (i = 0; i < stack->b_num; i++) { 03110 if (stack->bc[i].in_use && stack->bc[i].channel == channel) { 03111 cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); 03112 return NULL; 03113 } 03114 } 03115 } else { 03116 cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); 03117 return NULL; 03118 } 03119 } 03120 03121 int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num; 03122 03123 if (dec) { 03124 for (i = maxnum-1; i>=0; i--) { 03125 if (!stack->bc[i].in_use) { 03126 /* 3. channel on bri means CW*/ 03127 if (!stack->pri && i==stack->b_num) 03128 stack->bc[i].cw=1; 03129 03130 prepare_bc(&stack->bc[i], channel); 03131 stack->bc[i].dec=1; 03132 return &stack->bc[i]; 03133 } 03134 } 03135 } else { 03136 for (i = 0; i <maxnum; i++) { 03137 if (!stack->bc[i].in_use) { 03138 /* 3. channel on bri means CW*/ 03139 if (!stack->pri && i==stack->b_num) 03140 stack->bc[i].cw=1; 03141 03142 prepare_bc(&stack->bc[i], channel); 03143 return &stack->bc[i]; 03144 } 03145 } 03146 } 03147 03148 cb_log(1,port,"There is no free channel on port (%d)\n",port); 03149 return NULL; 03150 } 03151 } 03152 03153 cb_log(0,port,"Port is not configured (%d)\n",port); 03154 return NULL; 03155 }
int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 100 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
00101 { 00102 struct misdn_stack *stack=get_misdn_stack(); 00103 for ( ; stack; stack=stack->next) { 00104 if (stack->port == port) { 00105 if (stack->pri) 00106 return 30; 00107 else 00108 return 2; 00109 } 00110 } 00111 return -1; 00112 }
int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1714 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().
01715 { /* Pull Down L1 */ 01716 struct misdn_stack *stack; 01717 for (stack=glob_mgr->stack_list; 01718 stack; 01719 stack=stack->next) { 01720 if (stack->port == port) { 01721 if (stack->l2link) 01722 misdn_lib_get_l2_down(stack); 01723 misdn_lib_get_l1_down(stack); 01724 return 0; 01725 } 01726 } 01727 return 0; 01728 }
int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3597 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.
03598 { 03599 msg_t *msg=alloc_msg(MAX_MSG_SIZE); 03600 iframe_t *frm; 03601 struct misdn_stack *stack=find_stack_by_port(port); 03602 if (!msg) { 03603 cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n"); 03604 return -1; 03605 } 03606 frm=(iframe_t*)msg->data; 03607 if (!stack ) { 03608 cb_log(0, port, "There is no Stack for this port.\n"); 03609 return -1; 03610 } 03611 /* activate bchannel */ 03612 frm->prim = CC_STATUS_ENQUIRY | REQUEST; 03613 03614 frm->addr = stack->upper_id| FLG_MSG_DOWN; 03615 03616 frm->dinfo = 0; 03617 frm->len = 0; 03618 03619 msg_queue_tail(&glob_mgr->activatequeue, msg); 03620 sem_post(&glob_mgr->new_msg); 03621 03622 03623 return 0; 03624 }
int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1692 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().
01693 { /* Pull Up L1 */ 01694 struct misdn_stack *stack; 01695 01696 for (stack=glob_mgr->stack_list; 01697 stack; 01698 stack=stack->next) { 01699 01700 if (stack->port == port) { 01701 01702 if (!stack->l1link) 01703 misdn_lib_get_l1_up(stack); 01704 if (!stack->l2link) 01705 misdn_lib_get_l2_up(stack); 01706 01707 return 0; 01708 } 01709 } 01710 return 0; 01711 }
int misdn_lib_init | ( | char * | portlist, | |
struct misdn_lib_iface * | iface, | |||
void * | user_data | |||
) |
Definition at line 3872 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().
03873 { 03874 struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); 03875 char *tok, *tokb; 03876 char plist[1024]; 03877 int midev; 03878 int port_count=0; 03879 03880 cb_log = iface->cb_log; 03881 cb_event = iface->cb_event; 03882 cb_jb_empty = iface->cb_jb_empty; 03883 03884 glob_mgr = mgr; 03885 03886 msg_init(); 03887 03888 misdn_lib_nt_debug_init(0,NULL); 03889 03890 if (!portlist || (*portlist == 0) ) return 1; 03891 03892 init_flip_bits(); 03893 03894 { 03895 strncpy(plist,portlist, 1024); 03896 plist[1023] = 0; 03897 } 03898 03899 memcpy(tone_425_flip,tone_425,TONE_425_SIZE); 03900 flip_buf_bits(tone_425_flip,TONE_425_SIZE); 03901 03902 memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); 03903 flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); 03904 03905 midev=te_lib_init(); 03906 mgr->midev=midev; 03907 03908 port_count=mISDN_get_stack_count(midev); 03909 03910 msg_queue_init(&mgr->activatequeue); 03911 03912 if (sem_init(&mgr->new_msg, 1, 0)<0) 03913 sem_init(&mgr->new_msg, 0, 0); 03914 03915 for (tok=strtok_r(plist," ,",&tokb ); 03916 tok; 03917 tok=strtok_r(NULL," ,",&tokb)) { 03918 int port = atoi(tok); 03919 struct misdn_stack *stack; 03920 static int first=1; 03921 int ptp=0; 03922 03923 if (strstr(tok, "ptp")) 03924 ptp=1; 03925 03926 if (port > port_count) { 03927 cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); 03928 exit(1); 03929 } 03930 stack=stack_init(midev, port, ptp); 03931 03932 if (!stack) { 03933 perror("init_stack"); 03934 exit(1); 03935 } 03936 03937 { 03938 int i; 03939 for(i=0;i<=stack->b_num; i++) { 03940 int r; 03941 if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { 03942 cb_log(0, port, "Got Err @ init_bc :%d\n",r); 03943 exit(1); 03944 } 03945 } 03946 } 03947 03948 if (stack && first) { 03949 mgr->stack_list=stack; 03950 first=0; 03951 continue; 03952 } 03953 03954 if (stack) { 03955 struct misdn_stack * help; 03956 for ( help=mgr->stack_list; help; help=help->next ) 03957 if (help->next == NULL) break; 03958 help->next=stack; 03959 } 03960 03961 } 03962 03963 if (sem_init(&handler_started, 1, 0)<0) 03964 sem_init(&handler_started, 0, 0); 03965 03966 cb_log(8, 0, "Starting Event Handler\n"); 03967 pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); 03968 03969 sem_wait(&handler_started) ; 03970 cb_log(8, 0, "Starting Event Catcher\n"); 03971 pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); 03972 03973 cb_log(8, 0, "Event Catcher started\n"); 03974 03975 global_state= MISDN_INITIALIZED; 03976 03977 return (mgr == NULL); 03978 }
int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 80 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
00081 { 00082 struct misdn_stack *stack=get_misdn_stack(); 00083 for ( ; stack; stack=stack->next) { 00084 if (stack->port == port) { 00085 return stack->blocked; 00086 } 00087 } 00088 return -1; 00089 }
int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 91 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::ptp.
Referenced by do_immediate_setup().
00092 { 00093 struct misdn_stack *stack=get_misdn_stack(); 00094 for ( ; stack; stack=stack->next) { 00095 if (stack->port == port) return stack->ptp; 00096 } 00097 return -1; 00098 }
void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 2934 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().
02935 { 02936 struct misdn_stack *stack; 02937 02938 for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) 02939 ; 02940 02941 if (stack) { 02942 cb_log(4, port, "Checking L1 State\n"); 02943 if (!stack->l1link) { 02944 cb_log(4, port, "L1 State Down, trying to get it up again\n"); 02945 misdn_lib_get_short_status(stack); 02946 misdn_lib_get_l1_up(stack); 02947 misdn_lib_get_l2_up(stack); 02948 } 02949 } 02950 }
void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3176 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().
03177 { 03178 if (!bc) return; 03179 03180 struct misdn_stack *stack=get_stack_by_bc(bc); 03181 03182 if (!stack) return; 03183 03184 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); 03185 03186 cb_log(2, stack->port, 03187 " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", 03188 bc->info_dad, 03189 bc->onumplan>=0?'0'+bc->onumplan:' ', 03190 bc->dnumplan>=0?'0'+bc->dnumplan:' ', 03191 bc->rnumplan>=0?'0'+bc->rnumplan:' ', 03192 bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' 03193 ); 03194 03195 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); 03196 cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", 03197 bc->screen, bc->pres); 03198 03199 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); 03200 03201 cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); 03202 03203 cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); 03204 03205 cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); 03206 }
int misdn_lib_maxports_get | ( | void | ) |
Definition at line 3836 of file isdn_lib.c.
Referenced by load_module().
03836 { /** BE AWARE WE HAVE NO CB_LOG HERE! **/ 03837 03838 int i = mISDN_open(); 03839 int max=0; 03840 03841 if (i<0) 03842 return -1; 03843 03844 max = mISDN_get_stack_count(i); 03845 03846 mISDN_close(i); 03847 03848 return max; 03849 }
void misdn_lib_nt_debug_init | ( | int | flags, | |
char * | file | |||
) |
Definition at line 3852 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
03853 { 03854 int static init=0; 03855 char *f; 03856 03857 if (!flags) 03858 f=NULL; 03859 else 03860 f=file; 03861 03862 if (!init) { 03863 debug_init( flags , f, f, f); 03864 init=1; 03865 } else { 03866 debug_close(); 03867 debug_init( flags , f, f, f); 03868 } 03869 }
int misdn_lib_pid_restart | ( | int | pid | ) |
int misdn_lib_port_block | ( | int | port | ) |
Definition at line 54 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().
00055 { 00056 struct misdn_stack *stack=get_misdn_stack(); 00057 for ( ; stack; stack=stack->next) { 00058 if (stack->port == port) { 00059 stack->blocked=1; 00060 return 0; 00061 } 00062 } 00063 return -1; 00064 00065 }
int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 32 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().
00033 { 00034 struct misdn_stack *stack=get_misdn_stack(); 00035 for ( ; stack; stack=stack->next) { 00036 if (stack->port == port) { 00037 return stack->pri; 00038 } 00039 } 00040 00041 return -1; 00042 }
int misdn_lib_port_restart | ( | int | port | ) |
int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 67 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by misdn_port_unblock().
00068 { 00069 struct misdn_stack *stack=get_misdn_stack(); 00070 for ( ; stack; stack=stack->next) { 00071 if (stack->port == port) { 00072 stack->blocked=0; 00073 return 0; 00074 } 00075 } 00076 return -1; 00077 00078 }
int misdn_lib_port_up | ( | int | port, | |
int | notcheck | |||
) |
Definition at line 1730 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().
01731 { 01732 struct misdn_stack *stack; 01733 01734 01735 for (stack=glob_mgr->stack_list; 01736 stack; 01737 stack=stack->next) { 01738 01739 if (stack->port == port) { 01740 01741 if (stack->blocked) { 01742 cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); 01743 return -1; 01744 } 01745 01746 if (stack->ptp ) { 01747 01748 if (stack->l1link && stack->l2link) { 01749 return 1; 01750 } else { 01751 cb_log(1,port, "Port Down L2:%d L1:%d\n", 01752 stack->l2link, stack->l1link); 01753 return 0; 01754 } 01755 } else { 01756 if ( !check || stack->l1link ) 01757 return 1; 01758 else { 01759 cb_log(1,port, "Port down PMP\n"); 01760 return 0; 01761 } 01762 } 01763 } 01764 } 01765 01766 return -1; 01767 }
void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4488 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().
04489 { 04490 struct misdn_stack *stack=find_stack_by_port(port); 04491 04492 if (stack) { 04493 stack->l2link=0; 04494 stack->blocked=0; 04495 04496 cleanup_Isdnl3(&stack->nst); 04497 cleanup_Isdnl2(&stack->nst); 04498 04499 04500 memset(&stack->nst, 0, sizeof(net_stack_t)); 04501 memset(&stack->mgr, 0, sizeof(manager_t)); 04502 04503 stack->mgr.nst = &stack->nst; 04504 stack->nst.manager = &stack->mgr; 04505 04506 stack->nst.l3_manager = handle_event_nt; 04507 stack->nst.device = glob_mgr->midev; 04508 stack->nst.cardnr = port; 04509 stack->nst.d_stid = stack->d_stid; 04510 04511 stack->nst.feature = FEATURE_NET_HOLD; 04512 if (stack->ptp) 04513 stack->nst.feature |= FEATURE_NET_PTP; 04514 if (stack->pri) 04515 stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; 04516 04517 stack->nst.l1_id = stack->lower_id; 04518 stack->nst.l2_id = stack->upper_id; 04519 04520 msg_queue_init(&stack->nst.down_queue); 04521 04522 Isdnl2Init(&stack->nst); 04523 Isdnl3Init(&stack->nst); 04524 04525 if (!stack->ptp) 04526 misdn_lib_get_l1_up(stack); 04527 misdn_lib_get_l2_up(stack); 04528 } 04529 }
void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1672 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().
01673 { 01674 struct misdn_stack *stack=get_stack_by_bc(bc); 01675 01676 if (!stack) { 01677 cb_log(1,0,"misdn_release: No Stack found\n"); 01678 return; 01679 } 01680 01681 if (bc->channel>0) 01682 empty_chan_in_stack(stack,bc->channel); 01683 01684 empty_bc(bc); 01685 clean_up_bc(bc); 01686 bc->in_use=0; 01687 }
int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, | |
enum event_e | event | |||
) |
Definition at line 3227 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_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().
03228 { 03229 msg_t *msg; 03230 int retval=0; 03231 03232 if (!bc) RETURN(-1,OUT_POST_UNLOCK); 03233 03234 struct misdn_stack *stack=get_stack_by_bc(bc); 03235 03236 if (!stack) { 03237 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); 03238 RETURN(-1,OUT); 03239 } 03240 03241 misdn_send_lock(bc); 03242 03243 03244 cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id); 03245 03246 if ( stack->nt && !stack->l1link) { 03247 /** Queue Event **/ 03248 bc->evq=event; 03249 cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); 03250 misdn_lib_get_l1_up(stack); 03251 RETURN(0,OUT); 03252 } 03253 03254 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); 03255 cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); 03256 misdn_lib_log_ies(bc); 03257 03258 switch (event) { 03259 case EVENT_SETUP: 03260 if (create_process(glob_mgr->midev, bc)<0) { 03261 cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); 03262 03263 RETURN(-ENOCHAN,OUT); 03264 } 03265 break; 03266 03267 case EVENT_PROGRESS: 03268 case EVENT_ALERTING: 03269 case EVENT_PROCEEDING: 03270 case EVENT_SETUP_ACKNOWLEDGE: 03271 case EVENT_CONNECT: 03272 if (!stack->nt) break; 03273 03274 case EVENT_RETRIEVE_ACKNOWLEDGE: 03275 03276 if (stack->nt) { 03277 if (bc->channel <=0 ) { /* else we have the channel already */ 03278 if (find_free_chan_in_stack(stack, bc, 0, 0)<0) { 03279 cb_log(0, stack->port, " No free channel at the moment\n"); 03280 /*FIXME: add disconnect*/ 03281 RETURN(-ENOCHAN,OUT); 03282 } 03283 } 03284 /* Its that i generate channels */ 03285 } 03286 03287 retval=setup_bc(bc); 03288 if (retval == -EINVAL) { 03289 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03290 } 03291 03292 if (misdn_cap_is_speech(bc->capability)) { 03293 if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { 03294 if ( *bc->crypt_key ) { 03295 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); 03296 03297 manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); 03298 } 03299 03300 if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03301 manager_ec_enable(bc); 03302 03303 if (bc->txgain != 0) { 03304 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03305 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03306 } 03307 03308 if ( bc->rxgain != 0 ) { 03309 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03310 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03311 } 03312 } 03313 } 03314 break; 03315 03316 case EVENT_HOLD_ACKNOWLEDGE: 03317 { 03318 struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel)); 03319 if (!holded_bc) { 03320 cb_log(0,bc->port, "Could not allocate holded_bc!!!\n"); 03321 RETURN(-1,OUT); 03322 } 03323 03324 /*backup the bc*/ 03325 memcpy(holded_bc,bc,sizeof(struct misdn_bchannel)); 03326 holded_bc->holded=1; 03327 bc_state_change(holded_bc,BCHAN_CLEANED); 03328 03329 stack_holder_add(stack,holded_bc); 03330 03331 /*kill the bridge and clean the bchannel*/ 03332 if (stack->nt) { 03333 if (bc->bc_state == BCHAN_BRIDGED) { 03334 misdn_split_conf(bc,bc->conf_id); 03335 struct misdn_bchannel *bc2=find_bc_by_confid(bc->conf_id); 03336 if (!bc2) { 03337 cb_log(0,bc->port,"We have no second bc in bridge???\n"); 03338 } else { 03339 misdn_split_conf(bc2,bc->conf_id); 03340 } 03341 } 03342 03343 int channel=bc->channel; 03344 03345 empty_bc(bc); 03346 clean_up_bc(bc); 03347 03348 if (channel>0) 03349 empty_chan_in_stack(stack,channel); 03350 03351 bc->in_use=0; 03352 } 03353 03354 } 03355 break; 03356 03357 /* finishing the channel eh ? */ 03358 case EVENT_DISCONNECT: 03359 if (!bc->need_disconnect) { 03360 cb_log(0,bc->port," --> we have already send Disconnect\n"); 03361 RETURN(-1,OUT); 03362 } 03363 03364 bc->need_disconnect=0; 03365 break; 03366 case EVENT_RELEASE: 03367 if (!bc->need_release) { 03368 cb_log(0,bc->port," --> we have already send Release\n"); 03369 RETURN(-1,OUT); 03370 } 03371 bc->need_disconnect=0; 03372 bc->need_release=0; 03373 break; 03374 case EVENT_RELEASE_COMPLETE: 03375 if (!bc->need_release_complete) { 03376 cb_log(0,bc->port," --> we have already send Release_complete\n"); 03377 RETURN(-1,OUT); 03378 } 03379 bc->need_disconnect=0; 03380 bc->need_release=0; 03381 bc->need_release_complete=0; 03382 03383 if (!stack->nt) { 03384 /*create clenaup in TE*/ 03385 int channel=bc->channel; 03386 03387 int tmpcause=bc->cause; 03388 int tmp_out_cause=bc->out_cause; 03389 empty_bc(bc); 03390 bc->cause=tmpcause; 03391 bc->out_cause=tmp_out_cause; 03392 clean_up_bc(bc); 03393 03394 if (channel>0) 03395 empty_chan_in_stack(stack,channel); 03396 03397 bc->in_use=0; 03398 } 03399 break; 03400 03401 case EVENT_CONNECT_ACKNOWLEDGE: 03402 03403 if ( bc->nt || misdn_cap_is_speech(bc->capability)) { 03404 int retval=setup_bc(bc); 03405 if (retval == -EINVAL){ 03406 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03407 03408 } 03409 } 03410 03411 if (misdn_cap_is_speech(bc->capability)) { 03412 if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03413 manager_ec_enable(bc); 03414 03415 if ( bc->txgain != 0 ) { 03416 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03417 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03418 } 03419 if ( bc->rxgain != 0 ) { 03420 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03421 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03422 } 03423 } 03424 break; 03425 03426 default: 03427 break; 03428 } 03429 03430 /* Later we should think about sending bchannel data directly to misdn. */ 03431 msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); 03432 msg_queue_tail(&stack->downqueue, msg); 03433 sem_post(&glob_mgr->new_msg); 03434 03435 OUT: 03436 misdn_send_unlock(bc); 03437 03438 OUT_POST_UNLOCK: 03439 return retval; 03440 }
int misdn_lib_send_restart | ( | int | port, | |
int | channel | |||
) |
Definition at line 3663 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, misdn_stack::port, and misdn_stack::pri.
Referenced by handle_frm(), and misdn_send_restart().
03664 { 03665 struct misdn_stack *stack=find_stack_by_port(port); 03666 cb_log(0, port, "Sending Restarts on this port.\n"); 03667 03668 struct misdn_bchannel dummybc; 03669 make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); 03670 03671 /*default is all channels*/ 03672 int max=stack->pri?30:2; 03673 int i=1; 03674 03675 /*if a channel is specified we restart only this one*/ 03676 if (channel > 0) { 03677 i=channel; 03678 max=channel; 03679 } 03680 03681 for (;i<=max;i++) { 03682 dummybc.channel=i; 03683 cb_log(0, port, "Restarting and cleaning channel %d\n",i); 03684 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03685 /*do we need to wait before we get an EVENT_RESTART_ACK ?*/ 03686 03687 /* clean up chan in stack, to be sure we don't think it's 03688 * in use anymore */ 03689 int cnt; 03690 for (cnt=0; cnt<=stack->b_num; cnt++) { 03691 if (stack->bc[cnt].channel == i) { 03692 empty_bc(&stack->bc[cnt]); 03693 clean_up_bc(&stack->bc[cnt]); 03694 stack->bc[cnt].in_use=0; 03695 } 03696 } 03697 } 03698 03699 return 0; 03700 }
void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, | |
enum tone_e | tone | |||
) |
Definition at line 4298 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().
04299 { 04300 04301 switch(tone) { 04302 case TONE_DIAL: 04303 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 04304 break; 04305 04306 case TONE_ALERTING: 04307 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); 04308 break; 04309 04310 case TONE_HANGUP: 04311 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); 04312 break; 04313 04314 case TONE_NONE: 04315 default: 04316 manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); 04317 } 04318 04319 char buf[mISDN_HEADER_LEN+128]; 04320 iframe_t *frm=(iframe_t*)buf; 04321 memset(buf,0,mISDN_HEADER_LEN+128); 04322 04323 frm->prim=DL_DATA|REQUEST; 04324 frm->addr=bc->addr|FLG_MSG_DOWN; 04325 frm->dinfo=0; 04326 frm->len=128; 04327 04328 mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); 04329 }
void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 941 of file isdn_lib.c.
References misdn_stack::bc, clean_up_bc(), and setup_bc().
00942 { 00943 clean_up_bc(bc); 00944 setup_bc(bc); 00945 }
void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4460 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
04461 { 04462 04463 struct misdn_bchannel *bc_list[]={ 04464 bc1,bc2,NULL 04465 }; 04466 struct misdn_bchannel **bc; 04467 04468 for (bc=bc_list; *bc; bc++) { 04469 if ( (*bc)->bc_state == BCHAN_BRIDGED){ 04470 misdn_split_conf( *bc, (*bc)->conf_id); 04471 } else { 04472 cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); 04473 } 04474 } 04475 04476 }
void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2150 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by misdn_write().
02151 { 02152 bc->generate_tone=1; 02153 }
void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2155 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
02156 { 02157 bc->generate_tone=0; 02158 }
void misdn_lib_transfer | ( | struct misdn_bchannel * | holded_bc | ) |
Definition at line 3041 of file isdn_lib.c.
References misdn_bchannel::holded.
03042 { 03043 holded_bc->holded=0; 03044 }
int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, | |
void * | data, | |||
int | len | |||
) |
Definition at line 4078 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().
04079 { 04080 struct misdn_stack *stack=get_stack_by_bc(bc); 04081 04082 switch (bc->bc_state) { 04083 case BCHAN_ACTIVATED: 04084 case BCHAN_BRIDGED: 04085 break; 04086 default: 04087 cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); 04088 return -1; 04089 } 04090 04091 char buf[4096 + mISDN_HEADER_LEN]; 04092 iframe_t *frm= (iframe_t*)buf; 04093 int r; 04094 04095 frm->prim = DL_DATA|REQUEST; 04096 frm->dinfo = 0; 04097 frm->addr = bc->addr | FLG_MSG_DOWN ; 04098 04099 frm->len = len; 04100 memcpy(&buf[mISDN_HEADER_LEN], data,len); 04101 04102 if ( misdn_cap_is_speech(bc->capability) ) 04103 flip_buf_bits( &buf[mISDN_HEADER_LEN], len); 04104 else 04105 cb_log(6, stack->port, "Writing %d data bytes\n",len); 04106 04107 cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); 04108 r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); 04109 return 0; 04110 }
enum event_response_e(*) cb_event(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
Definition at line 372 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 373 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_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(), 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().