2. Corrected mac address length in match deserializer.
Signed-off-by: Deepthi V V <deepthi.v.v@ericsson.com>
Change-Id: I5be0c8356d46191bf6430b7b8f855e419d5162f3
public static final byte OF10_VERSION_ID = 0x01;
/** OpenFlow v1.0 wire protocol number */
public static final byte OF13_VERSION_ID = 0x04;
public static final byte OF10_VERSION_ID = 0x01;
/** OpenFlow v1.0 wire protocol number */
public static final byte OF13_VERSION_ID = 0x04;
/** Length of mac address */
public static final byte MAC_ADDRESS_LENGTH = 6;
/** Number of groups in ipv4 address */
/** Length of mac address */
public static final byte MAC_ADDRESS_LENGTH = 6;
/** Number of groups in ipv4 address */
public static final byte GROUPS_IN_IPV6_ADDRESS = 8;
/** Length of ipv6 address in bytes */
public static final byte SIZE_OF_IPV6_ADDRESS_IN_BYTES = (8 * Short.SIZE) / Byte.SIZE;
public static final byte GROUPS_IN_IPV6_ADDRESS = 8;
/** Length of ipv6 address in bytes */
public static final byte SIZE_OF_IPV6_ADDRESS_IN_BYTES = (8 * Short.SIZE) / Byte.SIZE;
/** Length of long in bytes */
public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE;
/** Length of int in bytes */
/** Length of long in bytes */
public static final byte SIZE_OF_LONG_IN_BYTES = Long.SIZE / Byte.SIZE;
/** Length of int in bytes */
public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE;
/** Length of byte in bytes */
public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE;
public static final byte SIZE_OF_SHORT_IN_BYTES = Short.SIZE / Byte.SIZE;
/** Length of byte in bytes */
public static final byte SIZE_OF_BYTE_IN_BYTES = Byte.SIZE / Byte.SIZE;
+ /** Length of 3 bytes */
+ public static final byte SIZE_OF_3_BYTES = 3;
+
/** OF v1.0 maximal port name length */
public static final byte MAX_PORT_NAME_LENGTH = 16;
}
/** OF v1.0 maximal port name length */
public static final byte MAX_PORT_NAME_LENGTH = 16;
}
public abstract class MatchDeserializer {
private static final Logger LOGGER = LoggerFactory.getLogger(MatchDeserializer.class);
public abstract class MatchDeserializer {
private static final Logger LOGGER = LoggerFactory.getLogger(MatchDeserializer.class);
/**
* Creates match
* @param in input ByteBuf
/**
* Creates match
* @param in input ByteBuf
/**
* Deserializes single match entry (oxm_field)
* @param in input ByteBuf
/**
* Deserializes single match entry (oxm_field)
* @param in input ByteBuf
public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {
return createMatchEntriesInternal(in, matchLength, true);
}
public static List<MatchEntries> createMatchEntry(ByteBuf in, int matchLength) {
return createMatchEntriesInternal(in, matchLength, true);
}
/**
* @param in input ByteBuf
* @param matchLength length of match entries
/**
* @param in input ByteBuf
* @param matchLength length of match entries
public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {
return createMatchEntriesInternal(in, matchLength, false);
}
public static List<MatchEntries> createMatchEntries(ByteBuf in, int matchLength) {
return createMatchEntriesInternal(in, matchLength, false);
}
private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) {
List<MatchEntries> matchEntriesList = new ArrayList<>();
int currLength = 0;
while(currLength < matchLength) {
private static List<MatchEntries> createMatchEntriesInternal(ByteBuf in, int matchLength, boolean oneEntry) {
List<MatchEntries> matchEntriesList = new ArrayList<>();
int currLength = 0;
while(currLength < matchLength) {
- MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
- switch (in.readUnsignedShort()) {
+ MatchEntriesBuilder matchEntriesBuilder = new MatchEntriesBuilder();
+ switch (in.readUnsignedShort()) {
case 0x0000:
matchEntriesBuilder.setOxmClass(Nxm0Class.class);
break;
case 0x0000:
matchEntriesBuilder.setOxmClass(Nxm0Class.class);
break;
int matchEntryLength = in.readUnsignedByte();
currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES +
(2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength;
int matchEntryLength = in.readUnsignedByte();
currLength += EncodeConstants.SIZE_OF_SHORT_IN_BYTES +
(2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES) + matchEntryLength;
matchEntriesBuilder.setOxmMatchField(InPort.class);
PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
matchEntriesBuilder.setOxmMatchField(InPort.class);
PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder();
- port.setPortNumber(new PortNumber(in.readUnsignedInt()));
+ port.setPortNumber(new PortNumber(in.readUnsignedInt()));
matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
break;
case 1:
matchEntriesBuilder.setOxmMatchField(InPhyPort.class);
PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();
matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, port.build());
break;
case 1:
matchEntriesBuilder.setOxmMatchField(InPhyPort.class);
PortNumberMatchEntryBuilder phyPort = new PortNumberMatchEntryBuilder();
- phyPort.setPortNumber(new PortNumber(in.readUnsignedInt()));
+ phyPort.setPortNumber(new PortNumber(in.readUnsignedInt()));
matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());
break;
case 2:
matchEntriesBuilder.addAugmentation(PortNumberMatchEntry.class, phyPort.build());
break;
case 2:
matchEntriesBuilder.setOxmMatchField(EthDst.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
matchEntriesBuilder.setOxmMatchField(EthDst.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+ addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
}
break;
case 4:
matchEntriesBuilder.setOxmMatchField(EthSrc.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
}
break;
case 4:
matchEntriesBuilder.setOxmMatchField(EthSrc.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+ addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
matchEntriesBuilder.setOxmMatchField(ArpSha.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
matchEntriesBuilder.setOxmMatchField(ArpSha.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+ addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
}
break;
case 25:
matchEntriesBuilder.setOxmMatchField(ArpTha.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
}
break;
case 25:
matchEntriesBuilder.setOxmMatchField(ArpTha.class);
addMacAddressAugmentation(matchEntriesBuilder, in);
if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+ addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.MAC_ADDRESS_LENGTH);
case 37:
matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
case 37:
matchEntriesBuilder.setOxmMatchField(PbbIsid.class);
IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder();
- isidBuilder.setIsid(in.readUnsignedInt());
+ Integer isid = in.readUnsignedMedium();
+ isidBuilder.setIsid(isid.longValue());
matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
if (hasMask) {
matchEntriesBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build());
if (hasMask) {
- addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+ addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_3_BYTES);
addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
}
break;
addMaskAugmentation(matchEntriesBuilder, in, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
}
break;
break;
}
matchEntriesList.add(matchEntriesBuilder.build());
break;
}
matchEntriesList.add(matchEntriesBuilder.build());
ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));
builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
}
ipv6AddressBuilder.setIpv6Address(new Ipv6Address(joiner.join(groups)));
builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
}
private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();
byte[] metadataBytes = new byte[Long.SIZE/Byte.SIZE];
in.readBytes(metadataBytes);
private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder();
byte[] metadataBytes = new byte[Long.SIZE/Byte.SIZE];
in.readBytes(metadataBytes);
- metadata.setMetadata(metadataBytes);
+ metadata.setMetadata(metadataBytes);
builder.addAugmentation(MetadataMatchEntry.class, metadata.build());
}
builder.addAugmentation(MetadataMatchEntry.class, metadata.build());
}
macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
}
macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address)));
builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build());
}
private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.
private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf in) {
PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();
portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.
short cfi = 1 << 12; // 13-th bit
vlanVidValue = vlanVidValue | cfi;
}
short cfi = 1 << 12; // 13-th bit
vlanVidValue = vlanVidValue | cfi;
}
-
- writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
+
+ writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
out.writeShort(vlanVidValue);
writeMask(entry, out, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
out.writeShort(vlanVidValue);
writeMask(entry, out, EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
writeIpv6AddressRelatedEntry(entry, out, fieldValue);
} else if (field.isAssignableFrom(Ipv6Flabel.class)) {
fieldValue = 28;
writeIpv6AddressRelatedEntry(entry, out, fieldValue);
} else if (field.isAssignableFrom(Ipv6Flabel.class)) {
fieldValue = 28;
- writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
+ writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_INT_IN_BYTES);
out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
writeMask(entry, out, EncodeConstants.SIZE_OF_INT_IN_BYTES);
EncodeConstants.SIZE_OF_INT_IN_BYTES);
out.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue());
writeMask(entry, out, EncodeConstants.SIZE_OF_INT_IN_BYTES);
out.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue());
} else if (field.isAssignableFrom(PbbIsid.class)) {
fieldValue = 37;
out.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue());
} else if (field.isAssignableFrom(PbbIsid.class)) {
fieldValue = 37;
- writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
- EncodeConstants.SIZE_OF_LONG_IN_BYTES);
- out.writeInt(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());
- writeMask(entry, out, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
+ writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(), EncodeConstants.SIZE_OF_3_BYTES);
+ out.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue());
+ writeMask(entry, out, EncodeConstants.SIZE_OF_3_BYTES);
} else if (field.isAssignableFrom(TunnelId.class)) {
fieldValue = 38;
writeMetadataRelatedEntry(entry, out, fieldValue);
} else if (field.isAssignableFrom(TunnelId.class)) {
fieldValue = 38;
writeMetadataRelatedEntry(entry, out, fieldValue);
map.put(7, pseudoField.isUnrep());
map.put(8, pseudoField.isUnseq());
int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
map.put(7, pseudoField.isUnrep());
map.put(8, pseudoField.isUnseq());
int bitmap = ByteBufUtils.fillBitMaskFromMap(map);
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
out.writeShort(bitmap);
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
out.writeShort(bitmap);
fieldAndMask |= 1;
length *= 2;
}
fieldAndMask |= 1;
length *= 2;
}
out.writeByte(fieldAndMask);
out.writeByte(length);
out.writeByte(fieldAndMask);
out.writeByte(length);
}
private static void writeMetadataRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
}
private static void writeMetadataRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
private static void writeMacAddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
int fieldValue = value;
private static void writeMacAddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
int fieldValue = value;
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.MAC_ADDRESS_LENGTH);
String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.MAC_ADDRESS_LENGTH);
String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue();
private static void writeIpv4AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
int fieldValue = value;
private static void writeIpv4AddressRelatedEntry(MatchEntries entry, ByteBuf out, int value) {
int fieldValue = value;
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_INT_IN_BYTES);
writeIpv4Address(entry, out);
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_INT_IN_BYTES);
writeIpv4Address(entry, out);
} else {
address = parseIpv6Address(textAddress.split(":"));
}
} else {
address = parseIpv6Address(textAddress.split(":"));
}
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
for (int i = 0; i < address.length; i++) {
writeOxmFieldAndLength(out, fieldValue, entry.isHasMask(),
EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
for (int i = 0; i < address.length; i++) {
} else if (field.isAssignableFrom(MplsBos.class)) {
length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
} else if (field.isAssignableFrom(PbbIsid.class)) {
} else if (field.isAssignableFrom(MplsBos.class)) {
length += EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
} else if (field.isAssignableFrom(PbbIsid.class)) {
- length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_INT_IN_BYTES);
+ length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_3_BYTES);
} else if (field.isAssignableFrom(TunnelId.class)) {
length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
} else if (field.isAssignableFrom(Ipv6Exthdr.class)) {
} else if (field.isAssignableFrom(TunnelId.class)) {
length += computePossibleMaskEntryLength(entry, EncodeConstants.SIZE_OF_LONG_IN_BYTES);
} else if (field.isAssignableFrom(Ipv6Exthdr.class)) {