Freeciv-3.3
Loading...
Searching...
No Matches
Macros | Functions
netintf.c File Reference
#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_listnet_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_FILEfc_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)
 

Macro Definition Documentation

◆ INADDR_NONE

#define INADDR_NONE   0xffffffff

Definition at line 64 of file netintf.c.

Function Documentation

◆ addr_family_for_announce_type()

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().

◆ fc_closesocket()

void fc_closesocket ( int  sock)

◆ fc_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().

◆ fc_inet_aton()

bool fc_inet_aton ( const char cp,
struct in_addr inp,
bool  addr_none_ok 
)

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().

◆ fc_init_network()

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().

◆ fc_nonblock()

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().

◆ fc_querysocket()

fz_FILE * fc_querysocket ( int  sock,
void buf,
size_t  size 
)

Writes buf to socket and returns the response in a fz_FILE. Use only on blocking sockets.

Definition at line 493 of file netintf.c.

◆ fc_readsocket()

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().

◆ fc_select()

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(), gui_event_loop(), read_from_connection(), server_sniff_all_input(), and write_socket_data().

◆ fc_shutdown_network()

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().

◆ fc_writesocket()

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().

◆ find_next_free_port()

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().

◆ net_lookup_service()

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().

◆ sockaddr_debug()

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().

◆ sockaddr_ipv6()

bool sockaddr_ipv6 ( union fc_sockaddr addr)

Returns whether address is IPv6 address.

Definition at line 330 of file netintf.c.

◆ sockaddr_size()

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().