Thu Feb 5 16:26:16 2009

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_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  {
  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  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_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)
void misdn_lib_transfer (struct misdn_bchannel *holded_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 664 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 665 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 662 of file isdn_lib.h.

Referenced by dahdi_call(), and dahdi_new().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 663 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 661 of file isdn_lib.h.


Enumeration Type Documentation

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

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.

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

References BCHAN_ACTIVATED, BCHAN_ACTIVE, BCHAN_BRIDGE, BCHAN_BRIDGED, BCHAN_CLEAN, BCHAN_CLEAN_REQUEST, BCHAN_CLEANED, BCHAN_EMPTY, BCHAN_ERROR, BCHAN_RELEASE, BCHAN_RELEASED, BCHAN_SETUP, BCHAN_SETUPED, and s.

Referenced by bc_next_state_change(), bc_state_change(), cb_events(), handle_bchan(), handle_err(), misdn_lib_send_event(), misdn_lib_split_bridge(), misdn_lib_tx2misdn_frm(), print_bc_info(), and setup_bc().

00562                                               {
00563    int i;
00564    
00565    struct bchan_state_s {
00566       char *n;
00567       enum bchannel_state s;
00568    } states[] = {
00569       {"BCHAN_CLEANED", BCHAN_CLEANED },
00570       {"BCHAN_EMPTY", BCHAN_EMPTY},
00571       {"BCHAN_SETUP", BCHAN_SETUP},
00572       {"BCHAN_SETUPED", BCHAN_SETUPED},
00573       {"BCHAN_ACTIVE", BCHAN_ACTIVE},
00574       {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
00575       {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
00576       {"BCHAN_BRIDGED", BCHAN_BRIDGED},
00577       {"BCHAN_RELEASE", BCHAN_RELEASE},
00578       {"BCHAN_RELEASED", BCHAN_RELEASED},
00579       {"BCHAN_CLEAN", BCHAN_CLEAN},
00580       {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
00581       {"BCHAN_ERROR", BCHAN_ERROR}
00582    };
00583    
00584    for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
00585       if ( states[i].s == state)
00586          return states[i].n;
00587 
00588    return "UNKNOWN";
00589 }

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

Definition at line 591 of file isdn_lib.c.

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

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

00592 {
00593    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00594       bc->l3_id,
00595           bc_state2str(bc->bc_state),
00596           bc_state2str(state) );
00597    
00598    switch (state) {
00599       case BCHAN_ACTIVATED:
00600          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00601             misdn_join_conf(bc, bc->conf_id);
00602             bc->next_bc_state = BCHAN_EMPTY;
00603             return;
00604          }
00605       default:
00606          bc->bc_state=state;
00607          break;
00608    }
00609 }

void get_show_stack_details ( int  port,
char *  buf 
)

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

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

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4301 of file isdn_lib.c.

References misdn_stack::bc, and manager_ph_control().

Referenced by process_ast_dsp().

04302 {
04303    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04304 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

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

04290 {
04291 #ifdef MISDN_1_2
04292    if (*bc->pipeline)
04293 #else
04294    if (bc->ec_enable)
04295 #endif
04296       manager_ec_enable(bc);
04297    else
04298       manager_ec_disable(bc);
04299 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4279 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04280 {
04281    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04282 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4284 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04285 {
04286    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04287 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

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

04163 {
04164    char buf[128];
04165 
04166    struct misdn_stack *stack=get_stack_by_bc(bc);
04167 
04168    if (!stack) {
04169       cb_log(0, bc->port, "bchannel_activate: Stack not found !");
04170       return ;
04171    }
04172    
04173    /* we must activate if we are deactivated */
04174    clear_ibuffer(bc->astbuf);
04175    
04176    cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
04177    
04178    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
04179 
04180    return ;
04181 }

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

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

04185 {
04186    struct misdn_stack *stack=get_stack_by_bc(bc);
04187    iframe_t dact;
04188    char buf[128]; 
04189 
04190    switch (bc->bc_state) {
04191       case BCHAN_ACTIVATED:
04192          break;
04193       case BCHAN_BRIDGED:
04194          misdn_split_conf(bc,bc->conf_id);
04195          break;
04196       default:
04197          cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
04198          return ;
04199 
04200    }
04201    
04202    cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
04203    
04204    bc->generate_tone=0;
04205    
04206    dact.prim = DL_RELEASE | REQUEST;
04207    dact.addr = bc->addr | FLG_MSG_DOWN;
04208    dact.dinfo = 0;
04209    dact.len = 0;
04210    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
04211 
04212    clear_ibuffer(bc->astbuf);
04213    
04214    bc_state_change(bc,BCHAN_RELEASE);
04215   
04216    return;
04217 }

void manager_ec_disable ( struct misdn_bchannel bc  ) 

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

04518 {
04519    struct misdn_stack *stack=get_stack_by_bc(bc);
04520    
04521    cb_log(4, stack?stack->port:0," --> ec_disable\n");
04522 
04523    if (!misdn_cap_is_speech(bc->capability)) {
04524       cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
04525       return;
04526    }
04527 
04528 #ifdef MISDN_1_2
04529    manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
04530 #else
04531    if ( ! bc->ec_enable) {
04532       cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
04533       manager_ph_control(bc,  ECHOCAN_OFF, 0);
04534    }
04535 #endif
04536 }

void manager_ec_enable ( struct misdn_bchannel bc  ) 

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

04469 {
04470    struct misdn_stack *stack=get_stack_by_bc(bc);
04471    
04472    cb_log(4, stack?stack->port:0,"ec_enable\n");
04473 
04474    if (!misdn_cap_is_speech(bc->capability)) {
04475       cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
04476    } else {
04477 
04478 #ifdef MISDN_1_2
04479    if (*bc->pipeline) {
04480       cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
04481       manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
04482    }
04483 #else
04484    int ec_arr[2];
04485 
04486    if (bc->ec_enable) {
04487       cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
04488    
04489       switch (bc->ec_deftaps) {
04490       case 4:
04491       case 8:
04492       case 16:
04493       case 32:
04494       case 64:
04495       case 128:
04496       case 256:
04497       case 512:
04498       case 1024:
04499          cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
04500          break;
04501       default:
04502          cb_log(0, stack->port, "Taps should be power of 2\n");
04503          bc->ec_deftaps=128;
04504       }
04505    
04506       ec_arr[0]=bc->ec_deftaps;
04507       ec_arr[1]=0;
04508       
04509       manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
04510    }
04511 #endif
04512    }
04513 }

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4157 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04158 {
04159    return isdn_get_info(msgs_g , event, 0);
04160 }

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

Definition at line 4258 of file isdn_lib.c.

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

04259 {
04260    unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
04261    iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
04262    unsigned int *d = (unsigned int*)&ctrl->data.p;
04263    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04264    
04265    cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
04266    
04267    ctrl->prim = PH_CONTROL | REQUEST;
04268    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04269    ctrl->dinfo = 0;
04270    ctrl->len = sizeof(unsigned int)*2;
04271    *d++ = c1;
04272    *d++ = c2;
04273    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04274 }

int misdn_cap_is_speech ( int  cap  ) 

Poor mans version

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

00423 {
00424    if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) &&
00425         (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1;
00426    return 0;
00427 }

void misdn_dump_chanlist ( void   ) 

Definition at line 459 of file isdn_lib.c.

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

Referenced by misdn_show_cls().

00460 {
00461    struct misdn_stack *stack=get_misdn_stack();
00462    for ( ; stack; stack=stack->next) {
00463       dump_chan_list(stack);
00464    }
00465 
00466 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

00430 {
00431 
00432    if (!bc->early_bconnect) {
00433       /* We have opted to never receive any available inband recorded messages */
00434       return 0;
00435    }
00436    
00437    switch (bc->progress_indicator) {
00438    case INFO_PI_INBAND_AVAILABLE:
00439    case INFO_PI_CALL_NOT_E2E_ISDN:
00440    case INFO_PI_CALLED_NOT_ISDN:
00441       return 1;
00442    default:
00443       return 0;
00444    }
00445    return 0;
00446 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

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

04568 {
04569    int conf_id = bc1->pid + 1;
04570    struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL };
04571    struct misdn_bchannel **bc;
04572 
04573    cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
04574 
04575    for (bc=bc_list; *bc;  bc++) { 
04576       (*bc)->conf_id=conf_id;
04577       cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
04578    
04579       switch((*bc)->bc_state) {
04580          case BCHAN_ACTIVATED:
04581             misdn_join_conf(*bc,conf_id);
04582             break;
04583          default:
04584             bc_next_state_change(*bc,BCHAN_BRIDGED);
04585             break;
04586       }
04587    }
04588 }

void misdn_lib_destroy ( void   ) 

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

04125 {
04126    struct misdn_stack *help;
04127    int i;
04128   
04129    for ( help=glob_mgr->stack_list; help; help=help->next ) {
04130       for(i=0;i<=help->b_num; i++) {
04131          char buf[1024];
04132          mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
04133          help->bc[i].addr = 0;
04134       }
04135       cb_log (1, help->port, "Destroying this port.\n");
04136       stack_destroy(help);
04137    }
04138    
04139    if (global_state == MISDN_INITIALIZED) {
04140       cb_log(4, 0, "Killing Handler Thread\n");
04141       if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
04142          cb_log(4, 0, "Joining Handler Thread\n");
04143          pthread_join(glob_mgr->event_handler_thread, NULL);
04144       }
04145      
04146       cb_log(4, 0, "Killing Main Thread\n");
04147       if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
04148          cb_log(4, 0, "Joining Main Thread\n");
04149          pthread_join(glob_mgr->event_thread, NULL);
04150       }
04151    }
04152   
04153    cb_log(1, 0, "Closing mISDN device\n");
04154    te_lib_destroy(glob_mgr->midev);
04155 }

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4610 of file isdn_lib.c.

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

04611 {
04612    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04613    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04614 }

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

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

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

03168 {
03169    struct misdn_stack *stack;
03170    int i;
03171    
03172    if (channel < 0 || channel > MAX_BCHANS) {
03173       cb_log(0,port,"Requested channel out of bounds (%d)\n",channel);
03174       return NULL;
03175    }
03176 
03177    usleep(1000);
03178 
03179    for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
03180     
03181       if (stack->port == port) {
03182          int maxnum;
03183 
03184          if (stack->blocked) {
03185             cb_log(0,port,"Port is blocked\n");
03186             return NULL;
03187          }
03188       
03189          if (channel > 0) {
03190             if (channel <= stack->b_num) {
03191                for (i = 0; i < stack->b_num; i++) {
03192                   if ( stack->bc[i].channel == channel) {
03193                      if (test_inuse(&stack->bc[i])) { 
03194                         cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
03195                         return NULL;
03196 
03197                      } else {
03198                         prepare_bc(&stack->bc[i], channel);
03199                         return &stack->bc[i];
03200                      }
03201                   }
03202                }
03203             } else {
03204                cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port);
03205                return NULL;
03206             }
03207          }
03208 
03209          maxnum = inout && !stack->pri && !stack->ptp ? stack->b_num + 1 : stack->b_num;
03210 
03211          if (dec) {
03212             for (i = maxnum-1; i>=0; i--) {
03213                if (!test_inuse(&stack->bc[i])) {
03214                   /* 3. channel on bri means CW*/
03215                   if (!stack->pri && i==stack->b_num)
03216                      stack->bc[i].cw=1;
03217                      
03218                   prepare_bc(&stack->bc[i], channel);
03219                   stack->bc[i].dec=1;
03220                   return &stack->bc[i];
03221                }
03222             }
03223          } else {
03224             for (i = 0; i <maxnum; i++) {
03225                if (!test_inuse(&stack->bc[i])) {
03226                   /* 3. channel on bri means CW*/
03227                   if (!stack->pri && i==stack->b_num)
03228                      stack->bc[i].cw=1;
03229 
03230                   prepare_bc(&stack->bc[i], channel);
03231                   return &stack->bc[i];
03232                }
03233             }
03234          }
03235 
03236          cb_log(1,port,"There is no free channel on port (%d)\n",port);
03237          return NULL;
03238       }
03239    }
03240 
03241    cb_log(0,port,"Port is not configured (%d)\n",port);
03242    return NULL;
03243 }

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 117 of file isdn_lib.c.

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

Referenced by misdn_request().

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

int misdn_lib_get_port_down ( int  port  ) 

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

01732 { /* Pull Down L1 */ 
01733    struct misdn_stack *stack;
01734    for (stack=glob_mgr->stack_list;
01735         stack;
01736         stack=stack->next) {
01737       if (stack->port == port) {
01738             if (stack->l2link)
01739                misdn_lib_get_l2_down(stack);
01740             misdn_lib_get_l1_down(stack);
01741          return 0;
01742       }
01743    }
01744    return 0;
01745 }

int misdn_lib_get_port_info ( int  port  ) 

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

03725 {
03726    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03727    iframe_t *frm;
03728    struct misdn_stack *stack=find_stack_by_port(port);
03729    if (!msg) {
03730       cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n");
03731       return -1;
03732    }
03733    frm=(iframe_t*)msg->data;
03734    if (!stack ) {
03735       cb_log(0, port, "There is no Stack for this port.\n");
03736       return -1;
03737    }
03738    /* activate bchannel */
03739    frm->prim = CC_STATUS_ENQUIRY | REQUEST;
03740 
03741    frm->addr = stack->upper_id| FLG_MSG_DOWN;
03742 
03743    frm->dinfo = 0;
03744    frm->len = 0;
03745   
03746    msg_queue_tail(&glob_mgr->activatequeue, msg);
03747    sem_post(&glob_mgr->new_msg);
03748 
03749   
03750    return 0; 
03751 }

int misdn_lib_get_port_up ( int  port  ) 

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

01710 { /* Pull Up L1 */ 
01711    struct misdn_stack *stack;
01712    
01713    for (stack=glob_mgr->stack_list;
01714         stack;
01715         stack=stack->next) {
01716       
01717       if (stack->port == port) {
01718 
01719          if (!stack->l1link)
01720             misdn_lib_get_l1_up(stack);
01721          if (!stack->l2link)
01722             misdn_lib_get_l2_up(stack);
01723          
01724          return 0;
01725       }
01726    }
01727    return 0;
01728 }

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

Definition at line 4016 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, cb_log, misdn_lib_iface::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().

04017 {
04018    struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
04019    char *tok, *tokb;
04020    char plist[1024];
04021    int midev;
04022    int port_count=0;
04023  
04024    cb_log = iface->cb_log;
04025    cb_event = iface->cb_event;
04026    cb_jb_empty = iface->cb_jb_empty;
04027    
04028    glob_mgr = mgr;
04029   
04030    msg_init();
04031 
04032    misdn_lib_nt_debug_init(0,NULL);
04033    
04034    if (!portlist || (*portlist == 0) ) return 1;
04035    
04036    init_flip_bits();
04037    
04038    {
04039       strncpy(plist,portlist, 1024);
04040       plist[1023] = 0;
04041    }
04042   
04043    memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
04044    flip_buf_bits(tone_425_flip,TONE_425_SIZE);
04045 
04046    memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
04047    flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);
04048   
04049    midev=te_lib_init();
04050    mgr->midev=midev;
04051 
04052    port_count=mISDN_get_stack_count(midev);
04053   
04054    msg_queue_init(&mgr->activatequeue);
04055   
04056    if (sem_init(&mgr->new_msg, 1, 0)<0)
04057       sem_init(&mgr->new_msg, 0, 0);
04058  
04059    for (tok=strtok_r(plist," ,",&tokb );
04060         tok; 
04061         tok=strtok_r(NULL," ,",&tokb)) {
04062       int port = atoi(tok);
04063       struct misdn_stack *stack;
04064       static int first=1;
04065       int ptp=0;
04066     
04067       if (strstr(tok, "ptp"))
04068          ptp=1;
04069 
04070       if (port > port_count) {
04071          cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
04072          exit(1);
04073       }
04074       stack=stack_init(midev, port, ptp);
04075     
04076       if (!stack) {
04077          perror("stack_init");
04078          exit(1);
04079       }
04080     
04081       {
04082          int i;
04083          for(i=0;i<=stack->b_num; i++) {
04084             int r;
04085             if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
04086                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
04087                exit(1);
04088             }
04089          }
04090       }
04091 
04092       if (stack && first) {
04093          mgr->stack_list=stack;
04094          first=0;
04095          continue;
04096       }
04097     
04098       if (stack) {
04099          struct misdn_stack * help;
04100          for ( help=mgr->stack_list; help; help=help->next ) 
04101             if (help->next == NULL) break;
04102          help->next=stack;
04103       }
04104     
04105    }
04106   
04107    if (sem_init(&handler_started, 1, 0)<0)
04108       sem_init(&handler_started, 0, 0);
04109   
04110    cb_log(8, 0, "Starting Event Handler\n");
04111    pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr);
04112   
04113    sem_wait(&handler_started) ;
04114    cb_log(8, 0, "Starting Event Catcher\n");
04115    pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);
04116   
04117    cb_log(8, 0, "Event Catcher started\n");
04118 
04119    global_state= MISDN_INITIALIZED; 
04120   
04121    return (mgr == NULL);
04122 }

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 97 of file isdn_lib.c.

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

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

