#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 467 of file isdn_lib.h.
| #define PRI_TRANS_CAP_7K_AUDIO 0x11 |
Definition at line 468 of file isdn_lib.h.
| #define PRI_TRANS_CAP_DIGITAL 0x08 |
| #define PRI_TRANS_CAP_RESTRICTED_DIGITAL 0x09 |
Definition at line 466 of file isdn_lib.h.
| #define PRI_TRANS_CAP_SPEECH 0x0 |
Definition at line 464 of file isdn_lib.h.
| anonymous enum |
Definition at line 163 of file isdn_lib.h.
00163 { /* bearer capability */ 00164 INFO_CAPABILITY_SPEECH=0, 00165 INFO_CAPABILITY_AUDIO_3_1K=0x10 , 00166 INFO_CAPABILITY_AUDIO_7K=0x11 , 00167 INFO_CAPABILITY_VIDEO =0x18, 00168 INFO_CAPABILITY_DIGITAL_UNRESTRICTED =0x8, 00169 INFO_CAPABILITY_DIGITAL_RESTRICTED =0x09, 00170 INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES 00171 };
| anonymous enum |
Definition at line 173 of file isdn_lib.h.
00173 { /* progress indicators */ 00174 INFO_PI_CALL_NOT_E2E_ISDN =0x01, 00175 INFO_PI_CALLED_NOT_ISDN =0x02, 00176 INFO_PI_CALLER_NOT_ISDN =0x03, 00177 INFO_PI_CALLER_RETURNED_TO_ISDN =0x04, 00178 INFO_PI_INBAND_AVAILABLE =0x08, 00179 INFO_PI_DELAY_AT_INTERF =0x0a, 00180 INFO_PI_INTERWORKING_WITH_PUBLIC =0x10, 00181 INFO_PI_INTERWORKING_NO_RELEASE =0x11, 00182 INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER =0x12, 00183 INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER =0x13 00184 };
| anonymous enum |
Definition at line 186 of file isdn_lib.h.
00186 { /*CODECS*/ 00187 INFO_CODEC_ULAW=2, 00188 INFO_CODEC_ALAW=3 00189 };
| enum bchannel_state |
| BCHAN_CLEANED | |
| BCHAN_EMPTY | |
| BCHAN_SETUP | |
| BCHAN_SETUPED | |
| BCHAN_ACTIVE | |
| BCHAN_ACTIVATED | |
| BCHAN_BRIDGE | |
| BCHAN_BRIDGED | |
| BCHAN_RELEASE | |
| BCHAN_RELEASED | |
| BCHAN_CLEAN | |
| BCHAN_CLEAN_REQUEST | |
| BCHAN_ERROR |
Definition at line 72 of file isdn_lib.h.
00072 { 00073 BCHAN_CLEANED=0, 00074 BCHAN_EMPTY, 00075 BCHAN_SETUP, 00076 BCHAN_SETUPED, 00077 BCHAN_ACTIVE, 00078 BCHAN_ACTIVATED, 00079 BCHAN_BRIDGE, 00080 BCHAN_BRIDGED, 00081 BCHAN_RELEASE, 00082 BCHAN_RELEASED, 00083 BCHAN_CLEAN, 00084 BCHAN_CLEAN_REQUEST, 00085 BCHAN_ERROR 00086 };
| enum event_e |
Definition at line 112 of file isdn_lib.h.
00112 { 00113 EVENT_NOTHING, 00114 EVENT_TONE_GENERATE, 00115 EVENT_BCHAN_DATA, 00116 EVENT_BCHAN_ACTIVATED, 00117 EVENT_BCHAN_ERROR, 00118 EVENT_CLEANUP, 00119 EVENT_PROCEEDING, 00120 EVENT_PROGRESS, 00121 EVENT_SETUP, 00122 EVENT_ALERTING, 00123 EVENT_CONNECT, 00124 EVENT_SETUP_ACKNOWLEDGE, 00125 EVENT_CONNECT_ACKNOWLEDGE , 00126 EVENT_USER_INFORMATION, 00127 EVENT_SUSPEND_REJECT, 00128 EVENT_RESUME_REJECT, 00129 EVENT_HOLD, 00130 EVENT_SUSPEND, 00131 EVENT_RESUME, 00132 EVENT_HOLD_ACKNOWLEDGE, 00133 EVENT_SUSPEND_ACKNOWLEDGE, 00134 EVENT_RESUME_ACKNOWLEDGE, 00135 EVENT_HOLD_REJECT, 00136 EVENT_RETRIEVE, 00137 EVENT_RETRIEVE_ACKNOWLEDGE, 00138 EVENT_RETRIEVE_REJECT, 00139 EVENT_DISCONNECT, 00140 EVENT_RESTART, 00141 EVENT_RELEASE, 00142 EVENT_RELEASE_COMPLETE, 00143 EVENT_FACILITY, 00144 EVENT_NOTIFY, 00145 EVENT_STATUS_ENQUIRY, 00146 EVENT_INFORMATION, 00147 EVENT_STATUS, 00148 EVENT_TIMEOUT, 00149 EVENT_DTMF_TONE, 00150 EVENT_NEW_L3ID, 00151 EVENT_NEW_BC, 00152 EVENT_PORT_ALARM, 00153 EVENT_NEW_CHANNEL, 00154 EVENT_UNKNOWN 00155 };
| enum event_response_e |
| RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE | |
| RESPONSE_IGNORE_SETUP | |
| RESPONSE_RELEASE_SETUP | |
| RESPONSE_ERR | |
| RESPONSE_OK |
Definition at line 103 of file isdn_lib.h.
00103 { 00104 RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, 00105 RESPONSE_IGNORE_SETUP, 00106 RESPONSE_RELEASE_SETUP, 00107 RESPONSE_ERR, 00108 RESPONSE_OK 00109 };
| enum ie_name_e |
| enum layer_e |
| enum misdn_err_e |
| enum mISDN_NUMBER_PLAN |
| NUMPLAN_UNINITIALIZED | |
| NUMPLAN_INTERNATIONAL | |
| NUMPLAN_NATIONAL | |
| NUMPLAN_SUBSCRIBER | |
| NUMPLAN_UNKNOWN |
Definition at line 94 of file isdn_lib.h.
00094 { 00095 NUMPLAN_UNINITIALIZED=-1, 00096 NUMPLAN_INTERNATIONAL=0x1, 00097 NUMPLAN_NATIONAL=0x2, 00098 NUMPLAN_SUBSCRIBER=0x4, 00099 NUMPLAN_UNKNOWN=0x0 00100 };
| enum tone_e |
end of init usage
| TONE_NONE | |
| TONE_DIAL | |
| TONE_ALERTING | |
| TONE_FAR_ALERTING | |
| TONE_BUSY | |
| TONE_HANGUP | |
| TONE_CUSTOM | |
| TONE_FILE |
Definition at line 57 of file isdn_lib.h.
00057 { 00058 TONE_NONE=0, 00059 TONE_DIAL, 00060 TONE_ALERTING, 00061 TONE_FAR_ALERTING, 00062 TONE_BUSY, 00063 TONE_HANGUP, 00064 TONE_CUSTOM, 00065 TONE_FILE 00066 };
| char* bc_state2str | ( | enum bchannel_state | state | ) |
Definition at line 490 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().
00490 { 00491 int i; 00492 00493 struct bchan_state_s { 00494 char *n; 00495 enum bchannel_state s; 00496 } states[] = { 00497 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00498 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00499 {"BCHAN_SETUP", BCHAN_SETUP}, 00500 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00501 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00502 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00503 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00504 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00505 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00506 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00507 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00508 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00509 {"BCHAN_ERROR", BCHAN_ERROR} 00510 }; 00511 00512 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00513 if ( states[i].s == state) 00514 return states[i].n; 00515 00516 return "UNKNOWN"; 00517 }
| void bc_state_change | ( | struct misdn_bchannel * | bc, | |
| enum bchannel_state | state | |||
| ) |
Definition at line 519 of file isdn_lib.c.
References misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_EMPTY, cb_log, misdn_bchannel::conf_id, misdn_bchannel::l3_id, misdn_join_conf(), misdn_bchannel::next_bc_state, and misdn_bchannel::port.
Referenced by clean_up_bc(), handle_bchan(), handle_frm(), init_bc(), manager_bchannel_deactivate(), misdn_join_conf(), misdn_lib_send_event(), misdn_split_conf(), and setup_bc().
00520 { 00521 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00522 bc->l3_id, 00523 bc_state2str(bc->bc_state), 00524 bc_state2str(state) ); 00525 00526 switch (state) { 00527 case BCHAN_ACTIVATED: 00528 if (bc->next_bc_state == BCHAN_BRIDGED) { 00529 misdn_join_conf(bc, bc->conf_id); 00530 bc->next_bc_state = BCHAN_EMPTY; 00531 return; 00532 } 00533 default: 00534 bc->bc_state=state; 00535 break; 00536 } 00537 }
| void get_show_stack_details | ( | int | port, | |
| char * | buf | |||
| ) |
Definition at line 121 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().
00122 { 00123 struct misdn_stack *stack=get_misdn_stack(); 00124 00125 for ( ; stack; stack=stack->next) { 00126 if (stack->port == port) break; 00127 } 00128 00129 if (stack) { 00130 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); 00131 00132 } else { 00133 buf[0]=0; 00134 } 00135 00136 }
| void isdn_lib_stop_dtmf | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4115 of file isdn_lib.c.
References misdn_stack::bc, and manager_ph_control().
Referenced by process_ast_dsp().
04116 { 04117 manager_ph_control(bc, DTMF_TONE_STOP, 0); 04118 }
| void isdn_lib_update_ec | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4103 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().
04104 { 04105 #ifdef MISDN_1_2 04106 if (*bc->pipeline) 04107 #else 04108 if (bc->ec_enable) 04109 #endif 04110 manager_ec_enable(bc); 04111 else 04112 manager_ec_disable(bc); 04113 }
| void isdn_lib_update_rxgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4093 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::rxgain.
Referenced by process_ast_dsp().
04094 { 04095 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 04096 }
| void isdn_lib_update_txgain | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4098 of file isdn_lib.c.
References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::txgain.
Referenced by process_ast_dsp().
04099 { 04100 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 04101 }
| void manager_bchannel_activate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3973 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.
Referenced by setup_bc().
03974 { 03975 char buf[128]; 03976 03977 struct misdn_stack *stack=get_stack_by_bc(bc); 03978 03979 if (!stack) { 03980 cb_log(0, bc->port, "bchannel_activate: Stack not found !"); 03981 return ; 03982 } 03983 03984 /* we must activate if we are deactivated */ 03985 clear_ibuffer(bc->astbuf); 03986 03987 cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr); 03988 03989 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC); 03990 03991 return ; 03992 }
| void manager_bchannel_deactivate | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3995 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().
03996 { 03997 03998 struct misdn_stack *stack=get_stack_by_bc(bc); 03999 04000 04001 switch (bc->bc_state) { 04002 case BCHAN_ACTIVATED: 04003 break; 04004 case BCHAN_BRIDGED: 04005 misdn_split_conf(bc,bc->conf_id); 04006 break; 04007 default: 04008 cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n"); 04009 return ; 04010 04011 } 04012 04013 cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr); 04014 04015 bc->generate_tone=0; 04016 04017 iframe_t dact; 04018 dact.prim = DL_RELEASE | REQUEST; 04019 dact.addr = bc->addr | FLG_MSG_DOWN; 04020 dact.dinfo = 0; 04021 dact.len = 0; 04022 char buf[128]; 04023 mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC); 04024 04025 clear_ibuffer(bc->astbuf); 04026 04027 bc_state_change(bc,BCHAN_RELEASE); 04028 04029 return; 04030 }
| void manager_ec_disable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4335 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().
04336 { 04337 struct misdn_stack *stack=get_stack_by_bc(bc); 04338 04339 cb_log(4, stack?stack->port:0," --> ec_disable\n"); 04340 04341 if (!misdn_cap_is_speech(bc->capability)) { 04342 cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n"); 04343 return; 04344 } 04345 04346 #ifdef MISDN_1_2 04347 manager_ph_control_block(bc, PIPELINE_CFG, "", 0); 04348 #else 04349 if ( ! bc->ec_enable) { 04350 cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n"); 04351 manager_ph_control(bc, ECHOCAN_OFF, 0); 04352 } 04353 #endif 04354 }
| void manager_ec_enable | ( | struct misdn_bchannel * | bc | ) |
Definition at line 4286 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 isdn_lib_update_ec(), misdn_lib_send_event(), and misdn_toggle_echocancel().
04287 { 04288 struct misdn_stack *stack=get_stack_by_bc(bc); 04289 04290 cb_log(4, stack?stack->port:0,"ec_enable\n"); 04291 04292 if (!misdn_cap_is_speech(bc->capability)) { 04293 cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n"); 04294 } else { 04295 04296 #ifdef MISDN_1_2 04297 if (*bc->pipeline) { 04298 cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline); 04299 manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1); 04300 } 04301 #else 04302 int ec_arr[2]; 04303 04304 if (bc->ec_enable) { 04305 cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps); 04306 04307 switch (bc->ec_deftaps) { 04308 case 4: 04309 case 8: 04310 case 16: 04311 case 32: 04312 case 64: 04313 case 128: 04314 case 256: 04315 case 512: 04316 case 1024: 04317 cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps); 04318 break; 04319 default: 04320 cb_log(0, stack->port, "Taps should be power of 2\n"); 04321 bc->ec_deftaps=128; 04322 } 04323 04324 ec_arr[0]=bc->ec_deftaps; 04325 ec_arr[1]=0; 04326 04327 manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr)); 04328 } 04329 #endif 04330 } 04331 }
| char* manager_isdn_get_info | ( | enum event_e | event | ) |
Definition at line 3968 of file isdn_lib.c.
References isdn_get_info(), and msgs_g.
Referenced by cb_events().
03969 { 03970 return isdn_get_info(msgs_g , event, 0); 03971 }
| void manager_ph_control | ( | struct misdn_bchannel * | bc, | |
| int | c1, | |||
| int | c2 | |||
| ) |
Definition at line 4072 of file isdn_lib.c.
References misdn_bchannel::addr, misdn_stack::bc, cb_log, glob_mgr, misdn_lib::midev, and misdn_bchannel::port.
Referenced by 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().
04073 { 04074 unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)]; 04075 iframe_t *ctrl = (iframe_t *)buffer; /* preload data */ 04076 unsigned int *d = (unsigned int*)&ctrl->data.p; 04077 /*struct misdn_stack *stack=get_stack_by_bc(bc);*/ 04078 04079 cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2); 04080 04081 ctrl->prim = PH_CONTROL | REQUEST; 04082 ctrl->addr = bc->addr | FLG_MSG_DOWN; 04083 ctrl->dinfo = 0; 04084 ctrl->len = sizeof(unsigned int)*2; 04085 *d++ = c1; 04086 *d++ = c2; 04087 mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC); 04088 }
| int misdn_cap_is_speech | ( | int | cap | ) |
Poor mans version
Definition at line 396 of file isdn_lib.c.
References INFO_CAPABILITY_DIGITAL_RESTRICTED, and INFO_CAPABILITY_DIGITAL_UNRESTRICTED.
Referenced by handle_bchan(), handle_event(), handle_event_nt(), manager_ec_disable(), manager_ec_enable(), misdn_lib_send_event(), and misdn_lib_tx2misdn_frm().
00398 { 00399 if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) && 00400 (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1; 00401 return 0; 00402 }
| int misdn_inband_avail | ( | struct misdn_bchannel * | bc | ) |
Definition at line 404 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().
00405 { 00406 00407 /*if ! early_bconnect we have never inband available*/ 00408 if ( ! bc->early_bconnect ) return 0; 00409 00410 switch (bc->progress_indicator) { 00411 case INFO_PI_INBAND_AVAILABLE: 00412 case INFO_PI_CALL_NOT_E2E_ISDN: 00413 case INFO_PI_CALLED_NOT_ISDN: 00414 return 1; 00415 default: 00416 return 0; 00417 } 00418 return 0; 00419 }
| void misdn_lib_bridge | ( | struct misdn_bchannel * | bc1, | |
| struct misdn_bchannel * | bc2 | |||
| ) |
Definition at line 4389 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().
04389 { 04390 int conf_id=bc1->pid +1; 04391 04392 cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port); 04393 04394 struct misdn_bchannel *bc_list[]={ 04395 bc1,bc2,NULL 04396 }; 04397 struct misdn_bchannel **bc; 04398 04399 for (bc=bc_list; *bc; bc++) { 04400 (*bc)->conf_id=conf_id; 04401 cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr); 04402 04403 switch((*bc)->bc_state) { 04404 case BCHAN_ACTIVATED: 04405 misdn_join_conf(*bc,conf_id); 04406 break; 04407 default: 04408 bc_next_state_change(*bc,BCHAN_BRIDGED); 04409 break; 04410 } 04411 } 04412 }
| void misdn_lib_destroy | ( | void | ) |
Definition at line 3935 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().
03936 { 03937 struct misdn_stack *help; 03938 int i; 03939 03940 for ( help=glob_mgr->stack_list; help; help=help->next ) { 03941 for(i=0;i<=help->b_num; i++) { 03942 char buf[1024]; 03943 mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 03944 help->bc[i].addr = 0; 03945 } 03946 cb_log (1, help->port, "Destroying this port.\n"); 03947 stack_destroy(help); 03948 } 03949 03950 if (global_state == MISDN_INITIALIZED) { 03951 cb_log(4, 0, "Killing Handler Thread\n"); 03952 if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) { 03953 cb_log(4, 0, "Joining Handler Thread\n"); 03954 pthread_join(glob_mgr->event_handler_thread, NULL); 03955 } 03956 03957 cb_log(4, 0, "Killing Main Thread\n"); 03958 if ( pthread_cancel(glob_mgr->event_thread) == 0 ) { 03959 cb_log(4, 0, "Joining Main Thread\n"); 03960 pthread_join(glob_mgr->event_thread, NULL); 03961 } 03962 } 03963 03964 cb_log(1, 0, "Closing mISDN device\n"); 03965 te_lib_destroy(glob_mgr->midev); 03966 }
| void misdn_lib_echo | ( | struct misdn_bchannel * | bc, | |
| int | onoff | |||
| ) |
Definition at line 4434 of file isdn_lib.c.
References cb_log, manager_ph_control(), and misdn_bchannel::port.
04435 { 04436 cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF"); 04437 manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0); 04438 }
| struct misdn_bchannel* misdn_lib_get_free_bc | ( | int | port, | |
| int | channel, | |||
| int | inout, | |||
| int | dec | |||
| ) |
Definition at line 3073 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().
03074 { 03075 struct misdn_stack *stack; 03076 int i; 03077 03078 if (channel < 0 || channel > MAX_BCHANS) { 03079 cb_log(0,port,"Requested channel out of bounds (%d)\n",channel); 03080 return NULL; 03081 } 03082 03083 for (stack=glob_mgr->stack_list; stack; stack=stack->next) { 03084 03085 if (stack->port == port) { 03086 if (stack->blocked) { 03087 cb_log(0,port,"Port is blocked\n"); 03088 return NULL; 03089 } 03090 03091 if (channel > 0) { 03092 if (channel <= stack->b_num) { 03093 for (i = 0; i < stack->b_num; i++) { 03094 if (stack->bc[i].in_use && stack->bc[i].channel == channel) { 03095 cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port); 03096 return NULL; 03097 } 03098 } 03099 } else { 03100 cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port); 03101 return NULL; 03102 } 03103 } 03104 03105 int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num; 03106 03107 if (dec) { 03108 for (i = maxnum-1; i>=0; i--) { 03109 if (!stack->bc[i].in_use) { 03110 /* 3. channel on bri means CW*/ 03111 if (!stack->pri && i==stack->b_num) 03112 stack->bc[i].cw=1; 03113 03114 prepare_bc(&stack->bc[i], channel); 03115 stack->bc[i].dec=1; 03116 return &stack->bc[i]; 03117 } 03118 } 03119 } else { 03120 for (i = 0; i <maxnum; i++) { 03121 if (!stack->bc[i].in_use) { 03122 /* 3. channel on bri means CW*/ 03123 if (!stack->pri && i==stack->b_num) 03124 stack->bc[i].cw=1; 03125 03126 prepare_bc(&stack->bc[i], channel); 03127 return &stack->bc[i]; 03128 } 03129 } 03130 } 03131 03132 cb_log(1,port,"There is no free channel on port (%d)\n",port); 03133 return NULL; 03134 } 03135 } 03136 03137 cb_log(0,port,"Port is not configured (%d)\n",port); 03138 return NULL; 03139 }
| int misdn_lib_get_maxchans | ( | int | port | ) |
Definition at line 89 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_request().
00090 { 00091 struct misdn_stack *stack=get_misdn_stack(); 00092 for ( ; stack; stack=stack->next) { 00093 if (stack->port == port) { 00094 if (stack->pri) 00095 return 30; 00096 else 00097 return 2; 00098 } 00099 } 00100 return -1; 00101 }
| int misdn_lib_get_port_down | ( | int | port | ) |
Definition at line 1683 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().
01684 { /* Pull Down L1 */ 01685 struct misdn_stack *stack; 01686 for (stack=glob_mgr->stack_list; 01687 stack; 01688 stack=stack->next) { 01689 if (stack->port == port) { 01690 if (stack->l2link) 01691 misdn_lib_get_l2_down(stack); 01692 misdn_lib_get_l1_down(stack); 01693 return 0; 01694 } 01695 } 01696 return 0; 01697 }
| int misdn_lib_get_port_info | ( | int | port | ) |
Definition at line 3565 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.
03566 { 03567 msg_t *msg=alloc_msg(MAX_MSG_SIZE); 03568 iframe_t *frm; 03569 struct misdn_stack *stack=find_stack_by_port(port); 03570 if (!msg) { 03571 cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n"); 03572 return -1; 03573 } 03574 frm=(iframe_t*)msg->data; 03575 if (!stack ) { 03576 cb_log(0, port, "There is no Stack for this port.\n"); 03577 return -1; 03578 } 03579 /* activate bchannel */ 03580 frm->prim = CC_STATUS_ENQUIRY | REQUEST; 03581 03582 frm->addr = stack->upper_id| FLG_MSG_DOWN; 03583 03584 frm->dinfo = 0; 03585 frm->len = 0; 03586 03587 msg_queue_tail(&glob_mgr->activatequeue, msg); 03588 sem_post(&glob_mgr->new_msg); 03589 03590 03591 return 0; 03592 }
| int misdn_lib_get_port_up | ( | int | port | ) |
Definition at line 1661 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_port_up().
01662 { /* Pull Up L1 */ 01663 struct misdn_stack *stack; 01664 01665 for (stack=glob_mgr->stack_list; 01666 stack; 01667 stack=stack->next) { 01668 01669 if (stack->port == port) { 01670 01671 if (!stack->l1link) 01672 misdn_lib_get_l1_up(stack); 01673 if (!stack->l2link) 01674 misdn_lib_get_l2_up(stack); 01675 01676 return 0; 01677 } 01678 } 01679 return 0; 01680 }
| int misdn_lib_init | ( | char * | portlist, | |
| struct misdn_lib_iface * | iface, | |||
| void * | user_data | |||
| ) |
Definition at line 3827 of file isdn_lib.c.
References misdn_lib::activatequeue, misdn_stack::b_num, misdn_stack::bc, calloc, misdn_lib_iface::cb_event, cb_event, misdn_lib_iface::cb_jb_empty, cb_jb_empty, misdn_lib_iface::cb_log, cb_log, 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().
03828 { 03829 struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib)); 03830 char *tok, *tokb; 03831 char plist[1024]; 03832 int midev; 03833 int port_count=0; 03834 03835 cb_log = iface->cb_log; 03836 cb_event = iface->cb_event; 03837 cb_jb_empty = iface->cb_jb_empty; 03838 03839 glob_mgr = mgr; 03840 03841 msg_init(); 03842 03843 misdn_lib_nt_debug_init(0,NULL); 03844 03845 if (!portlist || (*portlist == 0) ) return 1; 03846 03847 init_flip_bits(); 03848 03849 { 03850 strncpy(plist,portlist, 1024); 03851 plist[1023] = 0; 03852 } 03853 03854 memcpy(tone_425_flip,tone_425,TONE_425_SIZE); 03855 flip_buf_bits(tone_425_flip,TONE_425_SIZE); 03856 03857 memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE); 03858 flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE); 03859 03860 midev=te_lib_init(); 03861 mgr->midev=midev; 03862 03863 port_count=mISDN_get_stack_count(midev); 03864 03865 msg_queue_init(&mgr->activatequeue); 03866 03867 if (sem_init(&mgr->new_msg, 1, 0)<0) 03868 sem_init(&mgr->new_msg, 0, 0); 03869 03870 for (tok=strtok_r(plist," ,",&tokb ); 03871 tok; 03872 tok=strtok_r(NULL," ,",&tokb)) { 03873 int port = atoi(tok); 03874 struct misdn_stack *stack; 03875 static int first=1; 03876 int ptp=0; 03877 03878 if (strstr(tok, "ptp")) 03879 ptp=1; 03880 03881 if (port > port_count) { 03882 cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count); 03883 exit(1); 03884 } 03885 stack=stack_init(midev, port, ptp); 03886 03887 if (!stack) { 03888 perror("init_stack"); 03889 exit(1); 03890 } 03891 03892 { 03893 int i; 03894 for(i=0;i<=stack->b_num; i++) { 03895 int r; 03896 if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) { 03897 cb_log(0, port, "Got Err @ init_bc :%d\n",r); 03898 exit(1); 03899 } 03900 } 03901 } 03902 03903 if (stack && first) { 03904 mgr->stack_list=stack; 03905 first=0; 03906 continue; 03907 } 03908 03909 if (stack) { 03910 struct misdn_stack * help; 03911 for ( help=mgr->stack_list; help; help=help->next ) 03912 if (help->next == NULL) break; 03913 help->next=stack; 03914 } 03915 03916 } 03917 03918 if (sem_init(&handler_started, 1, 0)<0) 03919 sem_init(&handler_started, 0, 0); 03920 03921 cb_log(8, 0, "Starting Event Handler\n"); 03922 pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr); 03923 03924 sem_wait(&handler_started) ; 03925 cb_log(8, 0, "Starting Event Catcher\n"); 03926 pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr); 03927 03928 cb_log(8, 0, "Event Catcher started\n"); 03929 03930 global_state= MISDN_INITIALIZED; 03931 03932 return (mgr == NULL); 03933 }
| int misdn_lib_is_port_blocked | ( | int | port | ) |
Definition at line 69 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
00070 { 00071 struct misdn_stack *stack=get_misdn_stack(); 00072 for ( ; stack; stack=stack->next) { 00073 if (stack->port == port) { 00074 return stack->blocked; 00075 } 00076 } 00077 return -1; 00078 }
| int misdn_lib_is_ptp | ( | int | port | ) |
Definition at line 80 of file isdn_lib.c.
References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::ptp.
Referenced by do_immediate_setup().
00081 { 00082 struct misdn_stack *stack=get_misdn_stack(); 00083 for ( ; stack; stack=stack->next) { 00084 if (stack->port == port) return stack->ptp; 00085 } 00086 return -1; 00087 }
| void misdn_lib_isdn_l1watcher | ( | int | port | ) |
Definition at line 2918 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().
02919 { 02920 struct misdn_stack *stack; 02921 02922 for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next) 02923 ; 02924 02925 if (stack) { 02926 cb_log(4, port, "Checking L1 State\n"); 02927 if (!stack->l1link) { 02928 cb_log(4, port, "L1 State Down, trying to get it up again\n"); 02929 misdn_lib_get_short_status(stack); 02930 misdn_lib_get_l1_up(stack); 02931 misdn_lib_get_l2_up(stack); 02932 } 02933 } 02934 }
| void misdn_lib_log_ies | ( | struct misdn_bchannel * | bc | ) |
Definition at line 3160 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().
03161 { 03162 if (!bc) return; 03163 03164 struct misdn_stack *stack=get_stack_by_bc(bc); 03165 03166 if (!stack) return; 03167 03168 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); 03169 03170 cb_log(2, stack->port, 03171 " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n", 03172 bc->info_dad, 03173 bc->onumplan>=0?'0'+bc->onumplan:' ', 03174 bc->dnumplan>=0?'0'+bc->dnumplan:' ', 03175 bc->rnumplan>=0?'0'+bc->rnumplan:' ', 03176 bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' ' 03177 ); 03178 03179 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); 03180 cb_log(4, stack->port, " --> screen:%d --> pres:%d\n", 03181 bc->screen, bc->pres); 03182 03183 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); 03184 03185 cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function)); 03186 03187 cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1); 03188 03189 cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder); 03190 }
| int misdn_lib_maxports_get | ( | void | ) |
Definition at line 3791 of file isdn_lib.c.
Referenced by load_module().
03791 { /** BE AWARE WE HAVE NO CB_LOG HERE! **/ 03792 03793 int i = mISDN_open(); 03794 int max=0; 03795 03796 if (i<0) 03797 return -1; 03798 03799 max = mISDN_get_stack_count(i); 03800 03801 mISDN_close(i); 03802 03803 return max; 03804 }
| void misdn_lib_nt_debug_init | ( | int | flags, | |
| char * | file | |||
| ) |
Definition at line 3807 of file isdn_lib.c.
References f.
Referenced by load_module(), and misdn_lib_init().
03808 { 03809 int static init=0; 03810 char *f; 03811 03812 if (!flags) 03813 f=NULL; 03814 else 03815 f=file; 03816 03817 if (!init) { 03818 debug_init( flags , f, f, f); 03819 init=1; 03820 } else { 03821 debug_close(); 03822 debug_init( flags , f, f, f); 03823 } 03824 }
| int misdn_lib_pid_restart | ( | int | pid | ) |
| int misdn_lib_port_block | ( | int | port | ) |
Definition at line 43 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().
00044 { 00045 struct misdn_stack *stack=get_misdn_stack(); 00046 for ( ; stack; stack=stack->next) { 00047 if (stack->port == port) { 00048 stack->blocked=1; 00049 return 0; 00050 } 00051 } 00052 return -1; 00053 00054 }
| int misdn_lib_port_is_pri | ( | int | port | ) |
Definition at line 30 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().
00031 { 00032 struct misdn_stack *stack=get_misdn_stack(); 00033 for ( ; stack; stack=stack->next) { 00034 if (stack->port == port) { 00035 return stack->pri; 00036 } 00037 } 00038 00039 return -1; 00040 }
| int misdn_lib_port_restart | ( | int | port | ) |
| int misdn_lib_port_unblock | ( | int | port | ) |
Definition at line 56 of file isdn_lib.c.
References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.
Referenced by misdn_port_unblock().
00057 { 00058 struct misdn_stack *stack=get_misdn_stack(); 00059 for ( ; stack; stack=stack->next) { 00060 if (stack->port == port) { 00061 stack->blocked=0; 00062 return 0; 00063 } 00064 } 00065 return -1; 00066 00067 }
| int misdn_lib_port_up | ( | int | port, | |
| int | notcheck | |||
| ) |
Definition at line 1699 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_request().
01700 { 01701 struct misdn_stack *stack; 01702 01703 01704 for (stack=glob_mgr->stack_list; 01705 stack; 01706 stack=stack->next) { 01707 01708 if (stack->port == port) { 01709 01710 if (stack->blocked) { 01711 cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link); 01712 return -1; 01713 } 01714 01715 if (stack->ptp ) { 01716 01717 if (stack->l1link && stack->l2link) { 01718 return 1; 01719 } else { 01720 cb_log(0,port, "Port Down L2:%d L1:%d\n", 01721 stack->l2link, stack->l1link); 01722 return 0; 01723 } 01724 } else { 01725 if ( !check || stack->l1link ) 01726 return 1; 01727 else { 01728 cb_log(0,port, "Port down PMP\n"); 01729 return 0; 01730 } 01731 } 01732 } 01733 } 01734 01735 return -1; 01736 }
| void misdn_lib_reinit_nt_stack | ( | int | port | ) |
Definition at line 4442 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().
04443 { 04444 struct misdn_stack *stack=find_stack_by_port(port); 04445 04446 if (stack) { 04447 stack->l2link=0; 04448 stack->blocked=0; 04449 04450 cleanup_Isdnl3(&stack->nst); 04451 cleanup_Isdnl2(&stack->nst); 04452 04453 04454 memset(&stack->nst, 0, sizeof(net_stack_t)); 04455 memset(&stack->mgr, 0, sizeof(manager_t)); 04456 04457 stack->mgr.nst = &stack->nst; 04458 stack->nst.manager = &stack->mgr; 04459 04460 stack->nst.l3_manager = handle_event_nt; 04461 stack->nst.device = glob_mgr->midev; 04462 stack->nst.cardnr = port; 04463 stack->nst.d_stid = stack->d_stid; 04464 04465 stack->nst.feature = FEATURE_NET_HOLD; 04466 if (stack->ptp) 04467 stack->nst.feature |= FEATURE_NET_PTP; 04468 if (stack->pri) 04469 stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID; 04470 04471 stack->nst.l1_id = stack->lower_id; 04472 stack->nst.l2_id = stack->upper_id; 04473 04474 msg_queue_init(&stack->nst.down_queue); 04475 04476 Isdnl2Init(&stack->nst); 04477 Isdnl3Init(&stack->nst); 04478 04479 if (!stack->ptp) 04480 misdn_lib_get_l1_up(stack); 04481 misdn_lib_get_l2_up(stack); 04482 } 04483 }
| void misdn_lib_release | ( | struct misdn_bchannel * | bc | ) |
Definition at line 1642 of file isdn_lib.c.
References misdn_stack::bc, cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), empty_chan_in_stack(), and get_stack_by_bc().
Referenced by misdn_hangup().
01643 { 01644 struct misdn_stack *stack=get_stack_by_bc(bc); 01645 01646 if (!stack) { 01647 cb_log(1,0,"misdn_release: No Stack found\n"); 01648 return; 01649 } 01650 01651 if (bc->channel>0) { 01652 empty_chan_in_stack(stack,bc->channel); 01653 } 01654 empty_bc(bc); 01655 clean_up_bc(bc); 01656 }
| int misdn_lib_send_event | ( | struct misdn_bchannel * | bc, | |
| enum event_e | event | |||
| ) |
Definition at line 3192 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, 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_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, misdn_stack::ptp, misdn_bchannel::rxgain, set_chan_in_stack(), setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.
Referenced by cb_events(), do_immediate_setup(), handle_event(), handle_event_nt(), handle_frm(), handle_l1(), misdn_answer(), misdn_call(), misdn_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_lib_send_restart(), misdn_overlap_dial_task(), misdn_send_cd(), misdn_send_display(), and misdn_send_text().
03193 { 03194 msg_t *msg; 03195 int err = -1 ; 03196 int ret=0; 03197 03198 if (!bc) goto ERR; 03199 03200 struct misdn_stack *stack=get_stack_by_bc(bc); 03201 03202 if (!stack) { 03203 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); 03204 return -1; 03205 } 03206 03207 cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id); 03208 03209 if ( stack->nt && !stack->l1link) { 03210 /** Queue Event **/ 03211 bc->evq=event; 03212 cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0)); 03213 misdn_lib_get_l1_up(stack); 03214 return 0; 03215 } 03216 03217 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); 03218 cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state)); 03219 misdn_lib_log_ies(bc); 03220 03221 switch (event) { 03222 case EVENT_SETUP: 03223 if (create_process(glob_mgr->midev, bc)<0) { 03224 cb_log(0, stack->port, " No free channel at the moment @ send_event\n"); 03225 03226 err=-ENOCHAN; 03227 goto ERR; 03228 } 03229 #if 0 03230 if (stack->nt) { 03231 ret=setup_bc(bc); 03232 if (ret == -EINVAL) { 03233 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03234 } 03235 } 03236 #endif 03237 break; 03238 03239 case EVENT_PROGRESS: 03240 case EVENT_ALERTING: 03241 case EVENT_PROCEEDING: 03242 case EVENT_SETUP_ACKNOWLEDGE: 03243 if (!bc->nt && !stack->ptp) break; 03244 03245 case EVENT_CONNECT: 03246 case EVENT_RETRIEVE_ACKNOWLEDGE: 03247 03248 if (stack->nt) { 03249 if (bc->channel <=0 ) { /* else we have the channel already */ 03250 if (!find_free_chan_in_stack(stack, bc, 0,0)) { 03251 cb_log(0, stack->port, " No free channel at the moment\n"); 03252 /*FIXME: add disconnect*/ 03253 err=-ENOCHAN; 03254 goto ERR; 03255 } 03256 03257 if (set_chan_in_stack(stack ,bc->channel)<0) { 03258 /*FIXME: add disconnect*/ 03259 err=-ENOCHAN; 03260 goto ERR; 03261 } 03262 } 03263 /* Its that i generate channels */ 03264 } 03265 03266 ret=setup_bc(bc); 03267 if (ret == -EINVAL) { 03268 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03269 } 03270 03271 if (misdn_cap_is_speech(bc->capability)) { 03272 if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) { 03273 if ( *bc->crypt_key ) { 03274 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); 03275 03276 manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) ); 03277 } 03278 03279 if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03280 manager_ec_enable(bc); 03281 03282 if (bc->txgain != 0) { 03283 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03284 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03285 } 03286 03287 if ( bc->rxgain != 0 ) { 03288 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03289 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03290 } 03291 } 03292 } 03293 break; 03294 03295 case EVENT_HOLD_ACKNOWLEDGE: 03296 { 03297 struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel)); 03298 if (!holded_bc) { 03299 cb_log(0,bc->port, "Could not allocate holded_bc!!!\n"); 03300 return -1; 03301 } 03302 03303 /*backup the bc*/ 03304 memcpy(holded_bc,bc,sizeof(struct misdn_bchannel)); 03305 holded_bc->holded=1; 03306 bc_state_change(holded_bc,BCHAN_CLEANED); 03307 03308 stack_holder_add(stack,holded_bc); 03309 03310 /*kill the bridge and clean the bchannel*/ 03311 if (stack->nt) { 03312 if (bc->bc_state == BCHAN_BRIDGED) { 03313 misdn_split_conf(bc,bc->conf_id); 03314 struct misdn_bchannel *bc2=find_bc_by_confid(bc->conf_id); 03315 if (!bc2) 03316 cb_log(0,bc->port,"We have no second bc in bridge???\n"); 03317 else 03318 misdn_split_conf(bc2,bc->conf_id); 03319 } 03320 03321 if (bc->channel>0) 03322 empty_chan_in_stack(stack,bc->channel); 03323 empty_bc(bc); 03324 clean_up_bc(bc); 03325 } 03326 03327 } 03328 break; 03329 03330 /* finishing the channel eh ? */ 03331 case EVENT_DISCONNECT: 03332 if (!bc->need_disconnect) { 03333 cb_log(0,bc->port," --> we have already send Disconnect\n"); 03334 return -1; 03335 } 03336 03337 bc->need_disconnect=0; 03338 break; 03339 case EVENT_RELEASE: 03340 if (!bc->need_release) { 03341 cb_log(0,bc->port," --> we have already send Release\n"); 03342 return -1; 03343 } 03344 bc->need_disconnect=0; 03345 bc->need_release=0; 03346 break; 03347 case EVENT_RELEASE_COMPLETE: 03348 if (!bc->need_release_complete) { 03349 cb_log(0,bc->port," --> we have already send Release_complete\n"); 03350 return -1; 03351 } 03352 bc->need_disconnect=0; 03353 bc->need_release=0; 03354 bc->need_release_complete=0; 03355 03356 if (!stack->nt) { 03357 /*create clenaup in TE*/ 03358 if (bc->channel>0) 03359 empty_chan_in_stack(stack,bc->channel); 03360 int tmpcause=bc->cause; 03361 int tmp_out_cause=bc->out_cause; 03362 empty_bc(bc); 03363 bc->cause=tmpcause; 03364 bc->out_cause=tmp_out_cause; 03365 clean_up_bc(bc); 03366 } 03367 break; 03368 03369 case EVENT_CONNECT_ACKNOWLEDGE: 03370 03371 if ( bc->nt || misdn_cap_is_speech(bc->capability)) { 03372 int ret=setup_bc(bc); 03373 if (ret == -EINVAL){ 03374 cb_log(0,bc->port,"send_event: setup_bc failed\n"); 03375 03376 } 03377 } 03378 03379 03380 if (misdn_cap_is_speech(bc->capability)) { 03381 if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0); 03382 manager_ec_enable(bc); 03383 03384 if ( bc->txgain != 0 ) { 03385 cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain); 03386 manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain); 03387 } 03388 if ( bc->rxgain != 0 ) { 03389 cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain); 03390 manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain); 03391 } 03392 } 03393 break; 03394 03395 default: 03396 break; 03397 } 03398 03399 /* Later we should think about sending bchannel data directly to misdn. */ 03400 msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt); 03401 msg_queue_tail(&stack->downqueue, msg); 03402 sem_post(&glob_mgr->new_msg); 03403 03404 return 0; 03405 03406 ERR: 03407 return -1; 03408 }
| int misdn_lib_send_restart | ( | int | port | ) |
Definition at line 3631 of file isdn_lib.c.
References cb_log, EVENT_RESTART, find_stack_by_port(), misdn_lib_send_event(), misdn_stack::nt, misdn_stack::port, and misdn_stack::pri.
Referenced by misdn_send_restart().
03632 { 03633 struct misdn_stack *stack=find_stack_by_port(port); 03634 cb_log(0, port, "Sending Restarts on this port.\n"); 03635 03636 struct misdn_bchannel dummybc; 03637 memset (&dummybc,0,sizeof(dummybc)); 03638 dummybc.port=stack->port; 03639 dummybc.l3_id=MISDN_ID_GLOBAL; 03640 dummybc.nt=stack->nt; 03641 03642 int max=stack->pri?30:2; 03643 int i; 03644 for (i=1;i<=max;i++) { 03645 dummybc.channel=i; 03646 cb_log(0, port, "Restarting channel %d\n",i); 03647 misdn_lib_send_event(&dummybc, EVENT_RESTART); 03648 /*do we need to wait before we get an EVENT_RESTART_ACK ?*/ 03649 } 03650 03651 return 0; 03652 }
| void misdn_lib_send_tone | ( | struct misdn_bchannel * | bc, | |
| enum tone_e | tone | |||
| ) |
Definition at line 4252 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().
04253 { 04254 04255 switch(tone) { 04256 case TONE_DIAL: 04257 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 04258 break; 04259 04260 case TONE_ALERTING: 04261 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING); 04262 break; 04263 04264 case TONE_HANGUP: 04265 manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP); 04266 break; 04267 04268 case TONE_NONE: 04269 default: 04270 manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP); 04271 } 04272 04273 char buf[mISDN_HEADER_LEN+128]; 04274 iframe_t *frm=(iframe_t*)buf; 04275 memset(buf,0,mISDN_HEADER_LEN+128); 04276 04277 frm->prim=DL_DATA|REQUEST; 04278 frm->addr=bc->addr|FLG_MSG_DOWN; 04279 frm->dinfo=0; 04280 frm->len=128; 04281 04282 mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC); 04283 }
| void misdn_lib_setup_bc | ( | struct misdn_bchannel * | bc | ) |
Definition at line 921 of file isdn_lib.c.
References misdn_stack::bc, clean_up_bc(), and setup_bc().
Referenced by misdn_set_opt_exec().
00922 { 00923 clean_up_bc(bc); 00924 setup_bc(bc); 00925 }
| void misdn_lib_split_bridge | ( | struct misdn_bchannel * | bc1, | |
| struct misdn_bchannel * | bc2 | |||
| ) |
Definition at line 4414 of file isdn_lib.c.
References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().
Referenced by misdn_bridge().
04415 { 04416 04417 struct misdn_bchannel *bc_list[]={ 04418 bc1,bc2,NULL 04419 }; 04420 struct misdn_bchannel **bc; 04421 04422 for (bc=bc_list; *bc; bc++) { 04423 if ( (*bc)->bc_state == BCHAN_BRIDGED){ 04424 misdn_split_conf( *bc, (*bc)->conf_id); 04425 } else { 04426 cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state)); 04427 } 04428 } 04429 04430 }
| void misdn_lib_tone_generator_start | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2167 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by dialtone_indicate().
02168 { 02169 bc->generate_tone=1; 02170 }
| void misdn_lib_tone_generator_stop | ( | struct misdn_bchannel * | bc | ) |
Definition at line 2172 of file isdn_lib.c.
References misdn_bchannel::generate_tone.
Referenced by start_bc_tones(), and stop_indicate().
02173 { 02174 bc->generate_tone=0; 02175 }
| void misdn_lib_transfer | ( | struct misdn_bchannel * | holded_bc | ) |
Definition at line 3025 of file isdn_lib.c.
References misdn_bchannel::holded.
03026 { 03027 holded_bc->holded=0; 03028 }
| int misdn_lib_tx2misdn_frm | ( | struct misdn_bchannel * | bc, | |
| void * | data, | |||
| int | len | |||
| ) |
Definition at line 4033 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().
04034 { 04035 struct misdn_stack *stack=get_stack_by_bc(bc); 04036 04037 switch (bc->bc_state) { 04038 case BCHAN_ACTIVATED: 04039 case BCHAN_BRIDGED: 04040 break; 04041 default: 04042 cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state)); 04043 return -1; 04044 } 04045 04046 char buf[4096 + mISDN_HEADER_LEN]; 04047 iframe_t *frm= (iframe_t*)buf; 04048 int r; 04049 04050 frm->prim = DL_DATA|REQUEST; 04051 frm->dinfo = 0; 04052 frm->addr = bc->addr | FLG_MSG_DOWN ; 04053 04054 frm->len = len; 04055 memcpy(&buf[mISDN_HEADER_LEN], data,len); 04056 04057 if ( misdn_cap_is_speech(bc->capability) ) 04058 flip_buf_bits( &buf[mISDN_HEADER_LEN], len); 04059 else 04060 cb_log(6, stack->port, "Writing %d data bytes\n",len); 04061 04062 cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len); 04063 r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT); 04064 return 0; 04065 }
| enum event_response_e(*) cb_event(enum event_e event, struct misdn_bchannel *bc, void *user_data) |
Definition at line 375 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(), set_channel(), and setup_bc().
| int(*) cb_jb_empty(struct misdn_bchannel *bc, char *buffer, int len) |
| void(*) cb_log(int level, int port, char *tmpl,...) |
Definition at line 376 of file isdn_lib.h.
Referenced by bc_next_state_change(), bc_state_change(), build_connect(), build_restart(), build_setup(), cb_events(), clean_up_bc(), config_jitterbuffer(), create_process(), dump_chan_list(), empty_chan_in_stack(), fetch_msg(), find_free_chan_in_stack(), handle_bchan(), handle_cr(), handle_err(), handle_event(), handle_event_nt(), handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), handle_mgmt(), handle_timers(), hangup_chan(), init_bc(), isdn_msg_get_index_by_event(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_ec_disable(), manager_ec_enable(), manager_event_handler(), manager_isdn_handler(), manager_ph_control(), misdn_join_conf(), misdn_lib_bridge(), misdn_lib_destroy(), misdn_lib_echo(), misdn_lib_get_free_bc(), misdn_lib_get_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().
1.5.1