Wed Mar 3 23:01:00 2010

Asterisk developer's documentation


isdn_lib.h File Reference

Interface to mISDN. More...

#include <mISDNuser/suppserv.h>
Include dependency graph for isdn_lib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  misdn_bchannel
struct  misdn_lib_iface

Defines

#define MAX_BCHANS   31
#define PRI_TRANS_CAP_3_1K_AUDIO   0x10
#define PRI_TRANS_CAP_7K_AUDIO   0x11
#define PRI_TRANS_CAP_DIGITAL   0x08
#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09
#define PRI_TRANS_CAP_SPEECH   0x0

Enumerations

enum  {
  INFO_CAPABILITY_SPEECH = 0, INFO_CAPABILITY_AUDIO_3_1K = 0x10, INFO_CAPABILITY_AUDIO_7K = 0x11, INFO_CAPABILITY_VIDEO = 0x18,
  INFO_CAPABILITY_DIGITAL_UNRESTRICTED = 0x8, INFO_CAPABILITY_DIGITAL_RESTRICTED = 0x09, INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES
}
enum  {
  INFO_PI_CALL_NOT_E2E_ISDN = 0x01, INFO_PI_CALLED_NOT_ISDN = 0x02, INFO_PI_CALLER_NOT_ISDN = 0x03, INFO_PI_CALLER_RETURNED_TO_ISDN = 0x04,
  INFO_PI_INBAND_AVAILABLE = 0x08, INFO_PI_DELAY_AT_INTERF = 0x0a, INFO_PI_INTERWORKING_WITH_PUBLIC = 0x10, INFO_PI_INTERWORKING_NO_RELEASE = 0x11,
  INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER = 0x12, INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER = 0x13
}
enum  { INFO_CODEC_ULAW = 2, INFO_CODEC_ALAW = 3 }
enum  bchannel_state {
  BCHAN_CLEANED = 0, BCHAN_EMPTY, BCHAN_SETUP, BCHAN_SETUPED,
  BCHAN_ACTIVE, BCHAN_ACTIVATED, BCHAN_BRIDGE, BCHAN_BRIDGED,
  BCHAN_RELEASE, BCHAN_RELEASED, BCHAN_CLEAN, BCHAN_CLEAN_REQUEST,
  BCHAN_ERROR
}
enum  event_e {
  EVENT_NOTHING, EVENT_TONE_GENERATE, EVENT_BCHAN_DATA, EVENT_BCHAN_ACTIVATED,
  EVENT_BCHAN_ERROR, EVENT_CLEANUP, EVENT_PROCEEDING, EVENT_PROGRESS,
  EVENT_SETUP, EVENT_ALERTING, EVENT_CONNECT, EVENT_SETUP_ACKNOWLEDGE,
  EVENT_CONNECT_ACKNOWLEDGE, EVENT_USER_INFORMATION, EVENT_SUSPEND_REJECT, EVENT_RESUME_REJECT,
  EVENT_HOLD, EVENT_SUSPEND, EVENT_RESUME, EVENT_HOLD_ACKNOWLEDGE,
  EVENT_SUSPEND_ACKNOWLEDGE, EVENT_RESUME_ACKNOWLEDGE, EVENT_HOLD_REJECT, EVENT_RETRIEVE,
  EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_RETRIEVE_REJECT, EVENT_DISCONNECT, EVENT_RESTART,
  EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_FACILITY, EVENT_NOTIFY,
  EVENT_STATUS_ENQUIRY, EVENT_INFORMATION, EVENT_STATUS, EVENT_TIMEOUT,
  EVENT_DTMF_TONE, EVENT_NEW_L3ID, EVENT_NEW_BC, EVENT_PORT_ALARM,
  EVENT_NEW_CHANNEL, EVENT_UNKNOWN
}
enum  event_response_e {
  RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, RESPONSE_IGNORE_SETUP, RESPONSE_RELEASE_SETUP, RESPONSE_ERR,
  RESPONSE_OK
}
enum  ie_name_e { IE_DUMMY, IE_LAST }
enum  layer_e { L3, L2, L1, UNKNOWN }
enum  misdn_err_e { ENOCHAN = 1 }
enum  mISDN_NUMBER_PLAN {
  NUMPLAN_UNINITIALIZED = -1, NUMPLAN_INTERNATIONAL = 0x1, NUMPLAN_NATIONAL = 0x2, NUMPLAN_SUBSCRIBER = 0x4,
  NUMPLAN_UNKNOWN = 0x0
}
enum  tone_e {
  TONE_NONE = 0, TONE_DIAL, TONE_ALERTING, TONE_FAR_ALERTING,
  TONE_BUSY, TONE_HANGUP, TONE_CUSTOM, TONE_FILE
}