int misdn_lib_is_ptp ( int  port  ) 

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

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

void misdn_lib_isdn_l1watcher ( int  port  ) 

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

02994 {
02995    struct misdn_stack *stack;
02996 
02997    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
02998       ;
02999 
03000    if (stack) {
03001       cb_log(4, port, "Checking L1 State\n");   
03002       if (!stack->l1link) {
03003          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
03004          misdn_lib_get_short_status(stack);
03005          misdn_lib_get_l1_up(stack); 
03006          misdn_lib_get_l2_up(stack); 
03007       }
03008    }
03009 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

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

03289 {
03290    struct misdn_stack *stack;
03291 
03292    if (!bc) return;
03293 
03294    stack = get_stack_by_bc(bc);
03295 
03296    if (!stack) return;
03297 
03298    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);
03299    
03300    cb_log(2, stack->port,
03301           " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
03302           bc->info_dad,
03303           bc->onumplan>=0?'0'+bc->onumplan:' ',
03304           bc->dnumplan>=0?'0'+bc->dnumplan:' ',
03305           bc->rnumplan>=0?'0'+bc->rnumplan:' ',
03306           bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
03307       );
03308    
03309    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);
03310    cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
03311          bc->screen, bc->pres);
03312    
03313    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);
03314    
03315    cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
03316 
03317    cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
03318    
03319    cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
03320 }

