use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress in project openflowplugin by opendaylight.
the class ArpTargetHardwareAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final ArpTargetHardwareAddressBuilder arpBuilder = new ArpTargetHardwareAddressBuilder().setAddress(OxmDeserializerHelper.convertMacAddress(message));
if (hasMask) {
arpBuilder.setMask(OxmDeserializerHelper.convertMacAddress(message));
}
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpTargetHardwareAddress(arpBuilder.build()).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetHardwareAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpTargetHardwareAddress(arpBuilder.build()).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpTargetHardwareAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress in project openflowplugin by opendaylight.
the class ArpTargetHardwareAddressEntrySerializer method serialize.
@Override
public void serialize(Match match, ByteBuf outBuffer) {
super.serialize(match, outBuffer);
final ArpTargetHardwareAddress arpTargetHardwareAddress = ArpMatch.class.cast(match.getLayer3Match()).getArpTargetHardwareAddress();
writeMacAddress(arpTargetHardwareAddress.getAddress(), outBuffer);
if (getHasMask(match)) {
writeMask(ByteBufUtils.macAddressToBytes(arpTargetHardwareAddress.getMask().getValue()), outBuffer, getValueLength());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress 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.ArpTargetHardwareAddress in project openflowplugin by opendaylight.
the class ArpTargetHardwareAddressEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final MacAddress arpTargetHardwareAddress = new MacAddress("00:01:02:03:04:05");
final MacAddress arpTargetHardwareAddressMask = new MacAddress("00:00:00:00:00:00");
writeHeader(in, false);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddress));
assertEquals(arpTargetHardwareAddress.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetHardwareAddress().getAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddress));
in.writeBytes(IetfYangUtil.INSTANCE.bytesFor(arpTargetHardwareAddressMask));
final ArpTargetHardwareAddress desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetHardwareAddress();
assertEquals(arpTargetHardwareAddress.getValue(), desAddress.getAddress().getValue());
assertEquals(arpTargetHardwareAddressMask.getValue(), desAddress.getMask().getValue());
assertEquals(0, in.readableBytes());
}
Aggregations