Sat Aug 6 00:39:57 2011

Asterisk developer's documentation


isdn_lib.c File Reference

Interface to mISDN. More...

#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>

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_bchannelfind_bc_by_addr (unsigned long addr)
static struct misdn_bchannelfind_bc_by_channel (int port, int channel)
static struct misdn_bchannelfind_bc_by_confid (unsigned long confid)
misdn_bchannelfind_bc_by_l3id (struct misdn_stack *stack, unsigned long l3id)
static struct misdn_bchannelfind_bc_by_masked_l3id (struct misdn_stack *stack, unsigned long l3id, unsigned long mask)
static int find_free_chan_in_stack (struct misdn_stack *stack, struct misdn_bchannel *bc, int channel, int dec)
static struct misdn_stackfind_stack_by_addr (int addr)
static struct misdn_stackfind_stack_by_mgr (manager_t *mgr_nt)
static struct misdn_stackfind_stack_by_port (int port)
static char * flip_buf_bits (char *buf, int len)
misdn_stackget_misdn_stack (void)
void get_show_stack_details (int port, char *buf)
misdn_stackget_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_bchannelmanager_find_bc_by_pid (int pid)
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_bchannelmisdn_lib_find_held_bc (int port, int l3_id)
 Find a held call's B channel record.
misdn_bchannelmisdn_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)
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_bchannelstack_holder_find (struct misdn_stack *stack, unsigned long l3id)
void stack_holder_remove (struct misdn_stack *stack, struct misdn_bchannel *holder)
static struct misdn_stackstack_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_libglob_mgr
static enum global_states global_state = MISDN_INITIALIZING
sem_t handler_started
isdn_msg msgs_g []
static int mypid = 1
static int new_te_id = 0
static int nt_err_cnt = 0
char tone_425_flip [TONE_425_SIZE]
char tone_silence_flip [TONE_SILENCE_SIZE]


Detailed Description

Interface to mISDN.

Author:
Christian Richter <crich@beronet.com>

Definition in file isdn_lib.c.


Define Documentation

#define ARRAY_LEN (  )     (sizeof(a) / sizeof(a[0]))

Definition at line 32 of file isdn_lib.c.

#define ECHOCAN_OFF   124

Definition at line 205 of file isdn_lib.c.

Referenced by manager_ec_disable().

#define ECHOCAN_ON   123

Definition at line 204 of file isdn_lib.c.

Referenced by manager_ec_enable().

#define ISDN_PID_L3_B_USER   0x430000ff

Definition at line 223 of file isdn_lib.c.

#define ISDN_PID_L4_B_USER   0x440000ff

Definition at line 224 of file isdn_lib.c.

#define MAXPROCS   0x100

Definition at line 795 of file isdn_lib.c.

Referenced by create_process().

#define MISDN_DEBUG   0

Definition at line 208 of file isdn_lib.c.

#define MISDN_DSP

#define MISDN_GEN_SILENCE

#define MISDN_IBUF_SIZE   512

Definition at line 227 of file isdn_lib.c.

Referenced by init_bc().

#define RETURN ( a,
 )     {retval=a; goto b;}

Definition at line 3380 of file isdn_lib.c.

Referenced by misdn_lib_send_event().

#define TONE_ALERT_CNT   41

Definition at line 230 of file isdn_lib.c.

#define TONE_ALERT_SILENCE_CNT   200

Definition at line 231 of file isdn_lib.c.

#define TONE_BUSY_CNT   20

Definition at line 233 of file isdn_lib.c.

#define TONE_BUSY_SILENCE_CNT   48

Definition at line 234 of file isdn_lib.c.


Enumeration Type Documentation

enum global_states

Enumerator:
MISDN_INITIALIZING 
MISDN_INITIALIZED 

Definition at line 167 of file isdn_lib.c.

00167                    {
00168    MISDN_INITIALIZING,
00169    MISDN_INITIALIZED
00170 } ;


Function Documentation

static void bc_next_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
) [static]

Definition at line 622 of file isdn_lib.c.

References bc_state2str(), cb_log, misdn_bchannel::next_bc_state, and misdn_bchannel::port.

Referenced by misdn_lib_bridge().

00623 {
00624    cb_log(5,bc->port,"BC_NEXT_STATE_CHANGE: from:%s to:%s\n",
00625           bc_state2str(bc->next_bc_state),
00626           bc_state2str(state) );
00627 
00628    bc->next_bc_state=state;
00629 }

char* bc_state2str ( enum bchannel_state  state  ) 

Definition at line 573 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().

00573                                               {
00574    int i;
00575    
00576    struct bchan_state_s {
00577       char *n;
00578       enum bchannel_state s;
00579    } states[] = {
00580       {"BCHAN_CLEANED", BCHAN_CLEANED },
00581       {"BCHAN_EMPTY", BCHAN_EMPTY},
00582       {"BCHAN_SETUP", BCHAN_SETUP},
00583       {"BCHAN_SETUPED", BCHAN_SETUPED},
00584       {"BCHAN_ACTIVE", BCHAN_ACTIVE},
00585       {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
00586       {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
00587       {"BCHAN_BRIDGED", BCHAN_BRIDGED},
00588       {"BCHAN_RELEASE", BCHAN_RELEASE},
00589       {"BCHAN_RELEASED", BCHAN_RELEASED},
00590       {"BCHAN_CLEAN", BCHAN_CLEAN},
00591       {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
00592       {"BCHAN_ERROR", BCHAN_ERROR}
00593    };
00594    
00595    for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
00596       if ( states[i].s == state)
00597          return states[i].n;
00598 
00599    return "UNKNOWN";
00600 }

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

Definition at line 602 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().

00603 {
00604    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00605       bc->l3_id,
00606           bc_state2str(bc->bc_state),
00607           bc_state2str(state) );
00608    
00609    switch (state) {
00610       case BCHAN_ACTIVATED:
00611          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00612             misdn_join_conf(bc, bc->conf_id);
00613             bc->next_bc_state = BCHAN_EMPTY;
00614             return;
00615          }
00616       default:
00617          bc->bc_state=state;
00618          break;
00619    }
00620 }

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 268 of file isdn_lib.c.

References INFO_CAPABILITY_AUDIO_3_1K, INFO_CAPABILITY_DIGITAL_RESTRICTED, INFO_CAPABILITY_DIGITAL_UNRESTRICTED, and INFO_CAPABILITY_SPEECH.

00268                                  {
00269    static char *bearers[]={
00270       "Speech",
00271       "Audio 3.1k",
00272       "Unres Digital",
00273       "Res Digital",
00274       "Unknown Bearer"
00275    };
00276    
00277    switch (cap) {
00278    case INFO_CAPABILITY_SPEECH:
00279       return bearers[0];
00280       break;
00281    case INFO_CAPABILITY_AUDIO_3_1K:
00282       return bearers[1];
00283       break;
00284    case INFO_CAPABILITY_DIGITAL_UNRESTRICTED:
00285       return bearers[2];
00286       break;
00287    case INFO_CAPABILITY_DIGITAL_RESTRICTED:
00288       return bearers[3];
00289       break;
00290    default:
00291       return bearers[4];
00292       break;
00293    }
00294 }

static int clean_up_bc ( struct misdn_bchannel bc  )  [static]

Definition at line 739 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().

00740 {
00741    int ret=0;
00742    unsigned char buff[32];
00743    struct misdn_stack * stack;
00744 
00745    cb_log(3, bc?bc->port:0, "$$$ CLEANUP CALLED pid:%d\n", bc?bc->pid:-1);
00746    
00747    if (!bc  ) return -1;
00748    stack=get_stack_by_bc(bc);
00749    
00750    if (!stack) return -1;
00751    
00752    switch (bc->bc_state ) {
00753    case BCHAN_CLEANED:
00754       cb_log(5, stack->port, "$$$ Already cleaned up bc with stid :%x\n", bc->b_stid);
00755       return -1;
00756       
00757    default:
00758       break;
00759    }
00760    
00761    cb_log(2, stack->port, "$$$ Cleaning up bc with stid :%x pid:%d\n", bc->b_stid, bc->pid);
00762    
00763    manager_ec_disable(bc);
00764 
00765    manager_bchannel_deactivate(bc);
00766 
00767    mISDN_write_frame(stack->midev, buff, bc->layer_id|FLG_MSG_TARGET|FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
00768    
00769    bc->b_stid = 0;
00770    bc_state_change(bc, BCHAN_CLEANED);
00771    
00772    return ret;
00773 }

static void clear_l3 ( struct misdn_stack stack  )  [static]

Definition at line 777 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().

00778 {
00779    int i;
00780 
00781    for (i=0; i<=stack->b_num; i++) {
00782       if (global_state == MISDN_INITIALIZED)  {
00783          cb_event(EVENT_CLEANUP, &stack->bc[i], NULL); 
00784          empty_bc(&stack->bc[i]);
00785          clean_up_bc(&stack->bc[i]);
00786          empty_chan_in_stack(stack, i + 1);
00787          stack->bc[i].in_use = 0;
00788       }
00789       
00790    } 
00791 }

static msg_t* create_l2msg ( int  prim,
int  dinfo,
int  size 
) [static]

Definition at line 327 of file isdn_lib.c.

Referenced by misdn_lib_get_l2_down(), and misdn_lib_get_l2_up().

00328 {
00329    int i = 0;
00330    msg_t *dmsg;
00331   
00332    while(i < 10)
00333    {
00334       dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
00335       if (dmsg)
00336          return(dmsg);
00337       
00338       if (!i)
00339          printf("cannot allocate memory, trying again...\n");
00340       i++;
00341       usleep(300000);
00342    }
00343    printf("cannot allocate memory, system overloaded.\n");
00344    exit(-1);
00345 }

msg_t* create_l3msg ( int  prim,
int  mt,
int  dinfo,
int  size,
int  ntmode 
)

Definition at line 349 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().

00350 {
00351    int i = 0;
00352    msg_t *dmsg;
00353    Q931_info_t *qi;
00354    iframe_t *frm;
00355   
00356    if (!ntmode)
00357       size = sizeof(Q931_info_t)+2;
00358   
00359    while(i < 10) {
00360       if (ntmode) {
00361          dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
00362          if (dmsg) {
00363             return(dmsg);
00364          }
00365       } else {
00366          dmsg = alloc_msg(size+256+mISDN_HEADER_LEN+DEFAULT_HEADROOM);
00367          if (dmsg)
00368          {
00369             memset(msg_put(dmsg,size+mISDN_HEADER_LEN), 0, size+mISDN_HEADER_LEN);
00370             frm = (iframe_t *)dmsg->data;
00371             frm->prim = prim;
00372             frm->dinfo = dinfo;
00373             qi = (Q931_info_t *)(dmsg->data + mISDN_HEADER_LEN);
00374             qi->type = mt;
00375             return(dmsg);
00376          }
00377       }
00378     
00379       if (!i) printf("cannot allocate memory, trying again...\n");
00380       i++;
00381       usleep(300000);
00382    }
00383    printf("cannot allocate memory, system overloaded.\n");
00384    exit(-1);
00385 }

static int create_process ( int  midev,
struct misdn_bchannel bc 
) [static]

Definition at line 911 of file isdn_lib.c.

References misdn_stack::bc, cb_log, misdn_bchannel::channel, misdn_bchannel::channel_preselected, find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::l3_id, MAXPROCS, misdn_stack::nt, misdn_stack::port, and misdn_stack::procids.

Referenced by misdn_lib_send_event().

00912 {
00913    iframe_t ncr;
00914    int l3_id;
00915    int proc_id;
00916    struct misdn_stack *stack;
00917 
00918    stack = get_stack_by_bc(bc);
00919    if (stack->nt) {
00920       if (find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0, 0) < 0) {
00921          return -1;
00922       }
00923       cb_log(4, stack->port, " -->  found channel: %d\n", bc->channel);
00924 
00925       for (proc_id = 0; proc_id < MAXPROCS; ++proc_id) {
00926          if (stack->procids[proc_id] == 0) {
00927             break;
00928          }
00929       }  /* end for */
00930       if (proc_id == MAXPROCS) {
00931          cb_log(0, stack->port, "Couldn't Create New ProcId.\n");
00932          return -1;
00933       }
00934 
00935       stack->procids[proc_id] = 1;
00936 
00937       l3_id = 0xff00 | proc_id;
00938       bc->l3_id = l3_id;
00939       cb_log(3, stack->port, " --> new_l3id %x\n", l3_id);
00940    } else {
00941       if ((stack->pri && stack->ptp) || bc->te_choose_channel) {
00942          /* we know exactly which channels are in use */
00943          if (find_free_chan_in_stack(stack, bc, bc->channel_preselected ? bc->channel : 0, bc->dec) < 0) {
00944             return -1;
00945          }
00946          cb_log(2, stack->port, " -->  found channel: %d\n", bc->channel);
00947       } else {
00948          /* other phones could have made a call also on this port (ptmp) */
00949          bc->channel = 0xff;
00950       }
00951 
00952       /* if we are in te-mode, we need to create a process first */
00953       if (++new_te_id > 0xffff) {
00954          new_te_id = 0x0001;
00955       }
00956 
00957       l3_id = (entity << 16) | new_te_id;
00958       bc->l3_id = l3_id;
00959       cb_log(3, stack->port, "--> new_l3id %x\n", l3_id);
00960 
00961       /* send message */
00962       ncr.prim = CC_NEW_CR | REQUEST;
00963       ncr.addr = (stack->upper_id | FLG_MSG_DOWN);
00964       ncr.dinfo = l3_id;
00965       ncr.len = 0;
00966       mISDN_write(midev, &ncr, mISDN_HEADER_LEN + ncr.len, TIMEOUT_1SEC);
00967    }
00968 
00969    return l3_id;
00970 }

static int do_tone ( struct misdn_bchannel bc,
int  len 
) [static]

Definition at line 2258 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().

02259 {
02260    bc->tone_cnt=len;
02261    
02262    if (bc->generate_tone) {
02263       cb_event(EVENT_TONE_GENERATE, bc, glob_mgr->user_data);
02264       
02265       if ( !bc->nojitter ) {
02266          misdn_tx_jitter(bc,len);
02267       }
02268       
02269       return 1;
02270    }
02271    
02272    return 0;
02273 }

static void dump_chan_list ( struct misdn_stack stack  )  [static]

Definition at line 442 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().

00443 {
00444    int i;
00445 
00446    for (i=0; i <= stack->b_num; i++) {
00447       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);
00448    }
00449 }

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 642 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().

00643 {
00644    bc->dummy=0;
00645 
00646    bc->bframe_len=0;
00647 
00648    bc->cw= 0;
00649 
00650    bc->dec=0;
00651    bc->channel = 0;
00652 
00653    bc->sending_complete = 0;
00654 
00655    bc->restart_channel=0;
00656    
00657    bc->conf_id = 0;
00658 
00659    bc->need_more_infos = 0;
00660    
00661    bc->send_dtmf=0;
00662    bc->nodsp=0;
00663    bc->nojitter=0;
00664 
00665    bc->time_usec=0;
00666    
00667    bc->rxgain=0;
00668    bc->txgain=0;
00669 
00670    bc->crypt=0;
00671    bc->curptx=0; bc->curprx=0;
00672    
00673    bc->crypt_key[0] = 0;
00674    
00675    bc->generate_tone=0;
00676    bc->tone_cnt=0;
00677   
00678    bc->dnumplan=NUMPLAN_UNKNOWN;
00679    bc->onumplan=NUMPLAN_UNKNOWN;
00680    bc->rnumplan=NUMPLAN_UNKNOWN;
00681    bc->cpnnumplan=NUMPLAN_UNKNOWN;
00682    
00683 
00684    bc->active = 0;
00685 
00686    bc->early_bconnect = 1;
00687    
00688 #ifdef MISDN_1_2
00689    *bc->pipeline = 0;
00690 #else
00691    bc->ec_enable = 0;
00692    bc->ec_deftaps = 128;
00693 #endif
00694 
00695    bc->orig=0;
00696   
00697    bc->cause = AST_CAUSE_NORMAL_CLEARING;
00698    bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
00699    bc->pres = 0;  /* allowed */
00700    
00701    bc->evq=EVENT_NOTHING;
00702 
00703    bc->progress_coding=0;
00704    bc->progress_location=0;
00705    bc->progress_indicator=0;
00706    
00707 /** Set Default Bearer Caps **/
00708    bc->capability=INFO_CAPABILITY_SPEECH;
00709    bc->law=INFO_CODEC_ALAW;
00710    bc->mode=0;
00711    bc->rate=0x10;
00712    bc->user1=0;
00713    bc->urate=0;
00714    
00715    bc->hdlc=0;
00716    
00717    
00718    bc->info_dad[0] = 0;
00719    bc->display[0] = 0;
00720    bc->infos_pending[0] = 0;
00721    bc->cad[0] = 0;
00722    bc->oad[0] = 0;
00723    bc->dad[0] = 0;
00724    bc->rad[0] = 0;
00725    bc->orig_dad[0] = 0;
00726    bc->uu[0]=0;
00727    bc->uulen=0;
00728    
00729    bc->fac_in.Function = Fac_None;
00730    bc->fac_out.Function = Fac_None;
00731    
00732    bc->te_choose_channel = 0;
00733    bc->channel_found= 0;
00734 
00735    gettimeofday(&bc->last_used, NULL);
00736 }

static int empty_chan_in_stack ( struct misdn_stack stack,
int  channel 
) [static]

Definition at line 560 of file isdn_lib.c.

References cb_log, misdn_stack::channels, dump_chan_list(), MAX_BCHANS, and misdn_stack::port.

Referenced by clear_l3(), handle_cr(), handle_event_nt(), handle_frm(), manager_clean_bc(), misdn_lib_release(), and misdn_lib_send_event().

00561 {
00562    if (channel<=0 || channel>MAX_BCHANS) {
00563       cb_log(0,stack?stack->port:0, "empty_chan_in_stack: cannot empty channel %d\n",channel);
00564       return -1;
00565    }
00566    
00567    cb_log (4, stack?stack->port:0, "empty_chan_in_stack: %d\n",channel); 
00568    stack->channels[channel-1] = 0;
00569    dump_chan_list(stack);
00570    return 0;
00571 }

static const char* fac2str ( enum FacFunction  facility  )  [static]

Definition at line 3312 of file isdn_lib.c.

References ARRAY_LEN, and name.

Referenced by misdn_lib_log_ies().

03313 {
03314    static const struct { 
03315       enum FacFunction facility; 
03316       char *name;
03317    } arr[] = {
03318 /* *INDENT-OFF* */
03319       { Fac_None, "Fac_None" },
03320       { Fac_GetSupportedServices, "Fac_GetSupportedServices" },
03321       { Fac_Listen, "Fac_Listen" },
03322       { Fac_Suspend, "Fac_Suspend" },
03323       { Fac_Resume, "Fac_Resume" },
03324       { Fac_CFActivate, "Fac_CFActivate" },
03325       { Fac_CFDeactivate, "Fac_CFDeactivate" },
03326       { Fac_CFInterrogateParameters, "Fac_CFInterrogateParameters" },
03327       { Fac_CFInterrogateNumbers, "Fac_CFInterrogateNumbers" },
03328       { Fac_CD, "Fac_CD" },
03329       { Fac_AOCDCurrency, "Fac_AOCDCurrency" },
03330       { Fac_AOCDChargingUnit, "Fac_AOCDChargingUnit" },
03331 /* *INDENT-ON* */
03332    };
03333    
03334    unsigned index;
03335    
03336    for (index = 0; index < ARRAY_LEN(arr); ++index) {
03337       if (arr[index].facility == facility) {
03338          return arr[index].name;
03339       }
03340    }  /* end for */
03341 
03342    return "unknown";
03343 }  /* end fac2str() */

static msg_t* fetch_msg ( int  midev  )  [static]

Definition at line 3020 of file isdn_lib.c.

References cb_log, and errno.

Referenced by misdn_lib_isdn_event_catcher().

03021 {
03022    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03023    int r;
03024 
03025    if (!msg) {
03026       cb_log(0, 0, "fetch_msg: alloc msg failed !!");
03027       return NULL;
03028    }
03029 
03030    AGAIN:
03031       r=mISDN_read(midev,msg->data,MAX_MSG_SIZE, TIMEOUT_10SEC);
03032       msg->len=r;
03033     
03034       if (r==0) {
03035          free_msg(msg); /* danger, cause usually freeing in main_loop */
03036          cb_log(6,0,"Got empty Msg..\n");
03037          return NULL;
03038       }
03039 
03040       if (r<0) {
03041          if (errno == EAGAIN) {
03042             /*we wait for mISDN here*/
03043             cb_log(4,0,"mISDN_read wants us to wait\n");
03044             usleep(5000);
03045             goto AGAIN;
03046          }
03047          
03048          cb_log(0,0,"mISDN_read returned :%d error:%s (%d)\n",r,strerror(errno),errno); 
03049       }
03050 
03051 #if 0
03052                if  (!(frm->prim == (DL_DATA|INDICATION) )|| (frm->prim == (PH_DATA|INDICATION)))
03053                        cb_log(0,0,"prim: %x dinfo:%x addr:%x msglen:%d frm->len:%d\n",frm->prim, frm->dinfo, frm->addr, msg->len,frm->len );
03054 #endif
03055       return msg;
03056 }

static struct misdn_bchannel* find_bc_by_addr ( unsigned long  addr  )  [static]

Definition at line 1494 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::b_num, misdn_stack::bc, glob_mgr, misdn_bchannel::in_use, misdn_bchannel::layer_id, misdn_stack::next, and misdn_lib::stack_list.

Referenced by handle_bchan().

01495 {
01496    struct misdn_stack *stack;
01497    int i;
01498 
01499    for (stack = glob_mgr->stack_list; stack; stack = stack->next) {
01500       for (i = 0; i <= stack->b_num; i++) {
01501          if (stack->bc[i].in_use
01502             && ((stack->bc[i].addr & STACK_ID_MASK) == (addr & STACK_ID_MASK)
01503                || stack->bc[i].layer_id == addr)) {
01504             return &stack->bc[i];
01505          }
01506       }
01507    }
01508    
01509    return NULL;
01510 }

