use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertToBinary.
private static Ipv6PrefixBinary convertToBinary(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix prefix) {
Ipv6PrefixBinaryBuilder pb = new Ipv6PrefixBinaryBuilder();
byte[] address = InetAddresses.forString(MaskUtil.getAddressStringForIpv6Prefix(prefix)).getAddress();
pb.setIpv6AddressBinary(new Ipv6AddressBinary(address));
pb.setIpv6MaskLength(MaskUtil.getMaskForAddress(prefix));
return pb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.
the class MaskUtil method normalize.
public static Eid normalize(Eid eid, short mask) {
Address address = eid.getAddress();
try {
if (address instanceof Ipv4PrefixBinary) {
byte[] addr = ((Ipv4PrefixBinary) address).getIpv4AddressBinary().getValue();
return LispAddressUtil.asIpv4PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv6PrefixBinary) {
byte[] addr = ((Ipv6PrefixBinary) address).getIpv6AddressBinary().getValue();
return LispAddressUtil.asIpv6PrefixBinaryEid(eid, normalizeByteArray(addr, mask), mask);
} else if (address instanceof Ipv4Prefix) {
final String addr = getPrefixAddress(((Ipv4Prefix) address).getIpv4Prefix().getValue());
InetAddress normalized = normalizeIP(InetAddresses.forString(addr), mask);
return LispAddressUtil.asIpv4PrefixEid(eid, (Inet4Address) normalized, mask);
} else if (address instanceof Ipv6Prefix) {
final String addr = getPrefixAddress(((Ipv6Prefix) address).getIpv6Prefix().getValue());
InetAddress normalized = normalizeIP(InetAddresses.forString(addr), mask);
return LispAddressUtil.asIpv6PrefixEid(eid, (Inet6Address) normalized, mask);
} else if (address instanceof InstanceId) {
// TODO - not absolutely necessary, but should be implemented
return eid;
}
} catch (UnknownHostException e) {
LOG.warn("Failed to normalize EID {} with mask {}, returning original EID", eid, mask, e);
}
return eid;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.
the class Ipv6PrefixBinarySerializer method deserializeEidData.
@Override
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
byte[] ipBuffer = new byte[16];
buffer.get(ipBuffer);
Ipv6PrefixBinary prefix = new Ipv6PrefixBinaryBuilder().setIpv6AddressBinary(new Ipv6AddressBinary(ipBuffer)).setIpv6MaskLength(ctx.getMaskLen()).build();
EidBuilder eb = new EidBuilder();
eb.setAddressType(Ipv6PrefixBinaryAfi.class);
eb.setVirtualNetworkId(getVni(ctx));
eb.setAddress(prefix);
return eb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.
the class LispAddressUtil method convertFromBinary.
private static Pair<Class<? extends LispAddressFamily>, Address> convertFromBinary(Address addr) {
Address convAddr = null;
Class<? extends LispAddressFamily> convType = null;
if (addr instanceof Ipv4PrefixBinary) {
convAddr = convertFromBinary((Ipv4PrefixBinary) addr);
convType = Ipv4PrefixAfi.class;
} else if (addr instanceof Ipv6PrefixBinary) {
convAddr = convertFromBinary((Ipv6PrefixBinary) addr);
convType = Ipv6PrefixAfi.class;
} else if (addr instanceof Ipv4Binary) {
convAddr = convertFromBinary((Ipv4Binary) addr);
convType = Ipv4Afi.class;
} else if (addr instanceof Ipv6Binary) {
convAddr = convertFromBinary((Ipv6Binary) addr);
convType = Ipv6Afi.class;
}
return new ImmutablePair<Class<? extends LispAddressFamily>, Address>(convType, convAddr);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary in project lispflowmapping by opendaylight.
the class MappingSystem method getVirtualParent.
private static Eid getVirtualParent(Eid eid) {
if (eid.getAddress() instanceof Ipv4PrefixBinary) {
Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) eid.getAddress();
short parentPrefixLength = (short) (prefix.getIpv4MaskLength() - 1);
byte[] parentPrefix = MaskUtil.normalizeByteArray(prefix.getIpv4AddressBinary().getValue(), parentPrefixLength);
return LispAddressUtil.asIpv4PrefixBinaryEid(eid, parentPrefix, parentPrefixLength);
} else if (eid.getAddress() instanceof Ipv6PrefixBinary) {
Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) eid.getAddress();
short parentPrefixLength = (short) (prefix.getIpv6MaskLength() - 1);
byte[] parentPrefix = MaskUtil.normalizeByteArray(prefix.getIpv6AddressBinary().getValue(), parentPrefixLength);
return LispAddressUtil.asIpv6PrefixBinaryEid(eid, parentPrefix, parentPrefixLength);
}
return null;
}
Aggregations