Fri Nov 12 12:04:43 2010

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

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 669 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 666 of file isdn_lib.h.

Referenced by dahdi_call().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 667 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

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

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

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

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

00627 {
00628    cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
00629       bc->l3_id,
00630           bc_state2str(bc->bc_state),
00631           bc_state2str(state) );
00632    
00633    switch (state) {
00634       case BCHAN_ACTIVATED:
00635          if (bc->next_bc_state ==  BCHAN_BRIDGED) {
00636             misdn_join_conf(bc, bc->conf_id);
00637             bc->next_bc_state = BCHAN_EMPTY;
00638             return;
00639          }
00640       default:
00641          bc->bc_state=state;
00642          break;
00643    }
00644 }

void get_show_stack_details ( int  port,
char *  buf 
)

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

00171 {
00172    struct misdn_stack *stack=get_misdn_stack();
00173    
00174    for ( ; stack; stack=stack->next) {
00175       if (stack->port == port) break;
00176    }
00177    
00178    if (stack) {
00179       sprintf(buf, "* Port %d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
00180          stack->port, stack->nt ? "NT" : "TE", stack->ptp ? "PTP" : "PMP",
00181          stack->l2link ? "UP" : "DOWN", stack->l1link ? "UP" : "DOWN",
00182          stack->blocked);
00183    } else {
00184       buf[0]=0;
00185    }
00186 }

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc  ) 

Definition at line 4387 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

04388 {
04389    manager_ph_control(bc, DTMF_TONE_STOP, 0);
04390 }

void isdn_lib_update_ec ( struct misdn_bchannel bc  ) 

Definition at line 4375 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

04376 {
04377 #ifdef MISDN_1_2
04378    if (*bc->pipeline)
04379 #else
04380    if (bc->ec_enable)
04381 #endif
04382       manager_ec_enable(bc);
04383    else
04384       manager_ec_disable(bc);
04385 }

void isdn_lib_update_rxgain ( struct misdn_bchannel bc  ) 

Definition at line 4365 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

04366 {
04367    manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
04368 }

void isdn_lib_update_txgain ( struct misdn_bchannel bc  ) 

Definition at line 4370 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

04371 {
04372    manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
04373 }

void manager_bchannel_activate ( struct misdn_bchannel bc  ) 

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

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

void manager_bchannel_deactivate ( struct misdn_bchannel bc  ) 

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

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

void manager_ec_disable ( struct misdn_bchannel bc  ) 

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

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

void manager_ec_enable ( struct misdn_bchannel bc  ) 

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

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

char* manager_isdn_get_info ( enum event_e  event  ) 

Definition at line 4243 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

04244 {
04245    return isdn_get_info(msgs_g , event, 0);
04246 }

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

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

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

int misdn_cap_is_speech ( int  cap  ) 
void misdn_dump_chanlist ( void   ) 

Definition at line 476 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_channels().

00477 {
00478    struct misdn_stack *stack=get_misdn_stack();
00479    for ( ; stack; stack=stack->next) {
00480       dump_chan_list(stack);
00481    }
00482 
00483 }

int misdn_inband_avail ( struct misdn_bchannel bc  ) 

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

00447 {
00448 
00449    if (!bc->early_bconnect) {
00450       /* We have opted to never receive any available inband recorded messages */
00451       return 0;
00452    }
00453    
00454    switch (bc->progress_indicator) {
00455    case INFO_PI_INBAND_AVAILABLE:
00456    case INFO_PI_CALL_NOT_E2E_ISDN:
00457    case INFO_PI_CALLED_NOT_ISDN:
00458       return 1;
00459    default:
00460       return 0;
00461    }
00462    return 0;
00463 }

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

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

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

void misdn_lib_destroy ( void   ) 

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

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

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4696 of file isdn_lib.c.

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

04697 {
04698    cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
04699    manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
04700 }

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

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

Referenced by misdn_hangup().

04507 {
04508    struct misdn_bchannel *bc;
04509    struct misdn_stack *stack;
04510 
04511    bc = NULL;
04512    for (stack = get_misdn_stack(); stack; stack = stack->next) {
04513       if (stack->port == port) {
04514          bc = stack_holder_find(stack, l3_id);
04515          break;
04516       }
04517    }
04518 
04519    return bc;
04520 }

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

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

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

int misdn_lib_get_maxchans ( int  port  ) 

Definition at line 139 of file isdn_lib.c.

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

Referenced by misdn_request().