int misdn_lib_maxports_get ( void   ) 

Definition at line 3966 of file isdn_lib.c.

Referenced by load_module().

03967 {
03968    /* BE AWARE WE HAVE NO cb_log() HERE! */
03969 
03970    int i = mISDN_open();
03971    int max=0;
03972    
03973    if (i<0)
03974       return -1;
03975 
03976    max = mISDN_get_stack_count(i);
03977    
03978    mISDN_close(i);
03979    
03980    return max;
03981 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 3996 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

03997 {
03998    static int init=0;
03999    char *f;
04000    
04001    if (!flags) 
04002       f=NULL;
04003    else
04004       f=file;
04005 
04006    if (!init) {
04007       debug_init( flags , f, f, f);
04008       init=1;
04009    } else {
04010       debug_close();
04011       debug_init( flags , f, f, f);
04012    }
04013 }

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 3984 of file isdn_lib.c.

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

Referenced by load_module().

03985 {
03986 #ifdef FEATURE_NET_KEEPCALLS
03987    if (kc) {
03988       struct misdn_stack *stack=get_misdn_stack();
03989       for ( ; stack; stack=stack->next) {
03990          stack->nst.feature |= FEATURE_NET_KEEPCALLS;
03991       }
03992    }
03993 #endif
03994 }

int misdn_lib_pid_restart ( int  pid  ) 

int misdn_lib_port_block ( int  port  ) 

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

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

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  ) 

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 84 of file isdn_lib.c.

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

