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
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 */
13 uint16_t u6_addr16
[8];
14 uint32_t u6_addr32
[4];
19 union sockaddr_union
{
22 struct sockaddr_un un
;
23 #endif /* WITH_UNIX */
25 struct sockaddr_in ip4
;
26 #endif /* _WITH_IP4 */
28 struct sockaddr_in6 ip6
;
31 #endif /* _WITH_SOCKET */
35 union sockaddr_union netaddr
;
36 union sockaddr_union netmask
;
38 #endif /* _WITH_SOCKET */
41 extern socklen_t
socket_init(int af
, union sockaddr_union
*sa
);
44 extern void socket_un_init(struct sockaddr_un
*sa
);
45 #endif /* WITH_UNIX */
47 extern void socket_in_init(struct sockaddr_in
*sa
);
48 #endif /* _WITH_IP4 */
50 extern void socket_in6_init(struct sockaddr_in6
*sa
);
51 #endif /* _WITH_IP4 */
54 extern char *sockaddr_info(const struct sockaddr
*sa
, socklen_t salen
, char *buff
, size_t blen
);
57 extern char *sockaddr_unix_info(const struct sockaddr_un
*sa
, socklen_t salen
, char *buff
, size_t blen
);
58 #endif /* WITH_UNIX */
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
);
64 extern char *sockaddr_inet6_info(const struct sockaddr_in6
*sa
, char *buff
, size_t blen
);
67 extern const char *inet_ntop(int pf
, const void *binaddr
,
68 char *addrtext
, socklen_t textlen
);
71 extern int getusergroups(const char *user
, gid_t
*list
, size_t *ngroups
);
74 extern const char *hstrerror(int err
);
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
);
86 xiosetenv2(const char *varname
, const char *varname2
, const char *value
,
88 extern int xiosetenvulong(const char *varname
, unsigned long value
,
90 extern int xiosetenvushort(const char *varname
, unsigned short value
,
93 #endif /* !defined(__sysutils_h_included) */