use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class MapReplySerializationTest method deserialize__All.
@Test
public void deserialize__All() throws Exception {
MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 02 00 00 " + "00 02 02 20 00 00 00 00 " + "00 01 01 02 03 04 01 02 " + "03 04 00 06 00 01 0a 0a " + "0a 0a 04 03 02 01 00 01 " + "00 02 00 01 00 02 00 03 " + "00 04 00 05 00 06 00 07 00 08 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
assertEquals(2, mr.getNonce().longValue());
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
// XXX Why here normalized and other cases not normalized?
assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
assertArrayEquals(new byte[] { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8 }, ((Ipv6Binary) mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getRloc().getAddress()).getIpv6Binary().getValue());
assertArrayEquals(new byte[] { 10, 10, 10, 10 }, ((Ipv4Binary) mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc().getAddress()).getIpv4Binary().getValue());
assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getPriority().byteValue());
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getWeight().byteValue());
assertEquals(3, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getMulticastPriority().byteValue());
assertEquals(4, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getMulticastWeight().byteValue());
assertEquals(4, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getPriority().byteValue());
assertEquals(3, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getWeight().byteValue());
assertEquals(2, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getMulticastPriority().byteValue());
assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).getMulticastWeight().byteValue());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isLocalLocator());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isRlocProbed());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).isRouted());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isLocalLocator());
assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isRlocProbed());
assertEquals(true, mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(1).isRouted());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class MapRequestSerializationTest method deserialize__MultipleItrRlocs.
@Test
public void deserialize__MultipleItrRlocs() throws Exception {
MapRequest mr = MapRequestSerializer.getInstance().deserialize(hexToByteBuffer("10 00 " + // This means 3 ITR - RLOCs
"02 " + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " + // IPv4 (ITR-RLOC #1 of 3)
"00 01 c0 a8 88 0a " + // IPv6 (ITR-RLOC #2 of 3)
"00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 " + //
"00 01 11 22 34 56 " + // IPv4 (ITR-RLOC #3 of 3)
"00 20 00 01 01 02 03 04"), null);
assertEquals(3, mr.getItrRloc().size());
assertArrayEquals(new byte[] { (byte) 192, (byte) 168, (byte) 136, (byte) 10 }, ((Ipv4Binary) mr.getItrRloc().get(0).getRloc().getAddress()).getIpv4Binary().getValue());
assertArrayEquals(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, ((Ipv6Binary) mr.getItrRloc().get(1).getRloc().getAddress()).getIpv6Binary().getValue());
assertArrayEquals(new byte[] { 17, 34, 52, 86 }, ((Ipv4Binary) mr.getItrRloc().get(2).getRloc().getAddress()).getIpv4Binary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asIpvRloc.
/**
* Test {@link LispAddressUtil#asIpv4Rloc(String)} method with ipv4 or ipv6.
* Test {@link LispAddressUtil#asIpv6Rloc(String)} method with ipv4 or ipv6.
*/
@Test
public void asIpvRloc() {
final Rloc rlocFromIpV4 = LispAddressUtil.asIpv4Rloc(IPV4_ADDRESS_VALUE_TEST);
assertEquals(Ipv4BinaryAfi.class, rlocFromIpV4.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromIpV4.getAddress()).getIpv4Binary());
final Rloc rlocFromIpV6 = LispAddressUtil.asIpv6Rloc(IPV6_ADDRESS_VALUE_TEST);
assertEquals(Ipv6BinaryAfi.class, rlocFromIpV6.getAddressType());
assertEquals(IPV6_ADDRESS_BINARY_TEST, ((Ipv6Binary) rlocFromIpV6.getAddress()).getIpv6Binary());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromInet_ipv6.
/**
* Tests {@link LispAddressUtil#binaryAddressFromInet(InetAddress)} and
* {@link LispAddressUtil#binaryAddressTypeFromInet(InetAddress)} methods with ipv6 address.
*/
@Test
public void binaryAddressFromInet_ipv6() throws UnknownHostException {
final InetAddress ipv6InetAddress = Inet6Address.getByAddress(IPV6_ADDRESS_BYTES_A_TEST);
Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromInet(ipv6InetAddress);
assertEquals(Ipv6BinaryAfi.class, addressClass);
final Address address = LispAddressUtil.binaryAddressFromInet(ipv6InetAddress);
assertTrue(address instanceof Ipv6Binary);
assertArrayEquals(IPV6_ADDRESS_BYTES_A_TEST, ((Ipv6Binary) address).getIpv6Binary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromIpAddress_null.
/**
* Tests {@link LispAddressUtil#binaryAddressFromIpAddress(IpAddress)} and {@link
* LispAddressUtil#binaryAddressTypeFromIpAddress(IpAddress)}
* methods with Ipv6Binary address.
*/
@Test
public void binaryAddressFromIpAddress_null() {
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromIpAddress(null);
assertNull(addressClass);
final Address address = LispAddressUtil.binaryAddressFromIpAddress(null);
assertNull(address);
}
Aggregations