Thu Oct 8 21:57:51 2009

Asterisk developer's documentation


isdn_lib.h File Reference

#include <mISDNuser/suppserv.h>

Include dependency graph for isdn_lib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  misdn_bchannel
struct  misdn_lib_iface

Defines

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

Enumerations

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

Functions

char * bc_state2str (enum bchannel_state state)
void bc_state_change (struct misdn_bchannel *bc, enum bchannel_state state)
void get_show_stack_details (int port, char *buf)
void isdn_lib_stop_dtmf (struct misdn_bchannel *bc)
void isdn_lib_update_ec (struct misdn_bchannel *bc)
void isdn_lib_update_rxgain (struct misdn_bchannel *bc)
void isdn_lib_update_txgain (struct misdn_bchannel *bc)
void manager_bchannel_activate (struct misdn_bchannel *bc)
void manager_bchannel_deactivate (struct misdn_bchannel *bc)
void manager_ec_disable (struct misdn_bchannel *bc)
void manager_ec_enable (struct misdn_bchannel *bc)
char * manager_isdn_get_info (enum event_e event)
void manager_ph_control (struct misdn_bchannel *bc, int c1, int c2)
int misdn_cap_is_speech (int cap)
void misdn_dump_chanlist (void)
int misdn_inband_avail (struct misdn_bchannel *bc)
void misdn_lib_bridge (struct misdn_bchannel *bc1, struct misdn_bchannel *bc2)
void misdn_lib_destroy (void)
void misdn_lib_echo (struct misdn_bchannel *bc, int onoff)
struct misdn_bchannelmisdn_lib_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,...)


Define Documentation

#define MAX_BCHANS   31

#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 467 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 468 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 465 of file isdn_lib.h.

Referenced by zt_call(), and zt_new().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 466 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 464 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 163 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 173 of file isdn_lib.h.

anonymous enum

Enumerator:
INFO_CODEC_ULAW 
INFO_CODEC_ALAW 

Definition at line 186 of file isdn_lib.h.

00186      { /*CODECS*/
00187    INFO_CODEC_ULAW=2,
00188    INFO_CODEC_ALAW=3
00189 }; 

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 72 of file isdn_lib.h.

00072                     {
00073    BCHAN_CLEANED=0,
00074    BCHAN_EMPTY,
00075    BCHAN_SETUP,
00076    BCHAN_SETUPED,
00077    BCHAN_ACTIVE,
00078    BCHAN_ACTIVATED,
00079    BCHAN_BRIDGE,
00080    BCHAN_BRIDGED,
00081    BCHAN_RELEASE,
00082    BCHAN_RELEASED,
00083    BCHAN_CLEAN,
00084    BCHAN_CLEAN_REQUEST,
00085    BCHAN_ERROR
00086 };

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 112 of file isdn_lib.h.

Enumerator:
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE 
RESPONSE_IGNORE_SETUP 
RESPONSE_RELEASE_SETUP 
RESPONSE_ERR 
RESPONSE_OK 

Definition at line 103 of file isdn_lib.h.

enum ie_name_e

Enumerator:
IE_DUMMY 
IE_LAST 

Definition at line 158 of file isdn_lib.h.

00158                {
00159    IE_DUMMY,
00160    IE_LAST
00161 };

enum layer_e

Enumerator:
L3 
L2 
L1 
UNKNOWN 

Definition at line 192 of file isdn_lib.h.

00192              {
00193    L3,
00194    L2,
00195    L1,
00196    UNKNOWN
00197 }; 

Enumerator:
ENOCHAN 

Definition at line 89 of file isdn_lib.h.

00089                  {
00090    ENOCHAN=1
00091 };

Enumerator:
NUMPLAN_UNINITIALIZED 
NUMPLAN_INTERNATIONAL 
NUMPLAN_NATIONAL 
NUMPLAN_SUBSCRIBER 
NUMPLAN_UNKNOWN 

Definition at line 94 of file isdn_lib.h.

00094                        {
00095    NUMPLAN_UNINITIALIZED=-1,
00096    NUMPLAN_INTERNATIONAL=0x1,
00097    NUMPLAN_NATIONAL=0x2,
00098    NUMPLAN_SUBSCRIBER=0x4,
00099    NUMPLAN_UNKNOWN=0x0
00100 }; 

enum tone_e

For initialization usage end of init usage

Enumerator:
TONE_NONE 
TONE_DIAL 
TONE_ALERTING 
TONE_FAR_ALERTING 
TONE_BUSY 
TONE_HANGUP 
TONE_CUSTOM 
TONE_FILE 

Definition at line 57 of file isdn_lib.h.

00057             {
00058    TONE_NONE=0,
00059    TONE_DIAL,
00060    TONE_ALERTING,
00061    TONE_FAR_ALERTING,
00062    TONE_BUSY,
00063    TONE_HANGUP,
00064    TONE_CUSTOM,
00065    TONE_FILE
00066 };


Function Documentation

char* bc_state2str ( enum bchannel_state  state  ) 

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

