use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder 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());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.
the class ArpTargetHardwareAddressEntrySerializerTest 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().setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().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().setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().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());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.
the class ArpOpEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final int arpOp = message.readUnsignedShort();
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpOp(arpOp).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpOp())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpOp(arpOp).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpOp");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.
the class ArpTargetTransportAddressEntryDeserializer method deserializeEntry.
@Override
public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
final boolean hasMask = processHeader(message);
final Layer3Match layer3Match = builder.getLayer3Match();
final Ipv4Prefix prefix = readPrefix(message, hasMask);
if (Objects.isNull(layer3Match)) {
builder.setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(prefix).build());
} else if (ArpMatch.class.isInstance(layer3Match) && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetTransportAddress())) {
builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match)).setArpTargetTransportAddress(prefix).build());
} else {
throwErrorOnMalformed(builder, "layer3Match", "arpTargetTransportAddress");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder in project openflowplugin by opendaylight.
the class ArpTargetTransportAddressEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Match arpSpaMatch = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(new Ipv4Prefix("10.0.2.0/24")).build()).build();
assertMatch(arpSpaMatch, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 2, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match arpSpaMatchNoMask = new MatchBuilder().setLayer3Match(new ArpMatchBuilder().setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.0/32")).build()).build();
assertMatch(arpSpaMatchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { 10, 0, 0, 0 });
});
}
Aggregations