- Modified the bug of handling multiple OFPorts descriptions

Change-Id: Ia961ff9f432b58c7a9acdd1fa35443ed43334ba7
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
index 5f844f5..2dd458b 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFChannelHandler.java
@@ -113,7 +113,7 @@
 
     // Temporary storage for switch-features and port-description
     private OFFeaturesReply featuresReply;
-    private OFPortDescStatsReply portDescReply;
+    private List<OFPortDescStatsReply> portDescReplies;
     // a concurrent ArrayList to temporarily store port status messages
     // before we are ready to deal with them
     private final CopyOnWriteArrayList<OFPortStatus> pendingPortStatusMsg;
@@ -723,12 +723,28 @@
                             h.channel.getRemoteAddress());
                     return;
                 }
-                if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+                if (h.portDescReplies == null) {
+                    h.portDescReplies = new ArrayList<OFPortDescStatsReply>();
+                    h.portDescReplies.add((OFPortDescStatsReply) m);
+                    if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+                        log.warn("Stats reply indicates more stats from sw {} for "
+                                + "port description - not currently handled",
+                                h.getSwitchInfoString());
+                        return;
+                    }
+
+                }
+                else if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
                     log.warn("Stats reply indicates more stats from sw {} for "
                             + "port description - not currently handled",
                             h.getSwitchInfoString());
+                    h.portDescReplies.add((OFPortDescStatsReply)m);
+                    return;
                 }
-                h.portDescReply = (OFPortDescStatsReply) m; // temp store
+                else {
+                    h.portDescReplies.add((OFPortDescStatsReply)m);
+                }
+                //h.portDescReply = (OFPortDescStatsReply) m; // temp store
                 log.info("Received port desc reply for switch at {}",
                         h.getSwitchInfoString());
                 try {
@@ -863,7 +879,7 @@
                 // set switch information
                 h.sw.setOFVersion(h.ofVersion);
                 ((OFSwitchImplBase) h.sw).setFeaturesReply(h.featuresReply);
-                ((OFSwitchImplBase) h.sw).setPortDescReply(h.portDescReply);
+                ((OFSwitchImplBase) h.sw).setPortDescReplies(h.portDescReplies);
                 h.sw.setConnected(true);
                 h.sw.setChannel(h.channel);
                 h.sw.setFloodlightProvider(h.controller);
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
index a610c0d..501c020 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImplBase.java
@@ -462,6 +462,23 @@
         portManager.updatePorts(pdrep.getEntries());
     }
 
+    /**
+     * Set the port descriptions for this switch from the handshake for an OF1.3
+     * switch.
+     */
+    protected void setPortDescReplies(List<OFPortDescStatsReply> portDescList) {
+        if (ofversion != OFVersion.OF_13)
+            return;
+        if (portDescList == null) {
+            log.error("Error setting ports description for switch: {}", getStringId());
+            return;
+        }
+
+        for (OFPortDescStatsReply portDesc: portDescList) {
+            portManager.updatePorts(portDesc.getEntries());
+        }
+    }
+
     @Override
     public int getNumBuffers() {
         return buffers;
diff --git a/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java b/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
index 213119f..3b9f297 100644
--- a/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
+++ b/src/main/java/net/onrc/onos/core/drivermanager/DriverManager.java
@@ -44,7 +44,7 @@
 
         if (vendor.contains("Dell")
                 &&
-                hw.contains("OpenFlow 1.3")) {
+                hw.contains("OpenFlow switch HW ver. 1.0")) {
             return new OFSwitchImplDellOSR(desc, cpqdUsePipeline13);
         }