+/* Checks for changes to netdevs in the set monitored by 'monitor'. If any of
+ * the attributes (Ethernet address, carrier status, speed or peer-advertised
+ * speed, flags, etc.) of a network device monitored by 'monitor' has changed,
+ * sets '*devnamep' to the name of a device that has changed and returns 0.
+ * The caller is responsible for freeing '*devnamep' (with free()).
+ *
+ * If no devices have changed, sets '*devnamep' to NULL and returns EAGAIN.
+ */
+int
+netdev_monitor_poll(struct netdev_monitor *monitor, char **devnamep)
+{
+ struct shash_node *node = shash_first(&monitor->changed_netdevs);
+ if (!node) {
+ *devnamep = NULL;
+ return EAGAIN;
+ } else {
+ *devnamep = xstrdup(node->name);
+ shash_delete(&monitor->changed_netdevs, node);
+ return 0;
+ }
+}
+
+/* Registers with the poll loop to wake up from the next call to poll_block()
+ * when netdev_monitor_poll(monitor) would indicate that a device has
+ * changed. */
+void
+netdev_monitor_poll_wait(const struct netdev_monitor *monitor)
+{
+ if (!shash_is_empty(&monitor->changed_netdevs)) {
+ poll_immediate_wake();
+ } else {
+ /* XXX Nothing needed here for netdev_linux, but maybe other netdev
+ * classes need help. */
+ }
+}
+\f
+/* Restore the network device flags on 'netdev' to those that were active
+ * before we changed them. Returns 0 if successful, otherwise a positive
+ * errno value.
+ *
+ * To avoid reentry, the caller must ensure that fatal signals are blocked. */