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