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