Search in sources :

Example 11 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 addMapping.

public void addMapping(Eid key, Object value) {
    Eid eid = MaskUtil.normalize(key);
    ILispDAO table = getOrInstantiateVniTable(key);
    if (eid.getAddress() instanceof SourceDestKey) {
        Eid srcKey = SourceDestKeyHelper.getSrcBinary(eid);
        ILispDAO srcDstDao = getOrInstantiateSDInnerDao(eid, table);
        srcDstDao.put(srcKey, new MappingEntry<>(SubKeys.RECORD, value));
    } else {
        table.put(eid, new MappingEntry<>(SubKeys.RECORD, value));
    }
}
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 12 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 getData.

@Override
public Object getData(Eid eid, String subKey) {
    Eid key = MaskUtil.normalize(eid);
    ILispDAO table = getVniTable(key);
    if (table == null) {
        return null;
    }
    if (key.getAddress() instanceof SourceDestKey) {
        ILispDAO srcDstDao = getSDInnerDao(key, table);
        return srcDstDao.getSpecific(SourceDestKeyHelper.getSrcBinary(key), subKey);
    } else {
        return table.getSpecific(key, subKey);
    }
}
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 13 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 getMapping.

public Object getMapping(Eid srcEid, Eid dstEid) {
    if (dstEid == null) {
        return null;
    }
    ILispDAO table = getVniTable(dstEid);
    if (table == null) {
        return null;
    }
    // a map-request for an actual SrcDst LCAF, ignore src eid
    if (dstEid.getAddress() instanceof SourceDestKey) {
        Eid srcAddr = SourceDestKeyHelper.getSrcBinary(dstEid);
        Eid dstAddr = SourceDestKeyHelper.getDstBinary(dstEid);
        return getMappingLpmSD(srcAddr, dstAddr, table);
    }
    // potential map-request for SrcDst LCAF from non SrcDst capable devices
    return getMappingLpmSD(srcEid, dstEid, table);
}
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 14 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 LispAddressUtilTest method asSrcDstEid_addressesAsSrcDstKey.

/**
 * Tests {@link LispAddressUtil#asSrcDstEid(SourceDestKey, InstanceIdType)}  method.
 */
@Test
public void asSrcDstEid_addressesAsSrcDstKey() {
    final SourceDestKey expectedSourceDestKey = new SourceDestKeyBuilder().setSource(SIMPLE_ADDRESS_IPV4_PREFIX_TEST).setDest(SIMPLE_ADDRESS_IPV6_PREFIX_TEST).build();
    final Eid srcDstEid = LispAddressUtil.asSrcDstEid(expectedSourceDestKey, INSTANCE_ID_TYPE_TEST);
    assertNotNull(srcDstEid);
    assertEquals(SourceDestKeyLcaf.class, srcDstEid.getAddressType());
    final SourceDestKey testedSourceDestKey = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.SourceDestKey) srcDstEid.getAddress()).getSourceDestKey();
    assertNotNull(testedSourceDestKey);
    assertEquals(SIMPLE_ADDRESS_IPV4_PREFIX_TEST, testedSourceDestKey.getSource());
    assertEquals(SIMPLE_ADDRESS_IPV6_PREFIX_TEST, testedSourceDestKey.getDest());
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) SourceDestKeyBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder) SourceDestKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKey) Test(org.junit.Test)

Example 15 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 MultiTableMapCacheTest method getMappingTest_withSourceDestKey.

/**
 * Tests {@link MultiTableMapCache#getMapping} with SourceDestKey address type.
 */
@Test
public void getMappingTest_withSourceDestKey() {
    when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
    final Eid dstAddr = SourceDestKeyHelper.getDstBinary(EID_SOURCE_DEST_KEY_TYPE);
    final Eid normalizedDstAddr = MaskUtil.normalize(dstAddr);
    final Eid srcAddr = SourceDestKeyHelper.getSrcBinary(EID_SOURCE_DEST_KEY_TYPE);
    final Eid normalizedSrcAddr = MaskUtil.normalize(srcAddr);
    final Map<String, Object> entry = getEntry1();
    final Map<String, Object> entry2 = getEntry2();
    when(tableDaoMock.getBest(normalizedDstAddr)).thenReturn(entry);
    when(srcDstDaoMock.getBest(normalizedSrcAddr)).thenReturn(entry2);
    assertEquals(DUMMY_OBJECT_2, multiTableMapCache.getMapping(null, EID_SOURCE_DEST_KEY_TYPE));
    assertNull(multiTableMapCache.getMapping(null, null));
    assertNull(multiTableMapCache.getMapping(EID_TEST, null));
}
Also used : Eid(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid) Test(org.junit.Test)

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