Referenced by misdn_port_unblock().

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

int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

01748 {
01749    struct misdn_stack *stack;
01750 
01751 
01752    for (stack=glob_mgr->stack_list;
01753         stack;
01754         stack=stack->next) {
01755       
01756       if (stack->port == port) {
01757 
01758          if (stack->blocked) {
01759             cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
01760             return -1;
01761          }
01762 
01763          if (stack->ptp ) {
01764 
01765             if (stack->l1link && stack->l2link) {
01766                return 1;
01767             } else {
01768                cb_log(1,port, "Port Down L2:%d L1:%d\n",
01769                   stack->l2link, stack->l1link);
01770                return 0;
01771             }
01772          } else {
01773             if ( !check || stack->l1link )
01774                return 1;
01775             else {
01776                cb_log(1,port, "Port down PMP\n");
01777                return 0;
01778             }
01779          }
01780       }
01781    }
01782   
01783    return -1;
01784 }

void misdn_lib_reinit_nt_stack ( int  port  ) 

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

04619 {
04620    struct misdn_stack *stack=find_stack_by_port(port);
04621    
04622    if (stack) {
04623       stack->l2link=0;
04624       stack->blocked=0;
04625    
04626       cleanup_Isdnl3(&stack->nst);
04627       cleanup_Isdnl2(&stack->nst);
04628 
04629 
04630       memset(&stack->nst, 0, sizeof(net_stack_t));
04631       memset(&stack->mgr, 0, sizeof(manager_t));
04632    
04633       stack->mgr.nst = &stack->nst;
04634       stack->nst.manager = &stack->mgr;
04635     
04636       stack->nst.l3_manager = handle_event_nt;
04637       stack->nst.device = glob_mgr->midev;
04638       stack->nst.cardnr = port;
04639       stack->nst.d_stid = stack->d_stid;
04640    
04641       stack->nst.feature = FEATURE_NET_HOLD;
04642       if (stack->ptp)
04643          stack->nst.feature |= FEATURE_NET_PTP;
04644       if (stack->pri)
04645          stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
04646       
04647       stack->nst.l1_id = stack->lower_id;
04648       stack->nst.l2_id = stack->upper_id;
04649       
04650       msg_queue_init(&stack->nst.down_queue);
04651    
04652       Isdnl2Init(&stack->nst);
04653       Isdnl3Init(&stack->nst);
04654 
04655       if (!stack->ptp)
04656          misdn_lib_get_l1_up(stack);
04657       misdn_lib_get_l2_up(stack);
04658    }
04659 }