00553                                               {
00554    int i;
00555    
00556    struct bchan_state_s {
00557       char *n;
00558       enum bchannel_state s;
00559    } states[] = {
00560       {"BCHAN_CLEANED", BCHAN_CLEANED },
00561       {"BCHAN_EMPTY", BCHAN_EMPTY},
00562       {"BCHAN_SETUP", BCHAN_SETUP},
00563       {"BCHAN_SETUPED", BCHAN_SETUPED},
00564       {"BCHAN_ACTIVE", BCHAN_ACTIVE},
00565       {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
00566       {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
00567       {"BCHAN_BRIDGED", BCHAN_BRIDGED},
00568       {"BCHAN_RELEASE", BCHAN_RELEASE},
00569       {"BCHAN_RELEASED", BCHAN_RELEASED},
00570       {"BCHAN_CLEAN", BCHAN_CLEAN},
00571       {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
00572       {"BCHAN_ERROR", BCHAN_ERROR}
00573    };
00574    
00575    for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
00576       if ( states[i].s == state)
00577          return states[i].n;
00578 
00579    return "UNKNOWN";
00580 }

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

Definition at line 582 of file isdn_lib.c.

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

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

00583 {
00584    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00585       bc->l3_id,
00586           bc_state2str(bc->bc_state),
00587           bc_state2str(state) );
00588    
00589    switch (state) {
00590       case BCHAN_ACTIVATED:
00591          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00592             misdn_join_conf(bc, bc->conf_id);
00593             bc->next_bc_state = BCHAN_EMPTY;
00594             return;
00595          }
00596       default:
00597          bc->bc_state=state;
00598          break;
00599    }
00600 }

void get_show_stack_details ( int  port,
char *  buf 
)

Definition at line 135 of file isdn_lib.c.

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

Referenced by misdn_show_port(), and misdn_show_stacks().

00136 {
00137    struct misdn_stack *stack=get_misdn_stack();
00138    
00139    for ( ; stack; stack=stack->next) {
00140       if (stack->port == port) break;
00141    }
00142    
00143    if (stack) {
00144       sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d", stack->port, stack->nt?"NT":"TE", stack->ptp?"PTP":"PMP", stack->l2link?"UP":"DOWN", stack->l1link?"UP":"DOWN",stack->blocked);
00145 
00146    } else {
00147       buf[0]=0;
00148    }
00149    
00150 }

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4241 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

04242 {
04243    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04244 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

Definition at line 4229 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04230 {
04231 #ifdef MISDN_1_2
04232    if (*bc->pipeline)
04233 #else
04234    if (bc->ec_enable)
04235 #endif
04236       manager_ec_enable(bc);
04237    else
04238       manager_ec_disable(bc);
04239 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4219 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

04220 {
04221    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04222 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4224 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

04225 {
04226    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04227 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

Definition at line 4100 of file isdn_lib.c.

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

Referenced by setup_bc().

04101 {
04102    char buf[128];
04103 
04104    struct misdn_stack *stack=get_stack_by_bc(bc);
04105 
04106    if (!stack) {
04107       cb_log(0, bc->port, "bchannel_activate: Stack not found !");
04108       return ;
04109    }
04110    
04111    /* we must activate if we are deactivated */
04112    clear_ibuffer(bc->astbuf);
04113    
04114    cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
04115    
04116    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
04117 
04118    return ;
04119 }

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

Definition at line 4122 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::astbuf, misdn_bchannel::bc_state, bc_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_RELEASE, 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().

04123 {
04124    char buf[128]; 
04125    iframe_t dact;
04126    struct misdn_stack *stack=get_stack_by_bc(bc);
04127 
04128    switch (bc->bc_state) {
04129       case BCHAN_ACTIVATED:
04130          break;
04131       case BCHAN_BRIDGED:
04132          misdn_split_conf(bc,bc->conf_id);
04133          break;
04134       default:
04135          cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
04136          return ;
04137 
04138    }
04139    
04140    cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
04141    
04142    bc->generate_tone=0;
04143    
04144    dact.prim = DL_RELEASE | REQUEST;
04145    dact.addr = bc->addr | FLG_MSG_DOWN;
04146    dact.dinfo = 0;
04147    dact.len = 0;
04148    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
04149 
04150    clear_ibuffer(bc->astbuf);
04151    
04152    bc_state_change(bc,BCHAN_RELEASE);
04153   
04154    return;
04155 }

void manager_ec_disable ( struct misdn_bchannel bc  ) 

Definition at line 4463 of file isdn_lib.c.

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

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

04464 {
04465    struct misdn_stack *stack=get_stack_by_bc(bc);
04466    
04467    cb_log(4, stack?stack->port:0," --> ec_disable\n");
04468 
04469    if (!misdn_cap_is_speech(bc->capability)) {
04470       cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
04471       return;
04472    }
04473 
04474 #ifdef MISDN_1_2
04475    manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
04476 #else
04477    if ( ! bc->ec_enable) {
04478       cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
04479       manager_ph_control(bc,  ECHOCAN_OFF, 0);
04480    }
04481 #endif
04482 }

void manager_ec_enable ( struct misdn_bchannel bc  ) 

Definition at line 4414 of file isdn_lib.c.

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

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

04415 {
04416    struct misdn_stack *stack=get_stack_by_bc(bc);
04417    
04418    cb_log(4, stack?stack->port:0,"ec_enable\n");
04419 
04420    if (!misdn_cap_is_speech(bc->capability)) {
04421       cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
04422    } else {
04423 
04424 #ifdef MISDN_1_2
04425    if (*bc->pipeline) {
04426       cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
04427       manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
04428    }
04429 #else
04430    int ec_arr[2];
04431 
04432    if (bc->ec_enable) {
04433       cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
04434    
04435       switch (bc->ec_deftaps) {
04436       case 4:
04437       case 8:
04438       case 16:
04439       case 32:
04440       case 64:
04441       case 128:
04442       case 256:
04443       case 512:
04444       case 1024:
04445          cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
04446          break;
04447       default:
04448          cb_log(0, stack->port, "Taps should be power of 2\n");
04449          bc->ec_deftaps=128;
04450       }
04451    
04452       ec_arr[0]=bc->ec_deftaps;
04453       ec_arr[1]=0;
04454       
04455       manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
04456    }
04457 #endif
04458    }
04459 }

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4095 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04096 {
04097    return isdn_get_info(msgs_g , event, 0);
04098 }

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

Definition at line 4198 of file isdn_lib.c.

References misdn_bchannel::addr, cb_log, misdn_lib::midev, and misdn_bchannel::port.

Referenced by handle_event(), isdn_lib_stop_dtmf(), isdn_lib_update_rxgain(), isdn_lib_update_txgain(), manager_ec_disable(), misdn_join_conf(), misdn_lib_echo(), misdn_lib_send_event(), misdn_lib_send_tone(), and misdn_split_conf().

04199 {
04200    unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
04201    iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
04202    unsigned int *d = (unsigned int*)&ctrl->data.p;
04203    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04204    
04205    cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
04206    
04207    ctrl->prim = PH_CONTROL | REQUEST;
04208    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04209    ctrl->dinfo = 0;
04210    ctrl->len = sizeof(unsigned int)*2;
04211    *d++ = c1;
04212    *d++ = c2;
04213    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04214 }

int misdn_cap_is_speech ( int  cap  ) 

void misdn_dump_chanlist ( void   ) 

Definition at line 447 of file isdn_lib.c.

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

Referenced by misdn_show_cls().

00448 {
00449    struct misdn_stack *stack=get_misdn_stack();
00450    for ( ; stack; stack=stack->next) {
00451       dump_chan_list(stack);
00452    }
00453 
00454 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

00420 {
00421 
00422    /*if ! early_bconnect we have never inband available*/
00423    if ( ! bc->early_bconnect ) return 0;
00424    
00425    switch (bc->progress_indicator) {
00426    case INFO_PI_INBAND_AVAILABLE:
00427    case INFO_PI_CALL_NOT_E2E_ISDN:
00428    case INFO_PI_CALLED_NOT_ISDN:
00429       return 1;
00430    default:
00431       return 0;
00432    }
00433    return 0;
00434 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

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

04518 {
04519    int conf_id=bc1->pid +1;
04520    struct misdn_bchannel *bc_list[]={
04521       bc1,bc2,NULL
04522    };
04523    struct misdn_bchannel **bc;
04524 
04525    cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
04526    
04527    for (bc=bc_list; *bc;  bc++) { 
04528       (*bc)->conf_id=conf_id;
04529       cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
04530    
04531       switch((*bc)->bc_state) {
04532          case BCHAN_ACTIVATED:
04533             misdn_join_conf(*bc,conf_id);
04534             break;
04535          default:
04536             bc_next_state_change(*bc,BCHAN_BRIDGED);
04537             break;
04538       }
04539    }
04540 }

void misdn_lib_destroy ( void   ) 

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

04063 {
04064    struct misdn_stack *help;
04065    int i;
04066   
04067    for ( help=glob_mgr->stack_list; help; help=help->next ) {
04068       for(i=0;i<=help->b_num; i++) {
04069          char buf[1024];
04070          mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
04071          help->bc[i].addr = 0;
04072       }
04073       cb_log (1, help->port, "Destroying this port.\n");
04074       stack_destroy(help);
04075    }
04076    
04077    if (global_state == MISDN_INITIALIZED) {
04078       cb_log(4, 0, "Killing Handler Thread\n");
04079       if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
04080          cb_log(4, 0, "Joining Handler Thread\n");
04081          pthread_join(glob_mgr->event_handler_thread, NULL);
04082       }
04083      
04084       cb_log(4, 0, "Killing Main Thread\n");
04085       if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
04086          cb_log(4, 0, "Joining Main Thread\n");
04087          pthread_join(glob_mgr->event_thread, NULL);
04088       }
04089    }
04090   
04091    cb_log(1, 0, "Closing mISDN device\n");
04092    te_lib_destroy(glob_mgr->midev);
04093 }

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4562 of file isdn_lib.c.

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

04563 {
04564    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04565    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04566 }

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

Definition at line 3142 of file isdn_lib.c.

References misdn_stack::b_num, misdn_stack::bc, misdn_stack::blocked, cb_log, misdn_bchannel::channel, misdn_bchannel::cw, misdn_bchannel::dec, MAX_BCHANS, misdn_stack::next, misdn_stack::port, prepare_bc(), misdn_stack::pri, misdn_stack::ptp, misdn_lib::stack_list, and test_inuse().

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

03143 {
03144    struct misdn_stack *stack;
03145    int i;
03146    
03147    if (channel < 0 || channel > MAX_BCHANS) {
03148       cb_log(0,port,"Requested channel out of bounds (%d)\n",channel);
03149       return NULL;
03150    }
03151 
03152    usleep(1000);
03153 
03154    for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
03155     
03156       if (stack->port == port) {
03157          int maxnum;
03158          if (stack->blocked) {
03159             cb_log(0,port,"Port is blocked\n");
03160             return NULL;
03161          }
03162       
03163          if (channel > 0) {
03164             if (channel <= stack->b_num) {
03165                for (i = 0; i < stack->b_num; i++) {
03166                   if ( test_inuse(&stack->bc[i]) && stack->bc[i].channel == channel) {
03167                      cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
03168                      return NULL;
03169                   }
03170                }
03171             } else {
03172                cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port);
03173                return NULL;
03174             }
03175          }
03176 
03177          maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
03178 
03179          if (dec) {
03180             for (i = maxnum-1; i>=0; i--) {
03181                if (test_inuse(&stack->bc[i])) {
03182                   /* 3. channel on bri means CW*/
03183                   if (!stack->pri && i==stack->b_num)
03184                      stack->bc[i].cw=1;
03185                      
03186                   prepare_bc(&stack->bc[i], channel);
03187                   stack->bc[i].dec=1;
03188                   return &stack->bc[i];
03189                }
03190             }
03191          } else {
03192             for (i = 0; i <maxnum; i++) {
03193                if (test_inuse(&stack->bc[i])) {
03194                   /* 3. channel on bri means CW*/
03195                   if (!stack->pri && i==stack->b_num)
03196                      stack->bc[i].cw=1;
03197 
03198                   prepare_bc(&stack->bc[i], channel);
03199                   return &stack->bc[i];
03200                }
03201             }
03202          }
03203 
03204          cb_log(1,port,"There is no free channel on port (%d)\n",port);
03205          return NULL;
03206       }
03207    }
03208 
03209    cb_log(0,port,"Port is not configured (%d)\n",port);
03210    return NULL;
03211 }

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 103 of file isdn_lib.c.

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

Referenced by misdn_request().

00104 {
00105    struct misdn_stack *stack=get_misdn_stack();
00106    for ( ; stack; stack=stack->next) {
00107       if (stack->port == port) {
00108          if (stack->pri) 
00109             return 30;
00110          else
00111             return 2;
00112       }
00113    }
00114    return -1;
00115 }

int misdn_lib_get_port_down ( int  port  ) 

Definition at line 1724 of file isdn_lib.c.

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

Referenced by misdn_port_down().

01725 { /* Pull Down L1 */ 
01726    struct misdn_stack *stack;
01727    for (stack=glob_mgr->stack_list;
01728         stack;
01729         stack=stack->next) {
01730       if (stack->port == port) {
01731             if (stack->l2link)
01732                misdn_lib_get_l2_down(stack);
01733             misdn_lib_get_l1_down(stack);
01734          return 0;
01735       }
01736    }
01737    return 0;
01738 }

int misdn_lib_get_port_info ( int  port  ) 

Definition at line 3668 of file isdn_lib.c.

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

03669 {
03670    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03671    iframe_t *frm;
03672    struct misdn_stack *stack=find_stack_by_port(port);
03673    if (!msg) {
03674       cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n");
03675       return -1;
03676    }
03677    frm=(iframe_t*)msg->data;
03678    if (!stack ) {
03679       cb_log(0, port, "There is no Stack for this port.\n");
03680       return -1;
03681    }
03682    /* activate bchannel */
03683    frm->prim = CC_STATUS_ENQUIRY | REQUEST;
03684 
03685    frm->addr = stack->upper_id| FLG_MSG_DOWN;
03686 
03687    frm->dinfo = 0;
03688    frm->len = 0;
03689   
03690    msg_queue_tail(&glob_mgr->activatequeue, msg);
03691    sem_post(&glob_mgr->new_msg);
03692 
03693   
03694    return 0; 
03695 }

int misdn_lib_get_port_up ( int  port  ) 

Definition at line 1702 of file isdn_lib.c.

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

Referenced by misdn_check_l2l1(), and misdn_port_up().

01703 { /* Pull Up L1 */ 
01704    struct misdn_stack *stack;
01705    
01706    for (stack=glob_mgr->stack_list;
01707         stack;
01708         stack=stack->next) {
01709       
01710       if (stack->port == port) {
01711 
01712          if (!stack->l1link)
01713             misdn_lib_get_l1_up(stack);
01714          if (!stack->l2link)
01715             misdn_lib_get_l2_up(stack);
01716          
01717          return 0;
01718       }
01719    }
01720    return 0;
01721 }

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

Definition at line 3954 of file isdn_lib.c.

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

Referenced by load_module().

03955 {
03956    struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
03957    char *tok, *tokb;
03958    char plist[1024];
03959    int midev;
03960    int port_count=0;
03961  
03962    cb_log = iface->cb_log;
03963    cb_event = iface->cb_event;
03964    cb_jb_empty = iface->cb_jb_empty;
03965    
03966    glob_mgr = mgr;
03967   
03968    msg_init();
03969 
03970    misdn_lib_nt_debug_init(0,NULL);
03971    
03972    if (!portlist || (*portlist == 0) ) return 1;
03973    
03974    init_flip_bits();
03975    
03976    {
03977       strncpy(plist,portlist, 1024);
03978       plist[1023] = 0;
03979    }
03980   
03981    memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
03982    flip_buf_bits(tone_425_flip,TONE_425_SIZE);
03983 
03984    memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
03985    flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);
03986   
03987    midev=te_lib_init();
03988    mgr->midev=midev;
03989 
03990    port_count=mISDN_get_stack_count(midev);
03991   
03992    msg_queue_init(&mgr->activatequeue);
03993   
03994    if (sem_init(&mgr->new_msg, 1, 0)<0)
03995       sem_init(&mgr->new_msg, 0, 0);
03996  
03997    for (tok=strtok_r(plist," ,",&tokb );
03998         tok; 
03999         tok=strtok_r(NULL," ,",&tokb)) {
04000       int port = atoi(tok);
04001       struct misdn_stack *stack;
04002       static int first=1;
04003       int ptp=0;
04004     
04005       if (strstr(tok, "ptp"))
04006          ptp=1;
04007 
04008       if (port > port_count) {
04009          cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
04010          exit(1);
04011       }
04012       stack=stack_init(midev, port, ptp);
04013     
04014       if (!stack) {
04015          perror("init_stack");
04016          exit(1);
04017       }
04018     
04019       {
04020          int i;
04021          for(i=0;i<=stack->b_num; i++) {
04022             int r;
04023             if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
04024                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
04025                exit(1);
04026             }
04027          }
04028       }
04029 
04030       if (stack && first) {
04031          mgr->stack_list=stack;
04032          first=0;
04033          continue;
04034       }
04035     
04036       if (stack) {
04037          struct misdn_stack * help;
04038          for ( help=mgr->stack_list; help; help=help->next ) 
04039             if (help->next == NULL) break;
04040          help->next=stack;
04041       }
04042     
04043    }
04044   
04045    if (sem_init(&handler_started, 1, 0)<0)
04046       sem_init(&handler_started, 0, 0);
04047   
04048    cb_log(8, 0, "Starting Event Handler\n");
04049    pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr);
04050   
04051    sem_wait(&handler_started) ;
04052    cb_log(8, 0, "Starting Event Catcher\n");
04053    pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);
04054   
04055    cb_log(8, 0, "Event Catcher started\n");
04056 
04057    global_state= MISDN_INITIALIZED; 
04058   
04059    return (mgr == NULL);
04060 }

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 83 of file isdn_lib.c.

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

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

