chiark / gitweb /
dbus: complete coverage for unit interface
[elogind.git] / src / dbus-socket.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <errno.h>
23
24 #include "dbus-unit.h"
25 #include "dbus-socket.h"
26 #include "dbus-execute.h"
27
28 #define BUS_SOCKET_INTERFACE                                            \
29         " <interface name=\"org.freedesktop.systemd1.Socket\">\n"       \
30         "  <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
31         "  <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n"   \
32         "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
33         BUS_EXEC_CONTEXT_INTERFACE                                      \
34         "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n"  \
35         "  <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
36         "  <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>\n" \
37         "  <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
38         "  <property name=\"SocketMode\" type=\"u\" access=\"read\"/>\n" \
39         "  <property name=\"Accept\" type=\"b\" access=\"read\"/>\n"    \
40         "  <property name=\"KeepAlive\" type=\"b\" access=\"read\"/>\n" \
41         "  <property name=\"Priority\" type=\"i\" access=\"read\"/>\n"  \
42         "  <property name=\"ReceiveBuffer\" type=\"t\" access=\"read\"/>\n" \
43         "  <property name=\"SendBuffer\" type=\"t\" access=\"read\"/>\n" \
44         "  <property name=\"IPTOS\" type=\"i\" access=\"read\"/>\n"     \
45         "  <property name=\"IPTTL\" type=\"i\" access=\"read\"/>\n"     \
46         "  <property name=\"PipeSize\" type=\"t\" access=\"read\"/>\n"  \
47         "  <property name=\"FreeBind\" type=\"b\" access=\"read\"/>\n"  \
48         "  <property name=\"Mark\" type=\"i\" access=\"read\"/>\n"      \
49         " </interface>\n"                                               \
50
51 #define INTROSPECTION                                                   \
52         DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
53         "<node>\n"                                                      \
54         BUS_UNIT_INTERFACE                                              \
55         BUS_SOCKET_INTERFACE                                            \
56         BUS_PROPERTIES_INTERFACE                                        \
57         BUS_INTROSPECTABLE_INTERFACE                                    \
58         "</node>\n"
59
60 const char bus_socket_interface[] = BUS_SOCKET_INTERFACE;
61
62 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
63
64 DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
65         const BusProperty properties[] = {
66                 BUS_UNIT_PROPERTIES,
67                 { "org.freedesktop.systemd1.Socket", "BindIPv6Only",  bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
68                 { "org.freedesktop.systemd1.Socket", "Backlog",       bus_property_append_unsigned, "u", &u->socket.backlog },
69                 { "org.freedesktop.systemd1.Socket", "TimeoutUSec",   bus_property_append_usec,     "t", &u->socket.timeout_usec },
70                 /* ExecCommand */
71                 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
72                 { "org.freedesktop.systemd1.Socket", "KillMode",      bus_unit_append_kill_mode,    "s", &u->socket.kill_mode },
73                 { "org.freedesktop.systemd1.Socket", "ControlPID",    bus_property_append_pid,      "u", &u->socket.control_pid },
74                 { "org.freedesktop.systemd1.Socket", "BindToDevice",  bus_property_append_string,   "s", u->socket.bind_to_device },
75                 { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode,     "u", &u->socket.directory_mode },
76                 { "org.freedesktop.systemd1.Socket", "SocketMode",    bus_property_append_mode,     "u", &u->socket.socket_mode },
77                 { "org.freedesktop.systemd1.Socket", "Accept",        bus_property_append_bool,     "b", &u->socket.accept },
78                 { "org.freedesktop.systemd1.Socket", "KeepAlive",     bus_property_append_bool,     "b", &u->socket.keep_alive },
79                 { "org.freedesktop.systemd1.Socket", "Priority",      bus_property_append_int,      "i", &u->socket.priority },
80                 { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size,     "t", &u->socket.receive_buffer },
81                 { "org.freedesktop.systemd1.Socket", "SendBuffer",    bus_property_append_size,     "t", &u->socket.send_buffer },
82                 { "org.freedesktop.systemd1.Socket", "IPTOS",         bus_property_append_int,      "i", &u->socket.ip_tos },
83                 { "org.freedesktop.systemd1.Socket", "IPTTL",         bus_property_append_int,      "i", &u->socket.ip_ttl },
84                 { "org.freedesktop.systemd1.Socket", "PipeSize",      bus_property_append_size,     "t", &u->socket.pipe_size },
85                 { "org.freedesktop.systemd1.Socket", "FreeBind",      bus_property_append_bool,     "b", &u->socket.free_bind },
86                 { "org.freedesktop.systemd1.Socket", "Mark",          bus_property_append_int,      "i", &u->socket.mark },
87                 { NULL, NULL, NULL, NULL, NULL }
88         };
89
90         return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
91 }