splitting roles from IO loop and providing a abstract of switch
diff --git a/of/api/pom.xml b/of/api/pom.xml
index 8f123e1..050fedd 100644
--- a/of/api/pom.xml
+++ b/of/api/pom.xml
@@ -63,7 +63,7 @@
                 <configuration>
                     <instructions>
                         <Export-Package>
-                            org.projectfloodlight.openflow.*
+                            org.onlab.onos.of.*,org.projectfloodlight.openflow.*
                         </Export-Package>
                     </instructions>
                 </configuration>
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/DeleteMe.java b/of/api/src/main/java/org/onlab/onos/of/controller/DeleteMe.java
deleted file mode 100644
index 1db6eae..0000000
--- a/of/api/src/main/java/org/onlab/onos/of/controller/DeleteMe.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.onlab.onos.of.controller;
-
-/**
- * Created by tom on 8/21/14.
- */
-public interface DeleteMe {
-}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/Dpid.java b/of/api/src/main/java/org/onlab/onos/of/controller/Dpid.java
new file mode 100644
index 0000000..02a957e
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/Dpid.java
@@ -0,0 +1,74 @@
+package org.onlab.onos.of.controller;
+
+import org.projectfloodlight.openflow.util.HexString;
+
+/**
+ * The class representing a network switch DPID.
+ * This class is immutable.
+ */
+public final class Dpid {
+    private static final long UNKNOWN = 0;
+    private final long value;
+
+    /**
+     * Default constructor.
+     */
+    public Dpid() {
+        this.value = Dpid.UNKNOWN;
+    }
+
+    /**
+     * Constructor from a long value.
+     *
+     * @param value the value to use.
+     */
+    public Dpid(long value) {
+        this.value = value;
+    }
+
+    /**
+     * Constructor from a string.
+     *
+     * @param value the value to use.
+     */
+    public Dpid(String value) {
+        this.value = HexString.toLong(value);
+    }
+
+    /**
+     * Get the value of the DPID.
+     *
+     * @return the value of the DPID.
+     */
+    public long value() {
+        return value;
+    }
+
+    /**
+     * Convert the DPID value to a ':' separated hexadecimal string.
+     *
+     * @return the DPID value as a ':' separated hexadecimal string.
+     */
+    @Override
+    public String toString() {
+        return HexString.toHexString(this.value);
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof Dpid)) {
+            return false;
+        }
+
+        Dpid otherDpid = (Dpid) other;
+
+        return value == otherDpid.value;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 17;
+        hash += 31 * hash + (int) (value ^ value >>> 32);
+        return hash;
+    }
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowController.java b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowController.java
new file mode 100644
index 0000000..5aec885
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowController.java
@@ -0,0 +1,100 @@
+package org.onlab.onos.of.controller;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Abstraction of an OpenFlow controller. Serves as a one stop
+ * shop for obtaining OpenFlow devices and (un)register listeners
+ * on OpenFlow events
+ */
+public interface OpenFlowController {
+
+    /**
+     * Returns all switches known to this OF controller.
+     * @return Iterable of dpid elements
+     */
+    public Iterable<OpenFlowSwitch> getSwitches();
+
+    /**
+     * Returns all master switches known to this OF controller.
+     * @return Iterable of dpid elements
+     */
+    public Iterable<OpenFlowSwitch> getMasterSwitches();
+
+    /**
+     * Returns all equal switches known to this OF controller.
+     * @return Iterable of dpid elements
+     */
+    public Iterable<OpenFlowSwitch> getEqualSwitches();
+
+
+    /**
+     * Returns the actual switch for the given Dpid.
+     * @param dpid the switch to fetch
+     * @return the interface to this switch
+     */
+    public OpenFlowSwitch getSwitch(Dpid dpid);
+
+    /**
+     * Returns the actual master switch for the given Dpid, if one exists.
+     * @param dpid the switch to fetch
+     * @return the interface to this switch
+     */
+    public OpenFlowSwitch getMasterSwitch(Dpid dpid);
+
+    /**
+     * Returns the actual equal switch for the given Dpid, if one exists.
+     * @param dpid the switch to fetch
+     * @return the interface to this switch
+     */
+    public OpenFlowSwitch getEqualSwitch(Dpid dpid);
+
+    /**
+     * Register a listener for meta events that occur to OF
+     * devices.
+     * @param listener the listener to notify
+     */
+    public void addListener(OpenFlowSwitchListener listener);
+
+    /**
+     * Unregister a listener.
+     *
+     * @param listener the listener to unregister
+     */
+    public void removeListener(OpenFlowSwitchListener listener);
+
+    /**
+     * Register a listener for packet events.
+     * @param priority the importance of this listener, lower values are more important
+     * @param listener the listener to notify
+     */
+    public void addPacketListener(int priority, PacketListener listener);
+
+    /**
+     * Unregister a listener.
+     *
+     * @param listener the listener to unregister
+     */
+    public void removePacketListener(PacketListener listener);
+
+    /**
+     * Send a message to a particular switch.
+     * @param dpid the switch to send to.
+     * @param msg the message to send
+     */
+    public void write(Dpid dpid, OFMessage msg);
+
+    /**
+     * Process a message and notify the appropriate listeners.
+     *
+     * @param msg the message to process.
+     */
+    public void processPacket(OFMessage msg);
+
+    /**
+     * Sets the role for a given switch.
+     * @param role the desired role
+     * @param dpid the switch to set the role for.
+     */
+    public void setRole(Dpid dpid, RoleState role);
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java
new file mode 100644
index 0000000..e6f52bd
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitch.java
@@ -0,0 +1,23 @@
+package org.onlab.onos.of.controller;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Abstract model of an OpenFlow Switch.
+ *
+ */
+public interface OpenFlowSwitch {
+
+    /**
+     * Writes the message to this switch.
+     *
+     * @param msg the message to write
+     */
+    public void write(OFMessage msg);
+
+    /**
+     * Handle a message from the switch.
+     * @param fromSwitch the message to handle
+     */
+    public void handleMessage(OFMessage fromSwitch);
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchEvent.java b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchEvent.java
new file mode 100644
index 0000000..281d505
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchEvent.java
@@ -0,0 +1,17 @@
+package org.onlab.onos.of.controller;
+
+/**
+ * Meta events that can happen at a switch.
+ *
+ */
+public enum OpenFlowSwitchEvent {
+    /**
+     * The switch connected.
+     */
+    SWITCH_CONNECTED,
+
+    /**
+     * The switch disconnected.
+     */
+    SWITCH_DISCONNECTED
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchListener.java b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchListener.java
new file mode 100644
index 0000000..7ccba6d
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/OpenFlowSwitchListener.java
@@ -0,0 +1,20 @@
+package org.onlab.onos.of.controller;
+
+/**
+ * Allows for providers interested in Switch events to be notified.
+ */
+public interface OpenFlowSwitchListener {
+
+    /**
+     * Notify that the switch was added.
+     * @param dpid the switch where the event occurred
+     */
+    public void switchAdded(Dpid dpid);
+
+    /**
+     * Notify that the switch was removed.
+     * @param dpid the switch where the event occurred.
+     */
+    public void switchRemoved(Dpid dpid);
+
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java b/of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java
new file mode 100644
index 0000000..bc06e93
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/PacketContext.java
@@ -0,0 +1,50 @@
+package org.onlab.onos.of.controller;
+
+import org.projectfloodlight.openflow.types.OFPort;
+
+/**
+ * A representation of a packet context which allows any provider
+ * to view the packet in event but may block the response to the
+ * event if blocked has been called.
+ */
+public interface PacketContext {
+
+    //TODO: may want to support sending packet out other switches than
+    // the one it came in on.
+    /**
+     * Blocks further responses (ie. send() calls) on this
+     * packet in event.
+     */
+    public void block();
+
+    /**
+     * Provided build has been called send the packet
+     * out the switch it came in on.
+     */
+    public void send();
+
+    /**
+     * Build the packet out in response to this packet in event.
+     * @param outPort the out port to send to packet out of.
+     */
+    public void build(OFPort outPort);
+
+    /**
+     * Build the packet out in response to this packet in event.
+     * @param ethFrame the actual packet to send out.
+     * @param outPort the out port to send to packet out of.
+     */
+    public void build(Object ethFrame, OFPort outPort);
+
+    /**
+     * Provided a handle onto the parsed payload.
+     * @return the parsed form of the payload.
+     */
+    public Object parsed();
+
+    /**
+     * Provide the dpid of the switch where the packet in arrived.
+     * @return the dpid of the switch.
+     */
+    public Dpid dpid();
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/PacketListener.java b/of/api/src/main/java/org/onlab/onos/of/controller/PacketListener.java
new file mode 100644
index 0000000..5c6d73f
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/PacketListener.java
@@ -0,0 +1,13 @@
+package org.onlab.onos.of.controller;
+
+/**
+ * Notifies providers about Packet in events.
+ */
+public interface PacketListener {
+
+    /**
+     * Handle the packet.
+     * @param pktCtx the packet context ({@link }
+     */
+    public void handlePacket(PacketContext pktCtx);
+}
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/RoleState.java b/of/api/src/main/java/org/onlab/onos/of/controller/RoleState.java
new file mode 100644
index 0000000..527a91c
--- /dev/null
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/RoleState.java
@@ -0,0 +1,23 @@
+package org.onlab.onos.of.controller;
+
+import org.projectfloodlight.openflow.protocol.OFControllerRole;
+
+/**
+ * The role of the controller as it pertains to a particular switch.
+ * Note that this definition of the role enum is different from the
+ * OF1.3 definition. It is maintained here to be backward compatible to
+ * earlier versions of the controller code. This enum is translated
+ * to the OF1.3 enum, before role messages are sent to the switch.
+ * See sendRoleRequestMessage method in OFSwitchImpl
+ */
+public enum RoleState {
+    EQUAL(OFControllerRole.ROLE_EQUAL),
+    MASTER(OFControllerRole.ROLE_MASTER),
+    SLAVE(OFControllerRole.ROLE_SLAVE);
+
+    private RoleState(OFControllerRole nxRole) {
+        nxRole.ordinal();
+    }
+
+}
+