use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary 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.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class Ipv4PrefixBinarySerializer method serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) lispAddress.getAddress();
buffer.put(prefix.getIpv4AddressBinary().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary in project lispflowmapping by opendaylight.
the class Ipv4PrefixBinarySerializer method deserializeEidData.
@Override
protected Eid deserializeEidData(ByteBuffer buffer, LispAddressSerializerContext ctx) {
byte[] ipBuffer = new byte[4];
buffer.get(ipBuffer);
Ipv4PrefixBinary prefix = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(ipBuffer)).setIpv4MaskLength(ctx.getMaskLen()).build();
EidBuilder eb = new EidBuilder();
eb.setAddressType(Ipv4PrefixBinaryAfi.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.Ipv4PrefixBinary 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.Ipv4PrefixBinary 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