Mon May 14 04:48:56 2007

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

Definition at line 70 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 468 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 469 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 466 of file isdn_lib.h.

Referenced by zt_call(), and zt_new().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 467 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

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

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

enum event_response_e

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

enum misdn_err_e

Enumerator:
ENOCHAN 

Definition at line 89 of file isdn_lib.h.

00089                  {
00090    ENOCHAN=1
00091 };

enum mISDN_NUMBER_PLAN

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

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

00490                                               {
00491    int i;
00492    
00493    struct bchan_state_s {
00494       char *n;
00495       enum bchannel_state s;
00496    } states[] = {
00497       {"BCHAN_CLEANED", BCHAN_CLEANED },
00498       {"BCHAN_EMPTY", BCHAN_EMPTY},
00499       {"BCHAN_SETUP", BCHAN_SETUP},
00500       {"BCHAN_SETUPED", BCHAN_SETUPED},
00501       {"BCHAN_ACTIVE", BCHAN_ACTIVE},
00502       {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
00503       {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
00504       {"BCHAN_BRIDGED", BCHAN_BRIDGED},
00505       {"BCHAN_RELEASE", BCHAN_RELEASE},
00506       {"BCHAN_RELEASED", BCHAN_RELEASED},
00507       {"BCHAN_CLEAN", BCHAN_CLEAN},
00508       {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
00509       {"BCHAN_ERROR", BCHAN_ERROR}
00510    };
00511    
00512    for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
00513       if ( states[i].s == state)
00514          return states[i].n;
00515 
00516    return "UNKNOWN";
00517 }

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

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

00520 {
00521    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00522       bc->l3_id,
00523           bc_state2str(bc->bc_state),
00524           bc_state2str(state) );
00525    
00526    switch (state) {
00527       case BCHAN_ACTIVATED:
00528          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00529             misdn_join_conf(bc, bc->conf_id);
00530             bc->next_bc_state = BCHAN_EMPTY;
00531             return;
00532          }
00533       default:
00534          bc->bc_state=state;
00535          break;
00536    }
00537 }

void get_show_stack_details ( int  port,
char *  buf 
)

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

00122 {
00123    struct misdn_stack *stack=get_misdn_stack();
00124    
00125    for ( ; stack; stack=stack->next) {
00126       if (stack->port == port) break;
00127    }
00128    
00129    if (stack) {
00130       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);
00131 
00132    } else {
00133       buf[0]=0;
00134    }
00135    
00136 }

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4141 of file isdn_lib.c.

References misdn_stack::bc, and manager_ph_control().

Referenced by process_ast_dsp().

