Mon Mar 12 2012 21:40:28

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
 B channel control structure. More...
struct  misdn_lib_iface
struct  misdn_party_dialing
 Dialed/Called information struct. More...
struct  misdn_party_id
 Connected-Line/Calling/Redirecting ID info struct. More...
struct  misdn_party_redirecting
 Redirecting information struct. More...

Defines

#define MAX_BCHANS   31
#define MISDN_MAX_KEYPAD_LEN   (31 + 1)
#define MISDN_MAX_NAME_LEN   (50 + 1)
#define MISDN_MAX_NUMBER_LEN   (31 + 1)
#define MISDN_MAX_SUBADDRESS_LEN   (23 + 1)
#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_REGISTER, 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_NOTIFY_CODE {
  mISDN_NOTIFY_CODE_INVALID = -1, mISDN_NOTIFY_CODE_USER_SUSPEND = 0x00, mISDN_NOTIFY_CODE_USER_RESUME = 0x01, mISDN_NOTIFY_CODE_CALL_IS_DIVERTING = 0x7B,
  mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED = 0x68, mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING = 0x69, mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE = 0x6A
}
 Notification description code enumeration. More...
enum  mISDN_NUMBER_PLAN {
  NUMPLAN_UNKNOWN = 0x0, NUMPLAN_ISDN = 0x1, NUMPLAN_DATA = 0x3, NUMPLAN_TELEX = 0x4,
  NUMPLAN_NATIONAL = 0x8, NUMPLAN_PRIVATE = 0x9
}
enum  mISDN_NUMBER_TYPE {
  NUMTYPE_UNKNOWN = 0x0, NUMTYPE_INTERNATIONAL = 0x1, NUMTYPE_NATIONAL = 0x2, NUMTYPE_NETWORK_SPECIFIC = 0x3,
  NUMTYPE_SUBSCRIBER = 0x4, NUMTYPE_ABBREVIATED = 0x5
}
enum  mISDN_REDIRECTING_REASON {
  mISDN_REDIRECTING_REASON_UNKNOWN = 0x0, mISDN_REDIRECTING_REASON_CALL_FWD_BUSY = 0x1, mISDN_REDIRECTING_REASON_NO_REPLY = 0x2, mISDN_REDIRECTING_REASON_DEFLECTION = 0x4,
  mISDN_REDIRECTING_REASON_OUT_OF_ORDER = 0x9, mISDN_REDIRECTING_REASON_CALL_FWD_DTE = 0xA, mISDN_REDIRECTING_REASON_CALL_FWD = 0xF
}
 Q.931 encoded redirecting reason. More...
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 MISDN_MAX_KEYPAD_LEN   (31 + 1)

Maximum keypad facility content length plus null terminator

Definition at line 262 of file isdn_lib.h.

#define MISDN_MAX_NAME_LEN   (50 + 1)

Maximum name length plus null terminator (From ECMA-164)

Definition at line 256 of file isdn_lib.h.

#define MISDN_MAX_NUMBER_LEN   (31 + 1)

Maximum phone number (address) length plus null terminator

Definition at line 253 of file isdn_lib.h.

Referenced by misdn_add_number_prefix().

#define MISDN_MAX_SUBADDRESS_LEN   (23 + 1)

Maximum subaddress length plus null terminator

Definition at line 259 of file isdn_lib.h.

#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 832 of file isdn_lib.h.

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 833 of file isdn_lib.h.

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 830 of file isdn_lib.h.

Referenced by sig_pri_call().

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 831 of file isdn_lib.h.

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 829 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 178 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 188 of file isdn_lib.h.

anonymous enum
Enumerator:
INFO_CODEC_ULAW 
INFO_CODEC_ALAW 

Definition at line 239 of file isdn_lib.h.

     { /*CODECS*/
   INFO_CODEC_ULAW=2,
   INFO_CODEC_ALAW=3
};
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.

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

Enumerator:
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE 
RESPONSE_IGNORE_SETUP 
RESPONSE_RELEASE_SETUP 
RESPONSE_ERR 
RESPONSE_OK 

Definition at line 117 of file isdn_lib.h.

enum ie_name_e
Enumerator:
IE_DUMMY 
IE_LAST 

Definition at line 173 of file isdn_lib.h.

enum layer_e
Enumerator:
L3 
L2 
L1 
UNKNOWN 

Definition at line 245 of file isdn_lib.h.

             {
   L3,
   L2,
   L1,
   UNKNOWN
};
Enumerator:
ENOCHAN 

Definition at line 95 of file isdn_lib.h.

                 {
   ENOCHAN=1
};

Notification description code enumeration.

Enumerator:
mISDN_NOTIFY_CODE_INVALID 
mISDN_NOTIFY_CODE_USER_SUSPEND 

Call is placed on hold (Q.931)

mISDN_NOTIFY_CODE_USER_RESUME 

Call is taken off of hold (Q.931)

mISDN_NOTIFY_CODE_CALL_IS_DIVERTING 

Call is diverting (EN 300 207-1 Section 7.2.1)

mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED 

Call diversion is enabled (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1)

mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING 

Call transfer, alerting (EN 300 369-1 Section 7.2)

mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE 

Call transfer, active(answered) (EN 300 369-1 Section 7.2)

Definition at line 223 of file isdn_lib.h.

                       {
   mISDN_NOTIFY_CODE_INVALID = -1,
   /*! Call is placed on hold (Q.931) */
   mISDN_NOTIFY_CODE_USER_SUSPEND = 0x00,
   /*! Call is taken off of hold (Q.931) */
   mISDN_NOTIFY_CODE_USER_RESUME = 0x01,
   /*! Call is diverting (EN 300 207-1 Section 7.2.1) */
   mISDN_NOTIFY_CODE_CALL_IS_DIVERTING = 0x7B,
   /*! Call diversion is enabled (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1) */
   mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED = 0x68,
   /*! Call transfer, alerting (EN 300 369-1 Section 7.2) */
   mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING = 0x69,
   /*! Call transfer, active(answered) (EN 300 369-1 Section 7.2) */
   mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE = 0x6A,
};
Enumerator:
NUMPLAN_UNKNOWN 
NUMPLAN_ISDN 
NUMPLAN_DATA 
NUMPLAN_TELEX 
NUMPLAN_NATIONAL 
NUMPLAN_PRIVATE 

