Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
netintf.h File Reference
#include <freeciv_config.h>
#include "ioz.h"
#include "net_types.h"
#include "support.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

union  fc_sockaddr
 

Macros

#define FC_FD_ZERO(p)   memset((void *)(p), 0, sizeof(*(p)))
 
#define FC_IPV6_ADD_MEMBERSHIP   IPV6_JOIN_GROUP
 
#define SPECLIST_TAG   fc_sockaddr
 
#define SPECLIST_TYPE   union fc_sockaddr
 
#define fc_sockaddr_list_iterate(sockaddrlist, paddr)    TYPED_LIST_ITERATE(union fc_sockaddr, sockaddrlist, paddr)
 
#define fc_sockaddr_list_iterate_end   LIST_ITERATE_END
 

Typedefs

typedef int socklen_t
 
typedef struct timeval fc_timeval
 

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_nonblock (int sockfd)
 
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)
 
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)
 

Macro Definition Documentation

◆ FC_FD_ZERO

#define FC_FD_ZERO (   p)    memset((void *)(p), 0, sizeof(*(p)))

Definition at line 57 of file netintf.h.

◆ FC_IPV6_ADD_MEMBERSHIP

#define FC_IPV6_ADD_MEMBERSHIP   IPV6_JOIN_GROUP

Definition at line 63 of file netintf.h.

◆ fc_sockaddr_list_iterate

#define fc_sockaddr_list_iterate (   sockaddrlist,
  paddr 
)     TYPED_LIST_ITERATE(union fc_sockaddr, sockaddrlist, paddr)

Definition at line 83 of file netintf.h.

◆ fc_sockaddr_list_iterate_end

#define fc_sockaddr_list_iterate_end   LIST_ITERATE_END

Definition at line 85 of file netintf.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   fc_sockaddr

Definition at line 79 of file netintf.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   union fc_sockaddr

Definition at line 80 of file netintf.h.

Typedef Documentation

◆ fc_timeval

Definition at line 90 of file netintf.h.

◆ socklen_t

Definition at line 67 of file netintf.h.

Function Documentation

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