int misdn_lib_is_ptp ( int  port  ) 

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

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

void misdn_lib_isdn_l1watcher ( int  port  ) 

Definition at line 2973 of file isdn_lib.c.

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

Referenced by misdn_l1_task().

02974 {
02975    struct misdn_stack *stack;
02976 
02977    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
02978       ;
02979 
02980    if (stack) {
02981       cb_log(4, port, "Checking L1 State\n");   
02982       if (!stack->l1link) {
02983          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
02984          misdn_lib_get_short_status(stack);
02985          misdn_lib_get_l1_up(stack); 
02986          misdn_lib_get_l2_up(stack); 
02987       }
02988    }
02989 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

Definition at line 3232 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::b_stid, bearer2str(), misdn_bchannel::cad, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::cpnnumplan, misdn_bchannel::dnumplan, fac2str(), misdn_bchannel::fac_in, misdn_bchannel::fac_out, get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::info_dad, misdn_bchannel::keypad, misdn_bchannel::l3_id, misdn_bchannel::layer_id, misdn_bchannel::mode, misdn_stack::nt, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_stack::port, misdn_bchannel::pres, misdn_bchannel::progress_indicator, misdn_bchannel::rad, misdn_bchannel::rate, misdn_bchannel::rnumplan, misdn_bchannel::screen, misdn_bchannel::sending_complete, misdn_bchannel::stack_holder, misdn_bchannel::urate, and misdn_bchannel::user1.

Referenced by cb_events(), and misdn_lib_send_event().

03233 {
03234    struct misdn_stack *stack;
03235    if (!bc) return;
03236 
03237    stack=get_stack_by_bc(bc);
03238 
03239    if (!stack) return;
03240 
03241    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);
03242    
03243    cb_log(2, stack->port,
03244           " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
03245           bc->info_dad,
03246           bc->onumplan>=0?'0'+bc->onumplan:' ',
03247           bc->dnumplan>=0?'0'+bc->dnumplan:' ',
03248           bc->rnumplan>=0?'0'+bc->rnumplan:' ',
03249           bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
03250       );
03251    
03252    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);
03253    cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
03254          bc->screen, bc->pres);
03255    
03256    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);
03257    
03258    cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
03259 
03260    cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
03261    
03262    cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
03263 }

