return 0;
}
+static int __nw_daemon_reconfigure(sd_event_source* s, void* data) {
+ nw_daemon* daemon = (nw_daemon*)data;
+ int r;
+
+ DEBUG("Reconfiguring...\n");
+
+ // Reconfigure all zones
+ r = nw_zones_reconfigure(daemon->zones);
+ if (r)
+ return r;
+
+ // Reconfigure all ports
+ r = nw_ports_reconfigure(daemon->ports);
+ if (r)
+ return r;
+
+ return 0;
+}
+
+static int nw_daemon_reconfigure(nw_daemon* daemon) {
+ int r;
+
+ r = sd_event_add_defer(daemon->loop, NULL, __nw_daemon_reconfigure, daemon);
+ if (r) {
+ ERROR("Could not schedule re-configuration task: %m\n");
+ return r;
+ }
+
+ return 0;
+}
+
static int nw_daemon_setup(nw_daemon* daemon) {
int r;
if (r)
return r;
+ // (Re-)configure everything
+ r = nw_daemon_reconfigure(daemon);
+ if (r)
+ return r;
+
return 0;
}
return &port->address;
}
+int nw_port_reconfigure(nw_port* port) {
+ return 0; // XXX TODO
+}
+
int nw_port_has_carrier(nw_port* port) {
if (!port->link)
return 0;
const nw_address_t* nw_port_get_address(nw_port* port);
+int nw_port_reconfigure(nw_port* port);
+
int nw_port_has_carrier(nw_port* port);
#endif /* NETWORKD_PORT_H */
return 1;
}
+
+int nw_ports_walk(nw_ports* ports, nw_ports_walk_callback callback, void* data) {
+ struct nw_ports_entry* entry = NULL;
+ int r;
+
+ STAILQ_FOREACH(entry, &ports->entries, nodes) {
+ r = callback(ports->daemon, entry->port, data);
+ if (r)
+ return r;
+ }
+
+ return 0;
+}
+
+static int __nw_ports_reconfigure(nw_daemon* daemon, nw_port* port, void* data) {
+ return nw_port_reconfigure(port);
+}
+
+int nw_ports_reconfigure(nw_ports* ports) {
+ return nw_ports_walk(ports, __nw_ports_reconfigure, NULL);
+}
typedef struct nw_ports nw_ports;
+typedef int (*nw_ports_walk_callback)(nw_daemon* daemon, nw_port* port, void* data);
+
#include "daemon.h"
int nw_ports_create(nw_ports** ports, nw_daemon* daemon);
int nw_ports_bus_paths(nw_ports* ports, char*** paths);
+int nw_ports_walk(nw_ports* ports, nw_ports_walk_callback callback, void* data);
+
+int nw_ports_reconfigure(nw_ports* ports);
+
#endif /* NETWORKD_PORTS_H */
return nw_link_ref(zone->link);
}
+int nw_zone_reconfigure(nw_zone* zone) {
+ return 0; // XXX TODO
+}
+
// Carrier
int nw_zone_has_carrier(nw_zone* zone) {
char* nw_zone_bus_path(nw_zone* zone);
+int nw_zone_reconfigure(nw_zone* zone);
+
int nw_zone_has_carrier(nw_zone* zone);
/*
return 0;
}
+
+static int __nw_zones_reconfigure(nw_daemon* daemon, nw_zone* zone, void* data) {
+ return nw_zone_reconfigure(zone);
+}
+
+int nw_zones_reconfigure(nw_zones* zones) {
+ return nw_zones_walk(zones, __nw_zones_reconfigure, NULL);
+}
int nw_zones_walk(nw_zones* zones, nw_zones_walk_callback callback, void* data);
+int nw_zones_reconfigure(nw_zones* zones);
+
#endif /* NETWORKD_ZONES_H */