8 #define DEFAULT_GBOX_MAX_DIST 2
9 #define DEFAULT_GBOX_MAX_ECM_SEND 5
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_SID_CONFIRM_TIME 3600
17 #define GBOX_DEFAULT_CW_TIME 500
18 #define RECEIVE_BUFFER_SIZE 1024
19 #define MIN_GBOX_MESSAGE_LENGTH 10 // CMD + pw + pw. TODO: Check if is really min
20 #define MIN_ECM_LENGTH 8
21 #define STATS_WRITE_TIME 300 // write stats file every 5 min
22 #define MAX_GBOX_CARDS 1024 // send max. 1024 cards to peer
23 #define LOCAL_GBOX_MAJOR_VERSION 0x02
25 #define MSG_ECM 0x445C
27 #define MSG_HELLO 0xDDAB
28 #define MSG_HELLO1 0x4849
29 #define MSG_CHECKCODE 0x41C0
30 #define MSG_GOODBYE 0x9091
31 #define MSG_GSMS_ACK 0x9099
32 #define MSG_GSMS 0x0FFF
33 #define MSG_HERE 0xA0A1
35 #define GBOX_ECM_NEW_REQ 0
36 #define GBOX_ECM_SENT 1
37 #define GBOX_ECM_ANSWERED 2
39 #define GBOX_CARD_TYPE_GBOX 0
40 #define GBOX_CARD_TYPE_LOCAL 1
41 #define GBOX_CARD_TYPE_BETUN 2
42 #define GBOX_CARD_TYPE_CCCAM 3
43 #define GBOX_CARD_TYPE_PROXY 4
45 #define FILE_GBOX_VERSION "gbox.ver"
46 #define FILE_SHARED_CARDS_INFO "share.info"
47 #define FILE_BACKUP_CARDS_INFO "expired.info"
48 #define FILE_ATTACK_INFO "attack.txt"
49 #define FILE_GBOX_PEER_ONL "share.onl"
50 #define FILE_STATS "stats.info"
51 #define FILE_MSG_INFO "msg.info"
52 #define FILE_LOCAL_CARDS_INFO "sc.info"
54 #define MSGID_GOODNIGHT 0
56 #define MSGID_GONEOFFLINE 2
57 #define MSGID_COMEONLINE 3
58 #define MSGID_GOODBYE 4
59 #define MSGID_LOSTCONNECT 5
60 #define MSGID_ATTACK 6
61 #define MSGID_IPCHANGE 7
62 #define MSGID_GBOXONL 8
63 #define MSGID_UNKNOWNMSG 9
66 #define GBOX_STAT_HELLOL 0
67 #define GBOX_STAT_HELLOS 1
68 #define GBOX_STAT_HELLOR 2
70 #define GBOX_DELETE_FROM_PEER 0
71 #define GBOX_DELETE_WITH_ID 1
72 #define GBOX_DELETE_WITH_TYPE 2
74 #define GBOX_PEER_OFFLINE 0
75 #define GBOX_PEER_ONLINE 1
77 #define GBOX_ATTACK_LOCAL_PW 0
78 #define GBOX_ATTACK_PEER_IGNORE 1
79 #define GBOX_ATTACK_PEER_PW 2
80 #define GBOX_ATTACK_AUTH_FAIL 3
81 #define GBOX_ATTACK_ECM_BLOCKED 4
82 #define GBOX_ATTACK_REMM_REQ_BLOCKED 5
84 #define LOCALCARDEJECTED 1
87 struct gbox_rbc_thread_args
100 struct gbox_good_srvid
102 struct gbox_srvid srvid
;
103 time_t last_cw_received
;
106 struct gbox_bad_srvid
108 struct gbox_srvid srvid
;
118 struct gbox_card_pending
120 struct gbox_card_id id
;
121 uint32_t pending_time
;
126 struct gbox_card_id id
;
131 LLIST
*badsids
; // sids that have failed to decode (struct gbox_srvid)
132 LLIST
*goodsids
; // sids that could be decoded (struct gbox_srvid)
133 uint32_t no_cws_returned
;
134 uint32_t average_cw_time
;
135 struct gbox_peer
*origin_peer
;
142 uint8_t minor_version
;
148 struct gbox_data gbox
;
150 uint8_t checkcode
[7];
158 struct s_client
*my_user
;
159 uint16_t filtered_cards
;
160 uint16_t total_cards
;
161 uint32_t last_remm_crc
;
164 struct gbox_ecm_request_ext
167 uint8_t gbox_version
;
170 uint8_t gbox_routing_info
[GBOX_MAXHOPS
];
173 void handle_attack(struct s_client
*cli
, uint8_t txt_id
, uint16_t rcvd_id
);
174 char *get_gbox_tmp_fname(char *fext
);
175 uint16_t gbox_get_local_gbox_id(void);
176 uint16_t gbox_convert_password_to_id(uint32_t password
);
177 uint8_t get_peer_onl_status(uint16_t peer_id
);
178 uint32_t gbox_get_local_gbox_password(void);
179 void gbox_send(struct s_client
*cli
, uint8_t *buf
, int32_t l
);
180 int8_t gbox_message_header(uint8_t *buf
, uint16_t cmd
, uint32_t peer_password
, uint32_t local_password
);
181 void gbox_free_cards_pending(ECM_REQUEST
*er
);
182 void gbox_send_good_night(void);
183 void gbox_send_goodbye(struct s_client
*cli
);
184 void restart_gbox_peer(char *rdrlabel
, uint8_t all
, uint16_t gbox_id
);
185 void write_msg_info(struct s_client
*cli
, uint8_t msg_id
, uint8_t txt_id
, uint16_t misc
);
186 extern void gbx_local_card_stat(uint8_t crdstat
, uint16_t caid
);
188 static inline void gbox_free_cards_pending(ECM_REQUEST
*UNUSED(er
)) { }
189 static inline void gbox_send_good_night(void) { }
190 static inline void gbx_local_card_stat(uint8_t UNUSED(crdstat
), uint16_t UNUSED(caid
) ) { }