04142 {
04143    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04144 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

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

04130 {
04131 #ifdef MISDN_1_2
04132    if (*bc->pipeline)
04133 #else
04134    if (bc->ec_enable)
04135 #endif
04136       manager_ec_enable(bc);
04137    else
04138       manager_ec_disable(bc);
04139 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4119 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04120 {
04121    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04122 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4124 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04125 {
04126    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04127 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

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

Referenced by setup_bc().

04000 {
04001    char buf[128];
04002 
04003    struct misdn_stack *stack=get_stack_by_bc(bc);
04004 
04005    if (!stack) {
04006       cb_log(0, bc->port, "bchannel_activate: Stack not found !");
04007       return ;
04008    }
04009    
04010    /* we must activate if we are deactivated */
04011    clear_ibuffer(bc->astbuf);
04012    
04013    cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
04014    
04015    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
04016 
04017    return ;
04018 }

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

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

04022 {
04023 
04024    struct misdn_stack *stack=get_stack_by_bc(bc);
04025 
04026 
04027    switch (bc->bc_state) {
04028       case BCHAN_ACTIVATED:
04029          break;
04030       case BCHAN_BRIDGED:
04031          misdn_split_conf(bc,bc->conf_id);
04032          break;
04033       default:
04034          cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
04035          return ;
04036 
04037    }
04038    
04039    cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
04040    
04041    bc->generate_tone=0;
04042    
04043    iframe_t dact;
04044    dact.prim = DL_RELEASE | REQUEST;
04045    dact.addr = bc->addr | FLG_MSG_DOWN;
04046    dact.dinfo = 0;
04047    dact.len = 0;
04048    char buf[128]; 
04049    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
04050 
04051    clear_ibuffer(bc->astbuf);
04052    
04053    bc_state_change(bc,BCHAN_RELEASE);
04054   
04055    return;
04056 }

void manager_ec_disable ( struct misdn_bchannel bc  ) 

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

04362 {
04363    struct misdn_stack *stack=get_stack_by_bc(bc);
04364    
04365    cb_log(4, stack?stack->port:0," --> ec_disable\n");
04366 
04367    if (!misdn_cap_is_speech(bc->capability)) {
04368       cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
04369       return;
04370    }
04371 
04372 #ifdef MISDN_1_2
04373    manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
04374 #else
04375    if ( ! bc->ec_enable) {
04376       cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
04377       manager_ph_control(bc,  ECHOCAN_OFF, 0);
04378    }
04379 #endif
04380 }

void manager_ec_enable ( struct misdn_bchannel bc  ) 

Definition at line 4312 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 isdn_lib_update_ec(), misdn_lib_send_event(), and misdn_toggle_echocancel().

04313 {
04314    struct misdn_stack *stack=get_stack_by_bc(bc);
04315    
04316    cb_log(4, stack?stack->port:0,"ec_enable\n");
04317 
04318    if (!misdn_cap_is_speech(bc->capability)) {
04319       cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
04320    } else {
04321 
04322 #ifdef MISDN_1_2
04323    if (*bc->pipeline) {
04324       cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
04325       manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
04326    }
04327 #else
04328    int ec_arr[2];
04329 
04330    if (bc->ec_enable) {
04331       cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
04332    
04333       switch (bc->ec_deftaps) {
04334       case 4:
04335       case 8:
04336       case 16:
04337       case 32:
04338       case 64:
04339       case 128:
04340       case 256:
04341       case 512:
04342       case 1024:
04343          cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
04344          break;
04345       default:
04346          cb_log(0, stack->port, "Taps should be power of 2\n");
04347          bc->ec_deftaps=128;
04348       }
04349    
04350       ec_arr[0]=bc->ec_deftaps;
04351       ec_arr[1]=0;
04352       
04353       manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
04354    }
04355 #endif
04356    }
04357 }

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 3994 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

03995 {
03996    return isdn_get_info(msgs_g , event, 0);
03997 }

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

Definition at line 4098 of file isdn_lib.c.

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

Referenced by 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().

04099 {
04100    unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
04101    iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
04102    unsigned int *d = (unsigned int*)&ctrl->data.p;
04103    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04104    
04105    cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
04106    
04107    ctrl->prim = PH_CONTROL | REQUEST;
04108    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04109    ctrl->dinfo = 0;
04110    ctrl->len = sizeof(unsigned int)*2;
04111    *d++ = c1;
04112    *d++ = c2;
04113    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04114 }

int misdn_cap_is_speech ( int  cap  ) 

Poor mans version

Definition at line 396 of file isdn_lib.c.

References INFO_CAPABILITY_DIGITAL_RESTRICTED, and INFO_CAPABILITY_DIGITAL_UNRESTRICTED.

Referenced by handle_bchan(), handle_event(), handle_event_nt(), manager_ec_disable(), manager_ec_enable(), misdn_lib_send_event(), and misdn_lib_tx2misdn_frm().

00398 {
00399    if ( (cap != INFO_CAPABILITY_DIGITAL_UNRESTRICTED) &&
00400         (cap != INFO_CAPABILITY_DIGITAL_RESTRICTED) ) return 1;
00401    return 0;
00402 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

00405 {
00406 
00407    /*if ! early_bconnect we have never inband available*/
00408    if ( ! bc->early_bconnect ) return 0;
00409    
00410    switch (bc->progress_indicator) {
00411    case INFO_PI_INBAND_AVAILABLE:
00412    case INFO_PI_CALL_NOT_E2E_ISDN:
00413    case INFO_PI_CALLED_NOT_ISDN:
00414       return 1;
00415    default:
00416       return 0;
00417    }
00418    return 0;
00419 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4415 of file isdn_lib.c.

References bc_next_state_change(), BCHAN_ACTIVATED, BCHAN_BRIDGED, cb_log, misdn_bchannel::conf_id, misdn_join_conf(), misdn_bchannel::pid, and misdn_bchannel::port.

Referenced by misdn_bridge().

04415                                                                                 {
04416    int conf_id=bc1->pid +1;
04417 
04418    cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
04419    
04420    struct misdn_bchannel *bc_list[]={
04421       bc1,bc2,NULL
04422    };
04423    struct misdn_bchannel **bc;
04424       
04425    for (bc=bc_list; *bc;  bc++) { 
04426       (*bc)->conf_id=conf_id;
04427       cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
04428    
04429       switch((*bc)->bc_state) {
04430          case BCHAN_ACTIVATED:
04431             misdn_join_conf(*bc,conf_id);
04432             break;
04433          default:
04434             bc_next_state_change(*bc,BCHAN_BRIDGED);
04435             break;
04436       }
04437    }
04438 }

void misdn_lib_destroy ( void   ) 

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

03962 {
03963    struct misdn_stack *help;
03964    int i;
03965   
03966    for ( help=glob_mgr->stack_list; help; help=help->next ) {
03967       for(i=0;i<=help->b_num; i++) {
03968          char buf[1024];
03969          mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
03970          help->bc[i].addr = 0;
03971       }
03972       cb_log (1, help->port, "Destroying this port.\n");
03973       stack_destroy(help);
03974    }
03975    
03976    if (global_state == MISDN_INITIALIZED) {
03977       cb_log(4, 0, "Killing Handler Thread\n");
03978       if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
03979          cb_log(4, 0, "Joining Handler Thread\n");
03980          pthread_join(glob_mgr->event_handler_thread, NULL);
03981       }
03982      
03983       cb_log(4, 0, "Killing Main Thread\n");
03984       if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
03985          cb_log(4, 0, "Joining Main Thread\n");
03986          pthread_join(glob_mgr->event_thread, NULL);
03987       }
03988    }
03989   
03990    cb_log(1, 0, "Closing mISDN device\n");
03991    te_lib_destroy(glob_mgr->midev);
03992 }

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4460 of file isdn_lib.c.

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

04461 {
04462    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04463    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04464 }

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

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

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

03085 {
03086    struct misdn_stack *stack;
03087    int i;
03088    
03089    if (channel < 0 || channel > MAX_BCHANS) {
03090       cb_log(0,port,"Requested channel out of bounds (%d)\n",channel);
03091       return NULL;
03092    }
03093 
03094    for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
03095     
03096       if (stack->port == port) {
03097          if (stack->blocked) {
03098             cb_log(0,port,"Port is blocked\n");
03099             return NULL;
03100          }
03101       
03102          if (channel > 0) {
03103             if (channel <= stack->b_num) {
03104                for (i = 0; i < stack->b_num; i++) {
03105                   if (stack->bc[i].in_use && stack->bc[i].channel == channel) {
03106                      cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
03107                      return NULL;
03108                   }
03109                }
03110             } else {
03111                cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port);
03112                return NULL;
03113             }
03114          }
03115 
03116          int maxnum=inout&&!stack->pri&&!stack->ptp?stack->b_num+1:stack->b_num;
03117 
03118          if (dec) {
03119             for (i = maxnum-1; i>=0; i--) {
03120                if (!stack->bc[i].in_use) {
03121                   /* 3. channel on bri means CW*/
03122                   if (!stack->pri && i==stack->b_num)
03123                      stack->bc[i].cw=1;
03124                      
03125                   prepare_bc(&stack->bc[i], channel);
03126                   stack->bc[i].dec=1;
03127                   return &stack->bc[i];
03128                }
03129             }
03130          } else {
03131             for (i = 0; i <maxnum; i++) {
03132                if (!stack->bc[i].in_use) {
03133                   /* 3. channel on bri means CW*/
03134                   if (!stack->pri && i==stack->b_num)
03135                      stack->bc[i].cw=1;
03136 
03137                   prepare_bc(&stack->bc[i], channel);
03138                   return &stack->bc[i];
03139                }
03140             }
03141          }
03142 
03143          cb_log(1,port,"There is no free channel on port (%d)\n",port);
03144          return NULL;
03145       }
03146    }
03147 
03148    cb_log(0,port,"Port is not configured (%d)\n",port);
03149    return NULL;
03150 }

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 89 of file isdn_lib.c.

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

Referenced by misdn_request().

00090 {
00091    struct misdn_stack *stack=get_misdn_stack();
00092    for ( ; stack; stack=stack->next) {
00093       if (stack->port == port) {
00094          if (stack->pri) 
00095             return 30;
00096          else
00097             return 2;
00098       }
00099    }
00100    return -1;
00101 }

int misdn_lib_get_port_down ( int  port  ) 

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

01683 { /* Pull Down L1 */ 
01684    struct misdn_stack *stack;
01685    for (stack=glob_mgr->stack_list;
01686         stack;
01687         stack=stack->next) {
01688       if (stack->port == port) {
01689             if (stack->l2link)
01690                misdn_lib_get_l2_down(stack);
01691             misdn_lib_get_l1_down(stack);
01692          return 0;
01693       }
01694    }
01695    return 0;
01696 }

int misdn_lib_get_port_info ( int  port  ) 

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

03592 {
03593    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03594    iframe_t *frm;
03595    struct misdn_stack *stack=find_stack_by_port(port);
03596    if (!msg) {
03597       cb_log(0, port, "misgn_lib_get_port: alloc_msg failed!\n");
03598       return -1;
03599    }
03600    frm=(iframe_t*)msg->data;
03601    if (!stack ) {
03602       cb_log(0, port, "There is no Stack for this port.\n");
03603       return -1;
03604    }
03605    /* activate bchannel */
03606    frm->prim = CC_STATUS_ENQUIRY | REQUEST;
03607 
03608    frm->addr = stack->upper_id| FLG_MSG_DOWN;
03609 
03610    frm->dinfo = 0;
03611    frm->len = 0;
03612   
03613    msg_queue_tail(&glob_mgr->activatequeue, msg);
03614    sem_post(&glob_mgr->new_msg);
03615 
03616   
03617    return 0; 
03618 }

int misdn_lib_get_port_up ( int  port  ) 

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

01661 { /* Pull Up L1 */ 
01662    struct misdn_stack *stack;
01663    
01664    for (stack=glob_mgr->stack_list;
01665         stack;
01666         stack=stack->next) {
01667       
01668       if (stack->port == port) {
01669 
01670          if (!stack->l1link)
01671             misdn_lib_get_l1_up(stack);
01672          if (!stack->l2link)
01673             misdn_lib_get_l2_up(stack);
01674          
01675          return 0;
01676       }
01677    }
01678    return 0;
01679 }

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

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

03854 {
03855    struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
03856    char *tok, *tokb;
03857    char plist[1024];
03858    int midev;
03859    int port_count=0;
03860  
03861    cb_log = iface->cb_log;
03862    cb_event = iface->cb_event;
03863    cb_jb_empty = iface->cb_jb_empty;
03864    
03865    glob_mgr = mgr;
03866   
03867    msg_init();
03868 
03869    misdn_lib_nt_debug_init(0,NULL);
03870    
03871    if (!portlist || (*portlist == 0) ) return 1;
03872    
03873    init_flip_bits();
03874    
03875    {
03876       strncpy(plist,portlist, 1024);
03877       plist[1023] = 0;
03878    }
03879   
03880    memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
03881    flip_buf_bits(tone_425_flip,TONE_425_SIZE);
03882 
03883    memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
03884    flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);
03885   
03886    midev=te_lib_init();
03887    mgr->midev=midev;
03888 
03889    port_count=mISDN_get_stack_count(midev);
03890   
03891    msg_queue_init(&mgr->activatequeue);
03892   
03893    if (sem_init(&mgr->new_msg, 1, 0)<0)
03894       sem_init(&mgr->new_msg, 0, 0);
03895  
03896    for (tok=strtok_r(plist," ,",&tokb );
03897         tok; 
03898         tok=strtok_r(NULL," ,",&tokb)) {
03899       int port = atoi(tok);
03900       struct misdn_stack *stack;
03901       static int first=1;
03902       int ptp=0;
03903     
03904       if (strstr(tok, "ptp"))
03905          ptp=1;
03906 
03907       if (port > port_count) {
03908          cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
03909          exit(1);
03910       }
03911       stack=stack_init(midev, port, ptp);
03912     
03913       if (!stack) {
03914          perror("init_stack");
03915          exit(1);
03916       }
03917     
03918       {
03919          int i;
03920          for(i=0;i<=stack->b_num; i++) {
03921             int r;
03922             if ((r=init_bc(stack, &stack->bc[i], stack->midev,port,i, "", 1))<0) {
03923                cb_log(0, port, "Got Err @ init_bc :%d\n",r);
03924                exit(1);
03925             }
03926          }
03927       }
03928 
03929       if (stack && first) {
03930          mgr->stack_list=stack;
03931          first=0;
03932          continue;
03933       }
03934     
03935       if (stack) {
03936          struct misdn_stack * help;
03937          for ( help=mgr->stack_list; help; help=help->next ) 
03938             if (help->next == NULL) break;
03939          help->next=stack;
03940       }
03941     
03942    }
03943   
03944    if (sem_init(&handler_started, 1, 0)<0)
03945       sem_init(&handler_started, 0, 0);
03946   
03947    cb_log(8, 0, "Starting Event Handler\n");
03948    pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr);
03949   
03950    sem_wait(&handler_started) ;
03951    cb_log(8, 0, "Starting Event Catcher\n");
03952    pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);
03953   
03954    cb_log(8, 0, "Event Catcher started\n");
03955 
03956    global_state= MISDN_INITIALIZED; 
03957   
03958    return (mgr == NULL);
03959 }

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 69 of file isdn_lib.c.

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

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