static struct misdn_bchannel* find_bc_by_channel ( int  port,
int  channel 
) [static]

Definition at line 1528 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, misdn_bchannel::channel, find_stack_by_port(), and misdn_bchannel::in_use.

Referenced by handle_err().

01529 {
01530    struct misdn_stack *stack = find_stack_by_port(port);
01531    int i;
01532 
01533    if (!stack) {
01534       return NULL;
01535    }
01536    
01537    for (i = 0; i <= stack->b_num; i++) {
01538       if (stack->bc[i].in_use && stack->bc[i].channel == channel) {
01539          return &stack->bc[i];
01540       }
01541    }
01542       
01543    return NULL;
01544 }

static struct misdn_bchannel* find_bc_by_confid ( unsigned long  confid  )  [static]

Definition at line 1512 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, misdn_bchannel::conf_id, glob_mgr, misdn_bchannel::in_use, misdn_stack::next, and misdn_lib::stack_list.

Referenced by misdn_lib_send_event().

01513 {
01514    struct misdn_stack *stack;
01515    int i;
01516    
01517    for (stack = glob_mgr->stack_list; stack; stack = stack->next) {
01518       for (i = 0; i <= stack->b_num; i++) {
01519          if (stack->bc[i].in_use && stack->bc[i].conf_id == confid) {
01520             return &stack->bc[i];
01521          }
01522       }
01523    }
01524    return NULL;
01525 }

struct misdn_bchannel * find_bc_by_l3id ( struct misdn_stack stack,
unsigned long  l3id 
)

Definition at line 1482 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, misdn_bchannel::in_use, and misdn_bchannel::l3_id.

Referenced by handle_cr(), handle_event_nt(), handle_frm(), manager_event_handler(), and release_cr().

01483 {
01484    int i;
01485 
01486    for (i = 0; i <= stack->b_num; i++) {
01487       if (stack->bc[i].in_use && stack->bc[i].l3_id == l3id) {
01488          return &stack->bc[i];
01489       }
01490    }
01491    return stack_holder_find(stack,l3id);
01492 }

static struct misdn_bchannel* find_bc_by_masked_l3id ( struct misdn_stack stack,
unsigned long  l3id,
unsigned long  mask 
) [static]

Definition at line 1469 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, misdn_bchannel::in_use, and misdn_bchannel::l3_id.

Referenced by handle_event_nt().

01470 {
01471    int i;
01472 
01473    for (i = 0; i <= stack->b_num; i++) {
01474       if (stack->bc[i].in_use && (stack->bc[i].l3_id & mask) == (l3id & mask)) {
01475          return &stack->bc[i];
01476       }
01477    }
01478    return stack_holder_find(stack,l3id);
01479 }

static int find_free_chan_in_stack ( struct misdn_stack stack,
struct misdn_bchannel bc,
int  channel,
int  dec 
) [static]

Definition at line 483 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_bchannel::channel_found, misdn_stack::channels, MAX_BCHANS, misdn_stack::port, misdn_stack::pri, pthread_mutex_lock, and misdn_stack::st_lock.

Referenced by create_process(), handle_event(), handle_event_nt(), and misdn_lib_send_event().

00484 {
00485    int i;
00486    int chan=0;
00487    int bnums = stack->pri ? stack->b_num : stack->b_num - 1;
00488 
00489    if (bc->channel_found)  
00490       return 0;
00491    
00492    bc->channel_found=1;
00493 
00494    cb_log(5,stack->port,"find_free_chan: req_chan:%d\n",channel);
00495 
00496    if (channel < 0 || channel > MAX_BCHANS) {
00497       cb_log(0, stack->port, " !! out of bound call to find_free_chan_in_stack! (ch:%d)\n", channel);
00498       return 0;
00499    }
00500    
00501    channel--;
00502 
00503    pthread_mutex_lock(&stack->st_lock);
00504    if (dec) {
00505       for (i = bnums; i >=0; i--) {
00506          if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 D channel ;) and work with chan preselection */
00507             if (!stack->channels[i]) {
00508                cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
00509                chan=i+1;
00510                break;
00511             }
00512          }
00513       }
00514    } else {
00515       for (i = 0; i <= bnums; i++) {
00516          if (i != 15 && (channel < 0 || i == channel)) { /* skip E1 D channel ;) and work with chan preselection */
00517             if (!stack->channels[i]) {
00518                cb_log (3, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
00519                chan=i+1;
00520                break;
00521             }
00522          }
00523       }
00524    }
00525 
00526    if (!chan) {
00527       pthread_mutex_unlock(&stack->st_lock);
00528       cb_log (1, stack->port, " !! NO FREE CHAN IN STACK\n");
00529       dump_chan_list(stack);
00530       bc->out_cause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION;
00531       return -1;
00532    }  
00533 
00534    if (set_chan_in_stack(stack, chan)<0) {
00535       pthread_mutex_unlock(&stack->st_lock);
00536       cb_log (0, stack->port, "Channel Already in use:%d\n", chan);
00537       bc->out_cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
00538       return -1;
00539    }
00540    pthread_mutex_unlock(&stack->st_lock);
00541 
00542    bc->channel=chan;
00543    return 0;
00544 }

static struct misdn_stack* find_stack_by_addr ( int  addr  )  [static]

Definition at line 1430 of file isdn_lib.c.

References glob_mgr, misdn_stack::next, misdn_lib::stack_list, and misdn_stack::upper_id.

Referenced by handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), and handle_mgmt().

01431 {
01432    struct misdn_stack *stack;
01433    
01434    for (stack=glob_mgr->stack_list;
01435         stack;
01436         stack=stack->next) {
01437       if ( (stack->upper_id&STACK_ID_MASK) == (addr&STACK_ID_MASK)) return stack;
01438 
01439    }
01440   
01441    return NULL;
01442 }

static struct misdn_stack* find_stack_by_mgr ( manager_t *  mgr_nt  )  [static]

Definition at line 1457 of file isdn_lib.c.

References glob_mgr, misdn_stack::mgr, misdn_stack::next, and misdn_lib::stack_list.

Referenced by handle_event_nt().

01458 {
01459    struct misdn_stack *stack;
01460   
01461    for (stack=glob_mgr->stack_list;
01462         stack;
01463         stack=stack->next) 
01464       if ( &stack->mgr == mgr_nt) return stack;
01465   
01466    return NULL;
01467 }

static struct misdn_stack* find_stack_by_port ( int  port  )  [static]

Definition at line 1445 of file isdn_lib.c.

References glob_mgr, misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.

Referenced by find_bc_by_channel(), handle_err(), manager_event_handler(), misdn_lib_get_port_info(), misdn_lib_port_restart(), misdn_lib_reinit_nt_stack(), and misdn_lib_send_restart().

01446 {
01447    struct misdn_stack *stack;
01448   
01449    for (stack=glob_mgr->stack_list;
01450         stack;
01451         stack=stack->next) 
01452       if (stack->port == port) return stack;
01453   
01454    return NULL;
01455 }

static char* flip_buf_bits ( char *  buf,
int  len 
) [static]

Definition at line 312 of file isdn_lib.c.

References flip_table.

Referenced by handle_bchan(), misdn_lib_init(), misdn_lib_tx2misdn_frm(), and misdn_tx_jitter().

00313 {
00314    int i;
00315    char * start = buf;
00316    
00317    for (i = 0 ; i < len; i++) {
00318       buf[i] = flip_table[(unsigned char)buf[i]];
00319    }
00320    
00321    return start;
00322 }

struct misdn_stack * get_misdn_stack ( void   ) 

Definition at line 4596 of file isdn_lib.c.

References glob_mgr, and misdn_lib::stack_list.

Referenced by get_show_stack_details(), get_stack_by_bc(), misdn_dump_chanlist(), misdn_lib_find_held_bc(), misdn_lib_get_maxchans(), misdn_lib_is_port_blocked(), misdn_lib_is_ptp(), misdn_lib_nt_keepcalls(), misdn_lib_port_block(), misdn_lib_port_is_pri(), and misdn_lib_port_unblock().

04596                                       {
04597    return glob_mgr->stack_list;
04598 }

void get_show_stack_details ( int  port,
char *  buf 
)

Definition at line 146 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().

00147 {
00148    struct misdn_stack *stack=get_misdn_stack();
00149    
00150    for ( ; stack; stack=stack->next) {
00151       if (stack->port == port) break;
00152    }
00153    
00154    if (stack) {
00155       sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
00156          stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP",
00157          stack->l2link ? "UP" : "DOWN", stack->l1link ? "UP" : "DOWN",
00158          stack->blocked);
00159    } else {
00160       buf[0]=0;
00161    }
00162 }

struct misdn_stack* get_stack_by_bc ( struct misdn_bchannel bc  ) 

Definition at line 130 of file isdn_lib.c.

References misdn_stack::bc, get_misdn_stack(), misdn_stack::next, misdn_bchannel::port, and misdn_stack::port.

Referenced by clean_up_bc(), create_process(), dec_ie_channel_id(), enc_ie_channel_id(), handle_bchan(), handle_event(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_clean_bc(), manager_ec_disable(), manager_ec_enable(), misdn_lib_log_ies(), misdn_lib_release(), misdn_lib_send_event(), misdn_lib_tx2misdn_frm(), parse_release_complete(), parse_restart(), send_msg(), and setup_bc().

00131 {
00132    struct misdn_stack *stack = get_misdn_stack();
00133 
00134    if (!bc)
00135       return NULL;
00136    
00137    for ( ; stack; stack = stack->next) {
00138       if (bc->port == stack->port)
00139          return stack;
00140    }
00141 
00142    return NULL;
00143 }

static int handle_bchan ( msg_t *  msg  )  [static]

Definition at line 2367 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::b_stid, misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_ACTIVATED, BCHAN_CLEAN_REQUEST, BCHAN_SETUP, BCHAN_SETUPED, misdn_bchannel::bframe, misdn_bchannel::bframe_len, misdn_bchannel::capability, cb_event, cb_log, misdn_bchannel::channel, clean_up_bc(), misdn_bchannel::dad, misdn_bchannel::dnumplan, do_tone(), misdn_bchannel::dtmf, errno, EVENT_BCHAN_DATA, EVENT_DTMF_TONE, find_bc_by_addr(), flip_buf_bits(), get_stack_by_bc(), glob_mgr, misdn_bchannel::layer, misdn_stack::midev, misdn_cap_is_speech(), misdn_tx_jitter(), misdn_bchannel::nojitter, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, t, and misdn_lib::user_data.

Referenced by handle_err(), and manager_isdn_handler().

02368 {
02369    iframe_t *frm= (iframe_t*)msg->data;
02370    struct misdn_bchannel *bc=find_bc_by_addr(frm->addr);
02371    struct misdn_stack *stack;
02372    
02373    if (!bc) {
02374       cb_log(1,0,"handle_bchan: BC not found for prim:%x with addr:%x dinfo:%x\n", frm->prim, frm->addr, frm->dinfo);
02375       return 0 ;
02376    }
02377    
02378    stack = get_stack_by_bc(bc);
02379    
02380    if (!stack) {
02381       cb_log(0, bc->port,"handle_bchan: STACK not found for prim:%x with addr:%x dinfo:%x\n", frm->prim, frm->addr, frm->dinfo);
02382       return 0;
02383    }
02384    
02385    switch (frm->prim) {
02386 
02387    case MGR_SETSTACK| CONFIRM:
02388       cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|CONFIRM pid:%d\n",bc->pid);
02389       break;
02390       
02391    case MGR_SETSTACK| INDICATION:
02392       cb_log(3, stack->port, "BCHAN: MGR_SETSTACK|IND pid:%d\n",bc->pid);
02393    break;
02394 #if 0
02395    AGAIN:
02396       bc->addr = mISDN_get_layerid(stack->midev, bc->b_stid, bc->layer);
02397       if (!bc->addr) {
02398 
02399          if (errno == EAGAIN) {
02400             usleep(1000);
02401             goto AGAIN;
02402          }
02403          
02404          cb_log(0,stack->port,"$$$ Get Layer (%d) Id Error: %s\n",bc->layer,strerror(errno));
02405          
02406          /* we kill the channel later, when we received some
02407             data. */
02408          bc->addr= frm->addr;
02409       } else if ( bc->addr < 0) {
02410          cb_log(0, stack->port,"$$$ bc->addr <0 Error:%s\n",strerror(errno));
02411          bc->addr=0;
02412       }
02413       
02414       cb_log(4, stack->port," --> Got Adr %x\n", bc->addr);
02415 
02416       free_msg(msg);
02417    
02418       
02419       switch(bc->bc_state) {
02420       case BCHAN_SETUP:
02421          bc_state_change(bc,BCHAN_SETUPED);
02422       break;
02423 
02424       case BCHAN_CLEAN_REQUEST:
02425       default:
02426          cb_log(0, stack->port," --> STATE WASN'T SETUP (but %s) in SETSTACK|IND pid:%d\n",bc_state2str(bc->bc_state), bc->pid);
02427          clean_up_bc(bc);
02428       }
02429       return 1;
02430 #endif
02431 
02432    case MGR_DELLAYER| INDICATION:
02433       cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|IND pid:%d\n",bc->pid);
02434       break;
02435       
02436    case MGR_DELLAYER| CONFIRM:
02437       cb_log(3, stack->port, "BCHAN: MGR_DELLAYER|CNF pid:%d\n",bc->pid);
02438       
02439       bc->pid=0;
02440       bc->addr=0;
02441       
02442       free_msg(msg);
02443       return 1;
02444       
02445    case PH_ACTIVATE | INDICATION:
02446    case DL_ESTABLISH | INDICATION:
02447       cb_log(3, stack->port, "BCHAN: ACT Ind pid:%d\n", bc->pid);
02448 
02449       free_msg(msg);
02450       return 1;    
02451 
02452    case PH_ACTIVATE | CONFIRM:
02453    case DL_ESTABLISH | CONFIRM:
02454       
02455       cb_log(3, stack->port, "BCHAN: bchan ACT Confirm pid:%d\n",bc->pid);
02456       free_msg(msg);
02457       
02458       return 1;    
02459 
02460    case DL_ESTABLISH | REQUEST:
02461       {
02462          char buf[128];
02463          mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_TARGET | FLG_MSG_DOWN,  DL_ESTABLISH | CONFIRM, 0,0, NULL, TIMEOUT_1SEC);
02464       }
02465       free_msg(msg);
02466       return 1;
02467 
02468    case DL_RELEASE|REQUEST:
02469       {
02470          char buf[128];
02471          mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_TARGET | FLG_MSG_DOWN,  DL_RELEASE| CONFIRM, 0,0, NULL, TIMEOUT_1SEC);
02472       }
02473       free_msg(msg);
02474       return 1;
02475       
02476    case PH_DEACTIVATE | INDICATION:
02477    case DL_RELEASE | INDICATION:
02478       cb_log (3, stack->port, "BCHAN: DeACT Ind pid:%d\n",bc->pid);
02479       
02480       free_msg(msg);
02481       return 1;
02482     
02483    case PH_DEACTIVATE | CONFIRM:
02484    case DL_RELEASE | CONFIRM:
02485       cb_log(3, stack->port, "BCHAN: DeACT Conf pid:%d\n",bc->pid);
02486       
02487       free_msg(msg);
02488       return 1;
02489     
02490    case PH_CONTROL|INDICATION:
02491    {
02492       unsigned int *cont = (unsigned int *) &frm->data.p;
02493       
02494       cb_log(4, stack->port, "PH_CONTROL: channel:%d oad%d:%s dad%d:%s \n", bc->channel, bc->onumplan,bc->oad, bc->dnumplan,bc->dad);
02495 
02496       if ((*cont & ~DTMF_TONE_MASK) == DTMF_TONE_VAL) {
02497          int dtmf = *cont & DTMF_TONE_MASK;
02498          cb_log(4, stack->port, " --> DTMF TONE: %c\n",dtmf);
02499          bc->dtmf=dtmf;
02500          cb_event(EVENT_DTMF_TONE, bc, glob_mgr->user_data);
02501    
02502          free_msg(msg);
02503          return 1;
02504       }
02505       if (*cont == BF_REJECT) {
02506          cb_log(4, stack->port, " --> BF REJECT\n");
02507          free_msg(msg);
02508          return 1;
02509       }
02510       if (*cont == BF_ACCEPT) {
02511          cb_log(4, stack->port, " --> BF ACCEPT\n");
02512          free_msg(msg);
02513          return 1;
02514       }
02515    }
02516    break;
02517 
02518    case PH_DATA|REQUEST:
02519    case DL_DATA|REQUEST:
02520       cb_log(0, stack->port, "DL_DATA REQUEST \n");
02521       do_tone(bc, 64);
02522       
02523       free_msg(msg);
02524       return 1;
02525    
02526    
02527    case PH_DATA|INDICATION:
02528    case DL_DATA|INDICATION:
02529    {
02530       bc->bframe = (void*)&frm->data.i;
02531       bc->bframe_len = frm->len;
02532 
02533       /** Anyway flip the bufbits **/
02534       if ( misdn_cap_is_speech(bc->capability) ) 
02535          flip_buf_bits(bc->bframe, bc->bframe_len);
02536    
02537 
02538       if (!bc->bframe_len) {
02539          cb_log(2, stack->port, "DL_DATA INDICATION bc->addr:%x frm->addr:%x\n", bc->addr, frm->addr);
02540          free_msg(msg);
02541          return 1;
02542       }
02543 
02544       if ( (bc->addr&STACK_ID_MASK) != (frm->addr&STACK_ID_MASK) ) {
02545          cb_log(2, stack->port, "DL_DATA INDICATION bc->addr:%x frm->addr:%x\n", bc->addr, frm->addr);
02546          free_msg(msg);
02547          return 1;
02548       }
02549       
02550 #if MISDN_DEBUG
02551       cb_log(0, stack->port, "DL_DATA INDICATION Len %d\n", frm->len);
02552 
02553 #endif
02554       
02555       if ( (bc->bc_state == BCHAN_ACTIVATED) && frm->len > 0) {
02556          int t;
02557 
02558 #ifdef MISDN_B_DEBUG
02559          cb_log(0,bc->port,"do_tone START\n");
02560 #endif
02561          t=do_tone(bc,frm->len);
02562 
02563 #ifdef MISDN_B_DEBUG
02564          cb_log(0,bc->port,"do_tone STOP (%d)\n",t);
02565 #endif
02566          if (  !t ) {
02567             int i;
02568             
02569             if ( misdn_cap_is_speech(bc->capability)) {
02570                if ( !bc->nojitter ) {
02571 #ifdef MISDN_B_DEBUG
02572                   cb_log(0,bc->port,"tx_jitter START\n");
02573 #endif
02574                   misdn_tx_jitter(bc,frm->len);
02575 #ifdef MISDN_B_DEBUG
02576                   cb_log(0,bc->port,"tx_jitter STOP\n");
02577 #endif
02578                }
02579             }
02580 
02581 #ifdef MISDN_B_DEBUG 
02582             cb_log(0,bc->port,"EVENT_B_DATA START\n");
02583 #endif
02584             
02585             i = cb_event(EVENT_BCHAN_DATA, bc, glob_mgr->user_data);
02586 #ifdef MISDN_B_DEBUG 
02587             cb_log(0,bc->port,"EVENT_B_DATA STOP\n");
02588 #endif
02589             
02590             if (i<0) {
02591                cb_log(10,stack->port,"cb_event returned <0\n");
02592                /*clean_up_bc(bc);*/
02593             }
02594          }
02595       }
02596       free_msg(msg);
02597       return 1;
02598    }
02599 
02600 
02601    case PH_CONTROL | CONFIRM:
02602       cb_log(4, stack->port, "PH_CONTROL|CNF bc->addr:%x\n", frm->addr);
02603       free_msg(msg);
02604       return 1;
02605 
02606    case PH_DATA | CONFIRM:
02607    case DL_DATA|CONFIRM:
02608 #if MISDN_DEBUG
02609 
02610       cb_log(0, stack->port, "Data confirmed\n");
02611 
02612 #endif
02613       free_msg(msg);
02614       return 1;
02615    case DL_DATA|RESPONSE:
02616 #if MISDN_DEBUG
02617       cb_log(0, stack->port, "Data response\n");
02618 
02619 #endif
02620       break;
02621    }
02622   
02623    return 0;
02624 }

static int handle_cr ( struct misdn_stack stack,
iframe_t *  frm 
) [static]

Definition at line 1635 of file isdn_lib.c.

References cb_event, cb_log, misdn_bchannel::channel, clean_up_bc(), dump_chan_list(), empty_bc(), empty_chan_in_stack(), EVENT_CLEANUP, find_bc_by_l3id(), free, glob_mgr, misdn_bchannel::in_use, misdn_bchannel::l3_id, misdn_lib_get_free_bc(), misdn_make_dummy(), misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_stack::nt, misdn_stack::port, misdn_bchannel::stack_holder, stack_holder_remove(), and misdn_lib::user_data.

Referenced by handle_event_nt(), handle_frm(), and release_cr().

