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