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 | #include "oscam-config.h"
|
---|
45 |
|
---|
46 | #ifdef UNUSED
|
---|
47 | #elif defined(__GNUC__)
|
---|
48 | # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
|
---|
49 | #elif defined(__LCLINT__)
|
---|
50 | # define UNUSED(x) /*@unused@*/ x
|
---|
51 | #else
|
---|
52 | # define UNUSED(x) x
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #ifdef WITH_DEBUG
|
---|
56 | # define call(arg) \
|
---|
57 | if (arg) { \
|
---|
58 | cs_debug_mask(D_TRACE, "ERROR, function call %s returns error.",#arg); \
|
---|
59 | return ERROR; \
|
---|
60 | }
|
---|
61 | # define D_USE(x) x
|
---|
62 | #else
|
---|
63 | # define call(arg) arg
|
---|
64 | # if defined(__GNUC__)
|
---|
65 | # define D_USE(x) D_USE_ ## x __attribute__((unused))
|
---|
66 | # elif defined(__LCLINT__)
|
---|
67 | # define D_USE(x) /*@debug use only@*/ x
|
---|
68 | # else
|
---|
69 | # define D_USE(x) x
|
---|
70 | # endif
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | #ifndef USE_CMAKE
|
---|
74 | # include "oscam-ostype.h"
|
---|
75 | #endif
|
---|
76 | #include "oscam-types.h"
|
---|
77 | #include "cscrypt/cscrypt.h"
|
---|
78 |
|
---|
79 | #ifdef HAVE_PCSC
|
---|
80 | #ifdef OS_CYGWIN32
|
---|
81 | #define __reserved
|
---|
82 | #define __nullnullterminated
|
---|
83 | #include <specstrings.h>
|
---|
84 | #include "cygwin/WinSCard.h"
|
---|
85 | #else
|
---|
86 | #include <PCSC/pcsclite.h>
|
---|
87 | #ifdef OS_MACOSX
|
---|
88 | #include <PCSC/wintypes.h>
|
---|
89 | #else
|
---|
90 | #include <PCSC/reader.h>
|
---|
91 | #endif
|
---|
92 | #endif
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #if defined(LIBUSB)
|
---|
96 | #ifdef __FreeBSD__
|
---|
97 | #include <libusb.h>
|
---|
98 | #else
|
---|
99 | #include <libusb-1.0/libusb.h>
|
---|
100 | #endif
|
---|
101 | #include "csctapi/smartreader_types.h"
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | #ifndef CS_CONFDIR
|
---|
105 | #define CS_CONFDIR "/usr/local/etc"
|
---|
106 | #endif
|
---|
107 | #ifndef CS_LOGFILE
|
---|
108 | #define CS_LOGFILE "/var/log/oscam.log"
|
---|
109 | #endif
|
---|
110 | #define CS_QLEN 128 // size of request queue
|
---|
111 | #define CS_MAXCAIDTAB 32 // max. caid-defs/user
|
---|
112 | #define CS_MAXTUNTAB 20 // max. betatunnel mappings
|
---|
113 | #define CS_MAXPROV 32
|
---|
114 | #define CS_MAXPORTS 32 // max server ports
|
---|
115 | #define CS_MAXFILTERS 16
|
---|
116 | #define CS_MAX_CAIDVALUETAB 16
|
---|
117 |
|
---|
118 | #define CS_ECMSTORESIZE 16 // use MD5()
|
---|
119 | #define CS_EMMSTORESIZE 16 // use MD5()
|
---|
120 | #define CS_CLIENT_TIMEOUT 5000
|
---|
121 | #define CS_CLIENT_MAXIDLE 120
|
---|
122 | #define CS_BIND_TIMEOUT 120
|
---|
123 | #define CS_DELAY 0
|
---|
124 | #define CS_MAXLOGHIST 30
|
---|
125 | #define CS_LOGHISTSIZE 193 // 32+128+33: username + logline + channelname
|
---|
126 | #define CS_ECM_RINGBUFFER_MAX 20 // max size for ECM last responsetimes ringbuffer
|
---|
127 |
|
---|
128 | #define CS_CACHE_TIMEOUT 60
|
---|
129 | #ifndef PTHREAD_STACK_MIN
|
---|
130 | #define PTHREAD_STACK_MIN 64000
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | #ifdef CS_EMBEDDED
|
---|
134 | #define CS_MAXPENDING 16
|
---|
135 | #define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN+8000
|
---|
136 | #else
|
---|
137 | #define CS_MAXPENDING 32
|
---|
138 | #define PTHREAD_STACK_SIZE PTHREAD_STACK_MIN+10000
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | #define CS_EMMCACHESIZE 64 //nr of EMMs that each client will cache; cache is per client, so memory-expensive...
|
---|
142 |
|
---|
143 | #define D_TRACE 1 // Generate very detailed error/trace messages per routine
|
---|
144 | #define D_ATR 2 // Debug ATR parsing, dump of ecm, cw
|
---|
145 | #define D_READER 4 // Debug Reader/Proxy Process
|
---|
146 | #define D_CLIENT 8 // Debug Client Process
|
---|
147 | #define D_IFD 16 // Debug IFD+protocol
|
---|
148 | #define D_DEVICE 32 // Debug Reader I/O
|
---|
149 | #define D_EMM 64 // Dumps EMM
|
---|
150 | #define D_DVBAPI 128 // Debug DVBAPI
|
---|
151 | #define D_ALL_DUMP 255 // dumps all
|
---|
152 |
|
---|
153 | #define R_DB2COM1 0x1 // Reader Dbox2 @ com1
|
---|
154 | #define R_DB2COM2 0x2 // Reader Dbox2 @ com1
|
---|
155 | #define R_SC8in1 0x3 // Reader Sc8in1 or MCR
|
---|
156 | #define R_MP35 0x4 // AD-Teknik Multiprogrammer 3.5 and 3.6 (only usb tested)
|
---|
157 | #define R_MOUSE 0x5 // Reader smartcard mouse
|
---|
158 | /////////////////// phoenix readers which need baudrate setting and timings need to be guarded by OSCam: BEFORE R_MOUSE
|
---|
159 | #define R_INTERNAL 0x6 // Reader smartcard intern
|
---|
160 | /////////////////// internal readers (Dreambox, Coolstream, IPBox) are all R_INTERNAL, they are determined compile-time
|
---|
161 | /////////////////// readers that do not reed baudrate setting and timings are guarded by reader itself (large buffer built in): AFTER R_SMART
|
---|
162 | #define R_SMART 0x7 // Smartreader+
|
---|
163 | #define R_PCSC 0x8 // PCSC
|
---|
164 | /////////////////// proxy readers after R_CS378X
|
---|
165 | #define R_CAMD35 0x20 // Reader cascading camd 3.5x
|
---|
166 | #define R_CAMD33 0x21 // Reader cascading camd 3.3x
|
---|
167 | #define R_NEWCAMD 0x22 // Reader cascading newcamd
|
---|
168 | #define R_RADEGAST 0x23 // Reader cascading radegast
|
---|
169 | #define R_CS378X 0x24 // Reader cascading camd 3.5x TCP
|
---|
170 | #define R_CONSTCW 0x25 // Reader for Constant CW
|
---|
171 | /////////////////// peer to peer proxy readers after R_CCCAM
|
---|
172 | #define R_GBOX 0x30 // Reader cascading gbox
|
---|
173 | #define R_CCCAM 0x35 // Reader cascading cccam
|
---|
174 | #define R_SERIAL 0x80 // Reader serial
|
---|
175 | #define R_IS_NETWORK 0x60
|
---|
176 | #define R_IS_CASCADING 0xE0
|
---|
177 |
|
---|
178 | //ECM rc codes, reader only:
|
---|
179 | #define E_RDR_NOTFOUND 0
|
---|
180 | #define E_RDR_FOUND 1
|
---|
181 | //ECM rc codes:
|
---|
182 | #define E_FOUND 0
|
---|
183 | #define E_CACHE1 1
|
---|
184 | #define E_CACHE2 2
|
---|
185 | #define E_EMU 3
|
---|
186 | ///////above is all found
|
---|
187 | #define E_NOTFOUND 4 //for selection of found, use < E_NOTFOUND
|
---|
188 | #define E_TIMEOUT 5
|
---|
189 | #define E_SLEEPING 6
|
---|
190 | #define E_FAKE 7
|
---|
191 | #define E_INVALID 8
|
---|
192 | #define E_CORRUPT 9
|
---|
193 | #define E_NOCARD 10
|
---|
194 | #define E_EXPDATE 11
|
---|
195 | #define E_DISABLED 12
|
---|
196 | #define E_STOPPED 13 //for selection of error, use <= E_STOPPED and exclude selection of found
|
---|
197 | ///////above is all notfound, some error or problem
|
---|
198 | #define E_99 99 //this code is undocumented
|
---|
199 | #define E_UNHANDLED 100 //for selection of unhandled, use >= E_UNHANDLED
|
---|
200 |
|
---|
201 | #define CS_MAX_MOD 20
|
---|
202 | #define MOD_CONN_TCP 1
|
---|
203 | #define MOD_CONN_UDP 2
|
---|
204 | #define MOD_CONN_NET 3
|
---|
205 | #define MOD_CONN_SERIAL 4
|
---|
206 | #define MOD_NO_CONN 8
|
---|
207 |
|
---|
208 | #define MOD_CARDSYSTEM 16
|
---|
209 | #define MOD_ADDON 32
|
---|
210 |
|
---|
211 |
|
---|
212 | #ifdef HAVE_DVBAPI
|
---|
213 | #define BOXTYPE_DREAMBOX 1
|
---|
214 | #define BOXTYPE_DUCKBOX 2
|
---|
215 | #define BOXTYPE_UFS910 3
|
---|
216 | #define BOXTYPE_DBOX2 4
|
---|
217 | #define BOXTYPE_IPBOX 5
|
---|
218 | #define BOXTYPE_IPBOX_PMT 6
|
---|
219 | #define BOXTYPE_DM7000 7
|
---|
220 | #define BOXTYPE_QBOXHD 8
|
---|
221 | #define BOXTYPE_COOLSTREAM 9
|
---|
222 | #define BOXTYPE_NEUMO 10
|
---|
223 | #define BOXTYPES 10
|
---|
224 | extern const char *boxdesc[];
|
---|
225 | #endif
|
---|
226 |
|
---|
227 | #ifdef CS_CORE
|
---|
228 | char *PIP_ID_TXT[] = { "ECM", "EMM", "CIN", "KCL", "UDP", NULL };
|
---|
229 | char *RDR_CD_TXT[] = { "cd", "dsr", "cts", "ring", "none",
|
---|
230 | #ifdef USE_GPIO
|
---|
231 | "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7", //felix: changed so that gpio can be used
|
---|
232 | #endif
|
---|
233 | NULL };
|
---|
234 | #else
|
---|
235 | extern char *PIP_ID_TXT[];
|
---|
236 | extern char *RDR_CD_TXT[];
|
---|
237 | #endif
|
---|
238 |
|
---|
239 | #define PIP_ID_ECM 0
|
---|
240 | #define PIP_ID_EMM 1
|
---|
241 | #define PIP_ID_CIN 2 // CARD_INFO
|
---|
242 | #define PIP_ID_KCL 3 // Schlocke: Kill all Clients (no param)
|
---|
243 | #define PIP_ID_UDP 4
|
---|
244 | #define PIP_ID_MAX PIP_ID_UDP
|
---|
245 |
|
---|
246 |
|
---|
247 | #define PIP_ID_ERR (-1)
|
---|
248 | #define PIP_ID_DIR (-2)
|
---|
249 | #define PIP_ID_NUL (-3)
|
---|
250 |
|
---|
251 | #define cdiff *c_start
|
---|
252 |
|
---|
253 | #define NCD_AUTO 0
|
---|
254 | #define NCD_524 1
|
---|
255 | #define NCD_525 2
|
---|
256 |
|
---|
257 | // moved from reader-common.h
|
---|
258 | #define UNKNOWN 0
|
---|
259 | #define NO_CARD 4
|
---|
260 | #define CARD_NEED_INIT 1
|
---|
261 | #define CARD_INSERTED 2
|
---|
262 | #define CARD_FAILURE 3
|
---|
263 |
|
---|
264 | // moved from stats
|
---|
265 | #define DEFAULT_REOPEN_SECONDS 900
|
---|
266 | #define DEFAULT_MIN_ECM_COUNT 5
|
---|
267 | #define DEFAULT_MAX_ECM_COUNT 500
|
---|
268 | #define DEFAULT_NBEST 1
|
---|
269 | #define DEFAULT_NFB 1
|
---|
270 | #define DEFAULT_RETRYLIMIT 800
|
---|
271 | #define DEFAULT_LB_STAT_CLEANUP 336
|
---|
272 | #define DEFAULT_LB_USE_LOCKING 0
|
---|
273 | #define DEFAULT_UPDATEINTERVAL 240
|
---|
274 |
|
---|
275 | enum {E1_GLOBAL=0, E1_USER, E1_READER, E1_SERVER, E1_LSERVER};
|
---|
276 | enum {E2_GLOBAL=0, E2_GROUP, E2_CAID, E2_IDENT, E2_CLASS, E2_CHID, E2_QUEUE,
|
---|
277 | E2_EA_LEN, E2_F0_LEN, E2_OFFLINE, E2_SID,
|
---|
278 | E2_CCCAM_NOCARD=0x27, E2_CCCAM_NOK1=0x28, E2_CCCAM_NOK2=0x29, E2_CCCAM_LOOP=0x30};
|
---|
279 |
|
---|
280 | typedef unsigned char uint8;
|
---|
281 | typedef unsigned short uint16;
|
---|
282 | typedef unsigned int uint32;
|
---|
283 | typedef unsigned long long uint64;
|
---|
284 | typedef long long int64;
|
---|
285 |
|
---|
286 | int server_pid; //alno: PID of server - set while startup
|
---|
287 |
|
---|
288 | // constants
|
---|
289 | #define CTA_RES_LEN 512
|
---|
290 |
|
---|
291 | #ifdef CS_LED
|
---|
292 | #define LED1A 0
|
---|
293 | #define LED1B 1
|
---|
294 | #define LED2 2
|
---|
295 | #define LED3 3
|
---|
296 | #define LED_OFF 0
|
---|
297 | #define LED_ON 1
|
---|
298 | #define LED_BLINK_ON 2
|
---|
299 | #define LED_BLINK_OFF 3
|
---|
300 | #define LED_DEFAULT 10
|
---|
301 | extern void cs_switch_led(int led, int action);
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | #ifdef QBOXHD_LED
|
---|
305 | typedef struct {
|
---|
306 | unsigned short H; // range 0-359
|
---|
307 | unsigned char S; // range 0-99
|
---|
308 | unsigned char V; // range 0-99
|
---|
309 | } qboxhd_led_color_struct;
|
---|
310 | typedef struct {
|
---|
311 | unsigned char red; // first 5 bit used (&0x1F)
|
---|
312 | unsigned char green; // first 5 bit used (&0x1F)
|
---|
313 | unsigned char blue; // first 5 bit used (&0x1F)
|
---|
314 | } qboxhdmini_led_color_struct;
|
---|
315 |
|
---|
316 | extern void qboxhd_led_blink(int color, int duration);
|
---|
317 |
|
---|
318 | #define QBOXHD_LED_DEVICE "/dev/sw0"
|
---|
319 | #define QBOXHD_SET_LED_ALL_PANEL_COLOR _IO(0xBC, 13) // payload = 3byte [H][S][V]
|
---|
320 | #define QBOXHD_LED_COLOR_RED 359 // only H value, S and V values are always == 99
|
---|
321 | #define QBOXHD_LED_COLOR_GREEN 120
|
---|
322 | #define QBOXHD_LED_COLOR_BLUE 230
|
---|
323 | #define QBOXHD_LED_COLOR_YELLOW 55
|
---|
324 | #define QBOXHD_LED_COLOR_MAGENTA 290
|
---|
325 |
|
---|
326 | #define QBOXHDMINI_LED_DEVICE "/dev/lpc_0"
|
---|
327 | #define QBOXHDMINI_IOSET_RGB _IOWR('L', 6, qboxhdmini_led_color_struct)
|
---|
328 | #define QBOXHDMINI_LED_COLOR_RED 0x1F0000 // 3 bytes RGB , 5 bit used for each color
|
---|
329 | #define QBOXHDMINI_LED_COLOR_GREEN 0x001F00
|
---|
330 | #define QBOXHDMINI_LED_COLOR_BLUE 0x00001F
|
---|
331 | #define QBOXHDMINI_LED_COLOR_YELLOW 0x1F1F00
|
---|
332 | #define QBOXHDMINI_LED_COLOR_MAGENTA 0x1F001F
|
---|
333 |
|
---|
334 | #define QBOXHD_LED_COLOR_OFF -1 // all colors H,S,V and/or R,G,B == 0,0,0
|
---|
335 |
|
---|
336 | #define QBOXHD_LED_BLINK_FAST 100 // blink milliseconds
|
---|
337 | #define QBOXHD_LED_BLINK_MEDIUM 200
|
---|
338 | #define QBOXHD_LED_BLINK_SLOW 400
|
---|
339 |
|
---|
340 | #endif //QBOXHD_LED
|
---|
341 |
|
---|
342 | #define MAX_ATR_LEN 33 // max. ATR length
|
---|
343 | #define MAX_HIST 15 // max. number of historical characters
|
---|
344 |
|
---|
345 | #define MAX_SIDBITS 64 // max services
|
---|
346 | #define SIDTABBITS uint64 // 64bit type for services, if a system does not support this type,
|
---|
347 | // please use a define and define it as uint32 / MAX_SIDBITS 32
|
---|
348 |
|
---|
349 | #define BAN_UNKNOWN 1 //failban mask for anonymous/ unknown contact
|
---|
350 | #define BAN_DISABLED 2 //failban mask for disabled user
|
---|
351 | #define BAN_SLEEPING 4 //failban mask for sleeping user
|
---|
352 | #define BAN_DUPLICATE 8 //failban mask for duplicate user
|
---|
353 |
|
---|
354 | //checking if (X) free(X) unneccessary since freeing a null pointer doesnt do anything
|
---|
355 | #define NULLFREE(X) {if (X) {void *tmpX=X; X=NULL; free(tmpX); }}
|
---|
356 |
|
---|
357 | typedef struct s_caidvaluetab
|
---|
358 | {
|
---|
359 | ushort n;
|
---|
360 | ushort caid[CS_MAX_CAIDVALUETAB];
|
---|
361 | ushort value[CS_MAX_CAIDVALUETAB];
|
---|
362 | } CAIDVALUETAB;
|
---|
363 |
|
---|
364 | typedef struct s_classtab
|
---|
365 | {
|
---|
366 | uchar an;
|
---|
367 | uchar bn;
|
---|
368 | uchar aclass[31];
|
---|
369 | uchar bclass[31];
|
---|
370 | } CLASSTAB;
|
---|
371 |
|
---|
372 | typedef struct s_caidtab
|
---|
373 | {
|
---|
374 | ushort caid[CS_MAXCAIDTAB];
|
---|
375 | ushort mask[CS_MAXCAIDTAB];
|
---|
376 | ushort cmap[CS_MAXCAIDTAB];
|
---|
377 | } CAIDTAB;
|
---|
378 |
|
---|
379 | typedef struct s_tuntab
|
---|
380 | {
|
---|
381 | ushort bt_caidfrom[CS_MAXTUNTAB];
|
---|
382 | ushort bt_caidto[CS_MAXTUNTAB];
|
---|
383 | ushort bt_srvid[CS_MAXTUNTAB];
|
---|
384 | } TUNTAB;
|
---|
385 |
|
---|
386 | typedef struct s_sidtab
|
---|
387 | {
|
---|
388 | char label[64];
|
---|
389 | ushort num_caid;
|
---|
390 | ushort num_provid;
|
---|
391 | ushort num_srvid;
|
---|
392 | ushort *caid;
|
---|
393 | ulong *provid;
|
---|
394 | ushort *srvid;
|
---|
395 | struct s_sidtab *next;
|
---|
396 | } SIDTAB;
|
---|
397 |
|
---|
398 |
|
---|
399 | typedef struct s_filter
|
---|
400 | {
|
---|
401 | ushort caid;
|
---|
402 | uchar nprids;
|
---|
403 | ulong prids[CS_MAXPROV];
|
---|
404 | } FILTER;
|
---|
405 |
|
---|
406 | typedef struct s_ftab
|
---|
407 | {
|
---|
408 | int nfilts;
|
---|
409 | FILTER filts[CS_MAXFILTERS];
|
---|
410 | } FTAB;
|
---|
411 |
|
---|
412 | typedef struct s_port
|
---|
413 | {
|
---|
414 | int fd;
|
---|
415 | int s_port;
|
---|
416 | int ncd_key_is_set; //0 or 1
|
---|
417 | uchar ncd_key[16];
|
---|
418 | FTAB ftab;
|
---|
419 | } PORT;
|
---|
420 |
|
---|
421 | typedef struct s_ptab
|
---|
422 | {
|
---|
423 | int nports;
|
---|
424 | PORT ports[CS_MAXPORTS];
|
---|
425 | } PTAB;
|
---|
426 |
|
---|
427 | typedef struct aes_entry {
|
---|
428 | ushort keyid;
|
---|
429 | ushort caid;
|
---|
430 | uint32 ident;
|
---|
431 | uchar plainkey[16];
|
---|
432 | AES_KEY key;
|
---|
433 | struct aes_entry *next;
|
---|
434 | } AES_ENTRY;
|
---|
435 |
|
---|
436 | struct s_ecm
|
---|
437 | {
|
---|
438 | uchar ecmd5[CS_ECMSTORESIZE];
|
---|
439 | uchar cw[16];
|
---|
440 | ushort caid;
|
---|
441 | uint64 grp;
|
---|
442 | struct s_reader *reader;
|
---|
443 | int rc;
|
---|
444 | time_t time;
|
---|
445 | };
|
---|
446 |
|
---|
447 | struct s_emm
|
---|
448 | {
|
---|
449 | uchar emmd5[CS_EMMSTORESIZE];
|
---|
450 | uchar type;
|
---|
451 | int count;
|
---|
452 | };
|
---|
453 |
|
---|
454 | // failban listmember
|
---|
455 | typedef struct v_ban {
|
---|
456 | int v_count;
|
---|
457 | uint v_ip;
|
---|
458 | time_t v_time;
|
---|
459 | } V_BAN;
|
---|
460 |
|
---|
461 | #define AVAIL_CHECK_CONNECTED 0
|
---|
462 | #define AVAIL_CHECK_LOADBALANCE 1
|
---|
463 |
|
---|
464 | struct s_client ;
|
---|
465 | struct ecm_request_t ;
|
---|
466 | struct emm_packet_t ;
|
---|
467 |
|
---|
468 | struct s_module
|
---|
469 | {
|
---|
470 | int active;
|
---|
471 | int multi;
|
---|
472 | int type;
|
---|
473 | int watchdog;
|
---|
474 | char desc[16];
|
---|
475 | char *logtxt;
|
---|
476 | //int s_port;
|
---|
477 | in_addr_t s_ip;
|
---|
478 | void *(*s_handler)();
|
---|
479 | int (*recv)(struct s_client *, uchar *, int);
|
---|
480 | void (*send_dcw)(struct s_client*, struct ecm_request_t *);
|
---|
481 | void (*cleanup)(struct s_client*);
|
---|
482 | int c_multi;
|
---|
483 | int (*c_recv_chk)(struct s_client*, uchar *, int *, uchar *, int);
|
---|
484 | int (*c_init)(struct s_client*);
|
---|
485 | int (*c_send_ecm)(struct s_client *, struct ecm_request_t *, uchar *);
|
---|
486 | int (*c_send_emm)(struct emm_packet_t *);
|
---|
487 | int (*c_init_log)(void);
|
---|
488 | int (*c_recv_log)(ushort *, ulong *, ushort *);
|
---|
489 | int (*c_available)(struct s_reader *, int); //Schlocke: available check for load-balancing,
|
---|
490 | //params:
|
---|
491 | //rdr (reader to check)
|
---|
492 | //int checktype (0=return connected, 1=return loadbalance-avail) return int
|
---|
493 | void (*c_idle)(void); //Schlocke: called when reader is idle
|
---|
494 | void (*c_card_info)(void); //Schlocke: request card infos
|
---|
495 | int c_port;
|
---|
496 | PTAB *ptab;
|
---|
497 | int num;
|
---|
498 | };
|
---|
499 |
|
---|
500 | struct s_ATR ;
|
---|
501 |
|
---|
502 | struct s_cardreader
|
---|
503 | {
|
---|
504 | int active;
|
---|
505 | char desc[16];
|
---|
506 | int (*reader_init)(struct s_reader*);
|
---|
507 | int (*get_status)(struct s_reader*, int*);
|
---|
508 | int (*activate)(struct s_reader*, struct s_ATR *);
|
---|
509 | int (*transmit)(struct s_reader*, unsigned char *sent, unsigned int size);
|
---|
510 | int (*receive)(struct s_reader*, unsigned char *data, unsigned int size);
|
---|
511 | int (*close)(struct s_reader*);
|
---|
512 | int (*set_parity)(struct s_reader*, uchar parity);
|
---|
513 | 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);
|
---|
514 | int (*set_protocol)(struct s_reader*, unsigned char * params, unsigned *length, uint len_request);
|
---|
515 | int (*set_baudrate)(struct s_reader*, ulong baud); //set only for readers which need baudrate setting and timings need to be guarded by OSCam
|
---|
516 | int typ; //fixme: workaround, remove when all old code is converted
|
---|
517 |
|
---|
518 | int max_clock_speed; // 1 for reader->typ > R_MOUSE
|
---|
519 | int need_inverse; //0 = reader does inversing; 1 = inversing done by oscam
|
---|
520 | //io_serial config
|
---|
521 | int flush;
|
---|
522 | int read_written; // 1 = written bytes has to read from device
|
---|
523 | };
|
---|
524 |
|
---|
525 | struct s_cardsystem
|
---|
526 | {
|
---|
527 | int active;
|
---|
528 | char *desc;
|
---|
529 | int (*card_init)();
|
---|
530 | int (*card_info)();
|
---|
531 | int (*do_ecm)();
|
---|
532 | int (*do_emm)();
|
---|
533 | void (*post_process)();
|
---|
534 | int (*get_emm_type)();
|
---|
535 | void (*get_emm_filter)();
|
---|
536 | uchar caids[2];
|
---|
537 | };
|
---|
538 |
|
---|
539 | #ifdef IRDETO_GUESSING
|
---|
540 | struct s_irdeto_quess
|
---|
541 | {
|
---|
542 | int b47;
|
---|
543 | ushort caid;
|
---|
544 | ushort sid;
|
---|
545 | struct s_irdeto_quess *next;
|
---|
546 | };
|
---|
547 | #endif
|
---|
548 |
|
---|
549 | #define MSGLOGSIZE 64
|
---|
550 | typedef struct ecm_request_t
|
---|
551 | {
|
---|
552 | uchar ecm[256];
|
---|
553 | uchar cw[16];
|
---|
554 | uchar ecmd5[CS_ECMSTORESIZE];
|
---|
555 | // uchar l;
|
---|
556 | short l;
|
---|
557 | ushort caid;
|
---|
558 | ushort ocaid; //original caid, used for betatunneling
|
---|
559 | ushort srvid;
|
---|
560 | ushort chid;
|
---|
561 | ushort pid;
|
---|
562 | ushort idx;
|
---|
563 | ulong prid;
|
---|
564 | struct s_reader *selected_reader;
|
---|
565 | LLIST *matching_rdr; //list of matching readers
|
---|
566 | LL_NODE *fallback; // in *matching_rdr, at position "fallback" the first fallback reader is in the list
|
---|
567 | struct s_client *client; //contains pointer to 'c' client while running in 'r' client
|
---|
568 | int cpti; // client pending table index
|
---|
569 | int stage; // processing stage in server module
|
---|
570 | int level; // send-level in client module
|
---|
571 | int rc;
|
---|
572 | uchar rcEx;
|
---|
573 | struct timeb tps; // incoming time stamp
|
---|
574 | uchar locals_done;
|
---|
575 | int btun; // mark er as betatunneled
|
---|
576 | int reader_avail; //count of available readers
|
---|
577 | int reader_count; //count of contacted readers
|
---|
578 |
|
---|
579 | #ifdef CS_WITH_DOUBLECHECK
|
---|
580 | int checked;
|
---|
581 | uchar cw_checked[16];
|
---|
582 | #endif
|
---|
583 |
|
---|
584 | struct s_reader *origin_reader;
|
---|
585 | void * origin_card; //CCcam preferred card!
|
---|
586 |
|
---|
587 | struct s_ecm *ecmcacheptr; //Pointer to ecm-cw-rc-cache!
|
---|
588 |
|
---|
589 | char msglog[MSGLOGSIZE];
|
---|
590 | } ECM_REQUEST;
|
---|
591 |
|
---|
592 | struct s_client
|
---|
593 | {
|
---|
594 | in_addr_t ip;
|
---|
595 | in_port_t port;
|
---|
596 | time_t login;
|
---|
597 | time_t last;
|
---|
598 | time_t lastswitch;
|
---|
599 | time_t lastemm;
|
---|
600 | time_t lastecm;
|
---|
601 | time_t expirationdate;
|
---|
602 | int allowedtimeframe[2];
|
---|
603 | int c35_suppresscmd08;
|
---|
604 | int c35_sleepsend;
|
---|
605 | int ncd_keepalive;
|
---|
606 | int disabled;
|
---|
607 | uint64 grp;
|
---|
608 | int crypted;
|
---|
609 | int dup;
|
---|
610 | LLIST *aureader_list;
|
---|
611 | int autoau;
|
---|
612 | int monlvl;
|
---|
613 | CAIDTAB ctab;
|
---|
614 | TUNTAB ttab;
|
---|
615 | SIDTABBITS sidtabok; // positiv services
|
---|
616 | SIDTABBITS sidtabno; // negative services
|
---|
617 | 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
|
---|
618 | int ctyp;
|
---|
619 | int stat;
|
---|
620 | int last_srvid;
|
---|
621 | int last_caid;
|
---|
622 | int tosleep;
|
---|
623 | struct s_auth *account;
|
---|
624 | int udp_fd;
|
---|
625 | int fd_m2c; //master writes to this fd
|
---|
626 | int fd_m2c_c; //client reads from this fd
|
---|
627 | struct sockaddr_in udp_sa;
|
---|
628 | int log;
|
---|
629 | int logcounter;
|
---|
630 | int cwfound; // count found ECMs per client
|
---|
631 | int cwcache; // count ECMs from cache1/2 per client
|
---|
632 | int cwnot; // count not found ECMs per client
|
---|
633 | int cwtun; // count betatunneled ECMs per client
|
---|
634 | int cwignored; // count ignored ECMs per client
|
---|
635 | int cwtout; // count timeouted ECMs per client
|
---|
636 | int cwlastresptime; //last Responsetime (ms)
|
---|
637 | int cwlastresptimes[CS_ECM_RINGBUFFER_MAX]; //ringbuffer for last 20 times
|
---|
638 | int cwlastresptimes_last; // ringbuffer pointer
|
---|
639 | int emmok; // count EMM ok
|
---|
640 | int emmnok; // count EMM nok
|
---|
641 | #ifdef WEBIF
|
---|
642 | int wihidden; // hidden in webinterface status
|
---|
643 | char lastreader[64]; // last cw got from this reader
|
---|
644 | #endif
|
---|
645 | uchar ucrc[4]; // needed by monitor and used by camd35
|
---|
646 | ulong pcrc; // pwd crc
|
---|
647 | AES_KEY aeskey; // encryption key needed by monitor and used by camd33, camd35
|
---|
648 | AES_KEY aeskey_decrypt; // decryption key needed by monitor and used by camd33, camd35
|
---|
649 | ushort ncd_msgid;
|
---|
650 | char ncd_client_id[5];
|
---|
651 | uchar ncd_skey[16];
|
---|
652 | void *cc;
|
---|
653 | void *gbox;
|
---|
654 | int port_idx; // index in server ptab
|
---|
655 | int ncd_server; // newcamd server
|
---|
656 | #ifdef CS_ANTICASC
|
---|
657 | ushort ac_idx;
|
---|
658 | ushort ac_limit;
|
---|
659 | uchar ac_penalty;
|
---|
660 | #endif
|
---|
661 | FTAB fchid;
|
---|
662 | FTAB ftab; // user [caid] and ident filter
|
---|
663 | CLASSTAB cltab;
|
---|
664 |
|
---|
665 |
|
---|
666 | int pfd; // Primary FD, must be closed on exit
|
---|
667 | struct s_reader *reader; //points to s_reader when cl->typ='r'
|
---|
668 |
|
---|
669 | ECM_REQUEST *ecmtask;
|
---|
670 | struct s_emm *emmcache;
|
---|
671 |
|
---|
672 | pthread_t thread;
|
---|
673 |
|
---|
674 | struct s_serial_client *serialdata;
|
---|
675 |
|
---|
676 | //reader common
|
---|
677 | int last_idx;
|
---|
678 | ushort idx;
|
---|
679 | int rotate;
|
---|
680 |
|
---|
681 | uchar *req;
|
---|
682 |
|
---|
683 | //camd33
|
---|
684 | uchar camdbug[256];
|
---|
685 |
|
---|
686 | int ncd_proto;
|
---|
687 |
|
---|
688 | //camd35
|
---|
689 | uchar upwd[64];
|
---|
690 | int is_udp;
|
---|
691 | int stopped;
|
---|
692 | int lastcaid;
|
---|
693 | int lastsrvid;
|
---|
694 | int lastpid;
|
---|
695 | time_t emm_last;
|
---|
696 | int disable_counter;
|
---|
697 | uchar lastserial[8];
|
---|
698 |
|
---|
699 | //cccam
|
---|
700 | int g_flag;
|
---|
701 | int cc_use_rc4;
|
---|
702 |
|
---|
703 | //monitor
|
---|
704 | int auth;
|
---|
705 |
|
---|
706 | //cs_hexdump buffer
|
---|
707 | uchar dump[520];
|
---|
708 |
|
---|
709 | //oscam.c
|
---|
710 | struct timeval tv;
|
---|
711 |
|
---|
712 | //failban value set bitwise - compared with BAN_
|
---|
713 | int failban;
|
---|
714 | struct s_client *next; //make client a linked list
|
---|
715 | };
|
---|
716 |
|
---|
717 |
|
---|
718 | //for viaccess var in s_reader:
|
---|
719 | struct geo_cache
|
---|
720 | {
|
---|
721 | ulong provid;
|
---|
722 | uchar geo[256];
|
---|
723 | uchar geo_len;
|
---|
724 | int number_ecm;
|
---|
725 | };
|
---|
726 | // for videoguard in s_reader
|
---|
727 | struct s_CmdTabEntry {
|
---|
728 | unsigned char cla;
|
---|
729 | unsigned char cmd;
|
---|
730 | unsigned char len;
|
---|
731 | unsigned char mode;
|
---|
732 | };
|
---|
733 |
|
---|
734 | struct s_CmdTab {
|
---|
735 | unsigned char index;
|
---|
736 | unsigned char size;
|
---|
737 | unsigned char Nentries;
|
---|
738 | unsigned char dummy;
|
---|
739 | struct s_CmdTabEntry e[1];
|
---|
740 | };
|
---|
741 | //ratelimit
|
---|
742 | struct ecmrl {
|
---|
743 | ushort srvid;
|
---|
744 | time_t last;
|
---|
745 | };
|
---|
746 | #define MAXECMRATELIMIT 20
|
---|
747 |
|
---|
748 | struct s_reader //contains device info, reader info and card info
|
---|
749 | {
|
---|
750 | ulong auprovid; // AU only for this provid
|
---|
751 | int audisabled; // exclude reader from auto AU
|
---|
752 | int smargopatch;
|
---|
753 | struct s_client * client; //pointer to 'r'client this reader is running in
|
---|
754 | int enable;
|
---|
755 | int available; //Schlocke: New flag for loadbalancing. Only reader if reader supports ph.c_available function
|
---|
756 | int fd_error;
|
---|
757 | int fd;
|
---|
758 | uint64 grp;
|
---|
759 | int fallback;
|
---|
760 | int typ;
|
---|
761 | char label[64];
|
---|
762 | char device[128];
|
---|
763 | void *spec_dev; //pointer to structure that contains specific device data
|
---|
764 | ushort slot; //in case of multiple slots like sc8in1; first slot = 1
|
---|
765 | int handle; //device handle
|
---|
766 | int fdmc; //device handle for multicam
|
---|
767 | #ifdef WITH_STAPI
|
---|
768 | unsigned int stsmart_handle; //device handle for stsmart driver
|
---|
769 | #endif
|
---|
770 | char pcsc_name[128];
|
---|
771 | int pcsc_has_card;
|
---|
772 | int detect;
|
---|
773 | int mhz; //actual clock rate of reader in 10khz steps
|
---|
774 | int cardmhz; //standard clock speed your card should have in 10khz steps; normally 357 but for Irdeto cards 600
|
---|
775 | int r_port;
|
---|
776 | char r_usr[64];
|
---|
777 | char r_pwd[64];
|
---|
778 | char l_pwd[64];
|
---|
779 | int r_crypted;
|
---|
780 | int l_port;
|
---|
781 | int log_port;
|
---|
782 | CAIDTAB ctab;
|
---|
783 | ulong boxid;
|
---|
784 | int nagra_read; // read nagra ncmed records: 0 disabled (default), 1 read all records, 2 read valid records only
|
---|
785 | uchar nagra_boxkey[16]; //n3 boxkey 8byte or tiger idea key 16byte
|
---|
786 | char country_code[3]; // irdeto country code.
|
---|
787 | int force_irdeto;
|
---|
788 | uchar rsa_mod[120]; //rsa modulus for nagra cards.
|
---|
789 | uchar atr[64];
|
---|
790 | int atrlen;
|
---|
791 | SIDTABBITS sidtabok; // positiv services
|
---|
792 | SIDTABBITS sidtabno; // negative services
|
---|
793 | uchar hexserial[8];
|
---|
794 | int nprov;
|
---|
795 | uchar prid[CS_MAXPROV][8];
|
---|
796 | uchar availkeys[CS_MAXPROV][16]; // viaccess; misused in seca, if availkeys[PROV][0]=0 then expired, 1 then valid.
|
---|
797 | uchar sa[CS_MAXPROV][4]; // viaccess & seca
|
---|
798 | ushort acs; // irdeto
|
---|
799 | ushort caid;
|
---|
800 | uchar b_nano[256];
|
---|
801 | int blockemm_unknown; //block EMMs that have unknown type
|
---|
802 | int blockemm_u; //blcok Unique EMMs
|
---|
803 | int blockemm_s; //block Shared EMMS
|
---|
804 | int blockemm_g; //block Global EMMs
|
---|
805 | char * emmfile;
|
---|
806 | char pincode[5];
|
---|
807 | int ucpk_valid;
|
---|
808 | int logemm;
|
---|
809 | int cachemm;
|
---|
810 | int rewritemm;
|
---|
811 | int card_status;
|
---|
812 | int deprecated; //if 0 ATR obeyed, if 1 default speed (9600) is chosen; for devices that cannot switch baudrate
|
---|
813 | struct s_module ph;
|
---|
814 | struct s_cardreader crdr;
|
---|
815 | struct s_cardsystem csystem;
|
---|
816 | uchar ncd_key[16];
|
---|
817 | uchar ncd_skey[16];
|
---|
818 | int ncd_disable_server_filt;
|
---|
819 | ushort ncd_msgid;
|
---|
820 | int ncd_proto;
|
---|
821 | char cc_version[7]; // cccam version
|
---|
822 | char cc_build[7]; // cccam build number
|
---|
823 | int cc_maxhop; // cccam max distance
|
---|
824 | int cc_mindown; // cccam min downhops
|
---|
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 | CAIDVALUETAB lb_retrylimittab;
|
---|
1150 | CAIDVALUETAB lb_nbest_readers_tab; //like nbest_readers, but for special caids
|
---|
1151 | char *lb_savepath; //path where the stat file is save. Empty=default=/tmp/.oscam/stat
|
---|
1152 | int lb_stat_cleanup; //duration in hours for cleaning old statistics
|
---|
1153 | int lb_use_locking; //use a mutex lock while searching for readers (get_cw())
|
---|
1154 | int resolve_gethostbyname;
|
---|
1155 |
|
---|
1156 | #ifdef CS_WITH_DOUBLECHECK
|
---|
1157 | int double_check; //schlocke: Double checks each ecm+dcw from two (or more) readers
|
---|
1158 | #endif
|
---|
1159 |
|
---|
1160 | #ifdef IRDETO_GUESSING
|
---|
1161 | struct s_irdeto_quess *itab[0xff];
|
---|
1162 | #endif
|
---|
1163 |
|
---|
1164 | #ifdef HAVE_DVBAPI
|
---|
1165 | int dvbapi_enabled;
|
---|
1166 | int dvbapi_au;
|
---|
1167 | char dvbapi_usr[64];
|
---|
1168 | int dvbapi_boxtype;
|
---|
1169 | int dvbapi_pmtmode;
|
---|
1170 | int dvbapi_requestmode;
|
---|
1171 | SIDTABBITS dvbapi_sidtabok; // positiv services
|
---|
1172 | SIDTABBITS dvbapi_sidtabno; // negative services
|
---|
1173 | #endif
|
---|
1174 |
|
---|
1175 | #ifdef CS_ANTICASC
|
---|
1176 | char ac_enabled;
|
---|
1177 | int ac_users; // num of users for account (0 - default)
|
---|
1178 | int ac_stime; // time to collect AC statistics (3 min - default)
|
---|
1179 | int ac_samples; // qty of samples
|
---|
1180 | int ac_penalty; // 0 - write to log
|
---|
1181 | int ac_fakedelay; // 100-1000 ms
|
---|
1182 | int ac_denysamples;
|
---|
1183 | char ac_logfile[128];
|
---|
1184 | struct s_cpmap *cpmap;
|
---|
1185 | #endif
|
---|
1186 |
|
---|
1187 | #ifdef QBOXHD_LED
|
---|
1188 | int disableqboxhdled; // disable qboxhd led , default = 0
|
---|
1189 | #endif
|
---|
1190 | };
|
---|
1191 |
|
---|
1192 | //Loadbalance constants:
|
---|
1193 | #define LB_NONE 0
|
---|
1194 | #define LB_FASTEST_READER_FIRST 1
|
---|
1195 | #define LB_OLDEST_READER_FIRST 2
|
---|
1196 | #define LB_LOWEST_USAGELEVEL 3
|
---|
1197 | #define LB_LOG_ONLY 10
|
---|
1198 |
|
---|
1199 | #define LB_MAX_STAT_TIME 20
|
---|
1200 |
|
---|
1201 | typedef struct reader_stat_t
|
---|
1202 | {
|
---|
1203 | int rc;
|
---|
1204 | ushort caid;
|
---|
1205 | ulong prid;
|
---|
1206 | ushort srvid;
|
---|
1207 |
|
---|
1208 | time_t last_received;
|
---|
1209 |
|
---|
1210 | int ecm_count;
|
---|
1211 | int time_avg;
|
---|
1212 | int time_stat[LB_MAX_STAT_TIME];
|
---|
1213 | int time_idx;
|
---|
1214 |
|
---|
1215 | int request_count;
|
---|
1216 | int fail_factor;
|
---|
1217 | } READER_STAT;
|
---|
1218 |
|
---|
1219 | typedef struct emm_packet_t
|
---|
1220 | {
|
---|
1221 | uchar emm[258];
|
---|
1222 | uchar l;
|
---|
1223 | uchar caid[2];
|
---|
1224 | uchar provid[4];
|
---|
1225 | uchar hexserial[8]; //contains hexserial or SA of EMM
|
---|
1226 | uchar type;
|
---|
1227 | struct s_client *client;
|
---|
1228 | } EMM_PACKET;
|
---|
1229 |
|
---|
1230 | //EMM types:
|
---|
1231 | #define UNKNOWN 0
|
---|
1232 | #define UNIQUE 1
|
---|
1233 | #define SHARED 2
|
---|
1234 | #define GLOBAL 3
|
---|
1235 |
|
---|
1236 | // oscam-simples
|
---|
1237 | extern char *remote_txt(void);
|
---|
1238 | extern char *trim(char *);
|
---|
1239 | extern char *strtolower(char *);
|
---|
1240 | extern int gethexval(char);
|
---|
1241 | extern int cs_atob(uchar *, char *, int);
|
---|
1242 | extern ulong cs_atoi(char *, int, int);
|
---|
1243 | extern int byte_atob(char *);
|
---|
1244 | extern long word_atob(char *);
|
---|
1245 | extern long dyn_word_atob(char *asc);
|
---|
1246 | extern int key_atob_l(char *, uchar *, int);
|
---|
1247 | extern char *key_btoa(char *, uchar *);
|
---|
1248 | extern char *cs_hexdump(int, const uchar *, int);
|
---|
1249 | extern in_addr_t cs_inet_order(in_addr_t);
|
---|
1250 | extern char *cs_inet_ntoa(in_addr_t);
|
---|
1251 | extern in_addr_t cs_inet_addr(char *txt);
|
---|
1252 | extern ulong b2i(int, uchar *);
|
---|
1253 | extern ullong b2ll(int, uchar *);
|
---|
1254 | extern uchar *i2b(int, ulong);
|
---|
1255 | extern ulong a2i(char *, int);
|
---|
1256 | extern int boundary(int, int);
|
---|
1257 | extern void cs_ftime(struct timeb *);
|
---|
1258 | extern void cs_sleepms(unsigned int);
|
---|
1259 | extern void cs_sleepus(unsigned int);
|
---|
1260 | extern int bytes_available(int);
|
---|
1261 | extern void cs_setpriority(int);
|
---|
1262 | extern struct s_auth *find_user(char *);
|
---|
1263 | extern int check_filled(uchar *value, int length);
|
---|
1264 | extern void *cs_malloc(void *result, size_t size, int quiterror);
|
---|
1265 | extern void *cs_realloc(void *result, size_t size, int quiterror);
|
---|
1266 | #ifdef WEBIF
|
---|
1267 | extern char to_hex(char code);
|
---|
1268 | extern void char_to_hex(const unsigned char* p_array, unsigned int p_array_len, unsigned char *result);
|
---|
1269 | extern void create_rand_str(char *dst, int size);
|
---|
1270 | #endif
|
---|
1271 | extern void uint64ToBitchar(uint64 value, int size, char *result);
|
---|
1272 | extern int file_exists(const char * filename);
|
---|
1273 | extern void clear_sip(struct s_ip **sip);
|
---|
1274 | extern void clear_ptab(struct s_ptab *ptab);
|
---|
1275 | extern void clear_ftab(struct s_ftab *ftab);
|
---|
1276 | void clear_caidtab(struct s_caidtab *ctab);
|
---|
1277 | void clear_tuntab(struct s_tuntab *ttab);
|
---|
1278 | extern int safe_overwrite_with_bak(char *destfile, char *tmpfile, char *bakfile, int forceBakOverWrite);
|
---|
1279 | extern void fprintf_conf(FILE *f, int varnameWidth, const char *varname, const char *fmtstring, ...);
|
---|
1280 | extern void cs_strncpy(char * destination, const char * source, size_t num);
|
---|
1281 | extern char *get_servicename(int srvid, int caid);
|
---|
1282 | extern char *get_tiername(int tierid, int caid);
|
---|
1283 | extern char *get_provider(int caid, ulong provid);
|
---|
1284 | extern void make_non_blocking(int fd);
|
---|
1285 | extern uchar fast_rnd(void);
|
---|
1286 | extern void init_rnd(void);
|
---|
1287 | extern int hexserialset(struct s_reader *rdr);
|
---|
1288 | extern char *monitor_get_proto(struct s_client *);
|
---|
1289 | extern char *reader_get_type_desc(struct s_reader * rdr, int extended);
|
---|
1290 | extern char *get_ncd_client_name(char *client_id);
|
---|
1291 | extern char *strnew(char *str);
|
---|
1292 | extern void hexserial_to_newcamd(uchar *source, uchar *dest, ushort caid);
|
---|
1293 | extern void newcamd_to_hexserial(uchar *source, uchar *dest, ushort caid);
|
---|
1294 | extern int check_ip(struct s_ip *ip, in_addr_t n);
|
---|
1295 |
|
---|
1296 | extern pthread_key_t getclient;
|
---|
1297 | extern struct s_client * cur_client(void);
|
---|
1298 | extern struct s_client *first_client;
|
---|
1299 | extern struct s_reader *first_active_reader; //points to list of _active_ readers (enable = 1, deleted = 0)
|
---|
1300 | extern LLIST *configured_readers;
|
---|
1301 |
|
---|
1302 | // oscam variables
|
---|
1303 |
|
---|
1304 | extern int cs_dblevel, loghistidx;
|
---|
1305 |
|
---|
1306 | extern ushort len4caid[256];
|
---|
1307 |
|
---|
1308 | extern struct card_struct *Cards;
|
---|
1309 | //extern struct idstore_struct *idstore;
|
---|
1310 | extern unsigned long *IgnoreList;
|
---|
1311 |
|
---|
1312 | extern struct s_config cfg;
|
---|
1313 | extern char cs_confdir[];
|
---|
1314 | extern char loghist[CS_MAXLOGHIST*CS_LOGHISTSIZE];
|
---|
1315 | extern struct s_module ph[CS_MAX_MOD];
|
---|
1316 | extern struct s_cardsystem cardsystem[CS_MAX_MOD];
|
---|
1317 | extern struct s_cardreader cardreader[CS_MAX_MOD];
|
---|
1318 | //extern ECM_REQUEST *ecmtask;
|
---|
1319 |
|
---|
1320 | #ifdef CS_ANTICASC
|
---|
1321 | extern FILE *fpa;
|
---|
1322 | #endif
|
---|
1323 | extern pthread_mutex_t gethostbyname_lock;
|
---|
1324 |
|
---|
1325 | // oscam
|
---|
1326 | #ifdef WEBIF
|
---|
1327 | extern void cs_exit_oscam();
|
---|
1328 | extern void cs_restart_oscam();
|
---|
1329 | extern int cs_get_restartmode();
|
---|
1330 | extern void start_thread(void * startroutine, char * nameroutine);
|
---|
1331 |
|
---|
1332 | //reset stats for webif:
|
---|
1333 | extern void clear_account_stats(struct s_auth *account);
|
---|
1334 | extern void clear_all_account_stats();
|
---|
1335 | extern void clear_system_stats();
|
---|
1336 |
|
---|
1337 | #endif
|
---|
1338 | extern void cs_reload_config();
|
---|
1339 | extern int recv_from_udpipe(uchar *);
|
---|
1340 | extern char* username(struct s_client *);
|
---|
1341 | extern struct s_client * get_client_by_tid(unsigned long);
|
---|
1342 | extern int chk_bcaid(ECM_REQUEST *, CAIDTAB *);
|
---|
1343 | extern void cs_exit(int sig);
|
---|
1344 | extern int comp_timeb(struct timeb *tpa, struct timeb *tpb);
|
---|
1345 | extern struct s_client * create_client(in_addr_t);
|
---|
1346 | extern int cs_auth_client(struct s_client *, struct s_auth *, const char*);
|
---|
1347 | extern void cs_disconnect_client(struct s_client *);
|
---|
1348 | extern int check_cwcache2(ECM_REQUEST *, uint64 grp);
|
---|
1349 | extern int write_to_pipe(int, int, uchar *, int);
|
---|
1350 | extern int read_from_pipe(int, uchar **, int);
|
---|
1351 | extern int write_ecm_answer(struct s_reader *, ECM_REQUEST *);
|
---|
1352 | extern void log_emm_request(struct s_reader *);
|
---|
1353 | extern ulong chk_provid(uchar *, ushort);
|
---|
1354 | #ifdef IRDETO_GUESSING
|
---|
1355 | extern void guess_irdeto(ECM_REQUEST *);
|
---|
1356 | #endif
|
---|
1357 | extern void get_cw(struct s_client *, ECM_REQUEST *);
|
---|
1358 | extern void do_emm(struct s_client *, EMM_PACKET *);
|
---|
1359 | extern ECM_REQUEST *get_ecmtask(void);
|
---|
1360 | extern void request_cw(ECM_REQUEST *, int, int);
|
---|
1361 | extern int send_dcw(struct s_client *, ECM_REQUEST *);
|
---|
1362 | extern int process_input(uchar *, int, int);
|
---|
1363 | extern int has_srvid(struct s_client *cl, ECM_REQUEST *er);
|
---|
1364 | extern int chk_srvid(struct s_client *, ECM_REQUEST *);
|
---|
1365 | extern int chk_srvid_match(ECM_REQUEST *, SIDTAB *);
|
---|
1366 | extern int chk_sfilter(ECM_REQUEST *, PTAB*);
|
---|
1367 | extern int chk_ufilters(ECM_REQUEST *);
|
---|
1368 | extern int chk_rsfilter(struct s_reader * reader, ECM_REQUEST *);
|
---|
1369 | extern int matching_reader(ECM_REQUEST *, struct s_reader *);
|
---|
1370 | extern int emm_reader_match(struct s_reader *reader, ushort caid, ulong provid);
|
---|
1371 | extern void set_signal_handler(int , int , void (*));
|
---|
1372 | extern void cs_log_config(void);
|
---|
1373 | extern void cs_waitforcardinit(void);
|
---|
1374 | extern void cs_reinit_clients(struct s_auth *new_accounts);
|
---|
1375 | extern int process_client_pipe(struct s_client *cl, uchar *buf, int l);
|
---|
1376 | extern void update_reader_config(uchar *ptr);
|
---|
1377 | extern int chk_ctab(ushort caid, CAIDTAB *ctab);
|
---|
1378 | extern int chk_srvid_by_caid_prov(struct s_client *, ushort caid, ulong provid);
|
---|
1379 | extern void nullclose(int *fd);
|
---|
1380 | extern void kill_thread(struct s_client *cl);
|
---|
1381 | extern int get_threadnum(struct s_client *client);
|
---|
1382 | extern void cs_add_violation(uint ip);
|
---|
1383 |
|
---|
1384 | extern void cs_card_info(void);
|
---|
1385 | extern void cs_debug_level(void);
|
---|
1386 |
|
---|
1387 | #ifdef CS_ANTICASC
|
---|
1388 | extern void init_ac(void);
|
---|
1389 | extern void ac_init_stat();
|
---|
1390 | extern void ac_clear();
|
---|
1391 | extern void ac_done_stat();
|
---|
1392 | extern int ac_init_log();
|
---|
1393 | extern void ac_do_stat(void);
|
---|
1394 | extern void ac_init_client(struct s_auth *);
|
---|
1395 | extern void ac_chk(ECM_REQUEST*, int);
|
---|
1396 | #endif
|
---|
1397 |
|
---|
1398 | // oscam-config
|
---|
1399 | extern int init_config(void);
|
---|
1400 | extern int init_free_userdb(struct s_auth *auth);
|
---|
1401 | extern struct s_auth *init_userdb();
|
---|
1402 | extern int init_readerdb(void);
|
---|
1403 | extern int init_sidtab(void);
|
---|
1404 | extern void free_sidtab(struct s_sidtab *sidtab);
|
---|
1405 | extern void init_free_sidtab();
|
---|
1406 | extern int init_srvid(void);
|
---|
1407 | extern int init_tierid(void);
|
---|
1408 | extern int search_boxkey(ushort, char *);
|
---|
1409 | extern void init_len4caid(void);
|
---|
1410 | #ifdef IRDETO_GUESSING
|
---|
1411 | extern int init_irdeto_guess_tab(void);
|
---|
1412 | #endif
|
---|
1413 | extern void chk_caidtab(char *caidasc, CAIDTAB *ctab);
|
---|
1414 | extern void chk_tuntab(char *tunasc, TUNTAB *ttab);
|
---|
1415 | extern void chk_services(char *labels, SIDTABBITS *sidok, SIDTABBITS *sidno);
|
---|
1416 | extern void chk_ftab(char *zFilterAsc, FTAB *ftab, const char *zType, const char *zName, const char *zFiltName);
|
---|
1417 | extern void chk_cltab(char *classasc, CLASSTAB *clstab);
|
---|
1418 | extern void chk_iprange(char *value, struct s_ip **base);
|
---|
1419 | extern void chk_port_tab(char *portasc, PTAB *ptab);
|
---|
1420 | #ifdef CS_ANTICASC
|
---|
1421 | extern void chk_t_ac(char *token, char *value);
|
---|
1422 | #endif
|
---|
1423 | extern void chk_t_camd33(char *token, char *value);
|
---|
1424 | extern void chk_t_camd35(char *token, char *value);
|
---|
1425 | extern void chk_t_camd35_tcp(char *token, char *value);
|
---|
1426 | extern void chk_t_newcamd(char *token, char *value);
|
---|
1427 | extern void chk_t_radegast(char *token, char *value);
|
---|
1428 | extern void chk_t_serial(char *token, char *value);
|
---|
1429 | extern void chk_t_gbox(char *token, char *value);
|
---|
1430 | extern void chk_t_cccam(char *token, char *value);
|
---|
1431 | extern void chk_t_global(const char *token, char *value);
|
---|
1432 | extern void chk_t_monitor(char *token, char *value);
|
---|
1433 | extern void chk_reader(char *token, char *value, struct s_reader *rdr);
|
---|
1434 |
|
---|
1435 | #ifdef HAVE_DVBAPI
|
---|
1436 | extern void chk_t_dvbapi(char *token, char *value);
|
---|
1437 | void dvbapi_chk_caidtab(char *caidasc, char type);
|
---|
1438 | void dvbapi_read_priority();
|
---|
1439 | #endif
|
---|
1440 |
|
---|
1441 | #ifdef WEBIF
|
---|
1442 | extern void chk_t_webif(char *token, char *value);
|
---|
1443 | #endif
|
---|
1444 |
|
---|
1445 | extern void cs_accounts_chk(void);
|
---|
1446 | extern void chk_account(const char *token, char *value, struct s_auth *account);
|
---|
1447 | extern void chk_sidtab(char *token, char *value, struct s_sidtab *sidtab);
|
---|
1448 | extern int write_services();
|
---|
1449 | extern int write_userdb(struct s_auth *authptr);
|
---|
1450 | extern int write_config();
|
---|
1451 | extern int write_server();
|
---|
1452 | extern void write_versionfile();
|
---|
1453 | extern char *mk_t_caidtab(CAIDTAB *ctab);
|
---|
1454 | extern char *mk_t_caidvaluetab(CAIDVALUETAB *tab);
|
---|
1455 | extern char *mk_t_tuntab(TUNTAB *ttab);
|
---|
1456 | extern char *mk_t_group(uint64 grp);
|
---|
1457 | extern char *mk_t_ftab(FTAB *ftab);
|
---|
1458 | extern char *mk_t_camd35tcp_port();
|
---|
1459 | extern char *mk_t_aeskeys(struct s_reader *rdr);
|
---|
1460 | extern char *mk_t_newcamd_port();
|
---|
1461 | extern char *mk_t_aureader(struct s_auth *account);
|
---|
1462 | extern char *mk_t_nano(struct s_reader *rdr, uchar flag);
|
---|
1463 | extern char *mk_t_service( uint64 sidtabok, uint64 sidtabno);
|
---|
1464 | extern char *mk_t_logfile();
|
---|
1465 |
|
---|
1466 | //Todo #ifdef CCCAM
|
---|
1467 | extern int init_provid();
|
---|
1468 | extern char * get_tmp_dir();
|
---|
1469 | extern void init_share();
|
---|
1470 | extern void done_share();
|
---|
1471 |
|
---|
1472 | // oscam-reader
|
---|
1473 | extern int logfd;
|
---|
1474 | extern int reader_cmd2icc(struct s_reader * reader, const uchar *buf, const int l, uchar *response, ushort *response_length);
|
---|
1475 | extern int card_write(struct s_reader * reader, const uchar *, const uchar *, uchar *, ushort *);
|
---|
1476 | extern int check_sct_len(const unsigned char *data, int off);
|
---|
1477 | extern void cs_ri_brk(struct s_reader * reader, int);
|
---|
1478 | extern void cs_ri_log(struct s_reader * reader, char *,...);
|
---|
1479 | extern void * start_cardreader(void *);
|
---|
1480 | extern void reader_card_info(struct s_reader * reader);
|
---|
1481 | extern int hostResolve(struct s_reader * reader);
|
---|
1482 | extern int network_tcp_connection_open();
|
---|
1483 | extern void network_tcp_connection_close(struct s_client *, int);
|
---|
1484 | extern int casc_recv_timer(struct s_reader * reader, uchar *buf, int l, int msec);
|
---|
1485 | extern void clear_reader_pipe(struct s_reader * reader);
|
---|
1486 | extern void block_connect(struct s_reader *rdr);
|
---|
1487 | extern int is_connect_blocked(struct s_reader *rdr);
|
---|
1488 |
|
---|
1489 | // oscam-log
|
---|
1490 | extern int cs_init_log();
|
---|
1491 | extern int cs_open_logfiles();
|
---|
1492 | extern void cs_write_log(char *);
|
---|
1493 | extern void cs_log(const char *,...);
|
---|
1494 | #ifdef WITH_DEBUG
|
---|
1495 | extern void cs_debug_mask(unsigned short, const char *,...);
|
---|
1496 | extern void cs_ddump_mask(unsigned short, const uchar *, int, char *, ...);
|
---|
1497 | #else
|
---|
1498 | #define nop() asm volatile("nop")
|
---|
1499 | #define cs_debug(...) nop()
|
---|
1500 | #define cs_debug_mask(...) nop()
|
---|
1501 | #define cs_ddump(...) nop()
|
---|
1502 | #define cs_ddump_mask(...) nop()
|
---|
1503 | #endif
|
---|
1504 | extern void cs_close_log(void);
|
---|
1505 | extern int cs_init_statistics();
|
---|
1506 | extern void cs_dump(const uchar *, int, char *, ...);
|
---|
1507 |
|
---|
1508 | // oscam-aes
|
---|
1509 | extern void aes_set_key(char *);
|
---|
1510 | extern void add_aes_entry(struct s_reader *rdr, ushort caid, uint32 ident, int keyid, uchar *aesKey);
|
---|
1511 | extern void aes_encrypt_idx(struct s_client *, uchar *, int);
|
---|
1512 | extern void aes_decrypt(uchar *, int);
|
---|
1513 | extern int aes_decrypt_from_list(AES_ENTRY *list, ushort caid, uint32 provid,int keyid, uchar *buf, int n);
|
---|
1514 | extern int aes_present(AES_ENTRY *list, ushort caid, uint32 provid,int keyid);
|
---|
1515 | extern void parse_aes_keys(struct s_reader *rdr,char *value);
|
---|
1516 | extern void aes_clear_entries(struct s_reader *rdr);
|
---|
1517 |
|
---|
1518 | #define aes_encrypt(b, n) aes_encrypt_idx(cur_client(), b, n)
|
---|
1519 |
|
---|
1520 | // reader-common
|
---|
1521 | extern int reader_device_init(struct s_reader * reader);
|
---|
1522 | extern int reader_checkhealth(struct s_reader * reader);
|
---|
1523 | extern void reader_post_process(struct s_reader * reader);
|
---|
1524 | extern int reader_ecm(struct s_reader * reader, ECM_REQUEST *);
|
---|
1525 | extern int reader_emm(struct s_reader * reader, EMM_PACKET *);
|
---|
1526 | int reader_get_emm_type(EMM_PACKET *ep, struct s_reader * reader);
|
---|
1527 | struct s_cardsystem *get_cardsystem_by_caid(ushort caid);
|
---|
1528 | extern void reader_device_close(struct s_reader * reader);
|
---|
1529 |
|
---|
1530 | //module-stat
|
---|
1531 | extern void init_stat();
|
---|
1532 | extern int get_best_reader(ECM_REQUEST *er);
|
---|
1533 | extern void clear_reader_stat(struct s_reader *reader);
|
---|
1534 | extern void add_stat(struct s_reader *rdr, ECM_REQUEST *er, int ecm_time, int rc);
|
---|
1535 | extern void load_stat_from_file();
|
---|
1536 | extern void save_stat_to_file();
|
---|
1537 | extern void clear_all_stat();
|
---|
1538 | extern void housekeeping_stat(int force);
|
---|
1539 |
|
---|
1540 | #ifdef HAVE_PCSC
|
---|
1541 | // reader-pcsc
|
---|
1542 | extern void pcsc_close(struct s_reader *pcsc_reader);
|
---|
1543 | #endif
|
---|
1544 |
|
---|
1545 | void reader_nagra();
|
---|
1546 | void reader_irdeto();
|
---|
1547 | void reader_cryptoworks();
|
---|
1548 | void reader_viaccess();
|
---|
1549 | void reader_conax();
|
---|
1550 | void reader_seca();
|
---|
1551 | void reader_videoguard1();
|
---|
1552 | void reader_videoguard2();
|
---|
1553 | void reader_videoguard12();
|
---|
1554 | void reader_dre();
|
---|
1555 | void reader_tongfang();
|
---|
1556 |
|
---|
1557 | void cardreader_mouse(struct s_cardreader *crdr);
|
---|
1558 | void cardreader_smargo(struct s_cardreader *crdr);
|
---|
1559 | #ifdef WITH_STAPI
|
---|
1560 | void cardreader_stapi(struct s_cardreader *crdr);
|
---|
1561 | #endif
|
---|
1562 |
|
---|
1563 | // protocol modules
|
---|
1564 | extern int monitor_send_idx(struct s_client *, char *);
|
---|
1565 | extern void module_monitor(struct s_module *);
|
---|
1566 | extern void module_camd35(struct s_module *);
|
---|
1567 | extern void module_camd35_tcp(struct s_module *);
|
---|
1568 | extern void module_camd33(struct s_module *);
|
---|
1569 | extern void module_newcamd(struct s_module *);
|
---|
1570 | extern void module_radegast(struct s_module *);
|
---|
1571 | extern void module_oscam_ser(struct s_module *);
|
---|
1572 | extern void module_cccam(struct s_module *);
|
---|
1573 | extern void module_gbox(struct s_module *);
|
---|
1574 | extern void module_constcw(struct s_module *);
|
---|
1575 | extern struct timeval *chk_pending(struct timeb tp_ctimeout);
|
---|
1576 | #ifdef HAVE_DVBAPI
|
---|
1577 | extern void module_dvbapi(struct s_module *);
|
---|
1578 | #endif
|
---|
1579 |
|
---|
1580 | #ifdef WEBIF
|
---|
1581 | // oscam-http
|
---|
1582 | extern void http_srv();
|
---|
1583 | #endif
|
---|
1584 |
|
---|
1585 | // oscam-garbage
|
---|
1586 | extern void add_garbage(void *data);
|
---|
1587 | extern void start_garbage_collector(int);
|
---|
1588 | extern void stop_garbage_collector();
|
---|
1589 |
|
---|
1590 | #endif // CS_GLOBALS
|
---|