Functions

char * bc_state2str (enum bchannel_state state)
void bc_state_change (struct misdn_bchannel *bc, enum bchannel_state state)
void get_show_stack_details (int port, char *buf)
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_deactivate (struct misdn_bchannel *bc)
void manager_ec_disable (struct misdn_bchannel *bc)
void manager_ec_enable (struct misdn_bchannel *bc)
char * manager_isdn_get_info (enum event_e event)
void manager_ph_control (struct misdn_bchannel *bc, int c1, int c2)
int misdn_cap_is_speech (int cap)
void misdn_dump_chanlist (void)
int misdn_inband_avail (struct misdn_bchannel *bc)
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)
struct misdn_bchannelmisdn_lib_find_held_bc (int port, int l3_id)
 Find a held call's B channel record.
struct misdn_bchannelmisdn_lib_get_free_bc (int port, int channel, int inout, int dec)
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)
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)
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_nt (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 notcheck)
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)
void misdn_make_dummy (struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel)

Variables

enum event_response_e(* cb_event )(enum event_e event, struct misdn_bchannel *bc, void *user_data)
int(* cb_jb_empty )(struct misdn_bchannel *bc, char *buffer, int len)
void(* cb_log )(int level, int port, char *tmpl,...)

Detailed Description

Interface to mISDN.

Author:
Christian Richter <crich@beronet.com>

Definition in file isdn_lib.h.


Define Documentation

#define MAX_BCHANS   31
#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 665 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 666 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 663 of file isdn_lib.h.

Referenced by dahdi_call().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 664 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 662 of file isdn_lib.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
INFO_CAPABILITY_SPEECH 
INFO_CAPABILITY_AUDIO_3_1K 
INFO_CAPABILITY_AUDIO_7K 
INFO_CAPABILITY_VIDEO 
INFO_CAPABILITY_DIGITAL_UNRESTRICTED 
INFO_CAPABILITY_DIGITAL_RESTRICTED 
INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES 

Definition at line 169 of file isdn_lib.h.

anonymous enum
Enumerator:
INFO_PI_CALL_NOT_E2E_ISDN 
INFO_PI_CALLED_NOT_ISDN 
INFO_PI_CALLER_NOT_ISDN 
INFO_PI_CALLER_RETURNED_TO_ISDN 
INFO_PI_INBAND_AVAILABLE 
INFO_PI_DELAY_AT_INTERF 
INFO_PI_INTERWORKING_WITH_PUBLIC 
INFO_PI_INTERWORKING_NO_RELEASE 
INFO_PI_INTERWORKING_NO_RELEASE_PRE_ANSWER 
INFO_PI_INTERWORKING_NO_RELEASE_POST_ANSWER 

Definition at line 179 of file isdn_lib.h.

anonymous enum
Enumerator:
INFO_CODEC_ULAW 
INFO_CODEC_ALAW 

Definition at line 192 of file isdn_lib.h.

00192      { /*CODECS*/
00193    INFO_CODEC_ULAW=2,
00194    INFO_CODEC_ALAW=3
00195 };

Enumerator:
BCHAN_CLEANED 
BCHAN_EMPTY 
BCHAN_SETUP 
BCHAN_SETUPED 
BCHAN_ACTIVE 
BCHAN_ACTIVATED 
BCHAN_BRIDGE 
BCHAN_BRIDGED 
BCHAN_RELEASE 
BCHAN_RELEASED 
BCHAN_CLEAN 
BCHAN_CLEAN_REQUEST 
BCHAN_ERROR 

