#include <syslog.h>
#include <sys/time.h>
#include <mISDNuser/isdn_debug.h>
#include "isdn_lib_intern.h"
#include "isdn_lib.h"
#include "asterisk/causes.h"
#include <mISDNuser/net_l2.h>
#include <mISDNuser/tone.h>
#include <unistd.h>
#include <semaphore.h>
#include <pthread.h>
#include <signal.h>
Include dependency graph for isdn_lib.c:

Go to the source code of this file.
Data Structures | |
| struct | misdn_lib |
Defines | |
| #define | ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) |
| #define | ECHOCAN_OFF 124 |
| #define | ECHOCAN_ON 123 |
| #define | ISDN_PID_L3_B_USER 0x430000ff |
| #define | ISDN_PID_L4_B_USER 0x440000ff |
| #define | MAXPROCS 0x100 |
| #define | MISDN_DEBUG 0 |
| #define | MISDN_DSP |
| #define | MISDN_GEN_SILENCE |
| #define | MISDN_IBUF_SIZE 512 |
| #define | RETURN(a, b) {retval=a; goto b;} |
| #define | TONE_ALERT_CNT 41 |
| #define | TONE_ALERT_SILENCE_CNT 200 |
| #define | TONE_BUSY_CNT 20 |
| #define | TONE_BUSY_SILENCE_CNT 48 |
Enumerations | |
| enum | global_states { MISDN_INITIALIZING, MISDN_INITIALIZED } |
Functions | |
| static void | bc_next_state_change (struct misdn_bchannel *bc, enum bchannel_state state) |
| char * | bc_state2str (enum bchannel_state state) |
| void | bc_state_change (struct misdn_bchannel *bc, enum bchannel_state state) |
| int | bchdev_echocancel_activate (struct misdn_bchannel *dev) |
| void | bchdev_echocancel_deactivate (struct misdn_bchannel *dev) |
| static char * | bearer2str (int cap) |
| static int | clean_up_bc (struct misdn_bchannel *bc) |
| static void | clear_l3 (struct misdn_stack *stack) |
| static msg_t * | create_l2msg (int prim, int dinfo, int size) |
| msg_t * | create_l3msg (int prim, int mt, int dinfo, int size, int ntmode) |
| static int | create_process (int midev, struct misdn_bchannel *bc) |
| static int | do_tone (struct misdn_bchannel *bc, int len) |
| static void | dump_chan_list (struct misdn_stack *stack) |
| void | ec_chunk (struct misdn_bchannel *bc, unsigned char *rxchunk, unsigned char *txchunk, int chunk_size) |
| static void | empty_bc (struct misdn_bchannel *bc) |
| static int | empty_chan_in_stack (struct misdn_stack *stack, int channel) |
| static const char * | fac2str (enum FacFunction facility) |
| static msg_t * | fetch_msg (int midev) |
| static struct misdn_bchannel * | find_bc_by_addr (unsigned long addr) |
| static struct misdn_bchannel * | find_bc_by_channel (int port, int channel) |
| misdn_bchannel * | find_bc_by_confid (unsigned long confid) |
| misdn_bchannel * | find_bc_by_l3id (struct misdn_stack *stack, unsigned long l3id) |
| static struct misdn_bchannel * | find_bc_by_masked_l3id (struct misdn_stack *stack, unsigned long l3id, unsigned long mask) |
| static struct misdn_bchannel * | find_bc_holded (struct misdn_stack *stack) |
| static int | find_free_chan_in_stack (struct misdn_stack *stack, struct misdn_bchannel *bc, int channel, int dec) |
| static struct misdn_stack * | find_stack_by_addr (int addr) |
| static struct misdn_stack * | find_stack_by_mgr (manager_t *mgr_nt) |
| static struct misdn_stack * | find_stack_by_port (int port) |
| static char * | flip_buf_bits (char *buf, int len) |
| misdn_stack * | get_misdn_stack (void) |
| void | get_show_stack_details (int port, char *buf) |
| misdn_stack * | get_stack_by_bc (struct misdn_bchannel *bc) |
| static int | handle_bchan (msg_t *msg) |
| static int | handle_cr (struct misdn_stack *stack, iframe_t *frm) |
| static int | handle_err (msg_t *msg) |
| static int | handle_event (struct misdn_bchannel *bc, enum event_e event, iframe_t *frm) |
| static int | handle_event_nt (void *dat, void *arg) |
| static int | handle_frm (msg_t *msg) |
| static int | handle_frm_nt (msg_t *msg) |
| static int | handle_l1 (msg_t *msg) |
| static int | handle_l2 (msg_t *msg) |
| static int | handle_mgmt (msg_t *msg) |
| static int | handle_timers (msg_t *msg) |
| static int | init_bc (struct misdn_stack *stack, struct misdn_bchannel *bc, int midev, int port, int bidx, char *msn, int firsttime) |
| static void | init_flip_bits (void) |
| void | isdn_lib_stop_dtmf (struct misdn_bchannel *bc) |
| void | isdn_lib_update_ec (struct misdn_bchannel *bc) |
| void | isdn_lib_update_rxgain (struct misdn_bchannel *bc) |
| void | isdn_lib_update_txgain (struct misdn_bchannel *bc) |
| void | manager_bchannel_activate (struct misdn_bchannel *bc) |
| void | manager_bchannel_cleanup (struct misdn_bchannel *bc) |
| void | manager_bchannel_deactivate (struct misdn_bchannel *bc) |
| void | manager_bchannel_setup (struct misdn_bchannel *bc) |
| void | manager_clean_bc (struct misdn_bchannel *bc) |
| void | manager_ec_disable (struct misdn_bchannel *bc) |
| void | manager_ec_enable (struct misdn_bchannel *bc) |
| static void | manager_event_handler (void *arg) |
| misdn_bchannel * | manager_find_bc_by_pid (int pid) |
| misdn_bchannel * | manager_find_bc_holded (struct misdn_bchannel *bc) |
| char * | manager_isdn_get_info (enum event_e event) |
| int | manager_isdn_handler (iframe_t *frm, msg_t *msg) |
| void | manager_ph_control (struct misdn_bchannel *bc, int c1, int c2) |
| void | manager_ph_control_block (struct misdn_bchannel *bc, int c1, void *c2, int c2_len) |
| int | misdn_cap_is_speech (int cap) |
| void | misdn_dump_chanlist () |
| int | misdn_inband_avail (struct misdn_bchannel *bc) |
| void | misdn_join_conf (struct misdn_bchannel *bc, int conf_id) |
| void | misdn_lib_bridge (struct misdn_bchannel *bc1, struct misdn_bchannel *bc2) |
| void | misdn_lib_destroy (void) |
| void | misdn_lib_echo (struct misdn_bchannel *bc, int onoff) |
| misdn_bchannel * | misdn_lib_get_free_bc (int port, int channel, int inout, int dec) |
| static int | misdn_lib_get_l1_down (struct misdn_stack *stack) |
| static int | misdn_lib_get_l1_up (struct misdn_stack *stack) |
| static int | misdn_lib_get_l2_down (struct misdn_stack *stack) |
| int | misdn_lib_get_l2_up (struct misdn_stack *stack) |
| int | misdn_lib_get_maxchans (int port) |
| int | misdn_lib_get_port_down (int port) |
| int | misdn_lib_get_port_info (int port) |
| int | misdn_lib_get_port_up (int port) |
| static int | misdn_lib_get_short_status (struct misdn_stack *stack) |
| int | misdn_lib_init (char *portlist, struct misdn_lib_iface *iface, void *user_data) |
| int | misdn_lib_is_port_blocked (int port) |
| int | misdn_lib_is_ptp (int port) |
| static void | misdn_lib_isdn_event_catcher (void *arg) |
| void | misdn_lib_isdn_l1watcher (int port) |
| void | misdn_lib_log_ies (struct misdn_bchannel *bc) |
| int | misdn_lib_maxports_get (void) |
| void | misdn_lib_nt_debug_init (int flags, char *file) |
| void | misdn_lib_nt_keepcalls (int kc) |
| int | misdn_lib_pid_restart (int pid) |
| int | misdn_lib_port_block (int port) |
| int | misdn_lib_port_is_pri (int port) |
| int | misdn_lib_port_restart (int port) |
| int | misdn_lib_port_unblock (int port) |
| int | misdn_lib_port_up (int port, int check) |
| void | misdn_lib_reinit_nt_stack (int port) |
| void | misdn_lib_release (struct misdn_bchannel *bc) |
| int | misdn_lib_send_event (struct misdn_bchannel *bc, enum event_e event) |
| int | misdn_lib_send_restart (int port, int channel) |
| void | misdn_lib_send_tone (struct misdn_bchannel *bc, enum tone_e tone) |
| void | misdn_lib_setup_bc (struct misdn_bchannel *bc) |
| void | misdn_lib_split_bridge (struct misdn_bchannel *bc1, struct misdn_bchannel *bc2) |
| void | misdn_lib_tone_generator_start (struct misdn_bchannel *bc) |
| void | misdn_lib_tone_generator_stop (struct misdn_bchannel *bc) |
| void | misdn_lib_transfer (struct misdn_bchannel *holded_bc) |
| int | misdn_lib_tx2misdn_frm (struct misdn_bchannel *bc, void *data, int len) |
| static void | misdn_make_dummy (struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel) |
| static void | misdn_send_lock (struct misdn_bchannel *bc) |
| static void | misdn_send_unlock (struct misdn_bchannel *bc) |
| void | misdn_split_conf (struct misdn_bchannel *bc, int conf_id) |
| void | misdn_tx_jitter (struct misdn_bchannel *bc, int len) |
| static void | prepare_bc (struct misdn_bchannel *bc, int channel) |
| int | queue_cleanup_bc (struct misdn_bchannel *bc) |
| int | release_cr (struct misdn_stack *stack, mISDNuser_head_t *hh) |
| static int | send_msg (int midev, struct misdn_bchannel *bc, msg_t *dmsg) |
| static int | set_chan_in_stack (struct misdn_stack *stack, int channel) |
| int | setup_bc (struct misdn_bchannel *bc) |
| static void | stack_destroy (struct misdn_stack *stack) |
| void | stack_holder_add (struct misdn_stack *stack, struct misdn_bchannel *holder) |
| misdn_bchannel * | stack_holder_find (struct misdn_stack *stack, unsigned long l3id) |
| misdn_bchannel * | stack_holder_find_bychan (struct misdn_stack *stack, int chan) |
| void | stack_holder_remove (struct misdn_stack *stack, struct misdn_bchannel *holder) |
| static struct misdn_stack * | stack_init (int midev, int port, int ptp) |
| void | te_lib_destroy (int midev) |
| int | te_lib_init (void) |
| static int | test_inuse (struct misdn_bchannel *bc) |
Variables | |
| static int | entity |
| static char | flip_table [256] |
| static struct misdn_lib * | glob_mgr |
| static enum global_states | global_state = MISDN_INITIALIZING |
| sem_t | handler_started |
| isdn_msg | msgs_g [] |
| static int | mypid = 1 |
| static int | newteid = 0 |
| static int | nt_err_cnt = 0 |
| char | tone_425_flip [TONE_425_SIZE] |
| char | tone_silence_flip [TONE_SILENCE_SIZE] |
Definition in file isdn_lib.c.
| #define ARRAY_LEN | ( | a | ) | (sizeof(a) / sizeof(a[0])) |
Definition at line 32 of file isdn_lib.c.
| #define ECHOCAN_OFF 124 |
| #define ECHOCAN_ON 123 |
| #define ISDN_PID_L3_B_USER 0x430000ff |
Definition at line 229 of file isdn_lib.c.
| #define ISDN_PID_L4_B_USER 0x440000ff |
Definition at line 230 of file isdn_lib.c.
| #define MAXPROCS 0x100 |
| #define MISDN_DEBUG 0 |
Definition at line 210 of file isdn_lib.c.
| #define MISDN_DSP |
| #define MISDN_GEN_SILENCE |
| #define MISDN_IBUF_SIZE 512 |
| #define RETURN | ( | a, | |||
| b | ) | {retval=a; goto b;} |
| #define TONE_ALERT_CNT 41 |
Definition at line 236 of file isdn_lib.c.
| #define TONE_ALERT_SILENCE_CNT 200 |
Definition at line 237 of file isdn_lib.c.
| #define TONE_BUSY_CNT 20 |
Definition at line 239 of file isdn_lib.c.
| #define TONE_BUSY_SILENCE_CNT 48 |
Definition at line 240 of file isdn_lib.c.
| enum global_states |
Definition at line 169 of file isdn_lib.c.
00169 { 00170 MISDN_INITIALIZING, 00171 MISDN_INITIALIZED 00172 } ;
| static void bc_next_state_change | ( | struct misdn_bchannel * | bc, | |
| enum bchannel_state | state | |||
| ) | [static] |
Definition at line 611 of file isdn_lib.c.
References bc_state2str(), cb_log, misdn_bchannel::next_bc_state, and misdn_bchannel::port.
Referenced by misdn_lib_bridge().
00612 { 00613 cb_log(5,bc->port,"BC_NEXT_STATE_CHANGE: from:%s to:%s\n", 00614 bc_state2str(bc->next_bc_state), 00615 bc_state2str(state) ); 00616 00617 bc->next_bc_state=state; 00618 }
| char* bc_state2str | ( | enum bchannel_state | state | ) |
Definition at line 562 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().
00562 { 00563 int i; 00564 00565 struct bchan_state_s { 00566 char *n; 00567 enum bchannel_state s; 00568 } states[] = { 00569 {"BCHAN_CLEANED", BCHAN_CLEANED }, 00570 {"BCHAN_EMPTY", BCHAN_EMPTY}, 00571 {"BCHAN_SETUP", BCHAN_SETUP}, 00572 {"BCHAN_SETUPED", BCHAN_SETUPED}, 00573 {"BCHAN_ACTIVE", BCHAN_ACTIVE}, 00574 {"BCHAN_ACTIVATED", BCHAN_ACTIVATED}, 00575 {"BCHAN_BRIDGE", BCHAN_BRIDGE}, 00576 {"BCHAN_BRIDGED", BCHAN_BRIDGED}, 00577 {"BCHAN_RELEASE", BCHAN_RELEASE}, 00578 {"BCHAN_RELEASED", BCHAN_RELEASED}, 00579 {"BCHAN_CLEAN", BCHAN_CLEAN}, 00580 {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST}, 00581 {"BCHAN_ERROR", BCHAN_ERROR} 00582 }; 00583 00584 for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++) 00585 if ( states[i].s == state) 00586 return states[i].n; 00587 00588 return "UNKNOWN"; 00589 }
| void bc_state_change | ( | struct misdn_bchannel * | bc, | |
| enum bchannel_state | state | |||
| ) |
Definition at line 591 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().
00592 { 00593 cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n", 00594 bc->l3_id, 00595 bc_state2str(bc->bc_state), 00596 bc_state2str(state) ); 00597 00598 switch (state) { 00599 case BCHAN_ACTIVATED: 00600 if (bc->next_bc_state == BCHAN_BRIDGED) { 00601 misdn_join_conf(bc, bc->conf_id); 00602 bc->next_bc_state = BCHAN_EMPTY; 00603 return; 00604 } 00605 default: 00606 bc->bc_state=state; 00607 break; 00608 } 00609 }
| int bchdev_echocancel_activate | ( | struct misdn_bchannel * | dev | ) |
| void bchdev_echocancel_deactivate | ( | struct misdn_bchannel * | dev | ) |
| static char* bearer2str | ( | int | cap | ) | [static] |
Definition at line 275 of file isdn_lib.c.
References INFO_CAPABILITY_AUDIO_3_1K, INFO_CAPABILITY_DIGITAL_RESTRICTED, INFO_CAPABILITY_DIGITAL_UNRESTRICTED, and INFO_CAPABILITY_SPEECH.
00275 { 00276 static char *bearers[]={ 00277 "Speech", 00278 "Audio 3.1k", 00279 "Unres Digital", 00280 "Res Digital", 00281 "Unknown Bearer" 00282 }; 00283 00284 switch (cap) { 00285 case INFO_CAPABILITY_SPEECH: 00286 return bearers[0]; 00287 break; 00288 case INFO_CAPABILITY_AUDIO_3_1K: 00289 return bearers[1]; 00290 break; 00291 case INFO_CAPABILITY_DIGITAL_UNRESTRICTED: 00292 return bearers[2]; 00293 break; 00294 case INFO_CAPABILITY_DIGITAL_RESTRICTED: 00295 return bearers[3]; 00296 break; 00297 default: 00298 return bearers[4]; 00299 break; 00300 } 00301 }
| static int clean_up_bc | ( | struct misdn_bchannel * | bc | ) | [static] |
Definition at line 718 of file isdn_lib.c.
References misdn_bchannel::b_stid, misdn_stack::bc, misdn_bchannel::bc_state, bc_state_change(), BCHAN_CLEANED, cb_log, get_stack_by_bc(), misdn_bchannel::layer_id, manager_bchannel_deactivate(), manager_ec_disable(), misdn_stack::midev, misdn_bchannel::pid, misdn_stack::port, and misdn_bchannel::port.
Referenced by clear_l3(), handle_bchan(), handle_cr(), handle_event_nt(), handle_frm(), manager_event_handler(), misdn_lib_release(), misdn_lib_send_event(), misdn_lib_send_restart(), and misdn_lib_setup_bc().
00719 { 00720 int ret=0; 00721 unsigned char buff[32]; 00722 struct misdn_stack * stack; 00723 00724 cb_log(3, bc?bc->port:0, "$$$ CLEANUP CALLED pid:%d\n", bc?bc->pid:-1); 00725 00726 if (!bc ) return -1; 00727 stack=get_stack_by_bc(bc); 00728 00729 if (!stack) return -1; 00730 00731 switch (bc->bc_state ) { 00732 case BCHAN_CLEANED: 00733 cb_log(5, stack->port, "$$$ Already cleaned up bc with stid :%x\n", bc->b_stid); 00734 return -1; 00735 00736 default: 00737 break; 00738 } 00739 00740 cb_log(2, stack->port, "$$$ Cleaning up bc with stid :%x pid:%d\n", bc->b_stid, bc->pid); 00741 00742 manager_ec_disable(bc); 00743 00744 manager_bchannel_deactivate(bc); 00745 00746 mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC); 00747 00748 bc->b_stid = 0; 00749 bc_state_change(bc, BCHAN_CLEANED); 00750 00751 return ret; 00752 }
| static void clear_l3 | ( | struct misdn_stack * | stack | ) | [static] |
Definition at line 756 of file isdn_lib.c.
References misdn_stack::b_num, misdn_stack::bc, cb_event, clean_up_bc(), empty_bc(), empty_chan_in_stack(), EVENT_CLEANUP, global_state, and MISDN_INITIALIZED.
Referenced by handle_mgmt(), and misdn_lib_port_restart().
00757 { 00758 int i; 00759 00760 for (i=0; i<=stack->b_num; i++) { 00761 if (global_state == MISDN_INITIALIZED) { 00762 cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); 00763 empty_chan_in_stack(stack,i+1); 00764 empty_bc(&stack->bc[i]); 00765 clean_up_bc(&stack->bc[i]); 00766 stack->bc[i].in_use = 0; 00767 } 00768 00769 } 00770 }
| static msg_t* create_l2msg | ( | int | prim, | |
| int | dinfo, | |||
| int | size | |||
| ) | [static] |
Definition at line 334 of file isdn_lib.c.
Referenced by misdn_lib_get_l2_down(), and misdn_lib_get_l2_up().
00335 { 00336 int i = 0; 00337 msg_t *dmsg; 00338 00339 while(i < 10) 00340 { 00341 dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL); 00342 if (dmsg) 00343 return(dmsg); 00344 00345 if (!i) 00346 printf("cannot allocate memory, trying again...\n"); 00347 i++; 00348 usleep(300000); 00349 } 00350 printf("cannot allocate memory, system overloaded.\n"); 00351 exit(-1); 00352 }
| msg_t* create_l3msg | ( | int | prim, | |
| int | mt, | |||
| int | dinfo, | |||
| int | size, | |||
| int | ntmode | |||
| ) |
Definition at line 356 of file isdn_lib.c.
Referenced by build_alerting(), build_connect(), build_connect_acknowledge(), build_disconnect(), build_facility(), build_hold(), build_hold_acknowledge(), build_hold_reject(), build_information(), build_notify(), build_proceeding(), build_progress(), build_release(), build_release_complete(), build_restart(), build_resume(), build_resume_acknowledge(), build_resume_reject(), build_retrieve(), build_retrieve_acknowledge(), build_retrieve_reject(), build_setup(), build_setup_acknowledge(), build_status(), build_status_enquiry(), build_suspend(), build_suspend_acknowledge(), build_suspend_reject(), build_timeout(), build_user_information(), and handle_event_nt().
00357 { 00358 int i = 0; 00359 msg_t *dmsg; 00360 Q931_info_t *qi; 00361 iframe_t *frm; 00362 00363 if (!ntmode) 00364 size = sizeof(Q931_info_t)+2; 00365 00366 while(i < 10) { 00367 if (ntmode) { 00368 dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL); 00369 if (dmsg) { 00370 return(dmsg); 00371 } 00372 } else { 00373 dmsg = alloc_msg(size+256+mISDN_HEADER_LEN+DEFAULT_HEADROOM); 00374 if (dmsg) 00375 { 00376 memset(msg_put(dmsg,size+mISDN_HEADER_LEN), 0, size+mISDN_HEADER_LEN); 00377 frm = (iframe_t *)dmsg->data; 00378 frm->prim = prim; 00379 frm->dinfo = dinfo; 00380 qi = (Q931_info_t *)(dmsg->data + mISDN_HEADER_LEN); 00381 qi->type = mt; 00382 return(dmsg); 00383 } 00384 } 00385 00386 if (!i) printf("cannot allocate memory, trying again...\n"); 00387 i++; 00388 usleep(300000); 00389 } 00390 printf("cannot allocate memory, system overloaded.\n"); 00391 exit(-1); 00392 }
| static int create_process | ( | int | midev, | |
| struct misdn_bchannel * | bc | |||
| ) | [static] |
Definition at line 888 of file isdn_lib.c.
References misdn_stack::bc, cb_log, misdn_bchannel::channel, misdn_bchannel::channel_preselected, misdn_bchannel::dec, entity, find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::l3_id, MAXPROCS, misdn_stack::nt, misdn_stack::port, misdn_stack::procids, misdn_stack::ptp, misdn_bchannel::te_choose_channel, and misdn_stack::upper_id.
Referenced by misdn_lib_send_event().
00888 { 00889 iframe_t ncr; 00890 int l3_id; 00891 int i; 00892 struct misdn_stack *stack=get_stack_by_bc(bc); 00893 00894 if (stack->nt) { 00895 if (find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0, 0)<0) return -1; 00896 cb_log(4,stack->port, " --> found channel: %d\n",bc->channel); 00897 00898 for (i=0; i <= MAXPROCS; i++) 00899 if (stack->procids[i]==0) break; 00900 00901 if (i== MAXPROCS) { 00902 cb_log(0, stack->port, "Couldn't Create New ProcId.\n"); 00903 return -1; 00904 } 00905 stack->procids[i]=1; 00906 00907 l3_id = 0xff00 | i; 00908 00909 ncr.prim = CC_NEW_CR | REQUEST; 00910 00911 ncr.addr = (stack->upper_id | FLG_MSG_DOWN) ; 00912 00913 ncr.dinfo = l3_id; 00914 ncr.len = 0; 00915 00916 bc->l3_id = l3_id; 00917 cb_log(3, stack->port, " --> new_l3id %x\n",l3_id); 00918 00919 } else { 00920 if (stack->ptp || bc->te_choose_channel) { 00921 /* we know exactly which channels are in use */ 00922 if (find_free_chan_in_stack(stack, bc, bc->channel_preselected?bc->channel:0, bc->dec)<0) return -1; 00923 cb_log(2,stack->port, " --> found channel: %d\n",bc->channel); 00924 } else { 00925 /* other phones could have made a call also on this port (ptmp) */ 00926 bc->channel=0xff; 00927 } 00928 00929 00930 /* if we are in te-mode, we need to create a process first */ 00931 if (newteid++ > 0xffff) 00932 newteid = 0x0001; 00933 00934 l3_id = (entity<<16) | newteid; 00935 /* preparing message */ 00936 ncr.prim = CC_NEW_CR | REQUEST; 00937 00938 ncr.addr = (stack->upper_id | FLG_MSG_DOWN) ; 00939 00940 ncr.dinfo =l3_id; 00941 ncr.len = 0; 00942 /* send message */ 00943 00944 bc->l3_id = l3_id; 00945 cb_log(3, stack->port, "--> new_l3id %x\n",l3_id); 00946 00947 mISDN_write(midev, &ncr, mISDN_HEADER_LEN+ncr.len, TIMEOUT_1SEC); 00948 } 00949 00950 return l3_id; 00951 }
| static int do_tone | ( | struct misdn_bchannel * | bc, | |
| int | len | |||
| ) | [static] |
Definition at line 2205 of file isdn_lib.c.
References cb_event, EVENT_TONE_GENERATE, misdn_bchannel::generate_tone, glob_mgr, misdn_tx_jitter(), misdn_bchannel::nojitter, misdn_bchannel::tone_cnt, and misdn_lib::user_data.
Referenced by handle_bchan().
02206 { 02207 bc->tone_cnt=len; 02208 02209 if (bc->generate_tone) { 02210 cb_event(EVENT_TONE_GENERATE, bc, glob_mgr->user_data); 02211 02212 if ( !bc->nojitter ) { 02213 misdn_tx_jitter(bc,len); 02214 } 02215 02216 return 1; 02217 } 02218 02219 return 0; 02220 }
| static void dump_chan_list | ( | struct misdn_stack * | stack | ) | [static] |
Definition at line 449 of file isdn_lib.c.
References misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_stack::channels, misdn_bchannel::in_use, and misdn_stack::port.
Referenced by empty_chan_in_stack(), handle_cr(), misdn_dump_chanlist(), and set_chan_in_stack().
00450 { 00451 int i; 00452 00453 for (i=0; i <= stack->b_num; i++) { 00454 cb_log(6, stack->port, "Idx:%d stack->cchan:%d in_use:%d Chan:%d\n",i,stack->channels[i], stack->bc[i].in_use, i+1); 00455 } 00456 }
| void ec_chunk | ( | struct misdn_bchannel * | bc, | |
| unsigned char * | rxchunk, | |||
| unsigned char * | txchunk, | |||
| int | chunk_size | |||
| ) |
| static void empty_bc | ( | struct misdn_bchannel * | bc | ) | [static] |
Definition at line 621 of file isdn_lib.c.
References misdn_bchannel::active, AST_CAUSE_NORMAL_CLEARING, misdn_bchannel::bframe_len, misdn_bchannel::cad, misdn_bchannel::capability, misdn_bchannel::cause, misdn_bchannel::channel, misdn_bchannel::channel_found, misdn_bchannel::conf_id, misdn_bchannel::cpnnumplan, misdn_bchannel::crypt, misdn_bchannel::crypt_key, misdn_bchannel::curprx, misdn_bchannel::curptx, misdn_bchannel::cw, misdn_bchannel::dad, misdn_bchannel::dec, misdn_bchannel::display, misdn_bchannel::dnumplan, misdn_bchannel::dummy, misdn_bchannel::early_bconnect, misdn_bchannel::ec_deftaps, misdn_bchannel::ec_enable, EVENT_NOTHING, misdn_bchannel::evq, misdn_bchannel::fac_in, misdn_bchannel::fac_out, misdn_bchannel::generate_tone, misdn_bchannel::hdlc, INFO_CAPABILITY_SPEECH, INFO_CODEC_ALAW, misdn_bchannel::info_dad, misdn_bchannel::infos_pending, misdn_bchannel::last_used, misdn_bchannel::law, misdn_bchannel::mode, misdn_bchannel::need_more_infos, misdn_bchannel::nodsp, misdn_bchannel::nojitter, NUMPLAN_UNKNOWN, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::orig, misdn_bchannel::orig_dad, misdn_bchannel::out_cause, misdn_bchannel::pres, misdn_bchannel::progress_coding, misdn_bchannel::progress_indicator, misdn_bchannel::progress_location, misdn_bchannel::rad, misdn_bchannel::rate, misdn_bchannel::restart_channel, misdn_bchannel::rnumplan, misdn_bchannel::rxgain, misdn_bchannel::send_dtmf, misdn_bchannel::sending_complete, misdn_bchannel::te_choose_channel, misdn_bchannel::time_usec, misdn_bchannel::tone_cnt, misdn_bchannel::txgain, misdn_bchannel::urate, misdn_bchannel::user1, misdn_bchannel::uu, and misdn_bchannel::uulen.
Referenced by clear_l3(), handle_cr(), handle_event_nt(), handle_frm(), init_bc(), manager_clean_bc(), misdn_lib_release(), misdn_lib_send_event(), and misdn_lib_send_restart().
00622 { 00623 bc->dummy=0; 00624 00625 bc->bframe_len=0; 00626 00627 bc->cw= 0; 00628 00629 bc->dec=0; 00630 bc->channel = 0; 00631 00632 bc->sending_complete = 0; 00633 00634 bc->restart_channel=0; 00635 00636 bc->conf_id = 0; 00637 00638 bc->need_more_infos = 0; 00639 00640 bc->send_dtmf=0; 00641 bc->