01636 {
01637    struct misdn_bchannel *bc;
01638 
01639    if (!stack) return -1;
01640   
01641    switch (frm->prim) {
01642    case CC_NEW_CR|INDICATION:
01643       cb_log(7, stack->port, " --> lib: NEW_CR Ind with l3id:%x on this port.\n",frm->dinfo);
01644 
01645       bc = misdn_lib_get_free_bc(stack->port, 0, 1, 0);
01646       if (!bc) {
01647          cb_log(0, stack->port, " --> !! lib: No free channel!\n");
01648          return -1;
01649       }
01650   
01651       cb_log(7, stack->port, " --> new_process: New L3Id: %x\n",frm->dinfo);
01652       bc->l3_id=frm->dinfo;
01653       return 1;
01654    case CC_NEW_CR|CONFIRM:
01655       return 1;
01656    case CC_NEW_CR|REQUEST:
01657       return 1;
01658    case CC_RELEASE_CR|REQUEST:
01659       return 1;
01660    case CC_RELEASE_CR|CONFIRM:
01661       break;
01662    case CC_RELEASE_CR|INDICATION:
01663       cb_log(4, stack->port, " --> lib: RELEASE_CR Ind with l3id:%x\n",frm->dinfo);
01664       {
01665          struct misdn_bchannel *bc=find_bc_by_l3id(stack, frm->dinfo);
01666          struct misdn_bchannel dummybc;
01667       
01668          if (!bc) {
01669             cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
01670             misdn_make_dummy(&dummybc, stack->port, frm->dinfo, stack->nt, 0);
01671             
01672             bc=&dummybc; 
01673          }
01674       
01675          if (bc) {
01676             int channel = bc->channel;
01677             cb_log(4, stack->port, " --> lib: CLEANING UP l3id: %x\n",frm->dinfo);
01678 
01679             /*bc->pid = 0;*/
01680             bc->need_disconnect=0;
01681             bc->need_release=0;
01682             bc->need_release_complete=0;
01683 
01684             cb_event(EVENT_CLEANUP, bc, glob_mgr->user_data);
01685 
01686             empty_bc(bc);
01687             clean_up_bc(bc);
01688 
01689             if (channel>0)
01690                empty_chan_in_stack(stack,channel);
01691             bc->in_use=0;
01692 
01693             dump_chan_list(stack);
01694 
01695             if (bc->stack_holder) {
01696                cb_log(4,stack->port, "REMOVING Holder\n");
01697                stack_holder_remove( stack, bc);
01698                free(bc);
01699             }
01700          }
01701          else {
01702             if (stack->nt) 
01703                cb_log(4, stack->port, "BC with dinfo: %x  not found.. (prim was %x and addr %x)\n",frm->dinfo, frm->prim, frm->addr);
01704          }
01705       
01706          return 1;
01707       }
01708       break;
01709    }
01710   
01711    return 0;
01712 }

static int handle_err ( msg_t *  msg  )  [static]

Definition at line 3616 of file isdn_lib.c.

References misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), cb_log, misdn_bchannel::channel, find_bc_by_channel(), find_stack_by_port(), handle_bchan(), misdn_stack::l1link, misdn_stack::l2link, misdn_lib_get_l1_down(), misdn_lib_get_l2_down(), and misdn_bchannel::port.

Referenced by manager_isdn_handler().

03617 {
03618    iframe_t *frm = (iframe_t*) msg->data;
03619 
03620 
03621    if (!frm->addr) {
03622       static int cnt=0;
03623       if (!cnt)
03624          cb_log(0,0,"mISDN Msg without Address pr:%x dinfo:%x\n",frm->prim,frm->dinfo);
03625       cnt++;
03626       if (cnt>100) {
03627          cb_log(0,0,"mISDN Msg without Address pr:%x dinfo:%x (already more than 100 of them)\n",frm->prim,frm->dinfo);
03628          cnt=0;
03629       }
03630       
03631       free_msg(msg);
03632       return 1;
03633       
03634    }
03635    
03636    switch (frm->prim) {
03637       case MGR_SETSTACK|INDICATION:
03638          return handle_bchan(msg);
03639       break;
03640 
03641       case MGR_SETSTACK|CONFIRM:
03642       case MGR_CLEARSTACK|CONFIRM:
03643          free_msg(msg) ; 
03644          return 1;
03645       break;
03646 
03647       case DL_DATA|CONFIRM:
03648          cb_log(4,0,"DL_DATA|CONFIRM\n");
03649          free_msg(msg);
03650          return 1;
03651 
03652       case PH_CONTROL|CONFIRM:
03653          cb_log(4,0,"PH_CONTROL|CONFIRM\n");
03654          free_msg(msg);
03655          return 1;
03656 
03657       case DL_DATA|INDICATION:
03658       {
03659          int port=(frm->addr&MASTER_ID_MASK) >> 8;
03660          int channel=(frm->addr&CHILD_ID_MASK) >> 16;
03661          struct misdn_bchannel *bc;
03662 
03663          /*we flush the read buffer here*/
03664          
03665          cb_log(9,0,"BCHAN DATA without BC: addr:%x port:%d channel:%d\n",frm->addr, port,channel);
03666          
03667          free_msg(msg); 
03668          return 1;
03669          
03670          
03671          bc = find_bc_by_channel(port, channel);
03672 
03673          if (!bc) {
03674             struct misdn_stack *stack = find_stack_by_port(port);
03675 
03676             if (!stack) {
03677                cb_log(0,0," --> stack not found\n");
03678                free_msg(msg);
03679                return 1;
03680             }
03681             
03682             cb_log(0,0," --> bc not found by channel\n");
03683             if (stack->l2link)
03684                misdn_lib_get_l2_down(stack);
03685 
03686             if (stack->l1link)
03687                misdn_lib_get_l1_down(stack);
03688 
03689             free_msg(msg);
03690             return 1;
03691          }
03692          
03693          cb_log(3,port," --> BC in state:%s\n", bc_state2str(bc->bc_state));
03694       }
03695    }
03696 
03697    return 0;
03698 }

static int handle_event ( struct misdn_bchannel bc,
enum event_e  event,
iframe_t *  frm 
) [static]

Definition at line 1550 of file isdn_lib.c.

References misdn_stack::bc, cb_log, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, find_free_chan_in_stack(), get_stack_by_bc(), manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_cap_is_speech(), misdn_lib_send_event(), misdn_stack::nt, misdn_stack::port, misdn_stack::pri, misdn_stack::ptp, and setup_bc().

Referenced by handle_frm().

01551 {
01552    struct misdn_stack *stack=get_stack_by_bc(bc);
01553    
01554    if (!stack->nt) {
01555       
01556       switch (event) {
01557 
01558       case EVENT_CONNECT_ACKNOWLEDGE:
01559          setup_bc(bc);
01560 
01561          if ( *bc->crypt_key ) {
01562             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);
01563             manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
01564          }
01565 
01566          if (misdn_cap_is_speech(bc->capability)) {
01567             if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
01568             manager_ec_enable(bc);
01569 
01570             if ( bc->txgain != 0 ) {
01571                cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
01572                manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
01573             }
01574             if ( bc->rxgain != 0 ) {
01575                cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
01576                manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
01577             }
01578          }
01579 
01580          break;
01581       case EVENT_CONNECT:
01582 
01583          if ( *bc->crypt_key ) {
01584             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);
01585             manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
01586          }
01587       case EVENT_ALERTING:
01588       case EVENT_PROGRESS:
01589       case EVENT_PROCEEDING:
01590       case EVENT_SETUP_ACKNOWLEDGE:
01591       case EVENT_SETUP:
01592       {
01593          if (bc->channel == 0xff || bc->channel<=0)
01594             bc->channel=0;
01595 
01596          if (find_free_chan_in_stack(stack, bc, bc->channel, 0)<0){
01597             if (!stack->pri && !stack->ptp)  {
01598                bc->cw=1;
01599                break;
01600             }
01601 
01602             if (!bc->channel)
01603                cb_log(0, stack->port, "Any Channel Requested, but we have no more!!\n");
01604             else 
01605                cb_log(0, stack->port,
01606                   "Requested Channel Already in Use releasing this call with cause %d!!!!\n",
01607                   bc->out_cause);
01608 
01609             /* when the channel is already in use, we can't
01610              * simply clear it, we need to make sure that 
01611              * it will still be marked as in_use in the 
01612              * available channels list.*/
01613             bc->channel=0;
01614 
01615             misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
01616             return -1;
01617          }
01618       }
01619 
01620       setup_bc(bc);
01621       break;
01622 
01623       case EVENT_RELEASE_COMPLETE:
01624       case EVENT_RELEASE:
01625          break;
01626       default:
01627          break;
01628       }
01629    } else {    /** NT MODE **/
01630       
01631    }
01632    return 0;
01633 }

int handle_event_nt ( void *  dat,
void *  arg 
) [static]

Definition at line 1849 of file isdn_lib.c.

References AST_CAUSE_USER_BUSY, misdn_bchannel::b_stid, misdn_stack::bc, misdn_bchannel::cause, cb_event, cb_log, misdn_bchannel::channel, clean_up_bc(), create_l3msg(), empty_bc(), empty_chan_in_stack(), EVENT_NEW_L3ID, EVENT_PORT_ALARM, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_SETUP, find_bc_by_l3id(), find_bc_by_masked_l3id(), find_free_chan_in_stack(), find_stack_by_mgr(), free, glob_mgr, handle_cr(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_get_event(), isdn_msg_parse_event(), misdn_stack::l1link, misdn_stack::l2link, misdn_stack::l2upcnt, misdn_bchannel::l3_id, misdn_lib_get_free_bc(), misdn_lib_get_l2_up(), misdn_lib_reinit_nt_stack(), misdn_lib_send_event(), misdn_lib_send_restart(), misdn_make_dummy(), mISDNUSER_HEAD_SIZE, msgs_g, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, misdn_bchannel::port, misdn_stack::port, misdn_stack::procids, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, release_cr(), misdn_stack::restart_sent, stack_holder_find(), stack_holder_remove(), misdn_stack::upper_id, and misdn_lib::user_data.

Referenced by misdn_lib_reinit_nt_stack().

01850 {
01851    manager_t *mgr = (manager_t *)dat;
01852    msg_t *msg = (msg_t *)arg;
01853    mISDNuser_head_t *hh;
01854    struct misdn_stack *stack;
01855    int reject=0;
01856 
01857    if (!msg || !mgr)
01858       return(-EINVAL);
01859 
01860    stack = find_stack_by_mgr(mgr);
01861    hh=(mISDNuser_head_t*)msg->data;
01862 
01863    /*
01864     * When we are called from the mISDNuser lib, the nstlock is held and it
01865     * must be held when we return.  We unlock here because the lib may be
01866     * entered again recursively.
01867     */
01868    pthread_mutex_unlock(&stack->nstlock);
01869 
01870    cb_log(5, stack->port, " --> lib: prim %x dinfo %x\n",hh->prim, hh->dinfo);
01871    {
01872       switch(hh->prim){
01873       case CC_RETRIEVE|INDICATION:
01874       {
01875          struct misdn_bchannel *bc;
01876          struct misdn_bchannel *hold_bc;
01877 
01878          iframe_t frm; /* fake te frm to add callref to global callreflist */
01879          frm.dinfo = hh->dinfo;
01880 
01881          frm.addr=stack->upper_id | FLG_MSG_DOWN;
01882 
01883          frm.prim = CC_NEW_CR|INDICATION;
01884          
01885          if (handle_cr( stack, &frm)< 0) {
01886             msg_t *dmsg;
01887             cb_log(4, stack->port, "Patch from MEIDANIS:Sending RELEASE_COMPLETE %x (No free Chan for you..)\n", hh->dinfo);
01888             dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
01889             pthread_mutex_lock(&stack->nstlock);
01890             stack->nst.manager_l3(&stack->nst, dmsg);
01891             free_msg(msg);
01892             return 0;
01893          }
01894          
01895          bc = find_bc_by_l3id(stack, hh->dinfo);
01896          hold_bc = stack_holder_find(stack, bc->l3_id);
01897          cb_log(4, stack->port, "bc_l3id:%x holded_bc_l3id:%x\n",bc->l3_id, hold_bc->l3_id);
01898 
01899          if (hold_bc) {
01900             cb_log(4, stack->port, "REMOVING Holder\n");
01901 
01902             /*swap the backup to our new channel back*/
01903             stack_holder_remove(stack, hold_bc);
01904             memcpy(bc, hold_bc, sizeof(struct misdn_bchannel));
01905             free(hold_bc);
01906 
01907             bc->holded=0;
01908             bc->b_stid=0;
01909          }
01910          
01911       }
01912          
01913          break;
01914          
01915       case CC_SETUP|CONFIRM:
01916       {
01917          struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
01918          int l3id = *((int *)(((u_char *)msg->data)+ mISDNUSER_HEAD_SIZE));
01919          cb_log(4, stack->port, " --> lib: Event_ind:SETUP CONFIRM [NT] : new L3ID  is %x\n",l3id );
01920    
01921          if (bc) {
01922             cb_log (2, bc->port, "I IND :CC_SETUP|CONFIRM: old l3id:%x new l3id:%x\n", bc->l3_id, l3id);
01923             bc->l3_id = l3id;
01924             cb_event(EVENT_NEW_L3ID, bc, glob_mgr->user_data);
01925          } else {
01926             cb_log(4, stack->port, "Bc Not found (after SETUP CONFIRM)\n");
01927          }
01928       }
01929       free_msg(msg);
01930       pthread_mutex_lock(&stack->nstlock);
01931       return 0;
01932       
01933       case CC_SETUP|INDICATION:
01934       {
01935          struct misdn_bchannel* bc=misdn_lib_get_free_bc(stack->port, 0, 1, 0);
01936          if (!bc) {
01937             msg_t *dmsg;
01938             cb_log(4, stack->port, "Patch from MEIDANIS:Sending RELEASE_COMPLETE %x (No free Chan for you..)\n", hh->dinfo);
01939             dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
01940             pthread_mutex_lock(&stack->nstlock);
01941             stack->nst.manager_l3(&stack->nst, dmsg);
01942             free_msg(msg);
01943             return 0;
01944          }
01945   
01946          cb_log(4, stack->port, " --> new_process: New L3Id: %x\n",hh->dinfo);
01947          bc->l3_id=hh->dinfo;
01948       }
01949       break;
01950 
01951       case CC_CONNECT_ACKNOWLEDGE|INDICATION:
01952       break;
01953       
01954       case CC_ALERTING|INDICATION:
01955       case CC_PROCEEDING|INDICATION:
01956       case CC_SETUP_ACKNOWLEDGE|INDICATION:
01957          if(!stack->ptp) break;  
01958       case CC_CONNECT|INDICATION:
01959       break;
01960       case CC_DISCONNECT|INDICATION:
01961       {
01962          struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
01963          if (!bc) {
01964             bc=find_bc_by_masked_l3id(stack, hh->dinfo, 0xffff0000);
01965             if (bc) { 
01966                int myprocid=bc->l3_id&0x0000ffff;
01967                hh->dinfo=(hh->dinfo&0xffff0000)|myprocid;
01968                cb_log(3,stack->port,"Reject dinfo: %x cause:%d\n",hh->dinfo,bc->cause);
01969                reject=1;      
01970             }
01971          }
01972       }
01973       break;
01974       
01975       case CC_FACILITY|INDICATION:
01976       {
01977          struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
01978          if (!bc) {
01979             bc=find_bc_by_masked_l3id(stack, hh->dinfo, 0xffff0000);
01980             if (bc) { 
01981                int myprocid=bc->l3_id&0x0000ffff;
01982                hh->dinfo=(hh->dinfo&0xffff0000)|myprocid;
01983                cb_log(4,bc->port,"Repaired reject Bug, new dinfo: %x\n",hh->dinfo);
01984             }
01985          }
01986       }
01987       break;
01988       
01989       case CC_RELEASE_COMPLETE|INDICATION:
01990          break;
01991 
01992       case CC_SUSPEND|INDICATION:
01993       {
01994          msg_t *dmsg;
01995          cb_log(4, stack->port, " --> Got Suspend, sending Reject for now\n");
01996          dmsg = create_l3msg(CC_SUSPEND_REJECT | REQUEST,MT_SUSPEND_REJECT, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
01997          pthread_mutex_lock(&stack->nstlock);
01998          stack->nst.manager_l3(&stack->nst, dmsg);
01999          free_msg(msg);
02000          return 0;
02001       }
02002       break;
02003       case CC_RESUME|INDICATION:
02004          break;
02005 
02006       case CC_RELEASE|CONFIRM:
02007          {
02008             struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
02009 
02010             if (bc) { 
02011                cb_log(1, stack->port, "CC_RELEASE|CONFIRM (l3id:%x), sending RELEASE_COMPLETE\n", hh->dinfo);
02012                misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
02013             }
02014          }
02015          break;
02016          
02017       case CC_RELEASE|INDICATION:
02018          break;
02019 
02020       case CC_RELEASE_CR|INDICATION:
02021          release_cr(stack, hh);
02022          free_msg(msg);
02023          pthread_mutex_lock(&stack->nstlock);
02024          return 0 ;
02025       break;
02026       
02027       case CC_NEW_CR|INDICATION:
02028          /*  Got New CR for bchan, for now I handle this one in */
02029          /*  connect_ack, Need to be changed */
02030       {
02031          struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
02032          int l3id = *((int *)(((u_char *)msg->data)+ mISDNUSER_HEAD_SIZE));
02033          if (!bc) {
02034             cb_log(0, stack->port, " --> In NEW_CR: didn't found bc ??\n");
02035             pthread_mutex_lock(&stack->nstlock);
02036             return -1;
02037          }
02038          if (((l3id&0xff00)!=0xff00) && ((bc->l3_id&0xff00)==0xff00)) {
02039             cb_log(4, stack->port, " --> Removing Process Id:%x on this port.\n", 0xff&bc->l3_id);
02040             stack->procids[bc->l3_id&0xff] = 0 ;
02041          }
02042          cb_log(4, stack->port, "lib: Event_ind:CC_NEW_CR : very new L3ID  is %x\n",l3id );
02043    
02044          bc->l3_id =l3id;
02045          cb_event(EVENT_NEW_L3ID, bc, glob_mgr->user_data);
02046    
02047          free_msg(msg);
02048          pthread_mutex_lock(&stack->nstlock);
02049          return 0;
02050       }
02051       
02052       case DL_ESTABLISH | INDICATION:
02053       case DL_ESTABLISH | CONFIRM:
02054       {
02055          cb_log(3, stack->port, "%% GOT L2 Activate Info.\n");
02056          
02057          if (stack->ptp && stack->l2link) {
02058             cb_log(0, stack->port, "%% GOT L2 Activate Info. but we're activated already.. this l2 is faulty, blocking port\n");
02059             cb_event(EVENT_PORT_ALARM, &stack->bc[0], glob_mgr->user_data);
02060          }
02061 
02062          if (stack->ptp && !stack->restart_sent) {
02063             /* make sure we restart the interface of the 
02064              * other side */
02065             stack->restart_sent=1;
02066             misdn_lib_send_restart(stack->port, -1);
02067 
02068          }
02069       
02070          /* when we get the L2 UP, the L1 is UP definitely too*/
02071          stack->l1link = 1;
02072          stack->l2link = 1;
02073          stack->l2upcnt=0;
02074          
02075          free_msg(msg);
02076          pthread_mutex_lock(&stack->nstlock);
02077          return 0;
02078       }
02079       break;
02080 
02081 
02082       case DL_RELEASE | INDICATION:
02083       case DL_RELEASE | CONFIRM:
02084       {
02085          if (stack->ptp) {
02086             cb_log(3 , stack->port, "%% GOT L2 DeActivate Info.\n");
02087 
02088             if (stack->l2upcnt>3) {
02089                cb_log(0 , stack->port, "!!! Could not Get the L2 up after 3 Attempts!!!\n");
02090             }  else {
02091 #if 0
02092                if (stack->nt) misdn_lib_reinit_nt_stack(stack->port);
02093 #endif
02094                if (stack->l1link) {
02095                   misdn_lib_get_l2_up(stack);
02096                   stack->l2upcnt++;
02097                }
02098             }
02099             
02100          } else 
02101             cb_log(3, stack->port, "%% GOT L2 DeActivate Info.\n");
02102          
02103          stack->l2link = 0;
02104          free_msg(msg);
02105          pthread_mutex_lock(&stack->nstlock);
02106          return 0;
02107       }
02108       break;
02109       }
02110    }
02111    
02112    {
02113       /*  Parse Events and fire_up to App. */
02114       struct misdn_bchannel *bc;
02115       struct misdn_bchannel dummybc;
02116       
02117       enum event_e event = isdn_msg_get_event(msgs_g, msg, 1);
02118     
02119       bc=find_bc_by_l3id(stack, hh->dinfo);
02120     
02121       if (!bc) {
02122          cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x).\n", hh->dinfo);
02123          misdn_make_dummy(&dummybc, stack->port,  hh->dinfo, stack->nt, 0);
02124          bc=&dummybc; 
02125       }
02126       if (bc ) {
02127          isdn_msg_parse_event(msgs_g,msg,bc, 1);
02128 
02129          switch (event) {
02130             case EVENT_SETUP:
02131                if (bc->channel<=0 || bc->channel==0xff) 
02132                   bc->channel=0;
02133             
02134                if (find_free_chan_in_stack(stack,bc, bc->channel,0)<0) {
02135                   msg_t *dmsg;
02136                   cb_log(4, stack->port, "Patch from MEIDANIS:Sending RELEASE_COMPLETE %x (No free Chan for you..)\n", hh->dinfo);
02137                   dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST,MT_RELEASE_COMPLETE, hh->dinfo,sizeof(RELEASE_COMPLETE_t), 1);
02138                   pthread_mutex_lock(&stack->nstlock);
02139                   stack->nst.manager_l3(&stack->nst, dmsg);
02140                   free_msg(msg);
02141                   return 0;
02142                }
02143                break;
02144             case EVENT_RELEASE:
02145             case EVENT_RELEASE_COMPLETE:
02146                {
02147                int channel=bc->channel;
02148                int tmpcause=bc->cause; 
02149                          empty_bc(bc);
02150                bc->cause=tmpcause;
02151                clean_up_bc(bc);
02152 
02153                if (channel>0)
02154                                  empty_chan_in_stack(stack,channel);
02155                bc->in_use=0;
02156                }
02157                break;
02158 
02159             default:
02160             break;
02161          }
02162          
02163          if(!isdn_get_info(msgs_g,event,1)) {
02164             cb_log(4, stack->port, "Unknown Event Ind: prim %x dinfo %x\n",hh->prim, hh->dinfo);
02165          } else {
02166             if (reject) {
02167                switch(bc->cause){
02168                   case AST_CAUSE_USER_BUSY:
02169                      cb_log(1, stack->port, "Siemens Busy reject..\n");
02170 
02171                      break;
02172                   default:
02173                      break;
02174                }
02175             }
02176             cb_event(event, bc, glob_mgr->user_data);
02177          }
02178       } else {
02179          cb_log(4, stack->port, "No BC found with l3id: prim %x dinfo %x\n",hh->prim, hh->dinfo);
02180       }
02181 
02182       free_msg(msg);
02183    }
02184 
02185 
02186    pthread_mutex_lock(&stack->nstlock);
02187    return 0;
02188 }

