use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress in project openflowplugin by opendaylight.
the class ArpSourceHardwareAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final ArpSourceHardwareAddressBuilder arpBuilder = new ArpSourceHardwareAddressBuilder().setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(arpBuilder.build()).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceHardwareAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpSourceHardwareAddress(arpBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpSourceHardwareAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress in project openflowplugin by opendaylight.
the class ArpSourceHardwareAddressEntrySerializer method serialize.
@Override
public void serialize(Match match, ByteBuf outBuffer) {
super.serialize(match, outBuffer);
final ArpSourceHardwareAddress arpSourceHardwareAddress = ArpMatch.class.cast(match.getLayer3Match()).getArpSourceHardwareAddress();
writeMacAddress(arpSourceHardwareAddress.getAddress(), outBuffer);
if (getHasMask(match)) {
writeMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()), outBuffer, getValueLength());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress in project openflowplugin by opendaylight.
the class SalToOfArpMatchCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull ArpMatch source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getArpOp() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setOxmMatchField(ArpOp.class);
ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
arpOpBuilder.setOpCode(source.getArpOp());
arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
matchEntryBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getArpSourceTransportAddress() != null) {
Ipv4Prefix ipv4Prefix = source.getArpSourceTransportAddress();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(ArpSpa.class);
ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
arpSpaBuilder.setIpv4Address(ipv4Address);
boolean hasMask = false;
byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
if (null != mask) {
arpSpaBuilder.setMask(mask);
hasMask = true;
}
matchEntryBuilder.setHasMask(hasMask);
ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
matchEntryBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getArpTargetTransportAddress() != null) {
Ipv4Prefix ipv4Prefix = source.getArpTargetTransportAddress();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(ArpTpa.class);
ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
Iterator<String> addressParts = IpConversionUtil.splitToParts(ipv4Prefix);
Ipv4Address ipv4Address = new Ipv4Address(addressParts.next());
arpTpaBuilder.setIpv4Address(ipv4Address);
boolean hasMask = false;
byte[] mask = MatchConvertorUtil.extractIpv4Mask(addressParts);
if (null != mask) {
arpTpaBuilder.setMask(mask);
hasMask = true;
}
matchEntryBuilder.setHasMask(hasMask);
ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
matchEntryBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
ArpSourceHardwareAddress arpSourceHardwareAddress = source.getArpSourceHardwareAddress();
if (arpSourceHardwareAddress != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(ArpSha.class);
ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
arpShaBuilder.setMacAddress(arpSourceHardwareAddress.getAddress());
boolean hasMask = false;
if (null != arpSourceHardwareAddress.getMask()) {
arpShaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpSourceHardwareAddress.getMask().getValue()));
hasMask = true;
}
arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
matchEntryBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
matchEntryBuilder.setHasMask(hasMask);
result.add(matchEntryBuilder.build());
}
ArpTargetHardwareAddress arpTargetHardwareAddress = source.getArpTargetHardwareAddress();
if (arpTargetHardwareAddress != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(ArpTha.class);
ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
arpThaBuilder.setMacAddress(arpTargetHardwareAddress.getAddress());
boolean hasMask = false;
if (null != arpTargetHardwareAddress.getMask()) {
arpThaBuilder.setMask(ByteBufUtils.macAddressToBytes(arpTargetHardwareAddress.getMask().getValue()));
hasMask = true;
}
arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
matchEntryBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
matchEntryBuilder.setHasMask(hasMask);
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress in project openflowplugin by opendaylight.
the class ArpSourceHardwareAddressEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final MacAddress arpSourceHardwareAddress = new MacAddress("00:01:02:03:04:05");
final MacAddress arpSourceHardwareAddressMask = new MacAddress("00:00:00:00:00:00");
writeHeader(in, false);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
assertEquals(arpSourceHardwareAddress.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress().getAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddress));
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpSourceHardwareAddressMask));
final ArpSourceHardwareAddress desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpSourceHardwareAddress();
assertEquals(arpSourceHardwareAddress.getValue(), desAddress.getAddress().getValue());
assertEquals(arpSourceHardwareAddressMask.getValue(), desAddress.getMask().getValue());
assertEquals(0, in.readableBytes());
}
Aggregations