Wed Oct 28 11:46:12 2009

Asterisk developer's documentation


isdn_lib.h File Reference

Interface to mISDN. More...

#include <mISDNuser/suppserv.h>

Include dependency graph for isdn_lib.h:

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

Go to the source code of this file.

Data Structures

struct  misdn_bchannel
struct  misdn_lib_iface

Defines

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

Enumerations

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

Functions

char * bc_state2str (enum bchannel_state state)
void bc_state_change (struct misdn_bchannel *bc, enum bchannel_state state)
void get_show_stack_details (int port, char *buf)
void isdn_lib_stop_dtmf (struct misdn_bchannel *bc)
void isdn_lib_update_ec (struct misdn_bchannel *bc)
void isdn_lib_update_rxgain (struct misdn_bchannel *bc)
void isdn_lib_update_txgain (struct misdn_bchannel *bc)
void manager_bchannel_activate (struct misdn_bchannel *bc)
void manager_bchannel_deactivate (struct misdn_bchannel *bc)
void manager_ec_disable (struct misdn_bchannel *bc)
void manager_ec_enable (struct misdn_bchannel *bc)
char * manager_isdn_get_info (enum event_e event)
void manager_ph_control (struct misdn_bchannel *bc, int c1, int c2)
int misdn_cap_is_speech (int cap)
void misdn_dump_chanlist (void)
int misdn_inband_avail (struct misdn_bchannel *bc)
void misdn_lib_bridge (struct misdn_bchannel *bc1, struct misdn_bchannel *bc2)
void misdn_lib_destroy (void)
void misdn_lib_echo (struct misdn_bchannel *bc, int onoff)
struct misdn_bchannelmisdn_lib_find_held_bc (int port, int l3_id)
 Find a held call's B channel record.
struct misdn_bchannelmisdn_lib_get_free_bc (int port, int channel, int inout, int dec)
int misdn_lib_get_maxchans (int port)
int misdn_lib_get_port_down (int port)
int misdn_lib_get_port_info (int port)
int misdn_lib_get_port_up (int port)
int misdn_lib_init (char *portlist, struct misdn_lib_iface *iface, void *user_data)
int misdn_lib_is_port_blocked (int port)
int misdn_lib_is_ptp (int port)
void misdn_lib_isdn_l1watcher (int port)
void misdn_lib_log_ies (struct misdn_bchannel *bc)
int misdn_lib_maxports_get (void)
void misdn_lib_nt_debug_init (int flags, char *file)
void misdn_lib_nt_keepcalls (int kc)
int misdn_lib_pid_restart (int pid)
int misdn_lib_port_block (int port)
int misdn_lib_port_is_nt (int port)
int misdn_lib_port_is_pri (int port)
int misdn_lib_port_restart (int port)
int misdn_lib_port_unblock (int port)
int misdn_lib_port_up (int port, int notcheck)
void misdn_lib_reinit_nt_stack (int port)
void misdn_lib_release (struct misdn_bchannel *bc)
int misdn_lib_send_event (struct misdn_bchannel *bc, enum event_e event)
int misdn_lib_send_restart (int port, int channel)
void misdn_lib_send_tone (struct misdn_bchannel *bc, enum tone_e tone)
void misdn_lib_setup_bc (struct misdn_bchannel *bc)
void misdn_lib_split_bridge (struct misdn_bchannel *bc1, struct misdn_bchannel *bc2)
void misdn_lib_tone_generator_start (struct misdn_bchannel *bc)
void misdn_lib_tone_generator_stop (struct misdn_bchannel *bc)
int misdn_lib_tx2misdn_frm (struct misdn_bchannel *bc, void *data, int len)
void misdn_make_dummy (struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel)

Variables

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


Detailed Description

Interface to mISDN.

Author:
Christian Richter <crich@beronet.com>

Definition in file isdn_lib.h.


Define Documentation

#define MAX_BCHANS   31

#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 665 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 666 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 663 of file isdn_lib.h.

Referenced by dahdi_call().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 664 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 662 of file isdn_lib.h.


Enumeration Type Documentation

anonymous enum

