use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class AbstractMatchEntryDeserializer method readPrefix.
/**
* Read Ipv4Prefix from message.
* @param message buffered message
* @param hasMask determines if prefix has mask or not
* @return IPv4 prefix
*/
protected static Ipv4Prefix readPrefix(ByteBuf message, boolean hasMask) {
final Ipv4Address address = ByteBufUtils.readIetfIpv4Address(message);
int mask = 32;
if (hasMask) {
mask = IpConversionUtil.countBits(OxmDeserializerHelper.convertMask(message, EncodeConstants.GROUPS_IN_IPV4_ADDRESS));
}
return IpConversionUtil.createPrefix(address, mask);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class ArpTargetTransportAddressEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final Ipv4Prefix arpTargetTransportAddress = new Ipv4Prefix("192.168.0.0/24");
final Ipv4Prefix arpTargetTransportAddressNoMask = new Ipv4Prefix("192.168.0.0/32");
writeHeader(in, false);
Iterator<String> addressParts = IpConversionUtil.splitToParts(arpTargetTransportAddressNoMask);
in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
assertEquals(arpTargetTransportAddressNoMask.getValue(), ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetTransportAddress().getValue());
assertEquals(0, in.readableBytes());
writeHeader(in, true);
addressParts = IpConversionUtil.splitToParts(arpTargetTransportAddress);
in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
final Ipv4Prefix desAddress = ArpMatch.class.cast(deserialize(in).getLayer3Match()).getArpTargetTransportAddress();
assertEquals(arpTargetTransportAddress.getValue(), desAddress.getValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class Ipv4SourceEntryDeserializerTest method deserializeEntry.
@Test
public void deserializeEntry() throws Exception {
final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
final Ipv4Prefix address = new Ipv4Prefix("192.168.72.0/24");
final Iterator<String> addressParts = IpConversionUtil.splitToParts(address);
writeHeader(in, true);
in.writeBytes(IetfInetUtil.INSTANCE.ipv4AddressBytes(new Ipv4Address(addressParts.next())));
in.writeBytes(MatchConvertorUtil.extractIpv4Mask(addressParts));
final Ipv4Match match = Ipv4Match.class.cast(deserialize(in).getLayer3Match());
assertEquals(address.getValue(), match.getIpv4Source().getValue());
assertEquals(0, in.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class SetNwDstActionSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv4 address = new Ipv4Builder().setIpv4Address(new Ipv4Prefix("192.168.76.2/32")).build();
final Action action = new SetNwDstActionCaseBuilder().setSetNwDstAction(new SetNwDstActionBuilder().setAddress(address).build()).build();
assertAction(action, out -> {
byte[] addressBytes = new byte[4];
out.readBytes(addressBytes);
assertArrayEquals(addressBytes, new byte[] { (byte) 192, (byte) 168, 76, 2 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createMatch1.
private static MatchBuilder createMatch1() {
final MatchBuilder match = new MatchBuilder();
final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
ipv4Match.setIpv4Destination(prefix);
final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
final EthernetMatchBuilder eth = new EthernetMatchBuilder();
final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
Aggregations