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 testArpMatchConversion.
@Test
public void testArpMatchConversion() {
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
arpBuilder.setArpOp(5);
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/32"));
arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/32"));
ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();
srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
arpBuilder.setArpSourceHardwareAddress(srcHwBuilder.build());
ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
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", 5, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, ArpOp.class, false);
Assert.assertEquals("Wrong arp op", 5, ((ArpOpCase) entry.getMatchEntryValue()).getArpOp().getOpCode().intValue());
entry = entries.get(1);
checkEntryHeader(entry, ArpSpa.class, false);
Assert.assertEquals("Wrong arp spa", "10.0.0.3", ((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getIpv4Address().getValue());
entry = entries.get(2);
checkEntryHeader(entry, ArpTpa.class, false);
Assert.assertEquals("Wrong arp tpa", "10.0.0.4", ((ArpTpaCase) entry.getMatchEntryValue()).getArpTpa().getIpv4Address().getValue());
entry = entries.get(3);
checkEntryHeader(entry, ArpSha.class, false);
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:05", ((ArpShaCase) entry.getMatchEntryValue()).getArpSha().getMacAddress().getValue());
entry = entries.get(4);
checkEntryHeader(entry, ArpTha.class, false);
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:06", ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMacAddress().getValue());
}
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 createArpMatch.
private static MatchBuilder createArpMatch() {
final MatchBuilder match = new MatchBuilder();
final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
final EtherType type = new EtherType(0x0806L);
ethmatch.setEthernetType(ethtype.setType(type).build());
// ipv4 match
final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
// arp match
final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
arpsrc.setAddress(macsrc);
arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
arpdst.setAddress(macdest);
arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
arpmatch.setArpOp(2);
arpmatch.setArpSourceHardwareAddress(arpsrc.build());
arpmatch.setArpTargetHardwareAddress(arpdst.build());
arpmatch.setArpSourceTransportAddress(srcip);
arpmatch.setArpTargetTransportAddress(dstip);
match.setEthernetMatch(ethmatch.build());
match.setLayer3Match(arpmatch.build());
return match;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder in project openflowplugin by opendaylight.
the class ArpSourceHardwareAddressEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final MacAddress address = new MacAddress("00:01:02:03:04:05");
final MacAddress mask = new MacAddress("00:00:00:00:00:00");
final Match arpShaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(address).setMask(mask).build()).build()).build();
assertMatch(arpShaMatch, true, (out) -> {
byte[] addressBytes = new byte[6];
out.readBytes(addressBytes);
assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
byte[] maskBytes = new byte[6];
out.readBytes(maskBytes);
assertEquals(new MacAddress(ByteBufUtils.macAddressToString(maskBytes)).getValue(), mask.getValue());
});
final Match arpShaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpSourceHardwareAddress(new ArpSourceHardwareAddressBuilder().setAddress(address).build()).build()).build();
assertMatch(arpShaMatchNoMask, false, (out) -> {
byte[] addressBytes = new byte[6];
out.readBytes(addressBytes);
assertEquals(new MacAddress(ByteBufUtils.macAddressToString(addressBytes)).getValue(), address.getValue());
});
}
Aggregations