b1c407c8b2eb5425a1205ab68f9fbc98019dc299
[lcr.git] / main.h
1 /*****************************************************************************\
2 **                                                                           **
3 ** Linux Call Router                                                         **
4 **                                                                           **
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg                                              **
7 **                                                                           **
8 ** Header file for defining fixed values for the current version             **
9 **                                                                           **
10 \*****************************************************************************/ 
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <stdarg.h>
15 #include <unistd.h>
16 #include <string.h>
17 #include <signal.h>
18 #include <time.h>
19 #include <fcntl.h>
20 #include <errno.h>
21 #include <pthread.h>
22 #include <dirent.h>
23 #include <math.h>
24 #include <sys/time.h>
25 #include <sys/types.h>
26 #include <sys/wait.h>
27 #include <sys/stat.h>
28 #include <sys/ioctl.h>
29 #include <sys/file.h>
30 #include <sys/mman.h>
31 #include <sys/resource.h>
32 #include <sys/socket.h>
33 #include <sys/un.h>
34
35 #define NAME            "LCR"
36
37 #define VERSION_STRING  VERSION
38
39 extern int memuse;
40 extern int mmemuse;
41 extern int cmemuse;
42 extern int ememuse;
43 extern int pmemuse;
44 extern int amemuse;
45 extern int rmemuse;
46 extern int classuse;
47 extern int fduse;
48 extern int fhuse;
49
50 //extern pthread_mutex_t mutex_lcr; // lcr process mutex
51
52 extern FILE *debug_fp;
53
54 #define PDEBUG(mask, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, mask, fmt, ## arg)
55 #define PERROR(fmt, arg...) _printerror(__FILE__, __FUNCTION__, __LINE__, fmt, ## arg)
56 #define PDEBUG_RUNTIME(mask, fmt, arg...) _printdebug(NULL, NULL, 0, mask, fmt, ## arg)
57 #define PERROR_RUNTIME(fmt, arg...) _printerror(NULL, NULL, 0, fmt, ## arg)
58 void _printdebug(const char *file, const char *function, int line, unsigned int mask, const char *fmt, ...);
59 void _printerror(const char *file, const char *function, int line, const char *fmt, ...);
60 #define DEBUG_FUNC
61 void debug(const char *file, const char *function, int line, const char *prefix, char *buffer);
62
63 #define DEBUG_CONFIG    0x0001
64 #define DEBUG_MSG       0x0002
65 #define DEBUG_STACK     0x0004
66 #define DEBUG_BCHANNEL  0x0008
67 #define DEBUG_PORT      0x0100
68 #define DEBUG_ISDN      0x0110
69 #define DEBUG_GSM       0x0120
70 #define DEBUG_SS5       0x0140
71 #define DEBUG_VBOX      0x0180
72 #define DEBUG_SIP       0x10100
73 #define DEBUG_EPOINT    0x0200
74 #define DEBUG_JOIN      0x0400
75 #define DEBUG_VERSATEL  0x0800
76 #define DEBUG_CRYPT     0x1000
77 #define DEBUG_ROUTE     0x2000
78 #define DEBUG_IDLETIME  0x4000
79
80 // check any faulty malloc
81 #define MALLOC_CHECK_   1
82
83 /*
84  * one of the bits must be enabled in order to write log files
85  */
86 #define DEBUG_LOG       0xfffff
87
88 /*
89  * load transmit buffer to avoid gaps at the beginning due to jitter
90  */
91 #define ISDN_LOAD       1024 // samples
92
93 /* give sendmail program. if not inside $PATH, give absolute path here (e.g. "/usr/sbin/sendmail")
94  */
95 #define SENDMAIL        "sendmail"
96
97 /* leave it above 1024, because lower values can be unsafe, higher valuse cause
98  * data larger than 512 bytes of hex strings.
99  */
100 #define RSA_BITS        1536
101
102 /* 'goto' or 'menu' actions may cause infinite loops. they will be prevented by this limit.
103  * Also other recursions, like redialing the 'redial' action must be prevented.
104  * increase it ONLY IF you have a deeper tree of rule sets, than the value given here.
105  */
106 #define RULE_NESTING    10
107
108 /* to debug core bridging, rather than mISDN dsp bridging, enable.
109  * this is for debugging only, bridging conferences will not work
110  */
111 //#define DEBUG_COREBRIDGE
112
113 /* special debugging for buffer overflow bugs
114  * note: whenever a buffer gets strange values, the budetect function must
115  * be modified to detect the change of these values. whenever it is detected,
116  * an error message is given at budetect function.
117  */
118 //#define BUDETECT_DEF
119
120 /* internal limit of payload type in a message */
121
122 #ifdef BUDETECT_DEF
123  #define BUDETECT       budetect(__FILE__, __LINE__, __FUNCTION__);
124  void budetect(const char *file, int line, const char *function);
125 #else
126  #define BUDETECT       ;
127 #endif
128
129 #ifdef WITH_MISDN
130  #ifdef __cplusplus
131   extern "C" {
132  #endif
133  #include <mISDN/mbuffer.h>
134  #ifdef __cplusplus
135   }
136  #endif
137 #endif
138 #include "macro.h"
139 #include "select.h"
140 #include "options.h"
141 #include "interface.h"
142 #include "extension.h"
143 #include "message.h"
144 #include "endpoint.h"
145 #include "endpointapp.h"
146 #include "apppbx.h"
147 #include "appbridge.h"
148 #include "callerid.h"
149 #include "route.h"
150 #include "port.h"
151 #include "remote.h"
152 #ifdef WITH_MISDN
153 #include "mISDN.h"
154 #include "dss1.h"
155 #include "fxs.h"
156 #endif
157 #if defined WITH_GSM_BS || defined WITH_GSM_MS
158 #include "gsm.h"
159 #endif
160 #ifdef WITH_GSM_BS
161 #include "gsm_bs.h"
162 #endif
163 #ifdef WITH_GSM_MS
164 #include "gsm_ms.h"
165 #endif
166 #ifdef WITH_SS5
167 #include "ss5_encode.h"
168 #include "ss5_decode.h"
169 #include "ss5.h"
170 #endif
171 #ifdef WITH_SIP
172 #include "sip.h"
173 #endif
174 #include "vbox.h"
175 #include "join.h"
176 #include "joinpbx.h"
177 #include "cause.h"
178 #include "alawulaw.h"
179 #include "tones.h"
180 #include "crypt.h"
181 #include "socket_server.h"
182 #include "trace.h"
183
184 extern int quit;
185
186 #define DIRECTION_NONE  0
187 #define DIRECTION_OUT   1
188 #define DIRECTION_IN    2
189
190 #if 0
191 struct lcr_fdset {
192         struct mISDNport *mISDNport;
193         int b_index;
194 };
195 #endif
196