void misdn_lib_release ( struct misdn_bchannel bc  ) 

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

01690 {
01691    struct misdn_stack *stack=get_stack_by_bc(bc);
01692 
01693    if (!stack) {
01694       cb_log(1,0,"misdn_release: No Stack found\n");
01695       return;
01696    }
01697    
01698    if (bc->channel>0) 
01699       empty_chan_in_stack(stack,bc->channel);
01700    
01701    empty_bc(bc);
01702    clean_up_bc(bc);
01703    bc->in_use=0;
01704 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Definition at line 3339 of file isdn_lib.c.

References misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_BRIDGED, BCHAN_CLEANED, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, clean_up_bc(), misdn_bchannel::conf_id, create_process(), misdn_bchannel::crypt_key, misdn_bchannel::dad, misdn_bchannel::dnumplan, misdn_stack::downqueue, empty_bc(), empty_chan_in_stack(), ENOCHAN, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_HOLD_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), glob_mgr, misdn_bchannel::holded, 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().

03340 {
03341    msg_t *msg; 
03342    int retval=0;
03343    struct misdn_stack *stack;
03344   
03345    if (!bc) RETURN(-1,OUT_POST_UNLOCK);
03346    
03347    stack = get_stack_by_bc(bc);
03348    
03349    if (!stack) {
03350       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);
03351       RETURN(-1,OUT);
03352    }
03353    
03354    misdn_send_lock(bc);
03355 
03356 
03357    cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->upperid:%x\n",stack->nt, stack->upper_id);
03358 
03359    if ( stack->nt && !stack->l1link) {
03360       /** Queue Event **/
03361       bc->evq=event;
03362       cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
03363       misdn_lib_get_l1_up(stack);
03364       RETURN(0,OUT);
03365    }
03366    
03367    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);
03368    cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
03369    misdn_lib_log_ies(bc);
03370    
03371    switch (event) {
03372    case EVENT_SETUP:
03373       if (create_process(glob_mgr->midev, bc)<0) {
03374          cb_log(0,  stack->port, " No free channel at the moment @ send_event\n");
03375 
03376          RETURN(-ENOCHAN,OUT);
03377       }
03378       break;
03379 
03380    case EVENT_PROGRESS:
03381    case EVENT_ALERTING:
03382    case EVENT_PROCEEDING:
03383    case EVENT_SETUP_ACKNOWLEDGE:
03384    case EVENT_CONNECT:
03385       if (!stack->nt) break;
03386 
03387    case EVENT_RETRIEVE_ACKNOWLEDGE:
03388 
03389       if (stack->nt) {
03390          if (bc->channel <=0 ) { /*  else we have the channel already */
03391             if (find_free_chan_in_stack(stack, bc, 0, 0)<0) {
03392                cb_log(0, stack->port, " No free channel at the moment\n");
03393                /*FIXME: add disconnect*/
03394                RETURN(-ENOCHAN,OUT);
03395             }
03396          }
03397          /* Its that i generate channels */
03398       }
03399 
03400       retval=setup_bc(bc);
03401       if (retval == -EINVAL) {
03402          cb_log(0,bc->port,"send_event: setup_bc failed\n");
03403       }
03404 
03405       if (misdn_cap_is_speech(bc->capability)) {
03406          if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
03407             if ( *bc->crypt_key ) {
03408                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);
03409                
03410                manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
03411             }
03412             
03413             if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03414             manager_ec_enable(bc);
03415             
03416             if (bc->txgain != 0) {
03417                cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
03418                manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03419             }
03420             
03421             if ( bc->rxgain != 0 ) {
03422                cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
03423                manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03424             }
03425          }
03426       }
03427       break;
03428 
03429    case EVENT_HOLD_ACKNOWLEDGE:
03430    {
03431       struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel));
03432       if (!holded_bc) {
03433          cb_log(0,bc->port, "Could not allocate holded_bc!!!\n");
03434          RETURN(-1,OUT);
03435       }
03436 
03437       /*backup the bc*/
03438       memcpy(holded_bc,bc,sizeof(struct misdn_bchannel));
03439       holded_bc->holded=1;
03440       bc_state_change(holded_bc,BCHAN_CLEANED);
03441 
03442       stack_holder_add(stack,holded_bc);
03443    
03444       /*kill the bridge and clean the bchannel*/
03445       if (stack->nt) {
03446          int channel;
03447          if (bc->bc_state == BCHAN_BRIDGED) {
03448             struct misdn_bchannel *bc2;
03449 
03450             misdn_split_conf(bc,bc->conf_id);
03451             bc2 = find_bc_by_confid(bc->conf_id);
03452             if (!bc2) {
03453                cb_log(0,bc->port,"We have no second bc in bridge???\n");
03454             } else {
03455                misdn_split_conf(bc2,bc->conf_id);
03456             }
03457          }
03458          
03459          channel = bc->channel;
03460 
03461          empty_bc(bc);
03462          clean_up_bc(bc);
03463 
03464          if (channel>0)
03465             empty_chan_in_stack(stack,channel);
03466 
03467          bc->in_use=0;  
03468       }
03469       
03470    }
03471    break;
03472 
03473    /* finishing the channel eh ? */
03474    case EVENT_DISCONNECT:
03475       if (!bc->need_disconnect) {
03476          cb_log(0,bc->port," --> we have already send Disconnect\n");
03477          RETURN(-1,OUT);
03478       }
03479       
03480       bc->need_disconnect=0;
03481       break;
03482    case EVENT_RELEASE:
03483       if (!bc->need_release) {
03484          cb_log(0,bc->port," --> we have already send Release\n");
03485          RETURN(-1,OUT);
03486       }
03487       bc->need_disconnect=0;
03488       bc->need_release=0;
03489       break;
03490    case EVENT_RELEASE_COMPLETE:
03491       if (!bc->need_release_complete) {
03492          cb_log(0,bc->port," --> we have already send Release_complete\n");
03493          RETURN(-1,OUT);
03494       }
03495       bc->need_disconnect=0;
03496       bc->need_release=0;
03497       bc->need_release_complete=0;
03498 
03499       if (!stack->nt) {
03500          /*create cleanup in TE*/
03501          int channel=bc->channel;
03502 
03503          int tmpcause=bc->cause; 
03504          int tmp_out_cause=bc->out_cause; 
03505          empty_bc(bc);
03506          bc->cause=tmpcause;
03507          bc->out_cause=tmp_out_cause;
03508          clean_up_bc(bc);
03509          
03510          if (channel>0)
03511             empty_chan_in_stack(stack,channel);
03512          
03513          bc->in_use=0;
03514       }
03515       break;
03516     
03517    case EVENT_CONNECT_ACKNOWLEDGE:
03518 
03519       if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
03520          int retval=setup_bc(bc);
03521          if (retval == -EINVAL){
03522             cb_log(0,bc->port,"send_event: setup_bc failed\n");
03523             
03524          }
03525       }
03526       
03527       if (misdn_cap_is_speech(bc->capability)) {
03528          if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03529          manager_ec_enable(bc);
03530 
03531          if ( bc->txgain != 0 ) {
03532             cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
03533             manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03534          }
03535          if ( bc->rxgain != 0 ) {
03536             cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
03537             manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03538          }
03539       }
03540       break;
03541     
03542    default:
03543       break;
03544    }
03545   
03546    /* Later we should think about sending bchannel data directly to misdn. */
03547    msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
03548    msg_queue_tail(&stack->downqueue, msg);
03549    sem_post(&glob_mgr->new_msg);
03550   
03551 OUT:
03552    misdn_send_unlock(bc);
03553 
03554 OUT_POST_UNLOCK:
03555    return retval; 
03556 }

