]> git.ipfire.org Git - thirdparty/systemd.git/blame - socket-util.h
fully clean up job dependencies on abort, too
[thirdparty/systemd.git] / socket-util.h
CommitLineData
42f4e3c4
LP
1/*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3#ifndef foosocketutilhfoo
4#define foosocketutilhfoo
5
6#include <sys/socket.h>
7#include <netinet/in.h>
8#include <sys/un.h>
9
10#include "macro.h"
11#include "util.h"
12
542563ba 13typedef struct SocketAddress {
42f4e3c4
LP
14 union {
15 struct sockaddr sa;
16 struct sockaddr_in in4;
17 struct sockaddr_in6 in6;
18 struct sockaddr_un un;
19 struct sockaddr_storage storage;
20 } sockaddr;
21
22 /* We store the size here explicitly due to the weird
23 * sockaddr_un semantics for abstract sockets */
24 socklen_t size;
25
26 /* Socket type, i.e. SOCK_STREAM, SOCK_DGRAM, ... */
27 int type;
542563ba 28} SocketAddress;
42f4e3c4 29
542563ba
LP
30typedef enum SocketAddressBindIPv6Only {
31 SOCKET_ADDRESS_DEFAULT,
32 SOCKET_ADDRESS_BOTH,
33 SOCKET_ADDRESS_IPV6_ONLY
34} SocketAddressBindIPv6Only;
42f4e3c4 35
542563ba 36#define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
42f4e3c4 37
542563ba
LP
38int socket_address_parse(SocketAddress *a, const char *s);
39int socket_address_print(const SocketAddress *a, char **p);
40int socket_address_verify(const SocketAddress *a);
83c60c9f 41int socket_address_listen(const SocketAddress *a, int backlog, SocketAddressBindIPv6Only only, int *ret);
42f4e3c4
LP
42
43#endif