Sat Aug 6 00:39:58 2011

Asterisk developer's documentation


isdn_lib.h File Reference

Interface to mISDN. More...

#include <mISDNuser/suppserv.h>

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)
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)
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_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)

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

Definition at line 76 of file isdn_lib.h.

Referenced by empty_chan_in_stack(), find_free_chan_in_stack(), misdn_lib_get_free_bc(), set_chan_in_stack(), and stack_init().

#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 663 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 664 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 661 of file isdn_lib.h.

Referenced by dahdi_call(), and dahdi_new().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 662 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 660 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 };

enum bchannel_state

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.

enum event_response_e

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 };

enum misdn_err_e

Enumerator:
ENOCHAN 

Definition at line 95 of file isdn_lib.h.

00095                  {
00096    ENOCHAN=1
00097 };

enum mISDN_NUMBER_PLAN

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

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

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 }

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_stack::port, and misdn_bchannel::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_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_stack::port, and misdn_bchannel::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_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 }

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 }

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 }

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

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 }

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 }

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, misdn_lib_iface::cb_event, cb_event, misdn_lib_iface::cb_jb_empty, cb_jb_empty, misdn_lib_iface::cb_log, cb_log, first, flip_buf_bits(), glob_mgr, init_bc(), init_flip_bits(), misdn_stack::mgr, misdn_stack::midev, misdn_lib::midev, misdn_lib_nt_debug_init(), misdn_lib::new_msg, misdn_stack::next, misdn_stack::port, ptp, stack_init(), te_lib_init(), tone_425_flip, and tone_silence_flip.

Referenced by load_module().

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 }

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  ) 

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  ) 

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  notcheck 
)

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_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_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_stack::port, and misdn_bchannel::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 }


Variable Documentation

enum event_response_e(*) cb_event(enum event_e event, struct misdn_bchannel *bc, void *user_data)

Definition at line 568 of file isdn_lib.h.

Referenced by clear_l3(), do_tone(), handle_bchan(), handle_cr(), handle_event_nt(), handle_frm(), handle_l1(), handle_l2(), manager_clean_bc(), misdn_lib_init(), and set_channel().

int(*) cb_jb_empty(struct misdn_bchannel *bc, char *buffer, int len)

Definition at line 571 of file isdn_lib.h.

Referenced by misdn_lib_init(), and misdn_tx_jitter().

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

Definition at line 569 of file isdn_lib.h.

Referenced by bc_next_state_change(), bc_state_change(), build_connect(), build_disconnect(), build_release(), build_release_complete(), build_restart(), build_setup(), cb_events(), clean_up_bc(), config_jitterbuffer(), create_process(), dump_chan_list(), empty_chan_in_stack(), fetch_msg(), find_free_chan_in_stack(), handle_bchan(), handle_cr(), handle_err(), handle_event(), handle_event_nt(), handle_frm(), handle_frm_nt(), handle_l1(), handle_l2(), handle_mgmt(), handle_timers(), hangup_chan(), init_bc(), isdn_msg_get_index_by_event(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_ec_disable(), manager_ec_enable(), manager_event_handler(), manager_isdn_handler(), 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(), 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 Sat Aug 6 00:39:58 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7