static int handle_frm ( msg_t *  msg  )  [static]

Definition at line 2663 of file isdn_lib.c.

References AST_CAUSE_NORMAL_CLEARING, AST_CAUSE_REQUESTED_CHAN_UNAVAIL, bc_state_change(), BCHAN_CLEANED, misdn_bchannel::cause, cb_event, cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), empty_chan_in_stack(), EVENT_RELEASE_COMPLETE, EVENT_RESTART, EVENT_SETUP, find_bc_by_l3id(), find_stack_by_addr(), glob_mgr, handle_cr(), handle_event(), misdn_bchannel::in_use, isdn_get_info(), isdn_msg_get_event(), isdn_msg_parse_event(), misdn_lib_send_event(), misdn_lib_send_restart(), misdn_make_dummy(), msgs_g, misdn_bchannel::out_cause, misdn_bchannel::port, RESPONSE_IGNORE_SETUP, RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, RESPONSE_OK, RESPONSE_RELEASE_SETUP, misdn_bchannel::restart_channel, and misdn_lib::user_data.

Referenced by manager_event_handler(), and manager_isdn_handler().

02664 {
02665    iframe_t *frm = (iframe_t*) msg->data;
02666    
02667    struct misdn_stack *stack=find_stack_by_addr(frm->addr);
02668 
02669    if (!stack || stack->nt) {
02670       return 0;
02671    }
02672    
02673    cb_log(4,stack?stack->port:0,"handle_frm: frm->addr:%x frm->prim:%x\n",frm->addr,frm->prim);
02674 
02675    {
02676       struct misdn_bchannel dummybc;
02677       struct misdn_bchannel *bc;
02678       int ret=handle_cr(stack, frm);
02679 
02680       if (ret<0) {
02681          cb_log(3,stack?stack->port:0,"handle_frm: handle_cr <0 prim:%x addr:%x\n", frm->prim, frm->addr);
02682 
02683 
02684       }
02685 
02686       if(ret) {
02687          free_msg(msg);
02688          return 1;
02689       }
02690     
02691       bc=find_bc_by_l3id(stack, frm->dinfo);
02692 
02693       if (!bc && (frm->prim==(CC_RESTART|CONFIRM)) ) {
02694          misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
02695          bc=&dummybc;
02696       }
02697 
02698       if (!bc && (frm->prim==(CC_SETUP|INDICATION)) ) {
02699          misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
02700          dummybc.port=stack->port;
02701          dummybc.l3_id=frm->dinfo;
02702          bc=&dummybc;
02703 
02704          misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
02705 
02706          free_msg(msg);
02707          return 1;
02708       }
02709 
02710     
02711 handle_frm_bc:
02712       if (bc ) {
02713          enum event_e event = isdn_msg_get_event(msgs_g, msg, 0);
02714          enum event_response_e response=RESPONSE_OK;
02715          int ret;
02716       
02717          isdn_msg_parse_event(msgs_g,msg,bc, 0);
02718          
02719          /** Preprocess some Events **/
02720          ret = handle_event(bc, event, frm);
02721          if (ret<0) {
02722             cb_log(0,stack->port,"couldn't handle event\n");
02723             free_msg(msg);
02724             return 1;
02725          }
02726          /*  shoot up event to App: */
02727          cb_log(5, stack->port, "lib Got Prim: Addr %x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
02728       
02729          if(!isdn_get_info(msgs_g,event,0)) 
02730             cb_log(0, stack->port, "Unknown Event Ind: Addr:%x prim %x dinfo %x\n",frm->addr, frm->prim, frm->dinfo);
02731          else
02732             response=cb_event(event, bc, glob_mgr->user_data);
02733 #if 1
02734          if (event == EVENT_SETUP) {
02735             switch (response) {
02736             case RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE:
02737 
02738                cb_log(0, stack->port, "TOTALLY IGNORING SETUP\n");               
02739                
02740                break;
02741             case RESPONSE_IGNORE_SETUP:
02742                /* I think we should send CC_RELEASE_CR, but am not sure*/
02743                bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
02744             
02745             case RESPONSE_RELEASE_SETUP:
02746                misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
02747                if (bc->channel>0)
02748                   empty_chan_in_stack(stack, bc->channel);
02749                empty_bc(bc);
02750                bc_state_change(bc,BCHAN_CLEANED);
02751                bc->in_use=0;
02752 
02753                cb_log(0, stack->port, "GOT IGNORE SETUP\n");
02754                break;
02755             case RESPONSE_OK:
02756                cb_log(4, stack->port, "GOT SETUP OK\n");
02757 
02758                
02759                break;
02760             default:
02761                break;
02762             }
02763          }
02764 
02765          if (event == EVENT_RELEASE_COMPLETE) {
02766             /* release bchannel only after we've announced the RELEASE_COMPLETE */
02767             int channel=bc->channel;
02768             int tmpcause=bc->cause; 
02769             int tmp_out_cause=bc->out_cause; 
02770             empty_bc(bc);
02771             bc->cause=tmpcause;
02772             bc->out_cause=tmp_out_cause;
02773             clean_up_bc(bc);
02774             bc->in_use = 0;
02775             
02776             if (tmpcause == AST_CAUSE_REQUESTED_CHAN_UNAVAIL) {
02777                cb_log(0, stack->port, "**** Received CAUSE:%d, restarting channel %d\n", AST_CAUSE_REQUESTED_CHAN_UNAVAIL, channel);
02778                misdn_lib_send_restart(stack->port, channel);
02779             }
02780             if (channel > 0) {
02781                empty_chan_in_stack(stack, channel);
02782             }
02783          }
02784 
02785          if (event == EVENT_RESTART) {
02786             cb_log(0, stack->port, "**** Received RESTART channel:%d\n", bc->restart_channel);
02787             empty_chan_in_stack(stack, bc->restart_channel);
02788          }
02789 
02790          cb_log(5, stack->port, "Freeing Msg on prim:%x \n",frm->prim);
02791 
02792          
02793          free_msg(msg);
02794          return 1;
02795 #endif
02796       
02797       } else {
02798          struct misdn_bchannel dummybc;
02799          cb_log(0, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", frm->dinfo);
02800          memset (&dummybc,0,sizeof(dummybc));
02801          dummybc.port=stack->port;
02802          dummybc.l3_id=frm->dinfo;
02803          bc=&dummybc; 
02804          goto handle_frm_bc;
02805       }
02806    }
02807 
02808    cb_log(4, stack->port, "TE_FRM_HANDLER: Returning 0 on prim:%x \n",frm->prim);
02809    return 0;
02810 }

static int handle_frm_nt ( msg_t *  msg  )  [static]

Definition at line 2628 of file isdn_lib.c.

References cb_log, find_stack_by_addr(), nt_err_cnt, pthread_mutex_lock, and pthread_mutex_unlock.

Referenced by manager_event_handler(), and manager_isdn_handler().

02629 {
02630    iframe_t *frm= (iframe_t*)msg->data;
02631    struct misdn_stack *stack;
02632    int err=0;
02633 
02634    stack=find_stack_by_addr( frm->addr );
02635 
02636    
02637   
02638    if (!stack || !stack->nt) {
02639       return 0;
02640    }
02641 
02642    
02643    pthread_mutex_lock(&stack->nstlock);
02644    if ((err=stack->nst.l1_l2(&stack->nst,msg))) {
02645       pthread_mutex_unlock(&stack->nstlock);
02646       if (nt_err_cnt > 0 ) {
02647          if (nt_err_cnt < 100) {
02648             nt_err_cnt++; 
02649             cb_log(0, stack->port, "NT Stack sends us error: %d \n", err);
02650          } else if (nt_err_cnt < 105){
02651             cb_log(0, stack->port, "NT Stack sends us error: %d over 100 times, so I'll stop this message\n", err);
02652             nt_err_cnt = - 1; 
02653          }
02654       }
02655       free_msg(msg);
02656       return 1;
02657    }
02658    pthread_mutex_unlock(&stack->nstlock);
02659    return 1;
02660 }

static int handle_l1 ( msg_t *  msg  )  [static]

Definition at line 2813 of file isdn_lib.c.

References cb_event, cb_log, EVENT_CLEANUP, EVENT_NOTHING, find_stack_by_addr(), glob_mgr, global_state, isdn_get_info(), MISDN_INITIALIZED, misdn_lib_get_l2_up(), misdn_lib_send_event(), msgs_g, pthread_mutex_lock, pthread_mutex_unlock, and misdn_lib::user_data.

Referenced by manager_isdn_handler().

02814 {
02815    iframe_t *frm = (iframe_t*) msg->data;
02816    struct misdn_stack *stack = find_stack_by_addr(frm->addr);
02817    int i ;
02818    
02819    if (!stack) return 0 ;
02820 
02821    switch (frm->prim) {
02822    case PH_ACTIVATE | CONFIRM:
02823    case PH_ACTIVATE | INDICATION:
02824       cb_log (3, stack->port, "L1: PH L1Link Up!\n");
02825       stack->l1link=1;
02826       
02827       if (stack->nt) {
02828          
02829          pthread_mutex_lock(&stack->nstlock);
02830          if (stack->nst.l1_l2(&stack->nst, msg))
02831             free_msg(msg);
02832          pthread_mutex_unlock(&stack->nstlock);
02833 
02834          if (stack->ptp)
02835             misdn_lib_get_l2_up(stack);
02836       } else {
02837          free_msg(msg);
02838       }
02839       
02840       for (i=0;i<=stack->b_num; i++) {
02841          if (stack->bc[i].evq != EVENT_NOTHING) {
02842             cb_log(4, stack->port, "Firing Queued Event %s because L1 got up\n", isdn_get_info(msgs_g, stack->bc[i].evq, 0));
02843             misdn_lib_send_event(&stack->bc[i],stack->bc[i].evq);
02844             stack->bc[i].evq=EVENT_NOTHING;
02845          }
02846          
02847       }
02848       return 1;
02849 
02850    case PH_ACTIVATE | REQUEST:
02851       free_msg(msg);
02852       cb_log(3,stack->port,"L1: PH_ACTIVATE|REQUEST \n");
02853       return 1;
02854       
02855    case PH_DEACTIVATE | REQUEST:
02856       free_msg(msg);
02857       cb_log(3,stack->port,"L1: PH_DEACTIVATE|REQUEST \n");
02858       return 1;
02859       
02860    case PH_DEACTIVATE | CONFIRM:
02861    case PH_DEACTIVATE | INDICATION:
02862       cb_log (3, stack->port, "L1: PH L1Link Down! \n");
02863    
02864 #if 0
02865       for (i=0; i<=stack->b_num; i++) {
02866          if (global_state == MISDN_INITIALIZED)  {
02867             cb_event(EVENT_CLEANUP, &stack->bc[i], glob_mgr->user_data);
02868          }
02869       }
02870 #endif
02871       
02872       if (stack->nt) {
02873          pthread_mutex_lock(&stack->nstlock);
02874          if (stack->nst.l1_l2(&stack->nst, msg))
02875             free_msg(msg);
02876          pthread_mutex_unlock(&stack->nstlock);
02877       } else {
02878          free_msg(msg);
02879       }
02880       
02881       stack->l1link=0;
02882       stack->l2link=0;
02883       return 1;
02884    }
02885   
02886    return 0;
02887 }

static int handle_l2 ( msg_t *  msg  )  [static]

Definition at line 2889 of file isdn_lib.c.

References cb_event, cb_log, EVENT_PORT_ALARM, find_stack_by_addr(), glob_mgr, and misdn_lib::user_data.

Referenced by manager_isdn_handler().

02890 {
02891    iframe_t *frm = (iframe_t*) msg->data;
02892 
02893    struct misdn_stack *stack = find_stack_by_addr(frm->addr);
02894    
02895    if (!stack) {
02896       return 0 ;
02897    }
02898    
02899    switch(frm->prim) {
02900 
02901    case DL_ESTABLISH | REQUEST:
02902       cb_log(1,stack->port,"DL_ESTABLISH|REQUEST \n");
02903       free_msg(msg);
02904       return 1;
02905    case DL_RELEASE | REQUEST:
02906       cb_log(1,stack->port,"DL_RELEASE|REQUEST \n");
02907       free_msg(msg);
02908       return 1;
02909       
02910    case DL_ESTABLISH | INDICATION:
02911    case DL_ESTABLISH | CONFIRM:
02912    {
02913       cb_log (3, stack->port, "L2: L2Link Up! \n");
02914       if (stack->ptp && stack->l2link) {
02915          cb_log (-1, stack->port, "L2: L2Link Up! but it's already UP.. must be faulty, blocking port\n"); 
02916          cb_event(EVENT_PORT_ALARM, &stack->bc[0], glob_mgr->user_data);
02917       }
02918       stack->l2link=1;
02919       free_msg(msg);
02920       return 1;
02921    }
02922    break;
02923     
02924    case DL_RELEASE | INDICATION:
02925    case DL_RELEASE | CONFIRM:
02926    {
02927       cb_log (3, stack->port, "L2: L2Link Down! \n");
02928       stack->l2link=0;
02929       
02930       free_msg(msg);
02931       return 1;
02932    }
02933    break;
02934    }
02935    return 0;
02936 }

static int handle_mgmt ( msg_t *  msg  )  [static]

Definition at line 2938 of file isdn_lib.c.

References cb_log, clear_l3(), and find_stack_by_addr().

Referenced by manager_isdn_handler().

02939 {
02940    iframe_t *frm = (iframe_t*) msg->data;
02941    struct misdn_stack *stack;
02942 
02943    if ( (frm->addr == 0) && (frm->prim == (MGR_DELLAYER|CONFIRM)) ) {
02944       cb_log(2, 0, "MGMT: DELLAYER|CONFIRM Addr: 0 !\n") ;
02945       free_msg(msg);
02946       return 1;
02947    }
02948    
02949    stack = find_stack_by_addr(frm->addr);
02950    
02951    if (!stack) {
02952       if (frm->prim == (MGR_DELLAYER|CONFIRM)) {
02953          cb_log(2, 0, "MGMT: DELLAYER|CONFIRM Addr: %x !\n",
02954                frm->addr) ;
02955          free_msg(msg);
02956          return 1;
02957       }
02958       
02959       return 0;
02960    }
02961    
02962    switch(frm->prim) {
02963    case MGR_SHORTSTATUS | INDICATION:
02964    case MGR_SHORTSTATUS | CONFIRM:
02965       cb_log(5, stack->port, "MGMT: Short status dinfo %x\n",frm->dinfo);
02966       
02967       switch (frm->dinfo) {
02968       case SSTATUS_L1_ACTIVATED:
02969          cb_log(3, stack->port, "MGMT: SSTATUS: L1_ACTIVATED \n");
02970          stack->l1link=1;
02971       
02972          break;
02973       case SSTATUS_L1_DEACTIVATED:
02974          cb_log(3, stack->port, "MGMT: SSTATUS: L1_DEACTIVATED \n");
02975          stack->l1link=0;
02976 #if 0
02977          clear_l3(stack);
02978 #endif
02979          break;
02980 
02981       case SSTATUS_L2_ESTABLISHED:
02982          cb_log(3, stack->port, "MGMT: SSTATUS: L2_ESTABLISH \n");
02983 
02984          /*when the L2 goes UP, L1 needs to be UP too*/
02985          stack->l1link=1;
02986          stack->l2link=1;
02987          break;
02988          
02989       case SSTATUS_L2_RELEASED:
02990          cb_log(3, stack->port, "MGMT: SSTATUS: L2_RELEASED \n");
02991          stack->l2link=0;
02992          break;
02993       }
02994       
02995       free_msg(msg);
02996       return 1;
02997       
02998    case MGR_SETSTACK | INDICATION:
02999       cb_log(4, stack->port, "MGMT: SETSTACK|IND dinfo %x\n",frm->dinfo);
03000       free_msg(msg);
03001       return 1;
03002    case MGR_DELLAYER | CONFIRM:
03003       cb_log(4, stack->port, "MGMT: DELLAYER|CNF dinfo %x\n",frm->dinfo) ;
03004       free_msg(msg);
03005       return 1;
03006       
03007    }
03008    
03009    /*
03010    if ( (frm->prim & 0x0f0000) ==  0x0f0000) {
03011    cb_log(5, 0, "$$$ MGMT FRAME: prim %x addr %x dinfo %x\n",frm->prim, frm->addr, frm->dinfo) ;
03012    free_msg(msg);
03013    return 1;
03014    } */
03015     
03016    return 0;
03017 }

static int handle_timers ( msg_t *  msg  )  [static]

Definition at line 2191 of file isdn_lib.c.

References cb_log, glob_mgr, misdn_stack::midev, misdn_stack::next, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, pthread_mutex_lock, pthread_mutex_unlock, and misdn_lib::stack_list.

Referenced by manager_isdn_handler().

02192 {
02193    iframe_t *frm= (iframe_t*)msg->data;
02194    struct misdn_stack *stack; 
02195   
02196    /* Timer Stuff */
02197    switch (frm->prim) {
02198    case MGR_INITTIMER | CONFIRM:
02199    case MGR_ADDTIMER | CONFIRM:
02200    case MGR_DELTIMER | CONFIRM:
02201    case MGR_REMOVETIMER | CONFIRM:
02202       free_msg(msg);
02203       return(1);
02204    }
02205   
02206   
02207   
02208    if (frm->prim==(MGR_TIMER | INDICATION) ) {
02209       for (stack = glob_mgr->stack_list;
02210            stack;
02211            stack = stack->next) {
02212          itimer_t *it;
02213       
02214          if (!stack->nt) continue;
02215       
02216          it = stack->nst.tlist;
02217          /* find timer */
02218          for(it=stack->nst.tlist;
02219              it;
02220              it=it->next) {
02221             if (it->id == (int)frm->addr)
02222                break;
02223          }
02224          if (it) {
02225             int ret;
02226             ret = mISDN_write_frame(stack->midev, msg->data, frm->addr,
02227                      MGR_TIMER | RESPONSE, 0, 0, NULL, TIMEOUT_1SEC);
02228             test_and_clear_bit(FLG_TIMER_RUNING, (long unsigned int *)&it->Flags);
02229             pthread_mutex_lock(&stack->nstlock);
02230             ret = it->function(it->data);
02231             pthread_mutex_unlock(&stack->nstlock);
02232             free_msg(msg);
02233             return 1;
02234          }
02235       }
02236     
02237       cb_log(0, 0, "Timer Msg without Timer ??\n");
02238       free_msg(msg);
02239       return 1;
02240    }
02241   
02242    return 0;
02243 }

static int init_bc ( struct misdn_stack stack,
struct misdn_bchannel bc,
int  midev,
int  port,
int  bidx,
char *  msn,
int  firsttime 
) [static]

IFACE

Definition at line 1152 of file isdn_lib.c.

References misdn_bchannel::astbuf, misdn_stack::bc, bc_state_change(), BCHAN_CLEANED, cb_log, empty_bc(), send_lock::lock, malloc, MISDN_IBUF_SIZE, misdn_bchannel::msn, misdn_stack::nt, misdn_bchannel::nt, misdn_stack::port, misdn_bchannel::port, misdn_stack::pri, misdn_bchannel::pri, pthread_mutex_init, and misdn_bchannel::send_lock.

Referenced by misdn_lib_init().

01153 {
01154    unsigned char buff[1025] = "";
01155    iframe_t *frm = (iframe_t *)buff;
01156    int ret;
01157   
01158    if (!bc) return -1;
01159   
01160    cb_log(8, port, "Init.BC %d.\n",bidx);
01161    
01162    memset(bc, 0,sizeof(struct misdn_bchannel));
01163 
01164    bc->send_lock=malloc(sizeof(struct send_lock));
01165    if (!bc->send_lock) {
01166       return -1;
01167    }
01168    pthread_mutex_init(&bc->send_lock->lock, NULL);
01169    
01170    if (msn) {
01171       int l = sizeof(bc->msn);
01172       strncpy(bc->msn,msn, l);
01173       bc->msn[l-1] = 0;
01174    }
01175    
01176    
01177    empty_bc(bc);
01178    bc_state_change(bc, BCHAN_CLEANED);
01179    
01180    bc->port=stack->port;
01181    bc->nt=stack->nt?1:0;
01182    bc->pri=stack->pri;
01183    
01184    {
01185       ibuffer_t* ibuf= init_ibuffer(MISDN_IBUF_SIZE);
01186 
01187       if (!ibuf) return -1;
01188       
01189       clear_ibuffer( ibuf);
01190       
01191       ibuf->rsem=malloc(sizeof(sem_t));
01192       if (!ibuf->rsem) {
01193          return -1;
01194       }
01195       
01196       bc->astbuf=ibuf;
01197 
01198       if (sem_init(ibuf->rsem,1,0)<0)
01199          sem_init(ibuf->rsem,0,0);
01200       
01201    }
01202    
01203    {
01204       stack_info_t *stinf;
01205       ret = mISDN_get_stack_info(midev, stack->port, buff, sizeof(buff));
01206       if (ret < 0) {
01207          cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
01208          return -1;
01209       }
01210     
01211       stinf = (stack_info_t *)&frm->data.p;
01212     
01213       cb_log(8, port, " --> Child %x\n",stinf->child[bidx]);
01214    }
01215   
01216    return 0;
01217 }

static void init_flip_bits ( void   )  [static]

Definition at line 299 of file isdn_lib.c.

References flip_table.

Referenced by misdn_lib_init().

00300 {
00301    int i,k;
00302    
00303    for (i = 0 ; i < 256 ; i++) {
00304       unsigned char sample = 0 ;
00305       for (k = 0; k<8; k++) {
00306          if ( i & 1 << k ) sample |= 0x80 >>  k;
00307       }
00308       flip_table[i] = sample;
00309    }
00310 }

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4359 of file isdn_lib.c.

References misdn_stack::bc, and manager_ph_control().

Referenced by process_ast_dsp().

04360 {
04361    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04362 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

Definition at line 4347 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().

04348 {
04349 #ifdef MISDN_1_2
04350    if (*bc->pipeline)
04351 #else
04352    if (bc->ec_enable)
04353 #endif
04354       manager_ec_enable(bc);
04355    else
04356       manager_ec_disable(bc);
04357 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4337 of file isdn_lib.c.

References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

04338 {
04339    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04340 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4342 of file isdn_lib.c.

References misdn_stack::bc, manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

04343 {
04344    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04345 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

Definition at line 4220 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_bchannel::port, and misdn_stack::port.

04221 {
04222    char buf[128];
04223 
04224    struct misdn_stack *stack=get_stack_by_bc(bc);
04225 
04226    if (!stack) {
04227       cb_log(0, bc->port, "bchannel_activate: Stack not found !");
04228       return ;
04229    }
04230    
04231    /* we must activate if we are deactivated */
04232    clear_ibuffer(bc->astbuf);
04233    
04234    cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
04235    
04236    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
04237 
04238    return ;
04239 }

void manager_bchannel_cleanup ( struct misdn_bchannel bc  ) 

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

Definition at line 4242 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_bchannel::port, and misdn_stack::port.

Referenced by clean_up_bc().

04243 {
04244    struct misdn_stack *stack=get_stack_by_bc(bc);
04245    iframe_t dact;
04246    char buf[128]; 
04247 
04248    switch (bc->bc_state) {
04249       case BCHAN_ACTIVATED:
04250          break;
04251       case BCHAN_BRIDGED:
04252          misdn_split_conf(bc,bc->conf_id);
04253          break;
04254       default:
04255          cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
04256          return ;
04257 
04258    }
04259    
04260    cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
04261    
04262    bc->generate_tone=0;
04263    
04264    dact.prim = DL_RELEASE | REQUEST;
04265    dact.addr = bc->addr | FLG_MSG_DOWN;
04266    dact.dinfo = 0;
04267    dact.len = 0;
04268    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
04269 
04270    clear_ibuffer(bc->astbuf);
04271    
04272    bc_state_change(bc,BCHAN_RELEASE);
04273   
04274    return;
04275 }

void manager_bchannel_setup ( struct misdn_bchannel bc  ) 

void manager_clean_bc ( struct misdn_bchannel bc  ) 

Definition at line 4386 of file isdn_lib.c.

References misdn_stack::bc, cb_event, misdn_bchannel::channel, empty_bc(), empty_chan_in_stack(), EVENT_CLEANUP, get_stack_by_bc(), and misdn_bchannel::in_use.

Referenced by misdn_lib_pid_restart().

04387 {
04388    struct misdn_stack *stack=get_stack_by_bc(bc);
04389    
04390    if (bc->channel>0)
04391       empty_chan_in_stack(stack, bc->channel);
04392    empty_bc(bc);
04393    bc->in_use=0;
04394 
04395    cb_event(EVENT_CLEANUP, bc, NULL); 
04396 }

void manager_ec_disable ( struct misdn_bchannel bc  ) 

Definition at line 4575 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().

04576 {
04577    struct misdn_stack *stack=get_stack_by_bc(bc);
04578    
04579    cb_log(4, stack?stack->port:0," --> ec_disable\n");
04580 
04581    if (!misdn_cap_is_speech(bc->capability)) {
04582       cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
04583       return;
04584    }
04585 
04586 #ifdef MISDN_1_2
04587    manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
04588 #else
04589    if ( ! bc->ec_enable) {
04590       cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
04591       manager_ph_control(bc,  ECHOCAN_OFF, 0);
04592    }
04593 #endif
04594 }

void manager_ec_enable ( struct misdn_bchannel bc  ) 

Definition at line 4526 of file isdn_lib.c.

References misdn_stack::bc, misdn_bchannel::capability, cb_log, misdn_bchannel::ec_deftaps, misdn_bchannel::ec_enable, ECHOCAN_ON, get_stack_by_bc(), manager_ph_control_block(), misdn_cap_is_speech(), and misdn_stack::port.

Referenced by handle_event(), isdn_lib_update_ec(), misdn_lib_send_event(), and misdn_toggle_echocancel().

04527 {
04528    struct misdn_stack *stack=get_stack_by_bc(bc);
04529    
04530    cb_log(4, stack?stack->port:0,"ec_enable\n");
04531 
04532    if (!misdn_cap_is_speech(bc->capability)) {
04533       cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
04534    } else {
04535 
04536 #ifdef MISDN_1_2
04537    if (*bc->pipeline) {
04538       cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
04539       manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
04540    }
04541 #else
04542    int ec_arr[2];
04543 
04544    if (bc->ec_enable) {
04545       cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
04546    
04547       switch (bc->ec_deftaps) {
04548       case 4:
04549       case 8:
04550       case 16:
04551       case 32:
04552       case 64:
04553       case 128:
04554       case 256:
04555       case 512:
04556       case 1024:
04557          cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
04558          break;
04559       default:
04560          cb_log(0, stack->port, "Taps should be power of 2\n");
04561          bc->ec_deftaps=128;
04562       }
04563    
04564       ec_arr[0]=bc->ec_deftaps;
04565       ec_arr[1]=0;
04566       
04567       manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
04568    }
04569 #endif
04570    }
04571 }

static void manager_event_handler ( void *  arg  )  [static]

Definition at line 3929 of file isdn_lib.c.

References misdn_lib::activatequeue, cb_log, clean_up_bc(), misdn_stack::downqueue, find_bc_by_l3id(), find_stack_by_port(), glob_mgr, handle_frm(), handle_frm_nt(), misdn_lib::midev, misdn_make_dummy(), misdn_lib::new_msg, misdn_stack::next, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, misdn_stack::port, misdn_bchannel::port, pthread_mutex_lock, pthread_mutex_unlock, send_msg(), misdn_lib::stack_list, and misdn_stack::upqueue.

03930 {
03931    sem_post(&handler_started); 
03932    while (1) {
03933       struct misdn_stack *stack;
03934       msg_t *msg;
03935     
03936       /** wait for events **/
03937       sem_wait(&glob_mgr->new_msg);
03938     
03939       for (msg=msg_dequeue(&glob_mgr->activatequeue);
03940            msg;
03941            msg=msg_dequeue(&glob_mgr->activatequeue)
03942          )
03943       {
03944    
03945          iframe_t *frm =  (iframe_t*) msg->data ;
03946 
03947          switch ( frm->prim) {
03948 
03949          case MGR_CLEARSTACK | REQUEST:
03950             /*a queued bchannel cleanup*/
03951             {
03952                struct misdn_stack *stack=find_stack_by_port(frm->dinfo);
03953                struct misdn_bchannel *bc;
03954                if (!stack) {
03955                   cb_log(0,0,"no stack found with port [%d]!! so we cannot cleanup the bc\n",frm->dinfo);
03956                   free_msg(msg);
03957                   break;
03958                }
03959                
03960                bc = find_bc_by_l3id(stack, frm->addr);
03961                if (bc) {
03962                   cb_log(1,bc->port,"CLEARSTACK queued, cleaning up\n");
03963                   clean_up_bc(bc);
03964                } else {
03965                   cb_log(0,stack->port,"bc could not be cleaned correctly !! addr [%x]\n",frm->addr);
03966                }
03967             }
03968             free_msg(msg); 
03969             break;
03970          case MGR_SETSTACK | REQUEST :
03971             free_msg(msg);
03972             break;
03973          default:
03974             mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
03975             free_msg(msg);
03976          }
03977       }
03978 
03979       for (stack=glob_mgr->stack_list;
03980            stack;
03981            stack=stack->next ) { 
03982 
03983          while ( (msg=msg_dequeue(&stack->upqueue)) ) {
03984             /** Handle L2/3 Signalling after bchans **/ 
03985             if (!handle_frm_nt(msg)) {
03986                /* Maybe it's TE */
03987                if (!handle_frm(msg)) {
03988                   /* wow none! */
03989                   cb_log(0,stack->port,"Wow we've got a strange issue while dequeueing a Frame\n");
03990                }
03991             }
03992          }
03993 
03994          /* Here we should check if we really want to 
03995             send all the messages we've queued, lets 
03996             assume we've queued a Disconnect, but 
03997             received it already from the other side!*/
03998            
03999          while ( (msg=msg_dequeue(&stack->downqueue)) ) {
04000             if (stack->nt ) {
04001                pthread_mutex_lock(&stack->nstlock);
04002                if (stack->nst.manager_l3(&stack->nst, msg))
04003                   cb_log(0, stack->port, "Error@ Sending Message in NT-Stack.\n");
04004                pthread_mutex_unlock(&stack->nstlock);
04005             } else {
04006                iframe_t *frm = (iframe_t *)msg->data;
04007                struct misdn_bchannel *bc = find_bc_by_l3id(stack, frm->dinfo);
04008                if (bc)
04009                   send_msg(glob_mgr->midev, bc, msg);
04010                else  {
04011                   if (frm->dinfo == MISDN_ID_GLOBAL) {
04012                      struct misdn_bchannel dummybc;
04013                      misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
04014                      send_msg(glob_mgr->midev, &dummybc, msg);
04015                   }
04016                }
04017             }
04018          }
04019       }
04020    }
04021 }

struct misdn_bchannel * manager_find_bc_by_pid ( int  pid  ) 

Definition at line 3162 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, glob_mgr, misdn_bchannel::in_use, misdn_stack::next, misdn_bchannel::pid, and misdn_lib::stack_list.

Referenced by misdn_lib_pid_restart().

03163 {
03164    struct misdn_stack *stack;
03165    int i;
03166   
03167    for (stack = glob_mgr->stack_list; stack; stack = stack->next) {
03168       for (i = 0; i <= stack->b_num; i++) {
03169          if (stack->bc[i].in_use && stack->bc[i].pid == pid) {
03170             return &stack->bc[i];
03171          }
03172       }
03173    }
03174   
03175    return NULL;
03176 }

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4215 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04216 {
04217    return isdn_get_info(msgs_g , event, 0);
04218 }

int manager_isdn_handler ( iframe_t *  frm,
msg_t *  msg 
)

Definition at line 3718 of file isdn_lib.c.

References cb_log, handle_bchan(), handle_err(), handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), handle_mgmt(), handle_timers(), and LOG_NOTICE.

Referenced by misdn_lib_isdn_event_catcher().

03719 {  
03720 
03721    if (frm->dinfo==0xffffffff && frm->prim==(PH_DATA|CONFIRM)) {
03722       cb_log(0,0,"SERIOUS BUG, dinfo == 0xffffffff, prim == PH_DATA | CONFIRM !!!!\n");
03723    }
03724 
03725    if ( ((frm->addr | ISDN_PID_BCHANNEL_BIT )>> 28 ) == 0x5) {
03726       static int unhandled_bmsg_count=1000;
03727       if (handle_bchan(msg)) {
03728          return 0 ;
03729       }
03730          
03731       if (unhandled_bmsg_count==1000) {
03732          cb_log(0, 0, "received 1k Unhandled Bchannel Messages: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);     
03733          unhandled_bmsg_count=0;
03734       }
03735 
03736       unhandled_bmsg_count++;
03737       free_msg(msg);
03738       return 0;
03739    }  
03740 
03741 #ifdef RECV_FRM_SYSLOG_DEBUG
03742    syslog(LOG_NOTICE,"mISDN recv: P(%02d): ADDR:%x PRIM:%x DINFO:%x\n",stack->port, frm->addr, frm->prim, frm->dinfo);
03743 #endif
03744 
03745    if (handle_timers(msg)) 
03746       return 0 ;
03747 
03748    
03749    if (handle_mgmt(msg)) 
03750       return 0 ; 
03751    
03752    if (handle_l2(msg)) 
03753       return 0 ;
03754 
03755    /* Its important to handle l1 AFTER l2  */
03756    if (handle_l1(msg)) 
03757       return 0 ;
03758    
03759    if (handle_frm_nt(msg)) {
03760       return 0;
03761    }
03762 
03763    if (handle_frm(msg)) {
03764       return 0;
03765    }
03766 
03767    if (handle_err(msg)) {
03768       return 0 ;
03769    }
03770 
03771 // cb_log(0, 0, "Unhandled Message: prim %x len %d from addr %x, dinfo %x on this port.\n",frm->prim, frm->len, frm->addr, frm->dinfo);      
03772    free_msg(msg);
03773    
03774 
03775    return 0;
03776 }

void manager_ph_control ( struct misdn_bchannel bc,
int  c1,
int  c2 
)

Definition at line 4316 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 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().

04317 {
04318    unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
04319    iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
04320    unsigned int *d = (unsigned int*)&ctrl->data.p;
04321    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04322    
04323    cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
04324    
04325    ctrl->prim = PH_CONTROL | REQUEST;
04326    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04327    ctrl->dinfo = 0;
04328    ctrl->len = sizeof(unsigned int)*2;
04329    *d++ = c1;
04330    *d++ = c2;
04331    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04332 }

void manager_ph_control_block ( struct misdn_bchannel bc,
int  c1,
void *  c2,
int  c2_len 
)

Definition at line 4367 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::bc, glob_mgr, and misdn_lib::midev.

Referenced by handle_event(), manager_ec_disable(), manager_ec_enable(), and misdn_lib_send_event().

04368 {
04369    unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+c2_len];
04370    iframe_t *ctrl = (iframe_t *)buffer;
04371    unsigned int *d = (unsigned int *)&ctrl->data.p;
04372    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04373    
04374    ctrl->prim = PH_CONTROL | REQUEST;
04375    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04376    ctrl->dinfo = 0;
04377    ctrl->len = sizeof(unsigned int) + c2_len;
04378    *d++ = c1;
04379    memcpy(d, c2, c2_len);
04380    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04381 }

int misdn_cap_is_speech ( int  cap  ) 

Poor mans version

Definition at line 414 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().

00416 {
00417    if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) &&
00418         (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1;
00419    return 0;
00420 }

void misdn_dump_chanlist ( void   ) 

Definition at line 452 of file isdn_lib.c.

References dump_chan_list(), get_misdn_stack(), and misdn_stack::next.

Referenced by misdn_show_cls().

00453 {
00454    struct misdn_stack *stack=get_misdn_stack();
00455    for ( ; stack; stack=stack->next) {
00456       dump_chan_list(stack);
00457    }
00458 
00459 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

Definition at line 422 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().

00423 {
00424 
00425    if (!bc->early_bconnect) {
00426       /* We have opted to never receive any available inband recorded messages */
00427       return 0;
00428    }
00429    
00430    switch (bc->progress_indicator) {
00431    case INFO_PI_INBAND_AVAILABLE:
00432    case INFO_PI_CALL_NOT_E2E_ISDN:
00433    case INFO_PI_CALLED_NOT_ISDN:
00434       return 1;
00435    default:
00436       return 0;
00437    }
00438    return 0;
00439 }

void misdn_join_conf ( struct misdn_bchannel bc,
int  conf_id 
)

Definition at line 4602 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::bc, bc_state_change(), BCHAN_BRIDGED, cb_log, manager_ph_control(), misdn_lib_tx2misdn_frm(), and misdn_bchannel::port.

Referenced by bc_state_change(), and misdn_lib_bridge().

04603 {
04604    char data[16] = "";
04605 
04606    bc_state_change(bc,BCHAN_BRIDGED);
04607    manager_ph_control(bc, CMX_RECEIVE_OFF, 0);
04608    manager_ph_control(bc, CMX_CONF_JOIN, conf_id);
04609 
04610    cb_log(3,bc->port, "Joining bc:%x in conf:%d\n",bc->addr,conf_id);
04611 
04612    misdn_lib_tx2misdn_frm(bc, data, sizeof(data) - 1);
04613 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4625 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().

04626 {
04627    int conf_id = bc1->pid + 1;
04628    struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL };
04629    struct misdn_bchannel **bc;
04630 
04631    cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
04632 
04633    for (bc=bc_list; *bc;  bc++) { 
04634       (*bc)->conf_id=conf_id;
04635       cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
04636    
04637       switch((*bc)->bc_state) {
04638          case BCHAN_ACTIVATED:
04639             misdn_join_conf(*bc,conf_id);
04640             break;
04641          default:
04642             bc_next_state_change(*bc,BCHAN_BRIDGED);
04643             break;
04644       }
04645    }
04646 }

void misdn_lib_destroy ( void   ) 

Definition at line 4182 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_stack::midev, misdn_lib::midev, MISDN_INITIALIZED, misdn_stack::next, misdn_stack::port, stack_destroy(), misdn_lib::stack_list, and te_lib_destroy().

Referenced by unload_module().

04183 {
04184    struct misdn_stack *help;
04185    int i;
04186   
04187    for ( help=glob_mgr->stack_list; help; help=help->next ) {
04188       for(i=0;i<=help->b_num; i++) {
04189          char buf[1024];
04190          mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
04191          help->bc[i].addr = 0;
04192       }
04193       cb_log (1, help->port, "Destroying this port.\n");
04194       stack_destroy(help);
04195    }
04196    
04197    if (global_state == MISDN_INITIALIZED) {
04198       cb_log(4, 0, "Killing Handler Thread\n");
04199       if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
04200          cb_log(4, 0, "Joining Handler Thread\n");
04201          pthread_join(glob_mgr->event_handler_thread, NULL);
04202       }
04203      
04204       cb_log(4, 0, "Killing Main Thread\n");
04205       if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
04206          cb_log(4, 0, "Joining Main Thread\n");
04207          pthread_join(glob_mgr->event_thread, NULL);
04208       }
04209    }
04210   
04211    cb_log(1, 0, "Closing mISDN device\n");
04212    te_lib_destroy(glob_mgr->midev);
04213 }

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4668 of file isdn_lib.c.

References cb_log, manager_ph_control(), and misdn_bchannel::port.

04669 {
04670    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04671    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04672 }

struct misdn_bchannel* misdn_lib_find_held_bc ( int  port,
int  l3_id 
)

Find a held call's B channel record.

Parameters:
port Port the call is on.
l3_id mISDN Layer 3 ID of held call.
Returns:
Found bc-record or NULL.

Definition at line 4478 of file isdn_lib.c.

References misdn_stack::bc, get_misdn_stack(), misdn_stack::next, misdn_stack::port, and stack_holder_find().

Referenced by misdn_hangup().

04479 {
04480    struct misdn_bchannel *bc;
04481    struct misdn_stack *stack;
04482 
04483    bc = NULL;
04484    for (stack = get_misdn_stack(); stack; stack = stack->next) {
04485       if (stack->port == port) {
04486          bc = stack_holder_find(stack, l3_id);
04487          break;
04488       }
04489    }
04490 
04491    return bc;
04492 }

struct misdn_bchannel* misdn_lib_get_free_bc ( int  port,
int  channel,
int  inout,
int  dec 
)

Definition at line 3219 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, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, misdn_stack::st_lock, misdn_lib::stack_list, and test_inuse().

Referenced by handle_cr(), handle_event_nt(), and misdn_request().

03220 {
03221    struct misdn_stack *stack;
03222    int i;
03223    
03224    if (channel < 0 || channel > MAX_BCHANS) {
03225       cb_log(0,port,"Requested channel out of bounds (%d)\n",channel);
03226       return NULL;
03227    }
03228 
03229    for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
03230     
03231       if (stack->port == port) {
03232          int maxnum;
03233 
03234          if (stack->blocked) {
03235             cb_log(0,port,"Port is blocked\n");
03236             return NULL;
03237          }
03238       
03239          pthread_mutex_lock(&stack->st_lock);
03240          if (channel > 0) {
03241             if (channel <= stack->b_num) {
03242                for (i = 0; i < stack->b_num; i++) {
03243                   if ( stack->bc[i].channel == channel) {
03244                      if (test_inuse(&stack->bc[i])) { 
03245                         pthread_mutex_unlock(&stack->st_lock);
03246                         cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
03247                         return NULL;
03248 
03249                      } else {
03250                         prepare_bc(&stack->bc[i], channel);
03251                         pthread_mutex_unlock(&stack->st_lock);
03252                         return &stack->bc[i];
03253                      }
03254                   }
03255                }
03256             } else {
03257                pthread_mutex_unlock(&stack->st_lock);
03258                cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port);
03259                return NULL;
03260             }
03261          }
03262 
03263          maxnum = inout && !stack->pri && !stack->ptp ? stack->b_num + 1 : stack->b_num;
03264 
03265          if (dec) {
03266             for (i = maxnum-1; i>=0; i--) {
03267                if (!test_inuse(&stack->bc[i])) {
03268                   /* 3. channel on bri means CW*/
03269                   if (!stack->pri && i==stack->b_num)
03270                      stack->bc[i].cw=1;
03271                      
03272                   prepare_bc(&stack->bc[i], channel);
03273                   stack->bc[i].dec=1;
03274                   pthread_mutex_unlock(&stack->st_lock);
03275                   return &stack->bc[i];
03276                }
03277             }
03278          } else {
03279             for (i = 0; i <maxnum; i++) {
03280                if (!test_inuse(&stack->bc[i])) {
03281                   /* 3. channel on bri means CW*/
03282                   if (!stack->pri && i==stack->b_num)
03283                      stack->bc[i].cw=1;
03284 
03285                   prepare_bc(&stack->bc[i], channel);
03286                   pthread_mutex_unlock(&stack->st_lock);
03287                   return &stack->bc[i];
03288                }
03289             }
03290          }
03291          pthread_mutex_unlock(&stack->st_lock);
03292 
03293          cb_log(1,port,"There is no free channel on port (%d)\n",port);
03294          return NULL;
03295       }
03296    }
03297 
03298    cb_log(0,port,"Port is not configured (%d)\n",port);
03299    return NULL;
03300 }

static int misdn_lib_get_l1_down ( struct misdn_stack stack  )  [static]

Definition at line 797 of file isdn_lib.c.

References cb_log, misdn_stack::lower_id, misdn_stack::midev, and misdn_stack::port.

Referenced by handle_err(), and misdn_lib_get_port_down().

00798 {
00799    /* Pull Up L1 */ 
00800    iframe_t act;
00801    act.prim = PH_DEACTIVATE | REQUEST; 
00802    act.addr = stack->lower_id|FLG_MSG_DOWN;
00803    act.dinfo = 0;
00804    act.len = 0;
00805 
00806    cb_log(1, stack->port, "SENDING PH_DEACTIVATE | REQ\n");
00807    return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
00808 }

static int misdn_lib_get_l1_up ( struct misdn_stack stack  )  [static]

Definition at line 838 of file isdn_lib.c.

References misdn_stack::midev, and misdn_stack::upper_id.

Referenced by misdn_lib_get_port_up(), misdn_lib_isdn_l1watcher(), misdn_lib_reinit_nt_stack(), and misdn_lib_send_event().

00839 {
00840    /* Pull Up L1 */ 
00841    iframe_t act;
00842    act.prim = PH_ACTIVATE | REQUEST; 
00843    act.addr = (stack->upper_id | FLG_MSG_DOWN)  ;
00844 
00845    
00846    act.dinfo = 0;
00847    act.len = 0;
00848 
00849    return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
00850 
00851 }

static int misdn_lib_get_l2_down ( struct misdn_stack stack  )  [static]

Definition at line 811 of file isdn_lib.c.

References create_l2msg(), misdn_stack::midev, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, and misdn_stack::upper_id.

Referenced by handle_err(), and misdn_lib_get_port_down().

00812 {
00813    
00814    if (stack->ptp && (stack->nt) ) {
00815       msg_t *dmsg;
00816       /* L2 */
00817       dmsg = create_l2msg(DL_RELEASE| REQUEST, 0, 0);
00818       
00819       pthread_mutex_lock(&stack->nstlock);
00820       if (stack->nst.manager_l3(&stack->nst, dmsg))
00821          free_msg(dmsg);
00822       pthread_mutex_unlock(&stack->nstlock);
00823    } else {
00824       iframe_t act;
00825       
00826       act.prim = DL_RELEASE| REQUEST;
00827       act.addr = (stack->upper_id |FLG_MSG_DOWN)  ;
00828       
00829       act.dinfo = 0;
00830       act.len = 0;
00831       return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
00832    }
00833    
00834    return 0;
00835 }

int misdn_lib_get_l2_up ( struct misdn_stack stack  ) 

Definition at line 853 of file isdn_lib.c.

References create_l2msg(), misdn_stack::midev, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, and misdn_stack::upper_id.

Referenced by handle_event_nt(), handle_l1(), misdn_lib_get_port_up(), misdn_lib_isdn_l1watcher(), and misdn_lib_reinit_nt_stack().

00854 {
00855    
00856    if (stack->ptp && (stack->nt) ) {
00857       msg_t *dmsg;
00858       /* L2 */
00859       dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0);
00860       
00861       pthread_mutex_lock(&stack->nstlock);
00862       if (stack->nst.manager_l3(&stack->nst, dmsg))
00863          free_msg(dmsg);
00864       pthread_mutex_unlock(&stack->nstlock);
00865    } else {
00866       iframe_t act;
00867       
00868       act.prim = DL_ESTABLISH | REQUEST;
00869       act.addr = (stack->upper_id |FLG_MSG_DOWN)  ;
00870       
00871       act.dinfo = 0;
00872       act.len = 0;
00873       return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
00874    }
00875    
00876    return 0;
00877 }

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 115 of file isdn_lib.c.

References get_misdn_stack(), misdn_stack::next, misdn_stack::port, and misdn_stack::pri.

Referenced by misdn_request().

00116 {
00117    struct misdn_stack *stack=get_misdn_stack();
00118    for ( ; stack; stack=stack->next) {
00119       if (stack->port == port) {
00120          if (stack->pri) 
00121             return 30;
00122          else
00123             return 2;
00124       }
00125    }
00126    return -1;
00127 }

int misdn_lib_get_port_down ( int  port  ) 

Definition at line 1760 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().

01761 { /* Pull Down L1 */ 
01762    struct misdn_stack *stack;
01763    for (stack=glob_mgr->stack_list;
01764         stack;
01765         stack=stack->next) {
01766       if (stack->port == port) {
01767             if (stack->l2link)
01768                misdn_lib_get_l2_down(stack);
01769             misdn_lib_get_l1_down(stack);
01770          return 0;
01771       }
01772    }
01773    return 0;
01774 }

int misdn_lib_get_port_info ( int  port  ) 

Definition at line 3781 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.

03782 {
03783    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03784    iframe_t *frm;
03785    struct misdn_stack *stack=find_stack_by_port(port);
03786    if (!msg) {
03787       cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n");
03788       return -1;
03789    }
03790    frm=(iframe_t*)msg->data;
03791    if (!stack ) {
03792       cb_log(0, port, "There is no Stack for this port.\n");
03793       return -1;
03794    }
03795    /* activate bchannel */
03796    frm->prim = CC_STATUS_ENQUIRY | REQUEST;
03797 
03798    frm->addr = stack->upper_id| FLG_MSG_DOWN;
03799 
03800    frm->dinfo = 0;
03801    frm->len = 0;
03802   
03803    msg_queue_tail(&glob_mgr->activatequeue, msg);
03804    sem_post(&glob_mgr->new_msg);
03805 
03806   
03807    return 0; 
03808 }

int misdn_lib_get_port_up ( int  port  ) 

Definition at line 1738 of file isdn_lib.c.

References glob_mgr, misdn_stack::l1link, misdn_stack::l2link, misdn_lib_get_l1_up(), misdn_lib_get_l2_up(), misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.

Referenced by misdn_check_l2l1(), and misdn_port_up().

01739 { /* Pull Up L1 */ 
01740    struct misdn_stack *stack;
01741    
01742    for (stack=glob_mgr->stack_list;
01743         stack;
01744         stack=stack->next) {
01745       
01746       if (stack->port == port) {
01747 
01748          if (!stack->l1link)
01749             misdn_lib_get_l1_up(stack);
01750          if (!stack->l2link)
01751             misdn_lib_get_l2_up(stack);
01752          
01753          return 0;
01754       }
01755    }
01756    return 0;
01757 }

static int misdn_lib_get_short_status ( struct misdn_stack stack  )  [static]

Definition at line 894 of file isdn_lib.c.

References misdn_stack::midev, and misdn_stack::upper_id.

Referenced by misdn_lib_isdn_l1watcher().

00895 {
00896    iframe_t act;
00897    
00898    
00899    act.prim = MGR_SHORTSTATUS | REQUEST; 
00900    
00901    act.addr = (stack->upper_id | MSG_BROADCAST)  ;
00902 
00903    act.dinfo = SSTATUS_BROADCAST_BIT | SSTATUS_ALL;
00904    
00905    act.len = 0;
00906    return mISDN_write(stack->midev, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
00907 }

int misdn_lib_init ( char *  portlist,
struct misdn_lib_iface iface,
void *  user_data 
)

Definition at line 4074 of file isdn_lib.c.

References misdn_lib::activatequeue, misdn_stack::b_num, misdn_stack::bc, calloc, cb_event, misdn_lib_iface::cb_event, cb_jb_empty, misdn_lib_iface::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_lib::midev, misdn_stack::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().

04075 {
04076    struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
04077    char *tok, *tokb;
04078    char plist[1024];
04079    int midev;
04080    int port_count=0;
04081  
04082    cb_log = iface->cb_log;
04083    cb_event = iface->cb_event;
04084    cb_jb_empty = iface->cb_jb_empty;
04085    
04086    glob_mgr = mgr;
04087   
04088    msg_init();
04089 
04090    misdn_lib_nt_debug_init(0,NULL);
04091    
04092    if (!portlist || (*portlist == 0) ) return 1;
04093    
04094    init_flip_bits();
04095    
04096    {
04097       strncpy(plist,portlist, 1024);
04098       plist[1023] = 0;
04099    }
04100   
04101    memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
04102    flip_buf_bits(tone_425_flip,TONE_425_SIZE);
04103 
04104    memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
04105    flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);
04106   
04107    midev=te_lib_init();
04108    mgr->midev=midev;
04109 
04110    port_count=mISDN_get_stack_count(midev);
04111   
04112    msg_queue_init(&mgr->activatequeue);
04113   
04114    if (sem_init(&mgr->new_msg, 1, 0)<0)
04115       sem_init(&mgr->new_msg, 0, 0);
04116  
04117    for (tok=strtok_r(plist," ,",&tokb );
04118         tok; 
04119         tok=strtok_r(NULL," ,",&tokb)) {
04120       int port = atoi(tok);
04121       struct misdn_stack *stack;
04122       static int first=1;
04123       int ptp=0;
04124     
04125       if (strstr(tok, "ptp"))
04126          ptp=1;
04127 
04128       if (port > port_count) {
04129          cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
04130          exit(1);
04131       }
04132       stack=stack_init(midev, port, ptp);
04133     
04134       if (!stack) {
04135          perror("stack_init");
04136          exit(1);
04137       }
04138     
04139       {
04140          int i;
04141          for(i=0;i<=stack->b_num; i++) {
04142             int r;
04143             if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
04144                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
04145                exit(1);
04146             }
04147          }
04148       }
04149 
04150       if (stack && first) {
04151          mgr->stack_list=stack;
04152          first=0;
04153          continue;
04154       }
04155     
04156       if (stack) {
04157          struct misdn_stack * help;
04158          for ( help=mgr->stack_list; help; help=help->next ) 
04159             if (help->next == NULL) break;
04160          help->next=stack;
04161       }
04162     
04163    }
04164   
04165    if (sem_init(&handler_started, 1, 0)<0)
04166       sem_init(&handler_started, 0, 0);
04167   
04168    cb_log(8, 0, "Starting Event Handler\n");
04169    pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr);
04170   
04171    sem_wait(&handler_started) ;
04172    cb_log(8, 0, "Starting Event Catcher\n");
04173    pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);
04174   
04175    cb_log(8, 0, "Event Catcher started\n");
04176 
04177    global_state= MISDN_INITIALIZED; 
04178   
04179    return (mgr == NULL);
04180 }

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 95 of file isdn_lib.c.

