import java.math.BigInteger;
-public class MetaDataUtil {
+public final class MetaDataUtil {
public static final BigInteger METADATA_MASK_LPORT_TAG = new BigInteger("0FFFFF0000000000", 16);
public static final BigInteger METADATA_MASK_SERVICE = new BigInteger("000000FFFF000000", 16);
public static final BigInteger METADATA_MASK_SERVICE_INDEX = new BigInteger("F000000000000000", 16);
public static final BigInteger METADATA_MASK_VRFID = new BigInteger("0000000000FFFFFE", 16);
- public static final BigInteger METADATA_MASK_REMOTE_ACL_ID = new BigInteger("0000000000FFFFFE", 16);
+ public static final BigInteger METADATA_MASK_REMOTE_ACL_TAG = new BigInteger("0000000000FFFFF0", 16);
public static final BigInteger METADATA_MASK_POLICY_CLASSIFER_ID = new BigInteger("0000000000FFFFFE", 16);
public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID
= new BigInteger("08000000FFFFFF00", 16);
public static final BigInteger METADATA_MASK_SH_FLAG = new BigInteger("0000000000000001", 16);
public static final BigInteger METADATA_MASK_ELAN_SUBNET_ROUTE = new BigInteger("000000FFFF000000", 16);
public static final BigInteger METADATA_MASK_SUBNET_ROUTE = new BigInteger("000000FFFFFFFFFE", 16);
+ public static final BigInteger METADATA_MASK_ACL_CONNTRACK_CLASSIFIER_TYPE = new BigInteger("0000000000000002", 16);
+ public static final BigInteger METADATA_MASK_ACL_DROP = new BigInteger("0000000000000004", 16);
+
+ public static final int METADATA_ELAN_TAG_OFFSET = 24;
+ public static final int METADATA_ELAN_TAG_BITLEN = 16;
+ public static final int METADATA_VPN_ID_OFFSET = 1;
+ public static final int METADATA_VPN_ID_BITLEN = 23;
+
+ private MetaDataUtil() { }
public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) {
return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag));
return getVpnIdFromMetadata(metadata);
}
+ /**
+ * Gets the ACL conntrack classifier type from meta data.<br>
+ * Second bit in metadata is used for this purpose.<br>
+ *
+ * <p>
+ * Conntrack supported traffic is identified by value 0 (0000 in binary)
+ * i.e., 0x0/0x2<br>
+ * Non-conntrack supported traffic is identified by value 2 (0010 in binary)
+ * i.e., 0x2/0x2
+ *
+ * @param conntrackClassifierType the conntrack classifier flag
+ * @return the acl conntrack classifier flag from meta data
+ */
+ public static BigInteger getAclConntrackClassifierTypeFromMetaData(BigInteger conntrackClassifierType) {
+ return METADATA_MASK_ACL_CONNTRACK_CLASSIFIER_TYPE.and(conntrackClassifierType.shiftLeft(1));
+ }
+
+ public static BigInteger getAclDropMetaData(BigInteger dropFlag) {
+ return METADATA_MASK_ACL_DROP.and(dropFlag.shiftLeft(2));
+ }
+
public static BigInteger getVpnIdMetadata(long vrfId) {
return METADATA_MASK_VRFID.and(BigInteger.valueOf(vrfId).shiftLeft(1));
}
return new BigInteger("F", 16).and(BigInteger.valueOf(serviceIndex)).shiftLeft(28);
}
+ public static BigInteger getInterfaceTypeForReg6(int tunnelType) {
+ return new BigInteger("F", 16).and(BigInteger.valueOf(tunnelType)).shiftLeft(4);
+ }
+
public static long getReg6ValueForLPortDispatcher(int lportTag, short serviceIndex) {
return getServiceIndexForReg6(serviceIndex).or(getLportTagForReg6(lportTag)).longValue();
}
+ /** Utility to fetch the register value for lport dispatcher table.
+ * Register6 used for service binding will have first 4 bits of service-index, next 20 bits for lportTag,
+ * and next 4 bits for interface-type
+ */
+ public static long getReg6ValueForLPortDispatcher(int lportTag, short serviceIndex, short interfaceType) {
+ return getServiceIndexForReg6(serviceIndex).or(getLportTagForReg6(lportTag)
+ .or(getInterfaceTypeForReg6(interfaceType))).longValue();
+ }
+
public static long getLportTagMaskForReg6() {
return METADATA_MASK_LPORT_TAG.shiftRight(32).longValue();
}
public static long getVpnIdMaskForReg() {
return METADATA_MASK_VRFID.shiftRight(1).longValue();
}
+
+ public static BigInteger mergeMetadataValues(BigInteger metadata, BigInteger metadata2) {
+ return metadata.or(metadata2);
+ }
+
+ public static BigInteger mergeMetadataMask(BigInteger mask, BigInteger mask2) {
+ return mask.or(mask2);
+ }
}