use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project bgpcep by opendaylight.
the class PCEPRROSubobjectParserTest method testRROIp6PrefixSubobject.
@Test
public void testRROIp6PrefixSubobject() throws PCEPDeserializerException {
final RROIpv6PrefixSubobjectParser parser = new RROIpv6PrefixSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setProtectionAvailable(false);
subs.setProtectionInUse(true);
subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, 22))).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(ip6PrefixBytes, 2))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(ip6PrefixBytes, ByteArray.getAllBytes(buff));
try {
parser.parseSubobject(null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseSubobject(Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project lispflowmapping by opendaylight.
the class LispAddressUtil method toEid.
public static Eid toEid(IpPrefix prefix, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddress(addressFromIpPrefix(prefix));
builder.setAddressType(addressTypeFromIpPrefix(prefix));
builder.setVirtualNetworkId(vni);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.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.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.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.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.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);
}
Aggregations