[systemd-devel] [PATCH] Add Listen* to dbus properties
Oleksii Shevchuk
alxchk at gmail.com
Sun Mar 31 08:23:24 PDT 2013
---
src/core/dbus-socket.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c
index 2092a63..1dfac6d 100644
--- a/src/core/dbus-socket.c
+++ b/src/core/dbus-socket.c
@@ -63,6 +63,10 @@
" <property name=\"NConnections\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"MessageQueueMaxMessages\" type=\"x\" access=\"read\"/>\n" \
" <property name=\"MessageQueueMessageSize\" type=\"x\" access=\"read\"/>\n" \
+ " <property name=\"ListenSocket\" type=\"as\" access=\"read\"/>\n" \
+ " <property name=\"ListenSpecial\" type=\"as\" access=\"read\"/>\n" \
+ " <property name=\"ListenMessageQueue\" type=\"as\" access=\"read\"/>\n" \
+ " <property name=\"ListenFIFO\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"Result\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"SmackLabel\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"SmackLabelIPIn\" type=\"s\" access=\"read\"/>\n" \
@@ -98,6 +102,52 @@ const char bus_socket_invalidating_properties[] =
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_socket_result, socket_result, SocketResult);
+static int bus_socket_append_listen(DBusMessageIter *i, const char *property, void *data) {
+ Unit *u = data;
+ SocketPort *p;
+ Socket *s = SOCKET(u);
+ DBusMessageIter sub;
+
+ assert(data);
+ assert(s);
+
+ if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+ return -ENOMEM;
+
+ LIST_FOREACH(port, p, s->ports) {
+
+ if ((p->type == SOCKET_SOCKET) && (streq(property, "ListenSocket"))) {
+ char *t, *k;
+ int r;
+
+ r = socket_address_print(&p->address, &t);
+ if (r && !k)
+ k = strerror(-errno);
+ else
+ k = t;
+
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &k))
+ return -ENOMEM;
+
+ free(t);
+ } else if ((p->type == SOCKET_SPECIAL) && (streq(property, "ListenSpecial"))) {
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &p->path))
+ return -ENOMEM;
+ } else if ((p->type == SOCKET_MQUEUE) && (streq(property, "ListenMessageQueue"))) {
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &p->path))
+ return -ENOMEM;
+ } else if ((p->type == SOCKET_FIFO) && (streq(property, "ListenFIFO"))) {
+ if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &p->path))
+ return -ENOMEM;
+ }
+ }
+
+ if (!dbus_message_iter_close_container(i, &sub))
+ return -ENOMEM;
+
+ return 0;
+}
+
static const BusProperty bus_socket_properties[] = {
{ "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", offsetof(Socket, bind_ipv6_only) },
{ "Backlog", bus_property_append_unsigned, "u", offsetof(Socket, backlog) },
@@ -123,6 +173,10 @@ static const BusProperty bus_socket_properties[] = {
{ "Broadcast", bus_property_append_bool, "b", offsetof(Socket, broadcast) },
{ "PassCredentials",bus_property_append_bool, "b", offsetof(Socket, pass_cred) },
{ "PassSecurity", bus_property_append_bool, "b", offsetof(Socket, pass_sec) },
+ { "ListenSocket", bus_socket_append_listen, "as", 0, },
+ { "ListenSpecial", bus_socket_append_listen, "as", 0, },
+ { "ListenMessageQueue", bus_socket_append_listen, "as", 0, },
+ { "ListenFIFO", bus_socket_append_listen, "as", 0, },
{ "Mark", bus_property_append_int, "i", offsetof(Socket, mark) },
{ "MaxConnections", bus_property_append_unsigned, "u", offsetof(Socket, max_connections) },
{ "NConnections", bus_property_append_unsigned, "u", offsetof(Socket, n_connections) },
--
1.8.1.2
More information about the systemd-devel
mailing list