version 1.7.3.0
[socat.git] / sysutils.h
blob906aa59bfcece32bc813fbda431779a12fc843ff
1 /* source: sysutils.h */
2 /* Copyright Gerhard Rieger */
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 #if WITH_INTERFACE
31 struct sockaddr_ll ll;
32 #endif
33 } ;
34 #endif /* _WITH_SOCKET */
36 #if _WITH_SOCKET
37 struct xiorange {
38 union sockaddr_union netaddr;
39 union sockaddr_union netmask;
40 } ;
41 #endif /* _WITH_SOCKET */
43 extern ssize_t writefull(int fd, const void *buff, size_t bytes);
45 #if _WITH_SOCKET
46 extern socklen_t socket_init(int af, union sockaddr_union *sa);
47 #endif
48 #if WITH_UNIX
49 extern void socket_un_init(struct sockaddr_un *sa);
50 #endif /* WITH_UNIX */
51 #if _WITH_IP4
52 extern void socket_in_init(struct sockaddr_in *sa);
53 #endif /* _WITH_IP4 */
54 #if _WITH_IP6
55 extern void socket_in6_init(struct sockaddr_in6 *sa);
56 #endif /* _WITH_IP4 */
58 #if _WITH_SOCKET
59 extern char *sockaddr_info(const struct sockaddr *sa, socklen_t salen, char *buff, size_t blen);
60 #endif
61 #if WITH_UNIX
62 extern char *sockaddr_unix_info(const struct sockaddr_un *sa, socklen_t salen, char *buff, size_t blen);
63 #endif /* WITH_UNIX */
64 #if WITH_IP4
65 extern char *inet4addr_info(uint32_t addr, char *buff, size_t blen);
66 extern char *sockaddr_inet4_info(const struct sockaddr_in *sa, char *buff, size_t blen);
67 #endif /* WITH_IP4 */
68 #if WITH_IP6
69 extern char *sockaddr_inet6_info(const struct sockaddr_in6 *sa, char *buff, size_t blen);
70 #endif /* WITH_IP6 */
71 #if !HAVE_INET_NTOP
72 extern const char *inet_ntop(int pf, const void *binaddr,
73 char *addrtext, socklen_t textlen);
74 #endif
76 #if defined(HAVE_SETGRENT) && defined(HAVE_GETGRENT) && defined(HAVE_ENDGRENT)
77 extern int getusergroups(const char *user, gid_t *list, int *ngroups);
78 #endif
80 #if !HAVE_HSTRERROR
81 extern const char *hstrerror(int err);
82 #endif
84 extern int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout);
86 extern int parseport(const char *portname, int proto);
88 extern int ifindexbyname(const char *ifname, int anysock);
89 extern int ifindex(const char *ifname, unsigned int *ifindex, int anysock);
91 extern int xiosetenv(const char *varname, const char *value, int overwrite, const char *sep);
92 extern int
93 xiosetenv2(const char *varname, const char *varname2, const char *value,
94 int overwrite, const char *sep);
95 extern int
96 xiosetenv3(const char *varname, const char *varname2, const char *varname3,
97 const char *value, int overwrite, const char *sep);
98 extern int xiosetenvulong(const char *varname, unsigned long value,
99 int overwrite);
100 extern int xiosetenvushort(const char *varname, unsigned short value,
101 int overwrite);
103 #endif /* !defined(__sysutils_h_included) */