int misdn_lib_is_ptp ( int  port  ) 

Definition at line 80 of file isdn_lib.c.

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

Referenced by do_immediate_setup().

00081 {
00082    struct misdn_stack *stack=get_misdn_stack();
00083    for ( ; stack; stack=stack->next) {
00084       if (stack->port == port) return stack->ptp;
00085    }
00086    return -1;
00087 }

void misdn_lib_isdn_l1watcher ( int  port  ) 

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

02930 {
02931    struct misdn_stack *stack;
02932 
02933    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
02934       ;
02935 
02936    if (stack) {
02937       cb_log(4, port, "Checking L1 State\n");   
02938       if (!stack->l1link) {
02939          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
02940          misdn_lib_get_short_status(stack);
02941          misdn_lib_get_l1_up(stack); 
02942          misdn_lib_get_l2_up(stack); 
02943       }
02944    }
02945 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

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

03172 {
03173    if (!bc) return;
03174 
03175    struct misdn_stack *stack=get_stack_by_bc(bc);
03176 
03177    if (!stack) return;
03178 
03179    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);
03180    
03181    cb_log(2, stack->port,
03182           " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
03183           bc->info_dad,
03184           bc->onumplan>=0?'0'+bc->onumplan:' ',
03185           bc->dnumplan>=0?'0'+bc->dnumplan:' ',
03186           bc->rnumplan>=0?'0'+bc->rnumplan:' ',
03187           bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
03188       );
03189    
03190    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);
03191    cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
03192          bc->screen, bc->pres);
03193    
03194    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);
03195    
03196    cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
03197 
03198    cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
03199    
03200    cb_log(5, stack->port, " --> bc:%x h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
03201 }