Definition at line 99 of file isdn_lib.h.

                       {
   NUMPLAN_UNKNOWN = 0x0,
   NUMPLAN_ISDN = 0x1,     /* ISDN/Telephony numbering plan E.164 */
   NUMPLAN_DATA = 0x3,     /* Data numbering plan X.121 */
   NUMPLAN_TELEX = 0x4, /* Telex numbering plan F.69 */
   NUMPLAN_NATIONAL = 0x8,
   NUMPLAN_PRIVATE = 0x9
};
Enumerator:
NUMTYPE_UNKNOWN 
NUMTYPE_INTERNATIONAL 
NUMTYPE_NATIONAL 
NUMTYPE_NETWORK_SPECIFIC 
NUMTYPE_SUBSCRIBER 
NUMTYPE_ABBREVIATED 

Definition at line 108 of file isdn_lib.h.

Q.931 encoded redirecting reason.

Enumerator:
mISDN_REDIRECTING_REASON_UNKNOWN 
mISDN_REDIRECTING_REASON_CALL_FWD_BUSY 

Call forwarding busy or called DTE busy

mISDN_REDIRECTING_REASON_NO_REPLY 

Call forwarding no reply

mISDN_REDIRECTING_REASON_DEFLECTION 

Call deflection

mISDN_REDIRECTING_REASON_OUT_OF_ORDER 

Called DTE out of order

mISDN_REDIRECTING_REASON_CALL_FWD_DTE 

Call forwarding by the called DTE

mISDN_REDIRECTING_REASON_CALL_FWD 

Call forwarding unconditional or systematic call redirection

Definition at line 204 of file isdn_lib.h.

                              {
   mISDN_REDIRECTING_REASON_UNKNOWN = 0x0,
   /*! Call forwarding busy or called DTE busy */
   mISDN_REDIRECTING_REASON_CALL_FWD_BUSY = 0x1,
   /*! Call forwarding no reply */
   mISDN_REDIRECTING_REASON_NO_REPLY = 0x2,
   /*! Call deflection */
   mISDN_REDIRECTING_REASON_DEFLECTION = 0x4,
   /*! Called DTE out of order */
   mISDN_REDIRECTING_REASON_OUT_OF_ORDER = 0x9,
   /*! Call forwarding by the called DTE */
   mISDN_REDIRECTING_REASON_CALL_FWD_DTE = 0xA,
   /*! Call forwarding unconditional or systematic call redirection */
   mISDN_REDIRECTING_REASON_CALL_FWD = 0xF
};
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.


Function Documentation

char* bc_state2str ( enum bchannel_state  state)

Definition at line 621 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, and BCHAN_SETUPED.

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

                                              {
   int i;

   struct bchan_state_s {
      char *n;
      enum bchannel_state s;
   } states[] = {
      {"BCHAN_CLEANED", BCHAN_CLEANED },
      {"BCHAN_EMPTY", BCHAN_EMPTY},
      {"BCHAN_SETUP", BCHAN_SETUP},
      {"BCHAN_SETUPED", BCHAN_SETUPED},
      {"BCHAN_ACTIVE", BCHAN_ACTIVE},
      {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
      {"BCHAN_BRIDGE",  BCHAN_BRIDGE},
      {"BCHAN_BRIDGED", BCHAN_BRIDGED},
      {"BCHAN_RELEASE", BCHAN_RELEASE},
      {"BCHAN_RELEASED", BCHAN_RELEASED},
      {"BCHAN_CLEAN", BCHAN_CLEAN},
      {"BCHAN_CLEAN_REQUEST", BCHAN_CLEAN_REQUEST},
      {"BCHAN_ERROR", BCHAN_ERROR}
   };

   for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
      if ( states[i].s == state)
         return states[i].n;

   return "UNKNOWN";
}
void get_show_stack_details ( int  port,
char *  buf 
)

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

{
   struct misdn_stack *stack = get_misdn_stack();

   for (; stack; stack = stack->next) {
      if (stack->port == port) {
         break;
      }
   }

   if (stack) {
      sprintf(buf, "* Port %2d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
         stack->port,
         stack->nt ? "NT" : "TE",
         stack->ptp ? "PTP" : "PMP",
         stack->l2link ? "UP  " : "DOWN",
         stack->l1link ? "UP  " : "DOWN",
         stack->blocked);
   } else {
      buf[0] = 0;
   }
}
void isdn_lib_stop_dtmf ( struct misdn_bchannel bc)

Definition at line 4633 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

{
   manager_ph_control(bc, DTMF_TONE_STOP, 0);
}
void isdn_lib_update_ec ( struct misdn_bchannel bc)

Definition at line 4621 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

{
#ifdef MISDN_1_2
   if (*bc->pipeline)
#else
   if (bc->ec_enable)
#endif
      manager_ec_enable(bc);
   else
      manager_ec_disable(bc);
}
void isdn_lib_update_rxgain ( struct misdn_bchannel bc)

Definition at line 4611 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

{
   manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
}
void isdn_lib_update_txgain ( struct misdn_bchannel bc)

Definition at line 4616 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

{
   manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
}
void manager_bchannel_activate ( struct misdn_bchannel bc)

Definition at line 4494 of file isdn_lib.c.

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

Referenced by setup_bc().

{
   char buf[128];

   struct misdn_stack *stack=get_stack_by_bc(bc);

   if (!stack) {
      cb_log(0, bc->port, "bchannel_activate: Stack not found !");
      return ;
   }

   /* we must activate if we are deactivated */
   clear_ibuffer(bc->astbuf);

   cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);

   mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN,  DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);

   return ;
}
void manager_bchannel_deactivate ( struct misdn_bchannel bc)

Definition at line 4516 of file isdn_lib.c.

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

Referenced by clean_up_bc().

{
   struct misdn_stack *stack=get_stack_by_bc(bc);
   iframe_t dact;
   char buf[128];

   switch (bc->bc_state) {
      case BCHAN_ACTIVATED:
         break;
      case BCHAN_BRIDGED:
         misdn_split_conf(bc,bc->conf_id);
         break;
      default:
         cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
         return ;

   }

   cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);

   bc->generate_tone=0;

   dact.prim = DL_RELEASE | REQUEST;
   dact.addr = bc->addr | FLG_MSG_DOWN;
   dact.dinfo = 0;
   dact.len = 0;
   mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);

   clear_ibuffer(bc->astbuf);

   bc_state_change(bc,BCHAN_RELEASE);

   return;
}
void manager_ec_disable ( struct misdn_bchannel bc)

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