References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.

00096 {  
00097    struct misdn_stack *stack=get_misdn_stack();
00098    for ( ; stack; stack=stack->next) {
00099       if (stack->port == port) {
00100          return stack->blocked;
00101       }
00102    }
00103    return -1;
00104 }

int misdn_lib_is_ptp ( int  port  ) 

Definition at line 106 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().

00107 {
00108    struct misdn_stack *stack=get_misdn_stack();
00109    for ( ; stack; stack=stack->next) {
00110       if (stack->port == port) return stack->ptp;
00111    }
00112    return -1;
00113 }

static void misdn_lib_isdn_event_catcher ( void *  arg  )  [static]

Definition at line 3077 of file isdn_lib.c.

References cb_log, fetch_msg(), manager_isdn_handler(), and misdn_lib::midev.

03078 {
03079    struct misdn_lib *mgr = arg;
03080    int zero_frm=0 , fff_frm=0 ;
03081    int midev= mgr->midev;
03082    int port=0;
03083    
03084    while (1) {
03085       msg_t *msg = fetch_msg(midev); 
03086       iframe_t *frm;
03087       
03088       
03089       if (!msg) continue;
03090       
03091       frm = (iframe_t*) msg->data;
03092       
03093       /** When we make a call from NT2Ast we get these frames **/
03094       if (frm->len == 0 && frm->addr == 0 && frm->dinfo == 0 && frm->prim == 0 ) {
03095          zero_frm++; 
03096          free_msg(msg);
03097          continue;
03098       } else {
03099          if (zero_frm) {
03100             cb_log(0, port, "*** Alert: %d zero_frms caught\n", zero_frm);
03101             zero_frm = 0 ;
03102          }
03103       }
03104       
03105       /** I get this sometimes after setup_bc **/
03106       if (frm->len == 0 &&  frm->dinfo == 0 && frm->prim == 0xffffffff ) {
03107          fff_frm++; 
03108          free_msg(msg);
03109          continue;
03110       } else {
03111          if (fff_frm) {
03112             cb_log(0, port, "*** Alert: %d fff_frms caught\n", fff_frm);
03113             fff_frm = 0 ;
03114          }
03115       }
03116       
03117       manager_isdn_handler(frm, msg);
03118    }
03119 
03120 }