int misdn_lib_maxports_get ( void   ) 

Definition at line 3817 of file isdn_lib.c.

Referenced by load_module().

03817                              { /** BE AWARE WE HAVE NO CB_LOG HERE! **/
03818    
03819    int i = mISDN_open();
03820    int max=0;
03821    
03822    if (i<0)
03823       return -1;
03824 
03825    max = mISDN_get_stack_count(i);
03826    
03827    mISDN_close(i);
03828    
03829    return max;
03830 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 3833 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

03834 {
03835    int static init=0;
03836    char *f;
03837    
03838    if (!flags) 
03839       f=NULL;
03840    else
03841       f=file;
03842 
03843    if (!init) {
03844       debug_init( flags , f, f, f);
03845       init=1;
03846    } else {
03847       debug_close();
03848       debug_init( flags , f, f, f);
03849    }
03850 }

int misdn_lib_pid_restart ( int  pid  ) 

int misdn_lib_port_block ( int  port  ) 

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

00044 {
00045    struct misdn_stack *stack=get_misdn_stack();
00046    for ( ; stack; stack=stack->next) {
00047       if (stack->port == port) {
00048          stack->blocked=1;
00049          return 0;
00050       }
00051    }
00052    return -1;
00053 
00054 }

int misdn_lib_port_is_pri ( int  port  ) 

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

00031 {
00032    struct misdn_stack *stack=get_misdn_stack();
00033    for ( ; stack; stack=stack->next) {
00034       if (stack->port == port) {
00035          return stack->pri;
00036       }
00037    }
00038    
00039    return -1;
00040 }

int misdn_lib_port_restart ( int  port  ) 

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 56 of file isdn_lib.c.

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

Referenced by misdn_port_unblock().

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

int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

01699 {
01700    struct misdn_stack *stack;
01701 
01702 
01703    for (stack=glob_mgr->stack_list;
01704         stack;
01705         stack=stack->next) {
01706       
01707       if (stack->port == port) {
01708 
01709          if (stack->blocked) {
01710             cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
01711             return -1;
01712          }
01713 
01714          if (stack->ptp ) {
01715 
01716             if (stack->l1link && stack->l2link) {
01717                return 1;
01718             } else {
01719                cb_log(1,port, "Port Down L2:%d L1:%d\n",
01720                   stack->l2link, stack->l1link);
01721                return 0;
01722             }
01723          } else {
01724             if ( !check || stack->l1link )
01725                return 1;
01726             else {
01727                cb_log(1,port, "Port down PMP\n");
01728                return 0;
01729             }
01730          }
01731       }
01732    }
01733   
01734    return -1;
01735 }

void misdn_lib_reinit_nt_stack ( int  port  ) 

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

04469 {
04470    struct misdn_stack *stack=find_stack_by_port(port);
04471    
04472    if (stack) {
04473       stack->l2link=0;
04474       stack->blocked=0;
04475    
04476       cleanup_Isdnl3(&stack->nst);
04477       cleanup_Isdnl2(&stack->nst);
04478 
04479 
04480       memset(&stack->nst, 0, sizeof(net_stack_t));
04481       memset(&stack->mgr, 0, sizeof(manager_t));
04482    
04483       stack->mgr.nst = &stack->nst;
04484       stack->nst.manager = &stack->mgr;
04485     
04486       stack->nst.l3_manager = handle_event_nt;
04487       stack->nst.device = glob_mgr->midev;
04488       stack->nst.cardnr = port;
04489       stack->nst.d_stid = stack->d_stid;
04490    
04491       stack->nst.feature = FEATURE_NET_HOLD;
04492       if (stack->ptp)
04493          stack->nst.feature |= FEATURE_NET_PTP;
04494       if (stack->pri)
04495          stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
04496       
04497       stack->nst.l1_id = stack->lower_id;
04498       stack->nst.l2_id = stack->upper_id;
04499       
04500       msg_queue_init(&stack->nst.down_queue);
04501    
04502       Isdnl2Init(&stack->nst);
04503       Isdnl3Init(&stack->nst);
04504 
04505       if (!stack->ptp)
04506          misdn_lib_get_l1_up(stack);
04507       misdn_lib_get_l2_up(stack);
04508    }
04509 }

void misdn_lib_release ( struct misdn_bchannel bc  ) 

Definition at line 1641 of file isdn_lib.c.

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

Referenced by misdn_hangup().

01642 {
01643    struct misdn_stack *stack=get_stack_by_bc(bc);
01644 
01645    if (!stack) {
01646       cb_log(1,0,"misdn_release: No Stack found\n");
01647       return;
01648    }
01649    
01650    if (bc->channel>0) {
01651       empty_chan_in_stack(stack,bc->channel);
01652    }
01653    empty_bc(bc);
01654    clean_up_bc(bc);
01655 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Definition at line 3220 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, 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, set_chan_in_stack(), 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(), and misdn_send_text().

03221 {
03222    msg_t *msg; 
03223    int retval=0;
03224   
03225    if (!bc) RETURN(-1,OUT_POST_UNLOCK);
03226    
03227    struct misdn_stack *stack=get_stack_by_bc(bc);
03228    
03229    if (!stack) {
03230       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);
03231       RETURN(-1,OUT);
03232    }
03233    
03234    misdn_send_lock(bc);
03235 
03236 
03237    cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->uperid:%x\n",stack->nt, stack->upper_id);
03238 
03239    if ( stack->nt && !stack->l1link) {
03240       /** Queue Event **/
03241       bc->evq=event;
03242       cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
03243       misdn_lib_get_l1_up(stack);
03244       RETURN(0,OUT);
03245    }
03246    
03247    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);
03248    cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
03249    misdn_lib_log_ies(bc);
03250    
03251    switch (event) {
03252    case EVENT_SETUP:
03253       if (create_process(glob_mgr->midev, bc)<0) {
03254          cb_log(0,  stack->port, " No free channel at the moment @ send_event\n");
03255 
03256          RETURN(-ENOCHAN,OUT);
03257       }
03258 #if 0
03259    if (stack->nt) {
03260       ret=setup_bc(bc);
03261       if (ret == -EINVAL) {
03262          cb_log(0,bc->port,"send_event: setup_bc failed\n");
03263       }
03264    }
03265 #endif
03266       break;
03267 
03268    case EVENT_PROGRESS:
03269    case EVENT_ALERTING:
03270    case EVENT_PROCEEDING:
03271    case EVENT_SETUP_ACKNOWLEDGE:
03272    case EVENT_CONNECT:
03273    case EVENT_RETRIEVE_ACKNOWLEDGE:
03274 
03275       if (stack->nt) {
03276          if (bc->channel <=0 ) { /*  else we have the channel already */
03277             if (!find_free_chan_in_stack(stack, bc, 0,0)) {
03278                cb_log(0, stack->port, " No free channel at the moment\n");
03279                /*FIXME: add disconnect*/
03280                RETURN(-ENOCHAN,OUT);
03281             }
03282             
03283             if (set_chan_in_stack(stack ,bc->channel)<0) {
03284                /*FIXME: add disconnect*/
03285                RETURN(-ENOCHAN,OUT);
03286             }
03287          }
03288          /* Its that i generate channels */
03289       }
03290 
03291       retval=setup_bc(bc);
03292       if (retval == -EINVAL) {
03293          cb_log(0,bc->port,"send_event: setup_bc failed\n");
03294       }
03295 
03296       if (misdn_cap_is_speech(bc->capability)) {
03297          if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
03298             if ( *bc->crypt_key ) {
03299                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);
03300                
03301                manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
03302             }
03303             
03304             if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03305             manager_ec_enable(bc);
03306             
03307             if (bc->txgain != 0) {
03308                cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
03309                manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03310             }
03311             
03312             if ( bc->rxgain != 0 ) {
03313                cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
03314                manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03315             }
03316          }
03317       }
03318       break;
03319 
03320    case EVENT_HOLD_ACKNOWLEDGE:
03321    {
03322       struct misdn_bchannel *holded_bc=malloc(sizeof(struct misdn_bchannel));
03323       if (!holded_bc) {
03324          cb_log(0,bc->port, "Could not allocate holded_bc!!!\n");
03325          RETURN(-1,OUT);
03326       }
03327 
03328       /*backup the bc*/
03329       memcpy(holded_bc,bc,sizeof(struct misdn_bchannel));
03330       holded_bc->holded=1;
03331       bc_state_change(holded_bc,BCHAN_CLEANED);
03332 
03333       stack_holder_add(stack,holded_bc);
03334    
03335       /*kill the bridge and clean the bchannel*/
03336       if (stack->nt) {
03337          if (bc->bc_state == BCHAN_BRIDGED) {
03338             misdn_split_conf(bc,bc->conf_id);
03339             struct misdn_bchannel *bc2=find_bc_by_confid(bc->conf_id);
03340             if (!bc2) {
03341                cb_log(0,bc->port,"We have no second bc in bridge???\n");
03342             } else {
03343                misdn_split_conf(bc2,bc->conf_id);
03344             }
03345          }
03346 
03347          if (bc->channel>0)
03348             empty_chan_in_stack(stack,bc->channel);
03349          empty_bc(bc);
03350          clean_up_bc(bc);
03351       }
03352       
03353    }
03354    break;
03355 
03356    /* finishing the channel eh ? */
03357    case EVENT_DISCONNECT:
03358       if (!bc->need_disconnect) {
03359          cb_log(0,bc->port," --> we have already send Disconnect\n");
03360          RETURN(-1,OUT);
03361       }
03362       
03363       bc->need_disconnect=0;
03364       break;
03365    case EVENT_RELEASE:
03366       if (!bc->need_release) {
03367          cb_log(0,bc->port," --> we have already send Release\n");
03368          RETURN(-1,OUT);
03369       }
03370       bc->need_disconnect=0;
03371       bc->need_release=0;
03372       break;
03373    case EVENT_RELEASE_COMPLETE:
03374       if (!bc->need_release_complete) {
03375          cb_log(0,bc->port," --> we have already send Release_complete\n");
03376          RETURN(-1,OUT);
03377       }
03378       bc->need_disconnect=0;
03379       bc->need_release=0;
03380       bc->need_release_complete=0;
03381 
03382       if (!stack->nt) {
03383          /*create clenaup in TE*/
03384          if (bc->channel>0)
03385             empty_chan_in_stack(stack,bc->channel);
03386          int tmpcause=bc->cause; 
03387          int tmp_out_cause=bc->out_cause; 
03388          empty_bc(bc);
03389          bc->cause=tmpcause;
03390          bc->out_cause=tmp_out_cause;
03391          clean_up_bc(bc);
03392       }
03393       break;
03394     
03395    case EVENT_CONNECT_ACKNOWLEDGE:
03396 
03397       if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
03398          int retval=setup_bc(bc);
03399          if (retval == -EINVAL){
03400             cb_log(0,bc->port,"send_event: setup_bc failed\n");
03401             
03402          }
03403       }
03404       
03405       if (misdn_cap_is_speech(bc->capability)) {
03406          if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
03407          manager_ec_enable(bc);
03408 
03409          if ( bc->txgain != 0 ) {
03410             cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
03411             manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
03412          }
03413          if ( bc->rxgain != 0 ) {
03414             cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
03415             manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
03416          }
03417       }
03418       break;
03419     
03420    default:
03421       break;
03422    }
03423   
03424    /* Later we should think about sending bchannel data directly to misdn. */
03425    msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
03426    msg_queue_tail(&stack->downqueue, msg);
03427    sem_post(&glob_mgr->new_msg);
03428   
03429 OUT:
03430    misdn_send_unlock(bc);
03431 
03432 OUT_POST_UNLOCK:
03433    return retval; 
03434 }