{
   struct misdn_stack *stack=get_stack_by_bc(bc);

   cb_log(4, stack?stack->port:0," --> ec_disable\n");

   if (!misdn_cap_is_speech(bc->capability)) {
      cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
      return;
   }

#ifdef MISDN_1_2
   manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
#else
   if ( ! bc->ec_enable) {
      cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
      manager_ph_control(bc,  ECHOCAN_OFF, 0);
   }
#endif
}
void manager_ec_enable ( struct misdn_bchannel bc)

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

{
   struct misdn_stack *stack=get_stack_by_bc(bc);

   cb_log(4, stack?stack->port:0,"ec_enable\n");

   if (!misdn_cap_is_speech(bc->capability)) {
      cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
   } else {

#ifdef MISDN_1_2
   if (*bc->pipeline) {
      cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
      manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
   }
#else
   int ec_arr[2];

   if (bc->ec_enable) {
      cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);

      switch (bc->ec_deftaps) {
      case 4:
      case 8:
      case 16:
      case 32:
      case 64:
      case 128:
      case 256:
      case 512:
      case 1024:
         cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
         break;
      default:
         cb_log(0, stack->port, "Taps should be power of 2\n");
         bc->ec_deftaps=128;
      }

      ec_arr[0]=bc->ec_deftaps;
      ec_arr[1]=0;

      manager_ph_control_block(bc,  ECHOCAN_ON,  ec_arr, sizeof(ec_arr));
   }
#endif
   }
}
char* manager_isdn_get_info ( enum event_e  event)

Definition at line 4489 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

{
   return isdn_get_info(msgs_g , event, 0);
}
void manager_ph_control ( struct misdn_bchannel bc,
int  c1,
int  c2 
)

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

{
   unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
   iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
   unsigned int *d = (unsigned int*)&ctrl->data.p;
   /*struct misdn_stack *stack=get_stack_by_bc(bc);*/

   cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);

   ctrl->prim = PH_CONTROL | REQUEST;
   ctrl->addr = bc->addr | FLG_MSG_DOWN;
   ctrl->dinfo = 0;
   ctrl->len = sizeof(unsigned int)*2;
   *d++ = c1;
   *d++ = c2;
   mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
}
void misdn_dump_chanlist ( void  )

Definition at line 487 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_channels().

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      dump_chan_list(stack);
   }

}
int misdn_inband_avail ( struct misdn_bchannel bc)

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

{

   if (!bc->early_bconnect) {
      /* We have opted to never receive any available inband recorded messages */
      return 0;
   }

   switch (bc->progress_indicator) {
   case INFO_PI_INBAND_AVAILABLE:
   case INFO_PI_CALL_NOT_E2E_ISDN:
   case INFO_PI_CALLED_NOT_ISDN:
      return 1;
   default:
      return 0;
   }
   return 0;
}
void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4901 of file isdn_lib.c.

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

Referenced by misdn_bridge().

{
   int conf_id = bc1->pid + 1;
   struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL };
   struct misdn_bchannel **bc;

   cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);

   for (bc=bc_list; *bc;  bc++) {
      (*bc)->conf_id=conf_id;
      cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);

      switch((*bc)->bc_state) {
         case BCHAN_ACTIVATED:
            misdn_join_conf(*bc,conf_id);
            break;
         default:
            bc_next_state_change(*bc,BCHAN_BRIDGED);
            break;
      }
   }
}
void misdn_lib_destroy ( void  )

Definition at line 4456 of file isdn_lib.c.

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

Referenced by unload_module().

{
   struct misdn_stack *help;
   int i;

   for ( help=glob_mgr->stack_list; help; help=help->next ) {
      for(i=0;i<=help->b_num; i++) {
         char buf[1024];
         mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
         help->bc[i].addr = 0;
      }
      cb_log (1, help->port, "Destroying this port.\n");
      stack_destroy(help);
   }

   if (global_state == MISDN_INITIALIZED) {
      cb_log(4, 0, "Killing Handler Thread\n");
      if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
         cb_log(4, 0, "Joining Handler Thread\n");
         pthread_join(glob_mgr->event_handler_thread, NULL);
      }

      cb_log(4, 0, "Killing Main Thread\n");
      if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
         cb_log(4, 0, "Joining Main Thread\n");
         pthread_join(glob_mgr->event_thread, NULL);
      }
   }

   cb_log(1, 0, "Closing mISDN device\n");
   te_lib_destroy(glob_mgr->midev);
}
void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4944 of file isdn_lib.c.

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

{
   cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
   manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
}
struct misdn_bchannel* misdn_lib_find_held_bc ( int  port,
int  l3_id 
) [read]

Find a held call's B channel record.

Parameters:
portPort the call is on.
l3_idmISDN Layer 3 ID of held call.
Returns:
Found bc-record or NULL.

Definition at line 4753 of file isdn_lib.c.

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

Referenced by misdn_hangup().

{
   struct misdn_bchannel *bc;
   struct misdn_stack *stack;

   bc = NULL;
   for (stack = get_misdn_stack(); stack; stack = stack->next) {
      if (stack->port == port) {
         bc = stack_holder_find(stack, l3_id);
         break;
      }
   }

   return bc;
}
struct misdn_bchannel* misdn_lib_get_free_bc ( int  port,
int  channel,
int  inout,
int  dec 
) [read]

Definition at line 3312 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, find_stack_by_port(), MAX_BCHANS, prepare_bc(), misdn_stack::pri, pthread_mutex_lock, pthread_mutex_unlock, misdn_stack::ptp, misdn_stack::st_lock, and test_inuse().

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

