43#define MAX_LEN_MSG 1536
44#define MAX_LEN_ROUTE 2000
47#define web_send_packet(packetname, ...) \
48 send_packet_web_ ##packetname( __VA_ARGS__ )
49#define web_lsend_packet(packetname, ...) \
50 lsend_packet_web_ ##packetname( __VA_ARGS__ )
52#define web_send_packet(packetname, ...)
53#define web_lsend_packet(packetname, ...)
65#define ATTRIBUTE_CHUNK_SIZE (1400)
70#define REQEST_PLAYER_INITIATED (0)
110#ifdef FREECIV_JSON_CONNECTION
111#define get_packet_from_connection(pc, ptype) get_packet_from_connection_json(pc, ptype)
113#define get_packet_from_connection(pc, ptype) get_packet_from_connection_raw(pc, ptype)
147#ifdef FREECIV_JSON_CONNECTION
151#define SEND_PACKET_START(packet_type) \
152 unsigned char buffer[MAX_LEN_PACKET]; \
153 struct raw_data_out dout; \
155 dio_output_init(&dout, buffer, sizeof(buffer)); \
156 dio_put_type_raw(&dout, pc->packet_header.length, 0); \
157 dio_put_type_raw(&dout, pc->packet_header.type, packet_type);
159#define SEND_PACKET_END(packet_type) \
161 size_t size = dio_output_used(&dout); \
163 dio_output_rewind(&dout); \
164 dio_put_type_raw(&dout, pc->packet_header.length, size); \
165 fc_assert(!dout.too_short); \
166 return send_packet_data(pc, buffer, size, packet_type); \
169#define RECEIVE_PACKET_START(packet_type, result) \
170 struct data_in din; \
171 struct packet_type packet_buf, *result = &packet_buf; \
173 dio_input_init(&din, pc->buffer->data, \
174 data_type_size(pc->packet_header.length)); \
178 dio_get_type_raw(&din, pc->packet_header.length, &size); \
179 dio_input_init(&din, pc->buffer->data, MIN(size, pc->buffer->ndata)); \
181 dio_input_skip(&din, (data_type_size(pc->packet_header.length) \
182 + data_type_size(pc->packet_header.type)));
184#define RECEIVE_PACKET_END(result) \
185 if (!packet_check(&din, pc)) { \
188 remove_packet_from_buffer(pc->buffer); \
189 result = fc_malloc(sizeof(*result)); \
190 *result = packet_buf; \
193#define RECEIVE_PACKET_FIELD_ERROR(field, ...) \
194 log_packet("Error on field '" #field "'" __VA_ARGS__); \
204#define PACKET_STRVEC_SEPARATOR '\3'
205#define PACKET_STRVEC_COMPUTE(str, strvec) \
206 if (NULL != strvec) { \
207 strvec_to_str(strvec, PACKET_STRVEC_SEPARATOR, str, sizeof(str)); \
211#define PACKET_STRVEC_EXTRACT(strvec, str) \
212 if ('\0' != str[0]) { \
213 strvec = strvec_new(); \
214 strvec_from_str(strvec, PACKET_STRVEC_SEPARATOR, str); \
void post_receive_packet_server_join_reply(struct connection *pconn, const struct packet_server_join_reply *packet)
void * get_packet_from_connection_raw(struct connection *pc, enum packet_type *ptype)
bool packet_has_game_info_flag(enum packet_type type)
bool packet_check(struct data_in *din, struct connection *pc)
void packet_header_init(struct packet_header *packet_header)
void packet_handlers_fill_capability(struct packet_handlers *phandlers, const char *capability)
const struct packet_handlers * packet_handlers_initial(void)
void packets_deinit(void)
@ REPORT_WONDERS_OF_THE_WORLD
void pre_send_packet_player_attribute_chunk(struct connection *pc, struct packet_player_attribute_chunk *packet)
void remove_packet_from_buffer(struct socket_packet_buffer *buffer)
const char * packet_name(enum packet_type type)
void post_send_packet_server_join_reply(struct connection *pconn, const struct packet_server_join_reply *packet)
int send_packet_data(struct connection *pc, unsigned char *data, int len, enum packet_type packet_type)
void generic_handle_player_attribute_chunk(struct player *pplayer, const struct packet_player_attribute_chunk *chunk)
void send_attribute_block(const struct player *pplayer, struct connection *pconn)
@ UNIT_INFO_CITY_SUPPORTED
const struct packet_handlers * packet_handlers_get(const char *capability)
void packet_handlers_fill_initial(struct packet_handlers *phandlers)
char capability[MAX_LEN_CAPSTR]
struct socket_packet_buffer * buffer
int(* force_to_send)(struct connection *pconn, const void *packet, bool force_to_send)
int(* no_packet)(struct connection *pconn)
int(* packet)(struct connection *pconn, const void *packet)
union packet_handlers::@67 send[PACKET_LAST]
void *(* receive[PACKET_LAST])(struct connection *pconn)