source: branches/monitor-improvement/globals.h@ 1176

Last change on this file since 1176 was 1176, checked in by alno, 12 years ago

WebIf:

  • built in function mk_t_ftab to generate the ident token from ftab
  • restructure userconfig / readerconfig to use mk_t_ftab
File size: 24.4 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 nagra_native;
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 http_port;
540 char http_user[65];
541 char http_pwd[65];
542 char http_css[128];
543 char http_tpl[128];
544 int http_refresh;
545 int http_hide_idle_clients;
546 int c33_port;
547 in_addr_t c33_srvip;
548 uchar c33_key[16];
549 int c33_crypted;
550 int c33_passive;
551 struct s_ip *c33_plain;
552 int c35_port;
553 in_addr_t c35_srvip;
554 PTAB c35_tcp_ptab;
555 in_addr_t c35_tcp_srvip;
556 PTAB ncd_ptab;
557 in_addr_t ncd_srvip;
558 uchar ncd_key[16];
559 PTAB cc_ptab;
560 int rad_port;
561 in_addr_t rad_srvip;
562 struct s_ip *rad_allowed;
563 char rad_usr[32];
564 char ser_device[512];
565 ulong srtimeout; // SerialReaderTimeount in millisec
566 int max_log_size;
567 int show_ecm_dw;
568 int waitforcards;
569 int preferlocalcards;
570#ifdef CS_WITH_GBOX
571 uchar gbox_pwd[8];
572 uchar ignorefile[512];
573 uchar cardfile[512];
574 uchar gbxShareOnl[512];
575 int maxdist;
576 int num_locals;
577 unsigned long locals[CS_MAXLOCALS];
578#endif
579 //struct s_irdeto_quess *itab[0xff];
580#ifdef HAVE_DVBAPI
581 int dvbapi_enabled;
582 int dvbapi_au;
583 char dvbapi_usr[64];
584 char dvbapi_boxtype[20];
585#endif
586#ifdef CS_ANTICASC
587 char ac_enabled;
588 int ac_users; // num of users for account (0 - default)
589 int ac_stime; // time to collect AC statistics (3 min - default)
590 int ac_samples; // qty of samples
591 int ac_penalty; // 0 - write to log
592 int ac_fakedelay; // 100-1000 ms
593 int ac_denysamples;
594 char ac_logfile[128];
595 struct s_cpmap *cpmap;
596#endif
597// struct s_reader reader[];
598};
599
600typedef struct ecm_request_t
601{
602
603 uchar ecm[256];
604 uchar cw[16];
605 uchar ecmd5[CS_ECMSTORESIZE];
606// uchar l;
607 short l;
608 ushort caid;
609 ushort ocaid;
610 ushort srvid;
611 ushort chid;
612 ushort pid;
613 ushort idx;
614 ulong prid;
615 int reader[CS_MAXREADER];
616 int cidx; // client index
617 int cpti; // client pending table index
618 int stage; // processing stage in server module
619 int level; // send-level in client module
620 int rc;
621 uchar rcEx;
622 struct timeb tps; // incoming time stamp
623 uchar locals_done;
624 ushort gbxCWFrom;
625 ushort gbxFrom;
626 ushort gbxTo;
627
628 uchar gbxForward[16];
629 int gbxRidx;
630} GCC_PACK ECM_REQUEST;
631
632typedef struct emm_packet_t
633{
634 uchar emm[258];
635 uchar l;
636 uchar caid[2];
637 uchar provid[4];
638 uchar hexserial[8];
639 uchar type;
640 int cidx;
641} GCC_PACK EMM_PACKET;
642
643// oscam-simples
644extern char *remote_txt(void);
645extern char *trim(char *);
646extern char *strtolower(char *);
647extern int gethexval(char);
648extern int cs_atob(uchar *, char *, int);
649extern ulong cs_atoi(char *, int, int);
650extern int byte_atob(char *);
651extern long word_atob(char *);
652extern int key_atob(char *, uchar *);
653extern int key_atob14(char *, uchar *);
654extern int key_atob_l(char *, uchar *, int);
655extern char *key_btoa(char *, uchar *);
656extern char *cs_hexdump(int, uchar *, int);
657extern in_addr_t cs_inet_order(in_addr_t);
658extern char *cs_inet_ntoa(in_addr_t);
659extern in_addr_t cs_inet_addr(char *txt);
660extern ulong b2i(int, uchar *);
661extern ullong b2ll(int, uchar *);
662extern uchar *i2b(int, ulong);
663extern ulong a2i(char *, int);
664extern int boundary(int, int);
665extern void cs_ftime(struct timeb *);
666extern void cs_sleepms(int);
667extern int bytes_available(int);
668extern void cs_setpriority(int);
669extern struct s_auth *find_user(char *);
670extern int x2i(int i);
671extern void urldecode(char *s);
672extern char to_hex(char code);
673extern char *urlencode(char *str);
674extern void long2bitchar(long value, char *result);
675extern char *char_to_hex(const unsigned char* p_array, unsigned int p_array_len, char hex2ascii[256][2]);
676extern void create_rand_str(char *dst, int size);
677extern int file_exists(const char * filename);
678extern void clear_sip(struct s_ip **sip);
679extern void clear_ptab(struct s_ptab *ptab);
680extern int safe_overwrite_with_bak(char *destfile, char *tmpfile, char *bakfile, int forceBakOverWrite);
681extern void fprintf_conf(FILE *f, int varnameWidth, const char *varname, const char *fmtstring, ...);
682
683// oscam variables
684extern int pfd, rfd, fd_c2m, fd_m2c, cs_idx, *c_start, cs_ptyp, cs_dblevel, cs_hw;
685extern int *logidx, *loghistidx, *log_fd;
686extern int is_server, *mcl;
687extern uchar mbuf[1024];
688extern ushort len4caid[256];
689extern pid_t master_pid;
690extern struct s_ecm *ecmcache;
691extern struct s_client *client;
692extern struct s_reader *reader;
693
694extern struct card_struct *Cards;
695extern struct idstore_struct *idstore;
696extern unsigned long *IgnoreList;
697
698extern struct s_config *cfg;
699extern char cs_confdir[], *loghist;
700extern EMM_PACKET epg;
701extern struct s_module ph[CS_MAX_MOD];
702extern ECM_REQUEST *ecmtask;
703extern char logfile[256];
704#ifdef CS_ANTICASC
705extern struct s_acasc_shm *acasc;
706extern FILE *fpa;
707extern int use_ac_log;
708#endif
709
710
711// oscam
712extern char *cs_platform(char *);
713extern int recv_from_udpipe(uchar *);
714extern char* username(int);
715extern int idx_from_pid(pid_t);
716extern int chk_bcaid(ECM_REQUEST *, CAIDTAB *);
717extern void cs_exit(int sig);
718extern int cs_fork(in_addr_t, in_port_t);
719extern void wait4master(void);
720extern int cs_auth_client(struct s_auth *, char*);
721extern void cs_disconnect_client(void);
722extern int check_ecmcache(ECM_REQUEST *, ulong);
723extern void store_logentry(char *);
724extern int write_to_pipe(int, int, uchar *, int);
725extern int read_from_pipe(int, uchar **, int);
726extern int write_ecm_request(int, ECM_REQUEST *);
727extern int write_ecm_answer(int, ECM_REQUEST *);
728extern void log_emm_request(int);
729extern ulong chk_provid(uchar *, ushort);
730extern void guess_cardsystem(ECM_REQUEST *);
731extern void guess_irdeto(ECM_REQUEST *);
732extern void get_cw(ECM_REQUEST *);
733extern void do_emm(EMM_PACKET *);
734extern ECM_REQUEST *get_ecmtask(void);
735extern void request_cw(ECM_REQUEST *, int, int);
736extern int send_dcw(ECM_REQUEST *);
737extern int process_input(uchar *, int, int);
738extern int chk_srvid(ECM_REQUEST *, int);
739extern int chk_sfilter(ECM_REQUEST *, PTAB*);
740extern int chk_ufilters(ECM_REQUEST *);
741extern int chk_rfilter(ECM_REQUEST *, struct s_reader *);
742extern int chk_rsfilter(ECM_REQUEST *, int);
743extern int chk_avail_reader(ECM_REQUEST *, struct s_reader *);
744extern int matching_reader(ECM_REQUEST *, struct s_reader *);
745extern void set_signal_handler(int , int , void (*)(int));
746extern void cs_log_config(void);
747extern void cs_reinit_clients(void);
748extern void cs_resolve(void);
749extern void chk_dcw(int fd);
750
751#ifdef CS_ANTICASC
752//extern void start_anticascader(void);
753extern void init_ac(void);
754extern void ac_init_stat();
755extern int ac_init_log(char*);
756extern void ac_do_stat(void);
757extern void ac_init_client(struct s_auth *);
758extern void ac_chk(ECM_REQUEST*, int);
759#endif
760
761// oscam-nano
762extern int chk_class(ECM_REQUEST *, CLASSTAB*, const char*, const char*);
763
764// oscam-config
765extern int init_config(void);
766extern int init_userdb(void);
767extern int init_readerdb(void);
768extern int init_sidtab(void);
769extern int init_srvid(void);
770extern int search_boxkey(ushort, char *);
771extern void init_len4caid(void);
772extern int init_irdeto_guess_tab(void);
773extern void chk_caidtab(char *caidasc, CAIDTAB *ctab);
774extern void chk_tuntab(char *tunasc, TUNTAB *ttab);
775extern void chk_services(char *labels, ulong *sidok, ulong *sidno);
776extern void chk_ftab(char *zFilterAsc, FTAB *ftab, const char *zType, const char *zName, const char *zFiltName);
777extern void chk_cltab(char *classasc, CLASSTAB *clstab);
778extern void chk_iprange(char *value, struct s_ip **base);
779extern void chk_port_tab(char *portasc, PTAB *ptab);
780#ifdef CS_ANTICASC
781extern void chk_t_ac(char *token, char *value);
782#endif
783extern void chk_t_camd33(char *token, char *value);
784extern void chk_t_camd35(char *token, char *value);
785extern void chk_t_camd35_tcp(char *token, char *value);
786extern void chk_t_newcamd(char *token, char *value);
787extern void chk_t_radegast(char *token, char *value);
788extern void chk_t_serial(char *token, char *value);
789extern void chk_t_gbox(char *token, char *value);
790extern void chk_t_cccam(char *token, char *value);
791extern void chk_t_global(char *token, char *value);
792extern void chk_t_monitor(char *token, char *value);
793extern void chk_t_dvbapi(char *token, char *value);
794extern void chk_account(char *token, char *value, struct s_auth *account);
795extern void chk_sidtab(char *token, char *value, struct s_sidtab *sidtab);
796extern int write_services();
797extern int write_userdb();
798extern int write_config();
799extern char *mk_t_caidtab(CAIDTAB *ctab);
800extern char *mk_t_tuntab(TUNTAB *ttab);
801extern char *mk_t_group(ulong *grp);
802extern char *mk_t_ftab(FTAB *ftab);
803
804// oscam-reader
805extern int ridx, logfd;
806extern int reader_cmd2api(uchar *, int);
807extern int reader_cmd2icc(uchar *, int);
808extern int card_write(uchar *, uchar *);
809extern void cs_ri_brk(int);
810extern void cs_ri_log(char *,...);
811extern void start_cardreader(void);
812extern void reader_card_info(void);
813extern int network_tcp_connection_open();
814extern void network_tcp_connection_close(int);
815
816// oscam-log
817extern int cs_init_log(char *);
818extern void cs_write_log(char *);
819extern void cs_log(char *,...);
820extern void cs_debug(char *,...);
821extern void cs_ddump(uchar *, int, char *, ...);
822extern void cs_close_log(void);
823extern int cs_init_statistics(char *);
824extern void cs_statistics(int);
825extern void cs_dump(uchar *, int, char *, ...);
826
827// oscam-aes
828extern void aes_set_key(char *);
829extern void aes_encrypt_idx(int, uchar *, int);
830extern void aes_decrypt(uchar *, int);
831#define aes_encrypt(b, n) aes_encrypt_idx(cs_idx, b, n)
832
833// reader-common
834extern int reader_device_init(char *);
835extern int reader_checkhealth(void);
836extern void reader_post_process(void);
837extern int reader_ecm(ECM_REQUEST *);
838extern int reader_emm(EMM_PACKET *);
839
840#ifdef HAVE_PCSC
841// reader-pcsc
842extern int pcsc_reader_do_api(struct s_reader *pcsc_reader, uchar *buf, uchar *cta_res, ushort *cta_lr,int l);
843extern int pcsc_activate_card(struct s_reader *pcsc_reader, uchar *atr, ushort *atr_size);
844extern int pcsc_check_card_inserted(struct s_reader *pcsc_reader);
845extern int pcsc_reader_init(struct s_reader *pcsc_reader, char *device);
846#endif
847
848// reader-irdeto
849extern int irdeto_card_init(uchar *);
850extern int irdeto_do_ecm(ECM_REQUEST *);
851extern int irdeto_do_emm(EMM_PACKET *);
852extern int irdeto_card_info(void);
853
854// reader-viaccess
855extern int viaccess_card_init(uchar *);
856extern int viaccess_do_ecm(ECM_REQUEST *);
857extern int viaccess_do_emm(EMM_PACKET *);
858extern int viaccess_card_info(void);
859
860// reader-videoguard
861extern int videoguard_card_init(uchar *, int);
862extern int videoguard_do_ecm(ECM_REQUEST *);
863extern int videoguard_do_emm(EMM_PACKET *);
864extern int videoguard_card_info(void);
865
866// reader-cryptoworks
867extern int cryptoworks_card_init(uchar *);
868extern int cryptoworks_do_ecm(ECM_REQUEST *);
869extern int cryptoworks_do_emm(EMM_PACKET *);
870extern int cryptoworks_card_info(void);
871extern int CheckSctLen(const uchar *, int);
872
873// reader-seca
874extern int seca_card_init(uchar *);
875extern int seca_do_ecm(ECM_REQUEST *);
876extern int seca_do_emm(EMM_PACKET *);
877extern int seca_card_info(void);
878
879// reader-nds
880extern int nds_card_init(uchar *, int);
881extern int nds_do_ecm(ECM_REQUEST *);
882extern int nds_do_emm(EMM_PACKET *);
883extern int nds_card_info(void);
884
885// reader nagra2/3
886extern int nagra2_card_init(uchar *);
887extern int nagra2_do_ecm(ECM_REQUEST *er);
888extern int nagra2_card_info(void);
889extern int nagra2_do_emm(EMM_PACKET *);
890extern void nagra2_post_process();
891
892// reader-conax
893extern int conax_card_init(uchar *);
894extern int conax_do_ecm(ECM_REQUEST *);
895extern int conax_do_emm(EMM_PACKET *);
896extern int conax_card_info(void);
897
898// reader-dre
899extern int dre_card_init(uchar *);
900extern int dre_do_ecm(ECM_REQUEST *);
901extern int dre_do_emm(EMM_PACKET *);
902extern int dre_card_info(void);
903
904// protocol modules
905extern int monitor_send_idx(int, char *);
906extern void module_monitor(struct s_module *);
907extern void module_camd35(struct s_module *);
908extern void module_camd35_tcp(struct s_module *);
909extern void module_camd33(struct s_module *);
910extern void module_newcamd(struct s_module *);
911extern void module_radegast(struct s_module *);
912extern void module_oscam_ser(struct s_module *);
913extern void module_gbox(struct s_module *);
914extern void module_cccam(struct s_module *);
915#ifdef HAVE_DVBAPI
916extern void module_dvbapi(struct s_module *);
917#endif
918extern struct timeval *chk_pending(struct timeb tp_ctimeout);
919
920// module-monitor
921extern char *monitor_get_proto(int idx);
922extern char *monitor_get_srvname(int id);
923extern int cs_idx2ridx(int idx);
924
925// oscam-http
926extern void http_srv();
927
928#endif // CS_GLOBALS
929
Note: See TracBrowser for help on using the repository browser.