Asterisk - The Open Source Telephony Project  18.5.0
isdn_lib_intern.h
Go to the documentation of this file.
1 #ifndef ISDN_LIB_INTERN
2 #define ISDN_LIB_INTERN
3 
4 
5 #include <mISDNuser/mISDNlib.h>
6 #include <mISDNuser/isdn_net.h>
7 #include <mISDNuser/l3dss1.h>
8 #include <mISDNuser/net_l3.h>
9 
10 #include <pthread.h>
11 
12 #include "isdn_lib.h"
13 
14 #ifndef MISDNUSER_VERSION_CODE
15 #error "You need a newer version of mISDNuser ..."
16 #elif MISDNUSER_VERSION_CODE < MISDNUSER_VERSION(1, 0, 3)
17 #error "You need a newer version of mISDNuser ..."
18 #endif
19 
20 
21 #define QI_ELEMENT(a) a.off
22 
23 
24 #ifndef mISDNUSER_HEAD_SIZE
25 
26 #define mISDNUSER_HEAD_SIZE (sizeof(mISDNuser_head_t))
27 /*#define mISDNUSER_HEAD_SIZE (sizeof(mISDN_head_t))*/
28 #endif
29 
30 
31 #if 0
32 ibuffer_t *astbuf; /* Not used */
33 ibuffer_t *misdnbuf; /* Not used */
34 #endif
35 
36 struct send_lock {
38 };
39 
40 
41 struct isdn_msg {
42  unsigned long misdn_msg;
43 
44  enum event_e event;
45 
46  void (*msg_parser)(struct isdn_msg *msgs, msg_t *msg, struct misdn_bchannel *bc, int nt);
47  msg_t *(*msg_builder)(struct isdn_msg *msgs, struct misdn_bchannel *bc, int nt);
48  char *info;
49 } ;
50 
51 /* for isdn_msg_parser.c */
52 msg_t *create_l3msg(int prim, int mt, int dinfo , int size, int nt);
53 
54 #if defined(AST_MISDN_ENHANCEMENTS)
55 /* Max call-completion REGISTER signaling links per stack/port */
56 #define MISDN_MAX_REGISTER_LINKS MAX_BCHANS
57 #else
58 /* Max call-completion REGISTER signaling links per stack/port */
59 #define MISDN_MAX_REGISTER_LINKS 0
60 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
61 
62 #define MAXPROCS 0x100
63 
64 struct misdn_stack {
65  /** is first element because &nst equals &mISDNlist **/
66  net_stack_t nst;
67  manager_t mgr;
69 
70  /*! \brief Stack struct critical section lock. */
72 
73  /*! \brief D Channel mISDN driver stack ID (Parent stack ID) */
74  int d_stid;
75 
76  /*! /brief Number of B channels supported by this port */
77  int b_num;
78 
79  /*! \brief B Channel mISDN driver stack IDs (Child stack IDs) */
80  int b_stids[MAX_BCHANS + 1];
81 
82  /*! \brief TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise) */
83  int ptp;
84 
85  /*! \brief Number of consecutive times PTP Layer 2 declared down */
86  int l2upcnt;
87 
88  int l2_id; /* Not used */
89 
90  /*! \brief Lower layer mISDN ID (addr) (Layer 1/3) */
91  int lower_id;
92 
93  /*! \brief Upper layer mISDN ID (addr) (Layer 2/4) */
94  int upper_id;
95 
96  /*! \brief TRUE if port is blocked */
97  int blocked;
98 
99  /*! \brief TRUE if Layer 2 is UP */
100  int l2link;
101 
102  /*! \brief TRUE if Layer 1 is UP */
103  int l1link;
104 
105  /*! \brief TRUE if restart has been sent to the other side after stack startup */
107 
108  /*! \brief mISDN device handle returned by mISDN_open() */
109  int midev;
110 
111  /*! \brief TRUE if NT side of protocol (TE otherwise) */
112  int nt;
113 
114  /*! \brief TRUE if ISDN-PRI (ISDN-BRI otherwise) */
115  int pri;
116 
117  /*! \brief CR Process ID allocation table. TRUE if ID allocated */
118  int procids[MAXPROCS];
119 
120  /*! \brief Queue of Event messages to send to mISDN */
121  msg_queue_t downqueue;
122  msg_queue_t upqueue; /* No code puts anything on this queue */
123  int busy; /* Not used */
124 
125  /*! \brief Logical Layer 1 port associated with this stack */
126  int port;
127 
128  /*!
129  * \brief B Channel record pool array
130  * (Must be dimensioned the same as struct misdn_stack.channels[])
131  */
133 
134  /*!
135  * \brief Array of B channels in use (a[0] = B1). TRUE if B channel in use.
136  * (Must be dimensioned the same as struct misdn_stack.bc[])
137  */
139 
140  /*! \brief List of held channels */
142 
143  /*! \brief Next stack in the list of stacks */
144  struct misdn_stack *next;
145 };
146 
147 
149 
150 int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *frm, int nt);
151 enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *frm, int nt);
152 int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *frm, struct misdn_bchannel *bc, int nt);
153 char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt);
154 msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt);
155 int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt);
156 char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt);
157 
158 
159 #endif
int upper_id
Upper layer mISDN ID (addr) (Layer 2/4)
#define MISDN_MAX_REGISTER_LINKS
char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt)
pthread_mutex_t lock
#define bc
struct misdn_stack * get_stack_by_bc(struct misdn_bchannel *bc)
Definition: isdn_lib.c:152
int midev
mISDN device handle returned by mISDN_open()
msg_queue_t upqueue
char * info
B channel control structure.
Definition: isdn_lib.h:324
Definition: astman.c:222
pthread_mutex_t nstlock
net_stack_t nst
void * astbuf
Not used. Contents are setup but not used.
Definition: isdn_lib.h:439
#define pthread_mutex_t
Definition: lock.h:620
enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *frm, int nt)
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
int l1link
TRUE if Layer 1 is UP.
msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt)
int lower_id
Lower layer mISDN ID (addr) (Layer 1/3)
int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *frm, int nt)
int d_stid
D Channel mISDN driver stack ID (Parent stack ID)
int nt
TRUE if NT side of protocol (TE otherwise)
Definition: isdn_lib.h:364
static struct channel_usage channels
Interface to mISDN.
int restart_sent
TRUE if restart has been sent to the other side after stack startup.
int l2link
TRUE if Layer 2 is UP.
msg_queue_t downqueue
Queue of Event messages to send to mISDN.
int l2upcnt
Number of consecutive times PTP Layer 2 declared down.
int ptp
TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise)
manager_t mgr
#define MAXPROCS
msg_t * create_l3msg(int prim, int mt, int dinfo, int size, int nt)
Definition: isdn_lib.c:371
int nt
TRUE if NT side of protocol (TE otherwise)
unsigned long misdn_msg
struct misdn_stack * next
Next stack in the list of stacks.
struct misdn_bchannel * holding
List of held channels.
int blocked
TRUE if port is blocked.
int port
Logical Layer 1 port associated with this stack.
int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *frm, struct misdn_bchannel *bc, int nt)
#define MAX_BCHANS
Definition: isdn_lib.h:76
char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt)
pthread_mutex_t st_lock
Stack struct critical section lock.
int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt)
event_e
Definition: isdn_lib.h:119