Added cookie into flows created during learning 62/5262/1
authorMichal Rehak <mirehak@cisco.com>
Tue, 11 Feb 2014 16:50:31 +0000 (17:50 +0100)
committerMichal Rehak <mirehak@cisco.com>
Tue, 11 Feb 2014 16:50:31 +0000 (17:50 +0100)
- cookie is unique per switch

Change-Id: I7aacc889a35c2bd4a785e96ba562d8fe3f6194ff
Signed-off-by: Michal Rehak <mirehak@cisco.com>
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java

index 2bd2bd2f164e1bfdafc73c0eedc19582c88068b9..080f6d1ff4c1e8b8a008693f4c8fbcd0e8fccebd 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.learningswitch;
 
+import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -60,6 +61,8 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
     private NodeId nodeId;
     private AtomicLong flowIdInc = new AtomicLong();
+    private AtomicLong flowCookieInc = new AtomicLong(0x2a00000000000000L);
+    
     private InstanceIdentifier<Node> nodePath;
     private InstanceIdentifier<Table> tablePath;
 
@@ -208,6 +211,7 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
                 Short tableId = InstanceIdentifierUtils.getTableId(tablePath);
                 FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac,
                         dstMac, destNodeConnector);
+                srcToDstFlow.setCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement()));
 
                 dataStoreAccessor.writeFlowToConfig(flowPath, srcToDstFlow.build());
             }