00140 {
00141    struct misdn_stack *stack=get_misdn_stack();
00142    for ( ; stack; stack=stack->next) {
00143       if (stack->port == port) {
00144          if (stack->pri) 
00145             return 30;
00146          else
00147             return 2;
00148       }
00149    }
00150    return -1;
00151 }

int misdn_lib_get_port_down ( int  port  ) 

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

01787 { /* Pull Down L1 */ 
01788    struct misdn_stack *stack;
01789    for (stack=glob_mgr->stack_list;
01790         stack;
01791         stack=stack->next) {
01792       if (stack->port == port) {
01793             if (stack->l2link)
01794                misdn_lib_get_l2_down(stack);
01795             misdn_lib_get_l1_down(stack);
01796          return 0;
01797       }
01798    }
01799    return 0;
01800 }

int misdn_lib_get_port_info ( int  port  ) 

Definition at line 3807 of file isdn_lib.c.

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

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

int misdn_lib_get_port_up ( int  port  ) 

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

01765 { /* Pull Up L1 */ 
01766    struct misdn_stack *stack;
01767    
01768    for (stack=glob_mgr->stack_list;
01769         stack;
01770         stack=stack->next) {
01771       
01772       if (stack->port == port) {
01773 
01774          if (!stack->l1link)
01775             misdn_lib_get_l1_up(stack);
01776          if (!stack->l2link)
01777             misdn_lib_get_l2_up(stack);
01778          
01779          return 0;
01780       }
01781    }
01782    return 0;
01783 }

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

Definition at line 4102 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(), 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, and te_lib_init().

Referenced by load_module().

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

int misdn_lib_is_port_blocked ( int  port  ) 

Definition at line 119 of file isdn_lib.c.

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

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

int misdn_lib_is_ptp ( int  port  ) 

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

00131 {
00132    struct misdn_stack *stack=get_misdn_stack();
00133    for ( ; stack; stack=stack->next) {
00134       if (stack->port == port) return stack->ptp;
00135    }
00136    return -1;
00137 }

void misdn_lib_isdn_l1watcher ( int  port  ) 

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

03089 {
03090    struct misdn_stack *stack;
03091 
03092    for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
03093       ;
03094 
03095    if (stack) {
03096       cb_log(4, port, "Checking L1 State\n");   
03097       if (!stack->l1link) {
03098          cb_log(4, port, "L1 State Down, trying to get it up again\n"); 
03099          misdn_lib_get_short_status(stack);
03100          misdn_lib_get_l1_up(stack); 
03101          misdn_lib_get_l2_up(stack); 
03102       }
03103    }
03104 }

void misdn_lib_log_ies ( struct misdn_bchannel bc  ) 

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

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

int misdn_lib_maxports_get ( void   ) 

Definition at line 4053 of file isdn_lib.c.

Referenced by load_module().

04054 {
04055    /* BE AWARE WE HAVE NO cb_log() HERE! */
04056 
04057    int i = mISDN_open();
04058    int max=0;
04059    
04060    if (i<0)
04061       return -1;
04062 
04063    max = mISDN_get_stack_count(i);
04064    
04065    mISDN_close(i);
04066    
04067    return max;
04068 }

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4083 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

04084 {
04085    static int init=0;
04086    char *f;
04087    
04088    if (!flags) 
04089       f=NULL;
04090    else
04091       f=file;
04092 
04093    if (!init) {
04094       debug_init( flags , f, f, f);
04095       init=1;
04096    } else {
04097       debug_close();
04098       debug_init( flags , f, f, f);
04099    }
04100 }

void misdn_lib_nt_keepcalls ( int  kc  ) 

Definition at line 4071 of file isdn_lib.c.

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

Referenced by load_module().

04072 {
04073 #ifdef FEATURE_NET_KEEPCALLS
04074    if (kc) {
04075       struct misdn_stack *stack=get_misdn_stack();
04076       for ( ; stack; stack=stack->next) {
04077          stack->nst.feature |= FEATURE_NET_KEEPCALLS;
04078       }
04079    }
04080 #endif
04081 }

int misdn_lib_pid_restart ( int  pid  ) 

Definition at line 3862 of file isdn_lib.c.

References manager_clean_bc(), and manager_find_bc_by_pid().

Referenced by handle_cli_misdn_restart_pid().

03863 {
03864    struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);
03865 
03866    if (bc) {
03867       manager_clean_bc(bc);
03868    }
03869    return 0;
03870 }

int misdn_lib_port_block ( int  port  ) 

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

00094 {
00095    struct misdn_stack *stack=get_misdn_stack();
00096    for ( ; stack; stack=stack->next) {
00097       if (stack->port == port) {
00098          stack->blocked=1;
00099          return 0;
00100       }
00101    }
00102    return -1;
00103 
00104 }