{
   struct misdn_stack *stack;
   int i;
   int maxnum;

   if (channel < 0 || channel > MAX_BCHANS) {
      cb_log(0, port, "Requested channel out of bounds (%d)\n", channel);
      return NULL;
   }

   /* Find the port stack structure */
   stack = find_stack_by_port(port);
   if (!stack) {
      cb_log(0, port, "Port is not configured (%d)\n", port);
      return NULL;
   }

   if (stack->blocked) {
      cb_log(0, port, "Port is blocked\n");
      return NULL;
   }

   pthread_mutex_lock(&stack->st_lock);
   if (channel > 0) {
      if (channel <= stack->b_num) {
         for (i = 0; i < stack->b_num; i++) {
            if (stack->bc[i].channel == channel) {
               if (test_inuse(&stack->bc[i])) {
                  pthread_mutex_unlock(&stack->st_lock);
                  cb_log(0, port, "Requested channel:%d on port:%d is already in use\n", channel, port);
                  return NULL;
               } else {
                  prepare_bc(&stack->bc[i], channel);
                  pthread_mutex_unlock(&stack->st_lock);
                  return &stack->bc[i];
               }
            }
         }
      } else {
         pthread_mutex_unlock(&stack->st_lock);
         cb_log(0, port, "Requested channel:%d is out of bounds on port:%d\n", channel, port);
         return NULL;
      }
   }

   /* Note: channel == 0 here */
   maxnum = (inout && !stack->pri && !stack->ptp) ? stack->b_num + 1 : stack->b_num;
   if (dec) {
      for (i = maxnum - 1; i >= 0; --i) {
         if (!test_inuse(&stack->bc[i])) {
            /* 3. channel on bri means CW*/
            if (!stack->pri && i == stack->b_num) {
               stack->bc[i].cw = 1;
            }

            prepare_bc(&stack->bc[i], channel);
            stack->bc[i].dec = 1;
            pthread_mutex_unlock(&stack->st_lock);
            return &stack->bc[i];
         }
      }
   } else {
      for (i = 0; i < maxnum; ++i) {
         if (!test_inuse(&stack->bc[i])) {
            /* 3. channel on bri means CW */
            if (!stack->pri && i == stack->b_num) {
               stack->bc[i].cw = 1;
            }

            prepare_bc(&stack->bc[i], channel);
            pthread_mutex_unlock(&stack->st_lock);
            return &stack->bc[i];
         }
      }
   }
   pthread_mutex_unlock(&stack->st_lock);

   cb_log(1, port, "There is no free channel on port (%d)\n", port);
   return NULL;
}
int misdn_lib_get_maxchans ( int  port)

Definition at line 137 of file isdn_lib.c.

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

Referenced by misdn_request().

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         if (stack->pri)
            return 30;
         else
            return 2;
      }
   }
   return -1;
}
int misdn_lib_get_port_down ( int  port)

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

{ /* Pull Down L1 */
   struct misdn_stack *stack;
   for (stack=glob_mgr->stack_list;
        stack;
        stack=stack->next) {
      if (stack->port == port) {
            if (stack->l2link)
               misdn_lib_get_l2_down(stack);
            misdn_lib_get_l1_down(stack);
         return 0;
      }
   }
   return 0;
}
int misdn_lib_get_port_info ( int  port)

Definition at line 4045 of file isdn_lib.c.

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

{
   msg_t *msg=alloc_msg(MAX_MSG_SIZE);
   iframe_t *frm;
   struct misdn_stack *stack=find_stack_by_port(port);
   if (!msg) {
      cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n");
      return -1;
   }
   frm=(iframe_t*)msg->data;
   if (!stack ) {
      cb_log(0, port, "There is no Stack for this port.\n");
      return -1;
   }
   /* activate bchannel */
   frm->prim = CC_STATUS_ENQUIRY | REQUEST;

   frm->addr = stack->upper_id| FLG_MSG_DOWN;

   frm->dinfo = 0;
   frm->len = 0;

   msg_queue_tail(&glob_mgr->activatequeue, msg);
   sem_post(&glob_mgr->new_msg);


   return 0;
}
int misdn_lib_get_port_up ( int  port)

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

{ /* Pull Up L1 */
   struct misdn_stack *stack;

   for (stack=glob_mgr->stack_list;
        stack;
        stack=stack->next) {

      if (stack->port == port) {

         if (!stack->l1link)
            misdn_lib_get_l1_up(stack);
         if (!stack->l2link)
            misdn_lib_get_l2_up(stack);

         return 0;
      }
   }
   return 0;
}
int misdn_lib_init ( char *  portlist,
struct misdn_lib_iface iface,
void *  user_data 
)

Definition at line 4340 of file isdn_lib.c.

References misdn_lib::activatequeue, ARRAY_LEN, misdn_stack::b_num, misdn_stack::bc, calloc, cb_event, misdn_lib_iface::cb_event, cb_jb_empty, misdn_lib_iface::cb_jb_empty, cb_log, misdn_lib_iface::cb_log, misdn_lib::event_handler_thread, misdn_lib::event_thread, flip_buf_bits(), init_bc(), init_flip_bits(), misdn_bchannel::is_register_pool, manager_event_handler(), MAX_BCHANS, 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().

{
   struct misdn_lib *mgr=calloc(1, sizeof(struct misdn_lib));
   char *tok, *tokb;
   char plist[1024];
   int midev;
   int port_count=0;

   cb_log = iface->cb_log;
   cb_event = iface->cb_event;
   cb_jb_empty = iface->cb_jb_empty;

   glob_mgr = mgr;

   msg_init();

   misdn_lib_nt_debug_init(0,NULL);

   if (!portlist || (*portlist == 0) ) return 1;

   init_flip_bits();

   {
      strncpy(plist,portlist, 1024);
      plist[1023] = 0;
   }

   memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
   flip_buf_bits(tone_425_flip,TONE_425_SIZE);

   memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
   flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);

   midev=te_lib_init();
   mgr->midev=midev;

   port_count=mISDN_get_stack_count(midev);

   msg_queue_init(&mgr->activatequeue);

   if (sem_init(&mgr->new_msg, 1, 0)<0)
      sem_init(&mgr->new_msg, 0, 0);

   for (tok=strtok_r(plist," ,",&tokb );
        tok;
        tok=strtok_r(NULL," ,",&tokb)) {
      int port = atoi(tok);
      struct misdn_stack *stack;
      struct misdn_stack *help;
      int ptp=0;
      int i;
      int r;

      if (strstr(tok, "ptp"))
         ptp=1;

      if (port > port_count) {
         cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
         exit(1);
      }

      stack = stack_init(midev, port, ptp);
      if (!stack) {
         perror("stack_init");
         exit(1);
      }

      /* Initialize the B channel records for real B channels. */
      for (i = 0; i <= stack->b_num; i++) {
         r = init_bc(stack, &stack->bc[i], stack->midev, port, i);
         if (r < 0) {
            cb_log(0, port, "Got Err @ init_bc :%d\n", r);
            exit(1);
         }
      }
#if defined(AST_MISDN_ENHANCEMENTS)
      /* Initialize the B channel records for REGISTER signaling links. */
      for (i = MAX_BCHANS + 1; i < ARRAY_LEN(stack->bc); ++i) {
         r = init_bc(stack, &stack->bc[i], stack->midev, port, i);
         if (r < 0) {
            cb_log(0, port, "Got Err @ init_bc :%d\n", r);
            exit(1);
         }
         stack->bc[i].is_register_pool = 1;
      }
#endif   /* defined(AST_MISDN_ENHANCEMENTS) */

      /* Add the new stack to the end of the list */
      help = mgr->stack_list;
      if (!help) {
         mgr->stack_list = stack;
      } else {
         while (help->next) {
            help = help->next;
         }
         help->next = stack;
      }
   }

   if (sem_init(&handler_started, 1, 0)<0)
      sem_init(&handler_started, 0, 0);

   cb_log(8, 0, "Starting Event Handler\n");
   pthread_create( &mgr->event_handler_thread, NULL,(void*)manager_event_handler, mgr);

   sem_wait(&handler_started) ;
   cb_log(8, 0, "Starting Event Catcher\n");
   pthread_create( &mgr->event_thread, NULL, (void*)misdn_lib_isdn_event_catcher, mgr);

   cb_log(8, 0, "Event Catcher started\n");

   global_state= MISDN_INITIALIZED;

   return (mgr == NULL);
}
int misdn_lib_is_port_blocked ( int  port)

