source: branches/smartreader/globals.h@ 1277

Last change on this file since 1277 was 1277, checked in by rorothetroll, 11 years ago

resync with trunk

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