int misdn_lib_maxports_get ( void   ) 

BE AWARE WE HAVE NO CB_LOG HERE!

Definition at line 3906 of file isdn_lib.c.

Referenced by load_module().

03906                              { /** BE AWARE WE HAVE NO CB_LOG HERE! **/
03907    
03908    int i = mISDN_open();
03909    int max=0;
03910    
03911    if (i<0)
03912       return -1;
03913 
03914    max = mISDN_get_stack_count(i);
03915    
03916    mISDN_close(i);
03917    
03918    return max;
03919 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 3934 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

03935 {
03936    int static init=0;
03937    char *f;
03938    
03939    if (!flags) 
03940       f=NULL;
03941    else
03942       f=file;
03943 
03944    if (!init) {
03945       debug_init( flags , f, f, f);
03946       init=1;
03947    } else {
03948       debug_close();
03949       debug_init( flags , f, f, f);
03950    }
03951 }

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 3922 of file isdn_lib.c.

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

Referenced by load_module().

03923 {
03924 #ifdef FEATURE_NET_KEEPCALLS
03925    if (kc) {
03926       struct misdn_stack *stack=get_misdn_stack();
03927       for ( ; stack; stack=stack->next) {
03928          stack->nst.feature |= FEATURE_NET_KEEPCALLS;
03929       }
03930    }
03931 #endif
03932 }

int misdn_lib_pid_restart ( int  pid  ) 

int misdn_lib_port_block ( int  port  ) 

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

00058 {
00059    struct misdn_stack *stack=get_misdn_stack();
00060    for ( ; stack; stack=stack->next) {
00061       if (stack->port == port) {
00062          stack->blocked=1;
00063          return 0;
00064       }
00065    }
00066    return -1;
00067 
00068 }

int misdn_lib_port_is_pri ( int  port  ) 

Definition at line 35 of file isdn_lib.c.

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

Referenced by misdn_new(), and update_name().

00036 {
00037    struct misdn_stack *stack=get_misdn_stack();
00038    for ( ; stack; stack=stack->next) {
00039       if (stack->port == port) {
00040          return stack->pri;
00041       }
00042    }
00043    
00044    return -1;
00045 }

int misdn_lib_port_restart ( int  port  ) 

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 70 of file isdn_lib.c.

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

Referenced by misdn_port_unblock().

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

int misdn_lib_port_up ( int  port,
int  notcheck 
)

Definition at line 1740 of file isdn_lib.c.

References misdn_stack::blocked, cb_log, misdn_stack::l1link, misdn_stack::l2link, misdn_stack::next, misdn_stack::port, misdn_stack::ptp, and misdn_lib::stack_list.

Referenced by misdn_check_l2l1(), and misdn_request().

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

void misdn_lib_reinit_nt_stack ( int  port  ) 

Definition at line 4570 of file isdn_lib.c.

References misdn_stack::blocked, misdn_stack::d_stid, find_stack_by_port(), handle_event_nt(), misdn_stack::l2link, misdn_stack::lower_id, misdn_stack::mgr, misdn_lib::midev, misdn_lib_get_l1_up(), misdn_lib_get_l2_up(), misdn_stack::nst, misdn_stack::pri, misdn_stack::ptp, and misdn_stack::upper_id.

Referenced by handle_event_nt(), and misdn_lib_port_restart().

04571 {
04572    struct misdn_stack *stack=find_stack_by_port(port);
04573    
04574    if (stack) {
04575       stack->l2link=0;
04576       stack->blocked=0;
04577    
04578       cleanup_Isdnl3(&stack->nst);
04579       cleanup_Isdnl2(&stack->nst);
04580 
04581 
04582       memset(&stack->nst, 0, sizeof(net_stack_t));
04583       memset(&stack->mgr, 0, sizeof(manager_t));
04584    
04585       stack->mgr.nst = &stack->nst;
04586       stack->nst.manager = &stack->mgr;
04587     
04588       stack->nst.l3_manager = handle_event_nt;
04589       stack->nst.device = glob_mgr->midev;
04590       stack->nst.cardnr = port;
04591       stack->nst.d_stid = stack->d_stid;
04592    
04593       stack->nst.feature = FEATURE_NET_HOLD;
04594       if (stack->ptp)
04595          stack->nst.feature |= FEATURE_NET_PTP;
04596       if (stack->pri)
04597          stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
04598       
04599       stack->nst.l1_id = stack->lower_id;
04600       stack->nst.l2_id = stack->upper_id;
04601       
04602       msg_queue_init(&stack->nst.down_queue);
04603    
04604       Isdnl2Init(&stack->nst);
04605       Isdnl3Init(&stack->nst);
04606 
04607       if (!stack->ptp)
04608          misdn_lib_get_l1_up(stack);
04609       misdn_lib_get_l2_up(stack);
04610    }
04611 }

void misdn_lib_release ( struct misdn_bchannel bc  ) 

Definition at line 1682 of file isdn_lib.c.

References cb_log, misdn_bchannel::channel, clean_up_bc(), empty_bc(), empty_chan_in_stack(), get_stack_by_bc(), and misdn_bchannel::in_use.

Referenced by misdn_hangup().

01683 {
01684    struct misdn_stack *stack=get_stack_by_bc(bc);
01685 
01686    if (!stack) {
01687       cb_log(1,0,"misdn_release: No Stack found\n");
01688       return;
01689    }
01690    
01691    if (bc->channel>0) 
01692       empty_chan_in_stack(stack,bc->channel);
01693    
01694    empty_bc(bc);
01695    clean_up_bc(bc);
01696    bc->in_use=0;
01697 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Queue Event

Definition at line 3284 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, clean_up_bc(), misdn_bchannel::conf_id, create_process(), misdn_bchannel::crypt_key, misdn_bchannel::dad, misdn_bchannel::dnumplan, misdn_stack::downqueue, empty_bc(), empty_chan_in_stack(), ENOCHAN, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_HOLD_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), 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().

03285 {
03286    msg_t *msg; 
03287    struct misdn_stack *stack;
03288    int retval=0;
03289   
03290    if (!bc) RETURN(-1,OUT_POST_UNLOCK);
03291    
03292    stack=get_stack_by_bc(bc);
03293    
03294    if (!stack) {
03295       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);
03296       RETURN(-1,OUT);
03297    }
03298    
03299    misdn_send_lock(bc);
03300 
03301 
03302    cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id);
03303 
03304    if ( stack->nt && !stack->l1link) {
03305       /** Queue Event **/
03306       bc->evq=event;
03307       cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
03308       misdn_lib_get_l1_up(stack);
03309       RETURN(0,OUT);
03310    }
03311    
03312    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);
03313    cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
03314    misdn_lib_log_ies(bc);
03315    
03316    switch (event) {
03317    case EVENT_SETUP:
03318       if (create_process(glob_mgr->midev, bc)<0) {
03319          cb_log(0,  stack->port, " No free channel at the moment @ send_event\n");
03320 
03321          RETURN(-ENOCHAN,OUT);
03322       }
03323       break;
03324 
03325    case EVENT_PROGRESS:
03326    case EVENT_ALERTING:
03327    case EVENT_PROCEEDING:
03328    case EVENT_SETUP_ACKNOWLEDGE:
03329    case EVENT_CONNECT:
03330       if (!stack->nt) break;
03331 
03332    case EVENT_RETRIEVE_ACKNOWLEDGE:
03333 
03334       if (stack->nt) {
03335          if (bc->channel <=0 ) { /*  else we have the channel already */
03336             if (find_free_chan_in_stack(stack, bc, 0, 0)<0) {
03337                cb_log(0, stack->port, " No free channel at the moment\n");
03338                /*FIXME: add disconnect*/
03339                RETURN(-ENOCHAN,OUT);
03340             }
03341          }
03342          /* Its that i generate channels */
03343       }
03344 
03345       retval=setup_bc(bc);
03346       if (retval == -EINVAL) {
03347          cb_log(0,bc->port,"send_event: setup_bc failed\n");
03348       }
03349 
03350       if (misdn_cap_is_speech(bc->capability)) {
03351          if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
03352             if ( *bc->crypt_key ) {
03353                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);
03354                
03355                manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
03356             }
03357             
03358             if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03359             manager_ec_enable(bc);
03360             
03361             if (bc->txgain != 0) {
03362                cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
03363                manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03364             }
03365             
03366             if ( bc->rxgain != 0 ) {
03367                cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
03368                manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03369             }
03370          }
03371       }
03372       break;
03373 
03374    case EVENT_HOLD_ACKNOWLEDGE:
03375    {
03376       struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel));
03377       if (!holded_bc) {
03378          cb_log(0,bc->port, "Could not allocate holded_bc!!!\n");
03379          RETURN(-1,OUT);
03380       }
03381 
03382       /*backup the bc*/
03383       memcpy(holded_bc,bc,sizeof(struct misdn_bchannel));
03384       holded_bc->holded=1;
03385       bc_state_change(holded_bc,BCHAN_CLEANED);
03386 
03387       stack_holder_add(stack,holded_bc);
03388    
03389       /*kill the bridge and clean the bchannel*/
03390       if (stack->nt) {
03391          int channel;
03392          if (bc->bc_state == BCHAN_BRIDGED) {
03393             struct misdn_bchannel *bc2;
03394             misdn_split_conf(bc,bc->conf_id);
03395             bc2=find_bc_by_confid(bc->conf_id);
03396             if (!bc2) {
03397                cb_log(0,bc->port,"We have no second bc in bridge???\n");
03398             } else {
03399                misdn_split_conf(bc2,bc->conf_id);
03400             }
03401          }
03402          
03403          channel=bc->channel;
03404 
03405          empty_bc(bc);
03406          clean_up_bc(bc);
03407 
03408          if (channel>0)
03409             empty_chan_in_stack(stack,channel);
03410 
03411          bc->in_use=0;  
03412       }
03413       
03414    }
03415    break;
03416 
03417    /* finishing the channel eh ? */
03418    case EVENT_DISCONNECT:
03419       if (!bc->need_disconnect) {
03420          cb_log(0,bc->port," --> we have already send Disconnect\n");
03421          RETURN(-1,OUT);
03422       }
03423       
03424       bc->need_disconnect=0;
03425       break;
03426    case EVENT_RELEASE:
03427       if (!bc->need_release) {
03428          cb_log(0,bc->port," --> we have already send Release\n");
03429          RETURN(-1,OUT);
03430       }
03431       bc->need_disconnect=0;
03432       bc->need_release=0;
03433       break;
03434    case EVENT_RELEASE_COMPLETE:
03435       if (!bc->need_release_complete) {
03436          cb_log(0,bc->port," --> we have already send Release_complete\n");
03437          RETURN(-1,OUT);
03438       }
03439       bc->need_disconnect=0;
03440       bc->need_release=0;
03441       bc->need_release_complete=0;
03442 
03443       if (!stack->nt) {
03444          /*create clenaup in TE*/
03445          int channel=bc->channel;
03446 
03447          int tmpcause=bc->cause; 
03448          int tmp_out_cause=bc->out_cause; 
03449          empty_bc(bc);
03450          bc->cause=tmpcause;
03451          bc->out_cause=tmp_out_cause;
03452          clean_up_bc(bc);
03453          
03454          if (channel>0)
03455             empty_chan_in_stack(stack,channel);
03456          
03457          bc->in_use=0;
03458       }
03459       break;
03460     
03461    case EVENT_CONNECT_ACKNOWLEDGE:
03462 
03463       if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
03464          int retval=setup_bc(bc);
03465          if (retval == -EINVAL){
03466             cb_log(0,bc->port,"send_event: setup_bc failed\n");
03467             
03468          }
03469       }
03470       
03471       if (misdn_cap_is_speech(bc->capability)) {
03472          if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03473          manager_ec_enable(bc);
03474 
03475          if ( bc->txgain != 0 ) {
03476             cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
03477             manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
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       break;
03485     
03486    default:
03487       break;
03488    }
03489   
03490    /* Later we should think about sending bchannel data directly to misdn. */
03491    msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
03492    msg_queue_tail(&stack->downqueue, msg);
03493    sem_post(&glob_mgr->new_msg);
03494   
03495 OUT:
03496    misdn_send_unlock(bc);
03497 
03498 OUT_POST_UNLOCK:
03499    return retval; 
03500 }