Definition at line 78 of file isdn_lib.h.

00078                     {
00079    BCHAN_CLEANED=0,
00080    BCHAN_EMPTY,
00081    BCHAN_SETUP,
00082    BCHAN_SETUPED,
00083    BCHAN_ACTIVE,
00084    BCHAN_ACTIVATED,
00085    BCHAN_BRIDGE,
00086    BCHAN_BRIDGED,
00087    BCHAN_RELEASE,
00088    BCHAN_RELEASED,
00089    BCHAN_CLEAN,
00090    BCHAN_CLEAN_REQUEST,
00091    BCHAN_ERROR
00092 };

enum event_e
Enumerator:
EVENT_NOTHING 
EVENT_TONE_GENERATE 
EVENT_BCHAN_DATA 
EVENT_BCHAN_ACTIVATED 
EVENT_BCHAN_ERROR 
EVENT_CLEANUP 
EVENT_PROCEEDING 
EVENT_PROGRESS 
EVENT_SETUP 
EVENT_ALERTING 
EVENT_CONNECT 
EVENT_SETUP_ACKNOWLEDGE 
EVENT_CONNECT_ACKNOWLEDGE 
EVENT_USER_INFORMATION 
EVENT_SUSPEND_REJECT 
EVENT_RESUME_REJECT 
EVENT_HOLD 
EVENT_SUSPEND 
EVENT_RESUME 
EVENT_HOLD_ACKNOWLEDGE 
EVENT_SUSPEND_ACKNOWLEDGE 
EVENT_RESUME_ACKNOWLEDGE 
EVENT_HOLD_REJECT 
EVENT_RETRIEVE 
EVENT_RETRIEVE_ACKNOWLEDGE 
EVENT_RETRIEVE_REJECT 
EVENT_DISCONNECT 
EVENT_RESTART 
EVENT_RELEASE 
EVENT_RELEASE_COMPLETE 
EVENT_FACILITY 
EVENT_NOTIFY 
EVENT_STATUS_ENQUIRY 
EVENT_INFORMATION 
EVENT_STATUS 
EVENT_TIMEOUT 
EVENT_DTMF_TONE 
EVENT_NEW_L3ID 
EVENT_NEW_BC 
EVENT_PORT_ALARM 
EVENT_NEW_CHANNEL 
EVENT_UNKNOWN 

Definition at line 118 of file isdn_lib.h.

Enumerator:
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE 
RESPONSE_IGNORE_SETUP 
RESPONSE_RELEASE_SETUP 
RESPONSE_ERR 
RESPONSE_OK 

Definition at line 109 of file isdn_lib.h.

enum ie_name_e
Enumerator:
IE_DUMMY 
IE_LAST 

Definition at line 164 of file isdn_lib.h.

00164                {
00165    IE_DUMMY,
00166    IE_LAST
00167 };

enum layer_e
Enumerator:
L3 
L2 
L1 
UNKNOWN 

Definition at line 198 of file isdn_lib.h.

00198              {
00199    L3,
00200    L2,
00201    L1,
00202    UNKNOWN
00203 };

Enumerator:
ENOCHAN 

Definition at line 95 of file isdn_lib.h.

00095                  {
00096    ENOCHAN=1
00097 };

Enumerator:
NUMPLAN_UNINITIALIZED 
NUMPLAN_INTERNATIONAL 
NUMPLAN_NATIONAL 
NUMPLAN_SUBSCRIBER 
NUMPLAN_UNKNOWN 

Definition at line 100 of file isdn_lib.h.

00100                        {
00101    NUMPLAN_UNINITIALIZED=-1,
00102    NUMPLAN_INTERNATIONAL=0x1,
00103    NUMPLAN_NATIONAL=0x2,
00104    NUMPLAN_SUBSCRIBER=0x4,
00105    NUMPLAN_UNKNOWN=0x0
00106 };

