diff --git a/src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java b/src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java
index 683e0dee8436e941e5663378d3e352f38cafafc9..2cefba104d32305992d1813fc5f59e59cb375c0b 100644
--- a/src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java
+++ b/src/main/java/net/floodlightcontroller/core/IFloodlightProviderService.java
@@ -82,7 +82,9 @@ public interface IFloodlightProviderService extends
      * @return the set of actively connected switches
      */
     public Map<Long, IOFSwitch> getSwitches();
-    
+
+    public IOFSwitch getSwitchByDpid(String dpid);
+
     /**
      * Get the current role of the controller
      */
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 21e1244a3eadaf9fd6df4089b08d59c87b4e4719..0c44214e0d842f36a0fe22b85989274426504a79 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -1500,6 +1500,24 @@ public class Controller implements IFloodlightProviderService,
         return Collections.unmodifiableMap(this.activeSwitches);
     }
 
+    @Override
+    public IOFSwitch getSwitchByDpid(String dpid) {
+        Map<Long, IOFSwitch> switches = getSwitches();
+        if (switches == null) return null;
+        Long switchid = HexString.toLong(dpid);
+
+        if (switchid != null && switches.containsKey(switchid)) {
+            return switches.get(switchid);
+        }
+
+        // TODO: This is a hack for the demo, which only has one switch
+        for (IOFSwitch sw : switches.values()) {
+            return sw;
+        }
+
+        return null;
+    }
+
     @Override
     public void addOFSwitchListener(IOFSwitchListener listener) {
         this.switchListeners.add(listener);
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/IDeviceService.java b/src/main/java/net/floodlightcontroller/devicemanager/IDeviceService.java
index 5e8f221a9829bdcf25d0f37a41fd33047db3affe..eb3801344f73d68ab0c35e6db556c09edfa1ba68 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/IDeviceService.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/IDeviceService.java
@@ -20,6 +20,7 @@ package net.floodlightcontroller.devicemanager;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.Iterator;
+import java.util.Set;
 
 import net.floodlightcontroller.core.FloodlightContextStore;
 import net.floodlightcontroller.core.module.IFloodlightService;
@@ -210,4 +211,6 @@ public interface IDeviceService extends IFloodlightService {
 
     public void removeSuppressAPs(long swId, short port);
 
+    public Set<SwitchPort> getSuppressAPs();
+
 }
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
index 52ebdf0493fcdc5e60e595df0273d761810e8d1d..ea9a3991e277c543b54f4cedb56bba4a7389577c 100755
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImpl.java
@@ -545,6 +545,11 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
         suppressAPs.remove(new SwitchPort(swId, port));
     }
 
