Freeciv-3.2
Loading...
Searching...
No Matches
netintf.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__NETINTF_H
15#define FC__NETINTF_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21#include <freeciv_config.h>
22
23/***********************************************************************
24 Common network interface.
25***********************************************************************/
26
27#ifdef FREECIV_HAVE_NETINET_IN_H
28#include <netinet/in.h>
29#endif
30#ifdef FREECIV_HAVE_SYS_SELECT_H
31#include <sys/select.h>
32#endif
33#ifdef FREECIV_HAVE_SYS_SOCKET_H
34#include <sys/socket.h>
35#endif
36#ifdef FREECIV_HAVE_SYS_TIME_H
37#include <sys/time.h>
38#endif
39#ifdef FREECIV_HAVE_SYS_TYPES_H
40#include <sys/types.h>
41#endif
42#ifdef FREECIV_HAVE_UNISTD_H
43#include <unistd.h>
44#endif
45#ifdef FREECIV_HAVE_WS2TCPIP_H
46#include <ws2tcpip.h>
47#endif
48
49/* utility */
50#include "ioz.h"
51#include "net_types.h"
52#include "support.h" /* bool type */
53
54#ifdef FD_ZERO
55#define FC_FD_ZERO FD_ZERO
56#else
57#define FC_FD_ZERO(p) memset((void *)(p), 0, sizeof(*(p)))
58#endif
59
60#ifdef IPV6_ADD_MEMBERSHIP
61#define FC_IPV6_ADD_MEMBERSHIP IPV6_ADD_MEMBERSHIP
62#else
63#define FC_IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
64#endif
65
66#ifndef FREECIV_HAVE_SOCKLEN_T
67typedef int socklen_t;
68#endif /* FREECIV_HAVE_SOCKLEN_T */
69
73#ifdef FREECIV_IPV6_SUPPORT
75#endif /* FREECIV_IPV6_SUPPORT */
76};
77
78/* get 'struct sockaddr_list' and related functions: */
79#define SPECLIST_TAG fc_sockaddr
80#define SPECLIST_TYPE union fc_sockaddr
81#include "speclist.h"
82
83#define fc_sockaddr_list_iterate(sockaddrlist, paddr) \
84 TYPED_LIST_ITERATE(union fc_sockaddr, sockaddrlist, paddr)
85#define fc_sockaddr_list_iterate_end LIST_ITERATE_END
86
87#ifdef FREECIV_MSWINDOWS
88typedef TIMEVAL fc_timeval;
89#else /* FREECIV_MSWINDOWS */
90typedef struct timeval fc_timeval;
91#endif /* FREECIV_MSWINDOWS */
92
93int fc_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
95 fc_timeval *timeout);
96int fc_readsocket(int sock, void *buf, size_t size);
97int fc_writesocket(int sock, const void *buf, size_t size);
98void fc_closesocket(int sock);
99
100void fc_nonblock(int sockfd);
101struct fc_sockaddr_list *net_lookup_service(const char *name, int port,
103bool fc_inet_aton(const char *cp, struct in_addr *inp, bool addr_none_ok);
104fz_FILE *fc_querysocket(int sock, void *buf, size_t size);
107 char *net_interface, bool not_avail_ok);
108
109void sockaddr_debug(union fc_sockaddr *addr, enum log_level lvl);
110int sockaddr_size(union fc_sockaddr *addr);
111bool sockaddr_ipv6(union fc_sockaddr *addr);
112
113#ifdef __cplusplus
114}
115#endif /* __cplusplus */
116
117#endif /* FC__NETINTF_H */
#define n
Definition astring.c:77
char * incite_cost
Definition comments.c:75
const char * name
Definition inputfile.c:127
log_level
Definition log.h:28
fc_addr_family
Definition net_types.h:61
struct timeval fc_timeval
Definition netintf.h:90
int socklen_t
Definition netintf.h:67
bool fc_inet_aton(const char *cp, struct in_addr *inp, bool addr_none_ok)
Definition netintf.c:466
bool sockaddr_ipv6(union fc_sockaddr *addr)
Definition netintf.c:330
struct fc_sockaddr_list * net_lookup_service(const char *name, int port, enum fc_addr_family family)
Definition netintf.c:411
void fc_closesocket(int sock)
Definition netintf.c:186
void sockaddr_debug(union fc_sockaddr *addr, enum log_level lvl)
Definition netintf.c:269
int find_next_free_port(int starting_port, int highest_port, enum fc_addr_family family, char *net_interface, bool not_avail_ok)
Definition netintf.c:560
int sockaddr_size(union fc_sockaddr *addr)
Definition netintf.c:305
int fc_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
Definition netintf.c:107
int fc_readsocket(int sock, void *buf, size_t size)
Definition netintf.c:144
int fc_writesocket(int sock, const void *buf, size_t size)
Definition netintf.c:163
void fc_nonblock(int sockfd)
Definition netintf.c:227
int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout)
Definition netintf.c:125
fz_FILE * fc_querysocket(int sock, void *buf, size_t size)
Definition netintf.c:493
size_t size
Definition specvec.h:72
struct sockaddr saddr
Definition netintf.h:71
struct sockaddr_in saddr_in4
Definition netintf.h:72