use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder in project openflowplugin by opendaylight.
the class OfToSalArpShaCase method process.
@Override
public Optional<MatchBuilder> process(@Nonnull ArpShaCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final MatchBuilder matchBuilder = data.getMatchBuilder();
final ArpMatchBuilder arpMatchBuilder = data.getArpMatchBuilder();
ArpSha arpSha = source.getArpSha();
MacAddress macAddress = arpSha.getMacAddress();
if (macAddress != null) {
ArpSourceHardwareAddressBuilder arpSourceHardwareAddressBuilder = new ArpSourceHardwareAddressBuilder();
arpSourceHardwareAddressBuilder.setAddress(macAddress);
byte[] mask = arpSha.getMask();
if (mask != null) {
arpSourceHardwareAddressBuilder.setMask(new MacAddress(ByteBufUtils.macAddressToString(mask)));
}
arpMatchBuilder.setArpSourceHardwareAddress(arpSourceHardwareAddressBuilder.build());
matchBuilder.setLayer3Match(arpMatchBuilder.build());
}
return Optional.of(matchBuilder);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder 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.ArpSourceHardwareAddressBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction43.
private static InstructionsBuilder createAppyActionInstruction43() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final ActionBuilder ab1 = new ActionBuilder();
final ActionBuilder ab2 = new ActionBuilder();
final ActionBuilder ab3 = new ActionBuilder();
final ActionBuilder ab4 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
// setting the values of ARP
final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
// create ARP match action
final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
arpsrc.setAddress(macsrc);
final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
arpdst.setAddress(macdest);
arpmatch.setArpOp(2);
arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
arpmatch2.setArpTargetHardwareAddress(arpdst.build());
arpmatch3.setArpSourceTransportAddress(srciparp);
arpmatch4.setArpTargetTransportAddress(dstiparp);
setFieldBuilder.setLayer3Match(arpmatch.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setLayer3Match(arpmatch1.build());
ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
setFieldBuilder2.setLayer3Match(arpmatch2.build());
ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
ab2.setKey(new ActionKey(2));
actionList.add(ab2.build());
setFieldBuilder3.setLayer3Match(arpmatch3.build());
ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
ab3.setKey(new ActionKey(3));
actionList.add(ab3.build());
setFieldBuilder4.setLayer3Match(arpmatch4.build());
ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
ab4.setKey(new ActionKey(4));
actionList.add(ab4.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeArpMatch.
@Test
public void normalizeArpMatch() {
final int arpOp = 10;
final String source = "192.168.1.2/24";
final String destination = "192.168.2.2/24";
final MacAddress sourceHw = new MacAddress("01:23:45:AB:CD:EF");
final MacAddress dstHw = new MacAddress("01:23:45:AB:C0:EF");
final MacAddress mask = new MacAddress("FF:FF:FF:FF:FF:FF");
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeArpMatch(new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpOp(10).setArpSourceTransportAddress(new Ipv4Prefix(source)).setArpTargetTransportAddress(new Ipv4Prefix(destination)).setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(dstHw).setMask(mask).build()).setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(sourceHw).setMask(mask).build()).build()));
assertEquals(arpOp, ArpMatch.class.cast(matchBuilder.getLayer3Match()).getArpOp().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testArpMatchConversionWithMasks.
@Test
public void testArpMatchConversionWithMasks() {
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
/* Use canonnical prefixes !!! */
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));
arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));
ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
srcHwBuilder.setMask(new MacAddress("00:00:00:00:00:08"));
arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(arpBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 4, entries.size());
MatchEntry entry = entries.get(0);
entry = entries.get(0);
checkEntryHeader(entry, ArpSpa.class, true);
Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp spa mask", new byte[] { (byte) 255, 0, 0, 0 }, ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());
entry = entries.get(1);
checkEntryHeader(entry, ArpTpa.class, true);
Assert.assertEquals("Wrong arp tpa", "10.0.0.4", ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getIpv4Address().getValue());
Assert.assertArrayEquals("Wrong arp tpa mask", new byte[] { (byte) 255, (byte) 255, (byte) 255, (byte) 254 }, ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getMask());
entry = entries.get(2);
checkEntryHeader(entry, ArpSha.class, true);
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp sha mask", new byte[] { 0, 0, 0, 0, 0, 8 }, ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMask());
entry = entries.get(3);
checkEntryHeader(entry, ArpTha.class, true);
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMacAddress().getValue());
Assert.assertArrayEquals("Wrong arp tha mask", new byte[] { 0, 0, 0, 0, 0, 9 }, ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());
}
Aggregations