use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address 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.inet.types.rev130715.Ipv4Address 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.inet.types.rev130715.Ipv4Address in project openflowplugin by opendaylight.
the class Ipv4ArbitraryBitMaskDestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv4Address ipv4Address = new Ipv4Address("192.168.10.0");
final DottedQuad ipv4mask = new DottedQuad("255.255.255.0");
final Match ipv4abmMatch = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).setIpv4DestinationArbitraryBitmask(ipv4mask).build()).build();
assertMatch(ipv4abmMatch, true, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
byte[] mask = new byte[4];
out.readBytes(mask);
assertArrayEquals(mask, new byte[] { (byte) 255, (byte) 255, (byte) 255, 0 });
});
final Match ipv4abmMatchNoMask = new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4DestinationAddressNoMask(ipv4Address).build()).build();
assertMatch(ipv4abmMatchNoMask, false, (out) -> {
byte[] address = new byte[4];
out.readBytes(address);
assertArrayEquals(address, new byte[] { (byte) 192, (byte) 168, 10, 0 });
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project openflowplugin by opendaylight.
the class TunIPv4SrcConvertor method convert.
@Override
public MatchEntry convert(Extension extension) {
Optional<NxmNxTunIpv4SrcGrouping> matchGrouping = MatchUtil.TUN_IPV4_SRC_RESOLVER.getExtension(extension);
if (!matchGrouping.isPresent()) {
throw new CodecPreconditionException(extension);
}
Ipv4Address value = matchGrouping.get().getNxmNxTunIpv4Src().getIpv4Address();
TunIpv4SrcCaseValueBuilder tunIpv4SrcCaseValueBuilder = new TunIpv4SrcCaseValueBuilder();
tunIpv4SrcCaseValueBuilder.setTunIpv4SrcValues(new TunIpv4SrcValuesBuilder().setValue(MatchUtil.ipv4ToLong(value)).build());
return MatchUtil.createDefaultMatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Src.class, Nxm1Class.class, tunIpv4SrcCaseValueBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project openflowplugin by opendaylight.
the class IpConverterTest method testIpv4AddressToLong2.
@Test
public void testIpv4AddressToLong2() {
Ipv4Address ipAddress = new Ipv4Address("10.168.1.2");
long address = 0x0aa80102L;
assertEquals(address, IpConverter.ipv4AddressToLong(ipAddress));
}
Aggregations