Search in sources :

Example 26 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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()));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) LispAddressSerializerContext(org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializerContext) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) Test(org.junit.Test)

Example 27 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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));
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) ILispDAO(org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)

Example 28 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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;
}
Also used : InetAddress(java.net.InetAddress) Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address) Inet4Address(java.net.Inet4Address) Inet6Address(java.net.Inet6Address) SimpleAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress) UnknownHostException(java.net.UnknownHostException) Ipv6(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6) InstanceId(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.InstanceId) Ipv4(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4) Ipv6PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv6PrefixBinary) Inet6Address(java.net.Inet6Address) ServicePath(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.ServicePath) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix) Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Prefix) InetAddress(java.net.InetAddress)

Example 29 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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);
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Subscriber(org.opendaylight.lispflowmapping.interfaces.dao.Subscriber) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Example 30 with SourceDestKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.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);
        }
    }
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)

Aggregations

Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)28 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey)20 Test (org.junit.Test)16 ILispDAO (org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO)7 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)6 EidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder)6 SourceDestKeyBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder)5 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)4 SourceDestKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey)4 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)3 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)3 LispAddressSerializerContext (org.opendaylight.lispflowmapping.lisp.serializer.address.LispAddressSerializerContext)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Ipv4PrefixAfi (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.Ipv4PrefixAfi)2 Ipv4PrefixBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4PrefixBuilder)2 Ipv4PrefixBinaryAfi (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4PrefixBinaryAfi)2 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)2 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)2 Preconditions (com.google.common.base.Preconditions)1 Inet4Address (java.net.Inet4Address)1