Freeciv-3.1
|
#include "fc_prehdrs.h"
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bugs.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "support.h"
#include "netintf.h"
Go to the source code of this file.
Macros | |
#define | INADDR_NONE 0xffffffff |
Functions | |
int | fc_connect (int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) |
int | fc_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout) |
int | fc_readsocket (int sock, void *buf, size_t size) |
int | fc_writesocket (int sock, const void *buf, size_t size) |
void | fc_closesocket (int sock) |
void | fc_init_network (void) |
void | fc_shutdown_network (void) |
void | fc_nonblock (int sockfd) |
void | sockaddr_debug (union fc_sockaddr *addr, enum log_level lvl) |
int | sockaddr_size (union fc_sockaddr *addr) |
bool | sockaddr_ipv6 (union fc_sockaddr *addr) |
struct fc_sockaddr_list * | net_lookup_service (const char *name, int port, enum fc_addr_family family) |
bool | fc_inet_aton (const char *cp, struct in_addr *inp, bool addr_none_ok) |
fz_FILE * | fc_querysocket (int sock, void *buf, size_t size) |
int | find_next_free_port (int starting_port, int highest_port, enum fc_addr_family family, char *net_interface, bool not_avail_ok) |
int | addr_family_for_announce_type (enum announce_type announce) |
int addr_family_for_announce_type | ( | enum announce_type | announce | ) |
Return address family matching the announce type
Definition at line 692 of file netintf.c.
Referenced by send_lanserver_response().
void fc_closesocket | ( | int | sock | ) |
Close a socket.
Definition at line 186 of file netintf.c.
Referenced by begin_lanserver_scan(), close_connections_and_socket(), connection_common_close(), fc_querysocket(), find_next_free_port(), send_lanserver_response(), server_accept_connection(), server_make_connection(), server_open_socket(), server_scan_finish(), and try_to_connect().
int fc_connect | ( | int | sockfd, |
const struct sockaddr * | serv_addr, | ||
socklen_t | addrlen | ||
) |
Connect a socket to an address
Definition at line 107 of file netintf.c.
Referenced by try_to_connect().
Convert internet IPv4 host address to binary form and store it to inp. Return FALSE on failure if possible, i.e., FALSE is guarantee that it failed but TRUE is not guarantee that it succeeded.
Definition at line 466 of file netintf.c.
Referenced by begin_lanserver_scan(), find_next_free_port(), net_lookup_service(), and server_open_socket().
void fc_init_network | ( | void | ) |
Initialize network stuff.
Definition at line 198 of file netintf.c.
Referenced by client_main(), fcmp_init(), and srv_prepare().
void fc_nonblock | ( | int | sockfd | ) |
Set socket to non-blocking.
Definition at line 227 of file netintf.c.
Referenced by begin_lanserver_scan(), server_make_connection(), and server_open_socket().
fz_FILE * fc_querysocket | ( | int | sock, |
void * | buf, | ||
size_t | size | ||
) |
int fc_readsocket | ( | int | sock, |
void * | buf, | ||
size_t | size | ||
) |
Read from a socket.
Definition at line 144 of file netintf.c.
Referenced by fc_querysocket(), and read_socket_data().
int fc_select | ( | int | n, |
fd_set * | readfds, | ||
fd_set * | writefds, | ||
fd_set * | exceptfds, | ||
fc_timeval * | timeout | ||
) |
Wait for a number of sockets to change status
Definition at line 125 of file netintf.c.
Referenced by fc_usleep(), flush_packets(), get_lanserver_announcement(), gui_event_loop(), read_from_connection(), server_sniff_all_input(), and write_socket_data().
void fc_shutdown_network | ( | void | ) |
Shutdown network stuff.
Definition at line 217 of file netintf.c.
Referenced by at_exit(), close_connections_and_socket(), and fcmp_deinit().
int fc_writesocket | ( | int | sock, |
const void * | buf, | ||
size_t | size | ||
) |
Write to a socket.
Definition at line 163 of file netintf.c.
Referenced by fc_querysocket(), and write_socket_data().
int find_next_free_port | ( | int | starting_port, |
int | highest_port, | ||
enum fc_addr_family | family, | ||
char * | net_interface, | ||
bool | not_avail_ok | ||
) |
Finds the next (lowest) free port.
Definition at line 560 of file netintf.c.
Referenced by client_start_server().
struct fc_sockaddr_list * net_lookup_service | ( | const char * | name, |
int | port, | ||
enum fc_addr_family | family | ||
) |
Look up the service at hostname:port.
Definition at line 411 of file netintf.c.
Referenced by get_server_address(), and server_open_socket().
void sockaddr_debug | ( | union fc_sockaddr * | addr, |
enum log_level | lvl | ||
) |
Write information about sockaddr to debug log.
Definition at line 269 of file netintf.c.
Referenced by server_open_socket().
bool sockaddr_ipv6 | ( | union fc_sockaddr * | addr | ) |
int sockaddr_size | ( | union fc_sockaddr * | addr | ) |
Gets size of address to fc_sockaddr. IPv6/IPv4 must be selected before calling this.
Definition at line 305 of file netintf.c.
Referenced by begin_lanserver_scan(), find_next_free_port(), send_lanserver_response(), server_open_socket(), and try_to_connect().