use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary in project lispflowmapping by opendaylight.
the class MapRequestSerializationTest method deserialize__ContainsMapReply.
@Test
public void deserialize__ContainsMapReply() throws Exception {
MapRequest mr = MapRequestSerializer.getInstance().deserialize(hexToByteBuffer("16 80 00 " + // single record
"01 " + "3d 8d 2a cd 39 c8 d6 08 00 00 00 01 c0 a8 88 0a " + // end of map request
"00 20 00 01 01 02 03 04 " + "00 00 " + "00 02 01 20 00 00 00 00 " + "00 01 01 02 03 04 01 02 " + "03 04 00 06 00 01 0a 0a " + "0a 0a"), null);
assertEquals(1, mr.getEidItem().size());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32"), mr.getEidItem().get(0).getEid());
MappingRecord record = mr.getMapReply().getMappingRecord();
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32"), record.getEid());
assertEquals(false, record.isAuthoritative());
assertEquals(Action.NoAction, record.getAction());
assertEquals(0, record.getMapVersion().shortValue());
assertEquals(32, MaskUtil.getMaskForAddress(record.getEid().getAddress()));
assertEquals(2, record.getRecordTtl().byteValue());
assertArrayEquals(new byte[] { 10, 10, 10, 10 }, ((Ipv4Binary) record.getLocatorRecord().get(0).getRloc().getAddress()).getIpv4Binary().getValue());
assertEquals(1, record.getLocatorRecord().get(0).getPriority().byteValue());
assertEquals(2, record.getLocatorRecord().get(0).getWeight().byteValue());
assertEquals(3, record.getLocatorRecord().get(0).getMulticastPriority().byteValue());
assertEquals(4, record.getLocatorRecord().get(0).getMulticastWeight().byteValue());
assertEquals(true, record.getLocatorRecord().get(0).isLocalLocator());
assertEquals(true, record.getLocatorRecord().get(0).isRlocProbed());
assertEquals(false, record.getLocatorRecord().get(0).isRouted());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary in project lispflowmapping by opendaylight.
the class InstanceIdSerializerTest method deserialize__Simple.
@Test
public void deserialize__Simple() throws Exception {
Eid address = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"02 20 00 0A " + // instance ID
"00 BB CC DD " + // AFI=1, IP=0x11223344
"00 01 11 22 33 44"), new LispAddressSerializerContext(null));
assertEquals(Ipv4BinaryAfi.class, address.getAddressType());
Ipv4Binary ipv4 = (Ipv4Binary) address.getAddress();
assertArrayEquals(new byte[] { 0x11, 0x22, 0x33, 0x44 }, ipv4.getIpv4Binary().getValue());
assertEquals(0x00BBCCDD, address.getVirtualNetworkId().getValue().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromInet_ipv4.
/**
* Tests {@link LispAddressUtil#binaryAddressFromInet(InetAddress)} and
* {@link LispAddressUtil#binaryAddressTypeFromInet(InetAddress)} methods with ipv4 address.
*/
@Test
public void binaryAddressFromInet_ipv4() throws UnknownHostException {
final InetAddress ipv4InetAddress = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromInet(ipv4InetAddress);
assertEquals(Ipv4BinaryAfi.class, addressClass);
final Address address = LispAddressUtil.binaryAddressFromInet(ipv4InetAddress);
assertTrue(address instanceof Ipv4Binary);
assertArrayEquals(IPV4_ADDRESS_BYTES_A_TEST, ((Ipv4Binary) address).getIpv4Binary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method binaryAddressFromIpAddress_Ipv4Binary.
/**
* Tests {@link LispAddressUtil#binaryAddressFromIpAddress(IpAddress)} and {@link
* LispAddressUtil#binaryAddressTypeFromIpAddress(IpAddress)}
* methods with Ipv4Binary address.
*/
@Test
public void binaryAddressFromIpAddress_Ipv4Binary() {
final IpAddress ipv4Address = new IpAddress(new Ipv4Address(IPV4_ADDRESS_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.binaryAddressTypeFromIpAddress(ipv4Address);
assertEquals(Ipv4BinaryAfi.class, addressClass);
final Address address = LispAddressUtil.binaryAddressFromIpAddress(ipv4Address);
assertEquals(IPV4_BINARY, address);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4Binary in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method toRloc.
/**
* Tests:
* - {@link LispAddressUtil#toRloc(InetAddress)}
* - {@link LispAddressUtil#toRloc(Ipv4Address)}
* - {@link LispAddressUtil#toRloc(Ipv6Address)}
* - {@link LispAddressUtil#toRloc(SimpleAddress)}
* methods.
*/
@Test
public void toRloc() throws UnknownHostException {
InetAddress ipv4AddressInet = Inet4Address.getByAddress(IPV4_ADDRESS_BYTES_A_TEST);
final Rloc rlocFromInetAddress = LispAddressUtil.toRloc(ipv4AddressInet);
assertEquals(Ipv4BinaryAfi.class, rlocFromInetAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromInetAddress.getAddress()).getIpv4Binary());
final Rloc rlocFromIpv4Address = LispAddressUtil.toRloc(IPV4_ADDRESS_TEST);
assertEquals(Ipv4Afi.class, rlocFromIpv4Address.getAddressType());
assertEquals(IPV4_ADDRESS_VALUE_TEST, ((Ipv4) rlocFromIpv4Address.getAddress()).getIpv4().getValue());
final Rloc rlocFromIpv6Address = LispAddressUtil.toRloc(IPV6_ADDRESS_TEST);
assertEquals(Ipv6Afi.class, rlocFromIpv6Address.getAddressType());
assertEquals(IPV6_ADDRESS_VALUE_TEST, ((Ipv6) rlocFromIpv6Address.getAddress()).getIpv6().getValue());
final Rloc rlocFromSimpleAddress = LispAddressUtil.toRloc(SIMPLE_ADDRESS_IPV4_TEST);
assertEquals(Ipv4BinaryAfi.class, rlocFromSimpleAddress.getAddressType());
assertEquals(IPV4_ADDRESS_BINARY_TEST, ((Ipv4Binary) rlocFromSimpleAddress.getAddress()).getIpv4Binary());
}
Aggregations