Merge "Openflowyang - added StripVlan, nwTos changes"
authorEd Warnicke <eaw@cisco.com>
Thu, 12 Dec 2013 21:22:32 +0000 (21:22 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 12 Dec 2013 21:22:32 +0000 (21:22 +0000)
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/utils/NodeConnectorCreator.java

index 012807eee9ff622e5469a035b2a0e0e7b3294496..811135252da07b5137d33d9a9f78380229346f42 100644 (file)
@@ -125,7 +125,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
     private Boolean throttling = false; // if true, no more batching.
     private volatile Boolean shuttingDown = false;
 
-    private LLDPTLV chassisIdTlv, portIdTlv, ttlTlv, customTlv;
+    private LLDPTLV chassisIdTlv, systemNameTlv, portIdTlv, ttlTlv, customTlv;
     private IPluginOutConnectionService connectionOutService;
 
     class DiscoveryTransmit implements Runnable {
@@ -217,6 +217,11 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
         chassisIdTlv.setType(LLDPTLV.TLVType.ChassisID.getValue()).setLength((short) cidValue.length)
                 .setValue(cidValue);
 
+        // Create LLDP SystemName TLV
+        byte[] snValue = LLDPTLV.createSystemNameTLVValue(nodeConnector.getNode().toString());
+        systemNameTlv.setType(LLDPTLV.TLVType.SystemName.getValue()).setLength((short) snValue.length)
+                .setValue(snValue);
+
         // Create LLDP PortID TLV
         String portId = nodeConnector.getNodeConnectorIDString();
         byte[] pidValue = LLDPTLV.createPortIDTLVValue(portId);
@@ -233,7 +238,8 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
 
         // Create discovery pkt
         LLDP discoveryPkt = new LLDP();
-        discoveryPkt.setChassisId(chassisIdTlv).setPortId(portIdTlv).setTtl(ttlTlv).setOptionalTLVList(customList);
+        discoveryPkt.setChassisId(chassisIdTlv).setPortId(portIdTlv).setTtl(ttlTlv).setSystemNameId(systemNameTlv)
+                .setOptionalTLVList(customList);
 
         RawPacket rawPkt = null;
         try {
@@ -1462,6 +1468,10 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
         chassisIdTlv = new LLDPTLV();
         chassisIdTlv.setType(LLDPTLV.TLVType.ChassisID.getValue());
 
+        // Create LLDP SystemName TLV
+        systemNameTlv = new LLDPTLV();
+        systemNameTlv.setType(LLDPTLV.TLVType.SystemName.getValue());
+
         // Create LLDP PortID TLV
         portIdTlv = new LLDPTLV();
         portIdTlv.setType(LLDPTLV.TLVType.PortID.getValue());
index 6a896c6c712aee0e06d94b7be31bbf27529c7845..95edca943bc8a61681c34c582f4aeb9dddb7972e 100644 (file)
@@ -21,9 +21,10 @@ import org.opendaylight.controller.sal.utils.NetUtils;
 
 public class LLDP extends Packet {
     private static final String CHASSISID = "ChassisId";
+    private static final String SYSTEMNAMEID = "SystemNameID";
     private static final String PORTID = "PortId";
     private static final String TTL = "TTL";
-    private static final int LLDPDefaultTlvs = 3;
+    private static final int LLDPDefaultTlvs = 4;
     private static LLDPTLV emptyTLV = new LLDPTLV().setLength((short) 0)
             .setType((byte) 0);
     public static final byte[] LLDPMulticastMac = { 1, (byte) 0x80,
@@ -101,6 +102,22 @@ public class LLDP extends Packet {
         return this;
     }
 
+    /**
+     * @return the SystemName TLV
+     */
+    public LLDPTLV getSystemNameId() {
+        return getTLV(SYSTEMNAMEID);
+    }
+
+    /**
+     * @param LLDPTLV
+     *            - the chassisId to set
+     */
+    public LLDP setSystemNameId(LLDPTLV systemNameId) {
+        tlvList.put(getType(SYSTEMNAMEID), systemNameId);
+        return this;
+    }
+
     /**
      * @return LLDPTLV - the portId TLV
      */
index bf674022596d8eb09df2b99bdb72314bdbdaf2cc..27660221ceb56da61d3c6c68cdfd46a13622ef96 100644 (file)
@@ -187,6 +187,18 @@ public class LLDPTLV extends Packet {
                 getfieldnumBits(VALUE)); // variable
     }
 
+    /**
+     * Creates the SystemName TLV value
+     *
+     * @param nodeId
+     *            node identifier string
+     * @return the SystemName TLV value in byte array
+     */
+    static public byte[] createSystemNameTLVValue(String nodeId) {
+        byte[] nid = nodeId.getBytes();
+        return nid;
+    }
+
     /**
      * Creates the ChassisID TLV value including the subtype and ChassisID
      * string
index da4cd5388380f81f69fd9dc9a431da61093a67a6..9cd551664cb945bb4a0c7ed279507a9870fe9b1e 100644 (file)
@@ -73,7 +73,11 @@ public abstract class NodeConnectorCreator {
     public static NodeConnector createNodeConnector(
             String nodeConnectorType, Object portId, Node node) {
         try {
-            return new NodeConnector(nodeConnectorType, portId, node);
+            if (nodeConnectorType.equals(Node.NodeIDType.OPENFLOW) && (portId.getClass() == String.class)) {
+                return new NodeConnector(nodeConnectorType, Short.parseShort((String) portId), node);
+            } else {
+                return new NodeConnector(nodeConnectorType, portId, node);
+            }
         } catch (ConstructionException e1) {
             logger.error("",e1);
             return null;