Asterisk - The Open Source Telephony Project  GIT-master-e8cda4b
Data Structures | Macros | Enumerations | Functions | Variables
isdn_lib.h File Reference

Interface to mISDN. More...

#include <mISDNuser/suppserv.h>

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

Macros

#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_ACTIVATED, BCHAN_BRIDGED,
  BCHAN_RELEASE, 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. More...
 
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_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.nosp@m.@ber.nosp@m.onet..nosp@m.com

Definition in file isdn_lib.h.

Macro Definition Documentation

◆ MAX_BCHANS

#define MAX_BCHANS   31

◆ MISDN_MAX_KEYPAD_LEN

#define MISDN_MAX_KEYPAD_LEN   (31 + 1)

Maximum keypad facility content length plus null terminator

Definition at line 255 of file isdn_lib.h.

◆ MISDN_MAX_NAME_LEN

#define MISDN_MAX_NAME_LEN   (50 + 1)

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

Definition at line 249 of file isdn_lib.h.

◆ MISDN_MAX_NUMBER_LEN

#define MISDN_MAX_NUMBER_LEN   (31 + 1)

Maximum phone number (address) length plus null terminator

Definition at line 246 of file isdn_lib.h.

Referenced by misdn_add_number_prefix().

◆ MISDN_MAX_SUBADDRESS_LEN

#define MISDN_MAX_SUBADDRESS_LEN   (23 + 1)

Maximum subaddress length plus null terminator

Definition at line 252 of file isdn_lib.h.

◆ PRI_TRANS_CAP_3_1K_AUDIO

#define PRI_TRANS_CAP_3_1K_AUDIO   0x10

Definition at line 820 of file isdn_lib.h.

◆ PRI_TRANS_CAP_7K_AUDIO

#define PRI_TRANS_CAP_7K_AUDIO   0x11

Definition at line 821 of file isdn_lib.h.

◆ PRI_TRANS_CAP_DIGITAL

#define PRI_TRANS_CAP_DIGITAL   0x08

Definition at line 818 of file isdn_lib.h.

◆ PRI_TRANS_CAP_RESTRICTED_DIGITAL

#define PRI_TRANS_CAP_RESTRICTED_DIGITAL   0x09

Definition at line 819 of file isdn_lib.h.

◆ PRI_TRANS_CAP_SPEECH

#define PRI_TRANS_CAP_SPEECH   0x0

Definition at line 817 of file isdn_lib.h.

Enumeration Type Documentation

◆ anonymous enum

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

◆ anonymous enum

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

◆ anonymous enum

anonymous enum
Enumerator
INFO_CODEC_ULAW 
INFO_CODEC_ALAW 

Definition at line 232 of file isdn_lib.h.

232  { /*CODECS*/
233  INFO_CODEC_ULAW=2,
235 };

◆ bchannel_state

Enumerator
BCHAN_CLEANED 
BCHAN_EMPTY 
BCHAN_ACTIVATED 
BCHAN_BRIDGED 
BCHAN_RELEASE 
BCHAN_ERROR 

Definition at line 78 of file isdn_lib.h.

◆ event_e

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

119  {
128  EVENT_SETUP,
137  EVENT_HOLD,
139  EVENT_RESUME,
152  EVENT_NOTIFY,
155  EVENT_STATUS,
159  EVENT_NEW_BC,
163 };

◆ event_response_e

Enumerator
RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE 
RESPONSE_IGNORE_SETUP 
RESPONSE_RELEASE_SETUP 
RESPONSE_ERR 
RESPONSE_OK 

Definition at line 110 of file isdn_lib.h.

◆ ie_name_e

enum ie_name_e
Enumerator
IE_DUMMY 
IE_LAST 

Definition at line 166 of file isdn_lib.h.

166  {
167  IE_DUMMY,
168  IE_LAST
169 };

◆ layer_e

enum layer_e
Enumerator
L3 
L2 
L1 
UNKNOWN 

Definition at line 238 of file isdn_lib.h.

238  {
239  L3,
240  L2,
241  L1,
242  UNKNOWN
243 };
Definition: isdn_lib.h:241
Definition: isdn_lib.h:240
Definition: isdn_lib.h:239

◆ misdn_err_e

Enumerator
ENOCHAN 

Definition at line 88 of file isdn_lib.h.

88  {
89  ENOCHAN=1
90 };

◆ mISDN_NOTIFY_CODE

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

216  {
218  /*! Call is placed on hold (Q.931) */
220  /*! Call is taken off of hold (Q.931) */
222  /*! Call is diverting (EN 300 207-1 Section 7.2.1) */
224  /*! Call diversion is enabled (cfu, cfb, cfnr) (EN 300 207-1 Section 7.2.1) */
226  /*! Call transfer, alerting (EN 300 369-1 Section 7.2) */
228  /*! Call transfer, active(answered) (EN 300 369-1 Section 7.2) */
230 };

◆ mISDN_NUMBER_PLAN

Enumerator
NUMPLAN_UNKNOWN 
NUMPLAN_ISDN 
NUMPLAN_DATA 
NUMPLAN_TELEX 
NUMPLAN_NATIONAL 
NUMPLAN_PRIVATE 

Definition at line 92 of file isdn_lib.h.

92  {
93  NUMPLAN_UNKNOWN = 0x0,
94  NUMPLAN_ISDN = 0x1, /* ISDN/Telephony numbering plan E.164 */
95  NUMPLAN_DATA = 0x3, /* Data numbering plan X.121 */
96  NUMPLAN_TELEX = 0x4, /* Telex numbering plan F.69 */
97  NUMPLAN_NATIONAL = 0x8,
98  NUMPLAN_PRIVATE = 0x9
99 };

◆ mISDN_NUMBER_TYPE

Enumerator
NUMTYPE_UNKNOWN 
NUMTYPE_INTERNATIONAL 
NUMTYPE_NATIONAL 
NUMTYPE_NETWORK_SPECIFIC 
NUMTYPE_SUBSCRIBER 
NUMTYPE_ABBREVIATED 

Definition at line 101 of file isdn_lib.h.

◆ mISDN_REDIRECTING_REASON

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

197  {
199  /*! Call forwarding busy or called DTE busy */
201  /*! Call forwarding no reply */
203  /*! Call deflection */
205  /*! Called DTE out of order */
207  /*! Call forwarding by the called DTE */
209  /*! Call forwarding unconditional or systematic call redirection */
211 };

◆ tone_e

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

◆ bc_state2str()

char* bc_state2str ( enum bchannel_state  state)

Definition at line 617 of file isdn_lib.c.

References BCHAN_ACTIVATED, BCHAN_BRIDGED, BCHAN_CLEANED, BCHAN_EMPTY, BCHAN_ERROR, and BCHAN_RELEASE.

Referenced by bc_next_state_change(), bc_state_change(), cb_events(), misdn_lib_send_event(), misdn_lib_split_bridge(), misdn_lib_tx2misdn_frm(), print_bc_info(), and setup_bc().

617  {
618  int i;
619 
620  struct bchan_state_s {
621  char *n;
622  enum bchannel_state s;
623  } states[] = {
624  {"BCHAN_CLEANED", BCHAN_CLEANED },
625  {"BCHAN_EMPTY", BCHAN_EMPTY},
626  {"BCHAN_ACTIVATED", BCHAN_ACTIVATED},
627  {"BCHAN_BRIDGED", BCHAN_BRIDGED},
628  {"BCHAN_RELEASE", BCHAN_RELEASE},
629  {"BCHAN_ERROR", BCHAN_ERROR}
630  };
631 
632  for (i=0; i< sizeof(states)/sizeof(struct bchan_state_s); i++)
633  if ( states[i].s == state)
634  return states[i].n;
635 
636  return "UNKNOWN";
637 }
bchannel_state
Definition: isdn_lib.h:78

◆ bc_state_change()

void bc_state_change ( struct misdn_bchannel bc,
enum bchannel_state  state 
)

Definition at line 639 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, misdn_bchannel::port, and state.

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

640 {
641  cb_log(5,bc->port,"BC_STATE_CHANGE: l3id:%x from:%s to:%s\n",
642  bc->l3_id,
643  bc_state2str(bc->bc_state),
644  bc_state2str(state) );
645 
646  switch (state) {
647  case BCHAN_ACTIVATED:
648  if (bc->next_bc_state == BCHAN_BRIDGED) {
649  misdn_join_conf(bc, bc->conf_id);
651  return;
652  }
653  default:
654  bc->bc_state=state;
655  break;
656  }
657 }
enum sip_cc_notify_state state
Definition: chan_sip.c:960
int conf_id
Bridging conference ID.
Definition: isdn_lib.h:553
char * bc_state2str(enum bchannel_state state)
Definition: isdn_lib.c:617
enum bchannel_state next_bc_state
This is used as a pending bridge join request for when bc_state becomes BCHAN_ACTIVATED.
Definition: isdn_lib.h:550
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
void misdn_join_conf(struct misdn_bchannel *bc, int conf_id)
Definition: isdn_lib.c:4705
enum bchannel_state bc_state
Current B Channel state.
Definition: isdn_lib.h:547
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
int l3_id
Layer 3 process ID.
Definition: isdn_lib.h:399

◆ get_show_stack_details()

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