Definition at line 117 of file isdn_lib.c.

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

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         return stack->blocked;
      }
   }
   return -1;
}
int misdn_lib_is_ptp ( int  port)

Definition at line 128 of file isdn_lib.c.

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

Referenced by build_setup(), cb_events(), do_immediate_setup(), misdn_call(), misdn_update_connected_line(), and misdn_update_redirecting().

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) return stack->ptp;
   }
   return -1;
}
void misdn_lib_isdn_l1watcher ( int  port)

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

{
   struct misdn_stack *stack;

   for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
      ;

   if (stack) {
      cb_log(4, port, "Checking L1 State\n");
      if (!stack->l1link) {
         cb_log(4, port, "L1 State Down, trying to get it up again\n");
         misdn_lib_get_short_status(stack);
         misdn_lib_get_l1_up(stack);
         misdn_lib_get_l2_up(stack);
      }
   }
}
void misdn_lib_log_ies ( struct misdn_bchannel bc)

Definition at line 3538 of file isdn_lib.c.

References misdn_bchannel::addr, misdn_bchannel::b_stid, bearer2str(), misdn_bchannel::caller, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, misdn_bchannel::channel, misdn_bchannel::connected, misdn_party_redirecting::count, misdn_bchannel::dialed, fac2str(), misdn_bchannel::fac_in, misdn_bchannel::fac_out, misdn_party_redirecting::from, 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_party_id::name, misdn_stack::nt, misdn_party_id::number, misdn_party_dialing::number_plan, misdn_party_id::number_plan, misdn_party_dialing::number_type, misdn_party_id::number_type, misdn_bchannel::out_cause, misdn_stack::port, misdn_party_id::presentation, misdn_bchannel::presentation, misdn_bchannel::progress_indicator, misdn_bchannel::rate, misdn_party_redirecting::reason, misdn_bchannel::redirecting, misdn_party_id::screening, misdn_bchannel::sending_complete, misdn_bchannel::set_presentation, misdn_bchannel::stack_holder, misdn_party_redirecting::to, misdn_bchannel::urate, and misdn_bchannel::user1.

Referenced by cb_events(), and misdn_lib_send_event().

{
   struct misdn_stack *stack;

   if (!bc) return;

   stack = get_stack_by_bc(bc);

   if (!stack) return;

   cb_log(2, stack->port,
      " --> channel:%d mode:%s cause:%d ocause:%d\n",
      bc->channel,
      stack->nt ? "NT" : "TE",
      bc->cause,
      bc->out_cause);

   cb_log(2, stack->port,
      " --> info_dad:%s dialed numtype:%d plan:%d\n",
      bc->info_dad,
      bc->dialed.number_type,
      bc->dialed.number_plan);

   cb_log(2, stack->port,
      " --> caller:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
      bc->caller.name,
      bc->caller.number,
      bc->caller.number_type,
      bc->caller.number_plan,
      bc->caller.presentation,
      bc->caller.screening);

   cb_log(2, stack->port,
      " --> redirecting-from:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
      bc->redirecting.from.name,
      bc->redirecting.from.number,
      bc->redirecting.from.number_type,
      bc->redirecting.from.number_plan,
      bc->redirecting.from.presentation,
      bc->redirecting.from.screening);
   cb_log(2, stack->port,
      " --> redirecting-to:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
      bc->redirecting.to.name,
      bc->redirecting.to.number,
      bc->redirecting.to.number_type,
      bc->redirecting.to.number_plan,
      bc->redirecting.to.presentation,
      bc->redirecting.to.screening);
   cb_log(2, stack->port,
      " --> redirecting reason:%d count:%d\n",
      bc->redirecting.reason,
      bc->redirecting.count);

   cb_log(2, stack->port,
      " --> connected:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
      bc->connected.name,
      bc->connected.number,
      bc->connected.number_type,
      bc->connected.number_plan,
      bc->connected.presentation,
      bc->connected.screening);

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

   cb_log(4, stack->port, " --> set_pres:%d pres:%d\n", bc->set_presentation, bc->presentation);

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

   cb_log(4, stack->port, " --> facility in:%s out:%s\n", fac2str(bc->fac_in.Function), fac2str(bc->fac_out.Function));

   cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);

   cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
}
int misdn_lib_maxports_get ( void  )

Definition at line 4291 of file isdn_lib.c.

Referenced by load_module().

{
   /* BE AWARE WE HAVE NO cb_log() HERE! */

   int i = mISDN_open();
   int max=0;

   if (i<0)
      return -1;

   max = mISDN_get_stack_count(i);

   mISDN_close(i);

   return max;
}
void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4321 of file isdn_lib.c.

References f.

Referenced by load_module(), and misdn_lib_init().