+    @Override
+    public Set<SwitchPort> getSuppressAPs() {
+        return Collections.unmodifiableSet(suppressAPs);
+    }
+
     private void logListeners() {
         List<IDeviceListener> listeners = deviceListeners.getOrderedListeners();
         if (listeners != null) {
diff --git a/src/main/java/net/floodlightcontroller/routing/IRoutingService.java b/src/main/java/net/floodlightcontroller/routing/IRoutingService.java
index 63b5d1856b00820f5558315d068655b4f3fb459f..a3d77a83ba6309c02c6f99c19d2523eab2ecfa3b 100644
--- a/src/main/java/net/floodlightcontroller/routing/IRoutingService.java
+++ b/src/main/java/net/floodlightcontroller/routing/IRoutingService.java
@@ -1,7 +1,7 @@
 /**
-*    Copyright 2011, Big Switch Networks, Inc. 
+*    Copyright 2011, Big Switch Networks, Inc.
 *    Originally created by David Erickson, Stanford University
-* 
+*
 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
 *    not use this file except in compliance with the License. You may obtain
 *    a copy of the License at
@@ -35,8 +35,8 @@ public interface IRoutingService extends IFloodlightService {
      */
     public Route getRoute(long src, long dst, long cookie);
 
-    /** 
-     * Provides a route between src and dst, with option to allow or 
+    /**
+     * Provides a route between src and dst, with option to allow or
      *  not allow tunnels in the path.
      * @param src Source switch DPID.
      * @param dst Destination switch DPID.
@@ -45,7 +45,7 @@ public interface IRoutingService extends IFloodlightService {
      */
     public Route getRoute(long src, long dst, long cookie, boolean tunnelEnabled);
 
-    /** 
+    /**
      * Provides a route between srcPort on src and dstPort on dst.
      * @param src Source switch DPID.
      * @param srcPort Source port on source switch.
@@ -53,10 +53,10 @@ public interface IRoutingService extends IFloodlightService {
      * @param dstPort dstPort on Destination switch.
      * @param cookie cookie (usage determined by implementation; ignored by topology instance now).
      */
-    public Route getRoute(long srcId, short srcPort, 
+    public Route getRoute(long srcId, short srcPort,
                              long dstId, short dstPort, long cookie);
 
-    /** 
+    /**
      * Provides a route between srcPort on src and dstPort on dst.
      * @param src Source switch DPID.
      * @param srcPort Source port on source switch.
@@ -65,7 +65,7 @@ public interface IRoutingService extends IFloodlightService {
      * @param cookie cookie (usage determined by implementation; ignored by topology instance now).
      * @param tunnelEnabled boolean option.
      */
-    public Route getRoute(long srcId, short srcPort, 
+    public Route getRoute(long srcId, short srcPort,
                              long dstId, short dstPort, long cookie,
                              boolean tunnelEnabled);
 
@@ -82,4 +82,4 @@ public interface IRoutingService extends IFloodlightService {
      */
     public boolean routeExists(long src, long dst, boolean tunnelEnabled);
 
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/floodlightcontroller/servicechaining/BITWServiceNode.java b/src/main/java/net/floodlightcontroller/servicechaining/BITWServiceNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..38752f0651b771a5662c7e91e26d9e538b16d9e1
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/servicechaining/BITWServiceNode.java
@@ -0,0 +1,28 @@
+package net.floodlightcontroller.servicechaining;
+
+import net.floodlightcontroller.topology.NodePortTuple;
+
+public class BITWServiceNode extends ServiceNode {
+    protected NodePortTuple ingressPort;
+    protected NodePortTuple egressPort;
+
+    public BITWServiceNode(String tenant, String name) {
+        super(tenant, name, InsertionType.BUMPINTHEWIRE);
+    }
+
+    public NodePortTuple getIngressPort() {
+        return ingressPort;
+    }
+
+    public void setIngressPort(NodePortTuple ingressPort) {
+        this.ingressPort = ingressPort;
+    }
+
+    public NodePortTuple getEgressPort() {
+        return egressPort;
+    }
+
+    public void setEgressPort(NodePortTuple egressPort) {
+        this.egressPort = egressPort;
+    }
+}
diff --git a/src/main/java/net/floodlightcontroller/servicechaining/IServiceChainingService.java b/src/main/java/net/floodlightcontroller/servicechaining/IServiceChainingService.java
new file mode 100644
index 0000000000000000000000000000000000000000..e72a5c84a7c78f861b0b2c1e81ed312b884d23fb
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/servicechaining/IServiceChainingService.java
@@ -0,0 +1,27 @@
+package net.floodlightcontroller.servicechaining;
+
+import net.floodlightcontroller.core.FloodlightContextStore;
+import net.floodlightcontroller.core.module.IFloodlightService;
+
+public interface IServiceChainingService extends IFloodlightService {
+    /**
+     * A FloodlightContextStore object that can be used to interact with the
+     * FloodlightContext information created by ServiceInsertion.
+     */
+    public static final FloodlightContextStore<String> scStore =
+        new FloodlightContextStore<String>();
+
+    /**
+     * Returns the service chain by source BVS.
+     * @param bvsName
+     * @return the ServiceChain, null is the requested service is not found.
+     */
+    public ServiceChain getServiceChainBySrcBVS(String bvsName);
+
+    /**
+     * Returns the service chain by destination BVS.
+     * @param bvsName
+     * @return the ServiceChain, null is the requested service is not found.
+     */
+    public ServiceChain getServiceChainByDstBVS(String bvsName);
+}
diff --git a/src/main/java/net/floodlightcontroller/servicechaining/ServiceChain.java b/src/main/java/net/floodlightcontroller/servicechaining/ServiceChain.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e934347c9d87a6c0ce682787efb9540da34a188
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/servicechaining/ServiceChain.java
@@ -0,0 +1,126 @@
+package net.floodlightcontroller.servicechaining;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+/**
+ * ServiceChaining module encapsulates properties of service chains and their member nodes
+ *
+ * @author kjiang
+ *
+ */
+@JsonSerialize(using=ServiceChainSerializer.class)
+public class ServiceChain {
+    // Tenant
+    private String tenant;
+
+    // Service Chain name
+    private String name;
+
+    // Source network
+    private String srcBvsName;
+
+    // Destination network
+    private String dstBvsName;
+
+    // Service Description
+    private String description;
+
+    // Ordered list of service Nodes
+    private List<ServiceNode> nodes;
+
+    /**
+     * Constructor to create a NetworkService
+     *
+     * @param name
+     * @param vMac
+     * @param vIp
+     */
+    public ServiceChain(String tenant, String name, String description,
+            String srcBvsName, String dstBvsName) {
+        this.tenant = tenant;
+        this.name = name;
+        this.description = description;
+        this.srcBvsName = srcBvsName;
+        this.dstBvsName = dstBvsName;
+        this.nodes = new ArrayList<ServiceNode>();
+    }
+
+    /**
+     * A getter for service tenant
+     * @return
+     */
+    public String getTenant() {
+        return tenant;
+    }
+
+    /**
+     * A getter for service name
+     * @return
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * A getter for service description
+     * @return
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * A getter for source BVS
+     */
+    public String getSourceBvs() {
+        return srcBvsName;
+    }
+
+    /**
+     * A getter for destination BVS
+     */
+    public String getDestinationBvs() {
+        return dstBvsName;
+    }
+
+    /**
+     * A getter returns an unmodifiable map of service nodes.
+     * @return
+     */
+    public List<ServiceNode> getServiceNodes() {
+        return Collections.unmodifiableList(nodes);
+    }
+
+    /**
+     * Add a service node to the end of the node list
+     */
+    public boolean addNode(ServiceNode node) {
+        try {
+            return nodes.add(node);
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * Remove a service node from the node list
+     */
+    public boolean removeNode(ServiceNode node) {
+        try {
+            return nodes.remove(node);
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "ServiceChain [tenant=" + tenant + ", name=" + name
+                + ", srcBvsName=" + srcBvsName + ", dstBvsName=" + dstBvsName
+                + ", description=" + description + "]";
+    }
+}
diff --git a/src/main/java/net/floodlightcontroller/servicechaining/ServiceChainSerializer.java b/src/main/java/net/floodlightcontroller/servicechaining/ServiceChainSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..2c51cd61530a9c540d98c417fcf8accb93ecab44
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/servicechaining/ServiceChainSerializer.java
@@ -0,0 +1,45 @@
+package net.floodlightcontroller.servicechaining;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+public class ServiceChainSerializer extends JsonSerializer<ServiceChain> {
+
+    @Override
+    public void serialize(ServiceChain sc, JsonGenerator jgen,
+                          SerializerProvider sp) throws IOException,
+            JsonProcessingException {
+        jgen.writeStartObject();
+        jgen.writeStringField("name", sc.getName());
+        jgen.writeStringField("description", sc.getDescription());
+        if (sc.getSourceBvs() != null) {
+            jgen.writeStringField("source-BVS", sc.getSourceBvs());
+        } else {
+            jgen.writeStringField("source-BVS", "*");
+        }
+        if (sc.getDestinationBvs() != null) {
+            jgen.writeStringField("destination-BVS", sc.getDestinationBvs());
+        } else {
+            jgen.writeStringField("destination-BVS", "*");
+        }
+        jgen.writeArrayFieldStart("service-nodes");
+        Collection<ServiceNode> serviceNodes = sc.getServiceNodes();
+        if (serviceNodes != null && !serviceNodes.isEmpty()) {
+            for (ServiceNode sn : serviceNodes) {
+                jgen.writeObject(sn);
+            }
+        }
+        jgen.writeEndArray();
+        jgen.writeEndObject();
+    }
+
+    @Override
+    public Class<ServiceChain> handledType() {
+        return ServiceChain.class;
+    }
+}
diff --git a/src/main/java/net/floodlightcontroller/servicechaining/ServiceNode.java b/src/main/java/net/floodlightcontroller/servicechaining/ServiceNode.java
new file mode 100644
index 0000000000000000000000000000000000000000..dfceead4439b51c59c7bb3a0142797817cdbf7f8
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/servicechaining/ServiceNode.java
@@ -0,0 +1,67 @@
+package net.floodlightcontroller.servicechaining;
+
+public class ServiceNode {
+    public enum InsertionType {
+        L3, L2, BUMPINTHEWIRE, TAP, UNKNOWN
+    }
+
+    public enum Direction {
+        INGRESS, EGRESS, ANY
+    }
+
+    protected String name;
+    protected String tenant;
+    protected InsertionType type;
+
+    public ServiceNode(String tenant, String name, InsertionType type) {
+        this.tenant = tenant;
+        this.name = name;
+        this.type = type;
+    }
+
+    public String getTenant() {
+        return tenant;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public InsertionType getServiceType() {
+        return this.type;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((tenant == null) ? 0 : tenant.hashCode());
+        result = prime * result + ((type == null) ? 0 : type.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ServiceNode other = (ServiceNode) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (tenant == null) {
+            if (other.tenant != null)
+                return false;
+        } else if (!tenant.equals(other.tenant))
+            return false;
+        if (type != other.type)
+            return false;
+        return true;
+    }
+}
diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java
index af49de70bbb6ca8f29426bc370d5b343fdc30442..893ab74e4d1e105fb3aa02b5bdf1fef2ac409716 100644
--- a/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java
+++ b/src/main/java/net/floodlightcontroller/topology/TopologyInstance.java
@@ -36,6 +36,8 @@ import net.floodlightcontroller.routing.BroadcastTree;
 import net.floodlightcontroller.routing.Link;
 import net.floodlightcontroller.routing.Route;
 import net.floodlightcontroller.routing.RouteId;
+import net.floodlightcontroller.servicechaining.ServiceChain;
+
 import com.google.common.cache.*;
 
 /**
@@ -659,7 +661,7 @@ public class TopologyInstance {
         return true;
     }
 
-    protected Route getRoute(long srcId, short srcPort,
+    protected Route getRoute(ServiceChain sc, long srcId, short srcPort,
                              long dstId, short dstPort, long cookie) {
 
 
diff --git a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
index 1904a58c61af16431fb43426cae27755950f79a2..fa28dd9719b79a387a39adaea97c0694d4f2e6db 100644
--- a/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
+++ b/src/main/java/net/floodlightcontroller/topology/TopologyManager.java
@@ -600,7 +600,7 @@ public class TopologyManager implements
     public Route getRoute(long src, short srcPort, long dst, short dstPort, long cookie,
                           boolean tunnelEnabled) {
         TopologyInstance ti = getCurrentInstance(tunnelEnabled);
-        return ti.getRoute(src, srcPort, dst, dstPort, cookie);
+        return ti.getRoute(null, src, srcPort, dst, dstPort, cookie);
     }
 
     @Override
diff --git a/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java b/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
index 7b5cd6293c1888250299c6352918c610df70733c..42f1acf0aa756721493a26e48801755ad1a4781d 100644
--- a/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
+++ b/src/test/java/net/floodlightcontroller/core/test/MockFloodlightProvider.java
@@ -1,7 +1,7 @@
 /**
-*    Copyright 2011, Big Switch Networks, Inc. 
+*    Copyright 2011, Big Switch Networks, Inc.
 *    Originally created by David Erickson, Stanford University
-* 
+*
 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
 *    not use this file except in compliance with the License. You may obtain
 *    a copy of the License at
@@ -53,6 +53,7 @@ import org.openflow.protocol.OFMessage;
 import org.openflow.protocol.OFPacketIn;
 import org.openflow.protocol.OFType;
 import org.openflow.protocol.factory.BasicFactory;
+import org.openflow.util.HexString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,10 +70,10 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     protected BasicFactory factory;
 
     /**
-     * 
+     *
      */
     public MockFloodlightProvider() {
-        listeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, 
+        listeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType,
                                    IOFMessageListener>>();
         switches = new ConcurrentHashMap<Long, IOFSwitch>();
         switchListeners = new CopyOnWriteArrayList<IOFSwitchListener>();
@@ -81,9 +82,9 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     }
 
     @Override
-    public synchronized void addOFMessageListener(OFType type, 
+    public synchronized void addOFMessageListener(OFType type,
                                                   IOFMessageListener listener) {
-        ListenerDispatcher<OFType, IOFMessageListener> ldd = 
+        ListenerDispatcher<OFType, IOFMessageListener> ldd =
                 listeners.get(type);
         if (ldd == null) {
             ldd = new ListenerDispatcher<OFType, IOFMessageListener>();
@@ -95,7 +96,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     @Override
     public synchronized void removeOFMessageListener(OFType type,
                                                      IOFMessageListener listener) {
-        ListenerDispatcher<OFType, IOFMessageListener> ldd = 
+        ListenerDispatcher<OFType, IOFMessageListener> ldd =
                 listeners.get(type);
         if (ldd != null) {
             ldd.removeListener(listener);
@@ -107,9 +108,9 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
      */
     @Override
     public Map<OFType, List<IOFMessageListener>> getListeners() {
-        Map<OFType, List<IOFMessageListener>> lers = 
+        Map<OFType, List<IOFMessageListener>> lers =
                 new HashMap<OFType, List<IOFMessageListener>>();
-            for(Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> e : 
+            for(Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> e :
                 listeners.entrySet()) {
                 lers.put(e.getKey(), e.getValue().getOrderedListeners());
             }
@@ -119,12 +120,25 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     public void clearListeners() {
         this.listeners.clear();
     }
-    
+
     @Override
     public Map<Long, IOFSwitch> getSwitches() {
         return this.switches;
     }
 
+    @Override
+    public IOFSwitch getSwitchByDpid(String dpid) {
+        Map<Long, IOFSwitch> switches = getSwitches();
+        if (switches == null) return null;
+        Long switchid = HexString.toLong(dpid);
+
+        if (switchid != null && switches.containsKey(switchid)) {
+            return switches.get(switchid);
+        }
+
+        return null;
+    }
+
     public void setSwitches(Map<Long, IOFSwitch> switches) {
         this.switches = switches;
     }
@@ -142,7 +156,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     public void dispatchMessage(IOFSwitch sw, OFMessage msg) {
         dispatchMessage(sw, msg, new FloodlightContext());
     }
-    
+
     public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
         List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
         if (theListeners != null) {
@@ -152,8 +166,8 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
                 OFPacketIn pi = (OFPacketIn)msg;
                 Ethernet eth = new Ethernet();
                 eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
-                IFloodlightProviderService.bcStore.put(bc, 
-                        IFloodlightProviderService.CONTEXT_PI_PAYLOAD, 
+                IFloodlightProviderService.bcStore.put(bc,
+                        IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                         eth);
             }
             while (it.hasNext() && !Command.STOP.equals(result)) {
@@ -161,15 +175,15 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
             }
         }
     }
-    
+
     @Override
     public void handleOutgoingMessage(IOFSwitch sw, OFMessage m, FloodlightContext bc) {
         List<IOFMessageListener> msgListeners = null;
         if (listeners.containsKey(m.getType())) {
             msgListeners = listeners.get(m.getType()).getOrderedListeners();
         }
-            
-        if (msgListeners != null) {                
+
+        if (msgListeners != null) {
             for (IOFMessageListener listener : msgListeners) {
                 if (listener instanceof IOFSwitchFilter) {
                     if (!((IOFSwitchFilter)listener).isInterested(sw)) {
@@ -182,7 +196,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
             }
         }
     }
-    
+
     public void handleOutgoingMessages(IOFSwitch sw, List<OFMessage> msglist, FloodlightContext bc) {
         for (OFMessage m:msglist) {
             handleOutgoingMessage(sw, m, bc);
@@ -195,7 +209,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     public List<IOFSwitchListener> getSwitchListeners() {
         return switchListeners;
     }
-    
+
     @Override
     public void terminate() {
     }
@@ -205,14 +219,14 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
         dispatchMessage(sw, msg);
         return true;
     }
-    
+
     @Override
-    public boolean injectOfMessage(IOFSwitch sw, OFMessage msg, 
-                                   FloodlightContext bContext) {        
-        dispatchMessage(sw, msg, bContext);     
+    public boolean injectOfMessage(IOFSwitch sw, OFMessage msg,
+                                   FloodlightContext bContext) {
+        dispatchMessage(sw, msg, bContext);
         return true;
     }
-    
+
     @Override
     public BasicFactory getOFMessageFactory() {
         return factory;
@@ -235,7 +249,7 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     public Map<Class<? extends IFloodlightService>, IFloodlightService>
             getServiceImpls() {
         Map<Class<? extends IFloodlightService>,
-            IFloodlightService> m = 
+            IFloodlightService> m =
                 new HashMap<Class<? extends IFloodlightService>,
                         IFloodlightService>();
         m.put(IFloodlightProviderService.class, this);
@@ -247,30 +261,30 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
             getModuleDependencies() {
         return null;
     }
-    
+
     @Override
     public void init(FloodlightModuleContext context)
                                                  throws FloodlightModuleException {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override
     public void startUp(FloodlightModuleContext context) {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override
     public void addInfoProvider(String type, IInfoProvider provider) {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override
     public void removeInfoProvider(String type, IInfoProvider provider) {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override
@@ -288,17 +302,17 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
     public void removeHAListener(IHAListener listener) {
         haListeners.remove(listener);
     }
-    
+
     @Override
     public Role getRole() {
         return null;
     }
-    
+
     @Override
     public void setRole(Role role, String roleChangeDescription) {
-        
+
     }
-    
+
     /**
      * Dispatches a new role change notification
      * @param oldRole
@@ -325,14 +339,14 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
 
     private void logListeners() {
         for (Map.Entry<OFType,
-                       ListenerDispatcher<OFType, 
+                       ListenerDispatcher<OFType,
                                           IOFMessageListener>> entry
              : listeners.entrySet()) {
-            
+
             OFType type = entry.getKey();
-            ListenerDispatcher<OFType, IOFMessageListener> ldd = 
+            ListenerDispatcher<OFType, IOFMessageListener> ldd =
                     entry.getValue();
-            
+
             StringBuffer sb = new StringBuffer();
             sb.append("OFListeners for ");
             sb.append(type);
@@ -341,20 +355,20 @@ public class MockFloodlightProvider implements IFloodlightModule, IFloodlightPro
                 sb.append(l.getName());
                 sb.append(",");
             }
-            log.debug(sb.toString());            
+            log.debug(sb.toString());
         }
     }
 
     @Override
     public void setAlwaysClearFlowsOnSwAdd(boolean value) {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override
     public void addOFSwitchDriver(String desc, IOFSwitchDriver driver) {
         // TODO Auto-generated method stub
-        
+
     }
 
     @Override