enum tone_e

For initialization usage end of init usage

Enumerator:
TONE_NONE 
TONE_DIAL 
TONE_ALERTING 
TONE_FAR_ALERTING 
TONE_BUSY 
TONE_HANGUP 
TONE_CUSTOM 
TONE_FILE 

Definition at line 63 of file isdn_lib.h.

00063             {
00064    TONE_NONE=0,
00065    TONE_DIAL,
00066    TONE_ALERTING,
00067    TONE_FAR_ALERTING,
00068    TONE_BUSY,
00069    TONE_HANGUP,
00070    TONE_CUSTOM,
00071    TONE_FILE
00072 };


Function Documentation

char* bc_state2str ( enum bchannel_state  state  ) 

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

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

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

Definition at line 605 of file isdn_lib.c.

References misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_EMPTY, cb_log, misdn_bchannel::conf_id, misdn_bchannel::l3_id, misdn_join_conf(), misdn_bchannel::next_bc_state, and misdn_bchannel::port.

Referenced by clean_up_bc(), handle_bchan(), handle_frm(), init_bc(), manager_bchannel_deactivate(), misdn_join_conf(), misdn_lib_send_event(), misdn_split_conf(), and setup_bc().

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

void get_show_stack_details ( int  port,
char *  buf 
)

Definition at line 164 of file isdn_lib.c.

References misdn_stack::blocked, get_misdn_stack(), misdn_stack::l1link, misdn_stack::l2link, misdn_stack::next, misdn_stack::nt, misdn_stack::port, and misdn_stack::ptp.

Referenced by handle_cli_misdn_show_port(), and handle_cli_misdn_show_stacks().

00165 {
00166    struct misdn_stack *stack=get_misdn_stack();
00167    
00168    for ( ; stack; stack=stack->next) {
00169       if (stack->port == port) break;
00170    }
00171    
00172    if (stack) {
00173       sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
00174          stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP",
00175          stack->l2link ? "UP" : "DOWN", stack->l1link ? "UP" : "DOWN",
00176          stack->blocked);
00177    } else {
00178       buf[0]=0;
00179    }
00180 }

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4357 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

