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 GBOX_MAX_LOCAL_CARDS 32
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 60 // write stats file every 1 min
22 #define MAX_GBOX_CARDS 1024 // send max. 1024 cards to peer
23 #define LOCAL_GBOX_MAJOR_VERSION 0x02
24 #define GBOX_START_TIME 30
26 #define MSG_ECM 0x445C
28 #define MSG_HELLO 0xDDAB
29 #define MSG_HELLO1 0x4849
30 #define MSG_CHECKCODE 0x41C0
31 #define MSG_GOODBYE 0x9091
32 #define MSG_GSMS_ACK 0x9099
33 #define MSG_GSMS 0x0FFF
34 #define MSG_HERE 0xA0A1
36 #define GBOX_ECM_NEW_REQ 0
37 #define GBOX_ECM_SENT 1
38 #define GBOX_ECM_ANSWERED 2
40 #define GBOX_CARD_TYPE_GBOX 0
41 #define GBOX_CARD_TYPE_LOCAL 1
42 #define GBOX_CARD_TYPE_BETUN 2
43 #define GBOX_CARD_TYPE_CCCAM 3
44 #define GBOX_CARD_TYPE_PROXY 4
46 #define FILE_GBOX_VERSION "gbox.ver"
47 #define FILE_SHARED_CARDS_INFO "share.info"
48 #define FILE_BACKUP_CARDS_INFO "expired.info"
49 #define FILE_ATTACK_INFO "attack.txt"
50 #define FILE_GBOX_PEER_ONL "share.onl"
51 #define FILE_STATS "stats.info"
52 #define FILE_MSG_INFO "msg.info"
53 #define FILE_LOCAL_CARDS_INFO "sc.info"
55 #define MSGID_GOODNIGHT 0
57 #define MSGID_GONEOFFLINE 2
58 #define MSGID_COMEONLINE 3
59 #define MSGID_GOODBYE 4
60 #define MSGID_LOSTCONNECT 5
61 #define MSGID_ATTACK 6
62 #define MSGID_IPCHANGE 7
63 #define MSGID_GBOXONL 8
64 #define MSGID_UNKNOWNMSG 9
67 #define GBOX_STAT_HELLOL 0
68 #define GBOX_STAT_HELLOS 1
69 #define GBOX_STAT_HELLOR 2
71 #define GBOX_DELETE_FROM_PEER 0
72 #define GBOX_DELETE_WITH_ID 1
73 #define GBOX_DELETE_WITH_TYPE 2
75 #define GBOX_PEER_OFFLINE 0
76 #define GBOX_PEER_ONLINE 1
78 #define GBOX_ATTACK_LOCAL_PW 0
79 #define GBOX_ATTACK_PEER_IGNORE 1
80 #define GBOX_ATTACK_PEER_PW 2
81 #define GBOX_ATTACK_AUTH_FAIL 3
82 #define GBOX_ATTACK_ECM_BLOCKED 4
83 #define GBOX_ATTACK_REMM_REQ_BLOCKED 5
84 #define GBOX_ATTACK_UNKWN_HDR 6
86 #define LOCALCARDEJECTED 1
88 #define LOCALCARDDISABLED 3
96 struct gbox_good_srvid
98 struct gbox_srvid srvid
;
99 time_t last_cw_received
;
102 struct gbox_bad_srvid
104 struct gbox_srvid srvid
;
114 struct gbox_card_pending
116 struct gbox_card_id id
;
117 uint32_t pending_time
;
122 struct gbox_card_id id
;
127 LLIST
*badsids
; // sids that have failed to decode (struct gbox_srvid)
128 LLIST
*goodsids
; // sids that could be decoded (struct gbox_srvid)
129 uint32_t no_cws_returned
;
130 uint32_t average_cw_time
;
131 struct gbox_peer
*origin_peer
;
138 uint8_t minor_version
;
144 struct gbox_data gbox
;
146 uint8_t checkcode
[7];
152 uint8_t crd_crc_change
;
155 struct s_client
*my_user
;
156 uint16_t filtered_cards
;
157 uint16_t total_cards
;
158 uint32_t last_remm_crc
;
161 struct gbox_ecm_request_ext
164 uint8_t gbox_version
;
167 uint8_t gbox_routing_info
[GBOX_MAXHOPS
];
170 void handle_attack(struct s_client
*cli
, uint8_t txt_id
, uint16_t rcvd_id
);
171 char *get_gbox_tmp_fname(char *fext
);
172 uint16_t gbox_get_local_gbox_id(void);
173 uint16_t gbox_convert_password_to_id(uint32_t password
);
174 uint8_t get_peer_onl_status(uint16_t peer_id
);
175 int8_t check_peer_ignored(uint16_t peer_id
);
176 uint32_t gbox_get_local_gbox_password(void);
177 void gbox_send(struct s_client
*cli
, uint8_t *buf
, int32_t l
);
178 int8_t gbox_message_header(uint8_t *buf
, uint16_t cmd
, uint32_t peer_password
, uint32_t local_password
);
179 void gbox_free_cards_pending(ECM_REQUEST
*er
);
180 void gbox_send_good_night(void);
181 void gbox_send_goodbye(struct s_client
*cli
);
182 void restart_gbox_peer(char *rdrlabel
, uint8_t all
, uint16_t gbox_id
);
183 void write_msg_info(struct s_client
*cli
, uint8_t msg_id
, uint8_t txt_id
, uint16_t misc
);
184 extern void gbx_local_card_stat(uint8_t crdstat
, uint16_t caid
);
185 extern void gbox_send_init_hello(void);
186 extern void stop_gbx_ticker(void);
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
) ) { }
191 static inline void gbox_send_init_hello(void) { }
192 static inline void stop_gbx_ticker(void) { }