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

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

WebIf:

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