[systemd-devel] [PATCH] [RFC] Show listen addresses in status output
Oleksii Shevchuk
alxchk at gmail.com
Sun Mar 31 14:09:50 PDT 2013
---
src/systemctl/systemctl.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 328b91b..0ad5112 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2254,6 +2254,7 @@ typedef struct UnitStatusInfo {
unsigned n_accepted;
unsigned n_connections;
bool accept;
+ char **listen;
/* Device */
const char *sysfs_path;
@@ -2386,6 +2387,19 @@ static void print_status_info(UnitStatusInfo *i) {
}
}
+ if (!strv_isempty(i->listen)) {
+ char **t;
+ bool first = true;
+
+ STRV_FOREACH(t, i->listen) {
+ if (first) {
+ printf("\t Listen: %s\n", *t);
+ first = false;
+ } else
+ printf("\t %s\n", *t);
+ }
+ }
+
if (i->accept)
printf("\tAccepted: %u; Connected: %u\n", i->n_accepted, i->n_connections);
@@ -2757,6 +2771,27 @@ static int status_property(const char *name, DBusMessageIter *iter, UnitStatusIn
dbus_message_iter_next(&sub);
}
+
+ } else if (dbus_message_iter_get_element_type(iter) == DBUS_TYPE_STRING &&
+ startswith(name, "Listen")) {
+ DBusMessageIter sub;
+
+ dbus_message_iter_recurse(iter, &sub);
+ while (dbus_message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) {
+ const char *s;
+ char **l;
+
+ dbus_message_iter_get_basic(&sub, &s);
+
+ l = strv_append(i->listen, s);
+ if (!l)
+ return -ENOMEM;
+
+ strv_free(i->listen);
+ i->listen = l;
+
+ dbus_message_iter_next(&sub);
+ }
}
break;
--
1.8.1.2
More information about the systemd-devel
mailing list