source: trunk/globals.h@ 1196

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