int misdn_lib_send_restart ( int  port  ) 

Definition at line 3657 of file isdn_lib.c.

References cb_log, EVENT_RESTART, find_stack_by_port(), misdn_lib_send_event(), misdn_stack::nt, misdn_stack::port, and misdn_stack::pri.

Referenced by misdn_send_restart().

03658 {
03659    struct misdn_stack *stack=find_stack_by_port(port);
03660    cb_log(0, port, "Sending Restarts on this port.\n");
03661    
03662    struct misdn_bchannel dummybc;
03663    memset (&dummybc,0,sizeof(dummybc));
03664    dummybc.port=stack->port;
03665    dummybc.l3_id=MISDN_ID_GLOBAL;
03666    dummybc.nt=stack->nt;
03667 
03668    int max=stack->pri?30:2;
03669    int i;
03670    for (i=1;i<=max;i++) {
03671       dummybc.channel=i;
03672       cb_log(0, port, "Restarting channel %d\n",i);
03673       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03674       /*do we need to wait before we get an EVENT_RESTART_ACK ?*/
03675    }
03676 
03677    return 0;
03678 }

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

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

04279 {
04280 
04281    switch(tone) {
04282    case TONE_DIAL:
04283       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 
04284    break;
04285    
04286    case TONE_ALERTING:
04287       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);  
04288    break;
04289    
04290    case TONE_HANGUP:
04291       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);   
04292    break;
04293 
04294    case TONE_NONE:
04295    default:
04296       manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);  
04297    }
04298 
04299    char buf[mISDN_HEADER_LEN+128];
04300    iframe_t *frm=(iframe_t*)buf;
04301    memset(buf,0,mISDN_HEADER_LEN+128);
04302 
04303    frm->prim=DL_DATA|REQUEST;
04304    frm->addr=bc->addr|FLG_MSG_DOWN;
04305    frm->dinfo=0;
04306    frm->len=128;
04307    
04308    mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
04309 }

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 921 of file isdn_lib.c.

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

