1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
3 #ifndef foosocketutilhfoo
4 #define foosocketutilhfoo
6 #include <sys/socket.h>
7 #include <netinet/in.h>
14 typedef struct SocketAddress
{
17 struct sockaddr_in in4
;
18 struct sockaddr_in6 in6
;
19 struct sockaddr_un un
;
20 struct sockaddr_storage storage
;
23 /* We store the size here explicitly due to the weird
24 * sockaddr_un semantics for abstract sockets */
27 /* Socket type, i.e. SOCK_STREAM, SOCK_DGRAM, ... */
31 typedef enum SocketAddressBindIPv6Only
{
32 SOCKET_ADDRESS_DEFAULT
,
34 SOCKET_ADDRESS_IPV6_ONLY
35 } SocketAddressBindIPv6Only
;
37 #define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
39 int socket_address_parse(SocketAddress
*a
, const char *s
);
40 int socket_address_print(const SocketAddress
*a
, char **p
);
41 int socket_address_verify(const SocketAddress
*a
);
42 int socket_address_listen(const SocketAddress
*a
, int backlog
, SocketAddressBindIPv6Only only
, const char *bind_to_device
, int *ret
);