int misdn_lib_send_restart ( int  port,
int  channel 
)

Definition at line 3734 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, make_dummy(), misdn_lib_send_event(), misdn_stack::nt, and misdn_stack::port.

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

03735 {
03736    struct misdn_bchannel dummybc;
03737    struct misdn_stack *stack=find_stack_by_port(port);
03738    cb_log(0, port, "Sending Restarts on this port.\n");
03739    
03740    make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
03741 
03742    /*default is all channels*/
03743    if (channel <0) {
03744       dummybc.channel=-1;
03745       cb_log(0, port, "Restarting and all Interfaces\n");
03746       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03747 
03748       return 0;
03749    }
03750 
03751    /*if a channel is specified we restart only this one*/
03752    if (channel >0) {
03753       int cnt;
03754       dummybc.channel=channel;
03755       cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
03756       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03757       /* clean up chan in stack, to be sure we don't think it's
03758        * in use anymore */
03759       for (cnt=0; cnt<=stack->b_num; cnt++) {
03760          if (stack->bc[cnt].channel == channel) {
03761             empty_bc(&stack->bc[cnt]);
03762             clean_up_bc(&stack->bc[cnt]);
03763             stack->bc[cnt].in_use=0;
03764          }
03765       }
03766    }
03767 
03768    return 0;
03769 }

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4379 of file isdn_lib.c.

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