169 {
170  struct misdn_stack *stack = get_misdn_stack();
171 
172  for (; stack; stack = stack->next) {
173  if (stack->port == port) {
174  break;
175  }
176  }
177 
178  if (stack) {
179  sprintf(buf, "* Port %2d Type %s Prot. %s L2Link %s L1Link:%s Blocked:%d",
180  stack->port,
181  stack->nt ? "NT" : "TE",
182  stack->ptp ? "PTP" : "PMP",
183  (stack->nt && !stack->ptp) ? "UNKN" : stack->l2link ? "UP " : "DOWN",
184  stack->l1link ? "UP " : "DOWN",
185  stack->blocked);
186  } else {
187  buf[0] = 0;
188  }
189 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int l1link
TRUE if Layer 1 is UP.
int l2link
TRUE if Layer 2 is UP.
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
int nt
TRUE if NT side of protocol (TE otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.

◆ isdn_lib_stop_dtmf()

void isdn_lib_stop_dtmf ( struct misdn_bchannel bc)

Definition at line 4462 of file isdn_lib.c.

References manager_ph_control().

Referenced by process_ast_dsp().

4463 {
4464  manager_ph_control(bc, DTMF_TONE_STOP, 0);
4465 }
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419

◆ isdn_lib_update_ec()

void isdn_lib_update_ec ( struct misdn_bchannel bc)

Definition at line 4450 of file isdn_lib.c.

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

Referenced by process_ast_dsp().

4451 {
4452 #ifdef MISDN_1_2
4453  if (*bc->pipeline)
4454 #else
4455  if (bc->ec_enable)
4456 #endif
4457  manager_ec_enable(bc);
4458  else
4459  manager_ec_disable(bc);
4460 }
int ec_enable
TRUE if the echo cancellor is enabled.
Definition: isdn_lib.h:688
void manager_ec_enable(struct misdn_bchannel *bc)
Definition: isdn_lib.c:4628
void manager_ec_disable(struct misdn_bchannel *bc)
Definition: isdn_lib.c:4677

◆ isdn_lib_update_rxgain()

void isdn_lib_update_rxgain ( struct misdn_bchannel bc)

Definition at line 4440 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::rxgain.

Referenced by process_ast_dsp().

4441 {
4442  manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
4443 }
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419
int rxgain
Rx gain setting (range -8 to 8)
Definition: isdn_lib.h:714

◆ isdn_lib_update_txgain()

void isdn_lib_update_txgain ( struct misdn_bchannel bc)

Definition at line 4445 of file isdn_lib.c.

References manager_ph_control(), and misdn_bchannel::txgain.

Referenced by process_ast_dsp().

4446 {
4447  manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
4448 }
int txgain
Tx gain setting (range -8 to 8)
Definition: isdn_lib.h:708
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419

◆ manager_bchannel_activate()

void manager_bchannel_activate ( struct misdn_bchannel bc)

Definition at line 4329 of file isdn_lib.c.

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

Referenced by setup_bc().

4330 {
4331  char buf[128];
4332 
4333  struct misdn_stack *stack=get_stack_by_bc(bc);
4334 
4335  if (!stack) {
4336  cb_log(0, bc->port, "bchannel_activate: Stack not found !");
4337  return ;
4338  }
4339 
4340  /* we must activate if we are deactivated */
4341  clear_ibuffer(bc->astbuf);
4342 
4343  cb_log(5, stack->port, "$$$ Bchan Activated addr %x\n", bc->addr);
4344 
4345  mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_ESTABLISH | REQUEST, 0,0, NULL, TIMEOUT_1SEC);
4346 
4347  return ;
4348 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int midev
mISDN device handle returned by mISDN_open()
void * astbuf
Not used. Contents are setup but not used.
Definition: isdn_lib.h:439
#define NULL
Definition: resample.c:96
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ manager_bchannel_deactivate()

void manager_bchannel_deactivate ( struct misdn_bchannel bc)

Definition at line 4351 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(), NULL, misdn_stack::port, and misdn_bchannel::port.

Referenced by clean_up_bc().

4352 {
4353  struct misdn_stack *stack=get_stack_by_bc(bc);
4354  char buf[128];
4355 
4356  switch (bc->bc_state) {
4357  case BCHAN_ACTIVATED:
4358  break;
4359  case BCHAN_BRIDGED:
4360  misdn_split_conf(bc,bc->conf_id);
4361  break;
4362  default:
4363  cb_log( 4, bc->port,"bchan_deactivate: called but not activated\n");
4364  return ;
4365 
4366  }
4367 
4368  cb_log(5, stack->port, "$$$ Bchan deActivated addr %x\n", bc->addr);
4369 
4370  bc->generate_tone=0;
4371 
4372  mISDN_write_frame(stack->midev, buf, bc->addr | FLG_MSG_DOWN, DL_RELEASE|REQUEST,0,0,NULL, TIMEOUT_1SEC);
4373 
4374  clear_ibuffer(bc->astbuf);
4375 
4377 
4378  return;
4379 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int midev
mISDN device handle returned by mISDN_open()
void * astbuf
Not used. Contents are setup but not used.
Definition: isdn_lib.h:439
#define NULL
Definition: resample.c:96
int conf_id
Bridging conference ID.
Definition: isdn_lib.h:553
void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
Definition: isdn_lib.c:639
void misdn_split_conf(struct misdn_bchannel *bc, int conf_id)
Definition: isdn_lib.c:4719
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
enum bchannel_state bc_state
Current B Channel state.
Definition: isdn_lib.h:547
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
int generate_tone
TRUE if tone generator allowed to start.
Definition: isdn_lib.h:541

◆ manager_ec_disable()

void manager_ec_disable ( struct misdn_bchannel bc)

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

4678 {
4679  struct misdn_stack *stack=get_stack_by_bc(bc);
4680 
4681  cb_log(4, stack?stack->port:0," --> ec_disable\n");
4682 
4683  if (!misdn_cap_is_speech(bc->capability)) {
4684  cb_log(1, stack?stack->port:0, " --> no speech? cannot disable EC\n");
4685  return;
4686  }
4687 
4688 #ifdef MISDN_1_2
4689  manager_ph_control_block(bc, PIPELINE_CFG, "", 0);
4690 #else
4691  if ( ! bc->ec_enable) {
4692  cb_log(3, stack?stack->port:0, "Sending Control ECHOCAN_OFF\n");
4694  }
4695 #endif
4696 }
#define ECHOCAN_OFF
Definition: isdn_lib.c:230
int ec_enable
TRUE if the echo cancellor is enabled.
Definition: isdn_lib.h:688
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
int misdn_cap_is_speech(int cap)
Definition: isdn_lib.c:436
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c2_len)
Definition: isdn_lib.c:4470
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ manager_ec_enable()

void manager_ec_enable ( struct misdn_bchannel bc)

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

4629 {
4630  struct misdn_stack *stack=get_stack_by_bc(bc);
4631 
4632  cb_log(4, stack?stack->port:0,"ec_enable\n");
4633 
4634  if (!misdn_cap_is_speech(bc->capability)) {
4635  cb_log(1, stack?stack->port:0, " --> no speech? cannot enable EC\n");
4636  } else {
4637 
4638 #ifdef MISDN_1_2
4639  if (*bc->pipeline) {
4640  cb_log(3, stack?stack->port:0,"Sending Control PIPELINE_CFG %s\n",bc->pipeline);
4641  manager_ph_control_block(bc, PIPELINE_CFG, bc->pipeline, strlen(bc->pipeline) + 1);
4642  }
4643 #else
4644  int ec_arr[2];
4645 
4646  if (bc->ec_enable) {
4647  cb_log(3, stack?stack->port:0,"Sending Control ECHOCAN_ON taps:%d\n",bc->ec_deftaps);
4648 
4649  switch (bc->ec_deftaps) {
4650  case 4:
4651  case 8:
4652  case 16:
4653  case 32:
4654  case 64:
4655  case 128:
4656  case 256:
4657  case 512:
4658  case 1024:
4659  cb_log(4, stack->port, "Taps is %d\n",bc->ec_deftaps);
4660  break;
4661  default:
4662  cb_log(0, stack->port, "Taps should be power of 2\n");
4663  bc->ec_deftaps=128;
4664  }
4665 
4666  ec_arr[0]=bc->ec_deftaps;
4667  ec_arr[1]=0;
4668 
4669  manager_ph_control_block(bc, ECHOCAN_ON, ec_arr, sizeof(ec_arr));
4670  }
4671 #endif
4672  }
4673 }
int ec_enable
TRUE if the echo cancellor is enabled.
Definition: isdn_lib.h:688
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
int misdn_cap_is_speech(int cap)
Definition: isdn_lib.c:436
#define ECHOCAN_ON
Definition: isdn_lib.c:229
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c2_len)
Definition: isdn_lib.c:4470
int ec_deftaps
Number of taps in the echo cancellor when enabled.
Definition: isdn_lib.h:693
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ manager_isdn_get_info()

char* manager_isdn_get_info ( enum event_e  event)

Definition at line 4324 of file isdn_lib.c.

References isdn_get_info(), and msgs_g.

Referenced by cb_events().

4325 {
4326  return isdn_get_info(msgs_g , event, 0);
4327 }
char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
struct isdn_msg msgs_g[]
Definition: astman.c:222

◆ manager_ph_control()

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

Definition at line 4419 of file isdn_lib.c.

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

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

4420 {
4421  unsigned char buffer[mISDN_HEADER_LEN+2*sizeof(int)];
4422  iframe_t *ctrl = (iframe_t *)buffer; /* preload data */
4423  unsigned int *d = (unsigned int*)&ctrl->data.p;
4424  /*struct misdn_stack *stack=get_stack_by_bc(bc);*/
4425 
4426  cb_log(4,bc->port,"ph_control: c1:%x c2:%x\n",c1,c2);
4427 
4428  ctrl->prim = PH_CONTROL | REQUEST;
4429  ctrl->addr = bc->addr | FLG_MSG_DOWN;
4430  ctrl->dinfo = 0;
4431  ctrl->len = sizeof(unsigned int)*2;
4432  *d++ = c1;
4433  *d++ = c2;
4434  mISDN_write(glob_mgr->midev, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
4435 }
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
static struct test_val d
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_cap_is_speech()

int misdn_cap_is_speech ( int  cap)

◆ misdn_dump_chanlist()

void misdn_dump_chanlist ( void  )

Definition at line 483 of file isdn_lib.c.

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

Referenced by handle_cli_misdn_show_channels().

484 {
485  struct misdn_stack *stack=get_misdn_stack();
486  for ( ; stack; stack=stack->next) {
487  dump_chan_list(stack);
488  }
489 
490 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
struct misdn_stack * next
Next stack in the list of stacks.
static void dump_chan_list(struct misdn_stack *stack)
Definition: isdn_lib.c:464

◆ misdn_inband_avail()

int misdn_inband_avail ( struct misdn_bchannel bc)

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

445 {
446 
447  if (!bc->early_bconnect) {
448  /* We have opted to never receive any available inband recorded messages */
449  return 0;
450  }
451 
452  switch (bc->progress_indicator) {
456  return 1;
457  default:
458  return 0;
459  }
460  return 0;
461 }
int progress_indicator
Progress Indicator IE progress description field. Used to determine if there is an inband audio messa...
Definition: isdn_lib.h:492
int early_bconnect
TRUE if the call progress indicators can indicate an inband audio message for the user to listen to...
Definition: isdn_lib.h:449

◆ misdn_lib_bridge()

void misdn_lib_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4728 of file isdn_lib.c.

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

Referenced by misdn_write().

4729 {
4730  int conf_id = bc1->pid + 1;
4731  struct misdn_bchannel *bc_list[] = { bc1, bc2, NULL };
4732  struct misdn_bchannel **bc;
4733 
4734  cb_log(4, bc1->port, "I Send: BRIDGE from:%d to:%d\n",bc1->port,bc2->port);
4735 
4736  for (bc=bc_list; *bc; bc++) {
4737  (*bc)->conf_id=conf_id;
4738  cb_log(4, (*bc)->port, " --> bc_addr:%x\n",(*bc)->addr);
4739 
4740  switch((*bc)->bc_state) {
4741  case BCHAN_ACTIVATED:
4742  misdn_join_conf(*bc,conf_id);
4743  break;
4744  default:
4746  break;
4747  }
4748  }
4749 }
#define bc
B channel control structure.
Definition: isdn_lib.h:324
#define NULL
Definition: resample.c:96
static void bc_next_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
Definition: isdn_lib.c:659
int conf_id
Bridging conference ID.
Definition: isdn_lib.h:553
int pid
B channel process ID (1-5000)
Definition: isdn_lib.h:402
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
void misdn_join_conf(struct misdn_bchannel *bc, int conf_id)
Definition: isdn_lib.c:4705
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_destroy()

void misdn_lib_destroy ( void  )

Definition at line 4285 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, free(), misdn_stack::midev, misdn_lib::midev, MISDN_INITIALIZED, misdn_stack::next, NULL, misdn_stack::port, stack_destroy(), misdn_lib::stack_list, and te_lib_destroy().

Referenced by unload_module().

4286 {
4287  struct misdn_stack *help;
4288  int i;
4289 
4290  for ( help=glob_mgr->stack_list; help; help=help->next ) {
4291  for(i=0;i<=help->b_num; i++) {
4292  char buf[1024];
4293  mISDN_write_frame(help->midev, buf, help->bc[i].addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
4294  help->bc[i].addr = 0;
4295  }
4296  cb_log (1, help->port, "Destroying this port.\n");
4297  stack_destroy(help);
4298  }
4299 
4301  cb_log(4, 0, "Killing Handler Thread\n");
4302  if ( pthread_cancel(glob_mgr->event_handler_thread) == 0 ) {
4303  cb_log(4, 0, "Joining Handler Thread\n");
4304  pthread_join(glob_mgr->event_handler_thread, NULL);
4305  }
4306 
4307  cb_log(4, 0, "Killing Main Thread\n");
4308  if ( pthread_cancel(glob_mgr->event_thread) == 0 ) {
4309  cb_log(4, 0, "Joining Main Thread\n");
4310  pthread_join(glob_mgr->event_thread, NULL);
4311  }
4312  }
4313 
4314  cb_log(1, 0, "Closing mISDN device\n");
4316  while ((help = glob_mgr->stack_list)) {
4317  glob_mgr->stack_list = help->next;
4318  free(help);
4319  }
4320  free(glob_mgr);
4321  glob_mgr = NULL;
4322 }
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int midev
mISDN device handle returned by mISDN_open()
static enum global_states global_state
Definition: isdn_lib.c:199
#define NULL
Definition: resample.c:96
void free()
struct misdn_bchannel bc[MAX_BCHANS+1+MISDN_MAX_REGISTER_LINKS]
B Channel record pool array (Must be dimensioned the same as struct misdn_stack.channels[]) ...
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
struct misdn_stack * next
Next stack in the list of stacks.
void te_lib_destroy(int midev)
Definition: isdn_lib.c:3142
static void stack_destroy(struct misdn_stack *stack)
Definition: isdn_lib.c:1454
pthread_t event_handler_thread
Definition: isdn_lib.c:217
pthread_t event_thread
Definition: isdn_lib.c:216
int port
Logical Layer 1 port associated with this stack.
struct misdn_stack * stack_list
Definition: isdn_lib.c:225
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_echo()

void misdn_lib_echo ( struct misdn_bchannel bc,
int  onoff 
)

Definition at line 4771 of file isdn_lib.c.

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

4772 {
4773  cb_log(3,bc->port, " --> ECHO %s\n", onoff?"ON":"OFF");
4774  manager_ph_control(bc, onoff?CMX_ECHO_ON:CMX_ECHO_OFF, 0);
4775 }
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_find_held_bc()

struct misdn_bchannel* misdn_lib_find_held_bc ( int  port,
int  l3_id 
)

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

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

Referenced by misdn_hangup().

4581 {
4582  struct misdn_bchannel *bc;
4583  struct misdn_stack *stack;
4584 
4585  bc = NULL;
4586  for (stack = get_misdn_stack(); stack; stack = stack->next) {
4587  if (stack->port == port) {
4588  bc = stack_holder_find(stack, l3_id);
4589  break;
4590  }
4591  }
4592 
4593  return bc;
4594 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
#define bc
struct misdn_bchannel * stack_holder_find(struct misdn_stack *stack, unsigned long l3id)
Definition: isdn_lib.c:4553
B channel control structure.
Definition: isdn_lib.h:324
#define NULL
Definition: resample.c:96
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_get_free_bc()

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

Definition at line 3205 of file isdn_lib.c.

References ARRAY_LEN, misdn_stack::b_num, bc, misdn_stack::bc, misdn_stack::blocked, cb_log, misdn_bchannel::channel, misdn_bchannel::cw, misdn_bchannel::dec, find_stack_by_port(), if(), MAX_BCHANS, misdn_bchannel::need_disconnect, misdn_bchannel::need_release, NULL, misdn_bchannel::port, 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().

3206 {
3207  struct misdn_stack *stack;
3208  int i;
3209  int maxnum;
3210 
3212  cb_log(0, port, "Requested channel out of bounds (%d)\n", channel);
3213  return NULL;
3214  }
3215 
3216  /* Find the port stack structure */
3217  stack = find_stack_by_port(port);
3218  if (!stack) {
3219  cb_log(0, port, "Port is not configured (%d)\n", port);
3220  return NULL;
3221  }
3222 
3223  if (stack->blocked) {
3224  cb_log(0, port, "Port is blocked\n");
3225  return NULL;
3226  }
3227 
3228  pthread_mutex_lock(&stack->st_lock);
3229  if (channel > 0) {
3231  for (i = 0; i < stack->b_num; i++) {
3232  if (stack->bc[i].channel == channel) {
3233  if (test_inuse(&stack->bc[i])) {
3234  pthread_mutex_unlock(&stack->st_lock);
3235  cb_log(0, port, "Requested channel:%d on port:%d is already in use\n", channel, port);
3236  return NULL;
3237  } else {
3238  prepare_bc(&stack->bc[i], channel);
3239  pthread_mutex_unlock(&stack->st_lock);
3240  return &stack->bc[i];
3241  }
3242  }
3243  }
3244  } else {
3245  pthread_mutex_unlock(&stack->st_lock);
3246  cb_log(0, port, "Requested channel:%d is out of bounds on port:%d\n", channel, port);
3247  return NULL;
3248  }
3249  }
3250 
3251  /* Note: channel == 0 here */
3252  maxnum = (inout && !stack->pri && !stack->ptp) ? stack->b_num + 1 : stack->b_num;
3253  if (dec) {
3254  for (i = maxnum - 1; i >= 0; --i) {
3255  if (!test_inuse(&stack->bc[i])) {
3256  /* 3. channel on bri means CW*/
3257  if (!stack->pri && i == stack->b_num) {
3258  stack->bc[i].cw = 1;
3259  }
3260 
3261  prepare_bc(&stack->bc[i], channel);
3262  stack->bc[i].dec = 1;
3263  pthread_mutex_unlock(&stack->st_lock);
3264  return &stack->bc[i];
3265  }
3266  }
3267  } else {
3268  for (i = 0; i < maxnum; ++i) {
3269  if (!test_inuse(&stack->bc[i])) {
3270  /* 3. channel on bri means CW */
3271  if (!stack->pri && i == stack->b_num) {
3272  stack->bc[i].cw = 1;
3273  }
3274 
3275  prepare_bc(&stack->bc[i], channel);
3276  pthread_mutex_unlock(&stack->st_lock);
3277  return &stack->bc[i];
3278  }
3279  }
3280  }
3281  pthread_mutex_unlock(&stack->st_lock);
3282 
3283  cb_log(1, port, "There is no free channel on port (%d)\n", port);
3284  return NULL;
3285 }
int cw
TRUE if call waiting.
Definition: isdn_lib.h:426
if(!yyg->yy_init)
Definition: ast_expr2f.c:868
Definition: muted.c:95
#define NULL
Definition: resample.c:96
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
struct misdn_bchannel bc[MAX_BCHANS+1+MISDN_MAX_REGISTER_LINKS]
B Channel record pool array (Must be dimensioned the same as struct misdn_stack.channels[]) ...
#define pthread_mutex_lock
Definition: lock.h:623
static void prepare_bc(struct misdn_bchannel *bc, int channel)
Definition: isdn_lib.c:3190
int dec
TRUE if allocate higher B channels first.
Definition: isdn_lib.h:395
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
static struct misdn_stack * find_stack_by_port(int port)
Definition: isdn_lib.c:1487
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
int blocked
TRUE if port is blocked.
#define pthread_mutex_unlock
Definition: lock.h:624
static int test_inuse(struct misdn_bchannel *bc)
Definition: isdn_lib.c:3168
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
#define MAX_BCHANS
Definition: isdn_lib.h:76
pthread_mutex_t st_lock
Stack struct critical section lock.

◆ misdn_lib_get_maxchans()

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

138 {
139  struct misdn_stack *stack=get_misdn_stack();
140  for ( ; stack; stack=stack->next) {
141  if (stack->port == port) {
142  if (stack->pri)
143  return 30;
144  else
145  return 2;
146  }
147  }
148  return -1;
149 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_get_port_down()

int misdn_lib_get_port_down ( int  port)

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

1806 { /* Pull Down L1 */
1807  struct misdn_stack *stack;
1808  for (stack=glob_mgr->stack_list;
1809  stack;
1810  stack=stack->next) {
1811  if (stack->port == port) {
1812  if (stack->l2link)
1813  misdn_lib_get_l2_down(stack);
1814  misdn_lib_get_l1_down(stack);
1815  return 0;
1816  }
1817  }
1818  return 0;
1819 }
static int misdn_lib_get_l2_down(struct misdn_stack *stack)
Definition: isdn_lib.c:890
static int misdn_lib_get_l1_down(struct misdn_stack *stack)
Definition: isdn_lib.c:876
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int l2link
TRUE if Layer 2 is UP.
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.
struct misdn_stack * stack_list
Definition: isdn_lib.c:225

◆ misdn_lib_get_port_info()

int misdn_lib_get_port_info ( int  port)

Definition at line 3903 of file isdn_lib.c.

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

3904 {
3905  msg_t *msg=alloc_msg(MAX_MSG_SIZE);
3906  iframe_t *frm;
3907  struct misdn_stack *stack=find_stack_by_port(port);
3908  if (!msg) {
3909  cb_log(0, port, "misdn_lib_get_port_info: alloc_msg failed!\n");
3910  return -1;
3911  }
3912  frm=(iframe_t*)msg->data;
3913  if (!stack ) {
3914  cb_log(0, port, "There is no Stack for this port.\n");
3915  return -1;
3916  }
3917  /* activate bchannel */
3918  frm->prim = CC_STATUS_ENQUIRY | REQUEST;
3919 
3920  frm->addr = stack->upper_id| FLG_MSG_DOWN;
3921 
3922  frm->dinfo = 0;
3923  frm->len = 0;
3924 
3925  msg_queue_tail(&glob_mgr->activatequeue, msg);
3926  sem_post(&glob_mgr->new_msg);
3927 
3928 
3929  return 0;
3930 }
int upper_id
Upper layer mISDN ID (addr) (Layer 2/4)
if(!yyg->yy_init)
Definition: ast_expr2f.c:868
sem_t new_msg
Definition: isdn_lib.c:223
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
static struct misdn_stack * find_stack_by_port(int port)
Definition: isdn_lib.c:1487
int port
Logical Layer 1 port associated with this stack.
msg_queue_t activatequeue
Definition: isdn_lib.c:221
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_get_port_up()

int misdn_lib_get_port_up ( int  port)

Definition at line 1781 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::nt, misdn_stack::port, and misdn_lib::stack_list.

Referenced by handle_cli_misdn_port_up(), and misdn_check_l2l1().

1782 { /* Pull Up L1 */
1783  struct misdn_stack *stack;
1784 
1785  for (stack=glob_mgr->stack_list;
1786  stack;
1787  stack=stack->next) {
1788 
1789  if (stack->port == port) {
1790 
1791  if (!stack->l1link)
1792  misdn_lib_get_l1_up(stack);
1793  /* handle_l1 will start L2 for NT. */
1794  if (!stack->l2link && !stack->nt) {
1795  misdn_lib_get_l2_up(stack);
1796  }
1797 
1798  return 0;
1799  }
1800  }
1801  return 0;
1802 }
int l1link
TRUE if Layer 1 is UP.
int misdn_lib_get_l2_up(struct misdn_stack *stack)
Definition: isdn_lib.c:932
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int l2link
TRUE if Layer 2 is UP.
int nt
TRUE if NT side of protocol (TE otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
static int misdn_lib_get_l1_up(struct misdn_stack *stack)
Definition: isdn_lib.c:918
int port
Logical Layer 1 port associated with this stack.
struct misdn_stack * stack_list
Definition: isdn_lib.c:225

◆ misdn_lib_init()

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

Definition at line 4143 of file isdn_lib.c.

References misdn_lib::activatequeue, ARRAY_LEN, misdn_stack::b_num, misdn_stack::bc, calloc, misdn_lib_iface::cb_event, 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(), free(), 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, NULL, pthread_create, ptp, stack_destroy(), stack_init(), misdn_lib::stack_list, te_lib_destroy(), and te_lib_init().

Referenced by load_module().

4144 {
4145  struct misdn_lib *mgr;
4146  char *tok, *tokb;
4147  char plist[1024];
4148  int midev;
4149  int port_count=0;
4150 
4151  cb_log = iface->cb_log;
4152  cb_event = iface->cb_event;
4153  cb_jb_empty = iface->cb_jb_empty;
4154 
4155  if (!portlist || (*portlist == 0)) {
4156  return 1;
4157  }
4158 
4159  mgr = calloc(1, sizeof(*mgr));
4160  if (!mgr) {
4161  return 1;
4162  }
4163  glob_mgr = mgr;
4164 
4165  msg_init();
4166 
4168 
4169  init_flip_bits();
4170 
4171  strncpy(plist, portlist, 1024);
4172  plist[1023] = 0;
4173 
4174  memcpy(tone_425_flip,tone_425,TONE_425_SIZE);
4175  flip_buf_bits(tone_425_flip,TONE_425_SIZE);
4176 
4177  memcpy(tone_silence_flip,tone_SILENCE,TONE_SILENCE_SIZE);
4178  flip_buf_bits(tone_silence_flip,TONE_SILENCE_SIZE);
4179 
4180  midev=te_lib_init();
4181  if (midev <= 0) {
4182  free(glob_mgr);
4183  glob_mgr = NULL;
4184  return 1;
4185  }
4186  mgr->midev=midev;
4187 
4188  port_count=mISDN_get_stack_count(midev);
4189 
4190  msg_queue_init(&mgr->activatequeue);
4191 
4192  if (sem_init(&mgr->new_msg, 1, 0)<0)
4193  sem_init(&mgr->new_msg, 0, 0);
4194 
4195  for (tok=strtok_r(plist," ,",&tokb );
4196  tok;
4197  tok=strtok_r(NULL," ,",&tokb)) {
4198  int port = atoi(tok);
4199  struct misdn_stack *stack;
4200  struct misdn_stack *help;
4201  int ptp=0;
4202  int i;
4203  int r;
4204 
4205  if (strstr(tok, "ptp"))
4206  ptp=1;
4207 
4208  if (port > port_count) {
4209  cb_log(0, port, "Couldn't Initialize this port since we have only %d ports\n", port_count);
4210  continue;
4211  }
4212 
4213  stack = stack_init(midev, port, ptp);
4214  if (!stack) {
4215  cb_log(0, port, "stack_init() failed for this port\n");
4216  continue;
4217  }
4218 
4219  /* Initialize the B channel records for real B channels. */
4220  for (i = 0; i <= stack->b_num; i++) {
4221  r = init_bc(stack, &stack->bc[i], stack->midev, port, i);
4222  if (r < 0) {
4223  cb_log(0, port, "Got Err @ init_bc :%d\n", r);
4224  break;
4225  }
4226  }
4227  if (i <= stack->b_num) {
4228  stack_destroy(stack);
4229  free(stack);
4230  continue;
4231  }
4232 #if defined(AST_MISDN_ENHANCEMENTS)
4233  /* Initialize the B channel records for REGISTER signaling links. */
4234  for (i = MAX_BCHANS + 1; i < ARRAY_LEN(stack->bc); ++i) {
4235  r = init_bc(stack, &stack->bc[i], stack->midev, port, i);
4236  if (r < 0) {
4237  cb_log(0, port, "Got Err @ init_bc :%d\n", r);
4238  break;
4239  }
4240  stack->bc[i].is_register_pool = 1;
4241  }
4242  if (i < ARRAY_LEN(stack->bc)) {
4243  stack_destroy(stack);
4244  free(stack);
4245  continue;
4246  }
4247 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
4248 
4249  /* Add the new stack to the end of the list */
4250  help = mgr->stack_list;
4251  if (!help) {
4252  mgr->stack_list = stack;
4253  } else {
4254  while (help->next) {
4255  help = help->next;
4256  }
4257  help->next = stack;
4258  }
4259  }
4260 
4261  if (!mgr->stack_list) {
4262  /* no stacks were successfully initialized !? */
4263  te_lib_destroy(midev);
4264  free(glob_mgr);
4265  glob_mgr = NULL;
4266  return 1;
4267  }
4268  if (sem_init(&handler_started, 1, 0)<0)
4269  sem_init(&handler_started, 0, 0);
4270 
4271  cb_log(8, 0, "Starting Event Handler\n");
4273 
4274  sem_wait(&handler_started) ;
4275  cb_log(8, 0, "Starting Event Catcher\n");
4277 
4278  cb_log(8, 0, "Event Catcher started\n");
4279 
4281 
4282  return (mgr == NULL);
4283 }
static char tone_silence_flip[TONE_SILENCE_SIZE]
Definition: isdn_lib.c:264
void misdn_lib_nt_debug_init(int flags, char *file)
Definition: isdn_lib.c:4124
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int init_bc(struct misdn_stack *stack, struct misdn_bchannel *bc, int midev, int port, int bidx)
Definition: isdn_lib.c:1210
static void init_flip_bits(void)
Definition: isdn_lib.c:321
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
int midev
mISDN device handle returned by mISDN_open()
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.h:730
enum event_response_e(* cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data)
Definition: isdn_lib.c:30
static enum global_states global_state
Definition: isdn_lib.c:199
static struct misdn_stack * stack_init(int midev, int port, int ptp)
Definition: isdn_lib.c:1274
static void misdn_lib_isdn_event_catcher(void *arg)
Definition: isdn_lib.c:3068
#define NULL
Definition: resample.c:96
#define calloc(a, b)
Definition: astmm.h:157
sem_t new_msg
Definition: isdn_lib.c:223
enum event_response_e(* cb_event)(enum event_e event, struct misdn_bchannel *bc, void *user_data)
Definition: isdn_lib.h:729
void free()
struct misdn_bchannel bc[MAX_BCHANS+1+MISDN_MAX_REGISTER_LINKS]
B Channel record pool array (Must be dimensioned the same as struct misdn_stack.channels[]) ...
static char tone_425_flip[TONE_425_SIZE]
Definition: isdn_lib.c:263
int(* cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len)
Definition: isdn_lib.h:732
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int is_register_pool
TRUE if the B channel is allocated from the REGISTER pool.
Definition: isdn_lib.h:417
int(* cb_jb_empty)(struct misdn_bchannel *bc, char *buffer, int len)
Definition: isdn_lib.c:35
#define pthread_create
Definition: lock.h:640
struct misdn_stack * next
Next stack in the list of stacks.
void te_lib_destroy(int midev)
Definition: isdn_lib.c:3142
static void stack_destroy(struct misdn_stack *stack)
Definition: isdn_lib.c:1454
static char * flip_buf_bits(char *buf, int len)
Definition: isdn_lib.c:334
pthread_t event_handler_thread
Definition: isdn_lib.c:217
pthread_t event_thread
Definition: isdn_lib.c:216
static int * ptp
Definition: misdn_config.c:436
static void manager_event_handler(void *arg)
Definition: isdn_lib.c:4025
msg_queue_t activatequeue
Definition: isdn_lib.c:221
struct misdn_stack * stack_list
Definition: isdn_lib.c:225
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
#define MAX_BCHANS
Definition: isdn_lib.h:76
static sem_t handler_started
Definition: isdn_lib.c:4022
static int te_lib_init(void)
Definition: isdn_lib.c:3116

◆ misdn_lib_is_port_blocked()

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.

118 {
119  struct misdn_stack *stack=get_misdn_stack();
120  for ( ; stack; stack=stack->next) {
121  if (stack->port == port) {
122  return stack->blocked;
123  }
124  }
125  return -1;
126 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
struct misdn_stack * next
Next stack in the list of stacks.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_is_ptp()

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

129 {
130  struct misdn_stack *stack=get_misdn_stack();
131  for ( ; stack; stack=stack->next) {
132  if (stack->port == port) return stack->ptp;
133  }
134  return -1;
135 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_isdn_l1watcher()

void misdn_lib_isdn_l1watcher ( int  port)

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

3050 {
3051  struct misdn_stack *stack;
3052 
3053  for (stack = glob_mgr->stack_list; stack && (stack->port != port); stack = stack->next)
3054  ;
3055 
3056  if (stack) {
3057  cb_log(4, port, "Checking L1 State\n");
3058  if (!stack->l1link) {
3059  cb_log(4, port, "L1 State Down, trying to get it up again\n");
3061  misdn_lib_get_l1_up(stack);
3062  misdn_lib_get_l2_up(stack);
3063  }
3064  }
3065 }
int l1link
TRUE if Layer 1 is UP.
int misdn_lib_get_l2_up(struct misdn_stack *stack)
Definition: isdn_lib.c:932
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
struct misdn_stack * next
Next stack in the list of stacks.
static int misdn_lib_get_short_status(struct misdn_stack *stack)
Definition: isdn_lib.c:959
static int misdn_lib_get_l1_up(struct misdn_stack *stack)
Definition: isdn_lib.c:918
int port
Logical Layer 1 port associated with this stack.
struct misdn_stack * stack_list
Definition: isdn_lib.c:225
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_log_ies()

void misdn_lib_log_ies ( struct misdn_bchannel bc)

Definition at line 3431 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_id::number_plan, misdn_party_dialing::number_plan, misdn_party_id::number_type, misdn_party_dialing::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().

3432 {
3433  struct misdn_stack *stack;
3434 
3435  if (!bc) return;
3436 
3437  stack = get_stack_by_bc(bc);
3438 
3439  if (!stack) return;
3440 
3441  cb_log(2, stack->port,
3442  " --> channel:%d mode:%s cause:%d ocause:%d\n",
3443  bc->channel,
3444  stack->nt ? "NT" : "TE",
3445  bc->cause,
3446  bc->out_cause);
3447 
3448  cb_log(2, stack->port,
3449  " --> info_dad:%s dialed numtype:%d plan:%d\n",
3450  bc->info_dad,
3451  bc->dialed.number_type,
3452  bc->dialed.number_plan);
3453 
3454  cb_log(2, stack->port,
3455  " --> caller:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
3456  bc->caller.name,
3457  bc->caller.number,
3458  bc->caller.number_type,
3459  bc->caller.number_plan,
3460  bc->caller.presentation,
3461  bc->caller.screening);
3462 
3463  cb_log(2, stack->port,
3464  " --> redirecting-from:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
3465  bc->redirecting.from.name,
3466  bc->redirecting.from.number,
3470  bc->redirecting.from.screening);
3471  cb_log(2, stack->port,
3472  " --> redirecting-to:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
3473  bc->redirecting.to.name,
3474  bc->redirecting.to.number,
3478  bc->redirecting.to.screening);
3479  cb_log(2, stack->port,
3480  " --> redirecting reason:%d count:%d\n",
3481  bc->redirecting.reason,
3482  bc->redirecting.count);
3483 
3484  cb_log(2, stack->port,
3485  " --> connected:\"%s\" <%s> type:%d plan:%d pres:%d screen:%d\n",
3486  bc->connected.name,
3487  bc->connected.number,
3488  bc->connected.number_type,
3489  bc->connected.number_plan,
3490  bc->connected.presentation,
3491  bc->connected.screening);
3492 
3493  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);
3494 
3495  cb_log(4, stack->port, " --> set_pres:%d pres:%d\n", bc->set_presentation, bc->presentation);
3496 
3497  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);
3498 
3499  cb_log(4, stack->port, " --> facility in:%s out:%s\n", fac2str(bc->fac_in.Function), fac2str(bc->fac_out.Function));
3500 
3501  cb_log(5, stack->port, " --> urate:%d rate:%d mode:%d user1:%d\n", bc->urate, bc->rate, bc->mode,bc->user1);
3502 
3503  cb_log(5, stack->port, " --> bc:%p h:%d sh:%d\n", bc, bc->holded, bc->stack_holder);
3504 }
char keypad[MISDN_MAX_KEYPAD_LEN]
Q.931 Keypad Facility IE contents.
Definition: isdn_lib.h:647
struct FacParm fac_out
Outbound FACILITY message function type and contents.
Definition: isdn_lib.h:512
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
static char * bearer2str(int cap)
Definition: isdn_lib.c:290
int presentation
User set presentation restriction code 0=Allowed, 1=Restricted, 2=Unavailable.
Definition: isdn_lib.h:600
int stack_holder
TRUE if this channel is on the misdn_stack->holding list.
Definition: isdn_lib.h:561
int mode
Q.931 Bearer Capability IE Transfer Mode field. Initialized to 0 (Circuit). Altered by incoming SETUP...
Definition: isdn_lib.h:619
int presentation
Number presentation restriction code 0=Allowed, 1=Restricted, 2=Unavailable.
Definition: isdn_lib.h:277
int sending_complete
TRUE if all digits necessary to complete the call are available. No more INFORMATION messages are nee...
Definition: isdn_lib.h:470
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
struct misdn_party_id to
Where the call is being redirected toward (Sent to the calling party)
Definition: isdn_lib.h:310
int layer_id
B Channel mISDN driver layer ID from mISDN_new_layer()
Definition: isdn_lib.h:379
int set_presentation
TRUE if the user set the presentation restriction code.
Definition: isdn_lib.h:603
enum mISDN_NUMBER_TYPE number_type
Type-of-number in ISDN terms for the number.
Definition: isdn_lib.h:285
int holded
TRUE if this channel is on hold.
Definition: isdn_lib.h:556
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
char name[MISDN_MAX_NAME_LEN]
Subscriber Name.
Definition: isdn_lib.h:295
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
int b_stid
B Channel mISDN driver stack ID.
Definition: isdn_lib.h:374
struct misdn_party_id connected
Connected-Party/Connected-Line ID information struct.
Definition: isdn_lib.h:353
struct misdn_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: isdn_lib.h:307
enum mISDN_NUMBER_TYPE number_type
Type-of-number in ISDN terms for the dialed/called number.
Definition: isdn_lib.h:260
struct misdn_party_redirecting redirecting
Redirecting information struct (Where a call diversion or transfer was invoked)
Definition: isdn_lib.h:358
int urate
Q.931 Bearer Capability IE Layer 1 User Rate field.
Definition: isdn_lib.h:629
struct misdn_party_dialing dialed
Dialed/Called information struct.
Definition: isdn_lib.h:337
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
int nt
TRUE if NT side of protocol (TE otherwise)
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
int out_cause
Q.931 Cause for disconnection code (sent)
Definition: isdn_lib.h:677
enum mISDN_REDIRECTING_REASON reason
Reason a call is being redirected (Q.931 field value)
Definition: isdn_lib.h:313
int user1
Q.931 Bearer Capability IE User Information Layer 1 Protocol field code.
Definition: isdn_lib.h:624
int progress_indicator
Progress Indicator IE progress description field. Used to determine if there is an inband audio messa...
Definition: isdn_lib.h:492
int rate
Q.931 Bearer Capability IE Information Transfer Rate field. Initialized to 0x10 (64kbit). Altered by incoming SETUP messages.
Definition: isdn_lib.h:616
int cause
Q.931 Cause for disconnection code (received)
Definition: isdn_lib.h:671
char info_dad[MISDN_MAX_NUMBER_LEN]
Current overlap dialing digits to/from INFORMATION messages.
Definition: isdn_lib.h:650
int port
Logical Layer 1 port associated with this stack.
int screening
Number screening code 0=Unscreened, 1=Passed Screen, 2=Failed Screen, 3=Network Number.
Definition: isdn_lib.h:282
static const char * fac2str(enum FacFunction facility)
Definition: isdn_lib.c:3338
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
struct FacParm fac_in
Inbound FACILITY message function type and contents.
Definition: isdn_lib.h:507
enum mISDN_NUMBER_PLAN number_plan
Type-of-number numbering plan.
Definition: isdn_lib.h:288
int count
Number of times the call has been redirected.
Definition: isdn_lib.h:316
enum mISDN_NUMBER_PLAN number_plan
Type-of-number numbering plan.
Definition: isdn_lib.h:263
int l3_id
Layer 3 process ID.
Definition: isdn_lib.h:399

◆ misdn_lib_maxports_get()

int misdn_lib_maxports_get ( void  )

Definition at line 4094 of file isdn_lib.c.

References max.

Referenced by load_module().

4095 {
4096  /* BE AWARE WE HAVE NO cb_log() HERE! */
4097 
4098  int i = mISDN_open();
4099  int max=0;
4100 
4101  if (i<0)
4102  return -1;
4103 
4104  max = mISDN_get_stack_count(i);
4105 
4106  mISDN_close(i);
4107 
4108  return max;
4109 }
#define max(a, b)
Definition: f2c.h:198

◆ misdn_lib_nt_debug_init()

void misdn_lib_nt_debug_init ( int  flags,
char *  file 
)

Definition at line 4124 of file isdn_lib.c.

References make_ari_stubs::file, and NULL.

Referenced by load_module(), and misdn_lib_init().

4125 {
4126  static int init=0;
4127  char *f;
4128 
4129  if (!flags)
4130  f=NULL;
4131  else
4132  f=file;
4133 
4134  if (!init) {
4135  debug_init( flags , f, f, f);
4136  init=1;
4137  } else {
4138  debug_close();
4139  debug_init( flags , f, f, f);
4140  }
4141 }
#define NULL
Definition: resample.c:96

◆ misdn_lib_nt_keepcalls()

void misdn_lib_nt_keepcalls ( int  kc)

Definition at line 4112 of file isdn_lib.c.

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

Referenced by load_module().

4113 {
4114 #ifdef FEATURE_NET_KEEPCALLS
4115  if (kc) {
4116  struct misdn_stack *stack=get_misdn_stack();
4117  for ( ; stack; stack=stack->next) {
4118  stack->nst.feature |= FEATURE_NET_KEEPCALLS;
4119  }
4120  }
4121 #endif
4122 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
net_stack_t nst
struct misdn_stack * next
Next stack in the list of stacks.

◆ misdn_lib_pid_restart()

int misdn_lib_pid_restart ( int  pid)

Definition at line 3932 of file isdn_lib.c.

References manager_clean_bc(), and manager_find_bc_by_pid().

Referenced by handle_cli_misdn_restart_pid().

3933 {
3935 
3936  if (bc) {
3937  manager_clean_bc(bc);
3938  }
3939  return 0;
3940 }
#define bc
B channel control structure.
Definition: isdn_lib.h:324
void manager_clean_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:4489
int pid
B channel process ID (1-5000)
Definition: isdn_lib.h:402
struct misdn_bchannel * manager_find_bc_by_pid(int pid)
Definition: isdn_lib.c:3152

◆ misdn_lib_port_block()

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

92 {
93  struct misdn_stack *stack=get_misdn_stack();
94  for ( ; stack; stack=stack->next) {
95  if (stack->port == port) {
96  stack->blocked=1;
97  return 0;
98  }
99  }
100  return -1;
101 
102 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
struct misdn_stack * next
Next stack in the list of stacks.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_port_is_nt()

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(), misdn_update_redirecting(), reload(), and wait_for_digits().

66 {
67  struct misdn_stack *stack=get_misdn_stack();
68  for ( ; stack; stack=stack->next) {
69  if (stack->port == port) {
70  return stack->nt;
71  }
72  }
73 
74  return -1;
75 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
int nt
TRUE if NT side of protocol (TE otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_port_is_pri()

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

54 {
55  struct misdn_stack *stack=get_misdn_stack();
56  for ( ; stack; stack=stack->next) {
57  if (stack->port == port) {
58  return stack->pri;
59  }
60  }
61 
62  return -1;
63 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_port_restart()

int misdn_lib_port_restart ( int  port)

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

3983 {
3984  struct misdn_stack *stack=find_stack_by_port(port);
3985 
3986  cb_log(0, port, "Restarting this port.\n");
3987  if (stack) {
3988  cb_log(0, port, "Stack:%p\n",stack);
3989 
3990  clear_l3(stack);
3991  {
3992  msg_t *msg=alloc_msg(MAX_MSG_SIZE);
3993  iframe_t *frm;
3994 
3995  if (!msg) {
3996  cb_log(0, port, "port_restart: alloc_msg failed\n");
3997  return -1;
3998  }
3999 
4000  frm=(iframe_t*)msg->data;
4001  /* we must activate if we are deactivated */
4002  /* activate bchannel */
4003  frm->prim = DL_RELEASE | REQUEST;
4004  frm->addr = stack->upper_id | FLG_MSG_DOWN;
4005 
4006  frm->dinfo = 0;
4007  frm->len = 0;
4008  msg_queue_tail(&glob_mgr->activatequeue, msg);
4009  sem_post(&glob_mgr->new_msg);
4010  }
4011 
4012  if (stack->nt)
4014 
4015  }
4016 
4017  return 0;
4018 }
int upper_id
Upper layer mISDN ID (addr) (Layer 2/4)
static void clear_l3(struct misdn_stack *stack)
Definition: isdn_lib.c:852
void misdn_lib_reinit_nt_stack(int port)
Definition: isdn_lib.c:4779
sem_t new_msg
Definition: isdn_lib.c:223
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int nt
TRUE if NT side of protocol (TE otherwise)
static struct misdn_stack * find_stack_by_port(int port)
Definition: isdn_lib.c:1487
int port
Logical Layer 1 port associated with this stack.
msg_queue_t activatequeue
Definition: isdn_lib.c:221
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_port_unblock()

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

105 {
106  struct misdn_stack *stack=get_misdn_stack();
107  for ( ; stack; stack=stack->next) {
108  if (stack->port == port) {
109  stack->blocked=0;
110  return 0;
111  }
112  }
113  return -1;
114 
115 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
struct misdn_stack * next
Next stack in the list of stacks.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_port_up()

int misdn_lib_port_up ( int  port,
int  notcheck 
)

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

1822 {
1823  struct misdn_stack *stack;
1824 
1825 
1826  for (stack=glob_mgr->stack_list;
1827  stack;
1828  stack=stack->next) {
1829 
1830  if (stack->port == port) {
1831 
1832  if (stack->blocked) {
1833  cb_log(0,port, "Port Blocked:%d L2:%d L1:%d\n", stack->blocked, stack->l2link, stack->l1link);
1834  return -1;
1835  }
1836 
1837  if (stack->ptp ) {
1838 
1839  if (stack->l1link && stack->l2link) {
1840  return 1;
1841  } else {
1842  cb_log(1,port, "Port Down L2:%d L1:%d\n",
1843  stack->l2link, stack->l1link);
1844  return 0;
1845  }
1846  } else {
1847  if ( !check || stack->l1link )
1848  return 1;
1849  else {
1850  cb_log(1,port, "Port down PMP\n");
1851  return 0;
1852  }
1853  }
1854  }
1855  }
1856 
1857  return -1;
1858 }
int l1link
TRUE if Layer 1 is UP.
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int l2link
TRUE if Layer 2 is UP.
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
struct misdn_stack * next
Next stack in the list of stacks.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.
struct misdn_stack * stack_list
Definition: isdn_lib.c:225
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_reinit_nt_stack()

void misdn_lib_reinit_nt_stack ( int  port)

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

Referenced by misdn_lib_port_restart().

4780 {
4781  struct misdn_stack *stack=find_stack_by_port(port);
4782 
4783  if (stack) {
4784  stack->l2link=0;
4785  stack->blocked=0;
4786 
4787  cleanup_Isdnl3(&stack->nst);
4788  cleanup_Isdnl2(&stack->nst);
4789 
4790 
4791  memset(&stack->nst, 0, sizeof(net_stack_t));
4792  memset(&stack->mgr, 0, sizeof(manager_t));
4793 
4794  stack->mgr.nst = &stack->nst;
4795  stack->nst.manager = &stack->mgr;
4796 
4797  stack->nst.l3_manager = handle_event_nt;
4798  stack->nst.device = glob_mgr->midev;
4799  stack->nst.cardnr = port;
4800  stack->nst.d_stid = stack->d_stid;
4801 
4802  stack->nst.feature = FEATURE_NET_HOLD;
4803  if (stack->ptp)
4804  stack->nst.feature |= FEATURE_NET_PTP;
4805  if (stack->pri)
4806  stack->nst.feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
4807 
4808  stack->nst.l1_id = stack->lower_id; /* never used */
4809  stack->nst.l2_id = stack->upper_id;
4810 
4811  msg_queue_init(&stack->nst.down_queue);
4812 
4813  Isdnl2Init(&stack->nst);
4814  Isdnl3Init(&stack->nst);
4815 
4816  if (!stack->ptp)
4817  misdn_lib_get_l1_up(stack);
4818  }
4819 }
int upper_id
Upper layer mISDN ID (addr) (Layer 2/4)
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
net_stack_t nst
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
int lower_id
Lower layer mISDN ID (addr) (Layer 1/3)
int d_stid
D Channel mISDN driver stack ID (Parent stack ID)
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int l2link
TRUE if Layer 2 is UP.
static int handle_event_nt(void *dat, void *arg)
Definition: isdn_lib.c:1890
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
manager_t mgr
static struct misdn_stack * find_stack_by_port(int port)
Definition: isdn_lib.c:1487
int blocked
TRUE if port is blocked.
static int misdn_lib_get_l1_up(struct misdn_stack *stack)
Definition: isdn_lib.c:918
int port
Logical Layer 1 port associated with this stack.

◆ misdn_lib_release()

void misdn_lib_release ( struct misdn_bchannel bc)

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

1760 {
1761  int channel;
1762  struct misdn_stack *stack=get_stack_by_bc(bc);
1763 
1764  if (!stack) {
1765  cb_log(1,0,"misdn_release: No Stack found\n");
1766  return;
1767  }
1768 
1769  channel = bc->channel;
1770  empty_bc(bc);
1771  clean_up_bc(bc);
1772  if (channel > 0) {
1773  empty_chan_in_stack(stack, channel);
1774  }
1775  bc->in_use=0;
1776 }
static void empty_chan_in_stack(struct misdn_stack *stack, int channel)
Definition: isdn_lib.c:605
static int clean_up_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:815
Definition: muted.c:95
static void empty_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:679
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
int in_use
TRUE if B channel record is in use.
Definition: isdn_lib.h:420
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_send_event()

int misdn_lib_send_event ( struct misdn_bchannel bc,
enum event_e  event 
)

Definition at line 3523 of file isdn_lib.c.

References 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, 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_id::number_type, misdn_party_dialing::number_type, misdn_bchannel::out_cause, misdn_bchannel::pid, misdn_stack::port, misdn_bchannel::port, misdn_stack::ptp, RETURN, retval, misdn_bchannel::rxgain, setup_bc(), stack_holder_add(), misdn_bchannel::txgain, and misdn_stack::upper_id.

Referenced by cb_events(), do_immediate_setup(), get_chan_by_ast_name(), handle_cli_misdn_send_display(), handle_cli_misdn_send_facility(), handle_event_nt(), handle_event_te(), handle_frm_te(), 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(), reload(), start_pbx(), and wait_for_digits().

3524 {
3525  msg_t *msg;
3526  struct misdn_bchannel *bc2;
3527  struct misdn_bchannel *held_bc;
3528  struct misdn_stack *stack;
3529  int retval = 0;
3530  int channel;
3531  int tmpcause;
3532  int tmp_out_cause;
3533 
3534  if (!bc)
3535  RETURN(-1,OUT_POST_UNLOCK);
3536 
3537  stack = get_stack_by_bc(bc);
3538  if (!stack) {
3539  cb_log(0,bc->port,
3540  "SENDEVENT: no Stack for event:%s caller:\"%s\" <%s> dialed:%s \n",
3541  isdn_get_info(msgs_g, event, 0),
3542  bc->caller.name,
3543  bc->caller.number,
3544  bc->dialed.number);
3545  RETURN(-1,OUT);
3546  }
3547 
3548  misdn_send_lock(bc);
3549 
3550 
3551  cb_log(6,stack->port,"SENDEVENT: stack->nt:%d stack->upperid:%x\n",stack->nt, stack->upper_id);
3552 
3553  if ( stack->nt && !stack->l1link) {
3554  misdn_lib_get_l1_up(stack);
3555  }
3556 
3557  cb_log(1, stack->port,
3558  "I SEND:%s caller:\"%s\" <%s> dialed:%s pid:%d\n",
3559  isdn_get_info(msgs_g, event, 0),
3560  bc->caller.name,
3561  bc->caller.number,
3562  bc->dialed.number,
3563  bc->pid);
3564  cb_log(4, stack->port, " --> bc_state:%s\n",bc_state2str(bc->bc_state));
3565  misdn_lib_log_ies(bc);
3566 
3567  switch (event) {
3568  case EVENT_REGISTER:
3569  case EVENT_SETUP:
3570  if (create_process(glob_mgr->midev, bc) < 0) {
3571  cb_log(0, stack->port, " No free channel at the moment @ send_event\n");
3572 
3573  RETURN(-ENOCHAN,OUT);
3574  }
3575  break;
3576 
3577  case EVENT_PROGRESS:
3578  case EVENT_ALERTING:
3579  case EVENT_PROCEEDING:
3581  case EVENT_CONNECT:
3582  if (!stack->nt) {
3583  if (stack->ptp) {
3584  setup_bc(bc);
3585  }
3586  break;
3587  }
3588  /* fall through */
3589 
3591  if (stack->nt) {
3592  if (bc->channel <=0 ) { /* else we have the channel already */
3593  if (find_free_chan_in_stack(stack, bc, 0, 0)<0) {
3594  cb_log(0, stack->port, " No free channel at the moment\n");
3595  /*FIXME: add disconnect*/
3596  RETURN(-ENOCHAN,OUT);
3597  }
3598  }
3599  /* Its that i generate channels */
3600  }
3601 
3602  retval=setup_bc(bc);
3603  if (retval == -EINVAL) {
3604  cb_log(0,bc->port,"send_event: setup_bc failed\n");
3605  }
3606 
3607  if (misdn_cap_is_speech(bc->capability)) {
3609  if ( *bc->crypt_key ) {
3610  cb_log(4, stack->port,
3611  " --> ENABLING BLOWFISH channel:%d caller%d:\"%s\" <%s> dialed%d:%s\n",
3612  bc->channel,
3613  bc->caller.number_type,
3614  bc->caller.name,
3615  bc->caller.number,
3616  bc->dialed.number_type,
3617  bc->dialed.number);
3618 
3619  manager_ph_control_block(bc, BF_ENABLE_KEY, bc->crypt_key, strlen(bc->crypt_key) );
3620  }
3621 
3622  if (!bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0);
3623  manager_ec_enable(bc);
3624 
3625  if (bc->txgain != 0) {
3626  cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
3627  manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
3628  }
3629 
3630  if ( bc->rxgain != 0 ) {
3631  cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
3632  manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
3633  }
3634  }
3635  }
3636  break;
3637 
3639  held_bc = malloc(sizeof(struct misdn_bchannel));
3640  if (!held_bc) {
3641  cb_log(0, bc->port, "Could not allocate held_bc!!!\n");
3642  RETURN(-1,OUT);
3643  }
3644 
3645  /* backup the bc and put it in storage */
3646  *held_bc = *bc;
3647  held_bc->holded = 1;
3648  held_bc->channel = 0;/* A held call does not have a channel anymore. */
3649  held_bc->channel_preselected = 0;
3650  held_bc->channel_found = 0;
3651  bc_state_change(held_bc, BCHAN_CLEANED);
3652  stack_holder_add(stack, held_bc);
3653 
3654  /* kill the bridge and clean the real b-channel record */
3655  if (stack->nt) {
3656  if (bc->bc_state == BCHAN_BRIDGED) {
3657  misdn_split_conf(bc,bc->conf_id);
3658  bc2 = find_bc_by_confid(bc->conf_id);
3659  if (!bc2) {
3660  cb_log(0,bc->port,"We have no second bc in bridge???\n");
3661  } else {
3662  misdn_split_conf(bc2,bc->conf_id);
3663  }
3664  }
3665 
3666  channel = bc->channel;
3667 
3668  empty_bc(bc);
3669  clean_up_bc(bc);
3670 
3671  if (channel>0)
3672  empty_chan_in_stack(stack,channel);
3673 
3674  bc->in_use=0;
3675  }
3676  break;
3677 
3678  /* finishing the channel eh ? */
3679  case EVENT_DISCONNECT:
3680  if (!bc->need_disconnect) {
3681  cb_log(0, bc->port, " --> we have already sent DISCONNECT\n");
3682  RETURN(-1,OUT);
3683  }
3684  /* IE cause is mandatory for DISCONNECT, but optional for the answers to DISCONNECT.
3685  * We must initialize cause, so it is later correctly indicated to ast_channel
3686  * in case the answer does not include one!
3687  */
3688  bc->cause = bc->out_cause;
3689 
3690  bc->need_disconnect=0;
3691  break;
3692  case EVENT_RELEASE:
3693  if (!bc->need_release) {
3694  cb_log(0, bc->port, " --> we have already sent RELEASE\n");
3695  RETURN(-1,OUT);
3696  }
3697  bc->need_disconnect=0;
3698  bc->need_release=0;
3699  break;
3701  if (!bc->need_release_complete) {
3702  cb_log(0, bc->port, " --> we have already sent RELEASE_COMPLETE\n");
3703  RETURN(-1,OUT);
3704  }
3705  bc->need_disconnect=0;
3706  bc->need_release=0;
3707  bc->need_release_complete=0;
3708 
3709  if (!stack->nt) {
3710  /* create cleanup in TE */
3711  channel = bc->channel;
3712  tmpcause = bc->cause;
3713  tmp_out_cause = bc->out_cause;
3714 
3715  empty_bc(bc);
3716  bc->cause=tmpcause;
3717  bc->out_cause=tmp_out_cause;
3718  clean_up_bc(bc);
3719 
3720  if (channel>0)
3721  empty_chan_in_stack(stack,channel);
3722 
3723  bc->in_use=0;
3724  }
3725  break;
3726 
3728  if ( bc->nt || misdn_cap_is_speech(bc->capability)) {
3729  int retval=setup_bc(bc);
3730  if (retval == -EINVAL){
3731  cb_log(0,bc->port,"send_event: setup_bc failed\n");
3732 
3733  }
3734  }
3735 
3736  if (misdn_cap_is_speech(bc->capability)) {
3737  if ( !bc->nodsp) manager_ph_control(bc, DTMF_TONE_START, 0);
3738  manager_ec_enable(bc);
3739 
3740  if ( bc->txgain != 0 ) {
3741  cb_log(4, stack->port, "--> Changing txgain to %d\n", bc->txgain);
3742  manager_ph_control(bc, VOL_CHANGE_TX, bc->txgain);
3743  }
3744  if ( bc->rxgain != 0 ) {
3745  cb_log(4, stack->port, "--> Changing rxgain to %d\n", bc->rxgain);
3746  manager_ph_control(bc, VOL_CHANGE_RX, bc->rxgain);
3747  }
3748  }
3749  break;
3750 
3751  default:
3752  break;
3753  }
3754 
3755  /* Later we should think about sending bchannel data directly to misdn. */
3756  msg = isdn_msg_build_event(msgs_g, bc, event, stack->nt);
3757  if (!msg) {
3758  /*
3759  * The message was not built.
3760  *
3761  * NOTE: The only time that the message will fail to build
3762  * is because the requested FACILITY message is not supported.
3763  * A failed malloc() results in exit() being called.
3764  */
3765  RETURN(-1, OUT);
3766  } else {
3767  msg_queue_tail(&stack->downqueue, msg);
3768  sem_post(&glob_mgr->new_msg);
3769  }
3770 
3771 OUT:
3772  misdn_send_unlock(bc);
3773 
3774 OUT_POST_UNLOCK:
3775  return retval;
3776 }
static void empty_chan_in_stack(struct misdn_stack *stack, int channel)
Definition: isdn_lib.c:605
int upper_id
Upper layer mISDN ID (addr) (Layer 2/4)
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
void stack_holder_add(struct misdn_stack *stack, struct misdn_bchannel *holder)
Definition: isdn_lib.c:4503
char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
int nodsp
TRUE if we will not use jollys dsp.
Definition: isdn_lib.h:474
int txgain
Tx gain setting (range -8 to 8)
Definition: isdn_lib.h:708
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
#define bc
struct isdn_msg msgs_g[]
static int clean_up_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:815
void manager_ec_enable(struct misdn_bchannel *bc)
Definition: isdn_lib.c:4628
B channel control structure.
Definition: isdn_lib.h:324
Definition: astman.c:222
char crypt_key[255]
Blowfish encryption key string (secret)
Definition: isdn_lib.h:529
static struct misdn_bchannel * find_bc_by_confid(unsigned long confid)
Definition: isdn_lib.c:1574
static int setup_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:1038
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
Definition: muted.c:95
int misdn_cap_is_speech(int cap)
Definition: isdn_lib.c:436
sem_t new_msg
Definition: isdn_lib.c:223
int l1link
TRUE if Layer 1 is UP.
static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel, int dec)
Definition: isdn_lib.c:513
char * malloc()
msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt)
char number[MISDN_MAX_NUMBER_LEN]
Dialed/Called Phone Number (Address)
Definition: isdn_lib.h:266
int conf_id
Bridging conference ID.
Definition: isdn_lib.h:553
int need_release_complete
TRUE if RELEASE_COMPLETE needs to be sent to clear a call.
Definition: isdn_lib.h:392
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419
static void misdn_send_unlock(struct misdn_bchannel *bc)
Definition: isdn_lib.c:3516
int nt
TRUE if NT side of protocol (TE otherwise)
Definition: isdn_lib.h:364
enum mISDN_NUMBER_TYPE number_type
Type-of-number in ISDN terms for the number.
Definition: isdn_lib.h:285
void misdn_lib_log_ies(struct misdn_bchannel *bc)
Definition: isdn_lib.c:3431
int holded
TRUE if this channel is on hold.
Definition: isdn_lib.h:556
void bc_state_change(struct misdn_bchannel *bc, enum bchannel_state state)
Definition: isdn_lib.c:639
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
char name[MISDN_MAX_NAME_LEN]
Subscriber Name.
Definition: isdn_lib.h:295
void misdn_split_conf(struct misdn_bchannel *bc, int conf_id)
Definition: isdn_lib.c:4719
static void empty_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:679
int rxgain
Rx gain setting (range -8 to 8)
Definition: isdn_lib.h:714
static void misdn_send_lock(struct misdn_bchannel *bc)
Definition: isdn_lib.c:3509
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
char * bc_state2str(enum bchannel_state state)
Definition: isdn_lib.c:617
int pid
B channel process ID (1-5000)
Definition: isdn_lib.h:402
enum mISDN_NUMBER_TYPE number_type
Type-of-number in ISDN terms for the dialed/called number.
Definition: isdn_lib.h:260
int in_use
TRUE if B channel record is in use.
Definition: isdn_lib.h:420
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
void manager_ph_control_block(struct misdn_bchannel *bc, int c1, void *c2, int c2_len)
Definition: isdn_lib.c:4470
msg_queue_t downqueue
Queue of Event messages to send to mISDN.
int channel_found
TRUE if the channel was allocated from the available B channels.
Definition: isdn_lib.h:697
#define RETURN(a, b)
Definition: isdn_lib.c:3507
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct misdn_party_dialing dialed
Dialed/Called information struct.
Definition: isdn_lib.h:337
static int create_process(int midev, struct misdn_bchannel *bc)
Definition: isdn_lib.c:976
int nt
TRUE if NT side of protocol (TE otherwise)
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
int out_cause
Q.931 Cause for disconnection code (sent)
Definition: isdn_lib.h:677
int need_release
TRUE if RELEASE needs to be sent to clear a call.
Definition: isdn_lib.h:389
enum bchannel_state bc_state
Current B Channel state.
Definition: isdn_lib.h:547
int need_disconnect
TRUE if DISCONNECT needs to be sent to clear a call.
Definition: isdn_lib.h:386
static ENTRY retval
Definition: hsearch.c:50
int channel_preselected
TRUE if the B channel number is preselected.
Definition: isdn_lib.h:414
static int misdn_lib_get_l1_up(struct misdn_stack *stack)
Definition: isdn_lib.c:918
int cause
Q.931 Cause for disconnection code (received)
Definition: isdn_lib.h:671
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_send_restart()

int misdn_lib_send_restart ( int  port,
int  channel 
)

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

3944 {
3945  struct misdn_stack *stack=find_stack_by_port(port);
3946  struct misdn_bchannel dummybc;
3947  /*default is all channels*/
3948  cb_log(0, port, "Sending Restarts on this port.\n");
3949 
3950  misdn_make_dummy(&dummybc, stack->port, MISDN_ID_GLOBAL, stack->nt, 0);
3951 
3952  /*default is all channels*/
3953  if (channel <0) {
3954  dummybc.channel=-1;
3955  cb_log(0, port, "Restarting and all Interfaces\n");
3957 
3958  return 0;
3959  }
3960 
3961  /*if a channel is specified we restart only this one*/
3962  if (channel >0) {
3963  int cnt;
3964  dummybc.channel=channel;
3965  cb_log(0, port, "Restarting and cleaning channel %d\n",channel);
3967  /* clean up chan in stack, to be sure we don't think it's
3968  * in use anymore */
3969  for (cnt=0; cnt<=stack->b_num; cnt++) {
3970  if (stack->bc[cnt].in_use && stack->bc[cnt].channel == channel) {
3971  empty_bc(&stack->bc[cnt]);
3972  clean_up_bc(&stack->bc[cnt]);
3973  stack->bc[cnt].in_use=0;
3974  }
3975  }
3976  }
3977 
3978  return 0;
3979 }
static int clean_up_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:815
void misdn_make_dummy(struct misdn_bchannel *dummybc, int port, int l3id, int nt, int channel)
Definition: isdn_lib.c:77
B channel control structure.
Definition: isdn_lib.h:324
Definition: muted.c:95
struct misdn_bchannel bc[MAX_BCHANS+1+MISDN_MAX_REGISTER_LINKS]
B Channel record pool array (Must be dimensioned the same as struct misdn_stack.channels[]) ...
static void empty_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:679
int in_use
TRUE if B channel record is in use.
Definition: isdn_lib.h:420
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int nt
TRUE if NT side of protocol (TE otherwise)
static struct misdn_stack * find_stack_by_port(int port)
Definition: isdn_lib.c:1487
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event)
Definition: isdn_lib.c:3523
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_send_tone()

void misdn_lib_send_tone ( struct misdn_bchannel bc,
enum tone_e  tone 
)

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

4597 {
4598  char buf[mISDN_HEADER_LEN + 128] = "";
4599  iframe_t *frm = (iframe_t*)buf;
4600 
4601  switch(tone) {
4602  case TONE_DIAL:
4603  manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_DIALTONE);
4604  break;
4605 
4606  case TONE_ALERTING:
4607  manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_RINGING);
4608  break;
4609 
4610  case TONE_HANGUP:
4611  manager_ph_control(bc, TONE_PATT_ON, TONE_GERMAN_HANGUP);
4612  break;
4613 
4614  case TONE_NONE:
4615  default:
4616  manager_ph_control(bc, TONE_PATT_OFF, TONE_GERMAN_HANGUP);
4617  }
4618 
4619  frm->prim=DL_DATA|REQUEST;
4620  frm->addr=bc->addr|FLG_MSG_DOWN;
4621  frm->dinfo=0;
4622  frm->len=128;
4623 
4624  mISDN_write(glob_mgr->midev, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
4625 }
int midev
mISDN device handle returned by mISDN_open()
Definition: isdn_lib.c:214
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void manager_ph_control(struct misdn_bchannel *bc, int c1, int c2)
Definition: isdn_lib.c:4419
static struct misdn_lib * glob_mgr
Definition: isdn_lib.c:261
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429

◆ misdn_lib_split_bridge()

void misdn_lib_split_bridge ( struct misdn_bchannel bc1,
struct misdn_bchannel bc2 
)

Definition at line 4751 of file isdn_lib.c.

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

Referenced by misdn_write().

4752 {
4753 
4754  struct misdn_bchannel *bc_list[]={
4755  bc1,bc2,NULL
4756  };
4757  struct misdn_bchannel **bc;
4758 
4759  for (bc=bc_list; *bc; bc++) {
4760  if ( (*bc)->bc_state == BCHAN_BRIDGED){
4761  misdn_split_conf( *bc, (*bc)->conf_id);
4762  } else {
4763  cb_log( 2, (*bc)->port, "BC not bridged (state:%s) so not splitting it\n",bc_state2str((*bc)->bc_state));
4764  }
4765  }
4766 
4767 }
#define bc
B channel control structure.
Definition: isdn_lib.h:324
#define NULL
Definition: resample.c:96
int conf_id
Bridging conference ID.
Definition: isdn_lib.h:553
void misdn_split_conf(struct misdn_bchannel *bc, int conf_id)
Definition: isdn_lib.c:4719
char * bc_state2str(enum bchannel_state state)
Definition: isdn_lib.c:617
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_lib_tone_generator_start()

void misdn_lib_tone_generator_start ( struct misdn_bchannel bc)

Definition at line 2271 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by misdn_write().

2272 {
2273  bc->generate_tone=1;
2274 }
int generate_tone
TRUE if tone generator allowed to start.
Definition: isdn_lib.h:541

◆ misdn_lib_tone_generator_stop()

void misdn_lib_tone_generator_stop ( struct misdn_bchannel bc)

Definition at line 2276 of file isdn_lib.c.

References misdn_bchannel::generate_tone.

Referenced by start_bc_tones(), and stop_indicate().

2277 {
2278  bc->generate_tone=0;
2279 }
int generate_tone
TRUE if tone generator allowed to start.
Definition: isdn_lib.h:541

◆ misdn_lib_tx2misdn_frm()

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

Definition at line 4382 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(), len(), misdn_stack::midev, misdn_cap_is_speech(), misdn_stack::port, and misdn_bchannel::port.

Referenced by misdn_join_conf(), and misdn_write().

4383 {
4384  struct misdn_stack *stack=get_stack_by_bc(bc);
4385  char buf[4096 + mISDN_HEADER_LEN];
4386  iframe_t *frm = (iframe_t*)buf;
4387 
4388  switch (bc->bc_state) {
4389  case BCHAN_ACTIVATED:
4390  case BCHAN_BRIDGED:
4391  break;
4392  default:
4393  cb_log(3, bc->port, "BC not yet activated (state:%s)\n",bc_state2str(bc->bc_state));
4394  return -1;
4395  }
4396 
4397  frm->prim = DL_DATA|REQUEST;
4398  frm->dinfo = 0;
4399  frm->addr = bc->addr | FLG_MSG_DOWN ;
4400 
4401  frm->len = len;
4402  memcpy(&buf[mISDN_HEADER_LEN], data,len);
4403 
4404  if ( misdn_cap_is_speech(bc->capability) )
4405  flip_buf_bits( &buf[mISDN_HEADER_LEN], len);
4406  else
4407  cb_log(6, stack->port, "Writing %d data bytes\n",len);
4408 
4409  cb_log(9, stack->port, "Writing %d bytes 2 mISDN\n",len);
4410  mISDN_write(stack->midev, buf, frm->len + mISDN_HEADER_LEN, TIMEOUT_INFINIT);
4411  return 0;
4412 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int midev
mISDN device handle returned by mISDN_open()
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
int misdn_cap_is_speech(int cap)
Definition: isdn_lib.c:436
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
char * bc_state2str(enum bchannel_state state)
Definition: isdn_lib.c:617
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
static char * flip_buf_bits(char *buf, int len)
Definition: isdn_lib.c:334
enum bchannel_state bc_state
Current B Channel state.
Definition: isdn_lib.h:547
int port
Logical Layer 1 port associated with this stack.
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ misdn_make_dummy()

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_te(), manager_event_handler(), misdn_lib_send_restart(), release_cr(), reload(), and wait_for_digits().

78 {
79  memset (dummybc,0,sizeof(struct misdn_bchannel));
80  dummybc->port=port;
81  if (l3id==0)
82  dummybc->l3_id = MISDN_ID_DUMMY;
83  else
84  dummybc->l3_id=l3id;
85 
86  dummybc->nt=nt;
87  dummybc->dummy=1;
88  dummybc->channel=channel;
89 }
int dummy
TRUE if this is a dummy BC record.
Definition: isdn_lib.h:361
B channel control structure.
Definition: isdn_lib.h:324
Definition: muted.c:95
int nt
TRUE if NT side of protocol (TE otherwise)
Definition: isdn_lib.h:364
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int nt
TRUE if NT side of protocol (TE otherwise)
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
int port
Logical Layer 1 port associated with this stack.
int l3_id
Layer 3 process ID.
Definition: isdn_lib.h:399

Variable Documentation

◆ cb_event

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

◆ cb_jb_empty

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

Definition at line 35 of file isdn_lib.c.

Referenced by misdn_lib_init(), and misdn_tx_jitter().

◆ cb_log

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

Definition at line 32 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(), do_tone(), dump_chan_list(), empty_chan_in_stack(), fetch_msg(), find_free_chan_in_stack(), handle_bchan(), handle_cr(), handle_err(), handle_event_nt(), handle_event_te(), handle_frm_nt(), handle_frm_te(), 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_l1_up(), 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(), 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().