{
   static int init=0;
   char *f;

   if (!flags)
      f=NULL;
   else
      f=file;

   if (!init) {
      debug_init( flags , f, f, f);
      init=1;
   } else {
      debug_close();
      debug_init( flags , f, f, f);
   }
}
void misdn_lib_nt_keepcalls ( int  kc)

Definition at line 4309 of file isdn_lib.c.

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

Referenced by load_module().

{
#ifdef FEATURE_NET_KEEPCALLS
   if (kc) {
      struct misdn_stack *stack=get_misdn_stack();
      for ( ; stack; stack=stack->next) {
         stack->nst.feature |= FEATURE_NET_KEEPCALLS;
      }
   }
#endif
}
int misdn_lib_pid_restart ( int  pid)

Definition at line 4100 of file isdn_lib.c.

References manager_clean_bc(), and manager_find_bc_by_pid().

Referenced by handle_cli_misdn_restart_pid().

{
   struct misdn_bchannel *bc=manager_find_bc_by_pid(pid);

   if (bc) {
      manager_clean_bc(bc);
   }
   return 0;
}
int misdn_lib_port_block ( int  port)

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

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         stack->blocked=1;
         return 0;
      }
   }
   return -1;

}
int misdn_lib_port_is_nt ( int  port)

Definition at line 65 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(), misdn_update_connected_line(), and misdn_update_redirecting().

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         return stack->nt;
      }
   }

   return -1;
}
int misdn_lib_port_is_pri ( int  port)

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

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         return stack->pri;
      }
   }

   return -1;
}
int misdn_lib_port_restart ( int  port)

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

{
   struct misdn_stack *stack=find_stack_by_port(port);

   cb_log(0, port, "Restarting this port.\n");
   if (stack) {
      cb_log(0, port, "Stack:%p\n",stack);

      clear_l3(stack);
      {
         msg_t *msg=alloc_msg(MAX_MSG_SIZE);
         iframe_t *frm;

         if (!msg) {
            cb_log(0, port, "port_restart: alloc_msg failed\n");
            return -1;
         }

         frm=(iframe_t*)msg->data;
         /* we must activate if we are deactivated */
         /* activate bchannel */
         frm->prim = DL_RELEASE | REQUEST;
         frm->addr = stack->upper_id | FLG_MSG_DOWN;

         frm->dinfo = 0;
         frm->len = 0;
         msg_queue_tail(&glob_mgr->activatequeue, msg);
         sem_post(&glob_mgr->new_msg);
      }

      if (stack->nt)
         misdn_lib_reinit_nt_stack(stack->port);

   }

   return 0;
}
int misdn_lib_port_unblock ( int  port)

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

{
   struct misdn_stack *stack=get_misdn_stack();
   for ( ; stack; stack=stack->next) {
      if (stack->port == port) {
         stack->blocked=0;
         return 0;
      }
   }
   return -1;

}
int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

{
   struct misdn_stack *stack;


   for (stack=glob_mgr->stack_list;
        stack;
        stack=stack->next) {

      if (stack->port == port) {

         if (stack->blocked) {
            cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
            return -1;
         }

         if (stack->ptp ) {

            if (stack->l1link && stack->l2link) {
               return 1;
            } else {
               cb_log(1,port, "Port Down L2:%d L1:%d\n",
                  stack->l2link, stack->l1link);
               return 0;
            }
         } else {
            if ( !check || stack->l1link )
               return 1;
            else {
               cb_log(1,port, "Port down PMP\n");
               return 0;
            }
         }
      }
   }

   return -1;
}
void misdn_lib_reinit_nt_stack ( int  port)

Definition at line 4952 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::port, misdn_stack::pri, misdn_stack::ptp, and misdn_stack::upper_id.

Referenced by handle_event_nt(), and misdn_lib_port_restart().

{
   struct misdn_stack *stack=find_stack_by_port(port);

   if (stack) {
      stack->l2link=0;
      stack->blocked=0;

      cleanup_Isdnl3(&stack->nst);
      cleanup_Isdnl2(&stack->nst);


      memset(&stack->nst, 0, sizeof(net_stack_t));
      memset(&stack->mgr, 0, sizeof(manager_t));

      stack->mgr.nst = &stack->nst;
      stack->nst.manager = &stack->mgr;

      stack->nst.l3_manager = handle_event_nt;
      stack->nst.device = glob_mgr->midev;
      stack->nst.cardnr = port;
      stack->nst.d_stid = stack->d_stid;

      stack->nst.feature = FEATURE_NET_HOLD;
      if (stack->ptp)
         stack->nst.feature |= FEATURE_NET_PTP;
      if (stack->pri)
         stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;

      stack->nst.l1_id = stack->lower_id;
      stack->nst.l2_id = stack->upper_id;

      msg_queue_init(&stack->nst.down_queue);

      Isdnl2Init(&stack->nst);
      Isdnl3Init(&stack->nst);

      if (!stack->ptp)
         misdn_lib_get_l1_up(stack);
      misdn_lib_get_l2_up(stack);
   }
}
void misdn_lib_release ( struct misdn_bchannel bc)

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

{
   int channel;
   struct misdn_stack *stack=get_stack_by_bc(bc);

   if (!stack) {
      cb_log(1,0,"misdn_release: No Stack found\n");
      return;
   }

   channel = bc->channel;
   empty_bc(bc);
   clean_up_bc(bc);
   if (channel > 0) {
      empty_chan_in_stack(stack, channel);
   }
   bc->in_use=0;
}
int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Queue Event

Definition at line 3630 of file isdn_lib.c.

References misdn_stack::bc, misdn_bchannel::bc_state, bc_state2str(), bc_state_change(), BCHAN_BRIDGED, BCHAN_CLEANED, misdn_bchannel::caller, 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::dialed, 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_REGISTER, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, misdn_bchannel::evq, find_bc_by_confid(), find_free_chan_in_stack(), get_stack_by_bc(), misdn_bchannel::holded, misdn_bchannel::in_use, isdn_get_info(), isdn_msg_build_event(), misdn_stack::l1link, malloc, manager_ec_enable(), manager_ph_control(), manager_ph_control_block(), misdn_lib::midev, misdn_cap_is_speech(), misdn_lib_get_l1_up(), misdn_lib_log_ies(), misdn_send_lock(), misdn_send_unlock(), misdn_split_conf(), msgs_g, misdn_party_id::name, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, misdn_lib::new_msg, misdn_bchannel::nodsp, misdn_stack::nt, misdn_bchannel::nt, misdn_party_dialing::number, misdn_party_id::number, misdn_party_dialing::number_type, misdn_party_id::number_type, 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_facility_ie_handler(), misdn_hangup(), misdn_indication(), misdn_lib_send_restart(), misdn_overlap_dial_task(), misdn_send_text(), misdn_update_connected_line(), misdn_update_redirecting(), start_pbx(), and wait_for_digits().

