revert breaks some stupid old compilers
[oscam.git] / module-gbox.h
blob9f1a50c85f390085b3b6aab671d2460f523f130c
1 #ifndef MODULE_GBOX_H_
2 #define MODULE_GBOX_H_
4 #ifdef MODULE_GBOX
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_GBOX_RECONNECT 180
12 #define GBOX_MIN_RECONNECT 60
13 #define GBOX_MAX_RECONNECT 300
14 #define CS_GBOX_MAX_LOCAL_CARDS 16
15 #define GBOX_REBROADCAST_TIMEOUT 1250
16 #define GBOX_MIN_REBROADCAST_TIME 100
17 #define GBOX_SID_CONFIRM_TIME 3600
18 #define GBOX_DEFAULT_CW_TIME 500
20 #define MSG_ECM 0x445C
21 #define MSG_CW 0x4844
22 #define MSG_HELLO 0xDDAB
23 #define MSG_HELLO1 0x4849
24 #define MSG_CHECKCODE 0x41C0
25 #define MSG_GOODBYE 0x9091
26 #define MSG_GSMS_ACK 0x9099
27 #define MSG_GSMS 0x0FFF
28 #define MSG_HERE 0xA0A1
30 #define GBOX_ECM_NOT_ASKED 0
31 #define GBOX_ECM_SENT 1
32 #define GBOX_ECM_SENT_ALL 2
33 #define GBOX_ECM_SENT_ALL_TWICE 3
34 #define GBOX_ECM_ANSWERED 4
36 #define GBOX_CARD_TYPE_GBOX 0
37 #define GBOX_CARD_TYPE_LOCAL 1
38 #define GBOX_CARD_TYPE_BETUN 2
39 #define GBOX_CARD_TYPE_CCCAM 3
40 #define GBOX_CARD_TYPE_PROXY 4
42 #define FILE_GBOX_VERSION "gbox.ver"
43 #define FILE_SHARED_CARDS_INFO "share.info"
44 #define FILE_BACKUP_CARDS_INFO "expired.info"
45 #define FILE_ATTACK_INFO "attack.txt"
46 #define FILE_GBOX_PEER_ONL "share.onl"
47 #define FILE_STATS "stats.info"
48 #define FILE_MSG_INFO "msg.info"
49 #define FILE_LOCAL_CARDS_INFO "sc.info"
51 #define MSGID_GOODNIGHT 0
52 #define MSGID_GSMS 1
53 #define MSGID_GONEOFFLINE 2
54 #define MSGID_COMEONLINE 3
55 #define MSGID_GOODBYE 4
56 #define MSGID_LOSTCONNECT 5
57 #define MSGID_ATTACK 6
58 #define MSGID_IPCHANGE 7
59 #define MSGID_GBOXONL 8
60 #define MSGID_UNKNOWNMSG 9
62 #define GBOX_STAT_HELLOL 0
63 #define GBOX_STAT_HELLOS 1
64 #define GBOX_STAT_HELLOR 2
66 #define GBOX_DELETE_FROM_PEER 0
67 #define GBOX_DELETE_WITH_ID 1
68 #define GBOX_DELETE_WITH_TYPE 2
70 #define GBOX_PEER_OFFLINE 0
71 #define GBOX_PEER_ONLINE 1
73 #define GBOX_ATTACK_LOCAL_PW 0
74 #define GBOX_ATTACK_PEER_IGNORE 1
75 #define GBOX_ATTACK_PEER_PW 2
76 #define GBOX_ATTACK_AUTH_FAIL 3
77 #define GBOX_ATTACK_ECM_BLOCKED 4
78 #define GBOX_ATTACK_REMM_REQ_BLOCKED 5
80 struct gbox_rbc_thread_args
82 struct s_client *cli;
83 ECM_REQUEST *er;
84 uint32_t waittime;
87 struct gbox_srvid
89 uint16_t sid;
90 uint32_t provid_id;
93 struct gbox_good_srvid
95 struct gbox_srvid srvid;
96 time_t last_cw_received;
99 struct gbox_bad_srvid
101 struct gbox_srvid srvid;
102 uint8_t bad_strikes;
105 struct gbox_card_id
107 uint16_t peer;
108 uint8_t slot;
111 struct gbox_card_pending
113 struct gbox_card_id id;
114 uint32_t pending_time;
117 struct gbox_card
119 struct gbox_card_id id;
120 uint32_t caprovid;
121 uint8_t dist;
122 uint8_t lvl;
123 uint8_t type;
124 LLIST *badsids; // sids that have failed to decode (struct gbox_srvid)
125 LLIST *goodsids; //sids that could be decoded (struct gbox_srvid)
126 uint32_t no_cws_returned;
127 uint32_t average_cw_time;
128 struct gbox_peer *origin_peer;
131 struct gbox_data
133 uint16_t id;
134 uint32_t password;
135 uint8_t minor_version;
136 uint8_t cpu_api;
139 struct gbox_peer
141 struct gbox_data gbox;
142 uchar *hostname;
143 uchar checkcode[7];
144 int8_t online;
145 uint8_t onlinestat;
146 uint8_t authstat;
147 uint8_t next_hello;
148 uint8_t gbox_rev;
149 uchar ecm_idx;
150 CS_MUTEX_LOCK lock;
151 struct s_client *my_user;
152 uint16_t filtered_cards;
153 uint16_t total_cards;
157 struct gbox_ecm_request_ext
159 uint8_t gbox_hops;
160 uint16_t gbox_peer;
161 uint16_t gbox_mypeer;
162 uint8_t gbox_slot;
163 uint8_t gbox_version;
164 uint8_t gbox_rev;
165 uint8_t gbox_type;
166 uchar gbox_routing_info[GBOX_MAXHOPS];
169 void handle_attack(struct s_client *cli, uint8_t txt_id, uint16_t rcvd_id);
170 char *get_gbox_tmp_fname(char *fext);
171 uint16_t gbox_get_local_gbox_id(void);
172 uint32_t gbox_get_local_gbox_password(void);
173 void gbox_send(struct s_client *cli, uchar *buf, int32_t l);
174 int8_t gbox_message_header(uchar *buf, uint16_t cmd, uint32_t peer_password, uint32_t local_password);
175 void gbox_free_cards_pending(ECM_REQUEST *er);
176 void gbox_send_good_night(void);
177 void gbox_send_goodbye(struct s_client *cli);
178 extern void gbx_local_card_changed(void);
179 #else
180 static inline void gbox_free_cards_pending(ECM_REQUEST *UNUSED(er)) { }
181 static inline void gbox_send_good_night(void) { }
182 static inline void gbx_local_card_changed(void) { }
183 #endif
185 #endif