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

Last change on this file since 1648 was 1648, checked in by alno, 11 years ago

WebIf:

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