{
   msg_t *msg;
   struct misdn_bchannel *bc2;
   struct misdn_bchannel *held_bc;
   struct misdn_stack *stack;
   int retval = 0;
   int channel;
   int tmpcause;
   int tmp_out_cause;

   if (!bc)
      RETURN(-1,OUT_POST_UNLOCK);

   stack = get_stack_by_bc(bc);
   if (!stack) {
      cb_log(0,bc->port,
         "SENDEVENT: no Stack for event:%s caller:\"%s\" <%s> dialed:%s \n",
         isdn_get_info(msgs_g, event, 0),
         bc->caller.name,
         bc->caller.number,
         bc->dialed.number);
      RETURN(-1,OUT);
   }

   misdn_send_lock(bc);


   cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->upperid:%x\n",stack->nt, stack->upper_id);

   if ( stack->nt && !stack->l1link) {
      /** Queue Event **/
      bc->evq=event;
      cb_log(1, stack->port, "Queueing Event %s because L1 is down (btw. Activating L1)\n", isdn_get_info(msgs_g, event, 0));
      misdn_lib_get_l1_up(stack);
      RETURN(0,OUT);
   }

   cb_log(1, stack->port,
      "I SEND:%s caller:\"%s\" <%s> dialed:%s pid:%d\n",
      isdn_get_info(msgs_g, event, 0),
      bc->caller.name,
      bc->caller.number,
      bc->dialed.number,
      bc->pid);
   cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
   misdn_lib_log_ies(bc);

   switch (event) {
   case EVENT_REGISTER:
   case EVENT_SETUP:
      if (create_process(glob_mgr->midev, bc) < 0) {
         cb_log(0, stack->port, " No free channel at the moment @ send_event\n");

         RETURN(-ENOCHAN,OUT);
      }
      break;

   case EVENT_PROGRESS:
   case EVENT_ALERTING:
   case EVENT_PROCEEDING:
   case EVENT_SETUP_ACKNOWLEDGE:
   case EVENT_CONNECT:
      if (!stack->nt)
         break;

   case EVENT_RETRIEVE_ACKNOWLEDGE:
      if (stack->nt) {
         if (bc->channel <=0 ) { /*  else we have the channel already */
            if (find_free_chan_in_stack(stack, bc, 0, 0)<0) {
               cb_log(0, stack->port, " No free channel at the moment\n");
               /*FIXME: add disconnect*/
               RETURN(-ENOCHAN,OUT);
            }
         }
         /* Its that i generate channels */
      }

      retval=setup_bc(bc);
      if (retval == -EINVAL) {
         cb_log(0,bc->port,"send_event: setup_bc failed\n");
      }

      if (misdn_cap_is_speech(bc->capability)) {
         if ((event==EVENT_CONNECT)||(event==EVENT_RETRIEVE_ACKNOWLEDGE)) {
            if ( *bc->crypt_key ) {
               cb_log(4, stack->port,
                  " --> ENABLING BLOWFISH channel:%d caller%d:\"%s\" <%s> dialed%d:%s\n",
                  bc->channel,
                  bc->caller.number_type,
                  bc->caller.name,
                  bc->caller.number,
                  bc->dialed.number_type,
                  bc->dialed.number);

               manager_ph_control_block(bc,  BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
            }

            if (!bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
            manager_ec_enable(bc);

            if (bc->txgain != 0) {
               cb_log(4, stack->port,  "--> Changing txgain to %d\n", bc->txgain);
               manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
            }

            if ( bc->rxgain != 0 ) {
               cb_log(4, stack->port,  "--> Changing rxgain to %d\n", bc->rxgain);
               manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
            }
         }
      }
      break;

   case EVENT_HOLD_ACKNOWLEDGE:
      held_bc = malloc(sizeof(struct misdn_bchannel));
      if (!held_bc) {
         cb_log(0, bc->port, "Could not allocate held_bc!!!\n");
         RETURN(-1,OUT);
      }

      /* backup the bc and put it in storage */
      *held_bc = *bc;
      held_bc->holded = 1;
      held_bc->channel = 0;/* A held call does not have a channel anymore. */
      held_bc->channel_preselected = 0;
      held_bc->channel_found = 0;
      bc_state_change(held_bc, BCHAN_CLEANED);
      stack_holder_add(stack, held_bc);

      /* kill the bridge and clean the real b-channel record */
      if (stack->nt) {
         if (bc->bc_state == BCHAN_BRIDGED) {
            misdn_split_conf(bc,bc->conf_id);
            bc2 = find_bc_by_confid(bc->conf_id);
            if (!bc2) {
               cb_log(0,bc->port,"We have no second bc in bridge???\n");
            } else {
               misdn_split_conf(bc2,bc->conf_id);
            }
         }

         channel = bc->channel;

         empty_bc(bc);
         clean_up_bc(bc);

         if (channel>0)
            empty_chan_in_stack(stack,channel);

         bc->in_use=0;
      }
      break;

   /* finishing the channel eh ? */
   case EVENT_DISCONNECT:
      if (!bc->need_disconnect) {
         cb_log(0, bc->port, " --> we have already sent DISCONNECT\n");
         RETURN(-1,OUT);
      }

      bc->need_disconnect=0;
      break;
   case EVENT_RELEASE:
      if (!bc->need_release) {
         cb_log(0, bc->port, " --> we have already sent RELEASE\n");
         RETURN(-1,OUT);
      }
      bc->need_disconnect=0;
      bc->need_release=0;
      break;
   case EVENT_RELEASE_COMPLETE:
      if (!bc->need_release_complete) {
         cb_log(0, bc->port, " --> we have already sent RELEASE_COMPLETE\n");
         RETURN(-1,OUT);
      }
      bc->need_disconnect=0;
      bc->need_release=0;
      bc->need_release_complete=0;

      if (!stack->nt) {
         /* create cleanup in TE */
         channel = bc->channel;
         tmpcause = bc->cause;
         tmp_out_cause = bc->out_cause;

         empty_bc(bc);
         bc->cause=tmpcause;
         bc->out_cause=tmp_out_cause;
         clean_up_bc(bc);

         if (channel>0)
            empty_chan_in_stack(stack,channel);

         bc->in_use=0;
      }
      break;

   case EVENT_CONNECT_ACKNOWLEDGE:
      if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
         int retval=setup_bc(bc);
         if (retval == -EINVAL){
            cb_log(0,bc->port,"send_event: setup_bc failed\n");

         }
      }

      if (misdn_cap_is_speech(bc->capability)) {
         if (  !bc->nodsp) manager_ph_control(bc,  DTMF_TONE_START, 0);
         manager_ec_enable(bc);

         if ( bc->txgain != 0 ) {
            cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
            manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
         }
         if ( bc->rxgain != 0 ) {
            cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
            manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
         }
      }
      break;

   default:
      break;
   }

   /* Later we should think about sending bchannel data directly to misdn. */
   msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
   if (!msg) {
      /*
       * The message was not built.
       *
       * NOTE:  The only time that the message will fail to build
       * is because the requested FACILITY message is not supported.
       * A failed malloc() results in exit() being called.
       */
      RETURN(-1, OUT);
   } else {
      msg_queue_tail(&stack->downqueue, msg);
      sem_post(&glob_mgr->new_msg);
   }

OUT:
   misdn_send_unlock(bc);

OUT_POST_UNLOCK:
   return retval;
}
int misdn_lib_send_restart ( int  port,
int  channel 
)

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

{
   struct misdn_stack *stack=find_stack_by_port(port);
   struct misdn_bchannel dummybc;
   /*default is all channels*/
   cb_log(0, port, "Sending Restarts on this port.\n");

   misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);

   /*default is all channels*/
   if (channel <0) {
      dummybc.channel=-1;
      cb_log(0, port, "Restarting and all Interfaces\n");
      misdn_lib_send_event(&dummybc, EVENT_RESTART);

      return 0;
   }

   /*if a channel is specified we restart only this one*/
   if (channel >0) {
      int cnt;
      dummybc.channel=channel;
      cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
      misdn_lib_send_event(&dummybc, EVENT_RESTART);
      /* clean up chan in stack, to be sure we don't think it's
       * in use anymore */
      for (cnt=0; cnt<=stack->b_num; cnt++) {
         if (stack->bc[cnt].in_use && stack->bc[cnt].channel == channel) {
            empty_bc(&stack->bc[cnt]);
            clean_up_bc(&stack->bc[cnt]);
            stack->bc[cnt].in_use=0;
         }
      }
   }

   return 0;
}
void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