Referenced by hanguptone_indicate().

04380 {
04381    char buf[mISDN_HEADER_LEN+128];
04382    iframe_t *frm;
04383 
04384    switch(tone) {
04385    case TONE_DIAL:
04386       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 
04387    break;
04388    
04389    case TONE_ALERTING:
04390       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);  
04391    break;
04392    
04393    case TONE_HANGUP:
04394       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);   
04395    break;
04396 
04397    case TONE_NONE:
04398    default:
04399       manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);  
04400    }
04401 
04402    frm=(iframe_t*)buf;
04403    memset(buf,0,mISDN_HEADER_LEN+128);
04404 
04405    frm->prim=DL_DATA|REQUEST;
04406    frm->addr=bc->addr|FLG_MSG_DOWN;
04407    frm->dinfo=0;
04408    frm->len=128;
04409    
04410    mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
04411 }

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 945 of file isdn_lib.c.

References clean_up_bc(), and setup_bc().

00946 {
00947    clean_up_bc(bc);
00948    setup_bc(bc);
00949 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4542 of file isdn_lib.c.

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

Referenced by misdn_bridge().

04543 {
04544 
04545    struct misdn_bchannel *bc_list[]={
04546       bc1,bc2,NULL
04547    };
04548    struct misdn_bchannel **bc;
04549       
04550    for (bc=bc_list; *bc;  bc++) { 
04551       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04552          misdn_split_conf( *bc, (*bc)->conf_id);
04553       } else {
04554          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04555       }
04556    }
04557    
04558 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2184 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02185 {
02186    bc->generate_tone=1;
02187 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2189 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02190 {
02191    bc->generate_tone=0;
02192 }

void misdn_lib_transfer ( struct misdn_bchannel holded_bc  ) 

Definition at line 3080 of file isdn_lib.c.

References misdn_bchannel::holded.

03081 {
03082    holded_bc->holded=0;
03083 }

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

Definition at line 4158 of file isdn_lib.c.

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

04159 {
04160    char buf[4096 + mISDN_HEADER_LEN];
04161    iframe_t *frm;
04162    int  r;
04163    struct misdn_stack *stack=get_stack_by_bc(bc);
04164 
04165    switch (bc->bc_state) {
04166       case BCHAN_ACTIVATED:
04167       case BCHAN_BRIDGED:
04168          break;
04169       default:
04170          cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
04171          return -1;
04172    }
04173    
04174    frm= (iframe_t*)buf;
04175    
04176    frm->prim = DL_DATA|REQUEST;
04177    frm->dinfo = 0;
04178    frm->addr = bc->addr | FLG_MSG_DOWN ;
04179    
04180    frm->len = len;
04181    memcpy(&buf[mISDN_HEADER_LEN], data,len);
04182       
04183    if ( misdn_cap_is_speech(bc->capability) ) 
04184       flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
04185    else
04186       cb_log(6, stack->port, "Writing %d data bytes\n",len);
04187    
04188    cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
04189    r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
04190    return 0;
04191 }


Variable Documentation

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

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

Referenced by misdn_lib_init(), and misdn_tx_jitter().

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

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


Generated on Thu Oct 8 21:57:51 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.8