Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions
isdn_lib_intern.h File Reference
#include <mISDNuser/mISDNlib.h>
#include <mISDNuser/isdn_net.h>
#include <mISDNuser/l3dss1.h>
#include <mISDNuser/net_l3.h>
#include <pthread.h>
#include "isdn_lib.h"
Include dependency graph for isdn_lib_intern.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  isdn_msg
 
struct  misdn_stack
 
struct  send_lock
 

Macros

#define MAXPROCS   0x100
 
#define MISDN_MAX_REGISTER_LINKS   0
 
#define mISDNUSER_HEAD_SIZE   (sizeof(mISDNuser_head_t))
 
#define QI_ELEMENT(a)   a.off
 

Functions

msg_t * create_l3msg (int prim, int mt, int dinfo, int size, int nt)
 
struct misdn_stackget_stack_by_bc (struct misdn_bchannel *bc)
 
char * isdn_get_info (struct isdn_msg msgs[], enum event_e event, int nt)
 
msg_t * isdn_msg_build_event (struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt)
 
enum event_e isdn_msg_get_event (struct isdn_msg msgs[], msg_t *frm, int nt)
 
int isdn_msg_get_index (struct isdn_msg msgs[], msg_t *frm, int nt)
 
int isdn_msg_get_index_by_event (struct isdn_msg msgs[], enum event_e event, int nt)
 
char * isdn_msg_get_info (struct isdn_msg msgs[], msg_t *msg, int nt)
 
int isdn_msg_parse_event (struct isdn_msg msgs[], msg_t *frm, struct misdn_bchannel *bc, int nt)
 

Macro Definition Documentation

◆ MAXPROCS

#define MAXPROCS   0x100

Definition at line 62 of file isdn_lib_intern.h.

Referenced by create_process().

◆ MISDN_MAX_REGISTER_LINKS

#define MISDN_MAX_REGISTER_LINKS   0

Definition at line 59 of file isdn_lib_intern.h.

◆ mISDNUSER_HEAD_SIZE

#define mISDNUSER_HEAD_SIZE   (sizeof(mISDNuser_head_t))

◆ QI_ELEMENT

#define QI_ELEMENT (   a)    a.off

Definition at line 21 of file isdn_lib_intern.h.

Function Documentation

◆ create_l3msg()

msg_t* create_l3msg ( int  prim,
int  mt,
int  dinfo,
int  size,
int  nt 
)

Definition at line 371 of file isdn_lib.c.

References NULL.

Referenced by build_alerting(), build_connect(), build_connect_acknowledge(), build_disconnect(), build_facility(), build_hold(), build_hold_acknowledge(), build_hold_reject(), build_information(), build_notify(), build_proceeding(), build_progress(), build_release(), build_release_complete(), build_restart(), build_resume(), build_resume_acknowledge(), build_resume_reject(), build_retrieve(), build_retrieve_acknowledge(), build_retrieve_reject(), build_setup(), build_setup_acknowledge(), build_status(), build_status_enquiry(), build_suspend(), build_suspend_acknowledge(), build_suspend_reject(), build_timeout(), build_user_information(), and handle_event_nt().

372 {
373  int i = 0;
374  msg_t *dmsg;
375  Q931_info_t *qi;
376  iframe_t *frm;
377 
378  if (!ntmode)
379  size = sizeof(Q931_info_t)+2;
380 
381  while(i < 10) {
382  if (ntmode) {
383  dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
384  if (dmsg) {
385  return(dmsg);
386  }
387  } else {
388  dmsg = alloc_msg(size+256+mISDN_HEADER_LEN+DEFAULT_HEADROOM);
389  if (dmsg)
390  {
391  memset(msg_put(dmsg,size+mISDN_HEADER_LEN), 0, size+mISDN_HEADER_LEN);
392  frm = (iframe_t *)dmsg->data;
393  frm->prim = prim;
394  frm->dinfo = dinfo;
395  qi = (Q931_info_t *)(dmsg->data + mISDN_HEADER_LEN);
396  qi->type = mt;
397  return(dmsg);
398  }
399  }
400 
401  if (!i) printf("cannot allocate memory, trying again...\n");
402  i++;
403  usleep(300000);
404  }
405  printf("cannot allocate memory, system overloaded.\n");
406  exit(-1);
407 }
#define NULL
Definition: resample.c:96