void misdn_lib_isdn_l1watcher ( int  port  ) 

Definition at line 3058 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().

03059 {
03060    struct misdn_stack *stack;
03061 
03062    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
03063       ;
03064 
03065    if (stack) {
03066       cb_log(4, port, "Checking L1 State\n");   
03067       if (!stack->l1link) {
03068          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
03069          misdn_lib_get_short_status(stack);
03070          misdn_lib_get_l1_up(stack); 
03071          misdn_lib_get_l2_up(stack); 
03072       }
03073    }
03074 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

Definition at line 3345 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().

03346 {
03347    struct misdn_stack *stack;
03348 
03349    if (!bc) return;
03350 
03351    stack = get_stack_by_bc(bc);
03352 
03353    if (!stack) return;
03354 
03355    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);
03356    
03357    cb_log(2, stack->port,
03358           " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
03359           bc->info_dad,
03360           bc->onumplan>=0?'0'+bc->onumplan:' ',
03361           bc->dnumplan>=0?'0'+bc->dnumplan:' ',
03362           bc->rnumplan>=0?'0'+bc->rnumplan:' ',
03363           bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
03364       );
03365    
03366    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);
03367    cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
03368          bc->screen, bc->pres);
03369    
03370    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);
03371    
03372    cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
03373 
03374    cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
03375    
03376    cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
03377 }

int misdn_lib_maxports_get ( void   ) 

Definition at line 4024 of file isdn_lib.c.

Referenced by load_module().

04025 {
04026    /* BE AWARE WE HAVE NO cb_log() HERE! */
04027 
04028    int i = mISDN_open();
04029    int max=0;
04030    
04031    if (i<0)
04032       return -1;
04033 
04034    max = mISDN_get_stack_count(i);
04035    
04036    mISDN_close(i);
04037    
04038    return max;
04039 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4054 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

04055 {
04056    static int init=0;
04057    char *f;
04058    
04059    if (!flags) 
04060       f=NULL;
04061    else
04062       f=file;
04063 
04064    if (!init) {
04065       debug_init( flags , f, f, f);
04066       init=1;
04067    } else {
04068       debug_close();
04069       debug_init( flags , f, f, f);
04070    }
04071 }

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 4042 of file isdn_lib.c.

References get_misdn_stack(), misdn_stack::next, and misdn_stack::nst.

Referenced by load_module().

04043 {
04044 #ifdef FEATURE_NET_KEEPCALLS
04045    if (kc) {
04046       struct misdn_stack *stack=get_misdn_stack();
04047       for ( ; stack; stack=stack->next) {
04048          stack->nst.feature |= FEATURE_NET_KEEPCALLS;
04049       }
04050    }
04051 #endif
04052 }

int misdn_lib_pid_restart ( int  pid  ) 

Definition at line 3836 of file isdn_lib.c.

References manager_clean_bc(), and manager_find_bc_by_pid().

Referenced by misdn_restart_pid().

03837 {
03838    struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
03839 
03840    if (bc) {
03841       manager_clean_bc(bc);
03842    }
03843    return 0;
03844 }

int misdn_lib_port_block ( 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.

Referenced by cb_events(), and misdn_port_block().

00070 {
00071    struct misdn_stack *stack=get_misdn_stack();
00072    for ( ; stack; stack=stack->next) {
00073       if (stack->port == port) {
00074          stack->blocked=1;
00075          return 0;
00076       }
00077    }
00078    return -1;
00079 
00080 }

int misdn_lib_port_is_pri ( int  port  ) 

Definition at line 47 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().

00048 {
00049    struct misdn_stack *stack=get_misdn_stack();
00050    for ( ; stack; stack=stack->next) {
00051       if (stack->port == port) {
00052          return stack->pri;
00053       }
00054    }
00055    
00056    return -1;
00057 }

int misdn_lib_port_restart ( int  port  ) 

Definition at line 3886 of file isdn_lib.c.

References misdn_lib::activatequeue, cb_log, clear_l3(), find_stack_by_port(), glob_mgr, misdn_lib_reinit_nt_stack(), misdn_lib::new_msg, misdn_stack::nt, misdn_stack::port, and misdn_stack::upper_id.

Referenced by misdn_restart_port().

03887 {
03888    struct misdn_stack *stack=find_stack_by_port(port);
03889  
03890    cb_log(0, port, "Restarting this port.\n");
03891    if (stack) {
03892       cb_log(0, port, "Stack:%p\n",stack);
03893          
03894       clear_l3(stack);
03895       {
03896          msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03897          iframe_t *frm;
03898 
03899          if (!msg) {
03900             cb_log(0, port, "port_restart: alloc_msg failed\n");
03901             return -1;
03902          }
03903          
03904          frm=(iframe_t*)msg->data;
03905          /* we must activate if we are deactivated */
03906          /* activate bchannel */
03907          frm->prim = DL_RELEASE | REQUEST;
03908          frm->addr = stack->upper_id | FLG_MSG_DOWN;
03909 
03910          frm->dinfo = 0;
03911          frm->len = 0;
03912          msg_queue_tail(&glob_mgr->activatequeue, msg);
03913          sem_post(&glob_mgr->new_msg);
03914       }
03915 
03916       if (stack->nt)
03917          misdn_lib_reinit_nt_stack(stack->port);
03918     
03919    }
03920 
03921    return 0;
03922 }

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 82 of file isdn_lib.c.

References misdn_stack::blocked, get_misdn_stack(), misdn_stack::next, and misdn_stack::port.

Referenced by misdn_port_unblock().

00083 {
00084    struct misdn_stack *stack=get_misdn_stack();
00085    for ( ; stack; stack=stack->next) {
00086       if (stack->port == port) {
00087          stack->blocked=0;
00088          return 0;
00089       }
00090    }
00091    return -1;
00092 
00093 }

int misdn_lib_port_up ( int  port,
int  check 
)

Definition at line 1776 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().

01777 {
01778    struct misdn_stack *stack;
01779 
01780 
01781    for (stack=glob_mgr->stack_list;
01782         stack;
01783         stack=stack->next) {
01784       
01785       if (stack->port == port) {
01786 
01787          if (stack->blocked) {
01788             cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
01789             return -1;
01790          }
01791 
01792          if (stack->ptp ) {
01793 
01794             if (stack->l1link && stack->l2link) {
01795                return 1;
01796             } else {
01797                cb_log(1,port, "Port Down L2:%d L1:%d\n",
01798                   stack->l2link, stack->l1link);
01799                return 0;
01800             }
01801          } else {
01802             if ( !check || stack->l1link )
01803                return 1;
01804             else {
01805                cb_log(1,port, "Port down PMP\n");
01806                return 0;
01807             }
01808          }
01809       }
01810    }
01811   
01812    return -1;
01813 }

void misdn_lib_reinit_nt_stack ( int  port  ) 

Definition at line 4676 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().

04677 {
04678    struct misdn_stack *stack=find_stack_by_port(port);
04679    
04680    if (stack) {
04681       stack->l2link=0;
04682       stack->blocked=0;
04683    
04684       cleanup_Isdnl3(&stack->nst);
04685       cleanup_Isdnl2(&stack->nst);
04686 
04687 
04688       memset(&stack->nst, 0, sizeof(net_stack_t));
04689       memset(&stack->mgr, 0, sizeof(manager_t));
04690    
04691       stack->mgr.nst = &stack->nst;
04692       stack->nst.manager = &stack->mgr;
04693     
04694       stack->nst.l3_manager = handle_event_nt;
04695       stack->nst.device = glob_mgr->midev;
04696       stack->nst.cardnr = port;
04697       stack->nst.d_stid = stack->d_stid;
04698    
04699       stack->nst.feature = FEATURE_NET_HOLD;
04700       if (stack->ptp)
04701          stack->nst.feature |= FEATURE_NET_PTP;
04702       if (stack->pri)
04703          stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
04704       
04705       stack->nst.l1_id = stack->lower_id;
04706       stack->nst.l2_id = stack->upper_id;
04707       
04708       msg_queue_init(&stack->nst.down_queue);
04709    
04710       Isdnl2Init(&stack->nst);
04711       Isdnl3Init(&stack->nst);
04712 
04713       if (!stack->ptp)
04714          misdn_lib_get_l1_up(stack);
04715       misdn_lib_get_l2_up(stack);
04716    }
04717 }

void misdn_lib_release ( struct misdn_bchannel bc  ) 

Definition at line 1716 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().

01717 {
01718    int channel;
01719    struct misdn_stack *stack=get_stack_by_bc(bc);
01720 
01721    if (!stack) {
01722       cb_log(1,0,"misdn_release: No Stack found\n");
01723       return;
01724    }
01725    
01726    channel = bc->channel;
01727    empty_bc(bc);
01728    clean_up_bc(bc);
01729    if (channel > 0) {
01730       empty_chan_in_stack(stack, channel);
01731    }
01732    bc->in_use=0;
01733 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Definition at line 3396 of file isdn_lib.c.

References misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_BRIDGED, BCHAN_CLEANED, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::channel_found, misdn_bchannel::channel_preselected, clean_up_bc(), misdn_bchannel::conf_id, create_process(), misdn_bchannel::crypt_key, misdn_bchannel::dad, misdn_bchannel::dnumplan, misdn_stack::downqueue, empty_bc(), empty_chan_in_stack(), ENOCHAN, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_HOLD_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), glob_mgr, misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), msgs_g, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_stack::nt, misdn_bchannel::nt, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_bchannel::port, misdn_stack::port, RETURN, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.

Referenced by cb_events(), do_immediate_setup(), handle_event(), handle_event_nt(), handle_frm(), handle_l1(), misdn_answer(), misdn_call(), misdn_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_lib_send_restart(), misdn_overlap_dial_task(), misdn_send_cd(), misdn_send_display(), misdn_send_text(), start_pbx(), and wait_for_digits().

03397 {
03398    msg_t *msg; 
03399    int retval=0;
03400    struct misdn_stack *stack;
03401    struct misdn_bchannel *held_bc;
03402   
03403    if (!bc) RETURN(-1,OUT_POST_UNLOCK);
03404    
03405    stack = get_stack_by_bc(bc);
03406    
03407    if (!stack) {
03408       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);
03409       RETURN(-1,OUT);
03410    }
03411    
03412    misdn_send_lock(bc);
03413 
03414 
03415    cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->upperid:%x\n",stack->nt, stack->upper_id);
03416 
03417    if ( stack->nt && !stack->l1link) {
03418       /** Queue Event **/
03419       bc->evq=event;
03420       cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
03421       misdn_lib_get_l1_up(stack);
03422       RETURN(0,OUT);
03423    }
03424    
03425    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);
03426    cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
03427    misdn_lib_log_ies(bc);
03428    
03429    switch (event) {
03430    case EVENT_SETUP:
03431       if (create_process(glob_mgr->midev, bc)<0) {
03432          cb_log(0,  stack->port, " No free channel at the moment @ send_event\n");
03433 
03434          RETURN(-ENOCHAN,OUT);
03435       }
03436       break;
03437 
03438    case EVENT_PROGRESS:
03439    case EVENT_ALERTING:
03440    case EVENT_PROCEEDING:
03441    case EVENT_SETUP_ACKNOWLEDGE:
03442    case EVENT_CONNECT:
03443       if (!stack->nt) break;
03444 
03445    case EVENT_RETRIEVE_ACKNOWLEDGE:
03446 
03447       if (stack->nt) {
03448          if (bc->channel <=0 ) { /*  else we have the channel already */
03449             if (find_free_chan_in_stack(stack, bc, 0, 0)<0) {
03450                cb_log(0, stack->port, " No free channel at the moment\n");
03451                /*FIXME: add disconnect*/
03452                RETURN(-ENOCHAN,OUT);
03453             }
03454          }
03455          /* Its that i generate channels */
03456       }
03457 
03458       retval=setup_bc(bc);
03459       if (retval == -EINVAL) {
03460          cb_log(0,bc->port,"send_event: setup_bc failed\n");
03461       }
03462 
03463       if (misdn_cap_is_speech(bc->capability)) {
03464          if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
03465             if ( *bc->crypt_key ) {
03466                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);
03467                
03468                manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
03469             }
03470             
03471             if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03472             manager_ec_enable(bc);
03473             
03474             if (bc->txgain != 0) {
03475                cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
03476                manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03477             }
03478             
03479             if ( bc->rxgain != 0 ) {
03480                cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
03481                manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03482             }
03483          }
03484       }
03485       break;
03486 
03487    case EVENT_HOLD_ACKNOWLEDGE:
03488       held_bc = malloc(sizeof(struct misdn_bchannel));
03489       if (!held_bc) {
03490          cb_log(0, bc->port, "Could not allocate held_bc!!!\n");
03491          RETURN(-1,OUT);
03492       }
03493 
03494       /* backup the bc and put it in storage */
03495       *held_bc = *bc;
03496       held_bc->holded = 1;
03497       held_bc->channel = 0;/* A held call does not have a channel anymore. */
03498       held_bc->channel_preselected = 0;
03499       held_bc->channel_found = 0;
03500       bc_state_change(held_bc, BCHAN_CLEANED);
03501       stack_holder_add(stack, held_bc);
03502    
03503       /* kill the bridge and clean the real b-channel record */
03504       if (stack->nt) {
03505          int channel;
03506          if (bc->bc_state == BCHAN_BRIDGED) {
03507             struct misdn_bchannel *bc2;
03508 
03509             misdn_split_conf(bc,bc->conf_id);
03510             bc2 = find_bc_by_confid(bc->conf_id);
03511             if (!bc2) {
03512                cb_log(0,bc->port,"We have no second bc in bridge???\n");
03513             } else {
03514                misdn_split_conf(bc2,bc->conf_id);
03515             }
03516          }
03517          
03518          channel = bc->channel;
03519 
03520          empty_bc(bc);
03521          clean_up_bc(bc);
03522 
03523          if (channel>0)
03524             empty_chan_in_stack(stack,channel);
03525 
03526          bc->in_use=0;  
03527       }
03528       break;
03529 
03530    /* finishing the channel eh ? */
03531    case EVENT_DISCONNECT:
03532       if (!bc->need_disconnect) {
03533          cb_log(0,bc->port," --> we have already send Disconnect\n");
03534          RETURN(-1,OUT);
03535       }
03536       
03537       bc->need_disconnect=0;
03538       break;
03539    case EVENT_RELEASE:
03540       if (!bc->need_release) {
03541          cb_log(0,bc->port," --> we have already send Release\n");
03542          RETURN(-1,OUT);
03543       }
03544       bc->need_disconnect=0;
03545       bc->need_release=0;
03546       break;
03547    case EVENT_RELEASE_COMPLETE:
03548       if (!bc->need_release_complete) {
03549          cb_log(0,bc->port," --> we have already send Release_complete\n");
03550          RETURN(-1,OUT);
03551       }
03552       bc->need_disconnect=0;
03553       bc->need_release=0;
03554       bc->need_release_complete=0;
03555 
03556       if (!stack->nt) {
03557          /*create cleanup in TE*/
03558          int channel=bc->channel;
03559 
03560          int tmpcause=bc->cause; 
03561          int tmp_out_cause=bc->out_cause; 
03562          empty_bc(bc);
03563          bc->cause=tmpcause;
03564          bc->out_cause=tmp_out_cause;
03565          clean_up_bc(bc);
03566          
03567          if (channel>0)
03568             empty_chan_in_stack(stack,channel);
03569          
03570          bc->in_use=0;
03571       }
03572       break;
03573     
03574    case EVENT_CONNECT_ACKNOWLEDGE:
03575 
03576       if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
03577          int retval=setup_bc(bc);
03578          if (retval == -EINVAL){
03579             cb_log(0,bc->port,"send_event: setup_bc failed\n");
03580             
03581          }
03582       }
03583       
03584       if (misdn_cap_is_speech(bc->capability)) {
03585          if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03586          manager_ec_enable(bc);
03587 
03588          if ( bc->txgain != 0 ) {
03589             cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
03590             manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03591          }
03592          if ( bc->rxgain != 0 ) {
03593             cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
03594             manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03595          }
03596       }
03597       break;
03598     
03599    default:
03600       break;
03601    }
03602   
03603    /* Later we should think about sending bchannel data directly to misdn. */
03604    msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
03605    msg_queue_tail(&stack->downqueue, msg);
03606    sem_post(&glob_mgr->new_msg);
03607   
03608 OUT:
03609    misdn_send_unlock(bc);
03610 
03611 OUT_POST_UNLOCK:
03612    return retval; 
03613 }

