1 | #ifndef GLOBALS_H_ |
---|
2 | #define GLOBALS_H_ |
---|
3 | |
---|
4 | #define _GNU_SOURCE //needed for PTHREAD_MUTEX_RECURSIVE on some plattforms and maybe other things; do not remove |
---|
5 | #include <stdlib.h> |
---|
6 | #include <stdio.h> |
---|
7 | #include <stdbool.h> |
---|
8 | #include <stddef.h> |
---|
9 | #include <assert.h> |
---|
10 | #include <fcntl.h> |
---|
11 | #include <sys/ioctl.h> |
---|
12 | #include <poll.h> |
---|
13 | #include <ctype.h> |
---|
14 | #include <sys/types.h> |
---|
15 | #include <sys/stat.h> |
---|
16 | #include <sys/wait.h> |
---|
17 | #include <unistd.h> |
---|
18 | #include <sys/mman.h> |
---|
19 | #include <stdarg.h> |
---|
20 | #include <time.h> |
---|
21 | #include <sys/time.h> |
---|
22 | #include <limits.h> |
---|
23 | #include <pwd.h> |
---|
24 | #include <netinet/tcp.h> |
---|
25 | #include <sys/socket.h> |
---|
26 | #include <netinet/in.h> |
---|
27 | #include <arpa/inet.h> |
---|
28 | #include <netdb.h> |
---|
29 | #include <string.h> |
---|
30 | #include <signal.h> |
---|
31 | #include <errno.h> |
---|
32 | #include <pthread.h> |
---|
33 | #include <dirent.h> |
---|
34 | #include <termios.h> |
---|
35 | #include <inttypes.h> |
---|
36 | |
---|
37 | /* |
---|
38 | * The following hack is taken from Linux: include/linux/kconfig.h |
---|
39 | * Original comment follows: |
---|
40 | * Getting something that works in C and CPP for an arg that may or may |
---|
41 | * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1" |
---|
42 | * we match on the placeholder define, insert the "0," for arg1 and generate |
---|
43 | * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one). |
---|
44 | * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when |
---|
45 | * the last step cherry picks the 2nd arg, we get a zero. |
---|
46 | */ |
---|
47 | #define __ARG_PLACEHOLDER_1 0, |
---|
48 | #define config_enabled(cfg) _config_enabled(cfg) |
---|
49 | #define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) |
---|
50 | #define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) |
---|
51 | #define ___config_enabled(__ignored, val, ...) val |
---|
52 | |
---|
53 | #include "config.h" |
---|
54 | |
---|
55 | #if defined(WITH_SSL) && !defined(WITH_LIBCRYPTO) |
---|
56 | # define WITH_LIBCRYPTO 1 |
---|
57 | #endif |
---|
58 | |
---|
59 | #if defined(__CYGWIN__) || defined(__arm__) || defined(__SH4__) || defined(__MIPS__) || defined(__MIPSEL__) || defined(__powerpc__) |
---|
60 | # define CS_LOGFILE "/dev/tty" |
---|
61 | #endif |
---|
62 | |
---|
63 | #if defined(__AIX__) || defined(__SGI__) || defined(__OSF__) || defined(__HPUX__) || defined(__SOLARIS__) || defined(__APPLE__) |
---|
64 | # define NEED_DAEMON |
---|
65 | #endif |
---|
66 | |
---|
67 | #if defined(__AIX__) || defined(__SGI__) || defined(__OSF__) || defined(__HPUX__) || defined(__SOLARIS__) || defined(__CYGWIN__) |
---|
68 | # define NO_ENDIAN_H |
---|
69 | #endif |
---|
70 | |
---|
71 | #if defined(__AIX__) || defined(__SGI__) |
---|
72 | # define socklen_t unsigned long |
---|
73 | #endif |
---|
74 | |
---|
75 | #if defined(__SOLARIS__) || defined(__FreeBSD__) |
---|
76 | # define BSD_COMP |
---|
77 | #endif |
---|
78 | |
---|
79 | #if defined(__HPUX__) |
---|
80 | # define _XOPEN_SOURCE_EXTENDED |
---|
81 | #endif |
---|
82 | |
---|
83 | #if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(s6_addr32) |
---|
84 | #define s6_addr32 __u6_addr.__u6_addr32 |
---|
85 | #endif |
---|
86 | |
---|
87 | #ifdef __ANDROID__ |
---|
88 | #ifndef in_port_t |
---|
89 | #define in_port_t uint16_t |
---|
90 | #endif |
---|
91 | #define tcdrain(fd) ioctl(fd, TCSBRK, 1) |
---|
92 | #endif |
---|
93 | |
---|
94 | #ifdef __uClinux__ |
---|
95 | #define fork() 0 |
---|
96 | #endif |
---|
97 | |
---|
98 | #include "cscrypt/aes.h" |
---|
99 | |
---|
100 | #ifndef uchar |
---|
101 | typedef unsigned char uchar; |
---|
102 | #endif |
---|
103 | |
---|
104 | #ifdef IPV6SUPPORT |
---|
105 | #define IN_ADDR_T struct in6_addr |
---|
106 | #define SOCKADDR sockaddr_storage |
---|
107 | #define ADDR_ANY in6addr_any |
---|
108 | #else |
---|
109 | #define IN_ADDR_T in_addr_t |
---|
110 | #define SOCKADDR sockaddr_in |
---|
111 | #define ADDR_ANY INADDR_ANY |
---|
112 | #endif |
---|
113 | |
---|
114 | #ifndef NO_ENDIAN_H |
---|
115 | #if defined(__APPLE__) |
---|
116 | #include <machine/endian.h> |
---|
117 | #define __BYTE_ORDER __DARWIN_BYTE_ORDER |
---|
118 | #define __BIG_ENDIAN __DARWIN_BIG_ENDIAN |
---|
119 | #define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN |
---|
120 | #elif defined(__FreeBSD__) |
---|
121 | #include <sys/endian.h> |
---|
122 | #define __BYTE_ORDER _BYTE_ORDER |
---|
123 | #define __BIG_ENDIAN _BIG_ENDIAN |
---|
124 | #define __LITTLE_ENDIAN _LITTLE_ENDIAN |
---|
125 | #else |
---|
126 | #include <endian.h> |
---|
127 | #include <byteswap.h> |
---|
128 | #endif |
---|
129 | #endif |
---|
130 | |
---|
131 | /* =========================== |
---|
132 | * macros |
---|
133 | * =========================== */ |
---|
134 | // Prevent use of unsafe functions (doesn't work for MacOSX) |
---|
135 | #if !defined(__APPLE__) |
---|
136 | #define strcpy(a,b) UNSAFE_STRCPY_USE_CS_STRNCPY_INSTEAD() |
---|
137 | #define sprintf(a,...) UNSAFE_SPRINTF_USE_SNPRINTF_INSTEAD() |
---|
138 | #define strtok(a,b,c) UNSAFE_STRTOK_USE_STRTOK_R_INSTEAD() |
---|
139 | #define gmtime(a) UNSAFE_GMTIME_NOT_THREADSAFE_USE_CS_GMTIME_R() |
---|
140 | #define localtime(a) UNSAFE_LOCALTIME_NOT_THREADSAFE_USE_LOCALTIME_R() |
---|
141 | #define asctime(a) UNSAFE_ASCTIME_NOT_THREADSAFE_USE_ASCTIME_R() |
---|
142 | #define ctime(a) UNSAFE_CTIME_NOT_THREADSAFE_USE_CS_CTIME_R() |
---|
143 | #define gethostbyaddr(a,b,c) UNSAFE_GETHOSTBYADDR_NOT_THREADSAFE_USE_GETADDRINFO() |
---|
144 | #define gethostent(a) UNSAFE_GETHOSTENT_NOT_THREADSAFE() |
---|
145 | #define getprotobyname(a) UNSAFE_GETPROTOBYNAME_NOT_THREADSAFE_USE_GETPROTOBYNAME_R() |
---|
146 | #define getservbyname(a,b) UNSAFE_GETSERVBYNAME_NOT_THREADSAFE_USE_GETSERVBYNAME_R() |
---|
147 | #define getservbyport(a,b) UNSAFE_GETSERVBYPORT_NOT_THREADSAFE_USE_GETSERVBYPORT_R() |
---|
148 | #define getservent() UNSAFE_GETSERVENT_NOT_THREADSAFE_USE_GETSERVENT_R() |
---|
149 | #define getnetbyname(a) UNSAFE_GETNETBYNAME_NOT_THREADSAFE_USE_GETNETBYNAME_R |
---|
150 | #define getnetbyaddr(a,b) UNSAFE_GETNETBYADDR_NOT_THREADSAFE_USE_GETNETBYADDR_R |
---|
151 | #define getnetent() UNSAFE_GETNETENT_NOT_THREADSAFE_USE_GETNETENT_R |
---|
152 | #define getrpcbyname(a) UNSAFE_GETRPCBYNAME_NOT_THREADSAFE_USE_GETRPCBYNAME_R |
---|
153 | #define getrpcbynumber(a) UNSAFE_GETRPCBYNUMBER_NOT_THREADSAFE_USE_GETRPCBYNUMBER_R |
---|
154 | #define getrpcent() UNSAFE_GETRPCENT_NOT_THREADSAFE_USE_GETRPCENT_R |
---|
155 | #define ctermid(a) UNSAFE_CTERMID_NOT_THREADSAFE_USE_CTERMID_R |
---|
156 | #define tmpnam(a) UNSAFE_TMPNAM_NOT_THREADSAFE |
---|
157 | #define tempnam(a,b) UNSAFE_TEMPNAM_NOT_THREADSAFE |
---|
158 | #define getlogin() UNSAFE_GETLOGIN_NOT_THREADSAFE_USE_GETLOGIN_R |
---|
159 | #define getpwnam(a) UNSAFE_GETPWNAM_NOT_THREADSAFE_USE_GETPWNAM_R |
---|
160 | #define getpwent() UNSAFE_GETPWENT_NOT_THREADSAFE_USE_GETPWENT_R |
---|
161 | #define fgetpwent(a) UNSAFE_FGETPWENT_NOT_THREADSAFE_USE_FGETPWENT_R |
---|
162 | #ifndef __ANDROID__ |
---|
163 | #define getpwuid(a) UNSAFE_GETPWUID_NOT_THREADSAFE_USE_GETPWUID_R |
---|
164 | #endif |
---|
165 | #define getspent() UNSAFE_GETSPENT_NOT_THREADSAFE_USE_GETSPENT_R |
---|
166 | #define getspnam(a) UNSAFE_GETSPNAM_NOT_THREADSAFE_USE_GETSPNAM_R |
---|
167 | #define fgetspent(a) UNSAFE_FGETSPENT_NOT_THREADSAFE_USE_FGETSPENT_R |
---|
168 | #define getgrnam(a) UNSAFE_GETGRNAM_NOT_THREADSAFE_USE_GETGRNAM_R |
---|
169 | #define getgrent() UNSAFE_GETGRENT_NOT_THREADSAFE_USE_GETGRENT_R |
---|
170 | #define getgrgid(a) UNSAFE_GETGRGID_NOT_THREADSAFE_USE_GETGRGID_R |
---|
171 | #define fgetgrent() UNSAFE_FGETGRENT_NOT_THREADSAFE_USE_FGETGRGID_R |
---|
172 | #define fcvt(a,b,c,d) UNSAFE_FCVT_NOT_THREADSAFE_AND_DEPRECATED |
---|
173 | #define ecvt(a,b,c,d) UNSAFE_ECVT_NOT_THREADSAFE_AND_DEPRECATED |
---|
174 | #define gcvt(a,b,c) UNSAFE_GCVT_NOT_THREADSAFE_AND_DEPRECATED |
---|
175 | #define strptime(a,b,c) STRPTIME_NOT_EXISTS_ON_SOME_DM500_DB2() |
---|
176 | #define ftime(a) FTIME_DEPRECATED() |
---|
177 | #define timegm(a) TIMEGM_GNU_SPECIFIC_USE_CS_TIMEGM |
---|
178 | #endif |
---|
179 | |
---|
180 | #ifdef UNUSED |
---|
181 | #elif __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) |
---|
182 | # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) |
---|
183 | #elif defined(__LCLINT__) |
---|
184 | # define UNUSED(x) /*@unused@*/ x |
---|
185 | #else |
---|
186 | # define UNUSED(x) x |
---|
187 | #endif |
---|
188 | |
---|
189 | #if __GNUC__ >= 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
---|
190 | # define MUST_CHECK_RESULT __attribute__((warn_unused_result)) |
---|
191 | #endif |
---|
192 | |
---|
193 | #ifdef OK |
---|
194 | #undef OK |
---|
195 | #endif |
---|
196 | |
---|
197 | #ifdef ERROR |
---|
198 | #undef ERROR |
---|
199 | #endif |
---|
200 | |
---|
201 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
---|
202 | |
---|
203 | #ifdef WITH_DEBUG |
---|
204 | # define call(arg) \ |
---|
205 | if (arg) { \ |
---|
206 | cs_debug_mask(D_TRACE, "ERROR, function call %s returns error.",#arg); \ |
---|
207 | return ERROR; \ |
---|
208 | } |
---|
209 | #else |
---|
210 | # define call(arg) \ |
---|
211 | if (arg) { \ |
---|
212 | return ERROR; \ |
---|
213 | } |
---|
214 | #endif |
---|
215 | |
---|
216 | //checking if (X) free(X) unneccessary since freeing a null pointer doesnt do anything |
---|
217 | #define NULLFREE(X) {if (X) {void *tmpX=X; X=NULL; free(tmpX); }} |
---|
218 | |
---|
219 | /* =========================== |
---|
220 | * constants |
---|
221 | * =========================== */ |
---|
222 | #define CS_VERSION "1.20-unstable_svn" |
---|
223 | #ifndef CS_SVN_VERSION |
---|
224 | # define CS_SVN_VERSION "test" |
---|
225 | #endif |
---|
226 | #ifndef CS_TARGET |
---|
227 | # define CS_TARGET "unknown" |
---|
228 | #endif |
---|
229 | #ifndef CS_CONFDIR |
---|
230 | #define CS_CONFDIR "/usr/local/etc" |
---|
231 | #endif |
---|
232 | #ifndef CS_LOGFILE |
---|
233 | #define CS_LOGFILE "/var/log/oscam.log" |
---|
234 | #endif |
---|
235 | #define CS_QLEN 128 // size of request queue |
---|
236 | #define CS_MAXCAIDTAB 32 // max. caid-defs/user |
---|
237 | #define CS_MAXTUNTAB 100 // max. betatunnel mappings |
---|
238 | #define CS_MAXPROV 32 |
---|
239 | #define CS_MAXPORTS 32 // max server ports |
---|
240 | #define CS_MAXFILTERS 16 |
---|
241 | #define CS_MAX_CAIDVALUETAB 16 |
---|
242 | #define CS_CLIENT_HASHBUCKETS 32 |
---|
243 | |
---|
244 | #define CS_ECMSTORESIZE 16 // use MD5() |
---|
245 | #define CS_EMMSTORESIZE 16 // use MD5() |
---|
246 | #define CS_CLIENT_TIMEOUT 5000 |
---|
247 | #define CS_CLIENT_MAXIDLE 120 |
---|
248 | #define CS_BIND_TIMEOUT 120 |
---|
249 | #define CS_DELAY 0 |
---|
250 | #define CS_ECM_RINGBUFFER_MAX 0x10 // max size for ECM last responsetimes ringbuffer. Keep this set to power of 2 values! |
---|
251 | |
---|
252 | #ifndef PTHREAD_STACK_MIN |
---|
253 | #define PTHREAD_STACK_MIN 64000 |
---|
254 | #endif |
---|
255 | #define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN+32768 |
---|
256 | |
---|
257 | #define CS_EMMCACHESIZE 127 //nr of EMMs that each client will cache; cache is per client, so memory-expensive... |
---|
258 | #define MSGLOGSIZE 64 //size of string buffer for a ecm to return messages |
---|
259 | |
---|
260 | #define D_TRACE 0x0001 // Generate very detailed error/trace messages per routine |
---|
261 | #define D_ATR 0x0002 // Debug ATR parsing, dump of ecm, cw |
---|
262 | #define D_READER 0x0004 // Debug Reader/Proxy Process |
---|
263 | #define D_CLIENT 0x0008 // Debug Client Process |
---|
264 | #define D_IFD 0x0010 // Debug IFD+protocol |
---|
265 | #define D_DEVICE 0x0020 // Debug Reader I/O |
---|
266 | #define D_EMM 0x0040 // Dumps EMM |
---|
267 | #define D_DVBAPI 0x0080 // Debug DVBAPI |
---|
268 | #define D_LB 0x0100 // Debug Loadbalancer/ECM handler |
---|
269 | #define D_CACHEEX 0x0200 // Debug CACHEEX |
---|
270 | #define D_CLIENTECM 0x0400 // Debug Client ECMs |
---|
271 | #define D_CSP 0x0800 // Debug CSP |
---|
272 | #define D_CWC 0x1000 // Debug CWC |
---|
273 | #define D_ALL_DUMP 0xFFFF // dumps all |
---|
274 | |
---|
275 | #define MAX_DEBUG_LEVELS 13 |
---|
276 | |
---|
277 | #define R_DB2COM1 0x1 // Reader Dbox2 @ com1 |
---|
278 | #define R_DB2COM2 0x2 // Reader Dbox2 @ com1 |
---|
279 | #define R_SC8in1 0x3 // Reader Sc8in1 or MCR |
---|
280 | #define R_MP35 0x4 // AD-Teknik Multiprogrammer 3.5 and 3.6 (only usb tested) |
---|
281 | #define R_MOUSE 0x5 // Reader smartcard mouse |
---|
282 | /////////////////// phoenix readers which need baudrate setting and timings need to be guarded by OSCam: BEFORE R_MOUSE |
---|
283 | #define R_INTERNAL 0x6 // Reader smartcard intern |
---|
284 | /////////////////// internal readers (Dreambox, Coolstream, IPBox) are all R_INTERNAL, they are determined compile-time |
---|
285 | /////////////////// readers that do not reed baudrate setting and timings are guarded by reader itself (large buffer built in): AFTER R_SMART |
---|
286 | #define R_SMART 0x7 // Smartreader+ |
---|
287 | #define R_PCSC 0x8 // PCSC |
---|
288 | /////////////////// proxy readers after R_CS378X |
---|
289 | #define R_CAMD35 0x20 // Reader cascading camd 3.5x |
---|
290 | #define R_CAMD33 0x21 // Reader cascading camd 3.3x |
---|
291 | #define R_NEWCAMD 0x22 // Reader cascading newcamd |
---|
292 | #define R_RADEGAST 0x23 // Reader cascading radegast |
---|
293 | #define R_CS378X 0x24 // Reader cascading camd 3.5x TCP |
---|
294 | #define R_CONSTCW 0x25 // Reader for Constant CW |
---|
295 | #define R_CSP 0x26 // Cache CSP |
---|
296 | #define R_GHTTP 0x27 // Reader ghttp |
---|
297 | /////////////////// peer to peer proxy readers after R_CCCAM |
---|
298 | #define R_GBOX 0x30 // Reader cascading gbox |
---|
299 | #define R_CCCAM 0x35 // Reader cascading cccam |
---|
300 | #define R_PANDORA 0x36 // Reader cascading pandora |
---|
301 | #define R_SERIAL 0x80 // Reader serial |
---|
302 | #define R_IS_NETWORK 0x60 |
---|
303 | #define R_IS_CASCADING 0xE0 |
---|
304 | |
---|
305 | #define is_network_reader(__X) (__X->typ & R_IS_NETWORK) |
---|
306 | #define is_cascading_reader(__X) (__X->typ & R_IS_CASCADING) |
---|
307 | |
---|
308 | //ECM rc codes: |
---|
309 | #define E_FOUND 0 |
---|
310 | #define E_CACHE1 1 |
---|
311 | #define E_CACHE2 2 |
---|
312 | #define E_CACHEEX 3 |
---|
313 | ///////above is all found |
---|
314 | #define E_NOTFOUND 4 //for selection of found, use < E_NOTFOUND |
---|
315 | #define E_TIMEOUT 5 |
---|
316 | #define E_SLEEPING 6 |
---|
317 | #define E_FAKE 7 |
---|
318 | #define E_INVALID 8 |
---|
319 | #define E_CORRUPT 9 |
---|
320 | #define E_NOCARD 10 |
---|
321 | #define E_EXPDATE 11 |
---|
322 | #define E_DISABLED 12 |
---|
323 | #define E_STOPPED 13 //for selection of error, use <= E_STOPPED and exclude selection of found |
---|
324 | ///////above is all notfound, some error or problem |
---|
325 | #define E_ALREADY_SENT 101 |
---|
326 | #define E_WAITING 102 |
---|
327 | #define E_99 99 //this code is undocumented |
---|
328 | #define E_UNHANDLED 100 //for selection of unhandled, use >= E_UNHANDLED |
---|
329 | |
---|
330 | #define CS_MAX_MOD 20 |
---|
331 | #define MOD_CONN_TCP 1 |
---|
332 | #define MOD_CONN_UDP 2 |
---|
333 | #define MOD_CONN_NET 3 |
---|
334 | #define MOD_CONN_SERIAL 4 |
---|
335 | #define MOD_NO_CONN 8 |
---|
336 | |
---|
337 | #define MOD_CARDSYSTEM 16 |
---|
338 | #define MOD_ADDON 32 |
---|
339 | |
---|
340 | #define EMM_UNIQUE 1 |
---|
341 | #define EMM_SHARED 2 |
---|
342 | #define EMM_GLOBAL 4 |
---|
343 | #define EMM_UNKNOWN 8 |
---|
344 | |
---|
345 | //Listener Types |
---|
346 | #define LIS_CAMD33TCP 1 |
---|
347 | #define LIS_CAMD35UDP 2 |
---|
348 | #define LIS_CAMD35TCP 4 |
---|
349 | #define LIS_NEWCAMD 8 |
---|
350 | #define LIS_CCCAM 16 |
---|
351 | #define LIS_GBOX 32 |
---|
352 | #define LIS_RADEGAST 64 |
---|
353 | #define LIS_DVBAPI 128 |
---|
354 | #define LIS_CONSTCW 256 |
---|
355 | #define LIS_SERIAL 1024 |
---|
356 | #define LIS_CSPUDP 2048 |
---|
357 | |
---|
358 | //EMM types: |
---|
359 | #define UNKNOWN 0 |
---|
360 | #define UNIQUE 1 |
---|
361 | #define SHARED 2 |
---|
362 | #define GLOBAL 3 |
---|
363 | |
---|
364 | #define PIP_ID_ECM 0 |
---|
365 | #define PIP_ID_EMM 1 |
---|
366 | #define PIP_ID_CIN 2 // CARD_INFO |
---|
367 | #define PIP_ID_UDP 3 |
---|
368 | #define PIP_ID_MAX PIP_ID_UDP |
---|
369 | #define PIP_ID_ERR (-1) |
---|
370 | #define PIP_ID_NUL (-2) |
---|
371 | |
---|
372 | #define cdiff *c_start |
---|
373 | |
---|
374 | #define NCD_AUTO 0 |
---|
375 | #define NCD_524 1 |
---|
376 | #define NCD_525 2 |
---|
377 | |
---|
378 | // moved from reader-common.h |
---|
379 | #define UNKNOWN 0 |
---|
380 | #define CARD_NEED_INIT 1 |
---|
381 | #define CARD_INSERTED 2 |
---|
382 | #define CARD_FAILURE 3 |
---|
383 | #define NO_CARD 4 |
---|
384 | |
---|
385 | // moved from stats |
---|
386 | #define DEFAULT_REOPEN_SECONDS 30 |
---|
387 | #define DEFAULT_MIN_ECM_COUNT 5 |
---|
388 | #define DEFAULT_MAX_ECM_COUNT 500 |
---|
389 | #define DEFAULT_NBEST 1 |
---|
390 | #define DEFAULT_NFB 1 |
---|
391 | #define DEFAULT_RETRYLIMIT 0 |
---|
392 | #define DEFAULT_LB_MODE 0 |
---|
393 | #define DEFAULT_LB_STAT_CLEANUP 336 |
---|
394 | #define DEFAULT_UPDATEINTERVAL 240 |
---|
395 | #define DEFAULT_LB_AUTO_BETATUNNEL 1 |
---|
396 | #define DEFAULT_LB_AUTO_BETATUNNEL_MODE 0 |
---|
397 | #define DEFAULT_LB_AUTO_BETATUNNEL_PREFER_BETA 50 |
---|
398 | |
---|
399 | #define DEFAULT_MAX_CACHE_TIME 15 |
---|
400 | #define DEFAULT_MAX_HITCACHE_TIME 15 |
---|
401 | |
---|
402 | #define DEFAULT_LB_AUTO_TIMEOUT 0 |
---|
403 | #define DEFAULT_LB_AUTO_TIMEOUT_P 30 |
---|
404 | #define DEFAULT_LB_AUTO_TIMEOUT_T 300 |
---|
405 | |
---|
406 | enum {E1_GLOBAL = 0, E1_USER, E1_READER, E1_SERVER, E1_LSERVER}; |
---|
407 | |
---|
408 | //LB blocking events: |
---|
409 | enum {E2_GLOBAL = 0, E2_GROUP, E2_CAID, E2_IDENT, E2_CLASS, E2_CHID, E2_QUEUE, E2_OFFLINE, |
---|
410 | E2_SID, E2_CCCAM_NOCARD, |
---|
411 | //From here only LB nonblocking events: |
---|
412 | E2_CCCAM_NOK1, E2_CCCAM_NOK2, E2_CCCAM_LOOP, E2_WRONG_CHKSUM, E2_RATELIMIT |
---|
413 | }; |
---|
414 | |
---|
415 | #define LB_NONBLOCK_E2_FIRST E2_CCCAM_NOK1 |
---|
416 | |
---|
417 | #define CTA_RES_LEN 512 |
---|
418 | |
---|
419 | #define MAX_ATR_LEN 33 // max. ATR length |
---|
420 | #define MAX_HIST 15 // max. number of historical characters |
---|
421 | |
---|
422 | #define MAX_SIDBITS 64 // max services |
---|
423 | #define SIDTABBITS uint64_t // 64bit type for services, if a system does not support this type, |
---|
424 | // please use a define and define it as uint32_t / MAX_SIDBITS 32 |
---|
425 | |
---|
426 | #define BAN_UNKNOWN 1 // Failban mask for anonymous/ unknown contact |
---|
427 | #define BAN_DISABLED 2 // Failban mask for Disabled user |
---|
428 | #define BAN_SLEEPING 4 // Failban mask for sleeping user |
---|
429 | #define BAN_DUPLICATE 8 // Failban mask for duplicate user |
---|
430 | |
---|
431 | #define MAX_HTTP_DYNDNS 3 // maximum allowed Dyndns addresses for webif access |
---|
432 | |
---|
433 | #define CHECK_WAKEUP 1 |
---|
434 | #define CHECK_ANTICASCADER 2 |
---|
435 | #define CHECK_ECMCACHE 3 |
---|
436 | |
---|
437 | #define AVAIL_CHECK_CONNECTED 0 |
---|
438 | #define AVAIL_CHECK_LOADBALANCE 1 |
---|
439 | |
---|
440 | #define ECM_FMT_LEN 109 //64 |
---|
441 | #define CXM_FMT_LEN 209 // 160 |
---|
442 | |
---|
443 | #define LB_MAX_STAT_TIME 10 |
---|
444 | |
---|
445 | #if defined(__APPLE__) || defined(__FreeBSD__) |
---|
446 | #define OSCAM_SIGNAL_WAKEUP SIGCONT |
---|
447 | #else |
---|
448 | #define OSCAM_SIGNAL_WAKEUP SIGRTMAX-2 |
---|
449 | #endif |
---|
450 | |
---|
451 | #define READER_ACTIVE 0x01 |
---|
452 | #define READER_FALLBACK 0x02 |
---|
453 | #define READER_LOCAL 0x04 |
---|
454 | #define READER_CACHEEX 0x08 |
---|
455 | |
---|
456 | #define REQUEST_SENT 0x10 |
---|
457 | #define REQUEST_ANSWERED 0x20 |
---|
458 | |
---|
459 | /* =========================== |
---|
460 | * Default Values |
---|
461 | * =========================== */ |
---|
462 | #define DEFAULT_INACTIVITYTIMEOUT 0 |
---|
463 | #define DEFAULT_TCP_RECONNECT_TIMEOUT 30 |
---|
464 | #define DEFAULT_NCD_KEEPALIVE 0 |
---|
465 | |
---|
466 | #define DEFAULT_CC_MAXHOPS 10 |
---|
467 | #define DEFAULT_CC_RESHARE -1 // Use global cfg |
---|
468 | #define DEFAULT_CC_IGNRSHR -1 // Use global cfg |
---|
469 | #define DEFAULT_CC_STEALTH -1 // Use global cfg |
---|
470 | #define DEFAULT_CC_KEEPALIVE 0 |
---|
471 | #define DEFAULT_CC_RECONNECT 12000 |
---|
472 | #define DEFAULT_CC_RECV_TIMEOUT 2000 |
---|
473 | |
---|
474 | #define DEFAULT_AC_USERS -1 // Use global cfg |
---|
475 | #define DEFAULT_AC_PENALTY -1 // Use global cfg |
---|
476 | |
---|
477 | // Return MPEG section length |
---|
478 | #define SCT_LEN(sct) (3+((sct[1]&0x0f)<<8)+sct[2]) |
---|
479 | // Used by readers |
---|
480 | #define MAX_LEN 256 |
---|
481 | |
---|
482 | #define NO_CAID_VALUE 0xfffe |
---|
483 | #define NO_SRVID_VALUE 0xfffe |
---|
484 | |
---|
485 | // If NULL return empty string |
---|
486 | #define ESTR(x) ((x) ? (x) : "") |
---|
487 | |
---|
488 | #ifndef MAX |
---|
489 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
---|
490 | #endif |
---|
491 | |
---|
492 | #ifndef MIN |
---|
493 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
---|
494 | #endif |
---|
495 | |
---|
496 | /* |
---|
497 | See: http://stackoverflow.com/questions/10269685/kernels-container-of-any-way-to-make-it-iso-conforming |
---|
498 | http://www.kroah.com/log/linux/container_of.html |
---|
499 | */ |
---|
500 | #define container_of(ptr, type, member) \ |
---|
501 | ((type *) ((char *) (ptr) - offsetof(type, member) + \ |
---|
502 | (&((type *) 0)->member == (ptr)) * 0)) |
---|
503 | |
---|
504 | /* =========================== |
---|
505 | * global structures |
---|
506 | * =========================== */ |
---|
507 | struct timeb |
---|
508 | { |
---|
509 | time_t time; |
---|
510 | uint16_t millitm; |
---|
511 | }; |
---|
512 | |
---|
513 | typedef struct cs_mutexlock |
---|
514 | { |
---|
515 | int32_t timeout; |
---|
516 | pthread_mutex_t lock; |
---|
517 | pthread_cond_t writecond, readcond; |
---|
518 | const char *name; |
---|
519 | int8_t flag; |
---|
520 | int16_t writelock, readlock; |
---|
521 | } CS_MUTEX_LOCK; |
---|
522 | |
---|
523 | #include "oscam-llist.h" |
---|
524 | |
---|
525 | typedef struct s_caidvaluetab |
---|
526 | { |
---|
527 | uint16_t n; |
---|
528 | uint16_t caid[CS_MAX_CAIDVALUETAB]; |
---|
529 | uint16_t value[CS_MAX_CAIDVALUETAB]; |
---|
530 | } CAIDVALUETAB; |
---|
531 | |
---|
532 | typedef struct s_classtab |
---|
533 | { |
---|
534 | uchar an; |
---|
535 | uchar bn; |
---|
536 | uchar aclass[31]; |
---|
537 | uchar bclass[31]; |
---|
538 | } CLASSTAB; |
---|
539 | |
---|
540 | typedef struct s_caidtab |
---|
541 | { |
---|
542 | uint16_t caid[CS_MAXCAIDTAB]; |
---|
543 | uint16_t mask[CS_MAXCAIDTAB]; |
---|
544 | uint16_t cmap[CS_MAXCAIDTAB]; |
---|
545 | } CAIDTAB; |
---|
546 | |
---|
547 | typedef struct s_tuntab |
---|
548 | { |
---|
549 | uint16_t n; |
---|
550 | uint16_t bt_caidfrom[CS_MAXTUNTAB]; |
---|
551 | uint16_t bt_caidto[CS_MAXTUNTAB]; |
---|
552 | uint16_t bt_srvid[CS_MAXTUNTAB]; |
---|
553 | } TUNTAB; |
---|
554 | |
---|
555 | typedef struct s_sidtab |
---|
556 | { |
---|
557 | char label[64]; |
---|
558 | uint16_t num_caid; |
---|
559 | uint16_t num_provid; |
---|
560 | uint16_t num_srvid; |
---|
561 | uint16_t *caid; |
---|
562 | uint32_t *provid; |
---|
563 | uint16_t *srvid; |
---|
564 | struct s_sidtab *next; |
---|
565 | } SIDTAB; |
---|
566 | |
---|
567 | typedef struct s_filter |
---|
568 | { |
---|
569 | uint16_t caid; |
---|
570 | uchar nprids; |
---|
571 | uint32_t prids[CS_MAXPROV]; |
---|
572 | } FILTER; |
---|
573 | |
---|
574 | typedef struct s_ftab |
---|
575 | { |
---|
576 | int32_t nfilts; |
---|
577 | FILTER filts[CS_MAXFILTERS]; |
---|
578 | } FTAB; |
---|
579 | |
---|
580 | struct ncd_port |
---|
581 | { |
---|
582 | bool ncd_key_is_set; |
---|
583 | uint8_t ncd_key[14]; |
---|
584 | FTAB ncd_ftab; |
---|
585 | }; |
---|
586 | |
---|
587 | typedef struct s_port |
---|
588 | { |
---|
589 | int32_t fd; |
---|
590 | int32_t s_port; |
---|
591 | struct ncd_port *ncd; // newcamd specific settings |
---|
592 | } PORT; |
---|
593 | |
---|
594 | typedef struct s_ptab |
---|
595 | { |
---|
596 | int32_t nports; |
---|
597 | PORT ports[CS_MAXPORTS]; |
---|
598 | } PTAB; |
---|
599 | |
---|
600 | typedef struct aes_entry |
---|
601 | { |
---|
602 | uint16_t keyid; |
---|
603 | uint16_t caid; |
---|
604 | uint32_t ident; |
---|
605 | uchar plainkey[16]; |
---|
606 | AES_KEY key; |
---|
607 | struct aes_entry *next; |
---|
608 | } AES_ENTRY; |
---|
609 | |
---|
610 | struct aes_keys |
---|
611 | { |
---|
612 | AES_KEY aeskey_encrypt; // encryption key needed by monitor and used by camd33, camd35 |
---|
613 | AES_KEY aeskey_decrypt; // decryption key needed by monitor and used by camd33, camd35 |
---|
614 | }; |
---|
615 | |
---|
616 | struct s_ecm |
---|
617 | { |
---|
618 | uchar ecmd5[CS_ECMSTORESIZE]; |
---|
619 | uchar cw[16]; |
---|
620 | uint16_t caid; |
---|
621 | uint64_t grp; |
---|
622 | struct s_reader *reader; |
---|
623 | int32_t rc; |
---|
624 | time_t time; |
---|
625 | }; |
---|
626 | |
---|
627 | struct s_emm |
---|
628 | { |
---|
629 | uchar emmd5[CS_EMMSTORESIZE]; |
---|
630 | uchar type; |
---|
631 | int32_t count; |
---|
632 | }; |
---|
633 | |
---|
634 | struct s_csystem_emm_filter |
---|
635 | { |
---|
636 | uint8_t type; |
---|
637 | uint8_t enabled; |
---|
638 | uint8_t filter[16]; |
---|
639 | uint8_t mask[16]; |
---|
640 | }; |
---|
641 | |
---|
642 | typedef struct v_ban // Failban listmember |
---|
643 | { |
---|
644 | int32_t v_count; |
---|
645 | IN_ADDR_T v_ip; |
---|
646 | int32_t v_port; |
---|
647 | struct timeb v_time; |
---|
648 | char *info; |
---|
649 | } V_BAN; |
---|
650 | |
---|
651 | typedef struct s_cacheex_stat_entry // Cacheex stats listmember |
---|
652 | { |
---|
653 | int32_t cache_count; |
---|
654 | time_t cache_last; |
---|
655 | uint16_t cache_caid; |
---|
656 | uint16_t cache_srvid; |
---|
657 | uint32_t cache_prid; |
---|
658 | int8_t cache_direction; // 0 = push / 1 = got |
---|
659 | } S_CACHEEX_STAT_ENTRY; |
---|
660 | |
---|
661 | typedef struct s_entitlement // contains entitlement Info |
---|
662 | { |
---|
663 | uint64_t id; // the element ID |
---|
664 | uint32_t type; // enumerator for tier,chid whatever |
---|
665 | // 0="", 1="Package", 2="PPV-Event", 3="chid", 4="tier", 5 = "class", 6 = "PBM". 7 = "seca-admin" |
---|
666 | uint16_t caid; // the caid of element |
---|
667 | uint32_t provid; // the provid of element |
---|
668 | uint32_t class; // the class needed for some systems |
---|
669 | time_t start; // startdate |
---|
670 | time_t end; // enddate |
---|
671 | } S_ENTITLEMENT; |
---|
672 | |
---|
673 | struct s_client ; |
---|
674 | struct ecm_request_t ; |
---|
675 | struct emm_packet_t ; |
---|
676 | struct s_ecm_answer ; |
---|
677 | struct demux_s ; |
---|
678 | |
---|
679 | struct s_module |
---|
680 | { |
---|
681 | int8_t active; |
---|
682 | int8_t type; |
---|
683 | int8_t large_ecm_support; |
---|
684 | int16_t listenertype; |
---|
685 | char *desc; |
---|
686 | //int32_t s_port; |
---|
687 | IN_ADDR_T s_ip; |
---|
688 | uint16_t bufsize; |
---|
689 | void *(*s_handler)(struct s_client *, uchar *, int32_t); |
---|
690 | void (*s_init)(struct s_client *); |
---|
691 | int32_t (*recv)(struct s_client *, uchar *, int32_t); |
---|
692 | void (*send_dcw)(struct s_client *, struct ecm_request_t *); |
---|
693 | void (*cleanup)(struct s_client *); |
---|
694 | int32_t (*c_recv_chk)(struct s_client *, uchar *, int32_t *, uchar *, int32_t); |
---|
695 | int32_t (*c_init)(struct s_client *); |
---|
696 | int32_t (*c_send_ecm)(struct s_client *, struct ecm_request_t *, uchar *); |
---|
697 | int32_t (*c_send_emm)(struct emm_packet_t *); |
---|
698 | int32_t (*c_available)(struct s_reader *, int32_t, struct ecm_request_t *); //Schlocke: available check for load-balancing, |
---|
699 | // params: |
---|
700 | // rdr (reader to check) |
---|
701 | // int32_t checktype (0=return connected, 1=return loadbalance-avail) return int |
---|
702 | void (*c_idle)(void); // Schlocke: called when reader is idle |
---|
703 | void (*s_idle)(struct s_client *); |
---|
704 | void (*c_card_info)(void); // Schlocke: request card infos |
---|
705 | |
---|
706 | int32_t (*c_capmt)(struct s_client *, struct demux_s *); |
---|
707 | |
---|
708 | #ifdef CS_CACHEEX |
---|
709 | int32_t (*c_cache_push)(struct s_client *, struct ecm_request_t *); //Cache push |
---|
710 | int32_t (*c_cache_push_chk)(struct s_client *, struct ecm_request_t *); //Cache push Node Check, 0=no push |
---|
711 | #endif |
---|
712 | int32_t c_port; |
---|
713 | PTAB ptab; |
---|
714 | int32_t num; |
---|
715 | }; |
---|
716 | |
---|
717 | struct s_ATR ; |
---|
718 | |
---|
719 | struct s_cardreader |
---|
720 | { |
---|
721 | char *desc; |
---|
722 | int32_t (*reader_init)(struct s_reader *); |
---|
723 | int32_t (*get_status)(struct s_reader *, int *); |
---|
724 | int32_t (*activate)(struct s_reader *, struct s_ATR *); |
---|
725 | int32_t (*transmit)(struct s_reader *, unsigned char *sent, uint32_t size, uint32_t expectedlen, uint32_t delay, uint32_t timeout); |
---|
726 | int32_t (*receive)(struct s_reader *, unsigned char *data, uint32_t size, uint32_t delay, uint32_t timeout); |
---|
727 | int32_t (*lock_init)(struct s_reader *); |
---|
728 | void (*lock)(struct s_reader *); |
---|
729 | void (*unlock)(struct s_reader *); |
---|
730 | int32_t (*close)(struct s_reader *); |
---|
731 | int32_t (*set_parity)(struct s_reader *, uchar parity); |
---|
732 | // FIXME: All parameters passed to write_settingsX should be put in a struct |
---|
733 | int32_t (*write_settings)(struct s_reader *, |
---|
734 | uint32_t ETU, |
---|
735 | uint32_t EGT, |
---|
736 | unsigned char P, |
---|
737 | unsigned char I, |
---|
738 | uint16_t Fi, |
---|
739 | unsigned char Di, |
---|
740 | unsigned char Ni); |
---|
741 | // FIXME: write_settings2 is used by coolstream reader |
---|
742 | int32_t (*write_settings2)(struct s_reader *, uint16_t F, uint8_t D, uint32_t WWT, uint32_t EGT, uint32_t BGT); |
---|
743 | // FIXME: write_settings3 is used by sci reader |
---|
744 | int32_t (*write_settings3)(struct s_reader *, uint32_t ETU, uint32_t F, uint32_t WWT, uint32_t CWT, uint32_t BWT, uint32_t EGT, uint32_t I); |
---|
745 | int32_t (*set_protocol)(struct s_reader *, |
---|
746 | unsigned char *params, |
---|
747 | uint32_t *length, |
---|
748 | uint32_t len_request); |
---|
749 | int32_t (*set_baudrate)(struct s_reader *, |
---|
750 | uint32_t baud); //set only for readers which need baudrate setting and timings need to be guarded by OSCam |
---|
751 | int32_t (*card_write)(struct s_reader *pcsc_reader, |
---|
752 | const uchar *buf, |
---|
753 | unsigned char *cta_res, |
---|
754 | uint16_t *cta_lr, |
---|
755 | int32_t l); |
---|
756 | void (*display_msg)(struct s_reader *, char *msg); |
---|
757 | |
---|
758 | int32_t (*do_reset)(struct s_reader *, struct s_ATR *, |
---|
759 | int32_t (*rdr_activate_card)(struct s_reader *, struct s_ATR *, uint16_t deprecated), |
---|
760 | int32_t (*rdr_get_cardsystem)(struct s_reader *, struct s_ATR *)); |
---|
761 | |
---|
762 | bool (*set_DTS_RTS)(struct s_reader *, int32_t *dtr, int32_t *rts); |
---|
763 | |
---|
764 | int32_t typ; // fixme: workaround, remove when all old code is converted |
---|
765 | |
---|
766 | int8_t max_clock_speed; // 1 for reader->typ > R_MOUSE |
---|
767 | int8_t need_inverse; // 0 = reader does inversing; 1 = inversing done by oscam |
---|
768 | //io_serial config |
---|
769 | int8_t flush; |
---|
770 | int8_t read_written; // 1 = written bytes has to read from device |
---|
771 | bool skip_extra_atr_parsing; |
---|
772 | bool skip_t1_command_retries; |
---|
773 | bool skip_setting_ifsc; |
---|
774 | }; |
---|
775 | |
---|
776 | struct s_cardsystem |
---|
777 | { |
---|
778 | int8_t active; |
---|
779 | char *desc; |
---|
780 | int32_t (*card_init)(struct s_reader *reader, struct s_ATR *); |
---|
781 | int32_t (*card_info)(struct s_reader *); |
---|
782 | int32_t (*do_ecm)(struct s_reader *, const struct ecm_request_t *, struct s_ecm_answer *); |
---|
783 | int32_t (*do_emm_reassembly)(struct s_client *, struct emm_packet_t *); // Returns 1/true if the EMM is ready to be written in the card |
---|
784 | int32_t (*do_emm)(struct s_reader *, struct emm_packet_t *); |
---|
785 | void (*post_process)(struct s_reader *); |
---|
786 | int32_t (*get_emm_type)(struct emm_packet_t *, struct s_reader *); |
---|
787 | int32_t (*get_emm_filter)(struct s_reader *, struct s_csystem_emm_filter **, unsigned int *); |
---|
788 | int32_t (*get_tunemm_filter)(struct s_reader *, struct s_csystem_emm_filter **, unsigned int *); |
---|
789 | uint16_t caids[8]; |
---|
790 | }; |
---|
791 | |
---|
792 | #define MAX_ECM_SIZE 512 |
---|
793 | |
---|
794 | typedef struct ecm_request_t |
---|
795 | { |
---|
796 | uchar ecm[MAX_ECM_SIZE]; |
---|
797 | uchar cw[16]; |
---|
798 | uchar ecmd5[CS_ECMSTORESIZE]; |
---|
799 | int16_t ecmlen; |
---|
800 | uint16_t caid; |
---|
801 | uint16_t ocaid; //original caid, used for betatunneling |
---|
802 | uint16_t srvid; |
---|
803 | uint16_t onid; |
---|
804 | uint16_t tsid; |
---|
805 | uint16_t pmtpid; |
---|
806 | uint32_t ens; // enigma namespace |
---|
807 | uint32_t vpid; // videopid |
---|
808 | uint16_t chid; |
---|
809 | uint16_t pid; |
---|
810 | uint16_t idx; |
---|
811 | uint32_t prid; |
---|
812 | struct s_reader *selected_reader; |
---|
813 | struct s_ecm_answer *matching_rdr; //list of matching readers |
---|
814 | const struct s_reader *fallback; //fallback is the first fallback reader in the list matching_rdr |
---|
815 | struct s_client *client; //contains pointer to 'c' client while running in 'r' client |
---|
816 | uint64_t grp; |
---|
817 | int32_t msgid; // client pending table index |
---|
818 | uint8_t stage; // processing stage in server module |
---|
819 | int8_t rc; |
---|
820 | uint8_t rcEx; |
---|
821 | struct timeb tps; // incoming time stamp |
---|
822 | int8_t btun; // mark er as betatunneled |
---|
823 | uint16_t reader_avail; // count of available readers for ecm |
---|
824 | uint16_t readers; // count of available used readers |
---|
825 | uint16_t reader_nocacheex_avail; // count of "normal" readers |
---|
826 | uint16_t reader_count; // count of contacted readers |
---|
827 | uint16_t fallback_reader_count; // count of contacted fb readers |
---|
828 | uint16_t cacheex_reader_count; // count of contacted cacheex mode-1 readers |
---|
829 | uint16_t reader_requested; // count of real requested readers |
---|
830 | int8_t checked; //for doublecheck |
---|
831 | uchar cw_checked[16]; //for doublecheck |
---|
832 | int8_t readers_timeout_check; // set to 1 after ctimeout occurs and readers not answered are checked |
---|
833 | struct s_reader *origin_reader; |
---|
834 | |
---|
835 | #if defined MODULE_CCCAM |
---|
836 | void *origin_card; // CCcam preferred card! |
---|
837 | #endif |
---|
838 | |
---|
839 | #if defined MODULE_GBOX |
---|
840 | uint32_t gbox_crc; // rcrc for gbox, used to identify ECM task in peer responses |
---|
841 | uint16_t gbox_ecm_id; |
---|
842 | uint8_t gbox_ecm_ok; |
---|
843 | #endif |
---|
844 | |
---|
845 | void *src_data; |
---|
846 | int32_t csp_hash; // csp has its own hash |
---|
847 | |
---|
848 | #ifdef CS_CACHEEX |
---|
849 | struct s_client *cacheex_src; // Cacheex origin |
---|
850 | int8_t cacheex_pushed; // to avoid duplicate pushs |
---|
851 | uint8_t csp_answered; // =1 if er get answer by csp |
---|
852 | LLIST *csp_lastnodes; // last 10 Cacheex nodes atm cc-proto-only |
---|
853 | uint32_t cacheex_wait_time; // cacheex wait time in ms |
---|
854 | struct timeb cacheex_wait; // incoming time stamp (tps) + cacheex wait time |
---|
855 | uint8_t cacheex_wait_time_expired; // =1 if cacheex wait_time expires |
---|
856 | uint8_t cacheex_hitcache; // =1 if wait_time due hitcache |
---|
857 | void *cw_cache; //pointer to cw stored in cache |
---|
858 | #endif |
---|
859 | uint32_t cw_count; |
---|
860 | uint8_t from_csp; // =1 if er from csp cache |
---|
861 | uint8_t from_cacheex; // =1 if er from cacheex client pushing cache |
---|
862 | uint8_t from_cacheex1_client; // =1 if er from cacheex-1 client |
---|
863 | char msglog[MSGLOGSIZE]; |
---|
864 | uint8_t cwc_cycletime; |
---|
865 | uint8_t cwc_next_cw_cycle; |
---|
866 | #ifdef CW_CYCLE_CHECK |
---|
867 | char cwc_msg_log[MSGLOGSIZE]; |
---|
868 | #endif |
---|
869 | struct ecm_request_t *parent; |
---|
870 | struct ecm_request_t *next; |
---|
871 | } ECM_REQUEST; |
---|
872 | |
---|
873 | |
---|
874 | struct s_ecm_answer |
---|
875 | { |
---|
876 | uint8_t status; |
---|
877 | struct s_reader *reader; |
---|
878 | ECM_REQUEST *er; |
---|
879 | int8_t rc; |
---|
880 | uint8_t rcEx; |
---|
881 | uchar cw[16]; |
---|
882 | char msglog[MSGLOGSIZE]; |
---|
883 | struct timeb time_request_sent; //using for evaluate ecm_time |
---|
884 | int32_t ecm_time; |
---|
885 | #ifdef WITH_LB |
---|
886 | int32_t value; |
---|
887 | int32_t time; |
---|
888 | #endif |
---|
889 | struct s_ecm_answer *next; |
---|
890 | CS_MUTEX_LOCK ecmanswer_lock; |
---|
891 | struct s_ecm_answer *pending; |
---|
892 | struct s_ecm_answer *pending_next; |
---|
893 | bool is_pending; |
---|
894 | }; |
---|
895 | |
---|
896 | struct s_acasc_shm |
---|
897 | { |
---|
898 | uint16_t ac_count : 15; |
---|
899 | uint16_t ac_deny : 1; |
---|
900 | }; |
---|
901 | |
---|
902 | struct s_acasc |
---|
903 | { |
---|
904 | uint16_t stat[10]; |
---|
905 | uchar idx; // current active index in stat[] |
---|
906 | }; |
---|
907 | |
---|
908 | struct s_cwresponse |
---|
909 | { |
---|
910 | int32_t duration; |
---|
911 | time_t timestamp; |
---|
912 | int32_t rc; |
---|
913 | }; |
---|
914 | |
---|
915 | struct s_cascadeuser |
---|
916 | { |
---|
917 | uint16_t caid; |
---|
918 | uint32_t prid; |
---|
919 | uint16_t srvid; |
---|
920 | time_t time; |
---|
921 | int8_t cwrate; |
---|
922 | }; |
---|
923 | |
---|
924 | typedef struct sidtabs |
---|
925 | { |
---|
926 | SIDTABBITS ok; // positive services |
---|
927 | SIDTABBITS no; // negative services |
---|
928 | } SIDTABS; |
---|
929 | |
---|
930 | struct s_client |
---|
931 | { |
---|
932 | uint32_t tid; |
---|
933 | int8_t init_done; |
---|
934 | pthread_mutex_t thread_lock; |
---|
935 | int8_t thread_active; |
---|
936 | int8_t kill; |
---|
937 | int8_t kill_started; |
---|
938 | LLIST *joblist; |
---|
939 | IN_ADDR_T ip; |
---|
940 | in_port_t port; |
---|
941 | time_t login; // connection |
---|
942 | time_t logout; // disconnection |
---|
943 | time_t last; |
---|
944 | time_t lastswitch; |
---|
945 | time_t lastemm; |
---|
946 | time_t lastecm; |
---|
947 | time_t expirationdate; |
---|
948 | int32_t allowedtimeframe[2]; |
---|
949 | int8_t c35_suppresscmd08; |
---|
950 | uint8_t c35_sleepsend; |
---|
951 | int8_t ncd_keepalive; |
---|
952 | int8_t disabled; |
---|
953 | uint64_t grp; |
---|
954 | int8_t crypted; |
---|
955 | int8_t dup; |
---|
956 | LLIST *aureader_list; |
---|
957 | int8_t autoau; |
---|
958 | #ifdef READER_VIACCESS |
---|
959 | int16_t via_rass_emmlen; |
---|
960 | uint8_t via_rass_emm[512]; |
---|
961 | #endif |
---|
962 | #ifdef READER_CRYPTOWORKS |
---|
963 | int16_t cw_rass_emmlen; |
---|
964 | uint8_t cw_rass_emm[512]; |
---|
965 | #endif |
---|
966 | int8_t monlvl; |
---|
967 | CAIDTAB ctab; |
---|
968 | TUNTAB ttab; |
---|
969 | SIDTABS sidtabs; |
---|
970 | SIDTABS lb_sidtabs; |
---|
971 | int8_t typ; // first s_client is type s=starting (master) thread; type r = physical reader, type p = proxy reader both always have 1 s_reader struct allocated; type c = client (user logging in into oscam) type m = monitor type h = http server a = anticascader |
---|
972 | uint8_t module_idx; |
---|
973 | uint16_t last_srvid; |
---|
974 | uint16_t last_caid; |
---|
975 | struct s_srvid *last_srvidptr; |
---|
976 | int32_t tosleep; |
---|
977 | struct s_auth *account; |
---|
978 | int32_t udp_fd; |
---|
979 | struct SOCKADDR udp_sa; |
---|
980 | socklen_t udp_sa_len; |
---|
981 | int8_t log; |
---|
982 | int32_t logcounter; |
---|
983 | int32_t cwfound; // count found ECMs per client |
---|
984 | int32_t cwcache; // count ECMs from cache1/2 per client |
---|
985 | int32_t cwnot; // count not found ECMs per client |
---|
986 | int32_t cwtun; // count betatunneled ECMs per client |
---|
987 | int32_t cwignored; // count ignored ECMs per client |
---|
988 | int32_t cwtout; // count timeouted ECMs per client |
---|
989 | int32_t cwlastresptime; // last Responsetime (ms) |
---|
990 | #ifdef CW_CYCLE_CHECK |
---|
991 | int32_t cwcycledchecked; // count checked cwcycles per client |
---|
992 | int32_t cwcycledok; // count pos checked cwcycles per client |
---|
993 | int32_t cwcyclednok; // count neg checked cwcycles per client |
---|
994 | int32_t cwcycledign; // count ign cwcycles per client |
---|
995 | #endif |
---|
996 | int32_t emmok; // count EMM ok |
---|
997 | int32_t emmnok; // count EMM nok |
---|
998 | int8_t pending; // number of ECMs pending |
---|
999 | #ifdef CS_CACHEEX |
---|
1000 | int32_t cwcacheexpush; // count pushed ecms/cws |
---|
1001 | int32_t cwcacheexgot; // count got ecms/cws |
---|
1002 | int32_t cwcacheexhit; // count hit ecms/cws |
---|
1003 | LLIST *ll_cacheex_stats; // list for Cacheex statistics |
---|
1004 | int8_t cacheex_maxhop; |
---|
1005 | int32_t cwcacheexerr; // cw=00 or chksum wrong |
---|
1006 | int32_t cwcacheexerrcw; // same Hex, different CW |
---|
1007 | int16_t cwcacheexping; // peer ping in ms, only used by csp |
---|
1008 | int32_t cwc_info; // count of in/out comming cacheex ecms with CWCinfo |
---|
1009 | #endif |
---|
1010 | |
---|
1011 | #ifdef WEBIF |
---|
1012 | struct s_cwresponse cwlastresptimes[CS_ECM_RINGBUFFER_MAX]; //ringbuffer for last 20 times |
---|
1013 | int32_t cwlastresptimes_last; // ringbuffer pointer |
---|
1014 | int8_t wihidden; // hidden in webinterface status |
---|
1015 | char lastreader[64]; // last cw got from this reader |
---|
1016 | #endif |
---|
1017 | |
---|
1018 | uchar ucrc[4]; // needed by monitor and used by camd35 |
---|
1019 | uint32_t pcrc; // password crc |
---|
1020 | struct aes_keys aes_keys; |
---|
1021 | uint16_t ncd_msgid; |
---|
1022 | uint16_t ncd_client_id; |
---|
1023 | uchar ncd_skey[16]; //Also used for camd35 Cacheex to store remote node id |
---|
1024 | |
---|
1025 | #ifdef MODULE_CCCAM |
---|
1026 | void *cc; |
---|
1027 | #endif |
---|
1028 | |
---|
1029 | #ifdef MODULE_GBOX |
---|
1030 | void *gbox; |
---|
1031 | uint16_t gbox_peer_id; |
---|
1032 | #endif |
---|
1033 | |
---|
1034 | #ifdef MODULE_GHTTP |
---|
1035 | void *ghttp; |
---|
1036 | #endif |
---|
1037 | |
---|
1038 | int32_t port_idx; // index in server ptab |
---|
1039 | int32_t ncd_server; // newcamd server |
---|
1040 | |
---|
1041 | #ifdef CS_ANTICASC |
---|
1042 | int32_t ac_fakedelay; // When this is -1, the global ac_fakedelay is used |
---|
1043 | uint16_t ac_limit; |
---|
1044 | int8_t ac_penalty; |
---|
1045 | struct s_acasc_shm acasc; |
---|
1046 | #endif |
---|
1047 | |
---|
1048 | FTAB fchid; |
---|
1049 | FTAB ftab; // user [caid] and ident filter |
---|
1050 | CLASSTAB cltab; |
---|
1051 | |
---|
1052 | int32_t pfd; // Primary FD, must be closed on exit |
---|
1053 | struct s_reader *reader; // points to s_reader when cl->typ='r' |
---|
1054 | |
---|
1055 | ECM_REQUEST *ecmtask; |
---|
1056 | struct s_emm *emmcache; |
---|
1057 | |
---|
1058 | pthread_t thread; |
---|
1059 | |
---|
1060 | #ifdef MODULE_SERIAL |
---|
1061 | struct s_serial_client *serialdata; |
---|
1062 | #endif |
---|
1063 | //reader common |
---|
1064 | int32_t last_idx; |
---|
1065 | uint16_t idx; |
---|
1066 | int8_t rotate; |
---|
1067 | |
---|
1068 | int8_t ncd_proto; |
---|
1069 | uint8_t ncd_header[12]; |
---|
1070 | |
---|
1071 | //camd35 |
---|
1072 | uchar upwd[64]; |
---|
1073 | int8_t is_udp; |
---|
1074 | int8_t stopped; |
---|
1075 | uint16_t lastcaid; |
---|
1076 | uint16_t lastsrvid; |
---|
1077 | int32_t lastpid; |
---|
1078 | int8_t disable_counter; |
---|
1079 | uchar lastserial[8]; |
---|
1080 | |
---|
1081 | // Failban value set bitwise - compared with BAN_ |
---|
1082 | int32_t failban; |
---|
1083 | |
---|
1084 | LLIST *cascadeusers; //s_cascadeuser |
---|
1085 | |
---|
1086 | int32_t n_request[2]; //count for number of request per minute by client |
---|
1087 | |
---|
1088 | void *work_mbuf; // Points to local data allocated in work_thread when the thread is running |
---|
1089 | void *work_job_data; // Points to current job_data when work_thread is running |
---|
1090 | |
---|
1091 | #ifdef MODULE_PANDORA |
---|
1092 | int32_t pand_autodelay; |
---|
1093 | uint8_t pand_send_ecm; |
---|
1094 | uchar pand_ignore_ecm; |
---|
1095 | uchar pand_md5_key[16]; |
---|
1096 | #endif |
---|
1097 | |
---|
1098 | void *module_data; // private module data |
---|
1099 | |
---|
1100 | struct s_client *next; //make client a linked list |
---|
1101 | struct s_client *nexthashed; |
---|
1102 | }; |
---|
1103 | |
---|
1104 | struct s_ecmWhitelist |
---|
1105 | { |
---|
1106 | uint16_t caid; |
---|
1107 | struct s_ecmWhitelistIdent *idents; |
---|
1108 | struct s_ecmWhitelist *next; |
---|
1109 | }; |
---|
1110 | |
---|
1111 | struct s_ecmWhitelistIdent |
---|
1112 | { |
---|
1113 | uint32_t ident; |
---|
1114 | struct s_ecmWhitelistLen *lengths; |
---|
1115 | struct s_ecmWhitelistIdent *next; |
---|
1116 | }; |
---|
1117 | |
---|
1118 | struct s_ecmWhitelistLen |
---|
1119 | { |
---|
1120 | int16_t len; |
---|
1121 | struct s_ecmWhitelistLen *next; |
---|
1122 | }; |
---|
1123 | |
---|
1124 | struct s_ecmHeaderwhitelist |
---|
1125 | { |
---|
1126 | uint16_t caid; |
---|
1127 | uint32_t provid; |
---|
1128 | uchar header[20]; |
---|
1129 | int16_t len; |
---|
1130 | struct s_ecmHeaderwhitelist *next; |
---|
1131 | }; |
---|
1132 | |
---|
1133 | //ratelimit |
---|
1134 | struct ecmrl |
---|
1135 | { |
---|
1136 | struct timeb last; |
---|
1137 | uchar kindecm; |
---|
1138 | uchar ecmd5[CS_ECMSTORESIZE]; |
---|
1139 | uint16_t caid; |
---|
1140 | uint32_t provid; |
---|
1141 | uint16_t srvid; |
---|
1142 | uint16_t chid; |
---|
1143 | int32_t ratelimitecm; |
---|
1144 | int32_t ratelimittime; |
---|
1145 | int32_t srvidholdtime; |
---|
1146 | }; |
---|
1147 | #define MAXECMRATELIMIT 20 |
---|
1148 | |
---|
1149 | #ifdef CS_CACHEEX |
---|
1150 | typedef struct ce_csp_tab |
---|
1151 | { |
---|
1152 | uint16_t n; |
---|
1153 | int32_t caid[CS_MAXCAIDTAB]; |
---|
1154 | int32_t cmask[CS_MAXCAIDTAB]; |
---|
1155 | int32_t prid[CS_MAXCAIDTAB]; |
---|
1156 | int32_t srvid[CS_MAXCAIDTAB]; |
---|
1157 | int16_t awtime[CS_MAXCAIDTAB]; |
---|
1158 | int16_t dwtime[CS_MAXCAIDTAB]; |
---|
1159 | } CECSPVALUETAB; |
---|
1160 | |
---|
1161 | typedef struct cacheex_check_cw_tab |
---|
1162 | { |
---|
1163 | uint16_t n; |
---|
1164 | int32_t caid[CS_MAXCAIDTAB]; |
---|
1165 | int32_t cmask[CS_MAXCAIDTAB]; |
---|
1166 | int32_t prid[CS_MAXCAIDTAB]; |
---|
1167 | int32_t srvid[CS_MAXCAIDTAB]; |
---|
1168 | int8_t mode[CS_MAXCAIDTAB]; |
---|
1169 | uint32_t counter[CS_MAXCAIDTAB]; |
---|
1170 | } CWCHECKTAB; |
---|
1171 | |
---|
1172 | typedef struct cacheex_check_cw |
---|
1173 | { |
---|
1174 | int8_t mode; |
---|
1175 | uint32_t counter; |
---|
1176 | } CWCHECK; |
---|
1177 | |
---|
1178 | typedef struct ce_csp_t |
---|
1179 | { |
---|
1180 | int8_t mode; |
---|
1181 | int8_t maxhop; |
---|
1182 | CECSPVALUETAB filter_caidtab; |
---|
1183 | uint8_t allow_request; |
---|
1184 | uint8_t allow_reforward; |
---|
1185 | uint8_t drop_csp; |
---|
1186 | } CECSP; |
---|
1187 | #endif |
---|
1188 | |
---|
1189 | struct s_emmlen_range |
---|
1190 | { |
---|
1191 | int16_t min; |
---|
1192 | int16_t max; |
---|
1193 | }; |
---|
1194 | |
---|
1195 | struct s_reader //contains device info, reader info and card info |
---|
1196 | { |
---|
1197 | uint8_t keepalive; |
---|
1198 | uint8_t changes_since_shareupdate; |
---|
1199 | int32_t resetcycle; // ECM until reset |
---|
1200 | int32_t resetcounter; // actual count |
---|
1201 | uint32_t auprovid; // AU only for this provid |
---|
1202 | int8_t audisabled; // exclude reader from auto AU |
---|
1203 | int8_t needsemmfirst; // 0: reader descrambles without emm first, 1: reader needs emms before it can descramble |
---|
1204 | struct timeb emm_last; // time of last successfully written emm |
---|
1205 | int8_t smargopatch; |
---|
1206 | int8_t autospeed; // 1 clockspeed set according to atr f max |
---|
1207 | struct s_client *client; // pointer to 'r'client this reader is running in |
---|
1208 | LLIST *ll_entitlements; // entitlements |
---|
1209 | int8_t enable; |
---|
1210 | int8_t active; |
---|
1211 | int8_t dropbadcws; // Schlocke: 1=drops cw if checksum is wrong. 0=fix checksum (default) |
---|
1212 | int8_t disablecrccws; // 1=disable cw checksum test. 0=enable checksum check |
---|
1213 | uint64_t grp; |
---|
1214 | int8_t fallback; |
---|
1215 | FTAB fallback_percaid; |
---|
1216 | #ifdef CS_CACHEEX |
---|
1217 | CECSP cacheex; //CacheEx Settings |
---|
1218 | #endif |
---|
1219 | int32_t typ; |
---|
1220 | char label[64]; |
---|
1221 | #ifdef WEBIF |
---|
1222 | char *description; |
---|
1223 | #endif |
---|
1224 | char device[128]; |
---|
1225 | uint16_t slot; // in case of multiple slots like sc8in1; first slot = 1 |
---|
1226 | int32_t handle; // device handle |
---|
1227 | int32_t fdmc; // device handle for multicam |
---|
1228 | int32_t detect; |
---|
1229 | int32_t mhz; // actual clock rate of reader in 10khz steps |
---|
1230 | int32_t cardmhz; // standard clock speed your card should have in 10khz steps; normally 357 but for Irdeto cards 600 |
---|
1231 | int32_t divider; // PLL divider for internal readers |
---|
1232 | int32_t r_port; |
---|
1233 | char r_usr[64]; |
---|
1234 | char r_pwd[64]; |
---|
1235 | int32_t l_port; |
---|
1236 | CAIDTAB ctab; |
---|
1237 | uint32_t boxid; |
---|
1238 | int8_t nagra_read; // read nagra ncmed records: 0 Disabled (default), 1 read all records, 2 read valid records only |
---|
1239 | uint8_t boxkey[8]; // n3 boxkey 8byte |
---|
1240 | int8_t force_irdeto; |
---|
1241 | uchar rsa_mod[120]; // rsa modulus for nagra cards. |
---|
1242 | uchar atr[64]; |
---|
1243 | uchar card_atr[64]; // ATR readed from card |
---|
1244 | int8_t card_atr_length; // length of ATR |
---|
1245 | int32_t atrlen; |
---|
1246 | SIDTABS sidtabs; |
---|
1247 | SIDTABS lb_sidtabs; |
---|
1248 | uchar hexserial[8]; |
---|
1249 | int32_t nprov; |
---|
1250 | uchar prid[CS_MAXPROV][8]; |
---|
1251 | uchar sa[CS_MAXPROV][4]; // viaccess & seca |
---|
1252 | uint16_t caid; |
---|
1253 | uint16_t b_nano; |
---|
1254 | uint16_t s_nano; |
---|
1255 | int8_t ecmcommand; // used for filtering nagra bad ecm commands |
---|
1256 | uchar ecmcommandcache[4]; // cachebuff for ecm commands |
---|
1257 | int32_t blockemm; |
---|
1258 | int32_t saveemm; |
---|
1259 | LLIST *blockemmbylen; |
---|
1260 | char *emmfile; |
---|
1261 | char pincode[5]; |
---|
1262 | int8_t logemm; |
---|
1263 | int8_t cachemm; |
---|
1264 | int16_t rewritemm; |
---|
1265 | int8_t card_status; |
---|
1266 | int8_t deprecated; //if 0 ATR obeyed, if 1 default speed (9600) is chosen; for devices that cannot switch baudrate |
---|
1267 | struct s_module ph; |
---|
1268 | struct s_cardreader crdr; |
---|
1269 | void *crdr_data; // Private card reader data |
---|
1270 | struct s_cardsystem csystem; |
---|
1271 | void *csystem_data; // Private card system data |
---|
1272 | uint8_t ncd_key[14]; |
---|
1273 | uchar ncd_skey[16]; |
---|
1274 | int8_t ncd_connect_on_init; |
---|
1275 | int8_t ncd_disable_server_filt; |
---|
1276 | int8_t ncd_proto; |
---|
1277 | int8_t currenthops; // number of hops (cccam & gbox) |
---|
1278 | #ifdef MODULE_CCCAM |
---|
1279 | char cc_version[7]; // cccam version |
---|
1280 | char cc_build[7]; // cccam build number |
---|
1281 | int8_t cc_maxhops; // cccam max distance |
---|
1282 | int8_t cc_mindown; // cccam min downhops |
---|
1283 | int8_t cc_want_emu; // Schlocke: Client want to have EMUs, 0 - NO; 1 - YES |
---|
1284 | uint32_t cc_id; |
---|
1285 | int8_t cc_keepalive; |
---|
1286 | int8_t cc_hop; // For non-cccam reader: hop for virtual cards |
---|
1287 | int8_t cc_reshare; |
---|
1288 | int32_t cc_reconnect; //reconnect on ecm-request timeout |
---|
1289 | #endif |
---|
1290 | int8_t tcp_connected; |
---|
1291 | int32_t tcp_ito; // inactivity timeout |
---|
1292 | int32_t tcp_rto; // reconnect timeout |
---|
1293 | int32_t tcp_reconnect_delay; // max tcp connection block delay |
---|
1294 | |
---|
1295 | struct timeb tcp_block_connect_till; //time tcp connect ist blocked |
---|
1296 | int32_t tcp_block_delay; //incrementing block time |
---|
1297 | time_t last_g; // get (if last_s-last_g>tcp_rto - reconnect ) |
---|
1298 | time_t last_s; // send |
---|
1299 | time_t last_check; // last checked |
---|
1300 | FTAB fchid; |
---|
1301 | FTAB ftab; |
---|
1302 | CLASSTAB cltab; |
---|
1303 | struct s_ecmWhitelist *ecmWhitelist; |
---|
1304 | struct s_ecmHeaderwhitelist *ecmHeaderwhitelist; // ECM Header Whitelist |
---|
1305 | int32_t brk_pos; |
---|
1306 | int32_t msg_idx; |
---|
1307 | int32_t secatype; // 0=not determined, 2=seca2, 3=nagra(~seca3) this is only valid for localreaders! |
---|
1308 | uint32_t maxreadtimeout; // in us |
---|
1309 | uint32_t minreadtimeout; // in us |
---|
1310 | uint32_t maxwritetimeout; // in us |
---|
1311 | uint32_t minwritetimeout; // in us |
---|
1312 | #if defined(WEBIF) || defined(LCDSUPPORT) |
---|
1313 | int32_t emmwritten[4]; // count written EMM |
---|
1314 | int32_t emmskipped[4]; // count skipped EMM |
---|
1315 | int32_t emmerror[4]; // count error EMM |
---|
1316 | int32_t emmblocked[4]; // count blocked EMM |
---|
1317 | int32_t lbvalue; // loadbalance Value |
---|
1318 | #endif |
---|
1319 | #ifdef WITH_AZBOX |
---|
1320 | int32_t azbox_mode; |
---|
1321 | #endif |
---|
1322 | int32_t use_gpio; // Should this reader use GPIO functions |
---|
1323 | int gpio_outen; // fd of opened /dev/gpio/outen |
---|
1324 | int gpio_out; // fd of opened /dev/gpio/out |
---|
1325 | int gpio_in; // fd of opened /dev/gpio/in |
---|
1326 | uint32_t gpio; // gpio addr |
---|
1327 | ////variables from icc_async.h start |
---|
1328 | #ifdef WITH_CARDREADER |
---|
1329 | int32_t convention; // Convention of this ICC |
---|
1330 | unsigned char protocol_type; // Type of protocol |
---|
1331 | uint32_t current_baudrate; // (for overclocking uncorrected) baudrate to prevent unnecessary conversions from/to termios structure |
---|
1332 | double worketu; // in us for internal and external readers calculated (1/D)*(F/cardclock)*1000000 |
---|
1333 | uint32_t read_timeout; // Max timeout (ETU) to receive characters |
---|
1334 | uint32_t char_delay; // Delay (ETU) after transmiting each successive char |
---|
1335 | uint32_t block_delay; // Delay (ms) after starting to transmit |
---|
1336 | uint32_t BWT, CWT; // (for overclocking uncorrected) block waiting time, character waiting time, in ETU |
---|
1337 | ////variables from io_serial.h |
---|
1338 | int32_t written; // keep score of how much bytes are written to serial port, since they are echoed back they have to be read |
---|
1339 | ////variables from protocol_t1.h |
---|
1340 | uint16_t ifsc; // Information field size for the ICC |
---|
1341 | unsigned char ns; // Send sequence number |
---|
1342 | int16_t smartdev_found; |
---|
1343 | int16_t smart_type; |
---|
1344 | uint16_t statuscnt; |
---|
1345 | uint16_t modemstat; |
---|
1346 | #endif |
---|
1347 | unsigned char rom[15]; |
---|
1348 | unsigned char irdId[4]; |
---|
1349 | #ifdef WITH_LB |
---|
1350 | int32_t lb_weight; //loadbalance weight factor, if unset, weight=100. The higher the value, the higher the usage-possibility |
---|
1351 | int32_t lb_usagelevel; //usagelevel for loadbalancer |
---|
1352 | int32_t lb_usagelevel_ecmcount; |
---|
1353 | struct timeb lb_usagelevel_time; //time for counting ecms, this creates usagelevel |
---|
1354 | struct timeb lb_last; //time for oldest reader |
---|
1355 | LLIST *lb_stat; //loadbalancer reader statistics |
---|
1356 | CS_MUTEX_LOCK lb_stat_lock; |
---|
1357 | #endif |
---|
1358 | |
---|
1359 | AES_ENTRY *aes_list; // multi AES linked list |
---|
1360 | int8_t ndsversion; // 0 auto (default), 1 NDS1, 12 NDS1+, 2 NDS2 |
---|
1361 | time_t card_valid_to; |
---|
1362 | //ratelimit |
---|
1363 | int32_t ratelimitecm; |
---|
1364 | int32_t ratelimittime; // ratelimit time in ms (everything below 60 ms is converted to ms by applying *1000) |
---|
1365 | int8_t ecmunique; // check for matching ecm hash in ratelimitslot |
---|
1366 | int32_t srvidholdtime; // time in ms to keep srvid in ratelimitslot (during this time not checked for ecmunique!) |
---|
1367 | // (everything below 60 ms is converted to ms by applying *1000) |
---|
1368 | struct timeb lastdvbapirateoverride; |
---|
1369 | uint32_t ecmsok; |
---|
1370 | uint32_t ecmsnok; |
---|
1371 | uint32_t ecmnotfoundlimit; // config setting. restart reader if ecmsnok >= ecmnotfoundlimit |
---|
1372 | int32_t ecmsfilteredhead; // count filtered ECM's by ECM Headerwhitelist |
---|
1373 | int32_t ecmsfilteredlen; // count filtered ECM's by ECM Whitelist |
---|
1374 | float ecmshealthok; |
---|
1375 | float ecmshealthnok; |
---|
1376 | int32_t cooldown[2]; |
---|
1377 | int8_t cooldownstate; |
---|
1378 | struct timeb cooldowntime; |
---|
1379 | struct ecmrl rlecmh[MAXECMRATELIMIT]; |
---|
1380 | int8_t fix_9993; |
---|
1381 | uint8_t ins7E[0x1A + 1]; |
---|
1382 | uint8_t ins7E11[0x01 + 1]; |
---|
1383 | int8_t ins7e11_fast_reset; |
---|
1384 | uint8_t sc8in1_dtrrts_patch; // fix for kernel commit 6a1a82df91fa0eb1cc76069a9efe5714d087eccd |
---|
1385 | #ifdef MODULE_GBOX |
---|
1386 | int8_t gbox_maxdist; |
---|
1387 | int8_t gbox_maxecmsend; |
---|
1388 | int8_t gbox_reshare; |
---|
1389 | #endif |
---|
1390 | |
---|
1391 | #ifdef MODULE_PANDORA |
---|
1392 | uint8_t pand_send_ecm; |
---|
1393 | #endif |
---|
1394 | #ifdef MODULE_GHTTP |
---|
1395 | uint8_t ghttp_use_ssl; |
---|
1396 | #endif |
---|
1397 | uint8_t cnxlastecm; // == 0 - las ecm has not been paired ecm, > 0 last ecm has been paired ecm |
---|
1398 | |
---|
1399 | struct s_reader *next; |
---|
1400 | }; |
---|
1401 | |
---|
1402 | struct s_cpmap |
---|
1403 | { |
---|
1404 | uint16_t caid; |
---|
1405 | uint32_t provid; |
---|
1406 | uint16_t sid; |
---|
1407 | uint16_t chid; |
---|
1408 | uint16_t dwtime; |
---|
1409 | struct s_cpmap *next; |
---|
1410 | }; |
---|
1411 | |
---|
1412 | struct s_auth |
---|
1413 | { |
---|
1414 | char usr[64]; |
---|
1415 | char *pwd; |
---|
1416 | #ifdef WEBIF |
---|
1417 | char *description; |
---|
1418 | #endif |
---|
1419 | int8_t uniq; |
---|
1420 | #ifdef CS_CACHEEX |
---|
1421 | CECSP cacheex; //CacheEx Settings |
---|
1422 | uint8_t no_wait_time; |
---|
1423 | #endif |
---|
1424 | int16_t allowedprotocols; |
---|
1425 | LLIST *aureader_list; |
---|
1426 | int8_t autoau; |
---|
1427 | uint8_t emm_reassembly; // 0 = OFF; 1 = OFF / DVBAPI = ON; 2 = ON (default) |
---|
1428 | int8_t monlvl; |
---|
1429 | uint64_t grp; |
---|
1430 | int32_t tosleep; |
---|
1431 | uint32_t umaxidle; |
---|
1432 | CAIDTAB ctab; |
---|
1433 | SIDTABS sidtabs; |
---|
1434 | FTAB fchid; |
---|
1435 | FTAB ftab; // user [caid] and ident filter |
---|
1436 | CLASSTAB cltab; |
---|
1437 | TUNTAB ttab; |
---|
1438 | #ifdef CS_ANTICASC |
---|
1439 | int32_t ac_fakedelay; // When this is -1, the global ac_fakedelay is used |
---|
1440 | int32_t ac_users; // 0 - unlimited |
---|
1441 | int8_t ac_penalty; // 0 - log, >0 - fake dw |
---|
1442 | struct s_acasc ac_stat; |
---|
1443 | #endif |
---|
1444 | #ifdef WITH_LB |
---|
1445 | int32_t lb_nbest_readers; // When this is -1, the global lb_nbest_readers is used |
---|
1446 | int32_t lb_nfb_readers; // When this is -1, the global lb_nfb_readers is used |
---|
1447 | CAIDVALUETAB lb_nbest_readers_tab; // like nbest_readers, but for special caids |
---|
1448 | #endif |
---|
1449 | IN_ADDR_T dynip; |
---|
1450 | char *dyndns; |
---|
1451 | time_t expirationdate; |
---|
1452 | time_t firstlogin; |
---|
1453 | int32_t allowedtimeframe[2]; |
---|
1454 | int8_t c35_suppresscmd08; |
---|
1455 | uint8_t c35_sleepsend; |
---|
1456 | int8_t ncd_keepalive; |
---|
1457 | #ifdef MODULE_CCCAM |
---|
1458 | int32_t cccmaxhops; |
---|
1459 | int8_t cccreshare; |
---|
1460 | int8_t cccignorereshare; |
---|
1461 | int8_t cccstealth; |
---|
1462 | #endif |
---|
1463 | int8_t disabled; |
---|
1464 | int32_t failban; |
---|
1465 | |
---|
1466 | int32_t cwfound; |
---|
1467 | int32_t cwcache; |
---|
1468 | int32_t cwnot; |
---|
1469 | int32_t cwtun; |
---|
1470 | int32_t cwignored; |
---|
1471 | int32_t cwtout; |
---|
1472 | #ifdef CW_CYCLE_CHECK |
---|
1473 | int32_t cwcycledchecked; // count checked cwcycles per client |
---|
1474 | int32_t cwcycledok; // count pos checked cwcycles per client |
---|
1475 | int32_t cwcyclednok; // count neg checked cwcycles per client |
---|
1476 | int32_t cwcycledign; // count ign cwcycles per client |
---|
1477 | #endif |
---|
1478 | int32_t emmok; |
---|
1479 | int32_t emmnok; |
---|
1480 | #ifdef CS_CACHEEX |
---|
1481 | int32_t cwcacheexpush; // count pushed ecms/cws |
---|
1482 | int32_t cwcacheexgot; // count got ecms/cws |
---|
1483 | int32_t cwcacheexhit; // count hit ecms/cws |
---|
1484 | int32_t cwcacheexerr; //cw=00 or chksum wrong |
---|
1485 | int32_t cwcacheexerrcw; //Same Hex, different CW |
---|
1486 | int32_t cwc_info; // count of in/out comming cacheex ecms with CWCinfo |
---|
1487 | #endif |
---|
1488 | struct s_auth *next; |
---|
1489 | }; |
---|
1490 | |
---|
1491 | struct s_srvid |
---|
1492 | { |
---|
1493 | uint16_t srvid; |
---|
1494 | int8_t ncaid; |
---|
1495 | uint16_t caid[10]; |
---|
1496 | char *data; |
---|
1497 | char *prov; |
---|
1498 | char *name; |
---|
1499 | char *type; |
---|
1500 | char *desc; |
---|
1501 | struct s_srvid *next; |
---|
1502 | }; |
---|
1503 | |
---|
1504 | struct s_rlimit |
---|
1505 | { |
---|
1506 | struct ecmrl rl; |
---|
1507 | struct s_rlimit *next; |
---|
1508 | }; |
---|
1509 | |
---|
1510 | struct s_tierid |
---|
1511 | { |
---|
1512 | uint16_t tierid; |
---|
1513 | int8_t ncaid; |
---|
1514 | uint16_t caid[10]; |
---|
1515 | char name[33]; |
---|
1516 | struct s_tierid *next; |
---|
1517 | }; |
---|
1518 | |
---|
1519 | struct s_provid |
---|
1520 | { |
---|
1521 | uint16_t caid; |
---|
1522 | uint32_t provid; |
---|
1523 | char prov[33]; |
---|
1524 | char sat[33]; |
---|
1525 | char lang[33]; |
---|
1526 | struct s_provid *next; |
---|
1527 | }; |
---|
1528 | |
---|
1529 | struct s_ip |
---|
1530 | { |
---|
1531 | IN_ADDR_T ip[2]; |
---|
1532 | struct s_ip *next; |
---|
1533 | }; |
---|
1534 | |
---|
1535 | struct s_global_whitelist |
---|
1536 | { |
---|
1537 | uint32_t line; //linenr of oscam.whitelist file, starting with 1 |
---|
1538 | char type; // w or i or l |
---|
1539 | uint16_t caid; |
---|
1540 | uint32_t provid; |
---|
1541 | uint16_t srvid; |
---|
1542 | uint16_t chid; |
---|
1543 | uint16_t pid; |
---|
1544 | uint16_t ecmlen; |
---|
1545 | uint16_t mapcaid; |
---|
1546 | uint32_t mapprovid; |
---|
1547 | struct s_global_whitelist *next; |
---|
1548 | }; |
---|
1549 | |
---|
1550 | struct s_cacheex_matcher |
---|
1551 | { |
---|
1552 | uint32_t line; //linenr of oscam.Cacheex file, starting with 1 |
---|
1553 | char type; // m |
---|
1554 | uint16_t caid; |
---|
1555 | uint32_t provid; |
---|
1556 | uint16_t srvid; |
---|
1557 | uint16_t chid; |
---|
1558 | uint16_t pid; |
---|
1559 | uint16_t ecmlen; |
---|
1560 | |
---|
1561 | uint16_t to_caid; |
---|
1562 | uint32_t to_provid; |
---|
1563 | uint16_t to_srvid; |
---|
1564 | uint16_t to_chid; |
---|
1565 | uint16_t to_pid; |
---|
1566 | uint16_t to_ecmlen; |
---|
1567 | |
---|
1568 | int32_t valid_from; |
---|
1569 | int32_t valid_to; |
---|
1570 | |
---|
1571 | struct s_cacheex_matcher *next; |
---|
1572 | }; |
---|
1573 | |
---|
1574 | struct s_config |
---|
1575 | { |
---|
1576 | int32_t nice; |
---|
1577 | uint32_t netprio; |
---|
1578 | uint32_t ctimeout; |
---|
1579 | uint32_t ftimeout; |
---|
1580 | CAIDVALUETAB ftimeouttab; |
---|
1581 | uint32_t cmaxidle; |
---|
1582 | int32_t ulparent; |
---|
1583 | uint32_t delay; |
---|
1584 | int32_t bindwait; |
---|
1585 | int32_t tosleep; |
---|
1586 | IN_ADDR_T srvip; |
---|
1587 | char *usrfile; |
---|
1588 | char *cwlogdir; |
---|
1589 | char *emmlogdir; |
---|
1590 | char *logfile; |
---|
1591 | char *mailfile; |
---|
1592 | uint8_t logtostdout; |
---|
1593 | uint8_t logtosyslog; |
---|
1594 | int8_t logduplicatelines; |
---|
1595 | #if defined(WEBIF) || defined(MODULE_MONITOR) |
---|
1596 | uint32_t loghistorysize; |
---|
1597 | #endif |
---|
1598 | int8_t disablelog; |
---|
1599 | int8_t disablemail; |
---|
1600 | int8_t disableuserfile; |
---|
1601 | int8_t usrfileflag; |
---|
1602 | struct s_auth *account; |
---|
1603 | struct s_srvid *srvid[16]; |
---|
1604 | struct s_tierid *tierid; |
---|
1605 | //Todo #ifdef CCCAM |
---|
1606 | struct s_provid *provid; |
---|
1607 | struct s_sidtab *sidtab; |
---|
1608 | #ifdef MODULE_MONITOR |
---|
1609 | int32_t mon_port; |
---|
1610 | IN_ADDR_T mon_srvip; |
---|
1611 | struct s_ip *mon_allowed; |
---|
1612 | uint8_t mon_level; |
---|
1613 | #endif |
---|
1614 | int32_t aulow; |
---|
1615 | int32_t hideclient_to; |
---|
1616 | #ifdef WEBIF |
---|
1617 | int32_t http_port; |
---|
1618 | IN_ADDR_T http_srvip; |
---|
1619 | char *http_user; |
---|
1620 | char *http_pwd; |
---|
1621 | char *http_css; |
---|
1622 | int32_t http_prepend_embedded_css; |
---|
1623 | char *http_jscript; |
---|
1624 | char *http_tpl; |
---|
1625 | char *http_script; |
---|
1626 | int32_t http_refresh; |
---|
1627 | int8_t http_hide_idle_clients; |
---|
1628 | char *http_hide_type; |
---|
1629 | int8_t http_showpicons; |
---|
1630 | int8_t http_picon_size; |
---|
1631 | int8_t http_showmeminfo; |
---|
1632 | int8_t http_showecminfo; |
---|
1633 | int8_t http_showloadinfo; |
---|
1634 | int8_t http_showuserinfo; |
---|
1635 | int8_t http_showcacheexinfo; |
---|
1636 | struct s_ip *http_allowed; |
---|
1637 | int8_t http_readonly; |
---|
1638 | IN_ADDR_T http_dynip[MAX_HTTP_DYNDNS]; |
---|
1639 | uchar http_dyndns[MAX_HTTP_DYNDNS][64]; |
---|
1640 | int8_t http_use_ssl; |
---|
1641 | int8_t http_force_sslv3; |
---|
1642 | char *http_cert; |
---|
1643 | char *http_help_lang; |
---|
1644 | char *http_oscam_label; |
---|
1645 | #endif |
---|
1646 | int8_t http_full_cfg; |
---|
1647 | int32_t failbantime; |
---|
1648 | int32_t failbancount; |
---|
1649 | LLIST *v_list; // Failban list |
---|
1650 | #ifdef MODULE_CAMD33 |
---|
1651 | int32_t c33_port; |
---|
1652 | IN_ADDR_T c33_srvip; |
---|
1653 | uint8_t c33_key[16]; |
---|
1654 | int32_t c33_crypted; |
---|
1655 | int32_t c33_passive; |
---|
1656 | struct s_ip *c33_plain; |
---|
1657 | #endif |
---|
1658 | #if defined(MODULE_CAMD35) || defined(MODULE_CAMD35_TCP) |
---|
1659 | int32_t c35_port; |
---|
1660 | IN_ADDR_T c35_srvip; |
---|
1661 | int8_t c35_tcp_suppresscmd08; |
---|
1662 | int8_t c35_udp_suppresscmd08; |
---|
1663 | PTAB c35_tcp_ptab; |
---|
1664 | IN_ADDR_T c35_tcp_srvip; |
---|
1665 | #endif |
---|
1666 | int8_t c35_suppresscmd08; // used in cccam module |
---|
1667 | uint32_t umaxidle; //User max Idle |
---|
1668 | #ifdef MODULE_NEWCAMD |
---|
1669 | PTAB ncd_ptab; |
---|
1670 | IN_ADDR_T ncd_srvip; |
---|
1671 | uint8_t ncd_key[14]; |
---|
1672 | int8_t ncd_keepalive; |
---|
1673 | int8_t ncd_mgclient; |
---|
1674 | struct s_ip *ncd_allowed; |
---|
1675 | #endif |
---|
1676 | #ifdef MODULE_RADEGAST |
---|
1677 | int32_t rad_port; |
---|
1678 | IN_ADDR_T rad_srvip; |
---|
1679 | struct s_ip *rad_allowed; |
---|
1680 | char *rad_usr; |
---|
1681 | #endif |
---|
1682 | #ifdef MODULE_CCCAM |
---|
1683 | uint16_t cc_port[CS_MAXPORTS]; |
---|
1684 | int8_t cc_reshare; |
---|
1685 | int8_t cc_ignore_reshare; |
---|
1686 | int32_t cc_update_interval; |
---|
1687 | IN_ADDR_T cc_srvip; |
---|
1688 | char cc_version[7]; |
---|
1689 | int8_t cc_minimize_cards; |
---|
1690 | int8_t cc_keep_connected; |
---|
1691 | int8_t cc_stealth; |
---|
1692 | int8_t cc_reshare_services; |
---|
1693 | int8_t cc_forward_origin_card; |
---|
1694 | uint8_t cc_fixed_nodeid[8]; |
---|
1695 | uint32_t cc_recv_timeout; // The poll() timeout parameter in ms. Default: DEFAULT_CC_RECV_TIMEOUT (2000 ms). |
---|
1696 | #endif |
---|
1697 | #ifdef MODULE_GBOX |
---|
1698 | char *gbox_hostname; |
---|
1699 | int32_t gbox_reconnect; |
---|
1700 | int32_t gbox_port; |
---|
1701 | char gbox_my_password[9]; |
---|
1702 | #endif |
---|
1703 | #ifdef MODULE_SERIAL |
---|
1704 | char *ser_device; |
---|
1705 | #endif |
---|
1706 | int32_t max_log_size; |
---|
1707 | int8_t waitforcards; |
---|
1708 | int32_t waitforcards_extra_delay; |
---|
1709 | int8_t preferlocalcards; |
---|
1710 | int32_t reader_restart_seconds; // schlocke: reader restart auf x seconds, disable = 0 |
---|
1711 | int8_t dropdups; // drop duplicate logins |
---|
1712 | |
---|
1713 | |
---|
1714 | //Loadbalancer-Config: |
---|
1715 | #ifdef WITH_LB |
---|
1716 | int32_t lb_mode; // schlocke: reader loadbalancing mode |
---|
1717 | int32_t lb_save; // schlocke: load/save statistics to file, save every x ecms |
---|
1718 | int32_t lb_nbest_readers; // count of best readers |
---|
1719 | int32_t lb_nfb_readers; // count of fallback readers |
---|
1720 | int32_t lb_min_ecmcount; // minimal ecm count to evaluate lbvalues |
---|
1721 | int32_t lb_max_ecmcount; // maximum ecm count before reseting lbvalues |
---|
1722 | int32_t lb_reopen_seconds; // time between retrying failed readers/caids/prov/srv |
---|
1723 | int32_t lb_retrylimit; // reopen only happens if reader response time > retrylimit |
---|
1724 | CAIDVALUETAB lb_retrylimittab; |
---|
1725 | CAIDVALUETAB lb_nbest_readers_tab; // like nbest_readers, but for special caids |
---|
1726 | CAIDTAB lb_noproviderforcaid; // do not store loadbalancer stats with providers for this caid |
---|
1727 | char *lb_savepath; // path where the stat file is save. Empty=default=/tmp/.oscam/stat |
---|
1728 | int32_t lb_stat_cleanup; // duration in hours for cleaning old statistics |
---|
1729 | int32_t lb_max_readers; // limit the amount of readers during learning |
---|
1730 | int32_t lb_auto_betatunnel; // automatic selection of betatunnel convertion based on learned data |
---|
1731 | int32_t lb_auto_betatunnel_mode; // automatic selection of betatunnel direction |
---|
1732 | int32_t lb_auto_betatunnel_prefer_beta; // prefer-beta-over-nagra factor |
---|
1733 | int32_t lb_auto_timeout; // Automatic timeout by loadbalancer statistics |
---|
1734 | int32_t lb_auto_timeout_p; // percent added to avg time as timeout time |
---|
1735 | int32_t lb_auto_timeout_t; // minimal time added to avg time as timeout time |
---|
1736 | #endif |
---|
1737 | int32_t resolve_gethostbyname; |
---|
1738 | int8_t double_check; // schlocke: Double checks each ecm+dcw from two (or more) readers |
---|
1739 | CAIDTAB double_check_caid; // do not store loadbalancer stats with providers for this caid |
---|
1740 | |
---|
1741 | #ifdef HAVE_DVBAPI |
---|
1742 | int8_t dvbapi_enabled; |
---|
1743 | int8_t dvbapi_au; |
---|
1744 | char *dvbapi_usr; |
---|
1745 | int8_t dvbapi_boxtype; |
---|
1746 | int8_t dvbapi_pmtmode; |
---|
1747 | int8_t dvbapi_requestmode; |
---|
1748 | SIDTABS dvbapi_sidtabs; |
---|
1749 | int32_t dvbapi_delayer; // delayer ms, minimum time to write cw |
---|
1750 | #endif |
---|
1751 | |
---|
1752 | #ifdef CS_ANTICASC |
---|
1753 | int8_t ac_enabled; |
---|
1754 | int32_t ac_users; // num of users for account (0 - default) |
---|
1755 | int32_t ac_stime; // time to collect AC statistics (3 min - default) |
---|
1756 | int32_t ac_samples; // qty of samples |
---|
1757 | int8_t ac_penalty; // 0 - write to log |
---|
1758 | int32_t ac_fakedelay; // 100-1000 ms |
---|
1759 | int32_t ac_denysamples; |
---|
1760 | char *ac_logfile; |
---|
1761 | struct s_cpmap *cpmap; |
---|
1762 | #endif |
---|
1763 | |
---|
1764 | #ifdef LEDSUPPORT |
---|
1765 | int8_t enableled; // 0=disabled led, 1=enable led for routers, 2=enable qboxhd led |
---|
1766 | #endif |
---|
1767 | |
---|
1768 | #ifdef LCDSUPPORT |
---|
1769 | int8_t enablelcd; |
---|
1770 | char *lcd_output_path; |
---|
1771 | int32_t lcd_hide_idle; |
---|
1772 | int32_t lcd_write_intervall; |
---|
1773 | #endif |
---|
1774 | |
---|
1775 | #ifdef MODULE_PANDORA |
---|
1776 | int8_t pand_skip_send_dw; |
---|
1777 | struct s_ip *pand_allowed; |
---|
1778 | char *pand_usr; |
---|
1779 | char *pand_pass; |
---|
1780 | int8_t pand_ecm; |
---|
1781 | int32_t pand_port; |
---|
1782 | IN_ADDR_T pand_srvip; |
---|
1783 | #endif |
---|
1784 | |
---|
1785 | int32_t max_cache_time; //seconds ecms are stored in ecmcwcache |
---|
1786 | int32_t max_hitcache_time; //seconds hits are stored in cspec_hitcache (to detect dyn wait_time) |
---|
1787 | |
---|
1788 | int8_t block_same_ip; //0=allow all, 1=block client requests to reader with same ip (default=1) |
---|
1789 | int8_t block_same_name; //0=allow all, 1=block client requests to reader with same name (default=1) |
---|
1790 | |
---|
1791 | #ifdef CS_CACHEEX |
---|
1792 | uint8_t wait_until_ctimeout; |
---|
1793 | CWCHECKTAB cacheex_cwcheck_tab; |
---|
1794 | IN_ADDR_T csp_srvip; |
---|
1795 | int32_t csp_port; |
---|
1796 | CECSPVALUETAB cacheex_wait_timetab; |
---|
1797 | CECSP csp; //CSP Settings |
---|
1798 | uint8_t cacheex_enable_stats; //enable stats |
---|
1799 | struct s_cacheex_matcher *cacheex_matcher; |
---|
1800 | #endif |
---|
1801 | |
---|
1802 | #ifdef CW_CYCLE_CHECK |
---|
1803 | int8_t cwcycle_check_enable; // on or off |
---|
1804 | CAIDTAB cwcycle_check_caidtab; // Caid for CW Cycle Check |
---|
1805 | int32_t keepcycletime; // how long stay the learned Cycletime in Memory |
---|
1806 | int32_t maxcyclelist; // max size of cwcyclelist |
---|
1807 | int8_t onbadcycle; // what to do on bad cwcycle |
---|
1808 | int8_t cwcycle_dropold; // what to do on old ecmd5/cw |
---|
1809 | int8_t cwcycle_sensitive; |
---|
1810 | int8_t cwcycle_allowbadfromffb; //allow Bad cycles from Fixed Fallbackreader |
---|
1811 | int8_t cwcycle_usecwcfromce; //Use CWC Info from Cacheex Sources for CWC Checking |
---|
1812 | #endif |
---|
1813 | |
---|
1814 | //Global whitelist: |
---|
1815 | struct s_global_whitelist *global_whitelist; |
---|
1816 | int8_t global_whitelist_use_l; |
---|
1817 | int8_t global_whitelist_use_m; |
---|
1818 | |
---|
1819 | char *ecmfmt; |
---|
1820 | char *pidfile; |
---|
1821 | |
---|
1822 | int32_t max_pending; |
---|
1823 | |
---|
1824 | //Ratelimit list |
---|
1825 | struct s_rlimit *ratelimit_list; |
---|
1826 | }; |
---|
1827 | |
---|
1828 | struct s_clientinit |
---|
1829 | { |
---|
1830 | void *(*handler)(struct s_client *); |
---|
1831 | struct s_client *client; |
---|
1832 | }; |
---|
1833 | |
---|
1834 | struct s_clientmsg |
---|
1835 | { |
---|
1836 | uint8_t msg[1024]; |
---|
1837 | int32_t len; |
---|
1838 | int32_t cmd; |
---|
1839 | }; |
---|
1840 | |
---|
1841 | typedef struct reader_stat_t |
---|
1842 | { |
---|
1843 | int32_t rc; |
---|
1844 | uint16_t caid; |
---|
1845 | uint32_t prid; |
---|
1846 | uint16_t srvid; |
---|
1847 | uint32_t chid; |
---|
1848 | int16_t ecmlen; |
---|
1849 | |
---|
1850 | struct timeb last_received; |
---|
1851 | |
---|
1852 | int32_t ecm_count; |
---|
1853 | int32_t time_avg; |
---|
1854 | int32_t time_stat[LB_MAX_STAT_TIME]; |
---|
1855 | int32_t time_idx; |
---|
1856 | |
---|
1857 | int8_t knocked; |
---|
1858 | |
---|
1859 | int32_t fail_factor; |
---|
1860 | } READER_STAT; |
---|
1861 | |
---|
1862 | typedef struct cs_stat_query |
---|
1863 | { |
---|
1864 | uint16_t caid; |
---|
1865 | uint32_t prid; |
---|
1866 | uint16_t srvid; |
---|
1867 | uint32_t chid; |
---|
1868 | int16_t ecmlen; |
---|
1869 | } STAT_QUERY; |
---|
1870 | |
---|
1871 | |
---|
1872 | typedef struct emm_packet_t |
---|
1873 | { |
---|
1874 | uchar emm[258]; |
---|
1875 | int16_t emmlen; |
---|
1876 | uchar caid[2]; |
---|
1877 | uchar provid[4]; |
---|
1878 | uchar hexserial[8]; //contains hexserial or SA of EMM |
---|
1879 | uchar type; |
---|
1880 | uint8_t skip_filter_check; |
---|
1881 | struct s_client *client; |
---|
1882 | } EMM_PACKET; |
---|
1883 | |
---|
1884 | |
---|
1885 | struct s_write_from_cache |
---|
1886 | { |
---|
1887 | ECM_REQUEST *er_new; |
---|
1888 | ECM_REQUEST *er_cache; |
---|
1889 | }; |
---|
1890 | |
---|
1891 | |
---|
1892 | /* =========================== |
---|
1893 | * global variables |
---|
1894 | * =========================== */ |
---|
1895 | extern pthread_key_t getclient; |
---|
1896 | extern struct s_client *first_client; |
---|
1897 | extern CS_MUTEX_LOCK config_lock; |
---|
1898 | extern CS_MUTEX_LOCK clientlist_lock; |
---|
1899 | extern CS_MUTEX_LOCK readerlist_lock; |
---|
1900 | extern struct s_reader *first_active_reader; //points to list of _active_ readers (enable = 1, deleted = 0) |
---|
1901 | extern LLIST *configured_readers; |
---|
1902 | |
---|
1903 | // These are used pretty much everywhere |
---|
1904 | extern struct s_config cfg; |
---|
1905 | extern uint16_t cs_dblevel; |
---|
1906 | |
---|
1907 | #include "oscam-log.h" |
---|
1908 | #include "oscam-log-reader.h" |
---|
1909 | |
---|
1910 | // Add here *only* funcs that are implemented in oscam.c and are called in other places |
---|
1911 | void cs_exit(int32_t sig); |
---|
1912 | void cs_exit_oscam(void); |
---|
1913 | void cs_restart_oscam(void); |
---|
1914 | int32_t cs_get_restartmode(void); |
---|
1915 | |
---|
1916 | void set_thread_name(const char *thread_name); |
---|
1917 | void start_thread(void *startroutine, char *nameroutine); |
---|
1918 | void kill_thread(struct s_client *cl); |
---|
1919 | |
---|
1920 | struct s_module *get_module(struct s_client *cl); |
---|
1921 | void module_reader_set(struct s_reader *rdr); |
---|
1922 | |
---|
1923 | // Until we find a better place for these (they are implemented in oscam-simples.h) |
---|
1924 | char *get_servicename(struct s_client *cl, uint16_t srvid, uint16_t caid, char *buf); |
---|
1925 | char *get_servicename_or_null(struct s_client *cl, uint16_t srvid, uint16_t caid, char *buf); |
---|
1926 | char *get_tiername(uint16_t tierid, uint16_t caid, char *buf); |
---|
1927 | char *get_provider(uint16_t caid, uint32_t provid, char *buf, uint32_t buflen); |
---|
1928 | void add_provider(uint16_t caid, uint32_t provid, const char *name, const char *sat, const char *lang); |
---|
1929 | |
---|
1930 | #endif |
---|