diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-04 11:44:37 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-02-05 11:50:34 +0100 |
commit | e331e24649213f2e093e16e4d3d64ee823dfc375 (patch) | |
tree | d21fa218f79f2621d6d61f071e846cc6465458c1 /src/network/networkd-manager.c | |
parent | 6a24f1484fcc1f59f89617afbe4282667a358eab (diff) |
networkd: add basic dbus API
Only the very basics, more to come.
For now:
$ busctl tree org.freedesktop.network1
└─/org/freedesktop/network1
└─/org/freedesktop/network1/link
├─/org/freedesktop/network1/link/1
├─/org/freedesktop/network1/link/2
├─/org/freedesktop/network1/link/3
├─/org/freedesktop/network1/link/4
├─/org/freedesktop/network1/link/5
├─/org/freedesktop/network1/link/6
├─/org/freedesktop/network1/link/7
├─/org/freedesktop/network1/link/8
└─/org/freedesktop/network1/link/9
$ busctl introspect org.freedesktop.network1 /org/freedesktop/network1
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.network1.Manager interface - - -
.OperationalState property s "carrier" emits-change
$ busctl introspect org.freedesktop.network1 /org/freedesktop/network1/link/1
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.network1.Link interface - - -
.AdministrativeState property s "unmanaged" emits-change
.OperationalState property s "carrier" emits-change
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r-- | src/network/networkd-manager.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 4d27272b3b..40328a36c9 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -151,10 +151,6 @@ int manager_connect_bus(Manager *m) { } if (r < 0) return r; - r = sd_bus_attach_event(m->bus, m->event, 0); - if (r < 0) - return r; - r = sd_bus_add_match(m->bus, &m->prepare_for_sleep_slot, "type='signal'," "sender='org.freedesktop.login1'," @@ -166,6 +162,26 @@ int manager_connect_bus(Manager *m) { if (r < 0) return log_error_errno(r, "Failed to add match for PrepareForSleep: %m"); + r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/network1", "org.freedesktop.network1.Manager", manager_vtable, m); + if (r < 0) + return log_error_errno(r, "Failed to add manager object vtable: %m"); + + r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/network1/link", "org.freedesktop.network1.Link", link_vtable, link_object_find, m); + if (r < 0) + return log_error_errno(r, "Failed to add link object vtable: %m"); + + r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/network1/link", link_node_enumerator, m); + if (r < 0) + return log_error_errno(r, "Failed to add link enumerator: %m"); + + r = sd_bus_request_name(m->bus, "org.freedesktop.network1", 0); + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); + + r = sd_bus_attach_event(m->bus, m->event, 0); + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); + return 0; } @@ -741,6 +757,13 @@ int manager_save(Manager *m) { goto fail; } + if (m->operational_state != operstate) { + m->operational_state = operstate; + r = manager_send_changed(m, "OperationalState", NULL); + if (r < 0) + log_error_errno(r, "Could not emit changed OperationalState: %m"); + } + return 0; fail: |