Referenced by misdn_set_opt_exec().

00922 {
00923    clean_up_bc(bc);
00924    setup_bc(bc);
00925 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4440 of file isdn_lib.c.

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

Referenced by misdn_bridge().

04441 {
04442 
04443    struct misdn_bchannel *bc_list[]={
04444       bc1,bc2,NULL
04445    };
04446    struct misdn_bchannel **bc;
04447       
04448    for (bc=bc_list; *bc;  bc++) { 
04449       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04450          misdn_split_conf( *bc, (*bc)->conf_id);
04451       } else {
04452          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04453       }
04454    }
04455    
04456 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2166 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by dialtone_indicate().

02167 {
02168    bc->generate_tone=1;
02169 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2171 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02172 {
02173    bc->generate_tone=0;
02174 }

void misdn_lib_transfer ( struct misdn_bchannel holded_bc  ) 

Definition at line 3036 of file isdn_lib.c.

References misdn_bchannel::holded.

03037 {
03038    holded_bc->holded=0;
03039 }

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

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

04060 {
04061    struct misdn_stack *stack=get_stack_by_bc(bc);
04062 
04063    switch (bc->bc_state) {
04064       case BCHAN_ACTIVATED:
04065       case BCHAN_BRIDGED:
04066          break;
04067       default:
04068          cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
04069          return -1;
04070    }
04071    
04072    char buf[4096 + mISDN_HEADER_LEN];
04073    iframe_t *frm= (iframe_t*)buf;
04074    int  r;
04075    
04076    frm->prim = DL_DATA|REQUEST;
04077    frm->dinfo = 0;
04078    frm->addr = bc->addr | FLG_MSG_DOWN ;
04079    
04080    frm->len = len;
04081    memcpy(&buf[mISDN_HEADER_LEN], data,len);
04082       
04083    if ( misdn_cap_is_speech(bc->capability) ) 
04084       flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
04085    else
04086       cb_log(6, stack->port, "Writing %d data bytes\n",len);
04087    
04088    cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
04089    r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
04090    return 0;
04091 }


Variable Documentation

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

Definition at line 376 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(), set_channel(), and setup_bc().

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

Definition at line 378 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 377 of file isdn_lib.h.

Referenced by bc_next_state_change(), bc_state_change(), build_connect(), 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_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(), 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(), and te_lib_destroy().


Generated on Mon May 14 04:48:57 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1