◆ get_stack_by_bc()

struct misdn_stack* get_stack_by_bc ( struct misdn_bchannel bc)

Definition at line 152 of file isdn_lib.c.

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

Referenced by clean_up_bc(), create_process(), dec_ie_channel_id(), enc_ie_channel_id(), handle_bchan(), handle_event_te(), manager_bchannel_activate(), manager_bchannel_deactivate(), manager_clean_bc(), manager_ec_disable(), manager_ec_enable(), misdn_lib_log_ies(), misdn_lib_release(), misdn_lib_send_event(), misdn_lib_tx2misdn_frm(), parse_release_complete(), parse_restart(), send_msg(), and setup_bc().

153 {
154  struct misdn_stack *stack = get_misdn_stack();
155 
156  if (!bc)
157  return NULL;
158 
159  for ( ; stack; stack = stack->next) {
160  if (bc->port == stack->port)
161  return stack;
162  }
163 
164  return NULL;
165 }
struct misdn_stack * get_misdn_stack(void)
Definition: isdn_lib.c:4698
#define NULL
Definition: resample.c:96
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct misdn_stack * next
Next stack in the list of stacks.
int port
Logical Layer 1 port associated with this stack.

◆ isdn_get_info()

char* isdn_get_info ( struct isdn_msg  msgs[],
enum event_e  event,
int  nt 
)

Definition at line 1734 of file isdn_msg_parser.c.

References EVENT_BCHAN_ACTIVATED, EVENT_BCHAN_ACTIVATED_INFO, EVENT_BCHAN_DATA, EVENT_BCHAN_DATA_INFO, EVENT_BCHAN_ERROR, EVENT_BCHAN_ERROR_INFO, EVENT_CLEAN_INFO, EVENT_CLEANUP, EVENT_DTMF_TONE, EVENT_DTMF_TONE_INFO, EVENT_NEW_BC, EVENT_NEW_BC_INFO, EVENT_NEW_CHANNEL, EVENT_NEW_CHANNEL_INFO, EVENT_NEW_L3ID, EVENT_NEW_L3ID_INFO, EVENT_PORT_ALARM, EVENT_PORT_ALARM_INFO, EVENT_TONE_GENERATE, EVENT_TONE_GENERATE_INFO, isdn_msg::info, isdn_msg_get_index_by_event(), and NULL.

Referenced by handle_event_nt(), handle_frm_te(), manager_isdn_get_info(), and misdn_lib_send_event().

1735 {
1736  int i=isdn_msg_get_index_by_event(msgs, event, nt);
1737 
1738  if(i>=0) return msgs[i].info;
1739 
1740  if (event == EVENT_CLEANUP) return EVENT_CLEAN_INFO;
1742  if (event == EVENT_NEW_L3ID) return EVENT_NEW_L3ID_INFO;
1743  if (event == EVENT_NEW_BC) return EVENT_NEW_BC_INFO;
1750 
1751  return NULL;
1752 }
char * info
char EVENT_DTMF_TONE_INFO[]
Definition: astman.c:222
char EVENT_NEW_L3ID_INFO[]
char EVENT_BCHAN_ACTIVATED_INFO[]
#define NULL
Definition: resample.c:96
char EVENT_NEW_CHANNEL_INFO[]
char EVENT_BCHAN_ERROR_INFO[]
int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt)
char EVENT_NEW_BC_INFO[]
char EVENT_PORT_ALARM_INFO[]
char EVENT_BCHAN_DATA_INFO[]
int nt
TRUE if NT side of protocol (TE otherwise)
char EVENT_TONE_GENERATE_INFO[]
char EVENT_CLEAN_INFO[]

◆ isdn_msg_build_event()

msg_t* isdn_msg_build_event ( struct isdn_msg  msgs[],
struct misdn_bchannel bc,
enum event_e  event,
int  nt 
)

Definition at line 1763 of file isdn_msg_parser.c.

References isdn_msg_get_index_by_event(), isdn_msg::msg_builder, and NULL.

Referenced by misdn_lib_send_event().

