source: trunk/globals.h@ 1584

Last change on this file since 1584 was 1584, checked in by merek, 11 years ago

Merge from UMP r1688

File size: 23.4 KB
Line 
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
20#include <sys/socket.h>
21#include <netinet/in.h>
22#include <arpa/inet.h>
23#include <netdb.h>
24#include <string.h>
25#include <signal.h>
26#include <errno.h>
27
28#include <pthread.h>
29
30#ifndef CS_GLOBALS
31#define CS_GLOBALS
32#define CS_VERSION "0.99.4svn"
33
34#if defined(__GNUC__)
35# define GCC_PACK __attribute__((packed))
36#else
37# define GCC_PACK
38#endif
39
40#define call(arg) \
41 if (arg) { \
42 cs_debug_mask(D_TRACE, "ERROR, function call %s returns error.",#arg); \
43 return ERROR; \
44 }
45
46#include "oscam-config.h"
47#ifndef USE_CMAKE
48# include "oscam-ostype.h"
49#endif
50#include "oscam-types.h"
51#include "cscrypt/cscrypt.h"
52
53#ifdef HAVE_PCSC
54#include <PCSC/pcsclite.h>
55#ifdef OS_MACOSX
56#include <PCSC/wintypes.h>
57#else
58#include <PCSC/reader.h>
59#endif
60#endif
61
62#if defined(LIBUSB)
63#include <libusb-1.0/libusb.h>
64#include "csctapi/smartreader_types.h"
65#endif
66
67#ifndef CS_CONFDIR
68#define CS_CONFDIR "/usr/local/etc"
69#endif
70#ifndef CS_MMAPFILE
71#define CS_MMAPFILE "/tmp/oscam.mem"
72#endif
73#ifndef CS_LOGFILE
74#define CS_LOGFILE "/var/log/oscam.log"
75#endif
76#define CS_QLEN 128 // size of request queue
77#define CS_MAXQLEN 128 // size of request queue for cardreader
78#define CS_MAXCAIDTAB 32 // max. caid-defs/user
79#define CS_MAXTUNTAB 16 // max. betatunnel mappings
80#define CS_MAXPROV 32
81#define CS_MAXPORTS 32 // max server ports
82#define CS_MAXFILTERS 16
83
84#define CS_MAXCARDS 4096
85#define CS_MAXIGNORE 1024
86#define CS_MAXLOCALS 16
87#define CS_ECMSTORESIZE 16 // use MD5()
88#define CS_EMMSTORESIZE 270
89#define CS_CLIENT_TIMEOUT 5000
90#define CS_CLIENT_MAXIDLE 120
91#define CS_BIND_TIMEOUT 120
92#define CS_DELAY 0
93#define CS_RESOLVE_DELAY 30
94#define CS_MAXLOGHIST 30
95#define CS_LOGHISTSIZE 160 // 32+128: username + logline
96
97#ifdef OLD_DEFS
98#ifdef CS_EMBEDDED
99#define CS_MAXPENDING 32
100#define CS_ECMCACHESIZE 32
101#define CS_EMMCACHESIZE 64
102#define CS_MAXPID 32
103#define CS_MAXREADER 8
104#else
105#define CS_MAXPENDING 128
106#define CS_ECMCACHESIZE 128
107#define CS_EMMCACHESIZE 256
108#define CS_MAXPID 128
109#define CS_MAXREADER 64
110#endif
111#endif
112
113#ifdef CS_EMBEDDED
114#define CS_MAXPID 32
115#define CS_MAXREADER (CS_MAXPID>>1)
116#define CS_MAXPENDING CS_MAXPID
117#define CS_ECMCACHESIZE CS_MAXPID
118#define CS_EMMCACHESIZE (CS_MAXPID<<1)
119#else
120#define CS_MAXPID 512
121#define CS_MAXREADER (CS_MAXPID>>2)
122#define CS_MAXPENDING (CS_MAXPID<<1)
123#define CS_ECMCACHESIZE CS_MAXPID
124#define CS_EMMCACHESIZE (CS_MAXPID<<1)
125#define CS_RDR_INIT_HIST
126#endif
127
128#define D_TRACE 1 // Generate very detailed error/trace messages per routine
129#define D_ATR 2 // Debug ATR parsing, dump of ecm, emm, cw
130#define D_READER 4 // Debug Reader/Proxy Process
131#define D_CLIENT 8 // Debug Client Process
132#define D_IFD 16 // Debug IFD+protocol
133#define D_DEVICE 32 // Debug Reader I/O
134#define D_ALL_DUMP 63 // dumps all
135
136#define R_DB2COM1 0x1 // Reader Dbox2 @ com1
137#define R_DB2COM2 0x2 // Reader Dbox2 @ com1
138#define R_MOUSE 0x3 // Reader smartcard mouse
139/////////////////// phoenix readers which need baudrate setting and timings need to be guarded by OSCam: BEFORE R_MOUSE
140#define R_INTERNAL 0x4 // Reader smartcard intern
141/////////////////// internal readers (Dreambox, Coolstream, IPBox) are all R_INTERNAL, they are determined compile-time
142/////////////////// readers that do not reed baudrate setting and timings are guarded by reader itself (large buffer built in): AFTER R_SMART
143#define R_SMART 0x5 // Smartreader+
144#define R_PCSC 0x6 // PCSC
145/////////////////// proxy readers after R_CS378X
146#define R_CAMD35 0x10 // Reader cascading camd 3.5x
147#define R_CAMD33 0x11 // Reader cascading camd 3.3x
148#define R_NEWCAMD 0x12 // Reader cascading newcamd
149#define R_RADEGAST 0x13 // Reader cascading radegast
150#define R_CS378X 0x14 // Reader cascading camd 3.5x TCP
151/////////////////// peer to peer proxy readers after R_CCCAM
152#define R_GBOX 0x20 // Reader cascading gbox
153#define R_CCCAM 0x25 // Reader cascading cccam
154#define R_SERIAL 0x80 // Reader serial
155#define R_IS_NETWORK 0x70
156#define R_IS_CASCADING 0xF0
157
158
159#define CS_MAX_MOD 12
160#define MOD_CONN_TCP 1
161#define MOD_CONN_UDP 2
162#define MOD_CONN_NET 3
163#define MOD_CONN_SERIAL 4
164
165#ifdef CS_CORE
166char *PIP_ID_TXT[] = { "ECM", "EMM", "LOG", "CIN", "HUP", NULL };
167char *RDR_CD_TXT[] = { "cd", "dsr", "cts", "ring", "none",
168#ifdef USE_GPIO
169 "gpio1", "gpio2", "gpio3", "gpio4", "gpio5", "gpio6", "gpio7", //felix: changed so that gpio can be used
170#endif
171 NULL };
172#else
173extern char *PIP_ID_TXT[];
174extern char *RDR_CD_TXT[];
175#endif
176
177#define PIP_ID_ECM 0
178#define PIP_ID_EMM 1
179#define PIP_ID_LOG 2
180#define PIP_ID_CIN 3 // CARD_INFO
181#define PIP_ID_HUP 4
182#define PIP_ID_MAX PIP_ID_HUP
183#define PIP_ID_DCW 5
184
185#define PIP_ID_ERR (-1)
186#define PIP_ID_DIR (-2)
187#define PIP_ID_NUL (-3)
188
189#define cdiff *c_start
190
191#define NCD_AUTO 0
192#define NCD_524 1
193#define NCD_525 2
194
195#define CS_ANTICASC
196
197// moved from reader-common.h
198#define NO_CARD 0
199#define CARD_NEED_INIT 1
200#define CARD_INSERTED 2
201#define CARD_FAILURE 3
202
203enum {E1_GLOBAL=0, E1_USER, E1_READER, E1_SERVER, E1_LSERVER};
204enum {E2_GLOBAL=0, E2_GROUP, E2_CAID, E2_IDENT, E2_CLASS, E2_CHID, E2_QUEUE,
205 E2_EA_LEN, E2_F0_LEN, E2_OFFLINE, E2_SID};
206
207//typedef unsigned char uchar;
208//typedef unsigned long ulong;
209
210typedef unsigned char uint8;
211typedef unsigned short uint16;
212typedef unsigned int uint32;
213typedef unsigned long long uint64;
214
215// constants
216#define CTA_RES_LEN 512
217
218typedef struct s_classtab
219{
220 uchar an;
221 uchar bn;
222 uchar aclass[31];
223 uchar bclass[31];
224} GCC_PACK CLASSTAB;
225
226typedef struct s_caidtab
227{
228 ushort caid[CS_MAXCAIDTAB];
229 ushort mask[CS_MAXCAIDTAB];
230 ushort cmap[CS_MAXCAIDTAB];
231} GCC_PACK CAIDTAB;
232
233typedef struct s_tuntab
234{
235 ushort bt_caidfrom[CS_MAXTUNTAB];
236 ushort bt_caidto[CS_MAXTUNTAB];
237 ushort bt_srvid[CS_MAXTUNTAB];
238} GCC_PACK TUNTAB;
239
240typedef struct s_sidtab
241{
242 char label[33];
243 ushort num_caid;
244 ushort num_provid;
245 ushort num_srvid;
246 ushort *caid;
247 ulong *provid;
248 ushort *srvid;
249 struct s_sidtab *next;
250} GCC_PACK SIDTAB;
251
252
253typedef struct s_filter
254{
255 ushort caid;
256 uchar nprids;
257 ulong prids[CS_MAXPROV];
258} GCC_PACK FILTER;
259
260typedef struct s_ftab
261{
262 int nfilts;
263 FILTER filts[CS_MAXFILTERS];
264} GCC_PACK FTAB;
265
266typedef struct s_port
267{
268 int fd;
269 int s_port;
270 FTAB ftab;
271} GCC_PACK PORT;
272
273typedef struct s_ptab
274{
275 int nports;
276 PORT ports[CS_MAXPORTS];
277} GCC_PACK PTAB;
278
279#if defined(LIBUSB)
280typedef struct {
281 int F;
282 float D;
283 int fs;
284 int N;
285 int T;
286 int inv;
287 int parity;
288 int irdeto;
289 int running;
290 libusb_device *usb_dev;
291 libusb_device_handle *usb_dev_handle;
292 enum smartreader_chip_type type;
293 int in_ep; // 0x01
294 int out_ep; // 0x82
295 int index;
296 /** usb read timeout */
297 int usb_read_timeout;
298 /** usb write timeout */
299 int usb_write_timeout;
300 unsigned int writebuffer_chunksize;
301 unsigned char bitbang_enabled;
302 int baudrate;
303 int interface; // 0 or 1
304 /** maximum packet size. Needed for filtering modem status bytes every n packets. */
305 unsigned int max_packet_size;
306} SR_CONFIG;
307#endif
308
309
310struct s_ecm
311{
312 uchar ecmd5[CS_ECMSTORESIZE];
313 uchar cw[16];
314 ushort caid;
315 ulong prid;
316 ulong grp;
317// int level;
318};
319
320struct s_emm
321{
322 uchar emm[CS_EMMSTORESIZE];
323 uchar type;
324 int count;
325};
326
327struct s_module
328{
329 //int fd;
330 int multi;
331 int type;
332 int watchdog;
333 char desc[16];
334 char *logtxt;
335 //int s_port;
336 in_addr_t s_ip;
337 void (*s_handler)();
338 int (*recv)();
339 void (*send_dcw)();
340 void (*cleanup)();
341 int c_multi;
342 int (*c_recv_chk)();
343 int (*c_init)();
344 int (*c_send_ecm)();
345 int (*c_init_log)();
346 int (*c_recv_log)();
347 int c_port;
348 PTAB *ptab;
349};
350
351struct s_irdeto_quess
352{
353 int b47;
354 ushort caid;
355 ushort sid;
356 struct s_irdeto_quess *next;
357};
358
359struct s_client
360{
361 pid_t pid;
362 in_addr_t ip;
363 in_port_t port;
364 time_t login;
365 time_t last;
366 time_t lastswitch;
367 time_t lastemm;
368 time_t lastecm;
369 time_t expirationdate;
370 int c35_suppresscmd08;
371 int ncd_keepalive;
372 int disabled;
373 ulong grp;
374 int crypted;
375 int dup;
376 int au;
377 int autoau;
378 int monlvl;
379 int dbglvl;
380 CAIDTAB ctab;
381 TUNTAB ttab;
382 ulong sidtabok; // positiv services
383 ulong sidtabno; // negative services
384 int typ;
385 int ctyp;
386 int stat;
387 int ufd;
388 int last_srvid;
389 int last_caid;
390 int tosleep;
391 char usr[32];
392 int udp_fd;
393 int fd_m2c;
394 struct sockaddr_in udp_sa;
395 int log;
396 int logcounter;
397 int cwfound; // count found ECMs per client
398 int cwcache; // count ECMs from cache1/2 per client
399 int cwnot; // count not found ECMs per client
400 int cwtun; // count betatunneled ECMs per client
401 int cwignored; // count ignored ECMs per client
402 int cwtout; // count timeouted ECMs per client
403 uchar ucrc[4]; // needed by monitor and used by camd35
404 ulong pcrc; // pwd crc
405 AES_KEY aeskey; // needed by monitor and used by camd33, camd35
406 ushort ncd_msgid;
407 uchar ncd_skey[16];
408 void *cc;
409 int port_idx; // index in server ptab
410 int ncd_server; // newcamd server?
411#ifdef CS_ANTICASC
412 ushort ac_idx;
413 ushort ac_limit;
414 uchar ac_penalty;
415#endif
416 FTAB fchid;
417 FTAB ftab; // user [caid] and ident filter
418 CLASSTAB cltab;
419};
420
421struct s_reader
422{
423 int cs_idx;
424 int enable;
425 int fd;
426 ulong grp;
427 int fallback;
428 int typ;
429 int card_system;
430 char label[32];
431 char device[128];
432 int handle; //device handle
433 char pcsc_name[128];
434 int pcsc_has_card;
435 int detect;
436 int mhz; //actual clock rate of reader in 10khz steps
437 int cardmhz; //standard clock speed your card should have in 10khz steps; normally 357 but for Irdeto cards 600
438 int r_port;
439 char r_usr[64];
440 char r_pwd[64];
441 int r_crypted;
442 int l_port;
443 int log_port;
444 CAIDTAB ctab;
445 ulong boxid;
446 uchar nagra_boxkey[16]; //n3 boxkey 8byte or tiger idea key 16byte
447 int has_rsa;
448 uchar aes_key[16];
449 uchar rsa_mod[120]; //rsa modulus for nagra cards.
450 ulong sidtabok; // positiv services
451 ulong sidtabno; // negative services
452 uchar hexserial[8];
453 int nprov;
454 uchar prid[CS_MAXPROV][8];
455 uchar availkeys[CS_MAXPROV][16]; // viaccess; misused in seca, if availkeys[PROV][0]=0 then expired, 1 then valid.
456 uchar sa[CS_MAXPROV][4]; // viaccess & seca
457 ushort acs; // irdeto
458 ushort caid[16];
459 uchar b_nano[256];
460 char * emmfile;
461 char pincode[5];
462 int ucpk_valid;
463 int logemm;
464 int cachemm;
465 int rewritemm;
466 int card_status;
467 int deprecated; //if 0 ATR obeyed, if 1 default speed (9600) is chosen; for devices that cannot switch baudrate
468 struct s_module ph;
469 uchar ncd_key[16];
470 uchar ncd_skey[16];
471 int ncd_disable_server_filt;
472 ushort ncd_msgid;
473 int ncd_proto;
474 char cc_version[7]; // cccam version
475 char cc_build[5]; // cccam build number
476 int cc_maxhop; // cccam max distance
477 void *cc; // ptr to cccam internal data struct
478 uchar tcp_connected;
479 int tcp_ito; // inactivity timeout
480 int tcp_rto; // reconnect timeout
481 time_t last_g; // get (if last_s-last_g>tcp_rto - reconnect )
482 time_t last_s; // send
483 uchar show_cls; // number of classes subscription showed on kill -31
484 int maxqlen; // max queue length
485 int qlen; // current queue length
486 FTAB fchid;
487 FTAB ftab;
488 CLASSTAB cltab;
489 uchar gbox_pwd[4];
490 uchar gbox_timecode[7];
491 int gbox_online;
492 uchar gbox_vers;
493 uchar gbox_prem;
494 int gbox_fd;
495 int loadbalanced;
496 struct timeb gbox_lasthello; // incoming time stamp
497#ifdef CS_RDR_INIT_HIST
498 uchar init_history[4096];
499 int init_history_pos;
500#endif
501 int msg_idx;
502#ifdef HAVE_PCSC
503 SCARDCONTEXT hContext;
504 SCARDHANDLE hCard;
505 DWORD dwActiveProtocol;
506#endif
507#if defined(LIBUSB)
508 unsigned char g_read_buffer[4096];
509 unsigned int g_read_buffer_size;
510 pthread_mutex_t g_read_mutex;
511 pthread_mutex_t g_usb_mutex;
512 struct usb_device *smartreader_usb_dev;
513 pthread_t rt;
514 unsigned char modem_status;
515 SR_CONFIG sr_config;
516#endif
517};
518
519#ifdef CS_ANTICASC
520
521struct s_acasc_shm {
522 ushort ac_count : 15;
523 ushort ac_deny : 1;
524};
525
526struct s_acasc {
527 ushort stat[10];
528 uchar idx; // current active index in stat[]
529};
530
531struct s_cpmap
532{
533 ushort caid;
534 ulong provid;
535 ushort sid;
536 ushort chid;
537 ushort dwtime;
538 struct s_cpmap *next;
539};
540#endif
541
542struct s_auth
543{
544 char usr[33];
545 char pwd[33];
546 int uniq;
547 int au;
548 int autoau;
549 int monlvl;
550 ulong grp;
551 int tosleep;
552 CAIDTAB ctab;
553 ulong sidtabok; // positiv services
554 ulong sidtabno; // negative services
555 FTAB fchid;
556 FTAB ftab; // user [caid] and ident filter
557 CLASSTAB cltab;
558 TUNTAB ttab;
559#ifdef CS_ANTICASC
560 int ac_idx;
561 int ac_users; // 0 - unlimited
562 uchar ac_penalty; // 0 - log, >0 - fake dw
563#endif
564 in_addr_t dynip;
565 uchar dyndns[64];
566 time_t expirationdate;
567 int c35_suppresscmd08;
568 int ncd_keepalive;
569 int disabled;
570 struct s_auth *next;
571};
572
573struct s_srvid
574{
575 int srvid;
576 int ncaid;
577 int caid[10];
578 char prov[33];
579 char name[33];
580 char type[33];
581 char desc[33];
582 struct s_srvid *next;
583};
584
585struct s_ip
586{
587 in_addr_t ip[2];
588 struct s_ip *next;
589};
590
591struct s_config
592{
593 int nice;
594 ulong netprio;
595 ulong ctimeout;
596 ulong ftimeout;
597 ulong cmaxidle;
598 int ulparent;
599 ulong delay;
600 int bindwait;
601 int resolvedelay;
602 int tosleep;
603 in_addr_t srvip;
604 char *pidfile;
605 char *usrfile;
606 char *cwlogdir;
607 char *logfile;
608 struct s_auth *account;
609 struct s_srvid *srvid;
610 struct s_sidtab *sidtab;
611 int mon_port;
612 in_addr_t mon_srvip;
613 struct s_ip *mon_allowed;
614 int mon_aulow;
615 int mon_hideclient_to;
616 int mon_level;
617 int c33_port;
618 in_addr_t c33_srvip;
619 uchar c33_key[16];
620 int c33_crypted;
621 int c33_passive;
622 struct s_ip *c33_plain;
623 int c35_port;
624 in_addr_t c35_srvip;
625 int c35_suppresscmd08;
626 PTAB c35_tcp_ptab;
627 in_addr_t c35_tcp_srvip;
628 PTAB ncd_ptab;
629 in_addr_t ncd_srvip;
630 uchar ncd_key[16];
631 int ncd_keepalive;
632 struct s_ip *ncd_allowed;
633 PTAB cc_ptab;
634 int rad_port;
635 in_addr_t rad_srvip;
636 int cc_port;
637 int cc_reshare;
638 in_addr_t cc_srvip;
639 uchar cc_version[7];
640 uchar cc_build[5];
641 struct s_ip *rad_allowed;
642 char rad_usr[32];
643 char ser_device[512];
644 ulong srtimeout; // SerialReaderTimeount in millisec
645 int max_log_size;
646 int waitforcards;
647 int preferlocalcards;
648#ifdef CS_WITH_GBOX
649 uchar gbox_pwd[8];
650 uchar ignorefile[128];
651 uchar cardfile[128];
652 uchar gbxShareOnl[128];
653 int maxdist;
654 int num_locals;
655 unsigned long locals[CS_MAXLOCALS];
656#endif
657 //struct s_irdeto_quess *itab[0xff];
658#ifdef HAVE_DVBAPI
659 int dvbapi_enabled;
660 int dvbapi_au;
661 char dvbapi_usr[33];
662 char dvbapi_boxtype[20];
663 char dvbapi_priority[64];
664 char dvbapi_ignore[64];
665#endif
666#ifdef CS_ANTICASC
667 char ac_enabled;
668 int ac_users; // num of users for account (0 - default)
669 int ac_stime; // time to collect AC statistics (3 min - default)
670 int ac_samples; // qty of samples
671 int ac_penalty; // 0 - write to log
672 int ac_fakedelay; // 100-1000 ms
673 int ac_denysamples;
674 char ac_logfile[128];
675 struct s_cpmap *cpmap;
676#endif
677// struct s_reader reader[];
678};
679
680typedef struct ecm_request_t
681{
682
683 uchar ecm[256];
684 uchar cw[16];
685 uchar ecmd5[CS_ECMSTORESIZE];
686// uchar l;
687 short l;
688 ushort caid;
689 ushort ocaid;
690 ushort srvid;
691 ushort chid;
692 ushort pid;
693 ushort idx;
694 ulong prid;
695 int reader[CS_MAXREADER];
696 int cidx; // client index
697 int cpti; // client pending table index
698 int stage; // processing stage in server module
699 int level; // send-level in client module
700 int rc;
701 uchar rcEx;
702 struct timeb tps; // incoming time stamp
703 uchar locals_done;
704 ushort gbxCWFrom;
705 ushort gbxFrom;
706 ushort gbxTo;
707
708 uchar gbxForward[16];
709 int gbxRidx;
710} GCC_PACK ECM_REQUEST;
711
712typedef struct emm_packet_t
713{
714 uchar emm[258];
715 uchar l;
716 uchar caid[2];
717 uchar provid[4];
718 uchar hexserial[8];
719 uchar type;
720 int cidx;
721} GCC_PACK EMM_PACKET;
722
723// oscam-simples
724extern char *remote_txt(void);
725extern char *trim(char *);
726extern char *strtolower(char *);
727extern int gethexval(char);
728extern int cs_atob(uchar *, char *, int);
729extern ulong cs_atoi(char *, int, int);
730extern int byte_atob(char *);
731extern long word_atob(char *);
732extern int key_atob(char *, uchar *);
733extern int key_atob14(char *, uchar *);
734extern int key_atob_l(char *, uchar *, int);
735extern char *key_btoa(char *, uchar *);
736extern char *cs_hexdump(int, uchar *, int);
737extern in_addr_t cs_inet_order(in_addr_t);
738extern char *cs_inet_ntoa(in_addr_t);
739extern in_addr_t cs_inet_addr(char *txt);
740extern ulong b2i(int, uchar *);
741extern ullong b2ll(int, uchar *);
742extern uchar *i2b(int, ulong);
743extern ulong a2i(char *, int);
744extern int boundary(int, int);
745extern void cs_ftime(struct timeb *);
746extern void cs_sleepms(unsigned int);
747extern int bytes_available(int);
748extern void cs_setpriority(int);
749extern struct s_auth *find_user(char *);
750
751// oscam variables
752extern int pfd, rfd, fd_c2m, fd_m2c, cs_idx, *c_start, cs_ptyp, cs_dblevel, cs_hw;
753extern int *logidx, *loghistidx, *log_fd;
754extern int is_server, *mcl;
755extern uchar mbuf[1024];
756extern ushort len4caid[256];
757extern pid_t master_pid;
758extern struct s_ecm *ecmcache;
759extern struct s_client *client;
760extern struct s_reader *reader;
761
762extern struct card_struct *Cards;
763extern struct idstore_struct *idstore;
764extern unsigned long *IgnoreList;
765
766extern struct s_config *cfg;
767extern char cs_confdir[], *loghist;
768extern EMM_PACKET epg;
769extern struct s_module ph[CS_MAX_MOD];
770extern ECM_REQUEST *ecmtask;
771#ifdef CS_ANTICASC
772extern struct s_acasc_shm *acasc;
773extern FILE *fpa;
774extern int use_ac_log;
775#endif
776
777
778// oscam
779extern char *cs_platform(char *);
780extern int recv_from_udpipe(uchar *);
781extern char* username(int);
782extern int idx_from_pid(pid_t);
783extern int idx_from_username(char *uname);
784extern int chk_bcaid(ECM_REQUEST *, CAIDTAB *);
785extern void cs_exit(int sig);
786extern int cs_fork(in_addr_t, in_port_t);
787extern void wait4master(void);
788extern int cs_auth_client(struct s_auth *, char*);
789extern void cs_disconnect_client(void);
790extern int check_ecmcache(ECM_REQUEST *, ulong);
791extern void store_logentry(char *);
792extern int write_to_pipe(int, int, uchar *, int);
793extern int read_from_pipe(int, uchar **, int);
794extern int write_ecm_request(int, ECM_REQUEST *);
795extern int write_ecm_answer(int, ECM_REQUEST *);
796extern void log_emm_request(int);
797extern ulong chk_provid(uchar *, ushort);
798extern void guess_cardsystem(ECM_REQUEST *);
799extern void guess_irdeto(ECM_REQUEST *);
800extern void get_cw(ECM_REQUEST *);
801extern void do_emm(EMM_PACKET *);
802extern ECM_REQUEST *get_ecmtask(void);
803extern void request_cw(ECM_REQUEST *, int, int);
804extern int send_dcw(ECM_REQUEST *);
805extern int process_input(uchar *, int, int);
806extern int chk_srvid(ECM_REQUEST *, int);
807extern int chk_sfilter(ECM_REQUEST *, PTAB*);
808extern int chk_ufilters(ECM_REQUEST *);
809extern int chk_rfilter(ECM_REQUEST *, struct s_reader *);
810extern int chk_rsfilter(ECM_REQUEST *, int);
811extern int chk_avail_reader(ECM_REQUEST *, struct s_reader *);
812extern int matching_reader(ECM_REQUEST *, struct s_reader *);
813extern void set_signal_handler(int , int , void (*)(int));
814extern void cs_log_config(void);
815extern void cs_resolve(void);
816extern void chk_dcw(int fd);
817
818#ifdef CS_ANTICASC
819//extern void start_anticascader(void);
820extern void init_ac(void);
821extern void ac_init_stat();
822extern int ac_init_log(char*);
823extern void ac_do_stat(void);
824extern void ac_init_client(struct s_auth *);
825extern void ac_chk(ECM_REQUEST*, int);
826#endif
827
828// oscam-nano
829extern int chk_class(ECM_REQUEST *, CLASSTAB*, const char*, const char*);
830
831// oscam-config
832extern int init_config(void);
833extern int init_userdb(void);
834extern int init_readerdb(void);
835extern int init_sidtab(void);
836extern int init_srvid(void);
837extern int search_boxkey(ushort, char *);
838extern void init_len4caid(void);
839extern int init_irdeto_guess_tab(void);
840
841// oscam-reader
842extern int ridx, logfd;
843extern int reader_cmd2icc(uchar *, int);
844extern int card_write(uchar *, uchar *);
845extern void cs_ri_brk(int);
846extern void cs_ri_log(char *,...);
847extern void start_cardreader(void);
848extern void reader_card_info(void);
849extern int network_tcp_connection_open();
850extern void network_tcp_connection_close(int);
851
852// oscam-log
853extern int cs_init_log(char *);
854extern void cs_write_log(char *);
855extern void cs_log(char *,...);
856extern void cs_debug(char *,...);
857extern void cs_debug_nolf(char *,...);
858extern void cs_debug_mask(unsigned short, char *,...);
859extern void cs_ddump(uchar *, int, char *, ...);
860extern void cs_ddump_mask(unsigned short, uchar *, int, char *, ...);
861extern void cs_close_log(void);
862extern int cs_init_statistics(char *);
863extern void cs_statistics(int);
864extern void cs_dump(uchar *, int, char *, ...);
865
866// oscam-aes
867extern void aes_set_key(char *);
868extern void aes_encrypt_idx(int, uchar *, int);
869extern void aes_decrypt(uchar *, int);
870#define aes_encrypt(b, n) aes_encrypt_idx(cs_idx, b, n)
871
872// reader-common
873extern int reader_device_init(char *);
874extern int reader_checkhealth(void);
875extern void reader_post_process(void);
876extern int reader_ecm(ECM_REQUEST *);
877extern int reader_emm(EMM_PACKET *);
878
879#ifdef HAVE_PCSC
880// reader-pcsc
881extern int pcsc_reader_do_api(struct s_reader *pcsc_reader, uchar *buf, uchar *cta_res, ushort *cta_lr,int l);
882extern int pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, ushort *atr_size);
883extern int pcsc_check_card_inserted(struct s_reader *pcsc_reader);
884extern int pcsc_reader_init(struct s_reader *pcsc_reader, char *device);
885#endif
886
887// protocol modules
888extern int monitor_send_idx(int, char *);
889extern void module_monitor(struct s_module *);
890extern void module_camd35(struct s_module *);
891extern void module_camd35_tcp(struct s_module *);
892extern void module_camd33(struct s_module *);
893extern void module_newcamd(struct s_module *);
894extern void module_radegast(struct s_module *);
895extern void module_oscam_ser(struct s_module *);
896extern void module_gbox(struct s_module *);
897extern void module_cccam(struct s_module *);
898#ifdef HAVE_DVBAPI
899extern void module_dvbapi(struct s_module *);
900#endif
901extern struct timeval *chk_pending(struct timeb tp_ctimeout);
902#endif // CS_GLOBALS
Note: See TracBrowser for help on using the repository browser.