use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix in project openflowplugin by opendaylight.
the class OfToSalIpv6DstCase method setIpv6MatchBuilderFields.
private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder builder, final byte[] mask, final Ipv6Address prefix) {
Ipv6Prefix ipv6Prefix;
if (mask != null) {
ipv6Prefix = IpConversionUtil.createPrefix(prefix, mask);
} else {
ipv6Prefix = IpConversionUtil.createPrefix(prefix);
}
builder.setIpv6Destination(ipv6Prefix);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix in project lispflowmapping by opendaylight.
the class LispSimpleAddressStringifierTest method getStringTest_asIpv6Prefix.
/**
* Tests {@link LispSimpleAddressStringifier#getString} with Ipv6Prefix.
*/
@Test
public void getStringTest_asIpv6Prefix() {
SimpleAddress simpleAddress = new SimpleAddress(IPV6_PREFIX);
String result = LispSimpleAddressStringifier.getString(simpleAddress);
assertEquals(IPV6_PREFIX.getIpv6Prefix().getValue(), result);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix in project lispflowmapping by opendaylight.
the class MaskUtilTest method normalizeTest_withIpv6Prefix_withMask.
/**
* Tests {@link MaskUtil#normalize(Eid eid, short mask)} method with Ipv6Prefix.
*/
@Test
public void normalizeTest_withIpv6Prefix_withMask() {
// input ip: 1111:2222:3333:4444:5555:6666:7777:8888, mask: 66
final Eid result = MaskUtil.normalize(EID_IPV6_PREFIX, (short) 66);
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix resultPrefix = (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) result.getAddress();
// expected result
final String expectedResult = "1111:2222:3333:4444:4000::" + MASK_3;
assertEquals(expectedResult, resultPrefix.getIpv6Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix in project lispflowmapping by opendaylight.
the class LispAddressUtilTest method addressFromIpPrefix_ipv6.
/**
* Tests {@link LispAddressUtil#addressFromIpPrefix(IpPrefix)} and {@link
* LispAddressUtil#addressTypeFromIpPrefix(IpPrefix)}
* methods with ipv6 address.
*/
@Test
public void addressFromIpPrefix_ipv6() {
IpPrefix ipv6Address = new IpPrefix(new Ipv6Prefix(IPV6_ADDRESS_PREFIX_VALUE_TEST));
final Class<? extends LispAddressFamily> addressClass = LispAddressUtil.addressTypeFromIpPrefix(ipv6Address);
assertEquals(Ipv6PrefixAfi.class, addressClass);
final Address address = LispAddressUtil.addressFromIpPrefix(ipv6Address);
assertTrue(address instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix);
assertEquals(IPV6_ADDRESS_PREFIX_VALUE_TEST, ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) address).getIpv6Prefix().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix in project lispflowmapping by opendaylight.
the class MaskUtil method normalize.
public static Eid normalize(Eid eid) {
Address address = eid.getAddress();
try {
if (address instanceof Ipv4PrefixBinary) {
byte[] addr = ((Ipv4PrefixBinary) address).getIpv4AddressBinary().getValue();
short mask = ((Ipv4PrefixBinary) address).getIpv4MaskLength();
return LispAddressUtil.asIpv4PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv6PrefixBinary) {
byte[] addr = ((Ipv6PrefixBinary) address).getIpv6AddressBinary().getValue();
short mask = ((Ipv6PrefixBinary) address).getIpv6MaskLength();
return LispAddressUtil.asIpv6PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv4Prefix) {
String[] v4prefix = splitPrefix(((Ipv4Prefix) address).getIpv4Prefix().getValue());
short mask = Short.parseShort(v4prefix[1]);
InetAddress normalized = normalizeIP(InetAddresses.forString(v4prefix[0]), mask);
return LispAddressUtil.asIpv4PrefixEid(eid, (Inet4Address) normalized, mask);
} else if (address instanceof Ipv6Prefix) {
String[] v6prefix = splitPrefix(((Ipv6Prefix) address).getIpv6Prefix().getValue());
short mask = Short.parseShort(v6prefix[1]);
InetAddress normalized = normalizeIP(InetAddresses.forString(v6prefix[0]), mask);
return LispAddressUtil.asIpv6PrefixEid(eid, (Inet6Address) normalized, mask);
} else if (address instanceof Ipv4) {
return LispAddressUtil.asIpv4PrefixEid(((Ipv4) address).getIpv4(), eid.getVirtualNetworkId());
} else if (address instanceof Ipv6) {
return LispAddressUtil.asIpv6PrefixEid(((Ipv6) address).getIpv6(), eid.getVirtualNetworkId());
} else if (address instanceof InstanceId) {
// TODO - not absolutely necessary, but should be implemented
return eid;
} else if (address instanceof SourceDestKey) {
return normalizeSrcDst(eid);
} else if (address instanceof ServicePath) {
// Build new Service Path eid with service index set to 0
long spi = ((ServicePath) address).getServicePath().getServicePathId().getValue();
long vni = eid.getVirtualNetworkId() != null ? eid.getVirtualNetworkId().getValue() : -1;
return LispAddressUtil.asServicePathEid(vni, spi, (short) 0);
}
} catch (UnknownHostException e) {
LOG.warn("Failed to normalize EID {}, returning original", eid, e);
}
return eid;
}
Aggregations