int misdn_lib_send_restart ( int  port,
int  channel 
)

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

03791 {
03792    struct misdn_stack *stack=find_stack_by_port(port);
03793    struct misdn_bchannel dummybc;
03794    /*default is all channels*/
03795    cb_log(0, port, "Sending Restarts on this port.\n");
03796    
03797    misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
03798 
03799    /*default is all channels*/
03800    if (channel <0) {
03801       dummybc.channel=-1;
03802       cb_log(0, port, "Restarting and all Interfaces\n");
03803       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03804 
03805       return 0;
03806    }
03807 
03808    /*if a channel is specified we restart only this one*/
03809    if (channel >0) {
03810       int cnt;
03811       dummybc.channel=channel;
03812       cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
03813       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03814       /* clean up chan in stack, to be sure we don't think it's
03815        * in use anymore */
03816       for (cnt=0; cnt<=stack->b_num; cnt++) {
03817          if (stack->bc[cnt].channel == channel) {
03818             empty_bc(&stack->bc[cnt]);
03819             clean_up_bc(&stack->bc[cnt]);
03820             stack->bc[cnt].in_use=0;
03821          }
03822       }
03823    }
03824 
03825    return 0;
03826 }

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4436 of file isdn_lib.c.

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

Referenced by hanguptone_indicate().

