13#ifndef FC__CONNECTION_H
14#define FC__CONNECTION_H
22#ifdef FREECIV_HAVE_SYS_TYPES_H
25#ifdef FREECIV_HAVE_SYS_TIME_H
29#ifdef FREECIV_JSON_CONNECTION
33#ifndef FREECIV_JSON_CONNECTION
34#define USE_COMPRESSION
50struct conn_pattern_list;
56#define MAX_LEN_PACKET 4096
57#define MAX_LEN_CAPSTR 512
58#define MAX_LEN_PASSWORD 512
59#define MAX_LEN_CONTENT (MAX_LEN_PACKET - 20)
61#define MAX_LEN_BUFFER (MAX_LEN_PACKET * 128)
68#define SPECENUM_NAME cmdlevel
70#define SPECENUM_VALUE0 ALLOW_NONE
71#define SPECENUM_VALUE0NAME "none"
73#define SPECENUM_VALUE1 ALLOW_INFO
74#define SPECENUM_VALUE1NAME "info"
76#define SPECENUM_VALUE2 ALLOW_BASIC
77#define SPECENUM_VALUE2NAME "basic"
80#define SPECENUM_VALUE3 ALLOW_CTRL
81#define SPECENUM_VALUE3NAME "ctrl"
83#define SPECENUM_VALUE4 ALLOW_ADMIN
84#define SPECENUM_VALUE4NAME "admin"
86#define SPECENUM_VALUE5 ALLOW_HACK
87#define SPECENUM_VALUE5NAME "hack"
88#define SPECENUM_COUNT CMDLEVEL_COUNT
109#define SPECLIST_TAG conn
110#define SPECLIST_TYPE struct connection
113#define conn_list_iterate(connlist, pconn) \
114 TYPED_LIST_ITERATE(struct connection, connlist, pconn)
115#define conn_list_iterate_end LIST_ITERATE_END
133#define SPECVEC_TAG byte
134#define SPECVEC_TYPE unsigned char
161#ifdef FREECIV_JSON_CONNECTION
187 bool data_available_and_socket_full);
270#ifdef USE_COMPRESSION
274 struct byte_vector queue;
290 const unsigned char *data,
int len);
335#define SPECLIST_TAG conn_pattern
336#define SPECLIST_TYPE struct conn_pattern
338#define conn_pattern_list_iterate(plist, ppatern) \
339 TYPED_LIST_ITERATE(struct conn_pattern, plist, ppatern)
340#define conn_pattern_list_iterate_end LIST_ITERATE_END
342#define SPECENUM_NAME conn_pattern_type
343#define SPECENUM_VALUE0 CPT_USER
344#define SPECENUM_VALUE0NAME "user"
345#define SPECENUM_VALUE1 CPT_HOST
346#define SPECENUM_VALUE1NAME "host"
347#define SPECENUM_VALUE2 CPT_IP
348#define SPECENUM_VALUE2NAME "ip"
361 char *buf,
size_t buf_len);
363 enum conn_pattern_type prefer,
365 size_t error_buf_len);
size_t conn_pattern_to_string(const struct conn_pattern *ppattern, char *buf, size_t buf_len)
struct player * conn_get_player(const struct connection *pconn)
void conn_list_do_unbuffer(struct conn_list *dest)
void free_compression_queue(struct connection *pconn)
struct connection * conn_by_user_prefix(const char *user_name, enum m_pre_result *result)
bool can_conn_edit(const struct connection *pconn)
void(* conn_close_fn_t)(struct connection *pconn)
struct connection * conn_by_user(const char *user_name)
void conn_list_compression_thaw(const struct conn_list *pconn_list)
void connections_set_close_callback(conn_close_fn_t func)
bool conn_compression_thaw(struct connection *pconn)
void flush_connection_send_buffer_all(struct connection *pc)
int get_next_request_id(int old_request_id)
struct socket_packet_buffer * new_socket_packet_buffer(void)
void conn_list_do_buffer(struct conn_list *dest)
bool can_conn_enable_editing(const struct connection *pconn)
void connection_do_buffer(struct connection *pc)
bool conn_pattern_match(const struct conn_pattern *ppattern, const struct connection *pconn)
void conn_set_capability(struct connection *pconn, const char *capability)
void conn_pattern_destroy(struct conn_pattern *ppattern)
void connection_common_init(struct connection *pconn)
void connection_close(struct connection *pconn, const char *reason)
void conn_list_compression_freeze(const struct conn_list *pconn_list)
struct conn_pattern * conn_pattern_new(enum conn_pattern_type type, const char *wildcard)
bool conn_controls_player(const struct connection *pconn)
bool conn_is_global_observer(const struct connection *pconn)
const char * conn_description(const struct connection *pconn)
void connection_common_close(struct connection *pconn)
struct conn_pattern * conn_pattern_from_string(const char *pattern, enum conn_pattern_type prefer, char *error_buf, size_t error_buf_len)
void conn_compression_freeze(struct connection *pconn)
struct connection * conn_by_number(int id)
const char blank_addr_str[]
int read_socket_data(int sock, struct socket_packet_buffer *buffer)
void conn_reset_delta_state(struct connection *pconn)
bool connection_send_data(struct connection *pconn, const unsigned char *data, int len)
enum cmdlevel conn_get_access(const struct connection *pconn)
bool conn_is_valid(const struct connection *pconn)
bool conn_compression_frozen(const struct connection *pconn)
bool conn_pattern_list_match(const struct conn_pattern_list *plist, const struct connection *pconn)
void connection_do_unbuffer(struct connection *pc)
int currently_processed_request_id
struct genhash ** received
struct connection::@61 statistics
struct connection::@57::@62 client
int request_id_of_currently_handled_packet
struct connection::@57::@63::@64 delegation
enum cmdlevel access_level
const struct packet_handlers * handlers
struct timer_list * ping_timers
struct connection::@59 phs
char username[MAX_LEN_NAME]
struct connection::@57::@63 server
struct timer * last_write
struct connection::@60 compression
char ipaddr[MAX_LEN_ADDR]
void(* incoming_packet_notify)(struct connection *pc, int packet_type, int size)
void(* outgoing_packet_notify)(struct connection *pc, int packet_type, int size, int request_id)
struct socket_packet_buffer * send_buffer
char capability[MAX_LEN_CAPSTR]
void(* notify_of_writable_data)(struct connection *pc, bool data_available_and_socket_full)
int last_processed_request_id_seen
struct socket_packet_buffer * buffer
char password[MAX_LEN_PASSWORD]
struct conn_pattern_list * ignore_list
enum cmdlevel granted_access_level