Definition at line 4769 of file isdn_lib.c.

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

Referenced by hanguptone_indicate().

{
   char buf[mISDN_HEADER_LEN + 128] = "";
   iframe_t *frm = (iframe_t*)buf;

   switch(tone) {
   case TONE_DIAL:
      manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE);
   break;

   case TONE_ALERTING:
      manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);
   break;

   case TONE_HANGUP:
      manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);
   break;

   case TONE_NONE:
   default:
      manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);
   }

   frm->prim=DL_DATA|REQUEST;
   frm->addr=bc->addr|FLG_MSG_DOWN;
   frm->dinfo=0;
   frm->len=128;

   mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
}
void misdn_lib_setup_bc ( struct misdn_bchannel bc)

Definition at line 1066 of file isdn_lib.c.

References clean_up_bc(), and setup_bc().

{
   clean_up_bc(bc);
   setup_bc(bc);
}
void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4924 of file isdn_lib.c.

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

Referenced by misdn_bridge().

{

   struct misdn_bchannel *bc_list[]={
      bc1,bc2,NULL
   };
   struct misdn_bchannel **bc;

   for (bc=bc_list; *bc;  bc++) {
      if ( (*bc)->bc_state == BCHAN_BRIDGED){
         misdn_split_conf( *bc, (*bc)->conf_id);
      } else {
         cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
      }
   }

}
void misdn_lib_tone_generator_start ( struct misdn_bchannel bc)

Definition at line 2341 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

{
   bc->generate_tone=1;
}
void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc)

Definition at line 2346 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

{
   bc->generate_tone=0;
}
int misdn_lib_tx2misdn_frm ( struct misdn_bchannel bc,
void *  data,
int  len 
)

Definition at line 4552 of file isdn_lib.c.

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

Referenced by misdn_join_conf(), and misdn_write().

{
   struct misdn_stack *stack=get_stack_by_bc(bc);
   char buf[4096 + mISDN_HEADER_LEN];
   iframe_t *frm = (iframe_t*)buf;
   int r;

   switch (bc->bc_state) {
      case BCHAN_ACTIVATED:
      case BCHAN_BRIDGED:
         break;
      default:
         cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
         return -1;
   }

   frm->prim = DL_DATA|REQUEST;
   frm->dinfo = 0;
   frm->addr = bc->addr | FLG_MSG_DOWN ;

   frm->len = len;
   memcpy(&buf[mISDN_HEADER_LEN], data,len);

   if ( misdn_cap_is_speech(bc->capability) )
      flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
   else
      cb_log(6, stack->port, "Writing %d data bytes\n",len);

   cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
   r=mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
   return 0;
}
void misdn_make_dummy ( struct misdn_bchannel dummybc,
int  port,
int  l3id,
int  nt,
int  channel 
)

Definition at line 77 of file isdn_lib.c.

References misdn_bchannel::channel, misdn_bchannel::dummy, misdn_bchannel::l3_id, misdn_stack::nt, misdn_bchannel::nt, misdn_stack::port, 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().

{
   memset (dummybc,0,sizeof(struct misdn_bchannel));
   dummybc->port=port;
   if (l3id==0)
      dummybc->l3_id = MISDN_ID_DUMMY;
   else
      dummybc->l3_id=l3id;

   dummybc->nt=nt;
   dummybc->dummy=1;
   dummybc->channel=channel;
}

Variable Documentation

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

Definition at line 33 of file isdn_lib.c.

Referenced by misdn_lib_init(), and misdn_tx_jitter().

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

Definition at line 30 of file isdn_lib.c.

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(), dec_ie_facility(), 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().