04437 {
04438    char buf[mISDN_HEADER_LEN + 128] = "";
04439    iframe_t *frm = (iframe_t*)buf;
04440 
04441    switch(tone) {
04442    case TONE_DIAL:
04443       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 
04444    break;
04445    
04446    case TONE_ALERTING:
04447       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);  
04448    break;
04449    
04450    case TONE_HANGUP:
04451       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);   
04452    break;
04453 
04454    case TONE_NONE:
04455    default:
04456       manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);  
04457    }
04458 
04459    frm->prim=DL_DATA|REQUEST;
04460    frm->addr=bc->addr|FLG_MSG_DOWN;
04461    frm->dinfo=0;
04462    frm->len=128;
04463    
04464    mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
04465 }

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 950 of file isdn_lib.c.

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

00951 {
00952    clean_up_bc(bc);
00953    setup_bc(bc);
00954 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4590 of file isdn_lib.c.

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

Referenced by misdn_bridge().

04591 {
04592 
04593    struct misdn_bchannel *bc_list[]={
04594       bc1,bc2,NULL
04595    };
04596    struct misdn_bchannel **bc;
04597       
04598    for (bc=bc_list; *bc;  bc++) { 
04599       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04600          misdn_split_conf( *bc, (*bc)->conf_id);
04601       } else {
04602          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04603       }
04604    }
04605    
04606 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2190 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02191 {
02192    bc->generate_tone=1;
02193 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2195 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02196 {
02197    bc->generate_tone=0;
02198 }

void misdn_lib_transfer ( struct misdn_bchannel holded_bc  ) 

Definition at line 3099 of file isdn_lib.c.

References misdn_bchannel::holded.

03100 {
03101    holded_bc->holded=0;
03102 }

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

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

04221 {
04222    struct misdn_stack *stack=get_stack_by_bc(bc);
04223    char buf[4096 + mISDN_HEADER_LEN];
04224    iframe_t *frm = (iframe_t*)buf;
04225    int r;
04226 
04227    switch (bc->bc_state) {
04228       case BCHAN_ACTIVATED:
04229       case BCHAN_BRIDGED:
04230          break;
04231       default:
04232          cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
04233          return -1;
04234    }
04235    
04236    frm->prim = DL_DATA|REQUEST;
04237    frm->dinfo = 0;
04238    frm->addr = bc->addr | FLG_MSG_DOWN ;
04239    
04240    frm->len = len;
04241    memcpy(&buf[mISDN_HEADER_LEN], data,len);
04242       
04243    if ( misdn_cap_is_speech(bc->capability) ) 
04244       flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
04245    else
04246       cb_log(6, stack->port, "Writing %d data bytes\n",len);
04247    
04248    cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
04249    r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
04250    return 0;
04251 }


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(), 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_find_bychan(), stack_holder_remove(), stack_init(), te_lib_destroy(), and test_inuse().


Generated on Thu Feb 5 16:26:16 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7