int misdn_lib_port_is_nt ( int  port  ) 

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

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

int misdn_lib_port_is_pri ( int  port  ) 

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

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

int misdn_lib_port_restart ( int  port  ) 

Definition at line 3912 of file isdn_lib.c.

References misdn_lib::activatequeue, cb_log, clear_l3(), find_stack_by_port(), misdn_lib_reinit_nt_stack(), misdn_lib::new_msg, misdn_stack::nt, misdn_stack::port, and misdn_stack::upper_id.

Referenced by handle_cli_misdn_restart_port().

03913 {
03914    struct misdn_stack *stack=find_stack_by_port(port);
03915  
03916    cb_log(0, port, "Restarting this port.\n");
03917    if (stack) {
03918       cb_log(0, port, "Stack:%p\n",stack);
03919          
03920       clear_l3(stack);
03921       {
03922          msg_t *msg=alloc_msg(MAX_MSG_SIZE);
03923          iframe_t *frm;
03924 
03925          if (!msg) {
03926             cb_log(0, port, "port_restart: alloc_msg failed\n");
03927             return -1;
03928          }
03929          
03930          frm=(iframe_t*)msg->data;
03931          /* we must activate if we are deactivated */
03932          /* activate bchannel */
03933          frm->prim = DL_RELEASE | REQUEST;
03934          frm->addr = stack->upper_id | FLG_MSG_DOWN;
03935 
03936          frm->dinfo = 0;
03937          frm->len = 0;
03938          msg_queue_tail(&glob_mgr->activatequeue, msg);
03939          sem_post(&glob_mgr->new_msg);
03940       }
03941 
03942       if (stack->nt)
03943          misdn_lib_reinit_nt_stack(stack->port);
03944     
03945    }
03946 
03947    return 0;
03948 }

int misdn_lib_port_unblock ( int  port  ) 

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

00107 {
00108    struct misdn_stack *stack=get_misdn_stack();
00109    for ( ; stack; stack=stack->next) {
00110       if (stack->port == port) {
00111          stack->blocked=0;
00112          return 0;
00113       }
00114    }
00115    return -1;
00116 
00117 }

int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

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

void misdn_lib_reinit_nt_stack ( int  port  ) 

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

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

void misdn_lib_release ( struct misdn_bchannel bc  ) 

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

01743 {
01744    int channel;
01745    struct misdn_stack *stack=get_stack_by_bc(bc);
01746 
01747    if (!stack) {
01748       cb_log(1,0,"misdn_release: No Stack found\n");
01749       return;
01750    }
01751    
01752    channel = bc->channel;
01753    empty_bc(bc);
01754    clean_up_bc(bc);
01755    if (channel > 0) {
01756       empty_chan_in_stack(stack, channel);
01757    }
01758    bc->in_use=0;
01759 }

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Queue Event

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

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

int misdn_lib_send_restart ( int  port,
int  channel 
)

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

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

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

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

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

void misdn_lib_setup_bc ( struct misdn_bchannel bc  ) 

Definition at line 999 of file isdn_lib.c.

References clean_up_bc(), and setup_bc().

01000 {
01001    clean_up_bc(bc);
01002    setup_bc(bc);
01003 }

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4676 of file isdn_lib.c.

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

Referenced by misdn_bridge().

04677 {
04678 
04679    struct misdn_bchannel *bc_list[]={
04680       bc1,bc2,NULL
04681    };
04682    struct misdn_bchannel **bc;
04683       
04684    for (bc=bc_list; *bc;  bc++) { 
04685       if ( (*bc)->bc_state == BCHAN_BRIDGED){
04686          misdn_split_conf( *bc, (*bc)->conf_id);
04687       } else {
04688          cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
04689       }
04690    }
04691    
04692 }

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc  ) 

Definition at line 2272 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

02273 {
02274    bc->generate_tone=1;
02275 }

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc  ) 

Definition at line 2277 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

02278 {
02279    bc->generate_tone=0;
02280 }

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

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

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

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

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

00080 {
00081    memset (dummybc,0,sizeof(struct misdn_bchannel));
00082    dummybc->port=port;
00083    if (l3id==0) 
00084       dummybc->l3_id = MISDN_ID_DUMMY;
00085    else
00086       dummybc->l3_id=l3id;
00087 
00088    dummybc->nt=nt;
00089    dummybc->dummy=1;
00090    dummybc->channel=channel;
00091 }


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 by  doxygen 1.6.2