1764 {
1765  int i=isdn_msg_get_index_by_event(msgs, event, nt);
1766  if(i<0) return NULL;
1767 
1768  return msgs[i].msg_builder(msgs, bc, nt);
1769 }
Definition: astman.c:222
#define NULL
Definition: resample.c:96
msg_t *(* msg_builder)(struct isdn_msg *msgs, struct misdn_bchannel *bc, int nt)
int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt)
int nt
TRUE if NT side of protocol (TE otherwise)

◆ isdn_msg_get_event()

enum event_e isdn_msg_get_event ( struct isdn_msg  msgs[],
msg_t *  frm,
int  nt 
)

Definition at line 1708 of file isdn_msg_parser.c.

References isdn_msg::event, EVENT_UNKNOWN, and isdn_msg_get_index().

Referenced by handle_event_nt(), and handle_frm_te().

1709 {
1710  int i=isdn_msg_get_index(msgs, msg, nt);
1711  if(i>=0) return msgs[i].event;
1712  return EVENT_UNKNOWN;
1713 }
enum event_e event
int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt)
int nt
TRUE if NT side of protocol (TE otherwise)

◆ isdn_msg_get_index()

int isdn_msg_get_index ( struct isdn_msg  msgs[],
msg_t *  msg,
int  nt 
)

INTERFACE FCTS

Definition at line 1676 of file isdn_msg_parser.c.

References isdn_msg::misdn_msg, and msgs_max.

Referenced by isdn_msg_get_event(), isdn_msg_get_info(), and isdn_msg_parse_event().

1677 {
1678  int i;
1679 
1680  if (nt){
1681  mISDNuser_head_t *hh = (mISDNuser_head_t*)msg->data;
1682 
1683  for (i=0; i< msgs_max -1; i++) {
1684  if ( (hh->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i;
1685  }
1686 
1687  } else {
1688  iframe_t *frm = (iframe_t*)msg->data;
1689 
1690  for (i=0; i< msgs_max -1; i++)
1691  if ( (frm->prim&COMMAND_MASK)==(msgs[i].misdn_msg&COMMAND_MASK)) return i;
1692  }
1693 
1694  return -1;
1695 }
#define msgs_max
int nt
TRUE if NT side of protocol (TE otherwise)
unsigned long misdn_msg

◆ isdn_msg_get_index_by_event()

int isdn_msg_get_index_by_event ( struct isdn_msg  msgs[],
enum event_e  event,
int  nt 
)

Definition at line 1697 of file isdn_msg_parser.c.

References cb_log, and msgs_max.

Referenced by isdn_get_info(), and isdn_msg_build_event().

1698 {
1699  int i;
1700  for (i=0; i< msgs_max; i++)
1701  if ( event == msgs[i].event) return i;
1702 
1703  cb_log(10,0, "get_index: event not found!\n");
1704 
1705  return -1;
1706 }
#define msgs_max
Definition: astman.c:222
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ isdn_msg_get_info()

char* isdn_msg_get_info ( struct isdn_msg  msgs[],
msg_t *  msg,
int  nt 
)

Definition at line 1715 of file isdn_msg_parser.c.

References isdn_msg::info, isdn_msg_get_index(), and NULL.

1716 {
1717  int i=isdn_msg_get_index(msgs, msg, nt);
1718  if(i>=0) return msgs[i].info;
1719  return NULL;
1720 }
char * info
#define NULL
Definition: resample.c:96
int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt)
int nt
TRUE if NT side of protocol (TE otherwise)

◆ isdn_msg_parse_event()

int isdn_msg_parse_event ( struct isdn_msg  msgs[],
msg_t *  frm,
struct misdn_bchannel bc,
int  nt 
)

Definition at line 1754 of file isdn_msg_parser.c.

References isdn_msg_get_index(), and isdn_msg::msg_parser.

Referenced by handle_event_nt(), and handle_frm_te().

1755 {
1756  int i=isdn_msg_get_index(msgs, msg, nt);
1757  if(i<0) return -1;
1758 
1759  msgs[i].msg_parser(msgs, msg, bc, nt);
1760  return 0;
1761 }
int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *msg, int nt)
int nt
TRUE if NT side of protocol (TE otherwise)
void(* msg_parser)(struct isdn_msg *msgs, msg_t *msg, struct misdn_bchannel *bc, int nt)