Enumerator:
INFO_CAPABILITY_SPEECH 
INFO_CAPABILITY_AUDIO_3_1K 
INFO_CAPABILITY_AUDIO_7K 
INFO_CAPABILITY_VIDEO 
INFO_CAPABILITY_DIGITAL_UNRESTRICTED 
INFO_CAPABILITY_DIGITAL_RESTRICTED 
INFO_CAPABILITY_DIGITAL_UNRESTRICTED_TONES 

Definition at line 169 of file isdn_lib.h.

anonymous enum

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

Definition at line 179 of file isdn_lib.h.

anonymous enum

Enumerator:
INFO_CODEC_ULAW 
INFO_CODEC_ALAW 

Definition at line 192 of file isdn_lib.h.

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

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

Definition at line 78 of file isdn_lib.h.

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

enum event_e

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

Definition at line 118 of file isdn_lib.h.

Enumerator:
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE 
RESPONSE_IGNORE_SETUP 
RESPONSE_RELEASE_SETUP 
RESPONSE_ERR 
RESPONSE_OK 

Definition at line 109 of file isdn_lib.h.

enum ie_name_e

Enumerator:
IE_DUMMY 
IE_LAST 

Definition at line 164 of file isdn_lib.h.

00164                {
00165    IE_DUMMY,
00166    IE_LAST
00167 };

enum layer_e

Enumerator:
L3 
L2 
L1 
UNKNOWN 

Definition at line 198 of file isdn_lib.h.

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

Enumerator:
ENOCHAN 

Definition at line 95 of file isdn_lib.h.

00095                  {
00096    ENOCHAN=1
00097 };

Enumerator:
NUMPLAN_UNINITIALIZED 
NUMPLAN_INTERNATIONAL 
NUMPLAN_NATIONAL 
NUMPLAN_SUBSCRIBER 
NUMPLAN_UNKNOWN 

Definition at line 100 of file isdn_lib.h.

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

enum tone_e

For initialization usage end of init usage

Enumerator:
TONE_NONE 
TONE_DIAL 
TONE_ALERTING 
TONE_FAR_ALERTING 
TONE_BUSY 
TONE_HANGUP 
TONE_CUSTOM 
TONE_FILE 

Definition at line 63 of file isdn_lib.h.

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


Function Documentation

char* bc_state2str ( enum bchannel_state  state  ) 

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

