1 | #ifndef MODULE_GBOX_H_
|
---|
2 | #define MODULE_GBOX_H_
|
---|
3 |
|
---|
4 | #ifdef MODULE_GBOX
|
---|
5 |
|
---|
6 | #define NO_GBOX_ID 0
|
---|
7 | #define GBOX_MAXHOPS 5
|
---|
8 | #define DEFAULT_GBOX_MAX_DIST 2
|
---|
9 | #define DEFAULT_GBOX_MAX_ECM_SEND 3
|
---|
10 | #define DEFAULT_GBOX_RESHARE 2
|
---|
11 | #define DEFAULT_CCC_GBOX_RESHARE 1
|
---|
12 | #define DEFAULT_GBOX_RECONNECT 180
|
---|
13 | #define GBOX_MIN_RECONNECT 60
|
---|
14 | #define GBOX_MAX_RECONNECT 300
|
---|
15 | #define CS_GBOX_MAX_LOCAL_CARDS 16
|
---|
16 | #define GBOX_REBROADCAST_TIMEOUT 1250
|
---|
17 | #define GBOX_MIN_REBROADCAST_TIME 100
|
---|
18 | #define GBOX_SID_CONFIRM_TIME 3600
|
---|
19 | #define GBOX_DEFAULT_CW_TIME 500
|
---|
20 | #define RECEIVE_BUFFER_SIZE 1024
|
---|
21 | #define MIN_GBOX_MESSAGE_LENGTH 10 //CMD + pw + pw. TODO: Check if is really min
|
---|
22 | #define MIN_ECM_LENGTH 8
|
---|
23 | #define STATS_WRITE_TIME 300 //write stats file every 5 min
|
---|
24 | #define MAX_GBOX_CARDS 1024 //send max. 1024 to peer
|
---|
25 | #define LOCAL_GBOX_MAJOR_VERSION 0x02
|
---|
26 |
|
---|
27 | #define MSG_ECM 0x445C
|
---|
28 | #define MSG_CW 0x4844
|
---|
29 | #define MSG_HELLO 0xDDAB
|
---|
30 | #define MSG_HELLO1 0x4849
|
---|
31 | #define MSG_CHECKCODE 0x41C0
|
---|
32 | #define MSG_GOODBYE 0x9091
|
---|
33 | #define MSG_GSMS_ACK 0x9099
|
---|
34 | #define MSG_GSMS 0x0FFF
|
---|
35 | #define MSG_HERE 0xA0A1
|
---|
36 |
|
---|
37 | #define GBOX_ECM_NOT_ASKED 0
|
---|
38 | #define GBOX_ECM_SENT 1
|
---|
39 | #define GBOX_ECM_SENT_ALL 2
|
---|
40 | #define GBOX_ECM_SENT_ALL_TWICE 3
|
---|
41 | #define GBOX_ECM_ANSWERED 4
|
---|
42 |
|
---|
43 | #define GBOX_CARD_TYPE_GBOX 0
|
---|
44 | #define GBOX_CARD_TYPE_LOCAL 1
|
---|
45 | #define GBOX_CARD_TYPE_BETUN 2
|
---|
46 | #define GBOX_CARD_TYPE_CCCAM 3
|
---|
47 | #define GBOX_CARD_TYPE_PROXY 4
|
---|
48 |
|
---|
49 | #define FILE_GBOX_VERSION "gbox.ver"
|
---|
50 | #define FILE_SHARED_CARDS_INFO "share.info"
|
---|
51 | #define FILE_BACKUP_CARDS_INFO "expired.info"
|
---|
52 | #define FILE_ATTACK_INFO "attack.txt"
|
---|
53 | #define FILE_GBOX_PEER_ONL "share.onl"
|
---|
54 | #define FILE_STATS "stats.info"
|
---|
55 | #define FILE_MSG_INFO "msg.info"
|
---|
56 | #define FILE_LOCAL_CARDS_INFO "sc.info"
|
---|
57 |
|
---|
58 | #define MSGID_GOODNIGHT 0
|
---|
59 | #define MSGID_GSMS 1
|
---|
60 | #define MSGID_GONEOFFLINE 2
|
---|
61 | #define MSGID_COMEONLINE 3
|
---|
62 | #define MSGID_GOODBYE 4
|
---|
63 | #define MSGID_LOSTCONNECT 5
|
---|
64 | #define MSGID_ATTACK 6
|
---|
65 | #define MSGID_IPCHANGE 7
|
---|
66 | #define MSGID_GBOXONL 8
|
---|
67 | #define MSGID_UNKNOWNMSG 9
|
---|
68 | #define MSGID_REMM 12
|
---|
69 |
|
---|
70 | #define GBOX_STAT_HELLOL 0
|
---|
71 | #define GBOX_STAT_HELLOS 1
|
---|
72 | #define GBOX_STAT_HELLOR 2
|
---|
73 |
|
---|
74 | #define GBOX_DELETE_FROM_PEER 0
|
---|
75 | #define GBOX_DELETE_WITH_ID 1
|
---|
76 | #define GBOX_DELETE_WITH_TYPE 2
|
---|
77 |
|
---|
78 | #define GBOX_PEER_OFFLINE 0
|
---|
79 | #define GBOX_PEER_ONLINE 1
|
---|
80 |
|
---|
81 | #define GBOX_ATTACK_LOCAL_PW 0
|
---|
82 | #define GBOX_ATTACK_PEER_IGNORE 1
|
---|
83 | #define GBOX_ATTACK_PEER_PW 2
|
---|
84 | #define GBOX_ATTACK_AUTH_FAIL 3
|
---|
85 | #define GBOX_ATTACK_ECM_BLOCKED 4
|
---|
86 | #define GBOX_ATTACK_REMM_REQ_BLOCKED 5
|
---|
87 |
|
---|
88 | #define LOCALCARDEJECTED 1
|
---|
89 | #define LOCALCARDUP 2
|
---|
90 |
|
---|
91 | struct gbox_rbc_thread_args
|
---|
92 | {
|
---|
93 | struct s_client *cli;
|
---|
94 | ECM_REQUEST *er;
|
---|
95 | uint32_t waittime;
|
---|
96 | };
|
---|
97 |
|
---|
98 | struct gbox_srvid
|
---|
99 | {
|
---|
100 | uint16_t sid;
|
---|
101 | uint32_t provid_id;
|
---|
102 | };
|
---|
103 |
|
---|
104 | struct gbox_good_srvid
|
---|
105 | {
|
---|
106 | struct gbox_srvid srvid;
|
---|
107 | time_t last_cw_received;
|
---|
108 | };
|
---|
109 |
|
---|
110 | struct gbox_bad_srvid
|
---|
111 | {
|
---|
112 | struct gbox_srvid srvid;
|
---|
113 | uint8_t bad_strikes;
|
---|
114 | };
|
---|
115 |
|
---|
116 | struct gbox_card_id
|
---|
117 | {
|
---|
118 | uint16_t peer;
|
---|
119 | uint8_t slot;
|
---|
120 | };
|
---|
121 |
|
---|
122 | struct gbox_card_pending
|
---|
123 | {
|
---|
124 | struct gbox_card_id id;
|
---|
125 | uint32_t pending_time;
|
---|
126 | };
|
---|
127 |
|
---|
128 | struct gbox_card
|
---|
129 | {
|
---|
130 | struct gbox_card_id id;
|
---|
131 | uint32_t caprovid;
|
---|
132 | uint8_t dist;
|
---|
133 | uint8_t lvl;
|
---|
134 | uint8_t type;
|
---|
135 | LLIST *badsids; // sids that have failed to decode (struct gbox_srvid)
|
---|
136 | LLIST *goodsids; //sids that could be decoded (struct gbox_srvid)
|
---|
137 | uint32_t no_cws_returned;
|
---|
138 | uint32_t average_cw_time;
|
---|
139 | struct gbox_peer *origin_peer;
|
---|
140 | };
|
---|
141 |
|
---|
142 | struct gbox_data
|
---|
143 | {
|
---|
144 | uint16_t id;
|
---|
145 | uint32_t password;
|
---|
146 | uint8_t minor_version;
|
---|
147 | uint8_t cpu_api;
|
---|
148 | };
|
---|
149 |
|
---|
150 | struct gbox_peer
|
---|
151 | {
|
---|
152 | struct gbox_data gbox;
|
---|
153 | uchar *hostname;
|
---|
154 | uchar checkcode[7];
|
---|
155 | int8_t online;
|
---|
156 | uint8_t onlinestat;
|
---|
157 | uint8_t authstat;
|
---|
158 | uint8_t next_hello;
|
---|
159 | uint8_t gbox_rev;
|
---|
160 | uchar ecm_idx;
|
---|
161 | CS_MUTEX_LOCK lock;
|
---|
162 | struct s_client *my_user;
|
---|
163 | uint16_t filtered_cards;
|
---|
164 | uint16_t total_cards;
|
---|
165 |
|
---|
166 | };
|
---|
167 |
|
---|
168 | struct gbox_ecm_request_ext
|
---|
169 | {
|
---|
170 | uint8_t gbox_hops;
|
---|
171 | uint16_t gbox_peer;
|
---|
172 | uint16_t gbox_mypeer;
|
---|
173 | uint8_t gbox_slot;
|
---|
174 | uint8_t gbox_version;
|
---|
175 | uint8_t gbox_rev;
|
---|
176 | uint8_t gbox_type;
|
---|
177 | uchar gbox_routing_info[GBOX_MAXHOPS];
|
---|
178 | };
|
---|
179 |
|
---|
180 | void handle_attack(struct s_client *cli, uint8_t txt_id, uint16_t rcvd_id);
|
---|
181 | char *get_gbox_tmp_fname(char *fext);
|
---|
182 | uint16_t gbox_get_local_gbox_id(void);
|
---|
183 | uint16_t gbox_convert_password_to_id(uint32_t password);
|
---|
184 | uint8_t get_peer_onl_status(uint16_t peer_id);
|
---|
185 | uint32_t gbox_get_local_gbox_password(void);
|
---|
186 | void gbox_send(struct s_client *cli, uchar *buf, int32_t l);
|
---|
187 | int8_t gbox_message_header(uchar *buf, uint16_t cmd, uint32_t peer_password, uint32_t local_password);
|
---|
188 | void gbox_free_cards_pending(ECM_REQUEST *er);
|
---|
189 | void gbox_send_good_night(void);
|
---|
190 | void gbox_send_goodbye(struct s_client *cli);
|
---|
191 | void restart_gbox_peer(char *rdrlabel, uint8_t all, uint16_t gbox_id);
|
---|
192 | void write_msg_info(struct s_client *cli, uint8_t msg_id, uint8_t txt_id, uint16_t misc);
|
---|
193 | extern void gbx_local_card_stat(uint8_t crdstat, uint16_t caid);
|
---|
194 | #else
|
---|
195 | static inline void gbox_free_cards_pending(ECM_REQUEST *UNUSED(er)) { }
|
---|
196 | static inline void gbox_send_good_night(void) { }
|
---|
197 | static inline void gbx_local_card_stat(uint8_t UNUSED(crdstat), uint16_t UNUSED(caid) ) { }
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | #endif
|
---|