int misdn_lib_send_restart ( int  port,
int  channel 
)

Definition at line 3847 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_event_nt(), handle_frm(), and misdn_send_restart().

03848 {
03849    struct misdn_stack *stack=find_stack_by_port(port);
03850    struct misdn_bchannel dummybc;
03851    /*default is all channels*/
03852    cb_log(0, port, "Sending Restarts on this port.\n");
03853    
03854    misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
03855 
03856    /*default is all channels*/
03857    if (channel <0) {
03858       dummybc.channel=-1;
03859       cb_log(0, port, "Restarting and all Interfaces\n");
03860       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03861 
03862       return 0;
03863    }
03864 
03865    /*if a channel is specified we restart only this one*/
03866    if (channel >0) {
03867       int cnt;
03868       dummybc.channel=channel;
03869       cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
03870       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03871       /* clean up chan in stack, to be sure we don't think it's
03872        * in use anymore */
03873       for (cnt=0; cnt<=stack->b_num; cnt++) {
03874          if (stack->bc[cnt].in_use && stack->bc[cnt].channel == channel) {
03875             empty_bc(&stack->bc[cnt]);
03876             clean_up_bc(&stack->bc[cnt]);
03877             stack->bc[cnt].in_use=0;
03878          }
03879       }
03880    }
03881 
03882    return 0;
03883 }

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4494 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::bc, glob_mgr, manager_ph_control(), misdn_lib::midev, TONE_ALERTING, TONE_DIAL, TONE_HANGUP, and TONE_NONE.

Referenced by hanguptone_indicate().

04495 {
04496    char buf[mISDN_HEADER_LEN + 128] = "";
04497    iframe_t *frm = (iframe_t*)buf;
04498 
04499    switch(tone) {
04500    case TONE_DIAL:
04501       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 
04502    break;
04503    
04504    case TONE_ALERTING:
04505       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);  
04506    break;
04507    
04508    case TONE_HANGUP:
04509       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);   
04510    break;
04511 
04512    case TONE_NONE:
04513    default:
04514       manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);  
04515    }
04516 
04517    frm->prim=DL_DATA|REQUEST;
04518    frm->addr=bc->addr|FLG_MSG_DOWN;
04519    frm->dinfo=0;
04520    frm->len=128;
04521    
04522    mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
04523 }

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 973 of file isdn_lib.c.

References misdn_stack::bc, clean_up_bc(), and setup_bc().

00974 {
00975    clean_up_bc(bc);
00976    setup_bc(bc);
00977 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4648 of file isdn_lib.c.

References bc_state2str(), BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, and misdn_split_conf().

Referenced by misdn_bridge().

04649 {
04650 
04651    struct misdn_bchannel *bc_list[]={
04652       bc1,bc2,NULL
04653    };
04654    struct misdn_bchannel **bc;
04655       
04656    for (bc=bc_list; *bc;  bc++) { 
04657       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04658          misdn_split_conf( *bc, (*bc)->conf_id);
04659       } else {
04660          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04661       }
04662    }
04663    
04664 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2247 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02248 {
02249    bc->generate_tone=1;
02250 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2252 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02253 {
02254    bc->generate_tone=0;
02255 }

int misdn_lib_tx2misdn_frm ( struct misdn_bchannel bc,
void *  data,
int  len 
)

Definition at line 4278 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_bchannel::port, and misdn_stack::port.

Referenced by misdn_join_conf().

04279 {
04280    struct misdn_stack *stack=get_stack_by_bc(bc);
04281    char buf[4096 + mISDN_HEADER_LEN];
04282    iframe_t *frm = (iframe_t*)buf;
04283    int r;
04284 
04285    switch (bc->bc_state) {
04286       case BCHAN_ACTIVATED:
04287       case BCHAN_BRIDGED:
04288          break;
04289       default:
04290          cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
04291          return -1;
04292    }
04293    
04294    frm->prim = DL_DATA|REQUEST;
04295    frm->dinfo = 0;
04296    frm->addr = bc->addr | FLG_MSG_DOWN ;
04297    
04298    frm->len = len;
04299    memcpy(&buf[mISDN_HEADER_LEN], data,len);
04300       
04301    if ( misdn_cap_is_speech(bc->capability) ) 
04302       flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
04303    else
04304       cb_log(6, stack->port, "Writing %d data bytes\n",len);
04305    
04306    cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
04307    r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
04308    return 0;
04309 }

static void misdn_make_dummy ( struct misdn_bchannel dummybc,
int  port,
int  l3id,
int  nt,
int  channel 
) [static]

Definition at line 59 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_cr(), handle_event_nt(), handle_frm(), manager_event_handler(), misdn_lib_send_restart(), and release_cr().

00060 {
00061    memset (dummybc,0,sizeof(struct misdn_bchannel));
00062    dummybc->port=port;
00063    dummybc->l3_id=l3id;
00064    dummybc->nt=nt;
00065    dummybc->dummy=1;
00066    dummybc->channel=channel;
00067 }

static void misdn_send_lock ( struct misdn_bchannel bc  )  [static]

Definition at line 3382 of file isdn_lib.c.

References misdn_stack::bc, send_lock::lock, pthread_mutex_lock, and misdn_bchannel::send_lock.

Referenced by misdn_lib_send_event().

03383 {
03384    //cb_log(0,bc->port,"Locking bc->pid:%d\n", bc->pid);
03385    if (bc->send_lock)
03386       pthread_mutex_lock(&bc->send_lock->lock);
03387 }

static void misdn_send_unlock ( struct misdn_bchannel bc  )  [static]

Definition at line 3389 of file isdn_lib.c.

References misdn_stack::bc, send_lock::lock, pthread_mutex_unlock, and misdn_bchannel::send_lock.

Referenced by misdn_lib_send_event().

03390 {
03391    //cb_log(0,bc->port,"UnLocking bc->pid:%d\n", bc->pid);
03392    if (bc->send_lock)
03393       pthread_mutex_unlock(&bc->send_lock->lock);
03394 }

void misdn_split_conf ( struct misdn_bchannel bc,
int  conf_id 
)

Definition at line 4616 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::bc, bc_state_change(), BCHAN_ACTIVATED, cb_log, manager_ph_control(), and misdn_bchannel::port.

Referenced by manager_bchannel_deactivate(), misdn_lib_send_event(), and misdn_lib_split_bridge().

04617 {
04618    bc_state_change(bc,BCHAN_ACTIVATED);
04619    manager_ph_control(bc, CMX_RECEIVE_ON, 0);
04620    manager_ph_control(bc, CMX_CONF_SPLIT, conf_id);
04621 
04622    cb_log(4,bc->port, "Splitting bc:%x in conf:%d\n",bc->addr,conf_id);
04623 }

void misdn_tx_jitter ( struct misdn_bchannel bc,
int  len 
)

Definition at line 2302 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::bframe, misdn_bchannel::bframe_len, cb_jb_empty, cb_log, misdn_bchannel::channel, errno, flip_buf_bits(), glob_mgr, misdn_lib::midev, misdn_bchannel::port, and tone_silence_flip.

Referenced by do_tone(), and handle_bchan().

02303 {
02304    char buf[4096 + mISDN_HEADER_LEN];
02305    char *data=&buf[mISDN_HEADER_LEN];
02306    iframe_t *txfrm= (iframe_t*)buf;
02307    int jlen, r;
02308    
02309    jlen=cb_jb_empty(bc,data,len);
02310    
02311    if (jlen) {
02312 #ifdef MISDN_SAVE_DATA
02313       misdn_save_data((bc->port*100+bc->channel), data, jlen, bc->bframe, bc->bframe_len);
02314 #endif
02315       flip_buf_bits( data, jlen);
02316       
02317       if (jlen < len) {
02318          cb_log(1, bc->port, "Jitterbuffer Underrun. Got %d of expected %d\n", jlen, len);
02319       }
02320       
02321       txfrm->prim = DL_DATA|REQUEST;
02322       
02323       txfrm->dinfo = 0;
02324       
02325       txfrm->addr = bc->addr|FLG_MSG_DOWN; /*  | IF_DOWN; */
02326       
02327       txfrm->len =jlen;
02328       cb_log(9, bc->port, "Transmitting %d samples 2 misdn\n", txfrm->len);
02329 
02330       r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
02331    } else {
02332 #define MISDN_GEN_SILENCE
02333 #ifdef MISDN_GEN_SILENCE
02334       int cnt=len/TONE_SILENCE_SIZE;
02335       int rest=len%TONE_SILENCE_SIZE;
02336       int i;
02337 
02338       for (i=0; i<cnt; i++) {
02339          memcpy(data, tone_silence_flip, TONE_SILENCE_SIZE );
02340          data +=TONE_SILENCE_SIZE;
02341       }
02342 
02343       if (rest) {
02344          memcpy(data, tone_silence_flip, rest);
02345       }
02346 
02347       txfrm->prim = DL_DATA|REQUEST;
02348 
02349       txfrm->dinfo = 0;
02350 
02351       txfrm->addr = bc->addr|FLG_MSG_DOWN; /*  | IF_DOWN; */
02352 
02353       txfrm->len =len;
02354       cb_log(5, bc->port, "Transmitting %d samples of silence to misdn\n", len);
02355 
02356       r=mISDN_write( glob_mgr->midev, buf, txfrm->len + mISDN_HEADER_LEN, 8000 );
02357 #else
02358       r = 0;
02359 #endif
02360    }
02361 
02362    if (r < 0) {
02363       cb_log(1, bc->port, "Error in mISDN_write (%s)\n", strerror(errno));
02364    }
02365 }

static void prepare_bc ( struct misdn_bchannel bc,
int  channel 
) [static]

Definition at line 3198 of file isdn_lib.c.

References misdn_bchannel::addr, AST_CAUSE_NORMAL_CLEARING, misdn_bchannel::b_stid, misdn_bchannel::cause, misdn_bchannel::channel, misdn_bchannel::channel_preselected, misdn_bchannel::in_use, misdn_bchannel::layer_id, mypid, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, and misdn_bchannel::pid.

Referenced by misdn_lib_get_free_bc().

03199 {
03200    bc->channel = channel;
03201    bc->channel_preselected = channel?1:0;
03202    bc->need_disconnect=1;
03203    bc->need_release=1;
03204    bc->need_release_complete=1;
03205    bc->cause = AST_CAUSE_NORMAL_CLEARING;
03206 
03207    if (++mypid>5000) mypid=1;
03208    bc->pid=mypid;
03209 
03210 #if 0
03211    bc->addr=0;
03212    bc->b_stid=0;
03213    bc->layer_id=0;
03214 #endif
03215 
03216    bc->in_use = 1;
03217 }

int queue_cleanup_bc ( struct misdn_bchannel bc  ) 

Definition at line 3811 of file isdn_lib.c.

References misdn_lib::activatequeue, misdn_stack::bc, cb_log, glob_mgr, misdn_bchannel::l3_id, misdn_lib::new_msg, and misdn_bchannel::port.

03812 {
03813    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03814    iframe_t *frm;
03815    if (!msg) {
03816       cb_log(0, bc->port, "queue_cleanup_bc: alloc_msg failed!\n");
03817       return -1;
03818    }
03819    frm=(iframe_t*)msg->data;
03820 
03821    /* activate bchannel */
03822    frm->prim = MGR_CLEARSTACK| REQUEST;
03823 
03824    frm->addr = bc->l3_id;
03825 
03826    frm->dinfo = bc->port;
03827    frm->len = 0;
03828   
03829    msg_queue_tail(&glob_mgr->activatequeue, msg);
03830    sem_post(&glob_mgr->new_msg);
03831 
03832    return 0; 
03833 
03834 }

int release_cr ( struct misdn_stack stack,
mISDNuser_head_t *  hh 
)

Definition at line 1816 of file isdn_lib.c.

References misdn_bchannel::addr, cb_log, find_bc_by_l3id(), handle_cr(), misdn_bchannel::l3_id, misdn_make_dummy(), misdn_stack::nt, misdn_stack::port, misdn_stack::procids, and misdn_stack::upper_id.

Referenced by handle_event_nt().

01817 {
01818    struct misdn_bchannel *bc=find_bc_by_l3id(stack, hh->dinfo);
01819    struct misdn_bchannel dummybc;
01820    iframe_t frm; /* fake te frm to remove callref from global callreflist */
01821    frm.dinfo = hh->dinfo;
01822 
01823    frm.addr=stack->upper_id | FLG_MSG_DOWN;
01824 
01825    frm.prim = CC_RELEASE_CR|INDICATION;
01826    cb_log(4, stack->port, " --> CC_RELEASE_CR: Faking Release_cr for %x l3id:%x\n",frm.addr, frm.dinfo);
01827    /** removing procid **/
01828    if (!bc) {
01829       cb_log(4, stack->port, " --> Didn't find BC so temporarily creating dummy BC (l3id:%x) on this port.\n", hh->dinfo);
01830       misdn_make_dummy(&dummybc, stack->port, hh->dinfo, stack->nt, 0);
01831       bc=&dummybc; 
01832    }
01833 
01834    if (bc) {
01835       if ( (bc->l3_id & 0xff00) == 0xff00) {
01836          cb_log(4, stack->port, " --> Removing Process Id:%x on this port.\n", bc->l3_id&0xff);
01837          stack->procids[bc->l3_id&0xff] = 0 ;
01838       }
01839    }
01840    else cb_log(0, stack->port, "Couldn't find BC so I couldn't remove the Process!!!! this is a bad port.\n");
01841 
01842    if (handle_cr(stack, &frm)<0) {
01843    }
01844 
01845    return 0 ;
01846 }

static int send_msg ( int  midev,
struct misdn_bchannel bc,
msg_t *  dmsg 
) [static]

Definition at line 388 of file isdn_lib.c.

References cb_log, get_stack_by_bc(), misdn_bchannel::l3_id, and misdn_bchannel::port.

Referenced by manager_event_handler().

00389 {
00390    iframe_t *frm = (iframe_t *)dmsg->data;
00391    struct misdn_stack *stack=get_stack_by_bc(bc);
00392 
00393    if (!stack) {
00394       cb_log(0,bc->port,"send_msg: IEK!! no stack\n ");
00395       return -1;
00396    }
00397    
00398    frm->addr = (stack->upper_id | FLG_MSG_DOWN);
00399    frm->dinfo = bc->l3_id;
00400    frm->len = (dmsg->len) - mISDN_HEADER_LEN;
00401             
00402    cb_log(4,stack->port,"Sending msg, prim:%x addr:%x dinfo:%x\n",frm->prim,frm->addr,frm->dinfo);
00403 
00404    mISDN_write(midev, dmsg->data, dmsg->len, TIMEOUT_1SEC);
00405    free_msg(dmsg);
00406 
00407    return 0;
00408 }

static int set_chan_in_stack ( struct misdn_stack stack,
int  channel 
) [static]

Definition at line 461 of file isdn_lib.c.

References cb_log, misdn_stack::channels, dump_chan_list(), MAX_BCHANS, and misdn_stack::port.

00462 {
00463 
00464    cb_log(4,stack->port,"set_chan_in_stack: %d\n",channel);
00465    dump_chan_list(stack);
00466    if (channel >=1 && channel <= MAX_BCHANS) {
00467       if (!stack->channels[channel-1])
00468          stack->channels[channel-1] = 1;
00469       else {
00470          cb_log(4,stack->port,"channel already in use:%d\n", channel );
00471          return -1;
00472       }
00473    } else {
00474       cb_log(0,stack->port,"couldn't set channel %d in\n", channel );
00475       return -1;
00476    }
00477   
00478    return 0;
00479 }

int setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 980 of file isdn_lib.c.

References misdn_stack::b_num, misdn_bchannel::b_stid, misdn_stack::b_stids, misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), BCHAN_CLEANED, cb_log, misdn_bchannel::channel, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.

Referenced by handle_event(), misdn_lib_send_event(), and misdn_lib_setup_bc().

00981 {
00982    unsigned char buff[1025];
00983    int midev;
00984    int channel;
00985    int b_stid;
00986    int i;
00987    mISDN_pid_t pid;
00988    int ret;
00989 
00990    struct misdn_stack *stack=get_stack_by_bc(bc);
00991 
00992    if (!stack) {
00993       cb_log(0, bc->port, "setup_bc: NO STACK FOUND!!\n");
00994       return -1;
00995    }
00996    
00997    midev = stack->midev;
00998    channel = bc->channel - 1 - (bc->channel > 16);
00999    b_stid = stack->b_stids[channel >= 0 ? channel : 0];
01000 
01001    switch (bc->bc_state) {
01002       case BCHAN_CLEANED:
01003          break;
01004       default:
01005          cb_log(4, stack->port, "$$$ bc already setup stid :%x (state:%s)\n", b_stid, bc_state2str(bc->bc_state) );
01006          return -1;
01007    }
01008    
01009    cb_log(5, stack->port, "$$$ Setting up bc with stid :%x\n", b_stid);
01010    
01011    /*check if the b_stid is already initialized*/
01012    for (i=0; i <= stack->b_num; i++) {
01013       if (stack->bc[i].b_stid == b_stid) {
01014          cb_log(0, bc->port, "setup_bc: b_stid:%x already in use !!!\n", b_stid);
01015          return -1;
01016       }
01017    }
01018    
01019    if (b_stid <= 0) {
01020       cb_log(0, stack->port," -- Stid <=0 at the moment in channel:%d\n",channel);
01021       
01022       bc_state_change(bc,BCHAN_ERROR);
01023       return 1;
01024    }
01025 
01026    bc->b_stid = b_stid;
01027 
01028    {
01029       layer_info_t li;
01030       memset(&li, 0, sizeof(li));
01031     
01032       li.object_id = -1;
01033       li.extentions = 0;
01034       
01035       li.st = bc->b_stid; /*  given idx */
01036 
01037 
01038 #define MISDN_DSP
01039 #ifndef MISDN_DSP
01040       bc->nodsp=1;
01041 #endif
01042       if ( bc->hdlc || bc->nodsp) {
01043          cb_log(4, stack->port,"setup_bc: without dsp\n");
01044          { 
01045             int l = sizeof(li.name);
01046             strncpy(li.name, "B L3", l);
01047             li.name[l-1] = 0;
01048          }
01049          li.pid.layermask = ISDN_LAYER((3));
01050          li.pid.protocol[3] = ISDN_PID_L3_B_USER;
01051          
01052          bc->layer=3;
01053       } else {
01054          cb_log(4, stack->port,"setup_bc: with dsp\n");
01055          { 
01056             int l = sizeof(li.name);
01057             strncpy(li.name, "B L4", l);
01058             li.name[l-1] = 0;
01059          }
01060          li.pid.layermask = ISDN_LAYER((4));
01061          li.pid.protocol[4] = ISDN_PID_L4_B_USER;
01062 
01063          bc->layer=4;
01064       }  
01065       
01066       ret = mISDN_new_layer(midev, &li);
01067       if (ret ) {
01068          cb_log(0, stack->port,"New Layer Err: %d %s\n",ret,strerror(errno));
01069 
01070          bc_state_change(bc,BCHAN_ERROR);
01071          return(-EINVAL);
01072       }
01073       
01074       bc->layer_id = li.id;
01075    }
01076    
01077    memset(&pid, 0, sizeof(pid));
01078    
01079    
01080    
01081    cb_log(4, stack->port," --> Channel is %d\n", bc->channel);
01082    
01083    if (bc->nodsp) {
01084       cb_log(2, stack->port," --> TRANSPARENT Mode (no DSP, no HDLC)\n");
01085       pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
01086       pid.protocol[2] = ISDN_PID_L2_B_TRANS;
01087       pid.protocol[3] = ISDN_PID_L3_B_USER;
01088       pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3));
01089       
01090    } else if ( bc->hdlc ) {
01091       cb_log(2, stack->port," --> HDLC Mode\n");
01092       pid.protocol[1] = ISDN_PID_L1_B_64HDLC ;
01093       pid.protocol[2] = ISDN_PID_L2_B_TRANS  ;
01094       pid.protocol[3] = ISDN_PID_L3_B_USER;
01095       pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) ;
01096    } else {
01097       cb_log(2, stack->port," --> TRANSPARENT Mode\n");
01098       pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
01099       pid.protocol[2] = ISDN_PID_L2_B_TRANS;
01100       pid.protocol[3] = ISDN_PID_L3_B_DSP;
01101       pid.protocol[4] = ISDN_PID_L4_B_USER;
01102       pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4));
01103       
01104    } 
01105 
01106    ret = mISDN_set_stack(midev, bc->b_stid, &pid);
01107 
01108    if (ret){
01109       cb_log(0, stack->port,"$$$ Set Stack Err: %d %s\n",ret,strerror(errno));
01110       
01111       mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
01112       
01113       bc_state_change(bc,BCHAN_ERROR);
01114       cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
01115       return(-EINVAL);
01116    }
01117 
01118    ret = mISDN_get_setstack_ind(midev, bc->layer_id);
01119 
01120    if (ret) {
01121       cb_log(0, stack->port,"$$$ Set StackIND Err: %d %s\n",ret,strerror(errno));
01122       mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
01123       
01124       bc_state_change(bc,BCHAN_ERROR);
01125       cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
01126       return(-EINVAL);
01127    }
01128 
01129    ret = mISDN_get_layerid(midev, bc->b_stid, bc->layer) ;
01130 
01131    bc->addr = ret>0? ret : 0;
01132 
01133    if (!bc->addr) {
01134       cb_log(0, stack->port,"$$$ Get Layerid Err: %d %s\n",ret,strerror(errno));
01135       mISDN_write_frame(midev, buff, bc->layer_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
01136       
01137       bc_state_change(bc,BCHAN_ERROR);
01138       cb_event(EVENT_BCHAN_ERROR, bc, glob_mgr->user_data);
01139       return (-EINVAL);
01140    }
01141 
01142    manager_bchannel_activate(bc);
01143    
01144    bc_state_change(bc,BCHAN_ACTIVATED);
01145 
01146    return 0;
01147 }