04358 {
04359    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04360 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

Definition at line 4345 of file isdn_lib.c.

References misdn_bchannel::ec_enable, manager_ec_disable(), and manager_ec_enable().

Referenced by process_ast_dsp().

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

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4335 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

04336 {
04337    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04338 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4340 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

04341 {
04342    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04343 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

Definition at line 4218 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::astbuf, buf, cb_log, get_stack_by_bc(), misdn_stack::midev, misdn_stack::port, and misdn_bchannel::port.

Referenced by setup_bc().

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

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

Definition at line 4240 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_bchannel::bc_state, bc_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_RELEASE, buf, cb_log, misdn_bchannel::conf_id, misdn_bchannel::generate_tone, get_stack_by_bc(), misdn_stack::midev, misdn_split_conf(), misdn_stack::port, and misdn_bchannel::port.

Referenced by clean_up_bc().

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

void manager_ec_disable ( struct misdn_bchannel bc  ) 

Definition at line 4573 of file isdn_lib.c.

References misdn_bchannel::capability, cb_log, misdn_bchannel::ec_enable, ECHOCAN_OFF, get_stack_by_bc(), manager_ph_control(), manager_ph_control_block(), misdn_cap_is_speech(), and misdn_stack::port.

Referenced by clean_up_bc(), handle_cli_misdn_toggle_echocancel(), and isdn_lib_update_ec().

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

void manager_ec_enable ( struct misdn_bchannel bc  ) 

Definition at line 4524 of file isdn_lib.c.

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

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

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

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4213 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04214 {
04215    return isdn_get_info(msgs_g , event, 0);
04216 }

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

Definition at line 4314 of file isdn_lib.c.

References misdn_bchannel::addr, cb_log, 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().

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

int misdn_cap_is_speech ( int  cap  ) 
void misdn_dump_chanlist ( void   ) 

Definition at line 473 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_channels().

00474 {
00475    struct misdn_stack *stack=get_misdn_stack();
00476    for ( ; stack; stack=stack->next) {
00477       dump_chan_list(stack);
00478    }
00479 
00480 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

00444 {
00445 
00446    if (!bc->early_bconnect) {
00447       /* We have opted to never receive any available inband recorded messages */
00448       return 0;
00449    }
00450    
00451    switch (bc->progress_indicator) {
00452    case INFO_PI_INBAND_AVAILABLE:
00453    case INFO_PI_CALL_NOT_E2E_ISDN:
00454    case INFO_PI_CALLED_NOT_ISDN:
00455       return 1;
00456    default:
00457       return 0;
00458    }
00459    return 0;
00460 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

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

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

void misdn_lib_destroy ( void   ) 

Definition at line 4180 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_stack::b_num, misdn_stack::bc, buf, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, global_state, misdn_lib::midev, misdn_stack::midev, MISDN_INITIALIZED, misdn_stack::next, misdn_stack::port, stack_destroy(), misdn_lib::stack_list, and te_lib_destroy().

Referenced by unload_module().

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

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4666 of file isdn_lib.c.

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

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

struct misdn_bchannel* misdn_lib_find_held_bc ( int  port,
int  l3_id 
) [read]

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

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

Referenced by misdn_hangup().

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

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

Definition at line 3223 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, MAX_BCHANS, misdn_stack::next, misdn_stack::port, prepare_bc(), misdn_stack::pri, misdn_stack::ptp, misdn_lib::stack_list, and test_inuse().

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

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

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 133 of file isdn_lib.c.

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

Referenced by misdn_request().

00134 {
00135    struct misdn_stack *stack=get_misdn_stack();
00136    for ( ; stack; stack=stack->next) {
00137       if (stack->port == port) {
00138          if (stack->pri) 
00139             return 30;
00140          else
00141             return 2;
00142       }
00143    }
00144    return -1;
00145 }

int misdn_lib_get_port_down ( int  port  ) 

Definition at line 1751 of file isdn_lib.c.

References misdn_stack::l2link, misdn_lib_get_l1_down(), misdn_lib_get_l2_down(), misdn_stack::next, misdn_stack::port, and misdn_lib::stack_list.

Referenced by handle_cli_misdn_port_down().

01752 { /* Pull Down L1 */ 
01753    struct misdn_stack *stack;
01754    for (stack=glob_mgr->stack_list;
01755         stack;
01756         stack=stack->next) {
01757       if (stack->port == port) {
01758             if (stack->l2link)
01759                misdn_lib_get_l2_down(stack);
01760             misdn_lib_get_l1_down(stack);
01761          return 0;
01762       }
01763    }
01764    return 0;
01765 }

int misdn_lib_get_port_info ( int  port  ) 

Definition at line 3776 of file isdn_lib.c.

References misdn_lib::activatequeue, cb_log, find_stack_by_port(), misdn_lib::new_msg, and misdn_stack::upper_id.

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

int misdn_lib_get_port_up ( int  port  ) 

Definition at line 1729 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_port_up(), and misdn_check_l2l1().

01730 { /* Pull Up L1 */ 
01731    struct misdn_stack *stack;
01732    
01733    for (stack=glob_mgr->stack_list;
01734         stack;
01735         stack=stack->next) {
01736       
01737       if (stack->port == port) {
01738 
01739          if (!stack->l1link)
01740             misdn_lib_get_l1_up(stack);
01741          if (!stack->l2link)
01742             misdn_lib_get_l2_up(stack);
01743          
01744          return 0;
01745       }
01746    }
01747    return 0;
01748 }

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

Definition at line 4072 of file isdn_lib.c.

References misdn_lib::activatequeue, misdn_stack::b_num, misdn_stack::bc, calloc, misdn_lib_iface::cb_event, cb_event, misdn_lib_iface::cb_jb_empty, cb_jb_empty, misdn_lib_iface::cb_log, cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, first, flip_buf_bits(), global_state, init_bc(), init_flip_bits(), manager_event_handler(), misdn_stack::midev, misdn_lib::midev, MISDN_INITIALIZED, misdn_lib_isdn_event_catcher(), misdn_lib_nt_debug_init(), misdn_lib::new_msg, misdn_stack::next, pthread_create, ptp, stack_init(), misdn_lib::stack_list, te_lib_init(), tone_425_flip, and tone_silence_flip.

Referenced by load_module().

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

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 113 of file isdn_lib.c.

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

00114 {  
00115    struct misdn_stack *stack=get_misdn_stack();
00116    for ( ; stack; stack=stack->next) {
00117       if (stack->port == port) {
00118          return stack->blocked;
00119       }
00120    }
00121    return -1;
00122 }

int misdn_lib_is_ptp ( int  port  ) 

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

00125 {
00126    struct misdn_stack *stack=get_misdn_stack();
00127    for ( ; stack; stack=stack->next) {
00128       if (stack->port == port) return stack->ptp;
00129    }
00130    return -1;
00131 }

void misdn_lib_isdn_l1watcher ( int  port  ) 

Definition at line 3056 of file isdn_lib.c.

References cb_log, 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().

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

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

Definition at line 3340 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::b_stid, 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().

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

int misdn_lib_maxports_get ( void   ) 

Definition at line 4022 of file isdn_lib.c.

Referenced by load_module().

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

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4052 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

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

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 4040 of file isdn_lib.c.

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

Referenced by load_module().

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

int misdn_lib_pid_restart ( int  pid  ) 

Definition at line 3831 of file isdn_lib.c.

References manager_clean_bc(), and manager_find_bc_by_pid().

Referenced by handle_cli_misdn_restart_pid().

03832 {
03833    struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
03834 
03835    if (bc) {
03836       manager_clean_bc(bc);
03837    }
03838    return 0;
03839 }

int misdn_lib_port_block ( int  port  ) 

Definition at line 87 of file isdn_lib.c.

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

Referenced by cb_events(), and handle_cli_misdn_port_block().

00088 {
00089    struct misdn_stack *stack=get_misdn_stack();
00090    for ( ; stack; stack=stack->next) {
00091       if (stack->port == port) {
00092          stack->blocked=1;
00093          return 0;
00094       }
00095    }
00096    return -1;
00097 
00098 }

int misdn_lib_port_is_nt ( int  port  ) 

Definition at line 61 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_send_facility().

00062 {
00063    struct misdn_stack *stack=get_misdn_stack();
00064    for ( ; stack; stack=stack->next) {
00065       if (stack->port == port) {
00066          return stack->nt;
00067       }
00068    }
00069    
00070    return -1;
00071 }

int misdn_lib_port_is_pri ( int  port  ) 

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

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

int misdn_lib_port_restart ( int  port  ) 

Definition at line 3881 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_restart_port().

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

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 100 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_port_unblock().

00101 {
00102    struct misdn_stack *stack=get_misdn_stack();
00103    for ( ; stack; stack=stack->next) {
00104       if (stack->port == port) {
00105          stack->blocked=0;
00106          return 0;
00107       }
00108    }
00109    return -1;
00110 
00111 }

int misdn_lib_port_up ( int  port,
int  notcheck 
)

Definition at line 1767 of file isdn_lib.c.

References misdn_stack::blocked, cb_log, 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().

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

void misdn_lib_reinit_nt_stack ( int  port  ) 

Definition at line 4674 of file isdn_lib.c.

References misdn_stack::blocked, misdn_stack::d_stid, find_stack_by_port(), 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().

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

void misdn_lib_release ( struct misdn_bchannel bc  ) 

Definition at line 1709 of file isdn_lib.c.

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

01710 {
01711    struct misdn_stack *stack=get_stack_by_bc(bc);
01712 
01713    if (!stack) {
01714       cb_log(1,0,"misdn_release: No Stack found\n");
01715       return;
01716    }
01717    
01718    if (bc->channel>0) 
01719       empty_chan_in_stack(stack,bc->channel);
01720    
01721    empty_bc(bc);
01722    clean_up_bc(bc);
01723    bc->in_use=0;
01724 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Queue Event

Definition at line 3391 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(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), msg, msgs_g, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_bchannel::nt, misdn_stack::nt, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, RETURN, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.

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

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

int misdn_lib_send_restart ( int  port,
int  channel 
)

Definition at line 3842 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), EVENT_RESTART, find_stack_by_port(), misdn_bchannel::in_use, misdn_lib_send_event(), misdn_make_dummy(), misdn_stack::nt, and misdn_stack::port.

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

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

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4492 of file isdn_lib.c.

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

Referenced by hanguptone_indicate().

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

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 968 of file isdn_lib.c.

References clean_up_bc(), and setup_bc().

00969 {
00970    clean_up_bc(bc);
00971    setup_bc(bc);
00972 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4646 of file isdn_lib.c.

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

Referenced by misdn_bridge().

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

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2237 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02238 {
02239    bc->generate_tone=1;
02240 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2242 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02243 {
02244    bc->generate_tone=0;
02245 }

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

Definition at line 4276 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::bc_state, bc_state2str(), BCHAN_ACTIVATED, BCHAN_BRIDGED, buf, misdn_bchannel::capability, cb_log, flip_buf_bits(), get_stack_by_bc(), misdn_stack::midev, misdn_cap_is_speech(), misdn_stack::port, and misdn_bchannel::port.

Referenced by misdn_join_conf(), and misdn_write().

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

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

Definition at line 73 of file isdn_lib.c.

References misdn_bchannel::channel, misdn_bchannel::dummy, misdn_bchannel::l3_id, misdn_bchannel::nt, and misdn_bchannel::port.

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

00074 {
00075    memset (dummybc,0,sizeof(struct misdn_bchannel));
00076    dummybc->port=port;
00077    if (l3id==0) 
00078       dummybc->l3_id = MISDN_ID_DUMMY;
00079    else
00080       dummybc->l3_id=l3id;
00081 
00082    dummybc->nt=nt;
00083    dummybc->dummy=1;
00084    dummybc->channel=channel;
00085 }


Variable Documentation

enum event_response_e(* cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data)
int(* cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len)

Referenced by misdn_lib_init(), and misdn_tx_jitter().

void(* cb_log)(int level, int port, char *tmpl,...)

Referenced by bc_next_state_change(), bc_state_change(), build_connect(), build_disconnect(), build_release(), build_release_complete(), build_restart(), build_setup(), cb_events(), clean_up_bc(), config_jitterbuffer(), create_process(), dump_chan_list(), empty_chan_in_stack(), fetch_msg(), find_free_chan_in_stack(), handle_bchan(), handle_cr(), handle_err(), handle_event(), handle_event_nt(), handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), handle_mgmt(), handle_timers(), hangup_chan(), init_bc(), isdn_msg_get_index_by_event(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_ec_disable(), manager_ec_enable(), manager_event_handler(), manager_isdn_handler(), manager_ph_control(), misdn_join_conf(), misdn_lib_bridge(), misdn_lib_destroy(), misdn_lib_echo(), misdn_lib_get_free_bc(), misdn_lib_get_l1_down(), misdn_lib_get_port_info(), misdn_lib_init(), misdn_lib_isdn_event_catcher(), misdn_lib_isdn_l1watcher(), misdn_lib_log_ies(), misdn_lib_port_restart(), misdn_lib_port_up(), misdn_lib_release(), misdn_lib_send_event(), misdn_lib_send_restart(), misdn_lib_split_bridge(), misdn_lib_tx2misdn_frm(), misdn_split_conf(), misdn_tasks_destroy(), misdn_tx_jitter(), misdn_write(), parse_facility(), parse_release_complete(), parse_restart(), parse_setup(), queue_cleanup_bc(), release_cr(), send_msg(), set_chan_in_stack(), set_channel(), setup_bc(), stack_holder_add(), stack_holder_find(), stack_holder_remove(), stack_init(), te_lib_destroy(), and test_inuse().


Generated on 3 Mar 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1