00589                                               {
00590    int i;
00591    
00592    struct bchan_state_s {
00593       char *n;
00594       enum bchannel_state s;
00595    } states[] = {
00596       {"BCHAN_CLEANED", BCHAN_CLEANED },
00597       {"BCHAN_EMPTY", BCHAN_EMPTY},
00598       {"BCHAN_SETUP", BCHAN_SETUP},
00599       {"BCHAN_SETUPED", BCHAN_SETUPED},
00600       {"BCHAN_ACTIVE", BCHAN_ACTIVE},
00601       {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
00602       {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
00603       {"BCHAN_BRIDGED", BCHAN_BRIDGED},
00604       {"BCHAN_RELEASE", BCHAN_RELEASE},
00605       {"BCHAN_RELEASED", BCHAN_RELEASED},
00606       {"BCHAN_CLEAN", BCHAN_CLEAN},
00607       {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
00608       {"BCHAN_ERROR", BCHAN_ERROR}
00609    };
00610    
00611    for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
00612       if ( states[i].s == state)
00613          return states[i].n;
00614 
00615    return "UNKNOWN";
00616 }

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

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

00619 {
00620    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00621       bc->l3_id,
00622           bc_state2str(bc->bc_state),
00623           bc_state2str(state) );
00624    
00625    switch (state) {
00626       case BCHAN_ACTIVATED:
00627          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00628             misdn_join_conf(bc, bc->conf_id);
00629             bc->next_bc_state = BCHAN_EMPTY;
00630             return;
00631          }
00632       default:
00633          bc->bc_state=state;
00634          break;
00635    }
00636 }

void get_show_stack_details ( int  port,
char *  buf 
)

Definition at line 162 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_port(), and handle_cli_misdn_show_stacks().

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

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4380 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

04381 {
04382    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04383 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

Definition at line 4368 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04369 {
04370 #ifdef MISDN_1_2
04371    if (*bc->pipeline)
04372 #else
04373    if (bc->ec_enable)
04374 #endif
04375       manager_ec_enable(bc);
04376    else
04377       manager_ec_disable(bc);
04378 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4358 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

04359 {
04360    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04361 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4363 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

04364 {
04365    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04366 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

Definition at line 4241 of file isdn_lib.c.

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

Referenced by setup_bc().

04242 {
04243    char buf[128];
04244 
04245    struct misdn_stack *stack=get_stack_by_bc(bc);
04246 
04247    if (!stack) {
04248       cb_log(0, bc->port, "bchannel_activate: Stack not found !");
04249       return ;
04250    }
04251    
04252    /* we must activate if we are deactivated */
04253    clear_ibuffer(bc->astbuf);
04254    
04255    cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
04256    
04257    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
04258 
04259    return ;
04260 }

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

Definition at line 4263 of file isdn_lib.c.

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

Referenced by clean_up_bc().

04264 {
04265    struct misdn_stack *stack=get_stack_by_bc(bc);
04266    iframe_t dact;
04267    char buf[128]; 
04268 
04269    switch (bc->bc_state) {
04270       case BCHAN_ACTIVATED:
04271          break;
04272       case BCHAN_BRIDGED:
04273          misdn_split_conf(bc,bc->conf_id);
04274          break;
04275       default:
04276          cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
04277          return ;
04278 
04279    }
04280    
04281    cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
04282    
04283    bc->generate_tone=0;
04284    
04285    dact.prim = DL_RELEASE | REQUEST;
04286    dact.addr = bc->addr | FLG_MSG_DOWN;
04287    dact.dinfo = 0;
04288    dact.len = 0;
04289    mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
04290 
04291    clear_ibuffer(bc->astbuf);
04292    
04293    bc_state_change(bc,BCHAN_RELEASE);
04294   
04295    return;
04296 }

void manager_ec_disable ( struct misdn_bchannel bc  ) 

Definition at line 4596 of file isdn_lib.c.

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

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

04597 {
04598    struct misdn_stack *stack=get_stack_by_bc(bc);
04599    
04600    cb_log(4, stack?stack->port:0," --> ec_disable\n");
04601 
04602    if (!misdn_cap_is_speech(bc->capability)) {
04603       cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
04604       return;
04605    }
04606 
04607 #ifdef MISDN_1_2
04608    manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
04609 #else
04610    if ( ! bc->ec_enable) {
04611       cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
04612       manager_ph_control(bc,  ECHOCAN_OFF, 0);
04613    }
04614 #endif
04615 }

void manager_ec_enable ( struct misdn_bchannel bc  ) 

Definition at line 4547 of file isdn_lib.c.

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

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

04548 {
04549    struct misdn_stack *stack=get_stack_by_bc(bc);
04550    
04551    cb_log(4, stack?stack->port:0,"ec_enable\n");
04552 
04553    if (!misdn_cap_is_speech(bc->capability)) {
04554       cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
04555    } else {
04556 
04557 #ifdef MISDN_1_2
04558    if (*bc->pipeline) {
04559       cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
04560       manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
04561    }
04562 #else
04563    int ec_arr[2];
04564 
04565    if (bc->ec_enable) {
04566       cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
04567    
04568       switch (bc->ec_deftaps) {
04569       case 4:
04570       case 8:
04571       case 16:
04572       case 32:
04573       case 64:
04574       case 128:
04575       case 256:
04576       case 512:
04577       case 1024:
04578          cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
04579          break;
04580       default:
04581          cb_log(0, stack->port, "Taps should be power of 2\n");
04582          bc->ec_deftaps=128;
04583       }
04584    
04585       ec_arr[0]=bc->ec_deftaps;
04586       ec_arr[1]=0;
04587       
04588       manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
04589    }
04590 #endif
04591    }
04592 }

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4236 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04237 {
04238    return isdn_get_info(msgs_g , event, 0);
04239 }

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

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

04338 {
04339    unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
04340    iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
04341    unsigned int *d = (unsigned int*)&ctrl->data.p;
04342    /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
04343    
04344    cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
04345    
04346    ctrl->prim = PH_CONTROL | REQUEST;
04347    ctrl->addr = bc->addr | FLG_MSG_DOWN;
04348    ctrl->dinfo = 0;
04349    ctrl->len = sizeof(unsigned int)*2;
04350    *d++ = c1;
04351    *d++ = c2;
04352    mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
04353 }

int misdn_cap_is_speech ( int  cap  ) 

void misdn_dump_chanlist ( void   ) 

Definition at line 468 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_channels().

00469 {
00470    struct misdn_stack *stack=get_misdn_stack();
00471    for ( ; stack; stack=stack->next) {
00472       dump_chan_list(stack);
00473    }
00474 
00475 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

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

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

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

04647 {
04648    int conf_id = bc1->pid + 1;
04649    struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL };
04650    struct misdn_bchannel **bc;
04651 
04652    cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
04653 
04654    for (bc=bc_list; *bc;  bc++) { 
04655       (*bc)->conf_id=conf_id;
04656       cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
04657    
04658       switch((*bc)->bc_state) {
04659          case BCHAN_ACTIVATED:
04660             misdn_join_conf(*bc,conf_id);
04661             break;
04662          default:
04663             bc_next_state_change(*bc,BCHAN_BRIDGED);
04664             break;
04665       }
04666    }
04667 }

void misdn_lib_destroy ( void   ) 

Definition at line 4203 of file isdn_lib.c.

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

Referenced by unload_module().

04204 {
04205    struct misdn_stack *help;
04206    int i;
04207   
04208    for ( help=glob_mgr->stack_list; help; help=help->next ) {
04209       for(i=0;i<=help->b_num; i++) {
04210          char buf[1024];
04211          mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
04212          help->bc[i].addr = 0;
04213       }
04214       cb_log (1, help->port, "Destroying this port.\n");
04215       stack_destroy(help);
04216    }
04217    
04218    if (global_state == MISDN_INITIALIZED) {
04219       cb_log(4, 0, "Killing Handler Thread\n");
04220       if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
04221          cb_log(4, 0, "Joining Handler Thread\n");
04222          pthread_join(glob_mgr->event_handler_thread, NULL);
04223       }
04224      
04225       cb_log(4, 0, "Killing Main Thread\n");
04226       if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
04227          cb_log(4, 0, "Joining Main Thread\n");
04228          pthread_join(glob_mgr->event_thread, NULL);
04229       }
04230    }
04231   
04232    cb_log(1, 0, "Closing mISDN device\n");
04233    te_lib_destroy(glob_mgr->midev);
04234 }

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4689 of file isdn_lib.c.

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

04690 {
04691    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04692    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04693 }

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

Find a held call's B channel record.

Parameters:
port Port the call is on.
l3_id mISDN Layer 3 ID of held call.
Returns:
Found bc-record or NULL.

Definition at line 4499 of file isdn_lib.c.

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

Referenced by misdn_hangup().

04500 {
04501    struct misdn_bchannel *bc;
04502    struct misdn_stack *stack;
04503 
04504    bc = NULL;
04505    for (stack = get_misdn_stack(); stack; stack = stack->next) {
04506       if (stack->port == port) {
04507          bc = stack_holder_find(stack, l3_id);
04508          break;
04509       }
04510    }
04511 
04512    return bc;
04513 }

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

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

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

03242 {
03243    struct misdn_stack *stack;
03244    int i;
03245    
03246    if (channel < 0 || channel > MAX_BCHANS) {
03247       cb_log(0,port,"Requested channel out of bounds (%d)\n",channel);
03248       return NULL;
03249    }
03250 
03251    for (stack=glob_mgr->stack_list; stack; stack=stack->next) {
03252     
03253       if (stack->port == port) {
03254          int maxnum;
03255 
03256          if (stack->blocked) {
03257             cb_log(0,port,"Port is blocked\n");
03258             return NULL;
03259          }
03260       
03261          pthread_mutex_lock(&stack->st_lock);
03262          if (channel > 0) {
03263             if (channel <= stack->b_num) {
03264                for (i = 0; i < stack->b_num; i++) {
03265                   if ( stack->bc[i].channel == channel) {
03266                      if (test_inuse(&stack->bc[i])) { 
03267                         pthread_mutex_unlock(&stack->st_lock);
03268                         cb_log(0,port,"Requested channel:%d on port:%d is already in use\n",channel, port);
03269                         return NULL;
03270 
03271                      } else {
03272                         prepare_bc(&stack->bc[i], channel);
03273                         pthread_mutex_unlock(&stack->st_lock);
03274                         return &stack->bc[i];
03275                      }
03276                   }
03277                }
03278             } else {
03279                pthread_mutex_unlock(&stack->st_lock);
03280                cb_log(0,port,"Requested channel:%d is out of bounds on port:%d\n",channel, port);
03281                return NULL;
03282             }
03283          }
03284 
03285          maxnum = inout && !stack->pri && !stack->ptp ? stack->b_num + 1 : stack->b_num;
03286 
03287          if (dec) {
03288             for (i = maxnum-1; i>=0; i--) {
03289                if (!test_inuse(&stack->bc[i])) {
03290                   /* 3. channel on bri means CW*/
03291                   if (!stack->pri && i==stack->b_num)
03292                      stack->bc[i].cw=1;
03293                      
03294                   prepare_bc(&stack->bc[i], channel);
03295                   stack->bc[i].dec=1;
03296                   pthread_mutex_unlock(&stack->st_lock);
03297                   return &stack->bc[i];
03298                }
03299             }
03300          } else {
03301             for (i = 0; i <maxnum; i++) {
03302                if (!test_inuse(&stack->bc[i])) {
03303                   /* 3. channel on bri means CW*/
03304                   if (!stack->pri && i==stack->b_num)
03305                      stack->bc[i].cw=1;
03306 
03307                   prepare_bc(&stack->bc[i], channel);
03308                   pthread_mutex_unlock(&stack->st_lock);
03309                   return &stack->bc[i];
03310                }
03311             }
03312          }
03313          pthread_mutex_unlock(&stack->st_lock);
03314 
03315          cb_log(1,port,"There is no free channel on port (%d)\n",port);
03316          return NULL;
03317       }
03318    }
03319 
03320    cb_log(0,port,"Port is not configured (%d)\n",port);
03321    return NULL;
03322 }

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 131 of file isdn_lib.c.

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

Referenced by misdn_request().

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

int misdn_lib_get_port_down ( int  port  ) 

Definition at line 1778 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_port_down().

01779 { /* Pull Down L1 */ 
01780    struct misdn_stack *stack;
01781    for (stack=glob_mgr->stack_list;
01782         stack;
01783         stack=stack->next) {
01784       if (stack->port == port) {
01785             if (stack->l2link)
01786                misdn_lib_get_l2_down(stack);
01787             misdn_lib_get_l1_down(stack);
01788          return 0;
01789       }
01790    }
01791    return 0;
01792 }

int misdn_lib_get_port_info ( int  port  ) 

Definition at line 3799 of file isdn_lib.c.

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

03800 {
03801    msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03802    iframe_t *frm;
03803    struct misdn_stack *stack=find_stack_by_port(port);
03804    if (!msg) {
03805       cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n");
03806       return -1;
03807    }
03808    frm=(iframe_t*)msg->data;
03809    if (!stack ) {
03810       cb_log(0, port, "There is no Stack for this port.\n");
03811       return -1;
03812    }
03813    /* activate bchannel */
03814    frm->prim = CC_STATUS_ENQUIRY | REQUEST;
03815 
03816    frm->addr = stack->upper_id| FLG_MSG_DOWN;
03817 
03818    frm->dinfo = 0;
03819    frm->len = 0;
03820   
03821    msg_queue_tail(&glob_mgr->activatequeue, msg);
03822    sem_post(&glob_mgr->new_msg);
03823 
03824   
03825    return 0; 
03826 }

int misdn_lib_get_port_up ( int  port  ) 

Definition at line 1756 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_port_up(), and misdn_check_l2l1().

01757 { /* Pull Up L1 */ 
01758    struct misdn_stack *stack;
01759    
01760    for (stack=glob_mgr->stack_list;
01761         stack;
01762         stack=stack->next) {
01763       
01764       if (stack->port == port) {
01765 
01766          if (!stack->l1link)
01767             misdn_lib_get_l1_up(stack);
01768          if (!stack->l2link)
01769             misdn_lib_get_l2_up(stack);
01770          
01771          return 0;
01772       }
01773    }
01774    return 0;
01775 }

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

Definition at line 4095 of file isdn_lib.c.

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

Referenced by load_module().

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

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 111 of file isdn_lib.c.

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

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

int misdn_lib_is_ptp ( int  port  ) 

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

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

void misdn_lib_isdn_l1watcher ( int  port  ) 

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

03081 {
03082    struct misdn_stack *stack;
03083 
03084    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
03085       ;
03086 
03087    if (stack) {
03088       cb_log(4, port, "Checking L1 State\n");   
03089       if (!stack->l1link) {
03090          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
03091          misdn_lib_get_short_status(stack);
03092          misdn_lib_get_l1_up(stack); 
03093          misdn_lib_get_l2_up(stack); 
03094       }
03095    }
03096 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

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

03364 {
03365    struct misdn_stack *stack;
03366 
03367    if (!bc) return;
03368 
03369    stack = get_stack_by_bc(bc);
03370 
03371    if (!stack) return;
03372 
03373    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);
03374    
03375    cb_log(2, stack->port,
03376           " --> info_dad:%s onumplan:%c dnumplan:%c rnumplan:%c cpnnumplan:%c\n",
03377           bc->info_dad,
03378           bc->onumplan>=0?'0'+bc->onumplan:' ',
03379           bc->dnumplan>=0?'0'+bc->dnumplan:' ',
03380           bc->rnumplan>=0?'0'+bc->rnumplan:' ',
03381           bc->cpnnumplan>=0?'0'+bc->cpnnumplan:' '
03382       );
03383    
03384    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);
03385    cb_log(4, stack->port, " --> screen:%d --> pres:%d\n",
03386          bc->screen, bc->pres);
03387    
03388    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);
03389    
03390    cb_log(4, stack->port, " --> facility:%s out_facility:%s\n",fac2str(bc->fac_in.Function),fac2str(bc->fac_out.Function));
03391 
03392    cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
03393    
03394    cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
03395 }

int misdn_lib_maxports_get ( void   ) 

Definition at line 4045 of file isdn_lib.c.

Referenced by load_module().

04046 {
04047    /* BE AWARE WE HAVE NO cb_log() HERE! */
04048 
04049    int i = mISDN_open();
04050    int max=0;
04051    
04052    if (i<0)
04053       return -1;
04054 
04055    max = mISDN_get_stack_count(i);
04056    
04057    mISDN_close(i);
04058    
04059    return max;
04060 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4075 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

04076 {
04077    static int init=0;
04078    char *f;
04079    
04080    if (!flags) 
04081       f=NULL;
04082    else
04083       f=file;
04084 
04085    if (!init) {
04086       debug_init( flags , f, f, f);
04087       init=1;
04088    } else {
04089       debug_close();
04090       debug_init( flags , f, f, f);
04091    }
04092 }

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 4063 of file isdn_lib.c.

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

Referenced by load_module().

04064 {
04065 #ifdef FEATURE_NET_KEEPCALLS
04066    if (kc) {
04067       struct misdn_stack *stack=get_misdn_stack();
04068       for ( ; stack; stack=stack->next) {
04069          stack->nst.feature |= FEATURE_NET_KEEPCALLS;
04070       }
04071    }
04072 #endif
04073 }

int misdn_lib_pid_restart ( int  pid  ) 

int misdn_lib_port_block ( int  port  ) 

Definition at line 85 of file isdn_lib.c.

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

Referenced by cb_events(), and handle_cli_misdn_port_block().

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

int misdn_lib_port_is_nt ( int  port  ) 

Definition at line 59 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_send_facility().

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

int misdn_lib_port_is_pri ( int  port  ) 

Definition at line 47 of file isdn_lib.c.

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

Referenced by misdn_new(), test_inuse(), and update_name().

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

int misdn_lib_port_restart ( int  port  ) 

int misdn_lib_port_unblock ( int  port  ) 

Definition at line 98 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_port_unblock().

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

int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

01795 {
01796    struct misdn_stack *stack;
01797 
01798 
01799    for (stack=glob_mgr->stack_list;
01800         stack;
01801         stack=stack->next) {
01802       
01803       if (stack->port == port) {
01804 
01805          if (stack->blocked) {
01806             cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
01807             return -1;
01808          }
01809 
01810          if (stack->ptp ) {
01811 
01812             if (stack->l1link && stack->l2link) {
01813                return 1;
01814             } else {
01815                cb_log(1,port, "Port Down L2:%d L1:%d\n",
01816                   stack->l2link, stack->l1link);
01817                return 0;
01818             }
01819          } else {
01820             if ( !check || stack->l1link )
01821                return 1;
01822             else {
01823                cb_log(1,port, "Port down PMP\n");
01824                return 0;
01825             }
01826          }
01827       }
01828    }
01829   
01830    return -1;
01831 }

void misdn_lib_reinit_nt_stack ( int  port  ) 

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

04698 {
04699    struct misdn_stack *stack=find_stack_by_port(port);
04700    
04701    if (stack) {
04702       stack->l2link=0;
04703       stack->blocked=0;
04704    
04705       cleanup_Isdnl3(&stack->nst);
04706       cleanup_Isdnl2(&stack->nst);
04707 
04708 
04709       memset(&stack->nst, 0, sizeof(net_stack_t));
04710       memset(&stack->mgr, 0, sizeof(manager_t));
04711    
04712       stack->mgr.nst = &stack->nst;
04713       stack->nst.manager = &stack->mgr;
04714     
04715       stack->nst.l3_manager = handle_event_nt;
04716       stack->nst.device = glob_mgr->midev;
04717       stack->nst.cardnr = port;
04718       stack->nst.d_stid = stack->d_stid;
04719    
04720       stack->nst.feature = FEATURE_NET_HOLD;
04721       if (stack->ptp)
04722          stack->nst.feature |= FEATURE_NET_PTP;
04723       if (stack->pri)
04724          stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
04725       
04726       stack->nst.l1_id = stack->lower_id;
04727       stack->nst.l2_id = stack->upper_id;
04728       
04729       msg_queue_init(&stack->nst.down_queue);
04730    
04731       Isdnl2Init(&stack->nst);
04732       Isdnl3Init(&stack->nst);
04733 
04734       if (!stack->ptp)
04735          misdn_lib_get_l1_up(stack);
04736       misdn_lib_get_l2_up(stack);
04737    }
04738 }

void misdn_lib_release ( struct misdn_bchannel bc  ) 

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

01735 {
01736    int channel;
01737    struct misdn_stack *stack=get_stack_by_bc(bc);
01738 
01739    if (!stack) {
01740       cb_log(1,0,"misdn_release: No Stack found\n");
01741       return;
01742    }
01743    
01744    channel = bc->channel;
01745    empty_bc(bc);
01746    clean_up_bc(bc);
01747    if (channel > 0) {
01748       empty_chan_in_stack(stack, channel);
01749    }
01750    bc->in_use=0;
01751 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Queue Event

Definition at line 3414 of file isdn_lib.c.

References misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_BRIDGED, BCHAN_CLEANED, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::channel_found, misdn_bchannel::channel_preselected, clean_up_bc(), misdn_bchannel::conf_id, create_process(), misdn_bchannel::crypt_key, misdn_bchannel::dad, misdn_bchannel::dnumplan, misdn_stack::downqueue, empty_bc(), empty_chan_in_stack(), ENOCHAN, EVENT_ALERTING, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_HOLD_ACKNOWLEDGE, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), msg, msgs_g, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_bchannel::nt, misdn_stack::nt, misdn_bchannel::oad, misdn_bchannel::onumplan, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, RETURN, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.

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

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

int misdn_lib_send_restart ( int  port,
int  channel 
)

Definition at line 3865 of file isdn_lib.c.

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

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

03866 {
03867    struct misdn_stack *stack=find_stack_by_port(port);
03868    struct misdn_bchannel dummybc;
03869    /*default is all channels*/
03870    cb_log(0, port, "Sending Restarts on this port.\n");
03871    
03872    misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
03873 
03874    /*default is all channels*/
03875    if (channel <0) {
03876       dummybc.channel=-1;
03877       cb_log(0, port, "Restarting and all Interfaces\n");
03878       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03879 
03880       return 0;
03881    }
03882 
03883    /*if a channel is specified we restart only this one*/
03884    if (channel >0) {
03885       int cnt;
03886       dummybc.channel=channel;
03887       cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
03888       misdn_lib_send_event(&dummybc, EVENT_RESTART);
03889       /* clean up chan in stack, to be sure we don't think it's
03890        * in use anymore */
03891       for (cnt=0; cnt<=stack->b_num; cnt++) {
03892          if (stack->bc[cnt].in_use && stack->bc[cnt].channel == channel) {
03893             empty_bc(&stack->bc[cnt]);
03894             clean_up_bc(&stack->bc[cnt]);
03895             stack->bc[cnt].in_use=0;
03896          }
03897       }
03898    }
03899 
03900    return 0;
03901 }

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4515 of file isdn_lib.c.

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

Referenced by hanguptone_indicate().

04516 {
04517    char buf[mISDN_HEADER_LEN + 128] = "";
04518    iframe_t *frm = (iframe_t*)buf;
04519 
04520    switch(tone) {
04521    case TONE_DIAL:
04522       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE); 
04523    break;
04524    
04525    case TONE_ALERTING:
04526       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);  
04527    break;
04528    
04529    case TONE_HANGUP:
04530       manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);   
04531    break;
04532 
04533    case TONE_NONE:
04534    default:
04535       manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);  
04536    }
04537 
04538    frm->prim=DL_DATA|REQUEST;
04539    frm->addr=bc->addr|FLG_MSG_DOWN;
04540    frm->dinfo=0;
04541    frm->len=128;
04542    
04543    mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
04544 }

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 991 of file isdn_lib.c.

