1 | /*
|
---|
2 | * module-cccam.h
|
---|
3 | *
|
---|
4 | * Created on: 23.04.2010
|
---|
5 | * Author: alno
|
---|
6 | */
|
---|
7 | #include "module-obj-llist.h"
|
---|
8 |
|
---|
9 | #ifndef MODULECCCAM_H_
|
---|
10 | #define MODULECCCAM_H_
|
---|
11 |
|
---|
12 | #define CC_MAXMSGSIZE 512
|
---|
13 | #define CC_MAX_PROV 16
|
---|
14 | #define CC_CAIDINFO_REBUILD 200 //SS: Rebuid Caidinfos after 200 Card-Updates
|
---|
15 | #define SWAPC(X, Y) do { char p; p = *X; *X = *Y; *Y = p; } while(0)
|
---|
16 |
|
---|
17 | #if (defined(WIN32) || defined(OS_CYGWIN32)) && !defined(MSG_WAITALL)
|
---|
18 | # define MSG_WAITALL 0
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | typedef enum {
|
---|
22 | DECRYPT, ENCRYPT
|
---|
23 | } cc_crypt_mode_t;
|
---|
24 |
|
---|
25 | typedef enum {
|
---|
26 | MSG_CLI_DATA = 0,
|
---|
27 | MSG_CW_ECM = 1,
|
---|
28 | MSG_EMM_ACK = 2,
|
---|
29 | MSG_CARD_REMOVED = 4,
|
---|
30 | MSG_BAD_ECM = 5,
|
---|
31 | MSG_KEEPALIVE = 6,
|
---|
32 | MSG_NEW_CARD = 7,
|
---|
33 | MSG_SRV_DATA = 8,
|
---|
34 | MSG_CMD_0A = 0x0a,
|
---|
35 | MSG_CMD_0B = 0x0b,
|
---|
36 | MSG_CW_NOK1 = 0xfe,
|
---|
37 | MSG_CW_NOK2 = 0xff,
|
---|
38 | MSG_NO_HEADER = 0xffff
|
---|
39 | } cc_msg_type_t;
|
---|
40 |
|
---|
41 | struct cc_crypt_block {
|
---|
42 | uint8 keytable[256];
|
---|
43 | uint8 state;
|
---|
44 | uint8 counter;
|
---|
45 | uint8 sum;
|
---|
46 | };
|
---|
47 |
|
---|
48 | struct cc_card {
|
---|
49 | uint32 id; // cccam card (share) id
|
---|
50 | uint32 sub_id; // subshare id
|
---|
51 | uint16 caid;
|
---|
52 | uint8 hop;
|
---|
53 | uint8 key[8]; // card serial (for au)
|
---|
54 | LLIST *provs; // providers
|
---|
55 | LLIST *badsids; // sids that have failed to decode
|
---|
56 | time_t time;
|
---|
57 | };
|
---|
58 |
|
---|
59 | struct cc_reported_carddata {
|
---|
60 | uint8 *buf;
|
---|
61 | int len;
|
---|
62 | };
|
---|
63 |
|
---|
64 | struct cc_caid_info {
|
---|
65 | uint16 caid;
|
---|
66 | LLIST *provs;
|
---|
67 | uint8 hop;
|
---|
68 | };
|
---|
69 |
|
---|
70 | struct cc_auto_blocked {
|
---|
71 | uint16 caid;
|
---|
72 | uint32 prov;
|
---|
73 | uint16 sid;
|
---|
74 | time_t time;
|
---|
75 | };
|
---|
76 |
|
---|
77 | struct cc_current_card {
|
---|
78 | struct cc_card *card;
|
---|
79 | uint32 prov;
|
---|
80 | uint16 sid;
|
---|
81 | };
|
---|
82 |
|
---|
83 | struct cc_data {
|
---|
84 | struct cc_crypt_block block[2]; // crypto state blocks
|
---|
85 |
|
---|
86 | uint8 node_id[8], // client node id
|
---|
87 | peer_node_id[8], // server node id
|
---|
88 | peer_version[8], // server version
|
---|
89 | dcw[16]; // control words
|
---|
90 | uint8 cmd0b_aeskey[16];
|
---|
91 |
|
---|
92 | LLIST *cards; // cards list
|
---|
93 |
|
---|
94 | LLIST *caid_infos; //struct cc_caid_info
|
---|
95 | long caid_size;
|
---|
96 | uint16 needs_rebuild_caidinfo;
|
---|
97 | int limit_ecms;
|
---|
98 | int max_ecms;
|
---|
99 | int ecm_counter;
|
---|
100 | int report_carddata_id; //Server only
|
---|
101 | LLIST *reported_carddatas; //struct cc_reported_carddata //struct cc_reported_carddata
|
---|
102 | LLIST *auto_blocked; //struct cc_auto_blocked //struct cc_auto_blocked
|
---|
103 | int just_logged_in; //true for checking NOK direct after login
|
---|
104 | uint8 key_table; //key for CMD 0B
|
---|
105 |
|
---|
106 | uint32 send_ecmtask;
|
---|
107 | uint32 recv_ecmtask;
|
---|
108 | int proxy_init_errors;
|
---|
109 |
|
---|
110 | int current_ecm_cidx; //index to last current_card (reader)
|
---|
111 | struct cc_current_card *current_card; //initialized by reader (index CS_MAXPID)
|
---|
112 | struct cc_card *server_card; //initialized by client
|
---|
113 |
|
---|
114 | unsigned long crc;
|
---|
115 |
|
---|
116 | pthread_mutex_t lock;
|
---|
117 | pthread_mutex_t ecm_busy;
|
---|
118 | };
|
---|
119 |
|
---|
120 | #endif /* MODULECCCAM_H_ */
|
---|