1
0
mirror of https://github.com/moparisthebest/socat synced 2024-11-10 19:15:03 -05:00
socat/sysutils.h

94 lines
2.7 KiB
C
Raw Normal View History

2008-01-28 16:37:16 -05:00
/* source: sysutils.h */
2008-09-22 16:17:55 -04:00
/* Copyright Gerhard Rieger 2001-2008 */
2008-01-27 07:00:08 -05:00
/* Published under the GNU General Public License V.2, see file COPYING */
#ifndef __sysutils_h_included
#define __sysutils_h_included 1
#if WITH_IP6
/* not all OSes provide in6_addr that allows splitting to 16 or 32 bit junks of
the host address part of sockaddr_in6; here we help ourselves */
union xioin6_u {
uint8_t u6_addr8[16];
uint16_t u6_addr16[8];
uint32_t u6_addr32[4];
} ;
#endif /* WITH_IP6 */
#if _WITH_SOCKET
2008-01-27 07:00:08 -05:00
union sockaddr_union {
struct sockaddr soa;
#if WITH_UNIX
struct sockaddr_un un;
#endif /* WITH_UNIX */
#if _WITH_IP4
2008-01-27 07:00:08 -05:00
struct sockaddr_in ip4;
#endif /* _WITH_IP4 */
2008-01-27 07:00:08 -05:00
#if WITH_IP6
struct sockaddr_in6 ip6;
#endif /* WITH_IP6 */
} ;
#endif /* _WITH_SOCKET */
2008-01-27 07:00:08 -05:00
#if _WITH_SOCKET
struct xiorange {
union sockaddr_union netaddr;
union sockaddr_union netmask;
2008-01-27 07:00:08 -05:00
} ;
#endif /* _WITH_SOCKET */
#if _WITH_SOCKET
extern socklen_t socket_init(int af, union sockaddr_union *sa);
#endif
#if WITH_UNIX
extern void socket_un_init(struct sockaddr_un *sa);
#endif /* WITH_UNIX */
#if _WITH_IP4
extern void socket_in_init(struct sockaddr_in *sa);
#endif /* _WITH_IP4 */
#if _WITH_IP6
extern void socket_in6_init(struct sockaddr_in6 *sa);
#endif /* _WITH_IP4 */
#if _WITH_SOCKET
extern char *sockaddr_info(const struct sockaddr *sa, socklen_t salen, char *buff, size_t blen);
#endif
#if WITH_UNIX
extern char *sockaddr_unix_info(const struct sockaddr_un *sa, socklen_t salen, char *buff, size_t blen);
#endif /* WITH_UNIX */
#if WITH_IP4
extern char *inet4addr_info(uint32_t addr, char *buff, size_t blen);
extern char *sockaddr_inet4_info(const struct sockaddr_in *sa, char *buff, size_t blen);
#endif /* WITH_IP4 */
#if WITH_IP6
extern char *sockaddr_inet6_info(const struct sockaddr_in6 *sa, char *buff, size_t blen);
#endif /* WITH_IP6 */
#if !HAVE_INET_NTOP
extern const char *inet_ntop(int pf, const void *binaddr,
char *addrtext, socklen_t textlen);
#endif
extern int getusergroups(const char *user, gid_t *list, size_t *ngroups);
#if !HAVE_HSTRERROR
extern const char *hstrerror(int err);
#endif
2008-10-12 06:01:00 -04:00
extern int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout);
2008-07-24 15:51:38 -04:00
2008-01-27 07:00:08 -05:00
extern int parseport(const char *portname, int proto);
extern int ifindexbyname(const char *ifname, int anysock);
extern int ifindex(const char *ifname, unsigned int *ifindex, int anysock);
2008-01-27 07:00:08 -05:00
2008-09-22 16:17:55 -04:00
extern int xiosetenv(const char *varname, const char *value, int overwrite);
extern int
xiosetenv2(const char *varname, const char *varname2, const char *value,
int overwrite);
extern int xiosetenvulong(const char *varname, unsigned long value,
int overwrite);
extern int xiosetenvushort(const char *varname, unsigned short value,
int overwrite);
2008-01-27 07:00:08 -05:00
#endif /* !defined(__sysutils_h_included) */