source: trunk/globals.h@ 1683

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

Remove uneeded code from last commit

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