Sketching SB & NB API.
Modified onos-of-api pom to subsume openflowj loxi-generated stuff.
diff --git a/net/api/src/main/java/org/onlab/onos/event/AbstractEvent.java b/net/api/src/main/java/org/onlab/onos/event/AbstractEvent.java
new file mode 100644
index 0000000..db688e6
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/event/AbstractEvent.java
@@ -0,0 +1,51 @@
+package org.onlab.onos.event;
+
+/**
+ * Base abstraction of an event.
+ */
+public class AbstractEvent<T extends Enum, S extends Object> implements Event<T, S> {
+
+    private final long time;
+    private final T type;
+    private S subject;
+
+    /**
+     * Creates an event of a given type and for the specified subject and the
+     * current time.
+     *
+     * @param type    event type
+     * @param subject event subject
+     */
+    protected AbstractEvent(T type, S subject) {
+        this(type, subject, System.currentTimeMillis());
+    }
+
+    /**
+     * Creates an event of a given type and for the specified subject and time.
+     *
+     * @param type    event type
+     * @param subject event subject
+     * @param time    occurrence time
+     */
+    protected AbstractEvent(T type, S subject, long time) {
+        this.type = type;
+        this.subject = subject;
+        this.time = time;
+    }
+
+    @Override
+    public long time() {
+        return time;
+    }
+
+    @Override
+    public T type() {
+        return type;
+    }
+
+    @Override
+    public S subject() {
+        return subject;
+    }
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/event/Event.java b/net/api/src/main/java/org/onlab/onos/event/Event.java
new file mode 100644
index 0000000..1cd49cd
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/event/Event.java
@@ -0,0 +1,30 @@
+package org.onlab.onos.event;
+
+/**
+ * Abstraction of an event.
+ */
+public interface Event<T extends Enum, S extends Object> {
+
+    /**
+     * Returns the timestamp of when the event occurred, given in milliseconds
+     * since the start of epoch.
+     *
+     * @return timestamp in milliseconds
+     */
+    long time();
+
+    /**
+     * Returns the type of the event.
+     *
+     * @return event type
+     */
+    T type();
+
+    /**
+     * Returns the subject of the event.
+     *
+     * @return subject to which this event pertains
+     */
+    S subject();
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/event/EventListener.java b/net/api/src/main/java/org/onlab/onos/event/EventListener.java
new file mode 100644
index 0000000..1e0d7e6
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/event/EventListener.java
@@ -0,0 +1,15 @@
+package org.onlab.onos.event;
+
+/**
+ * Entity capable of receiving events.
+ */
+public interface EventListener<E extends Event> {
+
+    /**
+     * Reacts to the specified event.
+     *
+     * @param event event to be processed
+     */
+    void event(E event);
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/Device.java b/net/api/src/main/java/org/onlab/onos/net/Device.java
new file mode 100644
index 0000000..c649479
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/Device.java
@@ -0,0 +1,14 @@
+package org.onlab.onos.net;
+
+/**
+ * Representation of an network infrastructure device.
+ */
+public class Device {
+
+    // type, e.g. switch, router, firewall, ips, controller
+
+    // id (uri within)
+
+    // ports
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/Host.java b/net/api/src/main/java/org/onlab/onos/net/Host.java
new file mode 100644
index 0000000..15badc5
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/Host.java
@@ -0,0 +1,12 @@
+package org.onlab.onos.net;
+
+/**
+ * Abstraction of an end-station host on the network, essentially a NIC.
+ */
+public class Host {
+
+    // MAC, IP(s), optional VLAN ID
+
+    // Location (current, recent locations?
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/MastershipRole.java b/net/api/src/main/java/org/onlab/onos/net/MastershipRole.java
new file mode 100644
index 0000000..10d53ad
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/MastershipRole.java
@@ -0,0 +1,27 @@
+package org.onlab.onos.net;
+
+/**
+ * Representation of a relationship role of a controller instance to a device
+ * or a region of network environment.
+ */
+public enum MastershipRole {
+
+    /**
+     * Represents a relationship where the controller instance is the master
+     * to a device or a region of network environment.
+     */
+    MASTER,
+
+    /**
+     * Represents a relationship where the controller instance is the standby,
+     * i.e. potential master to a device or a region of network environment.
+     */
+    STANDBY,
+
+    /**
+     * Represents that the controller instance is not eligible to be the master
+     * to a device or a region of network environment.
+     */
+    NONE
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
new file mode 100644
index 0000000..d82ae42
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceEvent.java
@@ -0,0 +1,56 @@
+package org.onlab.onos.net.device;
+
+import org.onlab.onos.event.AbstractEvent;
+import org.onlab.onos.net.Device;
+
+/**
+ * Describes infrastructure device event.
+ */
+public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
+
+    /**
+     * Type of device events.
+     */
+    public enum Type {
+        /** Signifies that a new device has been detected. */
+        DEVICE_ADDED,
+
+        /** Signifies that a device has been removed. */
+        DEVICE_REMOVED,
+
+        /** Signifies that a device has been administratively suspended. */
+        DEVICE_SUSPENDED,
+
+        /** Signifies that a device has come online or has gone offline. */
+        DEVICE_AVAILABILITY_CHANGED,
+
+        /**
+         * Signifies that the current controller instance relationship has
+         * changed with respect to a device.
+         */
+        DEVICE_MASTERSHIP_CHANGED
+    }
+
+    /**
+     * Creates an event of a given type and for the specified subject and the
+     * current time.
+     *
+     * @param type    event type
+     * @param subject event subject
+     */
+    public DeviceEvent(Type type, Device subject) {
+        super(type, subject);
+    }
+
+    /**
+     * Creates an event of a given type and for the specified subject and time.
+     *
+     * @param type    event type
+     * @param subject event subject
+     * @param time    occurrence time
+     */
+    public DeviceEvent(Type type, Device subject, long time) {
+        super(type, subject, time);
+    }
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceListener.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceListener.java
new file mode 100644
index 0000000..232fc95
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceListener.java
@@ -0,0 +1,7 @@
+package org.onlab.onos.net.device;
+
+/**
+ * Entity capable of receiving device related events.
+ */
+public interface DeviceListener {
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
index 04ca92c..449fcbe 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
@@ -1,9 +1,35 @@
 package org.onlab.onos.net.device;
 
-import org.onlab.onos.net.Provider;
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.MastershipRole;
+import org.onlab.onos.provider.Provider;
 
 /**
  * Abstraction of a device information provider.
  */
 public interface DeviceProvider extends Provider {
+
+    // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
+
+    /**
+     * Triggers an asynchronous probe of the specified device, intended to
+     * determine whether the host is present or not. An indirect result of this
+     * should be invocation of
+     * {@link org.onlab.onos.net.device.DeviceProviderService#deviceConnected(DeviceDescription)} )} or
+     * {@link org.onlab.onos.net.device.DeviceProviderService#deviceDisconnected(DeviceDescription)}
+     * at some later point in time.
+     *
+     * @param device device to be probed
+     */
+    void triggerProbe(Device device);
+
+    /**
+     * Notifies the provider of a mastership role change for the specified
+     * device as decided by the core.
+     *
+     * @param device  affected device
+     * @param newRole newly determined mastership role
+     */
+    void roleChanged(Device device, MastershipRole newRole);
+
 }
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderBroker.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderBroker.java
index 926f76e..a2016a1 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderBroker.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.device;
 
-import org.onlab.onos.net.ProviderBroker;
+import org.onlab.onos.provider.ProviderBroker;
 
 /**
  * Abstraction of a device provider brokerage.
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
index e5ee1f0..40ffc3e 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
@@ -1,6 +1,7 @@
 package org.onlab.onos.net.device;
 
-import org.onlab.onos.net.ProviderService;
+import org.onlab.onos.net.MastershipRole;
+import org.onlab.onos.provider.ProviderService;
 
 import java.util.List;
 
@@ -16,8 +17,9 @@
      * Signals the core that a device has connected or has been detected somehow.
      *
      * @param deviceDescription information about network device
+     * @return mastership role chosen by the provider service
      */
-    void deviceConnected(DeviceDescription deviceDescription);
+    MastershipRole deviceConnected(DeviceDescription deviceDescription);
 
     /**
      * Signals the core that a device has disconnected or is no longer reachable.
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceService.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
new file mode 100644
index 0000000..4048fbb
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
@@ -0,0 +1,52 @@
+package org.onlab.onos.net.device;
+
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.MastershipRole;
+
+/**
+ * Service for interacting with the inventory of infrastructure devices.
+ */
+public interface DeviceService {
+
+    /**
+     * Returns the current mastership role for the specified device.
+     *
+     * @param deviceId device identifier
+     * @return designated mastership role
+     */
+    MastershipRole getRole(DeviceId deviceId);
+
+    /**
+     * Returns an iterable collection of the currently known infrastructure
+     * devices.
+     *
+     * @return collection of devices
+     */
+    Iterable<Device> getDevices();
+
+    /**
+     * Returns the device with the specified identifier.
+     *
+     * @param deviceId device identifier
+     * @return device or null if one with the given identifier is not known
+     */
+    Device getDevice(DeviceId deviceId);
+
+
+//    List<Port> getPorts(DeviceId deviceId);
+
+    /**
+     * Adds the specified device listener.
+     *
+     * @param listener device listener
+     */
+    void addListener(DeviceListener listener);
+
+    /**
+     * Removes the specified device listener.
+     *
+     * @param listener device listener
+     */
+    void removeListener(DeviceListener listener);
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
index ac46da8..1ec0314 100644
--- a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
+++ b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProvider.java
@@ -1,9 +1,12 @@
 package org.onlab.onos.net.flow;
 
-import org.onlab.onos.net.Provider;
+import org.onlab.onos.provider.Provider;
 
 /**
  * Abstraction of a flow rule provider.
  */
 public interface FlowRuleProvider extends Provider {
+
+    // TODO: pushFlowRule
+
 }
diff --git a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderBroker.java b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderBroker.java
index c3f7602..d3ffc5f 100644
--- a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderBroker.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.flow;
 
-import org.onlab.onos.net.ProviderBroker;
+import org.onlab.onos.provider.ProviderBroker;
 
 /**
  * Abstraction for a flow rule provider brokerage.
diff --git a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java
index 9b26d76..2799788 100644
--- a/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/flow/FlowRuleProviderService.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.flow;
 
-import org.onlab.onos.net.ProviderService;
+import org.onlab.onos.provider.ProviderService;
 
 /**
  * Service through which flowrule providers can inject flowrule information into
diff --git a/net/api/src/main/java/org/onlab/onos/net/host/HostProvider.java b/net/api/src/main/java/org/onlab/onos/net/host/HostProvider.java
index 1ad2c65..59ddcc2 100644
--- a/net/api/src/main/java/org/onlab/onos/net/host/HostProvider.java
+++ b/net/api/src/main/java/org/onlab/onos/net/host/HostProvider.java
@@ -1,9 +1,24 @@
 package org.onlab.onos.net.host;
 
-import org.onlab.onos.net.Provider;
+import org.onlab.onos.net.Host;
+import org.onlab.onos.provider.Provider;
 
 /**
  * Provider of information about hosts and their location on the network.
  */
 public interface HostProvider extends Provider {
+
+    // TODO: consider how dirty the triggerProbe gets; if it costs too much, let's drop it
+
+    /**
+     * Triggers an asynchronous probe of the specified host, intended to
+     * determine whether the host is present or not. An indirect result of this
+     * should be invocation of {@link org.onlab.onos.net.host.HostProviderService#hostDetected(HostDescription)} or
+     * {@link org.onlab.onos.net.host.HostProviderService#hostNotDetected(HostDescription)}
+     * at some later point in time.
+     *
+     * @param host host to probe
+     */
+    void triggerProbe(Host host);
+
 }
diff --git a/net/api/src/main/java/org/onlab/onos/net/host/HostProviderBroker.java b/net/api/src/main/java/org/onlab/onos/net/host/HostProviderBroker.java
index 427e54e..66db967 100644
--- a/net/api/src/main/java/org/onlab/onos/net/host/HostProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/net/host/HostProviderBroker.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.host;
 
-import org.onlab.onos.net.ProviderBroker;
+import org.onlab.onos.provider.ProviderBroker;
 
 /**
  * Abstraction of a host provider brokerage.
diff --git a/net/api/src/main/java/org/onlab/onos/net/host/HostProviderService.java b/net/api/src/main/java/org/onlab/onos/net/host/HostProviderService.java
index 4d5d470..c66054f 100644
--- a/net/api/src/main/java/org/onlab/onos/net/host/HostProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/host/HostProviderService.java
@@ -1,12 +1,25 @@
 package org.onlab.onos.net.host;
 
-import org.onlab.onos.net.ProviderService;
+import org.onlab.onos.provider.ProviderService;
 
 /**
  * Means of conveying host information to the core.
  */
 public interface HostProviderService extends ProviderService {
 
+    /**
+     * Notifies the core when a host has been detected on a network along with
+     * information that identifies the hoot location.
+     *
+     * @param hostDescription description of host and its location
+     */
     void hostDetected(HostDescription hostDescription);
 
+    /**
+     * Notifies the core when a host is no longer detected on a network.
+     *
+     * @param hostDescription description of host
+     */
+    void hostNotDetected(HostDescription hostDescription);
+
 }
diff --git a/net/api/src/main/java/org/onlab/onos/net/link/LinkProvider.java b/net/api/src/main/java/org/onlab/onos/net/link/LinkProvider.java
index 57cc45d..2ef8955 100644
--- a/net/api/src/main/java/org/onlab/onos/net/link/LinkProvider.java
+++ b/net/api/src/main/java/org/onlab/onos/net/link/LinkProvider.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.link;
 
-import org.onlab.onos.net.Provider;
+import org.onlab.onos.provider.Provider;
 
 /**
  * Abstraction of an entity providing information about infrastructure links
diff --git a/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderBroker.java b/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderBroker.java
index b0bfb05..8822bbf 100644
--- a/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderBroker.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.link;
 
-import org.onlab.onos.net.ProviderBroker;
+import org.onlab.onos.provider.ProviderBroker;
 
 /**
  * Abstraction of an infrastructure link provider brokerage.
diff --git a/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderService.java b/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderService.java
index 9f523f7..f1b12e3 100644
--- a/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/link/LinkProviderService.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.link;
 
-import org.onlab.onos.net.ProviderService;
+import org.onlab.onos.provider.ProviderService;
 
 /**
  * Means for injecting link information into the core.
diff --git a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProvider.java b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProvider.java
index 70264dc..a9ec00f 100644
--- a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProvider.java
+++ b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProvider.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.topology;
 
-import org.onlab.onos.net.Provider;
+import org.onlab.onos.provider.Provider;
 
 /**
  * Means for injecting topology information into the core.
diff --git a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderBroker.java b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderBroker.java
index 9caa817..159d3ff 100644
--- a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderBroker.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.topology;
 
-import org.onlab.onos.net.ProviderBroker;
+import org.onlab.onos.provider.ProviderBroker;
 
 /**
  * Abstraction of a network topology provider brokerage.
diff --git a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
index bef83ed..0841700 100644
--- a/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/topology/TopologyProviderService.java
@@ -1,6 +1,6 @@
 package org.onlab.onos.net.topology;
 
-import org.onlab.onos.net.ProviderService;
+import org.onlab.onos.provider.ProviderService;
 
 /**
  * Means for injecting topology information into the core.
diff --git a/net/api/src/main/java/org/onlab/onos/net/Provider.java b/net/api/src/main/java/org/onlab/onos/provider/Provider.java
similarity index 80%
rename from net/api/src/main/java/org/onlab/onos/net/Provider.java
rename to net/api/src/main/java/org/onlab/onos/provider/Provider.java
index eda436b..8fb047f 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Provider.java
+++ b/net/api/src/main/java/org/onlab/onos/provider/Provider.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net;
+package org.onlab.onos.provider;
 
 /**
  * Abstraction of a provider of information about network environment.
diff --git a/net/api/src/main/java/org/onlab/onos/net/ProviderBroker.java b/net/api/src/main/java/org/onlab/onos/provider/ProviderBroker.java
similarity index 95%
rename from net/api/src/main/java/org/onlab/onos/net/ProviderBroker.java
rename to net/api/src/main/java/org/onlab/onos/provider/ProviderBroker.java
index 63d7189..20a612e 100644
--- a/net/api/src/main/java/org/onlab/onos/net/ProviderBroker.java
+++ b/net/api/src/main/java/org/onlab/onos/provider/ProviderBroker.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net;
+package org.onlab.onos.provider;
 
 /**
  * Broker used for registering/unregistering information providers with the core.
diff --git a/net/api/src/main/java/org/onlab/onos/net/ProviderId.java b/net/api/src/main/java/org/onlab/onos/provider/ProviderId.java
similarity index 95%
rename from net/api/src/main/java/org/onlab/onos/net/ProviderId.java
rename to net/api/src/main/java/org/onlab/onos/provider/ProviderId.java
index 53dd739..a5a297e 100644
--- a/net/api/src/main/java/org/onlab/onos/net/ProviderId.java
+++ b/net/api/src/main/java/org/onlab/onos/provider/ProviderId.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net;
+package org.onlab.onos.provider;
 
 /**
  * Notion of provider identity.
diff --git a/net/api/src/main/java/org/onlab/onos/net/ProviderService.java b/net/api/src/main/java/org/onlab/onos/provider/ProviderService.java
similarity index 83%
rename from net/api/src/main/java/org/onlab/onos/net/ProviderService.java
rename to net/api/src/main/java/org/onlab/onos/provider/ProviderService.java
index 8a7d7e9..fcfc7ad 100644
--- a/net/api/src/main/java/org/onlab/onos/net/ProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/provider/ProviderService.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net;
+package org.onlab.onos.provider;
 
 /**
  * Abstraction of a service through which providers can inject information