]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/dbus-socket.c
sd-journal: implement a number of non-implemented calls from the API for now
[thirdparty/systemd.git] / src / dbus-socket.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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 #include "dbus-common.h"
28
29 #define BUS_SOCKET_INTERFACE \
30 " <interface name=\"org.freedesktop.systemd1.Socket\">\n" \
31 " <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>\n" \
32 " <property name=\"Backlog\" type=\"u\" access=\"read\"/>\n" \
33 " <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>\n" \
34 BUS_EXEC_COMMAND_INTERFACE("ExecStartPre") \
35 BUS_EXEC_COMMAND_INTERFACE("ExecStartPost") \
36 BUS_EXEC_COMMAND_INTERFACE("ExecStopPre") \
37 BUS_EXEC_COMMAND_INTERFACE("ExecStopPost") \
38 BUS_EXEC_CONTEXT_INTERFACE \
39 " <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
40 " <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>\n" \
41 " <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>\n" \
42 " <property name=\"SocketMode\" type=\"u\" access=\"read\"/>\n" \
43 " <property name=\"Accept\" type=\"b\" access=\"read\"/>\n" \
44 " <property name=\"KeepAlive\" type=\"b\" access=\"read\"/>\n" \
45 " <property name=\"Priority\" type=\"i\" access=\"read\"/>\n" \
46 " <property name=\"ReceiveBuffer\" type=\"t\" access=\"read\"/>\n" \
47 " <property name=\"SendBuffer\" type=\"t\" access=\"read\"/>\n" \
48 " <property name=\"IPTOS\" type=\"i\" access=\"read\"/>\n" \
49 " <property name=\"IPTTL\" type=\"i\" access=\"read\"/>\n" \
50 " <property name=\"PipeSize\" type=\"t\" access=\"read\"/>\n" \
51 " <property name=\"FreeBind\" type=\"b\" access=\"read\"/>\n" \
52 " <property name=\"Transparent\" type=\"b\" access=\"read\"/>\n" \
53 " <property name=\"Broadcast\" type=\"b\" access=\"read\"/>\n" \
54 " <property name=\"PassCredentials\" type=\"b\" access=\"read\"/>\n" \
55 " <property name=\"Mark\" type=\"i\" access=\"read\"/>\n" \
56 " <property name=\"MaxConnections\" type=\"u\" access=\"read\"/>\n" \
57 " <property name=\"NAccepted\" type=\"u\" access=\"read\"/>\n" \
58 " <property name=\"NConnections\" type=\"u\" access=\"read\"/>\n" \
59 " <property name=\"MessageQueueMaxMessages\" type=\"x\" access=\"read\"/>\n" \
60 " <property name=\"MessageQueueMessageSize\" type=\"x\" access=\"read\"/>\n" \
61 " </interface>\n" \
62
63 #define INTROSPECTION \
64 DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
65 "<node>\n" \
66 BUS_UNIT_INTERFACE \
67 BUS_SOCKET_INTERFACE \
68 BUS_PROPERTIES_INTERFACE \
69 BUS_PEER_INTERFACE \
70 BUS_INTROSPECTABLE_INTERFACE \
71 "</node>\n"
72
73 #define INTERFACES_LIST \
74 BUS_UNIT_INTERFACES_LIST \
75 "org.freedesktop.systemd1.Socket\0"
76
77 const char bus_socket_interface[] _introspect_("Socket") = BUS_SOCKET_INTERFACE;
78
79 const char bus_socket_invalidating_properties[] =
80 "ExecStartPre\0"
81 "ExecStartPost\0"
82 "ExecStopPre\0"
83 "ExecStopPost\0"
84 "ControlPID\0"
85 "NAccepted\0"
86 "NConnections\0";
87
88 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
89
90 DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
91
92 const BusProperty properties[] = {
93 BUS_UNIT_PROPERTIES,
94 { "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
95 { "org.freedesktop.systemd1.Socket", "Backlog", bus_property_append_unsigned, "u", &u->socket.backlog },
96 { "org.freedesktop.systemd1.Socket", "TimeoutUSec", bus_property_append_usec, "t", &u->socket.timeout_usec },
97 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_PRE], "ExecStartPre"),
98 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_START_POST], "ExecStartPost"),
99 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_PRE], "ExecStopPre"),
100 BUS_EXEC_COMMAND_PROPERTY("org.freedesktop.systemd1.Socket", u->service.exec_command[SOCKET_EXEC_STOP_POST], "ExecStopPost"),
101 BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
102 { "org.freedesktop.systemd1.Socket", "ControlPID", bus_property_append_pid, "u", &u->socket.control_pid },
103 { "org.freedesktop.systemd1.Socket", "BindToDevice", bus_property_append_string, "s", u->socket.bind_to_device },
104 { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode, "u", &u->socket.directory_mode },
105 { "org.freedesktop.systemd1.Socket", "SocketMode", bus_property_append_mode, "u", &u->socket.socket_mode },
106 { "org.freedesktop.systemd1.Socket", "Accept", bus_property_append_bool, "b", &u->socket.accept },
107 { "org.freedesktop.systemd1.Socket", "KeepAlive", bus_property_append_bool, "b", &u->socket.keep_alive },
108 { "org.freedesktop.systemd1.Socket", "Priority", bus_property_append_int, "i", &u->socket.priority },
109 { "org.freedesktop.systemd1.Socket", "ReceiveBuffer", bus_property_append_size, "t", &u->socket.receive_buffer },
110 { "org.freedesktop.systemd1.Socket", "SendBuffer", bus_property_append_size, "t", &u->socket.send_buffer },
111 { "org.freedesktop.systemd1.Socket", "IPTOS", bus_property_append_int, "i", &u->socket.ip_tos },
112 { "org.freedesktop.systemd1.Socket", "IPTTL", bus_property_append_int, "i", &u->socket.ip_ttl },
113 { "org.freedesktop.systemd1.Socket", "PipeSize", bus_property_append_size, "t", &u->socket.pipe_size },
114 { "org.freedesktop.systemd1.Socket", "FreeBind", bus_property_append_bool, "b", &u->socket.free_bind },
115 { "org.freedesktop.systemd1.Socket", "Transparent", bus_property_append_bool, "b", &u->socket.transparent },
116 { "org.freedesktop.systemd1.Socket", "Broadcast", bus_property_append_bool, "b", &u->socket.broadcast },
117 { "org.freedesktop.systemd1.Socket", "PassCredentials",bus_property_append_bool, "b", &u->socket.pass_cred },
118 { "org.freedesktop.systemd1.Socket", "Mark", bus_property_append_int, "i", &u->socket.mark },
119 { "org.freedesktop.systemd1.Socket", "MaxConnections", bus_property_append_unsigned, "u", &u->socket.max_connections },
120 { "org.freedesktop.systemd1.Socket", "NConnections", bus_property_append_unsigned, "u", &u->socket.n_connections },
121 { "org.freedesktop.systemd1.Socket", "NAccepted", bus_property_append_unsigned, "u", &u->socket.n_accepted },
122 { "org.freedesktop.systemd1.Socket", "MessageQueueMaxMessages", bus_property_append_long,"x", &u->socket.mq_maxmsg },
123 { "org.freedesktop.systemd1.Socket", "MessageQueueMessageSize", bus_property_append_long,"x", &u->socket.mq_msgsize },
124 { NULL, NULL, NULL, NULL, NULL }
125 };
126
127 return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
128 }