References clean_up_bc(), and setup_bc().

00992 {
00993    clean_up_bc(bc);
00994    setup_bc(bc);
00995 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4669 of file isdn_lib.c.

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

Referenced by misdn_bridge().

04670 {
04671 
04672    struct misdn_bchannel *bc_list[]={
04673       bc1,bc2,NULL
04674    };
04675    struct misdn_bchannel **bc;
04676       
04677    for (bc=bc_list; *bc;  bc++) { 
04678       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04679          misdn_split_conf( *bc, (*bc)->conf_id);
04680       } else {
04681          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04682       }
04683    }
04684    
04685 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2264 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02265 {
02266    bc->generate_tone=1;
02267 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2269 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02270 {
02271    bc->generate_tone=0;
02272 }

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

Definition at line 4299 of file isdn_lib.c.

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

Referenced by misdn_join_conf(), and misdn_write().

04300 {
04301    struct misdn_stack *stack=get_stack_by_bc(bc);
04302    char buf[4096 + mISDN_HEADER_LEN];
04303    iframe_t *frm = (iframe_t*)buf;
04304    int r;
04305 
04306    switch (bc->bc_state) {
04307       case BCHAN_ACTIVATED:
04308       case BCHAN_BRIDGED:
04309          break;
04310       default:
04311          cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
04312          return -1;
04313    }
04314    
04315    frm->prim = DL_DATA|REQUEST;
04316    frm->dinfo = 0;
04317    frm->addr = bc->addr | FLG_MSG_DOWN ;
04318    
04319    frm->len = len;
04320    memcpy(&buf[mISDN_HEADER_LEN], data,len);
04321       
04322    if ( misdn_cap_is_speech(bc->capability) ) 
04323       flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
04324    else
04325       cb_log(6, stack->port, "Writing %d data bytes\n",len);
04326    
04327    cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
04328    r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
04329    return 0;
04330 }

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

Definition at line 71 of file isdn_lib.c.

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

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

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


Variable Documentation

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

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

Referenced by misdn_lib_init(), and misdn_tx_jitter().

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

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


Generated on Wed Oct 28 11:46:12 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6