use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.
the class SourceDestKeySerializerTest method deserialize__Ipv6.
@Test
public void deserialize__Ipv6() throws Exception {
Eid srcAddress = LispAddressSerializer.getInstance().deserializeEid(hexToByteBuffer(//
"40 03 00 00 " + //
"0C 20 00 28 " + // reserved + masks
"00 00 78 78 " + // AFI=2,
"00 02 11 22 33 44 55 66 77 88 99 AA BB CC AA BB CC DD " + // AFI=2,
"00 02 44 33 22 11 88 77 66 55 99 AA BB CC AA BB CC DD"), new LispAddressSerializerContext(null));
// IPv6
assertEquals("1122:3344:5566:7788:99aa:bbcc:aabb:ccdd/120", String.valueOf(((SourceDestKey) srcAddress.getAddress()).getSourceDestKey().getSource().getValue()));
assertEquals("4433:2211:8877:6655:99aa:bbcc:aabb:ccdd/120", String.valueOf(((SourceDestKey) srcAddress.getAddress()).getSourceDestKey().getDest().getValue()));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.
the class MultiTableMapCache method addData.
@Override
public void addData(Eid eid, String subKey, Object data) {
Eid key = MaskUtil.normalize(eid);
ILispDAO table = getOrInstantiateVniTable(key);
if (key.getAddress() instanceof SourceDestKey) {
ILispDAO srcDstDao = getOrInstantiateSDInnerDao(key, table);
srcDstDao.put(SourceDestKeyHelper.getSrcBinary(key), new MappingEntry<>(subKey, data));
} else {
table.put(key, new MappingEntry<>(subKey, data));
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.
the class MappingSystem method notifyChange.
public void notifyChange(Eid eid, MappingRecord mapping, MappingChange mappingChange) {
Set<Subscriber> subscribers = getSubscribers(eid);
Set<Subscriber> dstSubscribers = null;
// For SrcDst LCAF also send SMRs to Dst prefix
if (eid.getAddress() instanceof SourceDestKey) {
Eid dstAddr = SourceDestKeyHelper.getDstBinary(eid);
dstSubscribers = getSubscribers(dstAddr);
notifyChildren(dstAddr, mapping, mappingChange);
}
// No reason to send a notification when no subscribers exist
if (subscribers != null || dstSubscribers != null) {
publishNotification(mapping, eid, subscribers, dstSubscribers, mappingChange);
}
notifyChildren(eid, mapping, mappingChange);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey in project lispflowmapping by opendaylight.
the class MappingSystem method handleAddMappingNotifications.
private void handleAddMappingNotifications(MappingOrigin origin, Eid key, MappingData mappingData, MappingRecord oldMapping, MappingRecord newMapping, MappingChange changeType) {
// account policy as well
if (origin != MappingOrigin.Southbound || MappingRecordUtil.mappingChanged(oldMapping, newMapping)) {
notifyChange(key, mappingData.getRecord(), changeType);
Eid dstKey = key;
// for the checks that we do afterwards
if (key.getAddress() instanceof SourceDestKey) {
dstKey = SourceDestKeyHelper.getDstBinary(key);
}
// If the old mapping had a different EID than what was just added, notify those subscribers too
if (oldMapping != null && !oldMapping.getEid().equals(key) && !oldMapping.getEid().equals(dstKey)) {
notifyChange(oldMapping.getEid(), oldMapping, changeType);
}
// subscribers too
if (newMapping != null && !newMapping.getEid().equals(key) && !newMapping.getEid().equals(dstKey)) {
notifyChange(newMapping.getEid(), newMapping, changeType);
}
}
}
Aggregations