add listen-timeout to function as an accept timeout
[socat/sam.git] / sysutils.h
blob5d72b263401c99ce63096aae579a5c2ead8c88b6
1 /* source: sysutils.h */
2 /* Copyright Gerhard Rieger 2001-2008 */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __sysutils_h_included
6 #define __sysutils_h_included 1
8 #if WITH_IP6
9 /* not all OSes provide in6_addr that allows splitting to 16 or 32 bit junks of
10 the host address part of sockaddr_in6; here we help ourselves */
11 union xioin6_u {
12 uint8_t u6_addr8[16];
13 uint16_t u6_addr16[8];
14 uint32_t u6_addr32[4];
15 } ;
16 #endif /* WITH_IP6 */
18 #if _WITH_SOCKET
19 union sockaddr_union {
20 struct sockaddr soa;
21 #if WITH_UNIX
22 struct sockaddr_un un;
23 #endif /* WITH_UNIX */
24 #if _WITH_IP4
25 struct sockaddr_in ip4;
26 #endif /* _WITH_IP4 */
27 #if WITH_IP6
28 struct sockaddr_in6 ip6;
29 #endif /* WITH_IP6 */
30 } ;
31 #endif /* _WITH_SOCKET */
33 #if _WITH_SOCKET
34 struct xiorange {
35 union sockaddr_union netaddr;
36 union sockaddr_union netmask;
37 } ;
38 #endif /* _WITH_SOCKET */
40 #if _WITH_SOCKET
41 extern socklen_t socket_init(int af, union sockaddr_union *sa);
42 #endif
43 #if WITH_UNIX
44 extern void socket_un_init(struct sockaddr_un *sa);
45 #endif /* WITH_UNIX */
46 #if _WITH_IP4
47 extern void socket_in_init(struct sockaddr_in *sa);
48 #endif /* _WITH_IP4 */
49 #if _WITH_IP6
50 extern void socket_in6_init(struct sockaddr_in6 *sa);
51 #endif /* _WITH_IP4 */
53 #if _WITH_SOCKET
54 extern char *sockaddr_info(const struct sockaddr *sa, socklen_t salen, char *buff, size_t blen);
55 #endif
56 #if WITH_UNIX
57 extern char *sockaddr_unix_info(const struct sockaddr_un *sa, socklen_t salen, char *buff, size_t blen);
58 #endif /* WITH_UNIX */
59 #if WITH_IP4
60 extern char *inet4addr_info(uint32_t addr, char *buff, size_t blen);
61 extern char *sockaddr_inet4_info(const struct sockaddr_in *sa, char *buff, size_t blen);
62 #endif /* WITH_IP4 */
63 #if WITH_IP6
64 extern char *sockaddr_inet6_info(const struct sockaddr_in6 *sa, char *buff, size_t blen);
65 #endif /* WITH_IP6 */
66 #if !HAVE_INET_NTOP
67 extern const char *inet_ntop(int pf, const void *binaddr,
68 char *addrtext, socklen_t textlen);
69 #endif
71 extern int getusergroups(const char *user, gid_t *list, size_t *ngroups);
73 #if !HAVE_HSTRERROR
74 extern const char *hstrerror(int err);
75 #endif
77 extern int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout);
79 extern int parseport(const char *portname, int proto);
81 extern int ifindexbyname(const char *ifname, int anysock);
82 extern int ifindex(const char *ifname, unsigned int *ifindex, int anysock);
84 extern int xiosetenv(const char *varname, const char *value, int overwrite);
85 extern int
86 xiosetenv2(const char *varname, const char *varname2, const char *value,
87 int overwrite);
88 extern int xiosetenvulong(const char *varname, unsigned long value,
89 int overwrite);
90 extern int xiosetenvushort(const char *varname, unsigned short value,
91 int overwrite);
93 #endif /* !defined(__sysutils_h_included) */