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) {
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;
}
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 HashMapDb method getSubtree.
@Override
public Set<Eid> getSubtree(Eid key) {
Set<RadixTrie<Object>.TrieNode> nodes = null;
if (key.getAddress() instanceof Ipv4PrefixBinary) {
Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) key.getAddress();
nodes = ip4Trie.lookupSubtree(prefix.getIpv4AddressBinary().getValue(), prefix.getIpv4MaskLength());
} else if (key.getAddress() instanceof Ipv6PrefixBinary) {
Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) key.getAddress();
nodes = ip6Trie.lookupSubtree(prefix.getIpv6AddressBinary().getValue(), prefix.getIpv6MaskLength());
}
return nodesToEids(key, nodes);
}
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 HashMapDb method tryAddToIpTrie.
public void tryAddToIpTrie(Object key) {
if (key instanceof Eid) {
Eid eid = (Eid) key;
if (eid.getAddress() instanceof Ipv4PrefixBinary) {
Ipv4PrefixBinary prefix = (Ipv4PrefixBinary) eid.getAddress();
ip4Trie.insert(prefix.getIpv4AddressBinary().getValue(), prefix.getIpv4MaskLength(), key);
} else if (eid.getAddress() instanceof Ipv6PrefixBinary) {
Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) eid.getAddress();
ip6Trie.insert(prefix.getIpv6AddressBinary().getValue(), prefix.getIpv6MaskLength(), key);
}
}
}
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 serializeData.
@Override
protected void serializeData(ByteBuffer buffer, LispAddress lispAddress) {
Ipv6PrefixBinary prefix = (Ipv6PrefixBinary) lispAddress.getAddress();
buffer.put(prefix.getIpv6AddressBinary().getValue());
}
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 toEid.
public static Eid toEid(Ipv6PrefixBinary prefix, InstanceIdType vni) {
EidBuilder builder = new EidBuilder();
builder.setAddressType(Ipv6PrefixBinaryAfi.class);
builder.setVirtualNetworkId(vni);
builder.setAddress((Address) prefix);
return builder.build();
}
Aggregations