use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromSimpleAddressTest_asIpPrefix.
/**
* Tests {@link LispAddressUtil#addressTypeFromSimpleAddress} and {@link
* LispAddressUtil#addressFromSimpleAddress} methods
* with ipPrefix.
*/
@Test
public void addressFromSimpleAddressTest_asIpPrefix() {
final SimpleAddress simpleAddress = new SimpleAddress(new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST)));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromSimpleAddress(simpleAddress);
assertEquals(Ipv4PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromSimpleAddress(simpleAddress);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asIpPrefix_ipv6.
/**
* Tests {@link LispAddressUtil#asIpPrefix(String, int)} with ipv6 address and correct mask.
*/
@Test
public void asIpPrefix_ipv6() {
final IpPrefix ipPrefix = LispAddressUtil.asIpPrefix(IPV6_ADDRESS_VALUE_TEST, MASK_OK_TEST);
assertNotNull(ipPrefix);
final Ipv6Prefix ipv6Prefix = ipPrefix.getIpv6Prefix();
assertNotNull(ipv6Prefix);
assertEquals(IPV6_ADDRESS_PREFIX_TEST, ipv6Prefix);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method asIpPrefix_other.
/**
* Tests {@link LispAddressUtil#asIpPrefix(String, int)} with incorrect ip address and correct mask.
*/
@Test
public void asIpPrefix_other() {
final IpPrefix ipPrefix = LispAddressUtil.asIpPrefix(INCORRECT_IP_ADDRESS_TEST, MASK_OK_TEST);
assertNull(ipPrefix);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_ipv4.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
* LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
* methods with ipv4 address.
*/
@Test
public void addressFromIpPrefix_ipv4() {
IpPrefix ipv4Prefix = new IpPrefix(new Ipv4Prefix(IPV4_ADDRESS_PREFIX_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv4Prefix);
assertEquals(Ipv4PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(ipv4Prefix);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix);
assertEquals(IPV4_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) address).getIpv4Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix in project lispflowmapping by opendaylight.
the class Ipv6PrefixBinarySerializer method deserializeSimpleAddressData.
@Override
protected SimpleAddress deserializeSimpleAddressData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
byte[] ipBuffer = new byte[16];
InetAddress address = null;
buffer.get(ipBuffer);
try {
address = InetAddress.getByAddress(ipBuffer);
} catch (UnknownHostException e) {
LOG.debug("Unknown host {}", ipBuffer, e);
}
return new SimpleAddress(new IpPrefix(new Ipv6Prefix(address.getHostAddress() + "/" + ctx.getMaskLen())));
}
Aggregations