Ports can now be specified by number or by name.
[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
33 #define NAME            "LCR"
34
35 #define DEFAULT_ENDPOINT_APP EndpointAppPBX
36
37 #define VERSION_STRING  "1.1 (Summer 2008)"
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(__FUNCTION__, __LINE__, mask, fmt, ## arg)
55 #define PERROR(fmt, arg...) _printerror(__FUNCTION__, __LINE__, fmt, ## arg)
56 #define PDEBUG_RUNTIME(mask, fmt, arg...) _printdebug(NULL, 0, mask, fmt, ## arg)
57 #define PERROR_RUNTIME(fmt, arg...) _printerror(NULL, 0, fmt, ## arg)
58 void _printdebug(const char *function, int line, unsigned int mask, const char *fmt, ...);
59 void _printerror(const char *function, int line, const char *fmt, ...);
60 #define DEBUG_FUNC
61 void debug(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_KNOCK   0x0140
70 #define DEBUG_VBOX      0x0180
71 #define DEBUG_EPOINT    0x0200
72 #define DEBUG_JOIN      0x0400
73 #define DEBUG_VERSATEL  0x0800
74 #define DEBUG_CRYPT     0x1000
75 #define DEBUG_ROUTE     0x2000
76 #define DEBUG_IDLETIME  0x4000
77 #define DEBUG_LOG       0x7fff
78
79 // check any faulty malloc
80 #define MALLOC_CHECK_   1
81
82 /*
83  * one of the bits must be enabled in order to write log files
84  */
85 #define DEBUG_LOG       0x7fff
86
87 /*
88  * load transmit buffer to avoid gaps at the beginning due to jitter
89  * also the maximum load that will be kept in tx-buffer
90  * also the (minimum) number of data to transmit in a frame
91  */
92 #define ISDN_LOAD       1024 // samples
93 #define ISDN_MAXLOAD    2048 // samples
94
95 /* give sendmail program. if not inside $PATH, give absolute path here (e.g. "/usr/sbin/sendmail")
96  */
97 #define SENDMAIL        "sendmail"
98
99 /* leave it above 1024, because lower values can be unsafe, higher valuse cause
100  * data larger than 512 bytes of hex strings.
101  */
102 #define RSA_BITS        1536
103
104 /* 'goto' or 'menu' actions may cause infinite loops. they will be prevented by this limit.
105  * Also other recursions, like redialing the 'redial' action must be prevented.
106  * increase it ONLY IF you have a deeper tree of rule sets, than the value given here.
107  */
108 #define RULE_NESTING    10
109
110 /* to debug core bridging, rather than mISDN dsp bridging, enable.
111  * this is for debugging only, bridging conferences will not work
112  */
113 //#define DEBUG_COREBRIDGE
114
115 /* special debugging for buffer overflow bugs
116  * note: whenever a buffer gets strange values, the budetect function must
117  * be modified to detect the change of these values. whenever it is detected,
118  * an error message is given at budetect function.
119  */
120 //#define BUDETECT_DEF
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 __cplusplus
130 extern "C" {
131 #endif
132 #include <mbuffer.h>
133 #ifdef __cplusplus
134 }
135 #endif
136 #include "macro.h"
137 #include "options.h"
138 #include "interface.h"
139 #include "extension.h"
140 #include "message.h"
141 #include "endpoint.h"
142 #include "endpointapp.h"
143 #include "apppbx.h"
144 #include "callerid.h"
145 #include "route.h"
146 #include "port.h"
147 #include "mISDN.h"
148 #include "dss1.h"
149 #include "vbox.h"
150 #include "join.h"
151 #include "joinpbx.h"
152 #include "joinremote.h"
153 #include "cause.h"
154 #include "alawulaw.h"
155 #include "tones.h"
156 #include "crypt.h"
157 #include "socket_server.h"
158 #include "trace.h"
159
160 extern double now_d;
161 extern time_t now;
162 extern struct tm *now_tm;
163 extern struct timeval now_tv;
164 extern struct timezone now_tz;
165
166 #define DIRECTION_NONE  0
167 #define DIRECTION_OUT   1
168 #define DIRECTION_IN    2
169
170 #if 0
171 struct lcr_fdset {
172         struct mISDNport *mISDNport;
173         int b_index;
174 };
175 #endif
176