static void stack_destroy ( struct misdn_stack stack  )  [static]

Definition at line 1409 of file isdn_lib.c.

References misdn_stack::lower_id, misdn_stack::midev, misdn_stack::nst, misdn_stack::nstlock, misdn_stack::nt, pthread_mutex_destroy, misdn_stack::st_lock, and misdn_stack::upper_id.

Referenced by misdn_lib_destroy().

01410 {
01411    char buf[1024];
01412    if (!stack) return;
01413 
01414    if (stack->nt) {
01415       pthread_mutex_destroy(&stack->nstlock);
01416       cleanup_Isdnl2(&stack->nst);
01417       cleanup_Isdnl3(&stack->nst);
01418    }
01419   
01420    if (stack->lower_id) 
01421       mISDN_write_frame(stack->midev, buf, stack->lower_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
01422 
01423    if (stack->upper_id) 
01424       mISDN_write_frame(stack->midev, buf, stack->upper_id, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
01425 
01426    pthread_mutex_destroy(&stack->st_lock);
01427 }

void stack_holder_add ( struct misdn_stack stack,
struct misdn_bchannel holder 
)

Definition at line 4399 of file isdn_lib.c.

References cb_log, misdn_stack::holding, misdn_bchannel::l3_id, misdn_bchannel::next, misdn_stack::port, and misdn_bchannel::stack_holder.

Referenced by misdn_lib_send_event().

04400 {
04401    struct misdn_bchannel *help;
04402    cb_log(4,stack->port, "*HOLDER: add %x\n",holder->l3_id);
04403    
04404    holder->stack_holder=1;
04405    holder->next=NULL;
04406    
04407    if (!stack->holding) {
04408       stack->holding = holder;
04409       return;
04410    }
04411   
04412    for (help=stack->holding;
04413         help;
04414         help=help->next) {
04415       if (!help->next) {
04416          help->next=holder;
04417          break;
04418       }
04419    }
04420   
04421 }

struct misdn_bchannel * stack_holder_find ( struct misdn_stack stack,
unsigned long  l3id 
)

Definition at line 4449 of file isdn_lib.c.

References cb_log, misdn_stack::holding, misdn_bchannel::l3_id, misdn_bchannel::next, and misdn_stack::port.

Referenced by handle_event_nt(), and misdn_lib_find_held_bc().

04450 {
04451    struct misdn_bchannel *help;
04452 
04453    cb_log(4,stack?stack->port:0, "*HOLDER: find %lx\n",l3id);
04454    
04455    if (!stack) return NULL;
04456    
04457    for (help=stack->holding;
04458         help;
04459         help=help->next) {
04460       if (help->l3_id == l3id) {
04461          cb_log(4,stack->port, "*HOLDER: found bc\n");
04462          return help;
04463       }
04464    }
04465 
04466    cb_log(4,stack->port, "*HOLDER: find nothing\n");
04467    return NULL;
04468 }

void stack_holder_remove ( struct misdn_stack stack,
struct misdn_bchannel holder 
)

Definition at line 4423 of file isdn_lib.c.

References cb_log, misdn_stack::holding, misdn_bchannel::l3_id, misdn_bchannel::next, misdn_stack::port, and misdn_bchannel::stack_holder.

Referenced by handle_cr(), and handle_event_nt().

04424 {
04425    struct misdn_bchannel *h1;
04426 
04427    if (!holder->stack_holder) return;
04428    
04429    holder->stack_holder=0;
04430    
04431    cb_log(4,stack->port, "*HOLDER: remove %x\n",holder->l3_id);
04432    if (!stack || ! stack->holding) return;
04433   
04434    if (holder == stack->holding) {
04435       stack->holding = stack->holding->next;
04436       return;
04437    }
04438    
04439    for (h1=stack->holding;
04440         h1;
04441         h1=h1->next) {
04442       if (h1->next == holder) {
04443          h1->next=h1->next->next;
04444          return ;
04445       }
04446    }
04447 }

static struct misdn_stack* stack_init ( int  midev,
int  port,
int  ptp 
) [static]

Definition at line 1221 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::b_stids, cb_log, misdn_stack::channels, misdn_stack::d_stid, misdn_stack::downqueue, misdn_stack::holding, malloc, MAX_BCHANS, misdn_stack::midev, misdn_stack::nt, misdn_stack::port, misdn_stack::pri, pthread_mutex_init, misdn_stack::ptp, misdn_stack::st_lock, and misdn_stack::upqueue.

Referenced by misdn_lib_init().

01222 {
01223    int ret;
01224    unsigned char buff[1025];
01225    iframe_t *frm = (iframe_t *)buff;
01226    stack_info_t *stinf;
01227    int i; 
01228    layer_info_t li;
01229 
01230    struct misdn_stack *stack = malloc(sizeof(struct misdn_stack));
01231    if (!stack ) return NULL;
01232 
01233 
01234    cb_log(8, port, "Init. Stack.\n");
01235   
01236    memset(stack,0,sizeof(struct misdn_stack));
01237   
01238    for (i=0; i<MAX_BCHANS + 1; i++ ) stack->channels[i]=0;
01239    
01240    stack->port=port;
01241    stack->midev=midev;
01242    stack->ptp=ptp;
01243   
01244    stack->holding=NULL;
01245    stack->pri=0;
01246   
01247    msg_queue_init(&stack->downqueue);
01248    msg_queue_init(&stack->upqueue);
01249 
01250    pthread_mutex_init(&stack->st_lock, NULL);
01251   
01252    /* query port's requirements */
01253    ret = mISDN_get_stack_info(midev, port, buff, sizeof(buff));
01254    if (ret < 0) {
01255       cb_log(0, port, "%s: Cannot get stack info for this port. (ret=%d)\n", __FUNCTION__, ret);
01256       return(NULL);
01257    }
01258   
01259    stinf = (stack_info_t *)&frm->data.p;
01260 
01261    stack->d_stid = stinf->id;
01262    stack->b_num = stinf->childcnt;
01263 
01264    for (i=0; i<=stinf->childcnt; i++)
01265       stack->b_stids[i] = stinf->child[i];
01266   
01267    switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK) {
01268    case ISDN_PID_L0_TE_S0:
01269       stack->nt=0;
01270       break;
01271    case ISDN_PID_L0_NT_S0:
01272       cb_log(8, port, "NT Stack\n");
01273 
01274       stack->nt=1;
01275       break;
01276    case ISDN_PID_L0_TE_E1:
01277       cb_log(8, port, "TE S2M Stack\n");
01278       stack->nt=0;
01279       stack->pri=1;
01280       break;
01281    case ISDN_PID_L0_NT_E1:
01282       cb_log(8, port, "TE S2M Stack\n");
01283       stack->nt=1;
01284       stack->pri=1;
01285       
01286       break;
01287    default:
01288       cb_log(0, port, "this is a unknown port type 0x%08x\n", stinf->pid.protocol[0]);
01289 
01290    }
01291 
01292    if (!stack->nt) {
01293       if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP ) { 
01294          stack->ptp = 1;
01295       } else {
01296          stack->ptp = 0;
01297       }
01298    }
01299    
01300    {
01301       int ret;
01302       int nt=stack->nt;
01303 
01304       cb_log(8, port, "Init. Stack.\n");
01305       
01306       memset(&li, 0, sizeof(li));
01307       {
01308          int l = sizeof(li.name);
01309          strncpy(li.name,nt?"net l2":"user l4", l);
01310          li.name[l-1] = 0;
01311       }
01312       li.object_id = -1;
01313       li.extentions = 0;
01314       li.pid.protocol[nt?2:4] = nt?ISDN_PID_L2_LAPD_NET:ISDN_PID_L4_CAPI20;
01315       li.pid.layermask = ISDN_LAYER((nt?2:4));
01316       li.st = stack->d_stid;
01317       
01318       
01319       ret = mISDN_new_layer(midev, &li);
01320       if (ret) {
01321          cb_log(0, port, "%s: Cannot add layer %d to this port.\n", __FUNCTION__, nt?2:4);
01322          return(NULL);
01323       }
01324       
01325       
01326       stack->upper_id = li.id;
01327       ret = mISDN_register_layer(midev, stack->d_stid, stack->upper_id);
01328       if (ret)
01329       {
01330          cb_log(0,port,"Cannot register layer %d of this port.\n", nt?2:4);
01331          return(NULL);
01332       }
01333       
01334       stack->lower_id = mISDN_get_layerid(midev, stack->d_stid, nt?1:3); 
01335       if (stack->lower_id < 0) {
01336          cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, nt?1:3);
01337          return(NULL);
01338       }
01339       
01340       stack->upper_id = mISDN_get_layerid(midev, stack->d_stid, nt?2:4);
01341       if (stack->upper_id < 0) {
01342          cb_log(0, port, "%s: Cannot get layer(%d) id of this port.\n", __FUNCTION__, 2);
01343          return(NULL);
01344       }
01345       
01346       cb_log(8, port, "NT Stacks upper_id %x\n",stack->upper_id);
01347       
01348       
01349       /* create nst (nt-mode only) */
01350       if (nt) {
01351          
01352          memset(&stack->nst, 0, sizeof(net_stack_t));
01353          memset(&stack->mgr, 0, sizeof(manager_t));
01354     
01355          stack->mgr.nst = &stack->nst;
01356          stack->nst.manager = &stack->mgr;
01357     
01358          stack->nst.l3_manager = handle_event_nt;
01359          stack->nst.device = midev;
01360          stack->nst.cardnr = port;
01361          stack->nst.d_stid = stack->d_stid;
01362     
01363          stack->nst.feature = FEATURE_NET_HOLD;
01364          if (stack->ptp)
01365             stack->nst.feature |= FEATURE_NET_PTP;
01366          if (stack->pri)
01367             stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
01368          
01369          stack->nst.l1_id = stack->lower_id;
01370          stack->nst.l2_id = stack->upper_id;
01371          
01372          msg_queue_init(&stack->nst.down_queue);
01373          pthread_mutex_init(&stack->nstlock, NULL);
01374          
01375          Isdnl2Init(&stack->nst);
01376          Isdnl3Init(&stack->nst);
01377          
01378       } 
01379       
01380       if (!stack->nt) {
01381          /*assume L1 is up, we'll get DEACTIVATES soon, for non
01382           * up L1s*/
01383          stack->l1link=0;
01384       }
01385       stack->l1link=0;
01386       stack->l2link=0;
01387 #if 0 
01388       if (!stack->nt) {
01389          misdn_lib_get_short_status(stack);
01390       } else {
01391          misdn_lib_get_l1_up(stack);
01392          if (!stack->ptp) misdn_lib_get_l1_up(stack);
01393          misdn_lib_get_l2_up(stack);
01394       }
01395 #endif
01396 
01397       misdn_lib_get_short_status(stack);
01398       misdn_lib_get_l1_up(stack);
01399       misdn_lib_get_l2_up(stack); 
01400       
01401    }
01402 
01403    cb_log(8,0,"stack_init: port:%d lowerId:%x  upperId:%x\n",stack->port,stack->lower_id, stack->upper_id);
01404    
01405    return stack;
01406 }

void te_lib_destroy ( int  midev  ) 

Definition at line 3152 of file isdn_lib.c.

References cb_log, and entity.

Referenced by misdn_lib_destroy().

03153 {
03154    char buf[1024];
03155    mISDN_write_frame(midev, buf, 0, MGR_DELENTITY | REQUEST, entity, 0, NULL, TIMEOUT_1SEC);
03156 
03157    cb_log(4, 0, "Entity deleted\n");
03158    mISDN_close(midev);
03159    cb_log(4, 0, "midev closed\n");
03160 }

int te_lib_init ( void   ) 

App Interface

Definition at line 3125 of file isdn_lib.c.

References entity, errno, and misdn_lib::midev.

Referenced by misdn_lib_init().

03125                   {
03126    char buff[1025] = "";
03127    iframe_t *frm=(iframe_t*)buff;
03128    int midev=mISDN_open();
03129    int ret;
03130 
03131    if  (midev<=0) return midev;
03132   
03133 /* create entity for layer 3 TE-mode */
03134    mISDN_write_frame(midev, buff, 0, MGR_NEWENTITY | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
03135    ret = mISDN_read_frame(midev, frm, sizeof(iframe_t), 0, MGR_NEWENTITY | CONFIRM, TIMEOUT_1SEC);
03136   
03137    if (ret < mISDN_HEADER_LEN) {
03138    noentity:
03139       fprintf(stderr, "cannot request MGR_NEWENTITY from mISDN: %s\n",strerror(errno));
03140       exit(-1);
03141    }
03142   
03143    entity = frm->dinfo & 0xffff ;
03144   
03145    if (!entity)
03146       goto noentity;
03147 
03148    return midev;
03149   
03150 }

static int test_inuse ( struct misdn_bchannel bc  )  [static]

Definition at line 3178 of file isdn_lib.c.

References misdn_bchannel::b_stid, cb_log, misdn_bchannel::in_use, misdn_bchannel::last_used, misdn_lib_port_is_pri(), and misdn_bchannel::port.

Referenced by misdn_lib_get_free_bc().

03179 {
03180    struct timeval now;
03181    gettimeofday(&now, NULL);
03182    if (!bc->in_use) {
03183       if (misdn_lib_port_is_pri(bc->port) && bc->last_used.tv_sec == now.tv_sec ) {
03184          cb_log(2,bc->port, "channel with stid:%x for one second still in use! (n:%d lu:%d)\n", bc->b_stid, (int) now.tv_sec, (int) bc->last_used.tv_sec);
03185          return 1;
03186       }
03187       
03188 
03189       cb_log(3,bc->port, "channel with stid:%x not in use!\n", bc->b_stid);
03190       return 0;
03191    }
03192    
03193    cb_log(2,bc->port, "channel with stid:%x in use!\n", bc->b_stid);
03194    return 1;
03195 }


Variable Documentation

int entity [static]

Definition at line 236 of file isdn_lib.c.

Referenced by te_lib_destroy(), and te_lib_init().

char flip_table[256] [static]

Definition at line 297 of file isdn_lib.c.

Referenced by flip_buf_bits(), and init_flip_bits().

struct misdn_lib* glob_mgr [static]

Definition at line 238 of file isdn_lib.c.

Referenced by do_tone(), find_bc_by_addr(), find_bc_by_confid(), find_stack_by_addr(), find_stack_by_mgr(), find_stack_by_port(), get_misdn_stack(), handle_bchan(), handle_cr(), handle_event_nt(), handle_frm(), handle_l1(), handle_l2(), handle_timers(), manager_event_handler(), manager_find_bc_by_pid(), manager_ph_control(), manager_ph_control_block(), misdn_lib_destroy(), misdn_lib_get_free_bc(), misdn_lib_get_port_down(), misdn_lib_get_port_info(), misdn_lib_get_port_up(), misdn_lib_init(), misdn_lib_isdn_l1watcher(), misdn_lib_port_restart(), misdn_lib_port_up(), misdn_lib_reinit_nt_stack(), misdn_lib_send_event(), misdn_lib_send_tone(), misdn_tx_jitter(), and queue_cleanup_bc().

enum global_states global_state = MISDN_INITIALIZING [static]

Definition at line 172 of file isdn_lib.c.

Referenced by clear_l3(), handle_l1(), and misdn_lib_destroy().

sem_t handler_started

Definition at line 3926 of file isdn_lib.c.

struct isdn_msg msgs_g[]

Msg Array

Definition at line 1158 of file isdn_msg_parser.c.

Referenced by handle_event_nt(), handle_frm(), handle_l1(), manager_isdn_get_info(), and misdn_lib_send_event().

int mypid = 1 [static]

Definition at line 411 of file isdn_lib.c.

Referenced by prepare_bc().

int new_te_id = 0 [static]

Definition at line 793 of file isdn_lib.c.

int nt_err_cnt = 0 [static]

Definition at line 165 of file isdn_lib.c.

Referenced by handle_frm_nt().

char tone_425_flip[TONE_425_SIZE]

Definition at line 240 of file isdn_lib.c.

Referenced by misdn_lib_init().

char tone_silence_flip[TONE_SILENCE_SIZE]

Definition at line 241 of file isdn_lib.c.

Referenced by misdn_lib_init(), and misdn_tx_jitter().


Generated on Sat Aug 6 00:39:58 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7