summaryrefslogtreecommitdiff
path: root/socket-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-01-19 02:56:37 +0100
committerLennart Poettering <lennart@poettering.net>2010-01-19 02:56:37 +0100
commit42f4e3c4413ad35e3815f25211fee95d775488a7 (patch)
treef9b69266acc05db37467ee6c0383969ca9c21081 /socket-util.h
parenta66d02c3290008d50b2b52f84cfbf46a546ba831 (diff)
parse socket files properly
Diffstat (limited to 'socket-util.h')
-rw-r--r--socket-util.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/socket-util.h b/socket-util.h
new file mode 100644
index 0000000000..711f7740a8
--- /dev/null
+++ b/socket-util.h
@@ -0,0 +1,40 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foosocketutilhfoo
+#define foosocketutilhfoo
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+
+#include "macro.h"
+#include "util.h"
+
+typedef struct Address {
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in in4;
+ struct sockaddr_in6 in6;
+ struct sockaddr_un un;
+ struct sockaddr_storage storage;
+ } sockaddr;
+
+ /* We store the size here explicitly due to the weird
+ * sockaddr_un semantics for abstract sockets */
+ socklen_t size;
+
+ /* Socket type, i.e. SOCK_STREAM, SOCK_DGRAM, ... */
+ int type;
+
+ /* Only for INET6 sockets: issue IPV6_V6ONLY sockopt */
+ bool bind_ipv6_only;
+} Address;
+
+#define address_family(a) ((a)->sockaddr.sa.sa_family)
+
+int address_parse(Address *a, const char *s);
+int address_print(const Address *a, char **p);
+int address_verify(const Address *a);
+int address_listen(const Address *a, int backlog);
+
+#endif