#include <mISDNuser/suppserv.h>
Go to the source code of this file.
Definition in file isdn_lib.h.
#define MAX_BCHANS 31 |
Definition at line 76 of file isdn_lib.h.
Referenced by empty_chan_in_stack(), find_free_chan_in_stack(), misdn_lib_get_free_bc(), set_chan_in_stack(), and stack_init().
#define PRI_TRANS_CAP_3_1K_AUDIO 0x10 |
Definition at line 477 of file isdn_lib.h.
#define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 478 of file isdn_lib.h.
#define PRI_TRANS_CAP_DIGITAL 0x08 |
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 476 of file isdn_lib.h.
#define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 474 of file isdn_lib.h.
anonymous enum |
Definition at line 169 of file isdn_lib.h.
00169 { /* bearer capability */ 00170 INFO_CAPABILITY_SPEECH=0, 00171 INFO_CAPABILITY_AUDIO_3_1K=0x10 , 00172 INFO_CAPABILITY_AUDIO_7K=0x11 , 00173 INFO_CAPABILITY_VIDEO =0x18, 00174 INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8, 00175 INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09, 00176 INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES 00177 };
anonymous enum |
Definition at line 179 of file isdn_lib.h.
00179 { /* progress indicators */ 00180 INFO_PI_CALL_NOT_E2E_ISDN =0x01, 00181 INFO_PI_CALLED_NOT_ISDN =0x02, 00182 INFO_PI_CALLER_NOT_ISDN =0x03, 00183 INFO_PI_CALLER_RETURNED_TO_ISDN =0x04, 00184 INFO_PI_INBAND_AVAILABLE =0x08, 00185 INFO_PI_DELAY_AT_INTERF =0x0a, 00186 INFO_PI_INTERWORKING_WITH_PUBLIC =0x10, 00187 INFO_PI_INTERWORKING_NO_RELEASE =0x11, 00188 INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12, 00189 INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13 00190 };
anonymous enum |
Definition at line 192 of file isdn_lib.h.
00192 { /*CODECS*/ 00193 INFO_CODEC_ULAW=2, 00194 INFO_CODEC_ALAW=3 00195 };
enum bchannel_state |
BCHAN_CLEANED | |
BCHAN_EMPTY | |
BCHAN_SETUP | |
BCHAN_SETUPED | |
BCHAN_ACTIVE | |
BCHAN_ACTIVATED | |
BCHAN_BRIDGE | |
BCHAN_BRIDGED | |
BCHAN_RELEASE | |
BCHAN_RELEASED | |
BCHAN_CLEAN | |
BCHAN_CLEAN_REQUEST | |
BCHAN_ERROR |
Definition at line 78 of file isdn_lib.h.
00078 { 00079 BCHAN_CLEANED=0, 00080 BCHAN_EMPTY, 00081 BCHAN_SETUP, 00082 BCHAN_SETUPED, 00083 BCHAN_ACTIVE, 00084 BCHAN_ACTIVATED, 00085 BCHAN_BRIDGE, 00086 BCHAN_BRIDGED, 00087 BCHAN_RELEASE, 00088 BCHAN_RELEASED, 00089 BCHAN_CLEAN, 00090 BCHAN_CLEAN_REQUEST, 00091 BCHAN_ERROR 00092 };
enum event_e |
Definition at line 118 of file isdn_lib.h.
00118 { 00119 EVENT_NOTHING, 00120 EVENT_TONE_GENERATE, 00121 EVENT_BCHAN_DATA, 00122 EVENT_BCHAN_ACTIVATED, 00123 EVENT_BCHAN_ERROR, 00124 EVENT_CLEANUP, 00125 EVENT_PROCEEDING, 00126 EVENT_PROGRESS, 00127 EVENT_SETUP, 00128 EVENT_ALERTING, 00129 EVENT_CONNECT, 00130 EVENT_SETUP_ACKNOWLEDGE, 00131 EVENT_CONNECT_ACKNOWLEDGE , 00132 EVENT_USER_INFORMATION, 00133 EVENT_SUSPEND_REJECT, 00134 EVENT_RESUME_REJECT, 00135 EVENT_HOLD, 00136 EVENT_SUSPEND, 00137 EVENT_RESUME, 00138 EVENT_HOLD_ACKNOWLEDGE, 00139 EVENT_SUSPEND_ACKNOWLEDGE, 00140 EVENT_RESUME_ACKNOWLEDGE, 00141 EVENT_HOLD_REJECT, 00142 EVENT_RETRIEVE, 00143 EVENT_RETRIEVE_ACKNOWLEDGE, 00144 EVENT_RETRIEVE_REJECT, 00145 EVENT_DISCONNECT, 00146 EVENT_RESTART, 00147 EVENT_RELEASE, 00148 EVENT_RELEASE_COMPLETE, 00149 EVENT_FACILITY, 00150 EVENT_NOTIFY, 00151 EVENT_STATUS_ENQUIRY, 00152 EVENT_INFORMATION, 00153 EVENT_STATUS, 00154 EVENT_TIMEOUT, 00155 EVENT_DTMF_TONE, 00156 EVENT_NEW_L3ID, 00157 EVENT_NEW_BC, 00158 EVENT_PORT_ALARM, 00159 EVENT_NEW_CHANNEL, 00160 EVENT_UNKNOWN 00161 };
enum event_response_e |
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE | |
RESPONSE_IGNORE_SETUP | |
RESPONSE_RELEASE_SETUP | |
RESPONSE_ERR | |
RESPONSE_OK |
Definition at line 109 of file isdn_lib.h.
00109 { 00110 RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, 00111 RESPONSE_IGNORE_SETUP, 00112 RESPONSE_RELEASE_SETUP, 00113 RESPONSE_ERR, 00114 RESPONSE_OK 00115 };
enum ie_name_e |
enum layer_e |
enum misdn_err_e |
enum mISDN_NUMBER_PLAN |
NUMPLAN_UNINITIALIZED | |
NUMPLAN_INTERNATIONAL | |
NUMPLAN_NATIONAL | |
NUMPLAN_SUBSCRIBER | |
NUMPLAN_UNKNOWN |
Definition at line 100 of file isdn_lib.h.
00100 { 00101 NUMPLAN_UNINITIALIZED=-1, 00102 NUMPLAN_INTERNATIONAL=0x1, 00103 NUMPLAN_NATIONAL=0x2, 00104 NUMPLAN_SUBSCRIBER=0x4, 00105 NUMPLAN_UNKNOWN=0x0 00106 };
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 63 of file isdn_lib.h.
00063 { 00064 TONE_NONE=0, 00065 TONE_DIAL, 00066 TONE_ALERTING, 00067 TONE_FAR_ALERTING, 00068 TONE_BUSY, 00069 TONE_HANGUP, 00070 TONE_CUSTOM, 00071 TONE_FILE 00072 };
char* bc_state2str | ( | enum bchannel_state | state | ) |
Definition at line 570 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().
00570 { 00571 int i; 00572 00573 struct bchan_state_s { 00574 char *n; 00575 enum bchannel_state s; 00576 } states[] = { 00577 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00578 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00579 {"BCHAN_SETUP", BCHAN_SETUP}, 00580 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00581 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00582 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00583 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00584 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00585 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00586 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00587 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00588 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00589 {"BCHAN_ERROR", BCHAN_ERROR} 00590 }; 00591 00592 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00593 if ( states[i].s == state) 00594 return states[i].n; 00595 00596 return "UNKNOWN"; 00597 }
void bc_state_change | ( | struct misdn_bchannel * | bc, | |
enum bchannel_state | state | |||
) |
Definition at line 599 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().
00600 { 00601 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00602 bc->l3_id, 00603 bc_state2str(bc->bc_state), 00604 bc_state2str(state) ); 00605 00606 switch (state) { 00607 case BCHAN_ACTIVATED: 00608 if (bc->next_bc_state == BCHAN_BRIDGED) { 00609 misdn_join_conf(bc, bc->conf_id); 00610 bc->next_bc_state = BCHAN_EMPTY; 00611 return; 00612 } 00613 default: 00614 bc->bc_state=state; 00615 break; 00616 } 00617 }
void get_show_stack_details | ( | int | port, | |
char * | buf | |||
) |
Definition at line 157 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by handle_cli_misdn_show_port(), and handle_cli_misdn_show_stacks().
00158 { 00159 struct misdn_stack *stack=get_misdn_stack(); 00160 00161 for ( ; stack; stack=stack->next) { 00162 if (stack->port == port) break; 00163 } 00164 00165 if (stack) { 00166 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); 00167 00168 } else { 00169 buf[0]=0; 00170 } 00171 00172 }
void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4285 of file isdn_lib.c.
References misdn_stack::bc, and manager_ph_control().
Referenced by process_ast_dsp().
04286 { 04287 manager_ph_control(bc, DTMF_TONE_STOP, 0); 04288 }
void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4273 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().
04274 { 04275 #ifdef MISDN_1_2 04276 if (*bc->pipeline) 04277 #else 04278 if (bc->ec_enable) 04279 #endif 04280 manager_ec_enable(bc); 04281 else 04282 manager_ec_disable(bc); 04283 }
void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4263 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
04264 { 04265 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 04266 }
void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4268 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
04269 { 04270 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 04271 }
void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4145 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_stack::bc, buf, cb_log, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.
04146 { 04147 char buf[128]; 04148 04149 struct misdn_stack *stack=get_stack_by_bc(bc); 04150 04151 if (!stack) { 04152 cb_log(0, bc->port, "bchannel_activate: Stack not found !"); 04153 return ; 04154 } 04155 04156 /* we must activate if we are deactivated */ 04157 clear_ibuffer(bc->astbuf); 04158 04159 cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); 04160 04161 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); 04162 04163 return ; 04164 }
void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4167 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, buf, cb_log, misdn_bchannel::conf_id, misdn_bchannel::generate_tone, get_stack_by_bc(), misdn_stack::midev, misdn_split_conf(), misdn_stack::port, and misdn_bchannel::port.
Referenced by clean_up_bc().
04168 { 04169 04170 struct misdn_stack *stack=get_stack_by_bc(bc); 04171 iframe_t dact; 04172 char buf[128]; 04173 04174 switch (bc->bc_state) { 04175 case BCHAN_ACTIVATED: 04176 break; 04177 case BCHAN_BRIDGED: 04178 misdn_split_conf(bc,bc->conf_id); 04179 break; 04180 default: 04181 cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n"); 04182 return ; 04183 04184 } 04185 04186 cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); 04187 04188 bc->generate_tone=0; 04189 04190 dact.prim = DL_RELEASE | REQUEST; 04191 dact.addr = bc->addr | FLG_MSG_DOWN; 04192 dact.dinfo = 0; 04193 dact.len = 0; 04194 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); 04195 04196 clear_ibuffer(bc->astbuf); 04197 04198 bc_state_change(bc,BCHAN_RELEASE); 04199 04200 return; 04201 }
void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4504 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(), handle_cli_misdn_toggle_echocancel(), and isdn_lib_update_ec().
04505 { 04506 struct misdn_stack *stack=get_stack_by_bc(bc); 04507 04508 cb_log(4, stack?stack->port:0," --> ec_disable\n"); 04509 04510 if (!misdn_cap_is_speech(bc->capability)) { 04511 cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); 04512 return; 04513 } 04514 04515 #ifdef MISDN_1_2 04516 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); 04517 #else 04518 if ( ! bc->ec_enable) { 04519 cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); 04520 manager_ph_control(bc, ECHOCAN_OFF, 0); 04521 } 04522 #endif 04523 }
void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4455 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_cli_misdn_toggle_echocancel(), handle_event(), isdn_lib_update_ec(), and misdn_lib_send_event().
04456 { 04457 struct misdn_stack *stack=get_stack_by_bc(bc); 04458 04459 cb_log(4, stack?stack->port:0,"ec_enable\n"); 04460 04461 if (!misdn_cap_is_speech(bc->capability)) { 04462 cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); 04463 } else { 04464 04465 #ifdef MISDN_1_2 04466 if (*bc->pipeline) { 04467 cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); 04468 manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); 04469 } 04470 #else 04471 int ec_arr[2]; 04472 04473 if (bc->ec_enable) { 04474 cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); 04475 04476 switch (bc->ec_deftaps) { 04477 case 4: 04478 case 8: 04479 case 16: 04480 case 32: 04481 case 64: 04482 case 128: 04483 case 256: 04484 case 512: 04485 case 1024: 04486 cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); 04487 break; 04488 default: 04489 cb_log(0, stack->port, "Taps should be power of 2\n"); 04490 bc->ec_deftaps=128; 04491 } 04492 04493 ec_arr[0]=bc->ec_deftaps; 04494 ec_arr[1]=0; 04495 04496 manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); 04497 } 04498 #endif 04499 } 04500 }
char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 4140 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
04141 { 04142 return isdn_get_info(msgs_g , event, 0); 04143 }
void manager_ph_control | ( | struct misdn_bchannel * | bc, | |
int | c1, | |||
int | c2 | |||
) |
Definition at line 4242 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().
04243 { 04244 unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; 04245 iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ 04246 unsigned int *d = (unsigned int*)&ctrl->data.p; 04247 /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ 04248 04249 cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); 04250 04251 ctrl->prim = PH_CONTROL | REQUEST; 04252 ctrl->addr = bc->addr | FLG_MSG_DOWN; 04253 ctrl->dinfo = 0; 04254 ctrl->len = sizeof(unsigned int)*2; 04255 *d++ = c1; 04256 *d++ = c2; 04257 mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); 04258 }
int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 431 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().
00433 { 00434 if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && 00435 (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; 00436 return 0; 00437 }
void misdn_dump_chanlist | ( | void | ) |
Definition at line 467 of file isdn_lib.c.
References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.
Referenced by handle_cli_misdn_show_channels().
00468 { 00469 struct misdn_stack *stack=get_misdn_stack(); 00470 for ( ; stack; stack=stack->next) { 00471 dump_chan_list(stack); 00472 } 00473 00474 }
int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 439 of file isdn_lib.c.
References misdn_bchannel::early_bconnect, INFO_PI_CALL_NOT_E2E_ISDN, INFO_PI_CALLED_NOT_ISDN, INFO_PI_INBAND_AVAILABLE, and misdn_bchannel::progress_indicator.
Referenced by cb_events(), and misdn_indication().
00440 { 00441 00442 /*if ! early_bconnect we have never inband available*/ 00443 if ( ! bc->early_bconnect ) return 0; 00444 00445 switch (bc->progress_indicator) { 00446 case INFO_PI_INBAND_AVAILABLE: 00447 case INFO_PI_CALL_NOT_E2E_ISDN: 00448 case INFO_PI_CALLED_NOT_ISDN: 00449 return 1; 00450 default: 00451 return 0; 00452 } 00453 return 0; 00454 }
void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4554 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().
04554 { 04555 int conf_id = bc1->pid + 1; 04556 struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL }; 04557 struct misdn_bchannel **bc; 04558 04559 cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); 04560 04561 for (bc=bc_list; *bc; bc++) { 04562 (*bc)->conf_id=conf_id; 04563 cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); 04564 04565 switch((*bc)->bc_state) { 04566 case BCHAN_ACTIVATED: 04567 misdn_join_conf(*bc,conf_id); 04568 break; 04569 default: 04570 bc_next_state_change(*bc,BCHAN_BRIDGED); 04571 break; 04572 } 04573 } 04574 }
void misdn_lib_destroy | ( | void | ) |
Definition at line 4107 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::b_num, misdn_stack::bc, buf, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, 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().
04108 { 04109 struct misdn_stack *help; 04110 int i; 04111 04112 for ( help=glob_mgr->stack_list; help; help=help->next ) { 04113 for(i=0;i<=help->b_num; i++) { 04114 char buf[1024]; 04115 mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 04116 help->bc[i].addr = 0; 04117 } 04118 cb_log (1, help->port, "Destroying this port.\n"); 04119 stack_destroy(help); 04120 } 04121 04122 if (global_state == MISDN_INITIALIZED) { 04123 cb_log(4, 0, "Killing Handler Thread\n"); 04124 if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { 04125 cb_log(4, 0, "Joining Handler Thread\n"); 04126 pthread_join(glob_mgr->event_handler_thread, NULL); 04127 } 04128 04129 cb_log(4, 0, "Killing Main Thread\n"); 04130 if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { 04131 cb_log(4, 0, "Joining Main Thread\n"); 04132 pthread_join(glob_mgr->event_thread, NULL); 04133 } 04134 } 04135 04136 cb_log(1, 0, "Closing mISDN device\n"); 04137 te_lib_destroy(glob_mgr->midev); 04138 }
void misdn_lib_echo | ( | struct misdn_bchannel * | bc, | |
int | onoff | |||
) |
Definition at line 4596 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
04597 { 04598 cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); 04599 manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); 04600 }
struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, | |
int | channel, | |||
int | inout, | |||
int | dec | |||
) |
Definition at line 3173 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().
03174 { 03175 struct misdn_stack *stack; 03176 int i; 03177 03178 if (channel < 0 || channel > MAX_BCHANS) { 03179 cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); 03180 return NULL; 03181 } 03182 03183 usleep(1000); 03184 03185 for (stack=glob_mgr->stack_list; stack; stack=stack->next) { 03186 03187 if (stack->port == port) { 03188 int maxnum; 03189 03190 if (stack->blocked) { 03191 cb_log(0,port,"Port is blocked\n"); 03192 return NULL; 03193 } 03194 03195 if (channel > 0) { 03196 if (channel <= stack->b_num) { 03197 for (i = 0; i < stack->b_num; i++) { 03198 if ( stack->bc[i].channel == channel) { 03199 if (test_inuse(&stack->bc[i])) { 03200 cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); 03201 return NULL; 03202 03203 } else { 03204 prepare_bc(&stack->bc[i], channel); 03205 return &stack->bc[i]; 03206 } 03207 } 03208 } 03209 } else { 03210 cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); 03211 return NULL; 03212 } 03213 } 03214 03215 maxnum = inout && !stack->pri && !stack->ptp ? stack->b_num + 1 : stack->b_num; 03216 03217 if (dec) { 03218 for (i = maxnum-1; i>=0; i--) { 03219 if (!test_inuse(&stack->bc[i])) { 03220 /* 3. channel on bri means CW*/ 03221 if (!stack->pri && i==stack->b_num) 03222 stack->bc[i].cw=1; 03223 03224 prepare_bc(&stack->bc[i], channel); 03225 stack->bc[i].dec=1; 03226 return &stack->bc[i]; 03227 } 03228 } 03229 } else { 03230 for (i = 0; i <maxnum; i++) { 03231 if (!test_inuse(&stack->bc[i])) { 03232 /* 3. channel on bri means CW*/ 03233 if (!stack->pri && i==stack->b_num) 03234 stack->bc[i].cw=1; 03235 03236 prepare_bc(&stack->bc[i], channel); 03237 return &stack->bc[i]; 03238 } 03239 } 03240 } 03241 03242 cb_log(1,port,"There is no free channel on port (%d)\n",port); 03243 return NULL; 03244 } 03245 } 03246 03247 cb_log(0,port,"Port is not configured (%d)\n",port); 03248 return NULL; 03249 }
int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 125 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
00126 { 00127 struct misdn_stack *stack=get_misdn_stack(); 00128 for ( ; stack; stack=stack->next) { 00129 if (stack->port == port) { 00130 if (stack->pri) 00131 return 30; 00132 else 00133 return 2; 00134 } 00135 } 00136 return -1; 00137 }
int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1734 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 handle_cli_misdn_port_down().
01735 { /* Pull Down L1 */ 01736 struct misdn_stack *stack; 01737 for (stack=glob_mgr->stack_list; 01738 stack; 01739 stack=stack->next) { 01740 if (stack->port == port) { 01741 if (stack->l2link) 01742 misdn_lib_get_l2_down(stack); 01743 misdn_lib_get_l1_down(stack); 01744 return 0; 01745 } 01746 } 01747 return 0; 01748 }
int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3708 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.
03709 { 03710 msg_t *msg=alloc_msg(MAX_MSG_SIZE); 03711 iframe_t *frm; 03712 struct misdn_stack *stack=find_stack_by_port(port); 03713 if (!msg) { 03714 cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n"); 03715 return -1; 03716 } 03717 frm=(iframe_t*)msg->data; 03718 if (!stack ) { 03719 cb_log(0, port, "There is no Stack for this port.\n"); 03720 return -1; 03721 } 03722 /* activate bchannel */ 03723 frm->prim = CC_STATUS_ENQUIRY | REQUEST; 03724 03725 frm->addr = stack->upper_id| FLG_MSG_DOWN; 03726 03727 frm->dinfo = 0; 03728 frm->len = 0; 03729 03730 msg_queue_tail(&glob_mgr->activatequeue, msg); 03731 sem_post(&glob_mgr->new_msg); 03732 03733 03734 return 0; 03735 }
int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1712 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 handle_cli_misdn_port_up(), and misdn_check_l2l1().
01713 { /* Pull Up L1 */ 01714 struct misdn_stack *stack; 01715 01716 for (stack=glob_mgr->stack_list; 01717 stack; 01718 stack=stack->next) { 01719 01720 if (stack->port == port) { 01721 01722 if (!stack->l1link) 01723 misdn_lib_get_l1_up(stack); 01724 if (!stack->l2link) 01725 misdn_lib_get_l2_up(stack); 01726 01727 return 0; 01728 } 01729 } 01730 return 0; 01731 }
int misdn_lib_init | ( | char * | portlist, | |
struct misdn_lib_iface * | iface, | |||
void * | user_data | |||
) |
Definition at line 3999 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, first, 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().
04000 { 04001 struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); 04002 char *tok, *tokb; 04003 char plist[1024]; 04004 int midev; 04005 int port_count=0; 04006 04007 cb_log = iface->cb_log; 04008 cb_event = iface->cb_event; 04009 cb_jb_empty = iface->cb_jb_empty; 04010 04011 glob_mgr = mgr; 04012 04013 msg_init(); 04014 04015 misdn_lib_nt_debug_init(0,NULL); 04016 04017 if (!portlist || (*portlist == 0) ) return 1; 04018 04019 init_flip_bits(); 04020 04021 { 04022 strncpy(plist,portlist, 1024); 04023 plist[1023] = 0; 04024 } 04025 04026 memcpy(tone_425_flip,tone_425,TONE_425_SIZE); 04027 flip_buf_bits(tone_425_flip,TONE_425_SIZE); 04028 04029 memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); 04030 flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); 04031 04032 midev=te_lib_init(); 04033 mgr->midev=midev; 04034 04035 port_count=mISDN_get_stack_count(midev); 04036 04037 msg_queue_init(&mgr->activatequeue); 04038 04039 if (sem_init(&mgr->new_msg, 1, 0)<0) 04040 sem_init(&mgr->new_msg, 0, 0); 04041 04042 for (tok=strtok_r(plist," ,",&tokb ); 04043 tok; 04044 tok=strtok_r(NULL," ,",&tokb)) { 04045 int port = atoi(tok); 04046 struct misdn_stack *stack; 04047 static int first=1; 04048 int ptp=0; 04049 04050 if (strstr(tok, "ptp")) 04051 ptp=1; 04052 04053 if (port > port_count) { 04054 cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); 04055 exit(1); 04056 } 04057 stack=stack_init(midev, port, ptp); 04058 04059 if (!stack) { 04060 perror("init_stack"); 04061 exit(1); 04062 } 04063 04064 { 04065 int i; 04066 for(i=0;i<=stack->b_num; i++) { 04067 int r; 04068 if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { 04069 cb_log(0, port, "Got Err @ init_bc :%d\n",r); 04070 exit(1); 04071 } 04072 } 04073 } 04074 04075 if (stack && first) { 04076 mgr->stack_list=stack; 04077 first=0; 04078 continue; 04079 } 04080 04081 if (stack) { 04082 struct misdn_stack * help; 04083 for ( help=mgr->stack_list; help; help=help->next ) 04084 if (help->next == NULL) break; 04085 help->next=stack; 04086 } 04087 04088 } 04089 04090 if (sem_init(&handler_started, 1, 0)<0) 04091 sem_init(&handler_started, 0, 0); 04092 04093 cb_log(8, 0, "Starting Event Handler\n"); 04094 pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); 04095 04096 sem_wait(&handler_started) ; 04097 cb_log(8, 0, "Starting Event Catcher\n"); 04098 pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); 04099 04100 cb_log(8, 0, "Event Catcher started\n"); 04101 04102 global_state= MISDN_INITIALIZED; 04103 04104 return (mgr == NULL); 04105 }
int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 105 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
00106 { 00107 struct misdn_stack *stack=get_misdn_stack(); 00108 for ( ; stack; stack=stack->next) { 00109 if (stack->port == port) { 00110 return stack->blocked; 00111 } 00112 } 00113 return -1; 00114 }
int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 116 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().
00117 { 00118 struct misdn_stack *stack=get_misdn_stack(); 00119 for ( ; stack; stack=stack->next) { 00120 if (stack->port == port) return stack->ptp; 00121 } 00122 return -1; 00123 }
void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 3000 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().
03001 { 03002 struct misdn_stack *stack; 03003 03004 for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) 03005 ; 03006 03007 if (stack) { 03008 cb_log(4, port, "Checking L1 State\n"); 03009 if (!stack->l1link) { 03010 cb_log(4, port, "L1 State Down, trying to get it up again\n"); 03011 misdn_lib_get_short_status(stack); 03012 misdn_lib_get_l1_up(stack); 03013 misdn_lib_get_l2_up(stack); 03014 } 03015 } 03016 }
void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3270 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().
03271 { 03272 struct misdn_stack *stack; 03273 03274 if (!bc) return; 03275 03276 stack = get_stack_by_bc(bc); 03277 03278 if (!stack) return; 03279 03280 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); 03281 03282 cb_log(2, stack->port, 03283 " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", 03284 bc->info_dad, 03285 bc->onumplan>=0?'0'+bc->onumplan:' ', 03286 bc->dnumplan>=0?'0'+bc->dnumplan:' ', 03287 bc->rnumplan>=0?'0'+bc->rnumplan:' ', 03288 bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' 03289 ); 03290 03291 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); 03292 cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", 03293 bc->screen, bc->pres); 03294 03295 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); 03296 03297 cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); 03298 03299 cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); 03300 03301 cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); 03302 }
int misdn_lib_maxports_get | ( | void | ) |
Definition at line 3951 of file isdn_lib.c.
Referenced by load_module().
03951 { /** BE AWARE WE HAVE NO CB_LOG HERE! **/ 03952 03953 int i = mISDN_open(); 03954 int max=0; 03955 03956 if (i<0) 03957 return -1; 03958 03959 max = mISDN_get_stack_count(i); 03960 03961 mISDN_close(i); 03962 03963 return max; 03964 }
void misdn_lib_nt_debug_init | ( | int | flags, | |
char * | file | |||
) |
Definition at line 3979 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
03980 { 03981 static int init=0; 03982 char *f; 03983 03984 if (!flags) 03985 f=NULL; 03986 else 03987 f=file; 03988 03989 if (!init) { 03990 debug_init( flags , f, f, f); 03991 init=1; 03992 } else { 03993 debug_close(); 03994 debug_init( flags , f, f, f); 03995 } 03996 }
void misdn_lib_nt_keepcalls | ( | int | kc | ) |
Definition at line 3967 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, and misdn_stack::nst.
Referenced by load_module().
03968 { 03969 #ifdef FEATURE_NET_KEEPCALLS 03970 if (kc) { 03971 struct misdn_stack *stack=get_misdn_stack(); 03972 for ( ; stack; stack=stack->next) { 03973 stack->nst.feature |= FEATURE_NET_KEEPCALLS; 03974 } 03975 } 03976 #endif 03977 }
int misdn_lib_pid_restart | ( | int | pid | ) |
int misdn_lib_port_block | ( | int | port | ) |
Definition at line 79 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by cb_events(), and handle_cli_misdn_port_block().
00080 { 00081 struct misdn_stack *stack=get_misdn_stack(); 00082 for ( ; stack; stack=stack->next) { 00083 if (stack->port == port) { 00084 stack->blocked=1; 00085 return 0; 00086 } 00087 } 00088 return -1; 00089 00090 }
int misdn_lib_port_is_nt | ( | int | port | ) |
Definition at line 53 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::nt, and misdn_stack::port.
Referenced by handle_cli_misdn_send_facility().
00054 { 00055 struct misdn_stack *stack=get_misdn_stack(); 00056 for ( ; stack; stack=stack->next) { 00057 if (stack->port == port) { 00058 return stack->nt; 00059 } 00060 } 00061 00062 return -1; 00063 }
int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 41 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().
00042 { 00043 struct misdn_stack *stack=get_misdn_stack(); 00044 for ( ; stack; stack=stack->next) { 00045 if (stack->port == port) { 00046 return stack->pri; 00047 } 00048 } 00049 00050 return -1; 00051 }
int misdn_lib_port_restart | ( | int | port | ) |
int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 92 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by handle_cli_misdn_port_unblock().
00093 { 00094 struct misdn_stack *stack=get_misdn_stack(); 00095 for ( ; stack; stack=stack->next) { 00096 if (stack->port == port) { 00097 stack->blocked=0; 00098 return 0; 00099 } 00100 } 00101 return -1; 00102 00103 }
int misdn_lib_port_up | ( | int | port, | |
int | notcheck | |||
) |
Definition at line 1750 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().
01751 { 01752 struct misdn_stack *stack; 01753 01754 01755 for (stack=glob_mgr->stack_list; 01756 stack; 01757 stack=stack->next) { 01758 01759 if (stack->port == port) { 01760 01761 if (stack->blocked) { 01762 cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); 01763 return -1; 01764 } 01765 01766 if (stack->ptp ) { 01767 01768 if (stack->l1link && stack->l2link) { 01769 return 1; 01770 } else { 01771 cb_log(1,port, "Port Down L2:%d L1:%d\n", 01772 stack->l2link, stack->l1link); 01773 return 0; 01774 } 01775 } else { 01776 if ( !check || stack->l1link ) 01777 return 1; 01778 else { 01779 cb_log(1,port, "Port down PMP\n"); 01780 return 0; 01781 } 01782 } 01783 } 01784 } 01785 01786 return -1; 01787 }
void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4604 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().
04605 { 04606 struct misdn_stack *stack=find_stack_by_port(port); 04607 04608 if (stack) { 04609 stack->l2link=0; 04610 stack->blocked=0; 04611 04612 cleanup_Isdnl3(&stack->nst); 04613 cleanup_Isdnl2(&stack->nst); 04614 04615 04616 memset(&stack->nst, 0, sizeof(net_stack_t)); 04617 memset(&stack->mgr, 0, sizeof(manager_t)); 04618 04619 stack->mgr.nst = &stack->nst; 04620 stack->nst.manager = &stack->mgr; 04621 04622 stack->nst.l3_manager = handle_event_nt; 04623 stack->nst.device = glob_mgr->midev; 04624 stack->nst.cardnr = port; 04625 stack->nst.d_stid = stack->d_stid; 04626 04627 stack->nst.feature = FEATURE_NET_HOLD; 04628 if (stack->ptp) 04629 stack->nst.feature |= FEATURE_NET_PTP; 04630 if (stack->pri) 04631 stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; 04632 04633 stack->nst.l1_id = stack->lower_id; 04634 stack->nst.l2_id = stack->upper_id; 04635 04636 msg_queue_init(&stack->nst.down_queue); 04637 04638 Isdnl2Init(&stack->nst); 04639 Isdnl3Init(&stack->nst); 04640 04641 if (!stack->ptp) 04642 misdn_lib_get_l1_up(stack); 04643 misdn_lib_get_l2_up(stack); 04644 } 04645 }
void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1692 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().
01693 { 01694 struct misdn_stack *stack=get_stack_by_bc(bc); 01695 01696 if (!stack) { 01697 cb_log(1,0,"misdn_release: No Stack found\n"); 01698 return; 01699 } 01700 01701 if (bc->channel>0) 01702 empty_chan_in_stack(stack,bc->channel); 01703 01704 empty_bc(bc); 01705 clean_up_bc(bc); 01706 bc->in_use=0; 01707 }
int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, | |
enum event_e | event | |||
) |
Definition at line 3323 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(), msg, msgs_g, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_bchannel::nt, misdn_stack::nt, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, RETURN, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.
Referenced by cb_events(), do_immediate_setup(), handle_cli_misdn_send_display(), handle_cli_misdn_send_facility(), handle_event(), handle_event_nt(), handle_frm(), handle_l1(), misdn_answer(), misdn_call(), misdn_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_lib_send_restart(), misdn_overlap_dial_task(), misdn_send_text(), start_pbx(), and wait_for_digits().
03324 { 03325 msg_t *msg; 03326 int retval=0; 03327 struct misdn_stack *stack; 03328 03329 if (!bc) RETURN(-1,OUT_POST_UNLOCK); 03330 03331 stack = get_stack_by_bc(bc); 03332 03333 if (!stack) { 03334 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); 03335 RETURN(-1,OUT); 03336 } 03337 03338 misdn_send_lock(bc); 03339 03340 03341 cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id); 03342 03343 if ( stack->nt && !stack->l1link) { 03344 /** Queue Event **/ 03345 bc->evq=event; 03346 cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); 03347 misdn_lib_get_l1_up(stack); 03348 RETURN(0,OUT); 03349 } 03350 03351 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); 03352 cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); 03353 misdn_lib_log_ies(bc); 03354 03355 switch (event) { 03356 case EVENT_SETUP: 03357 if (create_process(glob_mgr->midev, bc)<0) { 03358 cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); 03359 03360 RETURN(-ENOCHAN,OUT); 03361 } 03362 break; 03363 03364 case EVENT_PROGRESS: 03365 case EVENT_ALERTING: 03366 case EVENT_PROCEEDING: 03367 case EVENT_SETUP_ACKNOWLEDGE: 03368 case EVENT_CONNECT: 03369 if (!stack->nt) break; 03370 03371 case EVENT_RETRIEVE_ACKNOWLEDGE: 03372 03373 if (stack->nt) { 03374 if (bc->channel <=0 ) { /* else we have the channel already */ 03375 if (find_free_chan_in_stack(stack, bc, 0, 0)<0) { 03376 cb_log(0, stack->port, " No free channel at the moment\n"); 03377 /*FIXME: add disconnect*/ 03378 RETURN(-ENOCHAN,OUT); 03379 } 03380 } 03381 /* Its that i generate channels */ 03382 } 03383 03384 retval=setup_bc(bc); 03385 if (retval == -EINVAL) { 03386 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03387 } 03388 03389 if (misdn_cap_is_speech(bc->capability)) { 03390 if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { 03391 if ( *bc->crypt_key ) { 03392 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); 03393 03394 manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); 03395 } 03396 03397 if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03398 manager_ec_enable(bc); 03399 03400 if (bc->txgain != 0) { 03401 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03402 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03403 } 03404 03405 if ( bc->rxgain != 0 ) { 03406 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03407 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03408 } 03409 } 03410 } 03411 break; 03412 03413 case EVENT_HOLD_ACKNOWLEDGE: 03414 { 03415 struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel)); 03416 if (!holded_bc) { 03417 cb_log(0,bc->port, "Could not allocate holded_bc!!!\n"); 03418 RETURN(-1,OUT); 03419 } 03420 03421 /*backup the bc*/ 03422 memcpy(holded_bc,bc,sizeof(struct misdn_bchannel)); 03423 holded_bc->holded=1; 03424 bc_state_change(holded_bc,BCHAN_CLEANED); 03425 03426 stack_holder_add(stack,holded_bc); 03427 03428 /*kill the bridge and clean the bchannel*/ 03429 if (stack->nt) { 03430 int channel; 03431 if (bc->bc_state == BCHAN_BRIDGED) { 03432 struct misdn_bchannel *bc2; 03433 03434 misdn_split_conf(bc,bc->conf_id); 03435 bc2 = find_bc_by_confid(bc->conf_id); 03436 if (!bc2) { 03437 cb_log(0,bc->port,"We have no second bc in bridge???\n"); 03438 } else { 03439 misdn_split_conf(bc2,bc->conf_id); 03440 } 03441 } 03442 03443 channel = bc->channel; 03444 03445 empty_bc(bc); 03446 clean_up_bc(bc); 03447 03448 if (channel>0) 03449 empty_chan_in_stack(stack,channel); 03450 03451 bc->in_use=0; 03452 } 03453 03454 } 03455 break; 03456 03457 /* finishing the channel eh ? */ 03458 case EVENT_DISCONNECT: 03459 if (!bc->need_disconnect) { 03460 cb_log(0,bc->port," --> we have already send Disconnect\n"); 03461 RETURN(-1,OUT); 03462 } 03463 03464 bc->need_disconnect=0; 03465 break; 03466 case EVENT_RELEASE: 03467 if (!bc->need_release) { 03468 cb_log(0,bc->port," --> we have already send Release\n"); 03469 RETURN(-1,OUT); 03470 } 03471 bc->need_disconnect=0; 03472 bc->need_release=0; 03473 break; 03474 case EVENT_RELEASE_COMPLETE: 03475 if (!bc->need_release_complete) { 03476 cb_log(0,bc->port," --> we have already send Release_complete\n"); 03477 RETURN(-1,OUT); 03478 } 03479 bc->need_disconnect=0; 03480 bc->need_release=0; 03481 bc->need_release_complete=0; 03482 03483 if (!stack->nt) { 03484 /*create clenaup in TE*/ 03485 int channel=bc->channel; 03486 03487 int tmpcause=bc->cause; 03488 int tmp_out_cause=bc->out_cause; 03489 empty_bc(bc); 03490 bc->cause=tmpcause; 03491 bc->out_cause=tmp_out_cause; 03492 clean_up_bc(bc); 03493 03494 if (channel>0) 03495 empty_chan_in_stack(stack,channel); 03496 03497 bc->in_use=0; 03498 } 03499 break; 03500 03501 case EVENT_CONNECT_ACKNOWLEDGE: 03502 03503 if ( bc->nt || misdn_cap_is_speech(bc->capability)) { 03504 int retval=setup_bc(bc); 03505 if (retval == -EINVAL){ 03506 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03507 03508 } 03509 } 03510 03511 if (misdn_cap_is_speech(bc->capability)) { 03512 if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03513 manager_ec_enable(bc); 03514 03515 if ( bc->txgain != 0 ) { 03516 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03517 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03518 } 03519 if ( bc->rxgain != 0 ) { 03520 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03521 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03522 } 03523 } 03524 break; 03525 03526 default: 03527 break; 03528 } 03529 03530 /* Later we should think about sending bchannel data directly to misdn. */ 03531 msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); 03532 msg_queue_tail(&stack->downqueue, msg); 03533 sem_post(&glob_mgr->new_msg); 03534 03535 OUT: 03536 misdn_send_unlock(bc); 03537 03538 OUT_POST_UNLOCK: 03539 return retval; 03540 }
int misdn_lib_send_restart | ( | int | port, | |
int | channel | |||
) |
Definition at line 3774 of file isdn_lib.c.
References misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), EVENT_RESTART, find_stack_by_port(), misdn_bchannel::in_use, misdn_lib_send_event(), misdn_make_dummy(), misdn_stack::nt, and misdn_stack::port.
Referenced by handle_cli_misdn_send_restart(), handle_event_nt(), and handle_frm().
03775 { 03776 struct misdn_stack *stack=find_stack_by_port(port); 03777 struct misdn_bchannel dummybc; 03778 /*default is all channels*/ 03779 cb_log(0, port, "Sending Restarts on this port.\n"); 03780 03781 misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0); 03782 03783 /*default is all channels*/ 03784 if (channel <0) { 03785 dummybc.channel=-1; 03786 cb_log(0, port, "Restarting and all Interfaces\n"); 03787 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03788 03789 return 0; 03790 } 03791 03792 /*if a channel is specified we restart only this one*/ 03793 if (channel >0) { 03794 int cnt; 03795 dummybc.channel=channel; 03796 cb_log(0, port, "Restarting and cleaning channel %d\n",channel); 03797 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03798 /* clean up chan in stack, to be sure we don't think it's 03799 * in use anymore */ 03800 for (cnt=0; cnt<=stack->b_num; cnt++) { 03801 if (stack->bc[cnt].channel == channel) { 03802 empty_bc(&stack->bc[cnt]); 03803 clean_up_bc(&stack->bc[cnt]); 03804 stack->bc[cnt].in_use=0; 03805 } 03806 } 03807 } 03808 03809 return 0; 03810 }
void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, | |
enum tone_e | tone | |||
) |
Definition at line 4423 of file isdn_lib.c.
References misdn_bchannel::addr, buf, glob_mgr, manager_ph_control(), misdn_lib::midev, TONE_ALERTING, TONE_DIAL, TONE_HANGUP, and TONE_NONE.
Referenced by hanguptone_indicate().
04424 { 04425 char buf[mISDN_HEADER_LEN + 128] = ""; 04426 iframe_t *frm = (iframe_t*)buf; 04427 04428 switch(tone) { 04429 case TONE_DIAL: 04430 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 04431 break; 04432 04433 case TONE_ALERTING: 04434 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); 04435 break; 04436 04437 case TONE_HANGUP: 04438 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); 04439 break; 04440 04441 case TONE_NONE: 04442 default: 04443 manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); 04444 } 04445 04446 frm->prim=DL_DATA|REQUEST; 04447 frm->addr=bc->addr|FLG_MSG_DOWN; 04448 frm->dinfo=0; 04449 frm->len=128; 04450 04451 mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); 04452 }
void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 960 of file isdn_lib.c.
References misdn_stack::bc, clean_up_bc(), and setup_bc().
00961 { 00962 clean_up_bc(bc); 00963 setup_bc(bc); 00964 }
void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, | |
struct misdn_bchannel * | bc2 | |||
) |
Definition at line 4576 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
04577 { 04578 04579 struct misdn_bchannel *bc_list[]={ 04580 bc1,bc2,NULL 04581 }; 04582 struct misdn_bchannel **bc; 04583 04584 for (bc=bc_list; *bc; bc++) { 04585 if ( (*bc)->bc_state == BCHAN_BRIDGED){ 04586 misdn_split_conf( *bc, (*bc)->conf_id); 04587 } else { 04588 cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); 04589 } 04590 } 04591 04592 }
void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2191 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by misdn_write().
02192 { 02193 bc->generate_tone=1; 02194 }
void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2196 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
02197 { 02198 bc->generate_tone=0; 02199 }
void misdn_lib_transfer | ( | struct misdn_bchannel * | holded_bc | ) |
Definition at line 3105 of file isdn_lib.c.
References misdn_bchannel::holded.
03106 { 03107 holded_bc->holded=0; 03108 }
int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, | |
void * | data, | |||
int | len | |||
) |
Definition at line 4204 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, buf, 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().
04205 { 04206 struct misdn_stack *stack=get_stack_by_bc(bc); 04207 char buf[4096 + mISDN_HEADER_LEN]; 04208 iframe_t *frm = (iframe_t*)buf; 04209 int r; 04210 04211 switch (bc->bc_state) { 04212 case BCHAN_ACTIVATED: 04213 case BCHAN_BRIDGED: 04214 break; 04215 default: 04216 cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); 04217 return -1; 04218 } 04219 04220 frm->prim = DL_DATA|REQUEST; 04221 frm->dinfo = 0; 04222 frm->addr = bc->addr | FLG_MSG_DOWN ; 04223 04224 frm->len = len; 04225 memcpy(&buf[mISDN_HEADER_LEN], data,len); 04226 04227 if ( misdn_cap_is_speech(bc->capability) ) 04228 flip_buf_bits( &buf[mISDN_HEADER_LEN], len); 04229 else 04230 cb_log(6, stack->port, "Writing %d data bytes\n",len); 04231 04232 cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); 04233 r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); 04234 return 0; 04235 }
void misdn_make_dummy | ( | struct misdn_bchannel * | dummybc, | |
int | port, | |||
int | l3id, | |||
int | nt, | |||
int | channel | |||
) |
Definition at line 65 of file isdn_lib.c.
References misdn_bchannel::channel, misdn_bchannel::dummy, misdn_bchannel::l3_id, misdn_bchannel::nt, and misdn_bchannel::port.
Referenced by handle_cli_misdn_send_facility(), handle_cr(), handle_event_nt(), handle_frm(), manager_event_handler(), misdn_lib_send_restart(), and release_cr().
00066 { 00067 memset (dummybc,0,sizeof(struct misdn_bchannel)); 00068 dummybc->port=port; 00069 if (l3id==0) 00070 dummybc->l3_id = MISDN_ID_DUMMY; 00071 else 00072 dummybc->l3_id=l3id; 00073 00074 dummybc->nt=nt; 00075 dummybc->dummy=1; 00076 dummybc->channel=channel; 00077 }
enum event_response_e(*) cb_event(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
Definition at line 380 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 381 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().