Skip to content
Snippets Groups Projects
Commit be1b2312 authored by meiyangbigswitch's avatar meiyangbigswitch
Browse files

APPCookie change to accomodate REWRITE FLAGS

parent fa5de47f
No related branches found
No related tags found
No related merge requests found
...@@ -27,10 +27,17 @@ package net.floodlightcontroller.core.util; ...@@ -27,10 +27,17 @@ package net.floodlightcontroller.core.util;
public class AppCookie { public class AppCookie {
static final int APP_ID_BITS = 12; static final int APP_ID_BITS = 12;
static final int APP_ID_SHIFT = (64 - APP_ID_BITS); static final int APP_ID_SHIFT = (64 - APP_ID_BITS);
// we have bits 13-31 unused here ... that's ok! /**the following bit will be set accordingly if the field is rewritten by application. e.g. VRS or floating IP */
static final int SRC_MAC_REWRITE_BIT=13;
static final int DEST_MAC_REWRITE_BIT=14;
static final int SRC_IP_REWRITE_BIT=15;
static final int DEST_IP_REWRITE_BIT=16;
// we have bits 17-31 unused here ... that's ok!
static final int USER_BITS = 32; static final int USER_BITS = 32;
static final int USER_SHIFT = 0; static final int USER_SHIFT = 0;
static final long REWRITE_MASK= 0x000f000000000000L;
/** /**
* Encapsulate an application ID and a user block of stuff into a cookie * Encapsulate an application ID and a user block of stuff into a cookie
...@@ -51,4 +58,42 @@ public class AppCookie { ...@@ -51,4 +58,42 @@ public class AppCookie {
static public int extractUser(long cookie) { static public int extractUser(long cookie) {
return (int)((cookie>> USER_SHIFT) & ((1L << USER_BITS) - 1)); return (int)((cookie>> USER_SHIFT) & ((1L << USER_BITS) - 1));
} }
static public boolean isRewriteFlagSet(long cookie) {
if ((cookie & REWRITE_MASK) !=0L)
return true;
return false;
}
static public boolean isSrcMacRewriteFlagSet(long cookie) {
if ((cookie & (1L << (64-SRC_MAC_REWRITE_BIT))) !=0L)
return true;
return false;
}
static public boolean isDestMacRewriteFlagSet(long cookie) {
if ((cookie & (1L << (64-DEST_MAC_REWRITE_BIT))) !=0L)
return true;
return false;
}
static public boolean isSrcIpRewriteFlagSet(long cookie) {
if ((cookie & (1L << (64-SRC_IP_REWRITE_BIT))) !=0L)
return true;
return false;
}
static public boolean isDestIpRewriteFlagSet(long cookie) {
if ((cookie & (1L << (64-DEST_IP_REWRITE_BIT))) !=0L)
return true;
return false;
}
static public long setSrcMacRewriteFlag(long cookie) {
return cookie | (1L << (64-SRC_MAC_REWRITE_BIT));
}
static public long setDestMacRewriteFlag(long cookie) {
return cookie | (1L << (64-DEST_MAC_REWRITE_BIT));
}
static public long setSrcIpRewriteFlag(long cookie) {
return cookie | (1L << (64-SRC_IP_REWRITE_BIT));
}
static public long setDestIpRewriteFlag(long cookie) {
return cookie | (1L << (64-DEST_IP_REWRITE_BIT));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment