23#ifdef FREECIV_HAVE_SYS_TYPES_H
26#ifdef HAVE_SYS_SOCKET_H
27#include <sys/socket.h>
29#ifdef HAVE_NETINET_IN_H
30#include <netinet/in.h>
32#ifdef HAVE_ARPA_INET_H
41#ifdef HAVE_SYS_SELECT_H
42#include <sys/select.h>
91#ifdef FREECIV_META_ENABLED
109#ifdef FREECIV_META_ENABLED
128#define QUALIFIED_FOLLOWTAG "?vertag:" FOLLOWTAG
161 log_verbose(
"Metaserver says latest '%s' version is '%s'; we have '%s'",
169 _(
"Latest %s release of Freeciv is %s, this is %s."),
173 }
else if (comment ==
NULL) {
175 _(
"There is no newer %s release of Freeciv available."),
182 if (comment !=
NULL) {
192 const char *host, *port, *version, *state, *
message, *nplayers, *
nhumans;
225 for (j = 0; j <
pserver->nplayers ; j++) {
229 "server%d.player%d.name",
i, j);
233 "server%d.player%d.type",
i, j);
237 "server%d.player%d.host",
i, j);
241 "server%d.player%d.nation",
i, j);
265 _(
"Failed to read the metaserver data from %s."),
279 scan->meta.mem.mem =
NULL;
283 _(
"Failed to parse the metaserver data from %s:\n"
334 scan->
error_func(scan,
_(
"Error connecting to metaserver"));
357 int n =
ptmp->nplayers;
365 for (
i = 0;
i <
n;
i++) {
390#ifndef FREECIV_HAVE_WINSOCK
404#ifdef FREECIV_IPV6_SUPPORT
408#ifndef FREECIV_HAVE_WINSOCK
417#ifdef FREECIV_IPV6_SUPPORT
434 _(
"Opening socket to listen LAN announcements failed:\n%s"),
444 (
char *)&
opt,
sizeof(
opt)) == -1) {
448 memset(&addr, 0,
sizeof(addr));
450#ifdef FREECIV_IPV6_SUPPORT
474 _(
"Binding socket to listen LAN announcements failed:\n%s"),
481#ifdef FREECIV_IPV6_SUPPORT
484 mreq6.ipv6mr_interface = 0;
491 _(
"Adding membership for IPv6 LAN announcement group failed:\n%s"),
501 mreq4.imr_ifindex = 0;
511 _(
"Adding membership for IPv4 LAN announcement group failed:\n%s"),
524 _(
"Opening socket for sending LAN announcement request failed:\n%s"),
531 memset(&addr, 0,
sizeof(addr));
533#ifdef FREECIV_IPV6_SUPPORT
547 log_error(
"Unsupported address family in begin_lanserver_scan()");
554#ifndef FREECIV_HAVE_WINSOCK
562 _(
"Setting Time-to-Live failed:\n%s"),
577 _(
"Setting Broadcast option failed:\n%s"),
595 _(
"Sending LAN announcement request failed:\n%s"),
601 log_debug(
"Sending request for server announcement on LAN.");
664#ifdef FREECIV_IPV6_SUPPORT
681 log_error(
"Unsupported address family in get_lan_server_list()");
687 const char *dst =
NULL;
689 const char *host =
NULL;
720 log_debug(
"Received a valid announcement from a server on the LAN.");
761#ifndef FREECIV_META_ENABLED
776#ifdef FREECIV_META_ENABLED
838 switch (scan->
type) {
840#ifdef FREECIV_META_ENABLED
845 status = scan->meta.status;
886#ifdef FREECIV_META_ENABLED
899 if (scan->
sock >= 0) {
911 if (scan->meta.mem.mem) {
913 scan->meta.mem.mem =
NULL;
917 if (scan->
sock >= 0) {
const char *const our_capability
int dio_put_uint8_raw(struct raw_data_out *dout, int value)
void dio_output_init(struct raw_data_out *dout, void *destination, size_t dest_size)
bool dio_get_uint8_raw(struct data_in *din, int *dest)
size_t dio_output_used(struct raw_data_out *dout)
void dio_input_init(struct data_in *din, const void *src, size_t src_size)
bool dio_get_string_raw(struct data_in *din, char *dest, size_t max_dest_size)
void fc_mutex_allocate(fc_mutex *mutex)
int fc_thread_start(fc_thread *thread, void(*function)(void *arg), void *arg)
void fc_mutex_init(fc_mutex *mutex)
void fc_mutex_release(fc_mutex *mutex)
void fc_thread_wait(fc_thread *thread)
void fc_mutex_destroy(fc_mutex *mutex)
void version_message(const char *vertext)
static struct server_list * server_list
fz_FILE * fz_from_memory(char *buffer, int size, bool control)
#define log_verbose(message,...)
#define fc_assert(condition)
#define log_debug(message,...)
#define log_error(message,...)
#define fc_calloc(n, esz)
void netfile_close_post(struct netfile_post *post)
struct netfile_post * netfile_start_post(void)
bool netfile_send_post(const char *URL, struct netfile_post *post, FILE *reply_fp, struct netfile_write_cb_data *mem_data, const char *addr)
void netfile_add_form_str(struct netfile_post *post, const char *name, const char *val)
bool fc_inet_aton(const char *cp, struct in_addr *inp, bool addr_none_ok)
void fc_closesocket(int sock)
int sockaddr_size(union fc_sockaddr *addr)
void fc_nonblock(int sockfd)
#define FC_IPV6_ADD_MEMBERSHIP
struct client_options gui_options
#define DEFAULT_FOLLOWTAG_OPTION
const char * secfile_error(void)
void secfile_destroy(struct section_file *secfile)
struct section_file * secfile_from_stream(fz_FILE *stream, bool allow_duplicates)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
#define SERVER_LAN_VERSION
static void delete_server_list(struct server_list *server_list)
struct srv_list * server_scan_get_list(struct server_scan *scan)
enum announce_type announce
static enum server_scan_status get_lan_server_list(struct server_scan *scan)
void server_scan_finish(struct server_scan *scan)
struct server_scan * server_scan_begin(enum server_scan_type type, ServerScanErrorFunc error_func)
static bool begin_lanserver_scan(struct server_scan *scan)
enum server_scan_type server_scan_get_type(const struct server_scan *scan)
enum server_scan_status server_scan_poll(struct server_scan *scan)
#define server_list_iterate_end
#define server_list_iterate(serverlist, pserver)
void(* ServerScanErrorFunc)(struct server_scan *scan, const char *message)
char * get_multicast_group(bool ipv6_preferred)
char followtag_override[5112]
ServerScanErrorFunc error_func
enum server_scan_type type
struct server_list * servers
int fc_snprintf(char *str, size_t n, const char *format,...)
int fc_strcasecmp(const char *str0, const char *str1)
const char * fc_strerror(fc_errno err)
fc_errno fc_get_errno(void)
#define sz_strlcpy(dest, src)
struct sockaddr_in saddr_in4
const char * fc_comparable_version(void)