1 | #define _GNU_SOURCE //prevents "implicit" warning for asprintf
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <assert.h>
|
---|
5 | #include <fcntl.h>
|
---|
6 | #include <sys/ioctl.h>
|
---|
7 | #include <sys/poll.h>
|
---|
8 | #include <ctype.h>
|
---|
9 | #include <sys/types.h>
|
---|
10 | #include <sys/stat.h>
|
---|
11 | #include <sys/shm.h>
|
---|
12 | #include <sys/wait.h>
|
---|
13 | #include <unistd.h>
|
---|
14 | #include <sys/mman.h>
|
---|
15 | #include <stdarg.h>
|
---|
16 | #include <time.h>
|
---|
17 | #include <sys/timeb.h>
|
---|
18 | #include <limits.h>
|
---|
19 | #include <pwd.h>
|
---|
20 | #include <netinet/tcp.h>
|
---|
21 |
|
---|
22 | #include <sys/socket.h>
|
---|
23 | #include <netinet/in.h>
|
---|
24 | #include <arpa/inet.h>
|
---|
25 | #include <netdb.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <signal.h>
|
---|
28 | #include <errno.h>
|
---|
29 |
|
---|
30 | #include <pthread.h>
|
---|
31 |
|
---|
32 | #include "module-datastruct-llist.h"
|
---|
33 |
|
---|
34 | //for reader-nagra variables in s_reader:
|
---|
35 | #include "cscrypt/idea.h"
|
---|
36 |
|
---|
37 | #ifndef CS_GLOBALS
|
---|
38 | #define CS_GLOBALS
|
---|
39 | #define CS_VERSION "1.00-unstable_svn"
|
---|
40 | #ifndef CS_SVN_VERSION
|
---|
41 | # define CS_SVN_VERSION "test"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #if defined(__GNUC__) && !defined(__arm__)
|
---|
45 | # define GCC_PACK __attribute__((packed))
|
---|
46 | #else
|
---|
47 | # define GCC_PACK
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | #include "oscam-config.h"
|
---|
51 |
|
---|
52 | #ifdef UNUSED
|
---|
53 | #elif defined(__GNUC__)
|
---|
54 | # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
---|
55 | #elif defined(__LCLINT__)
|
---|
56 | # define UNUSED(x) /*@unused@*/ x
|
---|
57 | #else
|
---|
58 | # define UNUSED(x) x
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | #ifdef WITH_DEBUG
|
---|
62 | # define call(arg) \
|
---|
63 | if (arg) { \
|
---|
64 | cs_debug_mask(D_TRACE, "ERROR, function call %s returns error.",#arg); \
|
---|
65 | return ERROR; \
|
---|
66 | }
|
---|
67 | # define D_USE(x) x
|
---|
68 | #else
|
---|
69 | # define call(arg) arg
|
---|
70 | # if defined(__GNUC__)
|
---|
71 | # define D_USE(x) D_USE_ ## x __attribute__((unused))
|
---|
72 | # elif defined(__LCLINT__)
|
---|
73 | # define D_USE(x) /*@debug use only@*/ x
|
---|
74 | # else
|
---|
75 | # define D_USE(x) x
|
---|
76 | # endif
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | #ifndef USE_CMAKE
|
---|
80 | # include "oscam-ostype.h"
|
---|
81 | #endif
|
---|
82 | #include "oscam-types.h"
|
---|
83 | #include "cscrypt/cscrypt.h"
|
---|
84 |
|
---|
85 | #ifdef HAVE_PCSC
|
---|
86 | #ifdef OS_CYGWIN32
|
---|
87 | #define __reserved
|
---|
88 | #define __nullnullterminated
|
---|
89 | #include <specstrings.h>
|
---|
90 | #include "cygwin/WinSCard.h"
|
---|
91 | #else
|
---|
92 | #include <PCSC/pcsclite.h>
|
---|
93 | #ifdef OS_MACOSX
|
---|
94 | #include <PCSC/wintypes.h>
|
---|
95 | #else
|
---|
96 | #include <PCSC/reader.h>
|
---|
97 | #endif
|
---|
98 | #endif
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | #if defined(LIBUSB)
|
---|
102 | #ifdef __FreeBSD__
|
---|
103 | #include <libusb.h>
|
---|
104 | #else
|
---|
105 | #include <libusb-1.0/libusb.h>
|
---|
106 | #endif
|
---|
107 | #include "csctapi/smartreader_types.h"
|
---|
108 | #endif
|
---|
109 |
|
---|
110 | #ifndef CS_CONFDIR
|
---|
111 | #define CS_CONFDIR "/usr/local/etc"
|
---|
112 | #endif
|
---|
113 | #ifndef CS_LOGFILE
|
---|
114 | #define CS_LOGFILE "/var/log/oscam.log"
|
---|
115 | #endif
|
---|
116 | #define CS_QLEN 128 // size of request queue
|
---|
117 | #define CS_MAXCAIDTAB 32 // max. caid-defs/user
|
---|
118 | #define CS_MAXTUNTAB 20 // max. betatunnel mappings
|
---|
119 | #define CS_MAXPROV 32
|
---|
120 | #define CS_MAXPORTS 32 // max server ports
|
---|
121 | #define CS_MAXFILTERS 16
|
---|
122 | #define CS_MAX_LB_RETRYLIMIT 16
|
---|
123 |
|
---|
124 | #define CS_ECMSTORESIZE 16 // use MD5()
|
---|
125 | #define CS_EMMSTORESIZE 16 // use MD5()
|
---|
126 | #define CS_CLIENT_TIMEOUT 5000
|
---|
127 | #define CS_CLIENT_MAXIDLE 120
|
---|
128 | #define CS_BIND_TIMEOUT 120
|
---|
129 | #define CS_DELAY 0
|
---|
130 | #define CS_MAXLOGHIST 30
|
---|
131 | #define CS_LOGHISTSIZE 193 // 32+128+33: username + logline + channelname
|
---|
132 |
|
---|
133 | #ifndef PTHREAD_STACK_MIN
|
---|
134 | #define PTHREAD_STACK_MIN 64000
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #ifdef CS_EMBEDDED
|
---|
138 | #define CS_MAXPENDING 16
|
---|
139 | #define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN+8000
|
---|
140 | #else
|
---|
141 | #define CS_MAXPENDING 32
|
---|
142 | #define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN+10000
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | #define CS_EMMCACHESIZE 64 //nr of EMMs that each client will cache; cache is per client, so memory-expensive...
|
---|
146 |
|
---|
147 | #define D_TRACE 1 // Generate very detailed error/trace messages per routine
|
---|
148 | #define D_ATR 2 // Debug ATR parsing, dump of ecm, cw
|
---|
149 | #define D_READER 4 // Debug Reader/Proxy Process
|
---|
150 | #define D_CLIENT 8 // Debug Client Process
|
---|
151 | #define D_IFD 16 // Debug IFD+protocol
|
---|
152 | #define D_DEVICE 32 // Debug Reader I/O
|
---|
153 | #define D_EMM 64 // Dumps EMM
|
---|
154 | #define D_DVBAPI 128 // Debug DVBAPI
|
---|
155 | #define D_ALL_DUMP 255 // dumps all
|
---|
156 |
|
---|
157 | #define R_DB2COM1 0x1 // Reader Dbox2 @ com1
|
---|
158 | #define R_DB2COM2 0x2 // Reader Dbox2 @ com1
|
---|
159 | #define R_SC8in1 0x3 // Reader Sc8in1 or MCR
|
---|
160 | #define R_MP35 0x4 // AD-Teknik Multiprogrammer 3.5 and 3.6 (only usb tested)
|
---|
161 | #define R_MOUSE 0x5 // Reader smartcard mouse
|
---|
162 | /////////////////// phoenix readers which need baudrate setting and timings need to be guarded by OSCam: BEFORE R_MOUSE
|
---|
163 | #define R_INTERNAL 0x6 // Reader smartcard intern
|
---|
164 | /////////////////// internal readers (Dreambox, Coolstream, IPBox) are all R_INTERNAL, they are determined compile-time
|
---|
165 | /////////////////// readers that do not reed baudrate setting and timings are guarded by reader itself (large buffer built in): AFTER R_SMART
|
---|
166 | #define R_SMART 0x7 // Smartreader+
|
---|
167 | #define R_PCSC 0x8 // PCSC
|
---|
168 | /////////////////// proxy readers after R_CS378X
|
---|
169 | #define R_CAMD35 0x20 // Reader cascading camd 3.5x
|
---|
170 | #define R_CAMD33 0x21 // Reader cascading camd 3.3x
|
---|
171 | #define R_NEWCAMD 0x22 // Reader cascading newcamd
|
---|
172 | #define R_RADEGAST 0x23 // Reader cascading radegast
|
---|
173 | #define R_CS378X 0x24 // Reader cascading camd 3.5x TCP
|
---|
174 | #define R_CONSTCW 0x25 // Reader for Constant CW
|
---|
175 | /////////////////// peer to peer proxy readers after R_CCCAM
|
---|
176 | #define R_GBOX 0x30 // Reader cascading gbox
|
---|
177 | #define R_CCCAM 0x35 // Reader cascading cccam
|
---|
178 | #define R_SERIAL 0x80 // Reader serial
|
---|
179 | #define R_IS_NETWORK 0x60
|
---|
180 | #define R_IS_CASCADING 0xE0
|
---|
181 |
|
---|
182 | //ECM rc codes, reader only:
|
---|
183 | #define E_RDR_NOTFOUND 0
|
---|
184 | #define E_RDR_FOUND 1
|
---|
185 | //ECM rc codes:
|
---|
186 | #define E_FOUND 0
|
---|
187 | #define E_CACHE1 1
|
---|
188 | #define E_CACHE2 2
|
---|
189 | #define E_EMU 3
|
---|
190 | ///////above is all found
|
---|
191 | #define E_NOTFOUND 4 //for selection of found, use < E_NOTFOUND
|
---|
192 | #define E_TIMEOUT 5
|
---|
193 | #define E_SLEEPING 6
|
---|
194 | #define E_FAKE 7
|
---|
195 | #define E_INVALID 8
|
---|
196 | #define E_CORRUPT 9
|
---|
197 | #define E_NOCARD 10
|
---|
198 | #define E_EXPDATE 11
|
---|
199 | #define E_DISABLED 12
|
---|
200 | #define E_STOPPED 13 //for selection of error, use <= E_STOPPED and exclude selection of found
|
---|
201 | ///////above is all notfound, some error or problem
|
---|
202 | #define E_99 99 //this code is undocumented
|
---|
203 | #define E_UNHANDLED 100 //for selection of unhandled, use >= E_UNHANDLED
|
---|
204 |
|
---|
205 | #define CS_MAX_MOD 20
|
---|
206 | #define MOD_CONN_TCP 1
|
---|
207 | #define MOD_CONN_UDP 2
|
---|
208 | #define MOD_CONN_NET 3
|
---|
209 | #define MOD_CONN_SERIAL 4
|
---|
210 | #define MOD_NO_CONN 8
|
---|
211 |
|
---|
212 | #define MOD_CARDSYSTEM 16
|
---|
213 | #define MOD_ADDON 32
|
---|
214 |
|
---|
215 |
|
---|
216 | #ifdef HAVE_DVBAPI
|
---|
217 | #define BOXTYPE_DREAMBOX 1
|
---|
218 | #define BOXTYPE_DUCKBOX 2
|
---|
219 | #define BOXTYPE_UFS910 3
|
---|
220 | #define BOXTYPE_DBOX2 4
|
---|
221 | #define BOXTYPE_IPBOX 5
|
---|
222 | #define BOXTYPE_IPBOX_PMT 6
|
---|
223 | #define BOXTYPE_DM7000 7
|
---|
224 | #define BOXTYPE_QBOXHD 8
|
---|
225 | #define BOXTYPE_COOLSTREAM 9
|
---|
226 | #define BOXTYPE_NEUMO 10
|
---|
227 | #define BOXTYPES 10
|
---|
228 | extern const char *boxdesc[];
|
---|
229 | #endif
|
---|
230 |
|
---|
231 | #ifdef CS_CORE
|
---|
232 | char *PIP_ID_TXT[] = { "ECM", "EMM", "CIN", "KCL", "UDP", NULL };
|
---|
233 | char *RDR_CD_TXT[] = { "cd", "dsr", "cts", "ring", "none",
|
---|
234 | #ifdef USE_GPIO
|
---|
235 | "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7", //felix: changed so that gpio can be used
|
---|
236 | #endif
|
---|
237 | NULL };
|
---|
238 | #else
|
---|
239 | extern char *PIP_ID_TXT[];
|
---|
240 | extern char *RDR_CD_TXT[];
|
---|
241 | #endif
|
---|
242 |
|
---|
243 | #define PIP_ID_ECM 0
|
---|
244 | #define PIP_ID_EMM 1
|
---|
245 | #define PIP_ID_CIN 2 // CARD_INFO
|
---|
246 | #define PIP_ID_KCL 3 // Schlocke: Kill all Clients (no param)
|
---|
247 | #define PIP_ID_UDP 4
|
---|
248 | #define PIP_ID_MAX PIP_ID_UDP
|
---|
249 |
|
---|
250 |
|
---|
251 | #define PIP_ID_ERR (-1)
|
---|
252 | #define PIP_ID_DIR (-2)
|
---|
253 | #define PIP_ID_NUL (-3)
|
---|
254 |
|
---|
255 | #define cdiff *c_start
|
---|
256 |
|
---|
257 | #define NCD_AUTO 0
|
---|
258 | #define NCD_524 1
|
---|
259 | #define NCD_525 2
|
---|
260 |
|
---|
261 | // moved from reader-common.h
|
---|
262 | #define UNKNOWN 0
|
---|
263 | #define NO_CARD 4
|
---|
264 | #define CARD_NEED_INIT 1
|
---|
265 | #define CARD_INSERTED 2
|
---|
266 | #define CARD_FAILURE 3
|
---|
267 |
|
---|
268 | // moved from stats
|
---|
269 | #define DEFAULT_REOPEN_SECONDS 900
|
---|
270 | #define DEFAULT_MIN_ECM_COUNT 5
|
---|
271 | #define DEFAULT_MAX_ECM_COUNT 500
|
---|
272 | #define DEFAULT_NBEST 1
|
---|
273 | #define DEFAULT_NFB 1
|
---|
274 | #define DEFAULT_RETRYLIMIT 800
|
---|
275 | #define DEFAULT_LB_STAT_CLEANUP 336
|
---|
276 | #define DEFAULT_LB_USE_LOCKING 0
|
---|
277 | #define DEFAULT_UPDATEINTERVAL 240
|
---|
278 |
|
---|
279 | enum {E1_GLOBAL=0, E1_USER, E1_READER, E1_SERVER, E1_LSERVER};
|
---|
280 | enum {E2_GLOBAL=0, E2_GROUP, E2_CAID, E2_IDENT, E2_CLASS, E2_CHID, E2_QUEUE,
|
---|
281 | E2_EA_LEN, E2_F0_LEN, E2_OFFLINE, E2_SID,
|
---|
282 | E2_CCCAM_NOCARD=0x27, E2_CCCAM_NOK1=0x28, E2_CCCAM_NOK2=0x29};
|
---|
283 |
|
---|
284 | typedef unsigned char uint8;
|
---|
285 | typedef unsigned short uint16;
|
---|
286 | typedef unsigned int uint32;
|
---|
287 | typedef unsigned long long uint64;
|
---|
288 | typedef long long int64;
|
---|
289 |
|
---|
290 | int server_pid; //alno: PID of server - set while startup
|
---|
291 |
|
---|
292 | // constants
|
---|
293 | #define CTA_RES_LEN 512
|
---|
294 |
|
---|
295 | #ifdef CS_LED
|
---|
296 | #define LED1A 0
|
---|
297 | #define LED1B 1
|
---|
298 | #define LED2 2
|
---|
299 | #define LED3 3
|
---|
300 | #define LED_OFF 0
|
---|
301 | #define LED_ON 1
|
---|
302 | #define LED_BLINK_ON 2
|
---|
303 | #define LED_BLINK_OFF 3
|
---|
304 | #define LED_DEFAULT 10
|
---|
305 | extern void cs_switch_led(int led, int action);
|
---|
306 | #endif
|
---|
307 |
|
---|
308 | #ifdef QBOXHD_LED
|
---|
309 | typedef struct {
|
---|
310 | unsigned short H; // range 0-359
|
---|
311 | unsigned char S; // range 0-99
|
---|
312 | unsigned char V; // range 0-99
|
---|
313 | } qboxhd_led_color_struct;
|
---|
314 | typedef struct {
|
---|
315 | unsigned char red; // first 5 bit used (&0x1F)
|
---|
316 | unsigned char green; // first 5 bit used (&0x1F)
|
---|
317 | unsigned char blue; // first 5 bit used (&0x1F)
|
---|
318 | } qboxhdmini_led_color_struct;
|
---|
319 |
|
---|
320 | extern void qboxhd_led_blink(int color, int duration);
|
---|
321 |
|
---|
322 | #define QBOXHD_LED_DEVICE "/dev/sw0"
|
---|
323 | #define QBOXHD_SET_LED_ALL_PANEL_COLOR _IO(0xBC, 13) // payload = 3byte [H][S][V]
|
---|
324 | #define QBOXHD_LED_COLOR_RED 359 // only H value, S and V values are always == 99
|
---|
325 | #define QBOXHD_LED_COLOR_GREEN 120
|
---|
326 | #define QBOXHD_LED_COLOR_BLUE 230
|
---|
327 | #define QBOXHD_LED_COLOR_YELLOW 55
|
---|
328 | #define QBOXHD_LED_COLOR_MAGENTA 290
|
---|
329 |
|
---|
330 | #define QBOXHDMINI_LED_DEVICE "/dev/lpc_0"
|
---|
331 | #define QBOXHDMINI_IOSET_RGB _IOWR('L', 6, qboxhdmini_led_color_struct)
|
---|
332 | #define QBOXHDMINI_LED_COLOR_RED 0x1F0000 // 3 bytes RGB , 5 bit used for each color
|
---|
333 | #define QBOXHDMINI_LED_COLOR_GREEN 0x001F00
|
---|
334 | #define QBOXHDMINI_LED_COLOR_BLUE 0x00001F
|
---|
335 | #define QBOXHDMINI_LED_COLOR_YELLOW 0x1F1F00
|
---|
336 | #define QBOXHDMINI_LED_COLOR_MAGENTA 0x1F001F
|
---|
337 |
|
---|
338 | #define QBOXHD_LED_COLOR_OFF -1 // all colors H,S,V and/or R,G,B == 0,0,0
|
---|
339 |
|
---|
340 | #define QBOXHD_LED_BLINK_FAST 100 // blink milliseconds
|
---|
341 | #define QBOXHD_LED_BLINK_MEDIUM 200
|
---|
342 | #define QBOXHD_LED_BLINK_SLOW 400
|
---|
343 |
|
---|
344 | #endif //QBOXHD_LED
|
---|
345 |
|
---|
346 | #define MAX_ATR_LEN 33 // max. ATR length
|
---|
347 | #define MAX_HIST 15 // max. number of historical characters
|
---|
348 |
|
---|
349 | #define MAX_SIDBITS 64 // max services
|
---|
350 | #define SIDTABBITS uint64 // 64bit type for services, if a system does not support this type,
|
---|
351 | // please use a define and define it as uint32 / MAX_SIDBITS 32
|
---|
352 |
|
---|
353 | #define BAN_UNKNOWN 1 //failban mask for anonymous/ unknown contact
|
---|
354 | #define BAN_DISABLED 2 //failban mask for disabled user
|
---|
355 | #define BAN_SLEEPING 4 //failban mask for sleeping user
|
---|
356 | #define BAN_DUPLICATE 8 //failban mask for duplicate user
|
---|
357 |
|
---|
358 | //checking if (X) free(X) unneccessary since freeing a null pointer doesnt do anything
|
---|
359 | #define NULLFREE(X) {if (X) {void *tmpX=X; X=NULL; free(tmpX); }}
|
---|
360 |
|
---|
361 | typedef struct s_retrylimittab
|
---|
362 | {
|
---|
363 | ushort n;
|
---|
364 | ushort caid[CS_MAX_LB_RETRYLIMIT];
|
---|
365 | ushort time[CS_MAX_LB_RETRYLIMIT];
|
---|
366 | } GCC_PACK RETRYLIMITTAB;
|
---|
367 |
|
---|
368 | typedef struct s_classtab
|
---|
369 | {
|
---|
370 | uchar an;
|
---|
371 | uchar bn;
|
---|
372 | uchar aclass[31];
|
---|
373 | uchar bclass[31];
|
---|
374 | } GCC_PACK CLASSTAB;
|
---|
375 |
|
---|
376 | typedef struct s_caidtab
|
---|
377 | {
|
---|
378 | ushort caid[CS_MAXCAIDTAB];
|
---|
379 | ushort mask[CS_MAXCAIDTAB];
|
---|
380 | ushort cmap[CS_MAXCAIDTAB];
|
---|
381 | } GCC_PACK CAIDTAB;
|
---|
382 |
|
---|
383 | typedef struct s_tuntab
|
---|
384 | {
|
---|
385 | ushort bt_caidfrom[CS_MAXTUNTAB];
|
---|
386 | ushort bt_caidto[CS_MAXTUNTAB];
|
---|
387 | ushort bt_srvid[CS_MAXTUNTAB];
|
---|
388 | } GCC_PACK TUNTAB;
|
---|
389 |
|
---|
390 | typedef struct s_sidtab
|
---|
391 | {
|
---|
392 | char label[64];
|
---|
393 | ushort num_caid;
|
---|
394 | ushort num_provid;
|
---|
395 | ushort num_srvid;
|
---|
396 | ushort *caid;
|
---|
397 | ulong *provid;
|
---|
398 | ushort *srvid;
|
---|
399 | struct s_sidtab *next;
|
---|
400 | } GCC_PACK SIDTAB;
|
---|
401 |
|
---|
402 |
|
---|
403 | typedef struct s_filter
|
---|
404 | {
|
---|
405 | ushort caid;
|
---|
406 | uchar nprids;
|
---|
407 | ulong prids[CS_MAXPROV];
|
---|
408 | } GCC_PACK FILTER;
|
---|
409 |
|
---|
410 | typedef struct s_ftab
|
---|
411 | {
|
---|
412 | int nfilts;
|
---|
413 | FILTER filts[CS_MAXFILTERS];
|
---|
414 | } GCC_PACK FTAB;
|
---|
415 |
|
---|
416 | typedef struct s_port
|
---|
417 | {
|
---|
418 | int fd;
|
---|
419 | int s_port;
|
---|
420 | int ncd_key_is_set; //0 or 1
|
---|
421 | uchar ncd_key[16];
|
---|
422 | FTAB ftab;
|
---|
423 | } GCC_PACK PORT;
|
---|
424 |
|
---|
425 | typedef struct s_ptab
|
---|
426 | {
|
---|
427 | int nports;
|
---|
428 | PORT ports[CS_MAXPORTS];
|
---|
429 | } GCC_PACK PTAB;
|
---|
430 |
|
---|
431 | typedef struct aes_entry {
|
---|
432 | ushort keyid;
|
---|
433 | ushort caid;
|
---|
434 | uint32 ident;
|
---|
435 | uchar plainkey[16];
|
---|
436 | AES_KEY key;
|
---|
437 | struct aes_entry *next;
|
---|
438 | } AES_ENTRY;
|
---|
439 |
|
---|
440 | struct s_ecm
|
---|
441 | {
|
---|
442 | uchar ecmd5[CS_ECMSTORESIZE];
|
---|
443 | uchar cw[16];
|
---|
444 | ushort caid;
|
---|
445 | uint64 grp;
|
---|
446 | struct s_reader *reader;
|
---|
447 | struct s_ecm *next;
|
---|
448 | //int level;
|
---|
449 | };
|
---|
450 |
|
---|
451 | struct s_emm
|
---|
452 | {
|
---|
453 | uchar emmd5[CS_EMMSTORESIZE];
|
---|
454 | uchar type;
|
---|
455 | int count;
|
---|
456 | };
|
---|
457 |
|
---|
458 | // failban listmember
|
---|
459 | typedef struct v_ban {
|
---|
460 | int v_count;
|
---|
461 | uint v_ip;
|
---|
462 | time_t v_time;
|
---|
463 | } GCC_PACK V_BAN;
|
---|
464 |
|
---|
465 | #define AVAIL_CHECK_CONNECTED 0
|
---|
466 | #define AVAIL_CHECK_LOADBALANCE 1
|
---|
467 |
|
---|
468 | struct s_client ;
|
---|
469 | struct ecm_request_t ;
|
---|
470 | struct emm_packet_t ;
|
---|
471 |
|
---|
472 | struct s_module
|
---|
473 | {
|
---|
474 | int active;
|
---|
475 | int multi;
|
---|
476 | int type;
|
---|
477 | int watchdog;
|
---|
478 | char desc[16];
|
---|
479 | char *logtxt;
|
---|
480 | //int s_port;
|
---|
481 | in_addr_t s_ip;
|
---|
482 | void *(*s_handler)();
|
---|
483 | int (*recv)(struct s_client *, uchar *, int);
|
---|
484 | void (*send_dcw)(struct s_client*, struct ecm_request_t *);
|
---|
485 | void (*cleanup)(struct s_client*);
|
---|
486 | int c_multi;
|
---|
487 | int (*c_recv_chk)(struct s_client*, uchar *, int *, uchar *, int);
|
---|
488 | int (*c_init)(struct s_client*);
|
---|
489 | int (*c_send_ecm)(struct s_client *, struct ecm_request_t *, uchar *);
|
---|
490 | int (*c_send_emm)(struct emm_packet_t *);
|
---|
491 | int (*c_init_log)(void);
|
---|
492 | int (*c_recv_log)(ushort *, ulong *, ushort *);
|
---|
493 | int (*c_available)(struct s_reader *, int); //Schlocke: available check for load-balancing,
|
---|
494 | //params:
|
---|
495 | //rdr (reader to check)
|
---|
496 | //int checktype (0=return connected, 1=return loadbalance-avail) return int
|
---|
497 | void (*c_idle)(void); //Schlocke: called when reader is idle
|
---|
498 | void (*c_card_info)(void); //Schlocke: request card infos
|
---|
499 | int c_port;
|
---|
500 | PTAB *ptab;
|
---|
501 | int num;
|
---|
502 | };
|
---|
503 |
|
---|
504 | struct s_ATR ;
|
---|
505 |
|
---|
506 | struct s_cardreader
|
---|
507 | {
|
---|
508 | int active;
|
---|
509 | char desc[16];
|
---|
510 | int (*reader_init)(struct s_reader*);
|
---|
511 | int (*get_status)(struct s_reader*, int*);
|
---|
512 | int (*activate)(struct s_reader*, struct s_ATR *);
|
---|
513 | int (*transmit)(struct s_reader*, unsigned char *sent, unsigned int size);
|
---|
514 | int (*receive)(struct s_reader*, unsigned char *data, unsigned int size);
|
---|
515 | int (*close)(struct s_reader*);
|
---|
516 | int (*set_parity)(struct s_reader*, uchar parity);
|
---|
517 | int (*write_settings)(struct s_reader*, unsigned long ETU, unsigned long EGT, unsigned char P, unsigned char I, unsigned short Fi, unsigned char Di, unsigned char Ni);
|
---|
518 | int (*set_protocol)(struct s_reader*, unsigned char * params, unsigned *length, uint len_request);
|
---|
519 | int (*set_baudrate)(struct s_reader*, ulong baud); //set only for readers which need baudrate setting and timings need to be guarded by OSCam
|
---|
520 | int typ; //fixme: workaround, remove when all old code is converted
|
---|
521 |
|
---|
522 | int max_clock_speed; // 1 for reader->typ > R_MOUSE
|
---|
523 | int need_inverse; //0 = reader does inversing; 1 = inversing done by oscam
|
---|
524 | //io_serial config
|
---|
525 | int flush;
|
---|
526 | int read_written; // 1 = written bytes has to read from device
|
---|
527 | };
|
---|
528 |
|
---|
529 | struct s_cardsystem
|
---|
530 | {
|
---|
531 | int active;
|
---|
532 | char *desc;
|
---|
533 | int (*card_init)();
|
---|
534 | int (*card_info)();
|
---|
535 | int (*do_ecm)();
|
---|
536 | int (*do_emm)();
|
---|
537 | void (*post_process)();
|
---|
538 | int (*get_emm_type)();
|
---|
539 | void (*get_emm_filter)();
|
---|
540 | uchar caids[2];
|
---|
541 | };
|
---|
542 |
|
---|
543 | #ifdef IRDETO_GUESSING
|
---|
544 | struct s_irdeto_quess
|
---|
545 | {
|
---|
546 | int b47;
|
---|
547 | ushort caid;
|
---|
548 | ushort sid;
|
---|
549 | struct s_irdeto_quess *next;
|
---|
550 | };
|
---|
551 | #endif
|
---|
552 |
|
---|
553 | #define MSGLOGSIZE 64
|
---|
554 | typedef struct ecm_request_t
|
---|
555 | {
|
---|
556 | uchar ecm[256];
|
---|
557 | uchar cw[16];
|
---|
558 | uchar ecmd5[CS_ECMSTORESIZE];
|
---|
559 | // uchar l;
|
---|
560 | short l;
|
---|
561 | ushort caid;
|
---|
562 | ushort ocaid; //original caid, used for betatunneling
|
---|
563 | ushort srvid;
|
---|
564 | ushort chid;
|
---|
565 | ushort pid;
|
---|
566 | ushort idx;
|
---|
567 | ulong prid;
|
---|
568 | struct s_reader *selected_reader;
|
---|
569 | LLIST *matching_rdr; //list of matching readers
|
---|
570 | LL_NODE *fallback; // in *matching_rdr, at position "fallback" the first fallback reader is in the list
|
---|
571 | struct s_client *client; //contains pointer to 'c' client while running in 'r' client
|
---|
572 | int cpti; // client pending table index
|
---|
573 | int stage; // processing stage in server module
|
---|
574 | int level; // send-level in client module
|
---|
575 | int rc;
|
---|
576 | uchar rcEx;
|
---|
577 | struct timeb tps; // incoming time stamp
|
---|
578 | uchar locals_done;
|
---|
579 | int btun; // mark er as betatunneled
|
---|
580 | int reader_avail; //count of available readers
|
---|
581 | int reader_count; //count of contacted readers
|
---|
582 |
|
---|
583 | #ifdef CS_WITH_DOUBLECHECK
|
---|
584 | int checked;
|
---|
585 | uchar cw_checked[16];
|
---|
586 | #endif
|
---|
587 |
|
---|
588 | struct s_reader *origin_reader;
|
---|
589 | void * origin_card; //CCcam preferred card!
|
---|
590 |
|
---|
591 | char msglog[MSGLOGSIZE];
|
---|
592 |
|
---|
593 | } GCC_PACK ECM_REQUEST;
|
---|
594 |
|
---|
595 | struct s_client
|
---|
596 | {
|
---|
597 | in_addr_t ip;
|
---|
598 | in_port_t port;
|
---|
599 | time_t login;
|
---|
600 | time_t last;
|
---|
601 | time_t lastswitch;
|
---|
602 | time_t lastemm;
|
---|
603 | time_t lastecm;
|
---|
604 | time_t expirationdate;
|
---|
605 | int allowedtimeframe[2];
|
---|
606 | int c35_suppresscmd08;
|
---|
607 | int c35_sleepsend;
|
---|
608 | int ncd_keepalive;
|
---|
609 | int disabled;
|
---|
610 | uint64 grp;
|
---|
611 | int crypted;
|
---|
612 | int dup;
|
---|
613 | LLIST *aureader_list;
|
---|
614 | int autoau;
|
---|
615 | int monlvl;
|
---|
616 | CAIDTAB ctab;
|
---|
617 | TUNTAB ttab;
|
---|
618 | SIDTABBITS sidtabok; // positiv services
|
---|
619 | SIDTABBITS sidtabno; // negative services
|
---|
620 | int 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
|
---|
621 | int ctyp;
|
---|
622 | int stat;
|
---|
623 | int last_srvid;
|
---|
624 | int last_caid;
|
---|
625 | int tosleep;
|
---|
626 | struct s_auth *account;
|
---|
627 | int udp_fd;
|
---|
628 | int fd_m2c; //master writes to this fd
|
---|
629 | int fd_m2c_c; //client reads from this fd
|
---|
630 | struct sockaddr_in udp_sa;
|
---|
631 | int log;
|
---|
632 | int logcounter;
|
---|
633 | int cwfound; // count found ECMs per client
|
---|
634 | int cwcache; // count ECMs from cache1/2 per client
|
---|
635 | int cwnot; // count not found ECMs per client
|
---|
636 | int cwtun; // count betatunneled ECMs per client
|
---|
637 | int cwignored; // count ignored ECMs per client
|
---|
638 | int cwtout; // count timeouted ECMs per client
|
---|
639 | int cwlastresptime; //last Responsetime (ms)
|
---|
640 | int emmok; // count EMM ok
|
---|
641 | int emmnok; // count EMM nok
|
---|
642 | #ifdef WEBIF
|
---|
643 | int wihidden; // hidden in webinterface status
|
---|
644 | char lastreader[64]; // last cw got from this reader
|
---|
645 | #endif
|
---|
646 | uchar ucrc[4]; // needed by monitor and used by camd35
|
---|
647 | ulong pcrc; // pwd crc
|
---|
648 | AES_KEY aeskey; // encryption key needed by monitor and used by camd33, camd35
|
---|
649 | AES_KEY aeskey_decrypt; // decryption key needed by monitor and used by camd33, camd35
|
---|
650 | ushort ncd_msgid;
|
---|
651 | char ncd_client_id[5];
|
---|
652 | uchar ncd_skey[16];
|
---|
653 | void *cc;
|
---|
654 | void *gbox;
|
---|
655 | int port_idx; // index in server ptab
|
---|
656 | int ncd_server; // newcamd server
|
---|
657 | #ifdef CS_ANTICASC
|
---|
658 | ushort ac_idx;
|
---|
659 | ushort ac_limit;
|
---|
660 | uchar ac_penalty;
|
---|
661 | #endif
|
---|
662 | FTAB fchid;
|
---|
663 | FTAB ftab; // user [caid] and ident filter
|
---|
664 | CLASSTAB cltab;
|
---|
665 |
|
---|
666 |
|
---|
667 | int pfd; // Primary FD, must be closed on exit
|
---|
668 | struct s_reader *reader; //points to s_reader when cl->typ='r'
|
---|
669 |
|
---|
670 | ECM_REQUEST *ecmtask;
|
---|
671 | struct s_emm *emmcache;
|
---|
672 |
|
---|
673 | pthread_t thread;
|
---|
674 |
|
---|
675 | struct s_serial_client *serialdata;
|
---|
676 |
|
---|
677 | //reader common
|
---|
678 | int last_idx;
|
---|
679 | ushort idx;
|
---|
680 | int rotate;
|
---|
681 |
|
---|
682 | uchar *req;
|
---|
683 |
|
---|
684 | //camd33
|
---|
685 | uchar camdbug[256];
|
---|
686 |
|
---|
687 | int ncd_proto;
|
---|
688 |
|
---|
689 | //camd35
|
---|
690 | uchar upwd[64];
|
---|
691 | int is_udp;
|
---|
692 | int stopped;
|
---|
693 | int lastcaid;
|
---|
694 | int lastsrvid;
|
---|
695 | int lastpid;
|
---|
696 | time_t emm_last;
|
---|
697 | int disable_counter;
|
---|
698 | uchar lastserial[8];
|
---|
699 |
|
---|
700 | //cccam
|
---|
701 | int g_flag;
|
---|
702 | int cc_use_rc4;
|
---|
703 |
|
---|
704 | //monitor
|
---|
705 | int auth;
|
---|
706 |
|
---|
707 | //cs_hexdump buffer
|
---|
708 | uchar dump[520];
|
---|
709 |
|
---|
710 | //oscam.c
|
---|
711 | struct timeval tv;
|
---|
712 |
|
---|
713 | //failban value set bitwise - compared with BAN_
|
---|
714 | int failban;
|
---|
715 | struct s_client *next; //make client a linked list
|
---|
716 | };
|
---|
717 |
|
---|
718 |
|
---|
719 | //for viaccess var in s_reader:
|
---|
720 | struct geo_cache
|
---|
721 | {
|
---|
722 | ulong provid;
|
---|
723 | uchar geo[256];
|
---|
724 | uchar geo_len;
|
---|
725 | int number_ecm;
|
---|
726 | };
|
---|
727 | // for videoguard in s_reader
|
---|
728 | struct s_CmdTabEntry {
|
---|
729 | unsigned char cla;
|
---|
730 | unsigned char cmd;
|
---|
731 | unsigned char len;
|
---|
732 | unsigned char mode;
|
---|
733 | };
|
---|
734 |
|
---|
735 | struct s_CmdTab {
|
---|
736 | unsigned char index;
|
---|
737 | unsigned char size;
|
---|
738 | unsigned char Nentries;
|
---|
739 | unsigned char dummy;
|
---|
740 | struct s_CmdTabEntry e[1];
|
---|
741 | };
|
---|
742 | //ratelimit
|
---|
743 | struct ecmrl {
|
---|
744 | ushort srvid;
|
---|
745 | time_t last;
|
---|
746 | };
|
---|
747 | #define MAXECMRATELIMIT 20
|
---|
748 |
|
---|
749 | struct s_reader //contains device info, reader info and card info
|
---|
750 | {
|
---|
751 | ulong auprovid; // AU only for this provid
|
---|
752 | int audisabled; // exclude reader from auto AU
|
---|
753 | int smargopatch;
|
---|
754 | struct s_client * client; //pointer to 'r'client this reader is running in
|
---|
755 | int enable;
|
---|
756 | int available; //Schlocke: New flag for loadbalancing. Only reader if reader supports ph.c_available function
|
---|
757 | int fd_error;
|
---|
758 | int fd;
|
---|
759 | uint64 grp;
|
---|
760 | int fallback;
|
---|
761 | int typ;
|
---|
762 | char label[64];
|
---|
763 | char device[128];
|
---|
764 | void *spec_dev; //pointer to structure that contains specific device data
|
---|
765 | ushort slot; //in case of multiple slots like sc8in1; first slot = 1
|
---|
766 | int handle; //device handle
|
---|
767 | int fdmc; //device handle for multicam
|
---|
768 | #ifdef WITH_STAPI
|
---|
769 | unsigned int stsmart_handle; //device handle for stsmart driver
|
---|
770 | #endif
|
---|
771 | char pcsc_name[128];
|
---|
772 | int pcsc_has_card;
|
---|
773 | int detect;
|
---|
774 | int mhz; //actual clock rate of reader in 10khz steps
|
---|
775 | int cardmhz; //standard clock speed your card should have in 10khz steps; normally 357 but for Irdeto cards 600
|
---|
776 | int r_port;
|
---|
777 | char r_usr[64];
|
---|
778 | char r_pwd[64];
|
---|
779 | char l_pwd[64];
|
---|
780 | int r_crypted;
|
---|
781 | int l_port;
|
---|
782 | int log_port;
|
---|
783 | CAIDTAB ctab;
|
---|
784 | ulong boxid;
|
---|
785 | int nagra_read; // read nagra ncmed records: 0 disabled (default), 1 read all records, 2 read valid records only
|
---|
786 | uchar nagra_boxkey[16]; //n3 boxkey 8byte or tiger idea key 16byte
|
---|
787 | char country_code[3]; // irdeto country code.
|
---|
788 | int force_irdeto;
|
---|
789 | uchar rsa_mod[120]; //rsa modulus for nagra cards.
|
---|
790 | uchar atr[64];
|
---|
791 | int atrlen;
|
---|
792 | SIDTABBITS sidtabok; // positiv services
|
---|
793 | SIDTABBITS sidtabno; // negative services
|
---|
794 | uchar hexserial[8];
|
---|
795 | int nprov;
|
---|
796 | uchar prid[CS_MAXPROV][8];
|
---|
797 | uchar availkeys[CS_MAXPROV][16]; // viaccess; misused in seca, if availkeys[PROV][0]=0 then expired, 1 then valid.
|
---|
798 | uchar sa[CS_MAXPROV][4]; // viaccess & seca
|
---|
799 | ushort acs; // irdeto
|
---|
800 | ushort caid;
|
---|
801 | uchar b_nano[256];
|
---|
802 | int blockemm_unknown; //block EMMs that have unknown type
|
---|
803 | int blockemm_u; //blcok Unique EMMs
|
---|
804 | int blockemm_s; //block Shared EMMS
|
---|
805 | int blockemm_g; //block Global EMMs
|
---|
806 | char * emmfile;
|
---|
807 | char pincode[5];
|
---|
808 | int ucpk_valid;
|
---|
809 | int logemm;
|
---|
810 | int cachemm;
|
---|
811 | int rewritemm;
|
---|
812 | int card_status;
|
---|
813 | int deprecated; //if 0 ATR obeyed, if 1 default speed (9600) is chosen; for devices that cannot switch baudrate
|
---|
814 | struct s_module ph;
|
---|
815 | struct s_cardreader crdr;
|
---|
816 | struct s_cardsystem csystem;
|
---|
817 | uchar ncd_key[16];
|
---|
818 | uchar ncd_skey[16];
|
---|
819 | int ncd_disable_server_filt;
|
---|
820 | ushort ncd_msgid;
|
---|
821 | int ncd_proto;
|
---|
822 | char cc_version[7]; // cccam version
|
---|
823 | char cc_build[7]; // cccam build number
|
---|
824 | int cc_maxhop; // cccam max distance
|
---|
825 | int cc_currenthops; // number of hops for CCCam
|
---|
826 | int cc_want_emu; //Schlocke: Client want to have EMUs, 0 - NO; 1 - YES
|
---|
827 | uint32 cc_id;
|
---|
828 | int cc_keepalive;
|
---|
829 | uchar tcp_connected;
|
---|
830 | int tcp_ito; // inactivity timeout
|
---|
831 | int tcp_rto; // reconnect timeout
|
---|
832 | struct timeb tcp_block_connect_till; //time tcp connect ist blocked
|
---|
833 | int tcp_block_delay; //incrementing block time
|
---|
834 | time_t last_g; // get (if last_s-last_g>tcp_rto - reconnect )
|
---|
835 | time_t last_s; // send
|
---|
836 | uchar show_cls; // number of classes subscription showed on kill -31
|
---|
837 | FTAB fchid;
|
---|
838 | FTAB ftab;
|
---|
839 | CLASSTAB cltab;
|
---|
840 | char *init_history;
|
---|
841 | int init_history_pos;
|
---|
842 | int brk_pos;
|
---|
843 | int msg_idx;
|
---|
844 | #ifdef WEBIF
|
---|
845 | int emmwritten[4]; //count written EMM
|
---|
846 | int emmskipped[4]; //count skipped EMM
|
---|
847 | int emmerror[4]; //count error EMM
|
---|
848 | int emmblocked[4]; //count blocked EMM
|
---|
849 | int lbvalue; //loadbalance Value
|
---|
850 | #endif
|
---|
851 | #ifdef HAVE_PCSC
|
---|
852 | SCARDCONTEXT hContext;
|
---|
853 | SCARDHANDLE hCard;
|
---|
854 | DWORD dwActiveProtocol;
|
---|
855 | #endif
|
---|
856 | #ifdef LIBUSB
|
---|
857 | uint8_t device_endpoint; // usb endpoint for Infinity USB Smart in smartreader mode.
|
---|
858 | struct s_sr_config *sr_config;
|
---|
859 | #endif
|
---|
860 | #ifdef AZBOX
|
---|
861 | int mode;
|
---|
862 | #endif
|
---|
863 | ////variables from icc_async.h start
|
---|
864 | int convention; //Convention of this ICC
|
---|
865 | unsigned char protocol_type; // Type of protocol
|
---|
866 | unsigned short BWT,CWT; // (for overclocking uncorrected) block waiting time, character waiting time, in ETU
|
---|
867 | unsigned long current_baudrate; // (for overclocking uncorrected) baudrate to prevent unnecessary conversions from/to termios structure
|
---|
868 | unsigned int read_timeout; // Max timeout (ms) to receive characters
|
---|
869 | unsigned int block_delay; // Delay (ms) after starting to transmit
|
---|
870 | unsigned int char_delay; // Delay (ms) after transmiting each sucesive char
|
---|
871 | ////variables from io_serial.h
|
---|
872 | int written; //keep score of how much bytes are written to serial port, since they are echoed back they have to be read
|
---|
873 | ////variables from protocol_t1.h
|
---|
874 | unsigned short ifsc; /* Information field size for the ICC */
|
---|
875 | unsigned char ns; /* Send sequence number */
|
---|
876 | ////variables from reader-dre.c
|
---|
877 | unsigned char provider;
|
---|
878 | ////variables from reader-nagra.c
|
---|
879 | IDEA_KEY_SCHEDULE ksSession;
|
---|
880 | int is_pure_nagra;
|
---|
881 | int is_tiger;
|
---|
882 | int is_n3_na;
|
---|
883 | int has_dt08;
|
---|
884 | int swapCW;
|
---|
885 | uint8_t ExpiryDate[2];
|
---|
886 | uint8_t ActivationDate[2];
|
---|
887 | unsigned char rom[15];
|
---|
888 | unsigned char plainDT08RSA[64];
|
---|
889 | unsigned char IdeaCamKey[16];
|
---|
890 | unsigned char irdId[4];
|
---|
891 | unsigned char sessi[16];
|
---|
892 | unsigned char signature[8];
|
---|
893 | unsigned char cam_state[3];
|
---|
894 | ////variables from reader-irdeto.c
|
---|
895 | int acs57; // A flag for the ACS57 ITA DVB-T
|
---|
896 | ////variables from reader-cryptoworks.c
|
---|
897 | BIGNUM exp;
|
---|
898 | BIGNUM ucpk;
|
---|
899 | ////variables from reader-viaccess.c
|
---|
900 | struct geo_cache last_geo;
|
---|
901 | int cc_reshare;
|
---|
902 | int lb_weight; //loadbalance weight factor, if unset, weight=100. The higher the value, the higher the usage-possibility
|
---|
903 | int lb_usagelevel; //usagelevel for loadbalancer
|
---|
904 | int lb_usagelevel_ecmcount;
|
---|
905 | time_t lb_usagelevel_time; //time for counting ecms, this creates usagelevel
|
---|
906 | struct timeb lb_last; //time for oldest reader
|
---|
907 | LLIST *lb_stat; //loadbalancer reader statistics
|
---|
908 | // multi AES linked list
|
---|
909 | AES_ENTRY *aes_list;
|
---|
910 | // variables from reader-videoguard*
|
---|
911 | int ndsversion; // 0 auto (default), 1 NDS1, 12 NDS1+, 2 NDS2
|
---|
912 | const char * card_desc;
|
---|
913 | int card_baseyear;
|
---|
914 | int card_tierstart;
|
---|
915 | int card_system_version;
|
---|
916 | struct s_CmdTab *cmd_table;
|
---|
917 | unsigned short cardkeys[3][32];
|
---|
918 | unsigned char stateD3A[16];
|
---|
919 | AES_KEY ekey;
|
---|
920 | AES_KEY astrokey;
|
---|
921 | //ratelimit
|
---|
922 | int ratelimitecm;
|
---|
923 | int ratelimitseconds;
|
---|
924 | struct ecmrl rlecmh[MAXECMRATELIMIT];
|
---|
925 | int fix_9993;
|
---|
926 | struct s_reader *next;
|
---|
927 | };
|
---|
928 |
|
---|
929 | #ifdef CS_ANTICASC
|
---|
930 |
|
---|
931 | struct s_acasc_shm {
|
---|
932 | ushort ac_count : 15;
|
---|
933 | ushort ac_deny : 1;
|
---|
934 | };
|
---|
935 |
|
---|
936 | struct s_acasc {
|
---|
937 | ushort stat[10];
|
---|
938 | uchar idx; // current active index in stat[]
|
---|
939 | };
|
---|
940 |
|
---|
941 | struct s_cpmap
|
---|
942 | {
|
---|
943 | ushort caid;
|
---|
944 | ulong provid;
|
---|
945 | ushort sid;
|
---|
946 | ushort chid;
|
---|
947 | ushort dwtime;
|
---|
948 | struct s_cpmap *next;
|
---|
949 | };
|
---|
950 | #endif
|
---|
951 |
|
---|
952 | struct s_auth
|
---|
953 | {
|
---|
954 | char usr[64];
|
---|
955 | char pwd[64];
|
---|
956 | #ifdef WEBIF
|
---|
957 | char description[64];
|
---|
958 | #endif
|
---|
959 | int uniq;
|
---|
960 | LLIST *aureader_list;
|
---|
961 | int autoau;
|
---|
962 | int monlvl;
|
---|
963 | uint64 grp;
|
---|
964 | int tosleep;
|
---|
965 | CAIDTAB ctab;
|
---|
966 | SIDTABBITS sidtabok; // positiv services
|
---|
967 | SIDTABBITS sidtabno; // negative services
|
---|
968 | FTAB fchid;
|
---|
969 | FTAB ftab; // user [caid] and ident filter
|
---|
970 | CLASSTAB cltab;
|
---|
971 | TUNTAB ttab;
|
---|
972 | #ifdef CS_ANTICASC
|
---|
973 | int ac_idx;
|
---|
974 | int ac_users; // 0 - unlimited
|
---|
975 | uchar ac_penalty; // 0 - log, >0 - fake dw
|
---|
976 | #endif
|
---|
977 | in_addr_t dynip;
|
---|
978 | uchar dyndns[64];
|
---|
979 | time_t expirationdate;
|
---|
980 | int allowedtimeframe[2];
|
---|
981 | int c35_suppresscmd08;
|
---|
982 | int c35_sleepsend;
|
---|
983 | int ncd_keepalive;
|
---|
984 | int cccmaxhops;
|
---|
985 | int cccreshare;
|
---|
986 | int cccignorereshare;
|
---|
987 | int disabled;
|
---|
988 | int failban;
|
---|
989 |
|
---|
990 | int cwfound;
|
---|
991 | int cwcache;
|
---|
992 | int cwnot;
|
---|
993 | int cwtun;
|
---|
994 | int cwignored;
|
---|
995 | int cwtout;
|
---|
996 | int emmok;
|
---|
997 | int emmnok;
|
---|
998 |
|
---|
999 | struct s_auth *next;
|
---|
1000 | };
|
---|
1001 |
|
---|
1002 | struct s_srvid
|
---|
1003 | {
|
---|
1004 | int srvid;
|
---|
1005 | int ncaid;
|
---|
1006 | int caid[10];
|
---|
1007 | char prov[33];
|
---|
1008 | char name[33];
|
---|
1009 | char type[33];
|
---|
1010 | char desc[33];
|
---|
1011 | struct s_srvid *next;
|
---|
1012 | };
|
---|
1013 |
|
---|
1014 | struct s_tierid
|
---|
1015 | {
|
---|
1016 | int tierid;
|
---|
1017 | int ncaid;
|
---|
1018 | int caid[10];
|
---|
1019 | char name[33];
|
---|
1020 | struct s_tierid *next;
|
---|
1021 | };
|
---|
1022 |
|
---|
1023 | //Todo #ifdef CCCAM
|
---|
1024 | struct s_provid
|
---|
1025 | {
|
---|
1026 | int caid;
|
---|
1027 | ulong provid;
|
---|
1028 | char prov[33];
|
---|
1029 | char sat[33];
|
---|
1030 | char lang[33];
|
---|
1031 | struct s_provid *next;
|
---|
1032 | };
|
---|
1033 |
|
---|
1034 | struct s_ip
|
---|
1035 | {
|
---|
1036 | in_addr_t ip[2];
|
---|
1037 | struct s_ip *next;
|
---|
1038 | };
|
---|
1039 |
|
---|
1040 | struct s_config
|
---|
1041 | {
|
---|
1042 | int nice;
|
---|
1043 | ulong netprio;
|
---|
1044 | ulong ctimeout;
|
---|
1045 | ulong ftimeout;
|
---|
1046 | ulong cmaxidle;
|
---|
1047 | int ulparent;
|
---|
1048 | ulong delay;
|
---|
1049 | int bindwait;
|
---|
1050 | int tosleep;
|
---|
1051 | in_addr_t srvip;
|
---|
1052 | char *usrfile;
|
---|
1053 | char *cwlogdir;
|
---|
1054 | char *logfile;
|
---|
1055 | uint8 logtostdout;
|
---|
1056 | uint8 logtosyslog;
|
---|
1057 | int disablelog;
|
---|
1058 | int disableuserfile;
|
---|
1059 | int usrfileflag;
|
---|
1060 | struct s_auth *account;
|
---|
1061 | struct s_srvid *srvid;
|
---|
1062 | struct s_tierid *tierid;
|
---|
1063 | //Todo #ifdef CCCAM
|
---|
1064 | struct s_provid *provid;
|
---|
1065 | struct s_sidtab *sidtab;
|
---|
1066 | int mon_port;
|
---|
1067 | in_addr_t mon_srvip;
|
---|
1068 | struct s_ip *mon_allowed;
|
---|
1069 | int mon_aulow;
|
---|
1070 | int mon_hideclient_to;
|
---|
1071 | int mon_level;
|
---|
1072 | int mon_appendchaninfo;
|
---|
1073 | #ifdef WEBIF
|
---|
1074 | int http_port;
|
---|
1075 | char http_user[65];
|
---|
1076 | char http_pwd[65];
|
---|
1077 | char http_css[128];
|
---|
1078 | char http_jscript[128];
|
---|
1079 | char http_tpl[128];
|
---|
1080 | char http_script[128];
|
---|
1081 | int http_refresh;
|
---|
1082 | int http_hide_idle_clients;
|
---|
1083 | struct s_ip *http_allowed;
|
---|
1084 | int http_readonly;
|
---|
1085 | in_addr_t http_dynip;
|
---|
1086 | uchar http_dyndns[64];
|
---|
1087 | int http_use_ssl;
|
---|
1088 | char http_cert[128];
|
---|
1089 | char http_help_lang[3];
|
---|
1090 | #endif
|
---|
1091 | int http_full_cfg;
|
---|
1092 | int failbantime;
|
---|
1093 | int failbancount;
|
---|
1094 | LLIST *v_list; //failban list
|
---|
1095 | int c33_port;
|
---|
1096 | in_addr_t c33_srvip;
|
---|
1097 | uchar c33_key[16];
|
---|
1098 | int c33_crypted;
|
---|
1099 | int c33_passive;
|
---|
1100 | struct s_ip *c33_plain;
|
---|
1101 | int c35_port;
|
---|
1102 | in_addr_t c35_srvip;
|
---|
1103 | int c35_suppresscmd08;
|
---|
1104 | PTAB c35_tcp_ptab;
|
---|
1105 | in_addr_t c35_tcp_srvip;
|
---|
1106 | PTAB ncd_ptab;
|
---|
1107 | in_addr_t ncd_srvip;
|
---|
1108 | uchar ncd_key[16];
|
---|
1109 | int ncd_keepalive;
|
---|
1110 | int ncd_mgclient;
|
---|
1111 | struct s_ip *ncd_allowed;
|
---|
1112 | PTAB cc_ptab;
|
---|
1113 | int rad_port;
|
---|
1114 | in_addr_t rad_srvip;
|
---|
1115 | int cc_port;
|
---|
1116 | int cc_reshare;
|
---|
1117 | int cc_ignore_reshare;
|
---|
1118 | int cc_update_interval;
|
---|
1119 | in_addr_t cc_srvip;
|
---|
1120 | char cc_version[7];
|
---|
1121 | int cc_minimize_cards;
|
---|
1122 | int cc_keep_connected;
|
---|
1123 | int cc_stealth;
|
---|
1124 | int cc_reshare_services;
|
---|
1125 | int cc_forward_origin_card;
|
---|
1126 | char gbox_hostname[128];
|
---|
1127 | char gbox_key[9];
|
---|
1128 | char gbox_gsms_path[200];
|
---|
1129 | int gbox_port;
|
---|
1130 | struct s_ip *rad_allowed;
|
---|
1131 | char rad_usr[32];
|
---|
1132 | char ser_device[512];
|
---|
1133 | ulong srtimeout; // SerialReaderTimeount in millisec
|
---|
1134 | int max_log_size;
|
---|
1135 | int waitforcards;
|
---|
1136 | int preferlocalcards;
|
---|
1137 | int saveinithistory;
|
---|
1138 | int reader_restart_seconds; //schlocke: reader restart auf x seconds, disable = 0
|
---|
1139 |
|
---|
1140 | //Loadbalancer-Config:
|
---|
1141 | int lb_mode; //schlocke: reader loadbalancing mode
|
---|
1142 | int lb_save; //schlocke: load/save statistics to file, save every x ecms
|
---|
1143 | int lb_nbest_readers; // count of best readers
|
---|
1144 | int lb_nfb_readers; // count of fallback readers
|
---|
1145 | int lb_min_ecmcount; // minimal ecm count to evaluate lbvalues
|
---|
1146 | int lb_max_ecmcount; // maximum ecm count before reseting lbvalues
|
---|
1147 | int lb_reopen_seconds; //time between retrying failed readers/caids/prov/srv
|
---|
1148 | int lb_retrylimit; //reopen only happens if reader response time > retrylimit
|
---|
1149 | RETRYLIMITTAB lb_retrylimittab;
|
---|
1150 | char *lb_savepath; //path where the stat file is save. Empty=default=/tmp/.oscam/stat
|
---|
1151 | int lb_stat_cleanup; //duration in hours for cleaning old statistics
|
---|
1152 | int lb_use_locking; //use a mutex lock while searching for readers (get_cw())
|
---|
1153 | int resolve_gethostbyname;
|
---|
1154 |
|
---|
1155 | #ifdef CS_WITH_DOUBLECHECK
|
---|
1156 | int double_check; //schlocke: Double checks each ecm+dcw from two (or more) readers
|
---|
1157 | #endif
|
---|
1158 |
|
---|
1159 | #ifdef IRDETO_GUESSING
|
---|
1160 | struct s_irdeto_quess *itab[0xff];
|
---|
1161 | #endif
|
---|
1162 |
|
---|
1163 | #ifdef HAVE_DVBAPI
|
---|
1164 | int dvbapi_enabled;
|
---|
1165 | int dvbapi_au;
|
---|
1166 | char dvbapi_usr[64];
|
---|
1167 | int dvbapi_boxtype;
|
---|
1168 | int dvbapi_pmtmode;
|
---|
1169 | int dvbapi_requestmode;
|
---|
1170 | SIDTABBITS dvbapi_sidtabok; // positiv services
|
---|
1171 | SIDTABBITS dvbapi_sidtabno; // negative services
|
---|
1172 | #endif
|
---|
1173 |
|
---|
1174 | #ifdef CS_ANTICASC
|
---|
1175 | char ac_enabled;
|
---|
1176 | int ac_users; // num of users for account (0 - default)
|
---|
1177 | int ac_stime; // time to collect AC statistics (3 min - default)
|
---|
1178 | int ac_samples; // qty of samples
|
---|
1179 | int ac_penalty; // 0 - write to log
|
---|
1180 | int ac_fakedelay; // 100-1000 ms
|
---|
1181 | int ac_denysamples;
|
---|
1182 | char ac_logfile[128];
|
---|
1183 | struct s_cpmap *cpmap;
|
---|
1184 | #endif
|
---|
1185 |
|
---|
1186 | #ifdef QBOXHD_LED
|
---|
1187 | int disableqboxhdled; // disable qboxhd led , default = 0
|
---|
1188 | #endif
|
---|
1189 | };
|
---|
1190 |
|
---|
1191 | //Loadbalance constants:
|
---|
1192 | #define LB_NONE 0
|
---|
1193 | #define LB_FASTEST_READER_FIRST 1
|
---|
1194 | #define LB_OLDEST_READER_FIRST 2
|
---|
1195 | #define LB_LOWEST_USAGELEVEL 3
|
---|
1196 | #define LB_LOG_ONLY 10
|
---|
1197 |
|
---|
1198 | #define LB_MAX_STAT_TIME 20
|
---|
1199 |
|
---|
1200 | typedef struct reader_stat_t
|
---|
1201 | {
|
---|
1202 | int rc;
|
---|
1203 | ushort caid;
|
---|
1204 | ulong prid;
|
---|
1205 | ushort srvid;
|
---|
1206 |
|
---|
1207 | time_t last_received;
|
---|
1208 |
|
---|
1209 | int ecm_count;
|
---|
1210 | int time_avg;
|
---|
1211 | int time_stat[LB_MAX_STAT_TIME];
|
---|
1212 | int time_idx;
|
---|
1213 |
|
---|
1214 | int request_count;
|
---|
1215 | } GCC_PACK READER_STAT;
|
---|
1216 |
|
---|
1217 | typedef struct emm_packet_t
|
---|
1218 | {
|
---|
1219 | uchar emm[258];
|
---|
1220 | uchar l;
|
---|
1221 | uchar caid[2];
|
---|
1222 | uchar provid[4];
|
---|
1223 | uchar hexserial[8]; //contains hexserial or SA of EMM
|
---|
1224 | uchar type;
|
---|
1225 | struct s_client *client;
|
---|
1226 | } GCC_PACK EMM_PACKET;
|
---|
1227 |
|
---|
1228 | //EMM types:
|
---|
1229 | #define UNKNOWN 0
|
---|
1230 | #define UNIQUE 1
|
---|
1231 | #define SHARED 2
|
---|
1232 | #define GLOBAL 3
|
---|
1233 |
|
---|
1234 | // oscam-simples
|
---|
1235 | extern char *remote_txt(void);
|
---|
1236 | extern char *trim(char *);
|
---|
1237 | extern char *strtolower(char *);
|
---|
1238 | extern int gethexval(char);
|
---|
1239 | extern int cs_atob(uchar *, char *, int);
|
---|
1240 | extern ulong cs_atoi(char *, int, int);
|
---|
1241 | extern int byte_atob(char *);
|
---|
1242 | extern long word_atob(char *);
|
---|
1243 | extern long dyn_word_atob(char *asc);
|
---|
1244 | extern int key_atob_l(char *, uchar *, int);
|
---|
1245 | extern char *key_btoa(char *, uchar *);
|
---|
1246 | extern char *cs_hexdump(int, const uchar *, int);
|
---|
1247 | extern in_addr_t cs_inet_order(in_addr_t);
|
---|
1248 | extern char *cs_inet_ntoa(in_addr_t);
|
---|
1249 | extern in_addr_t cs_inet_addr(char *txt);
|
---|
1250 | extern ulong b2i(int, uchar *);
|
---|
1251 | extern ullong b2ll(int, uchar *);
|
---|
1252 | extern uchar *i2b(int, ulong);
|
---|
1253 | extern ulong a2i(char *, int);
|
---|
1254 | extern int boundary(int, int);
|
---|
1255 | extern void cs_ftime(struct timeb *);
|
---|
1256 | extern void cs_sleepms(unsigned int);
|
---|
1257 | extern void cs_sleepus(unsigned int);
|
---|
1258 | extern int bytes_available(int);
|
---|
1259 | extern void cs_setpriority(int);
|
---|
1260 | extern struct s_auth *find_user(char *);
|
---|
1261 | extern int check_filled(uchar *value, int length);
|
---|
1262 | extern void *cs_malloc(void *result, size_t size, int quiterror);
|
---|
1263 | extern void *cs_realloc(void *result, size_t size, int quiterror);
|
---|
1264 | #ifdef WEBIF
|
---|
1265 | extern char to_hex(char code);
|
---|
1266 | extern void char_to_hex(const unsigned char* p_array, unsigned int p_array_len, unsigned char *result);
|
---|
1267 | extern void create_rand_str(char *dst, int size);
|
---|
1268 | #endif
|
---|
1269 | extern void uint64ToBitchar(uint64 value, int size, char *result);
|
---|
1270 | extern int file_exists(const char * filename);
|
---|
1271 | extern void clear_sip(struct s_ip **sip);
|
---|
1272 | extern void clear_ptab(struct s_ptab *ptab);
|
---|
1273 | extern void clear_ftab(struct s_ftab *ftab);
|
---|
1274 | void clear_caidtab(struct s_caidtab *ctab);
|
---|
1275 | void clear_tuntab(struct s_tuntab *ttab);
|
---|
1276 | extern int safe_overwrite_with_bak(char *destfile, char *tmpfile, char *bakfile, int forceBakOverWrite);
|
---|
1277 | extern void fprintf_conf(FILE *f, int varnameWidth, const char *varname, const char *fmtstring, ...);
|
---|
1278 | extern void cs_strncpy(char * destination, const char * source, size_t num);
|
---|
1279 | extern char *get_servicename(int srvid, int caid);
|
---|
1280 | extern char *get_tiername(int tierid, int caid);
|
---|
1281 | extern char *get_provider(int caid, ulong provid);
|
---|
1282 | extern void make_non_blocking(int fd);
|
---|
1283 | extern uchar fast_rnd(void);
|
---|
1284 | extern void init_rnd(void);
|
---|
1285 | extern int hexserialset(struct s_reader *rdr);
|
---|
1286 | extern char *monitor_get_proto(struct s_client *);
|
---|
1287 | extern char *reader_get_type_desc(struct s_reader * rdr, int extended);
|
---|
1288 | extern char *get_ncd_client_name(char *client_id);
|
---|
1289 | extern char *strnew(char *str);
|
---|
1290 | extern void hexserial_to_newcamd(uchar *source, uchar *dest, ushort caid);
|
---|
1291 | extern void newcamd_to_hexserial(uchar *source, uchar *dest, ushort caid);
|
---|
1292 | extern int check_ip(struct s_ip *ip, in_addr_t n);
|
---|
1293 |
|
---|
1294 | extern pthread_key_t getclient;
|
---|
1295 | extern struct s_client * cur_client(void);
|
---|
1296 | extern struct s_client *first_client;
|
---|
1297 | extern struct s_reader *first_active_reader; //points to list of _active_ readers (enable = 1, deleted = 0)
|
---|
1298 | extern LLIST *configured_readers;
|
---|
1299 |
|
---|
1300 | // oscam variables
|
---|
1301 |
|
---|
1302 | extern int cs_dblevel, loghistidx;
|
---|
1303 |
|
---|
1304 | extern ushort len4caid[256];
|
---|
1305 |
|
---|
1306 | extern struct card_struct *Cards;
|
---|
1307 | //extern struct idstore_struct *idstore;
|
---|
1308 | extern unsigned long *IgnoreList;
|
---|
1309 |
|
---|
1310 | extern struct s_config cfg;
|
---|
1311 | extern char cs_confdir[];
|
---|
1312 | extern char loghist[CS_MAXLOGHIST*CS_LOGHISTSIZE];
|
---|
1313 | extern struct s_module ph[CS_MAX_MOD];
|
---|
1314 | extern struct s_cardsystem cardsystem[CS_MAX_MOD];
|
---|
1315 | extern struct s_cardreader cardreader[CS_MAX_MOD];
|
---|
1316 | //extern ECM_REQUEST *ecmtask;
|
---|
1317 |
|
---|
1318 | #ifdef CS_ANTICASC
|
---|
1319 | extern FILE *fpa;
|
---|
1320 | #endif
|
---|
1321 | extern pthread_mutex_t gethostbyname_lock;
|
---|
1322 |
|
---|
1323 | // oscam
|
---|
1324 | #ifdef WEBIF
|
---|
1325 | extern void cs_exit_oscam();
|
---|
1326 | extern void cs_restart_oscam();
|
---|
1327 | extern int cs_get_restartmode();
|
---|
1328 |
|
---|
1329 | //reset stats for webif:
|
---|
1330 | extern void clear_account_stats(struct s_auth *account);
|
---|
1331 | extern void clear_all_account_stats();
|
---|
1332 | extern void clear_system_stats();
|
---|
1333 |
|
---|
1334 | #endif
|
---|
1335 | extern void cs_reload_config();
|
---|
1336 | extern int recv_from_udpipe(uchar *);
|
---|
1337 | extern char* username(struct s_client *);
|
---|
1338 | extern struct s_client * get_client_by_tid(unsigned long);
|
---|
1339 | extern int chk_bcaid(ECM_REQUEST *, CAIDTAB *);
|
---|
1340 | extern void cs_exit(int sig);
|
---|
1341 | extern int comp_timeb(struct timeb *tpa, struct timeb *tpb);
|
---|
1342 | extern struct s_client * create_client(in_addr_t);
|
---|
1343 | extern int cs_auth_client(struct s_client *, struct s_auth *, const char*);
|
---|
1344 | extern void cs_disconnect_client(struct s_client *);
|
---|
1345 | extern int check_cwcache2(ECM_REQUEST *);
|
---|
1346 | extern int write_to_pipe(int, int, uchar *, int);
|
---|
1347 | extern int read_from_pipe(int, uchar **, int);
|
---|
1348 | extern int write_ecm_answer(struct s_reader *, ECM_REQUEST *);
|
---|
1349 | extern void log_emm_request(struct s_reader *);
|
---|
1350 | extern ulong chk_provid(uchar *, ushort);
|
---|
1351 | #ifdef IRDETO_GUESSING
|
---|
1352 | extern void guess_irdeto(ECM_REQUEST *);
|
---|
1353 | #endif
|
---|
1354 | extern void get_cw(struct s_client *, ECM_REQUEST *);
|
---|
1355 | extern void do_emm(struct s_client *, EMM_PACKET *);
|
---|
1356 | extern ECM_REQUEST *get_ecmtask(void);
|
---|
1357 | extern void request_cw(ECM_REQUEST *, int, int);
|
---|
1358 | extern int send_dcw(struct s_client *, ECM_REQUEST *);
|
---|
1359 | extern int process_input(uchar *, int, int);
|
---|
1360 | extern int has_srvid(struct s_client *cl, ECM_REQUEST *er);
|
---|
1361 | extern int chk_srvid(struct s_client *, ECM_REQUEST *);
|
---|
1362 | extern int chk_srvid_match(ECM_REQUEST *, SIDTAB *);
|
---|
1363 | extern int chk_sfilter(ECM_REQUEST *, PTAB*);
|
---|
1364 | extern int chk_ufilters(ECM_REQUEST *);
|
---|
1365 | extern int chk_rsfilter(struct s_reader * reader, ECM_REQUEST *);
|
---|
1366 | extern int matching_reader(ECM_REQUEST *, struct s_reader *);
|
---|
1367 | extern int emm_reader_match(struct s_reader *reader, ushort caid, ulong provid);
|
---|
1368 | extern void set_signal_handler(int , int , void (*));
|
---|
1369 | extern void cs_log_config(void);
|
---|
1370 | extern void cs_waitforcardinit(void);
|
---|
1371 | extern void cs_reinit_clients(struct s_auth *new_accounts);
|
---|
1372 | extern int process_client_pipe(struct s_client *cl, uchar *buf, int l);
|
---|
1373 | extern void update_reader_config(uchar *ptr);
|
---|
1374 | extern int chk_ctab(ushort caid, CAIDTAB *ctab);
|
---|
1375 | extern int chk_srvid_by_caid_prov(struct s_client *, ushort caid, ulong provid);
|
---|
1376 | extern void nullclose(int *fd);
|
---|
1377 | extern void kill_thread(struct s_client *cl);
|
---|
1378 | extern int get_threadnum(struct s_client *client);
|
---|
1379 | extern void cs_add_violation(uint ip);
|
---|
1380 |
|
---|
1381 | extern void cs_card_info(void);
|
---|
1382 | extern void cs_debug_level(void);
|
---|
1383 |
|
---|
1384 | #ifdef CS_ANTICASC
|
---|
1385 | extern void init_ac(void);
|
---|
1386 | extern void ac_init_stat();
|
---|
1387 | extern void ac_clear();
|
---|
1388 | extern void ac_done_stat();
|
---|
1389 | extern int ac_init_log();
|
---|
1390 | extern void ac_do_stat(void);
|
---|
1391 | extern void ac_init_client(struct s_auth *);
|
---|
1392 | extern void ac_chk(ECM_REQUEST*, int);
|
---|
1393 | #endif
|
---|
1394 |
|
---|
1395 | // oscam-config
|
---|
1396 | extern int init_config(void);
|
---|
1397 | extern int init_free_userdb(struct s_auth *auth);
|
---|
1398 | extern struct s_auth *init_userdb();
|
---|
1399 | extern int init_readerdb(void);
|
---|
1400 | extern int init_sidtab(void);
|
---|
1401 | extern int init_srvid(void);
|
---|
1402 | extern int init_tierid(void);
|
---|
1403 | extern int search_boxkey(ushort, char *);
|
---|
1404 | extern void init_len4caid(void);
|
---|
1405 | #ifdef IRDETO_GUESSING
|
---|
1406 | extern int init_irdeto_guess_tab(void);
|
---|
1407 | #endif
|
---|
1408 | extern void chk_caidtab(char *caidasc, CAIDTAB *ctab);
|
---|
1409 | extern void chk_tuntab(char *tunasc, TUNTAB *ttab);
|
---|
1410 | extern void chk_services(char *labels, SIDTABBITS *sidok, SIDTABBITS *sidno);
|
---|
1411 | extern void chk_ftab(char *zFilterAsc, FTAB *ftab, const char *zType, const char *zName, const char *zFiltName);
|
---|
1412 | extern void chk_cltab(char *classasc, CLASSTAB *clstab);
|
---|
1413 | extern void chk_iprange(char *value, struct s_ip **base);
|
---|
1414 | extern void chk_port_tab(char *portasc, PTAB *ptab);
|
---|
1415 | #ifdef CS_ANTICASC
|
---|
1416 | extern void chk_t_ac(char *token, char *value);
|
---|
1417 | #endif
|
---|
1418 | extern void chk_t_camd33(char *token, char *value);
|
---|
1419 | extern void chk_t_camd35(char *token, char *value);
|
---|
1420 | extern void chk_t_camd35_tcp(char *token, char *value);
|
---|
1421 | extern void chk_t_newcamd(char *token, char *value);
|
---|
1422 | extern void chk_t_radegast(char *token, char *value);
|
---|
1423 | extern void chk_t_serial(char *token, char *value);
|
---|
1424 | extern void chk_t_gbox(char *token, char *value);
|
---|
1425 | extern void chk_t_cccam(char *token, char *value);
|
---|
1426 | extern void chk_t_global(const char *token, char *value);
|
---|
1427 | extern void chk_t_monitor(char *token, char *value);
|
---|
1428 | extern void chk_reader(char *token, char *value, struct s_reader *rdr);
|
---|
1429 |
|
---|
1430 | #ifdef HAVE_DVBAPI
|
---|
1431 | extern void chk_t_dvbapi(char *token, char *value);
|
---|
1432 | void dvbapi_chk_caidtab(char *caidasc, char type);
|
---|
1433 | void dvbapi_read_priority();
|
---|
1434 | #endif
|
---|
1435 |
|
---|
1436 | #ifdef WEBIF
|
---|
1437 | extern void chk_t_webif(char *token, char *value);
|
---|
1438 | #endif
|
---|
1439 |
|
---|
1440 | extern void cs_accounts_chk(void);
|
---|
1441 | extern void chk_account(const char *token, char *value, struct s_auth *account);
|
---|
1442 | extern void chk_sidtab(char *token, char *value, struct s_sidtab *sidtab);
|
---|
1443 | extern int write_services();
|
---|
1444 | extern int write_userdb(struct s_auth *authptr);
|
---|
1445 | extern int write_config();
|
---|
1446 | extern int write_server();
|
---|
1447 | extern void write_versionfile();
|
---|
1448 | extern char *mk_t_caidtab(CAIDTAB *ctab);
|
---|
1449 | extern char *mk_t_retrylimittab(RETRYLIMITTAB *tab);
|
---|
1450 | extern char *mk_t_tuntab(TUNTAB *ttab);
|
---|
1451 | extern char *mk_t_group(uint64 grp);
|
---|
1452 | extern char *mk_t_ftab(FTAB *ftab);
|
---|
1453 | extern char *mk_t_camd35tcp_port();
|
---|
1454 | extern char *mk_t_aeskeys(struct s_reader *rdr);
|
---|
1455 | extern char *mk_t_newcamd_port();
|
---|
1456 | extern char *mk_t_aureader(struct s_auth *account);
|
---|
1457 | extern char *mk_t_nano(struct s_reader *rdr, uchar flag);
|
---|
1458 | extern char *mk_t_service( uint64 sidtabok, uint64 sidtabno);
|
---|
1459 | extern char *mk_t_logfile();
|
---|
1460 |
|
---|
1461 | //Todo #ifdef CCCAM
|
---|
1462 | extern int init_provid();
|
---|
1463 | extern char * get_tmp_dir();
|
---|
1464 |
|
---|
1465 | // oscam-reader
|
---|
1466 | extern int logfd;
|
---|
1467 | extern int reader_cmd2icc(struct s_reader * reader, const uchar *buf, const int l, uchar *response, ushort *response_length);
|
---|
1468 | extern int card_write(struct s_reader * reader, const uchar *, const uchar *, uchar *, ushort *);
|
---|
1469 | extern int check_sct_len(const unsigned char *data, int off);
|
---|
1470 | extern void cs_ri_brk(struct s_reader * reader, int);
|
---|
1471 | extern void cs_ri_log(struct s_reader * reader, char *,...);
|
---|
1472 | extern void * start_cardreader(void *);
|
---|
1473 | extern void reader_card_info(struct s_reader * reader);
|
---|
1474 | extern int hostResolve(struct s_reader * reader);
|
---|
1475 | extern int network_tcp_connection_open();
|
---|
1476 | extern void network_tcp_connection_close(struct s_client *, int);
|
---|
1477 | extern int casc_recv_timer(struct s_reader * reader, uchar *buf, int l, int msec);
|
---|
1478 | extern void clear_reader_pipe(struct s_reader * reader);
|
---|
1479 | extern void block_connect(struct s_reader *rdr);
|
---|
1480 | extern int is_connect_blocked(struct s_reader *rdr);
|
---|
1481 |
|
---|
1482 | // oscam-log
|
---|
1483 | extern int cs_init_log();
|
---|
1484 | extern int cs_open_logfiles();
|
---|
1485 | extern void cs_write_log(char *);
|
---|
1486 | extern void cs_log(const char *,...);
|
---|
1487 | #ifdef WITH_DEBUG
|
---|
1488 | extern void cs_debug_mask(unsigned short, const char *,...);
|
---|
1489 | extern void cs_ddump_mask(unsigned short, const uchar *, int, char *, ...);
|
---|
1490 | #else
|
---|
1491 | #define nop() asm volatile("nop")
|
---|
1492 | #define cs_debug(...) nop()
|
---|
1493 | #define cs_debug_mask(...) nop()
|
---|
1494 | #define cs_ddump(...) nop()
|
---|
1495 | #define cs_ddump_mask(...) nop()
|
---|
1496 | #endif
|
---|
1497 | extern void cs_close_log(void);
|
---|
1498 | extern int cs_init_statistics();
|
---|
1499 | extern void cs_dump(const uchar *, int, char *, ...);
|
---|
1500 |
|
---|
1501 | // oscam-aes
|
---|
1502 | extern void aes_set_key(char *);
|
---|
1503 | extern void add_aes_entry(struct s_reader *rdr, ushort caid, uint32 ident, int keyid, uchar *aesKey);
|
---|
1504 | extern void aes_encrypt_idx(struct s_client *, uchar *, int);
|
---|
1505 | extern void aes_decrypt(uchar *, int);
|
---|
1506 | extern int aes_decrypt_from_list(AES_ENTRY *list, ushort caid, uint32 provid,int keyid, uchar *buf, int n);
|
---|
1507 | extern int aes_present(AES_ENTRY *list, ushort caid, uint32 provid,int keyid);
|
---|
1508 | extern void parse_aes_keys(struct s_reader *rdr,char *value);
|
---|
1509 | extern void aes_clear_entries(struct s_reader *rdr);
|
---|
1510 |
|
---|
1511 | #define aes_encrypt(b, n) aes_encrypt_idx(cur_client(), b, n)
|
---|
1512 |
|
---|
1513 | // reader-common
|
---|
1514 | extern int reader_device_init(struct s_reader * reader);
|
---|
1515 | extern int reader_checkhealth(struct s_reader * reader);
|
---|
1516 | extern void reader_post_process(struct s_reader * reader);
|
---|
1517 | extern int reader_ecm(struct s_reader * reader, ECM_REQUEST *);
|
---|
1518 | extern int reader_emm(struct s_reader * reader, EMM_PACKET *);
|
---|
1519 | int reader_get_emm_type(EMM_PACKET *ep, struct s_reader * reader);
|
---|
1520 | struct s_cardsystem *get_cardsystem_by_caid(ushort caid);
|
---|
1521 | extern void reader_device_close(struct s_reader * reader);
|
---|
1522 |
|
---|
1523 | //module-stat
|
---|
1524 | extern void init_stat();
|
---|
1525 | extern int get_best_reader(ECM_REQUEST *er);
|
---|
1526 | extern void clear_reader_stat(struct s_reader *reader);
|
---|
1527 | extern void add_stat(struct s_reader *rdr, ECM_REQUEST *er, int ecm_time, int rc);
|
---|
1528 | extern void load_stat_from_file();
|
---|
1529 | extern void save_stat_to_file();
|
---|
1530 | extern void clear_all_stat();
|
---|
1531 | extern void housekeeping_stat(int force);
|
---|
1532 |
|
---|
1533 | #ifdef HAVE_PCSC
|
---|
1534 | // reader-pcsc
|
---|
1535 | extern void pcsc_close(struct s_reader *pcsc_reader);
|
---|
1536 | #endif
|
---|
1537 |
|
---|
1538 | void reader_nagra();
|
---|
1539 | void reader_irdeto();
|
---|
1540 | void reader_cryptoworks();
|
---|
1541 | void reader_viaccess();
|
---|
1542 | void reader_conax();
|
---|
1543 | void reader_seca();
|
---|
1544 | void reader_videoguard1();
|
---|
1545 | void reader_videoguard2();
|
---|
1546 | void reader_videoguard12();
|
---|
1547 | void reader_dre();
|
---|
1548 | void reader_tongfang();
|
---|
1549 |
|
---|
1550 | void cardreader_mouse(struct s_cardreader *crdr);
|
---|
1551 | void cardreader_smargo(struct s_cardreader *crdr);
|
---|
1552 | #ifdef WITH_STAPI
|
---|
1553 | void cardreader_stapi(struct s_cardreader *crdr);
|
---|
1554 | #endif
|
---|
1555 |
|
---|
1556 | // protocol modules
|
---|
1557 | extern int monitor_send_idx(struct s_client *, char *);
|
---|
1558 | extern void module_monitor(struct s_module *);
|
---|
1559 | extern void module_camd35(struct s_module *);
|
---|
1560 | extern void module_camd35_tcp(struct s_module *);
|
---|
1561 | extern void module_camd33(struct s_module *);
|
---|
1562 | extern void module_newcamd(struct s_module *);
|
---|
1563 | extern void module_radegast(struct s_module *);
|
---|
1564 | extern void module_oscam_ser(struct s_module *);
|
---|
1565 | extern void module_cccam(struct s_module *);
|
---|
1566 | extern void module_gbox(struct s_module *);
|
---|
1567 | extern void module_constcw(struct s_module *);
|
---|
1568 | extern struct timeval *chk_pending(struct timeb tp_ctimeout);
|
---|
1569 | #ifdef HAVE_DVBAPI
|
---|
1570 | extern void module_dvbapi(struct s_module *);
|
---|
1571 | #endif
|
---|
1572 |
|
---|
1573 | #ifdef WEBIF
|
---|
1574 | // oscam-http
|
---|
1575 | extern void http_srv();
|
---|
1576 | #endif
|
---|
1577 |
|
---|
1578 | // oscam-garbage
|
---|
1579 | extern void add_garbage(void *data);
|
---|
1580 | extern void start_garbage_collector();
|
---|
1581 | extern void stop_garbage_collector();
|
---|
1582 |
|
---|
1583 | #endif // CS_GLOBALS
|
---|