Search in sources :

Example 31 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method getDefaultMappingRecordBuilder.

/**
 * Create a default MappingRecordBuilder object.
 *
 * @param eid EID for the mapping record, if null, a default will be added
 * @param rlocs RLOCs for the mapping record, if null, no locator record will be added
 * @return the MappingRecordBuilder object
 */
static MappingRecordBuilder getDefaultMappingRecordBuilder(Eid eid, List<Rloc> rlocs) {
    if (eid == null) {
        eid = DEFAULT_IPV4_EID_PREFIX;
        LOG.warn("getDefaultMappingRecordBuilder(): null EID received, using the default {}", DEFAULT_IPV4_EID_STRING);
    }
    MappingRecordBuilder mrb = new MappingRecordBuilder().setEid(eid).setAction(MappingRecord.Action.NoAction).setAuthoritative(false).setLocatorRecord(new ArrayList<>()).setMapVersion((short) 0).setRecordTtl(60).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setTimestamp(System.currentTimeMillis());
    // We want to allow for empty locator records, so we only add one if rloc is not null
    if (rlocs != null) {
        for (Rloc rloc : rlocs) {
            mrb.getLocatorRecord().add(getDefaultLocatorBuilder(rloc).build());
        }
    }
    return mrb;
}
Also used : MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) ArrayList(java.util.ArrayList) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ItrRloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)

Example 32 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method getDefaultLocatorBuilder.

/**
 * Create a default LocatorRecordBuilder object.
 *
 * @param rloc RLOC for the mapping record, if null, a default will be added
 * @return the LocatorRecordBuilder object
 */
static LocatorRecordBuilder getDefaultLocatorBuilder(Rloc rloc) {
    if (rloc == null) {
        rloc = DEFAULT_IPV4_RLOC;
        LOG.warn("getDefaultLocatorBuilder(): null RLOC received, using the default {}", DEFAULT_IPV4_RLOC_STRING);
    }
    return new LocatorRecordBuilder().setLocalLocator(true).setMulticastPriority((short) 255).setMulticastWeight((short) 0).setPriority((short) 1).setRlocProbed(false).setRouted(true).setWeight((short) 1).setKey(new LocatorRecordKey(LispAddressStringifier.getString(rloc))).setRloc(rloc);
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) LocatorRecordKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordKey)

Example 33 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingServiceIntegrationTestUtil method getDefaultMapRegisterBuilder.

/**
 * Create a default MapRegisterBuilder object.
 *
 * @param eid EID for the single mapping record, if null, a default will be added
 * @param rloc RLOC for the single mapping record, if null, no locator record will be added
 * @return the MapRegisterBuilder object
 */
static MapRegisterBuilder getDefaultMapRegisterBuilder(Eid eid, Rloc rloc) {
    final MapRegisterBuilder mapRegisterBuilder = new MapRegisterBuilder().setProxyMapReply(true).setWantMapNotify(true).setKeyId((short) 0).setMappingRecordItem(new ArrayList<>()).setMergeEnabled(true).setNonce(8L).setSiteId(DEFAULT_SITE_ID).setXtrId(DEFAULT_XTR_ID).setXtrSiteIdPresent(true);
    mapRegisterBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder(eid, rloc).build());
    return mapRegisterBuilder;
}
Also used : ArrayList(java.util.ArrayList) MapRegisterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder)

Example 34 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class DSBEInputUtil method toMapping.

public static Mapping toMapping(MappingOrigin origin, Eid key) {
    MappingBuilder mb = new MappingBuilder();
    mb.setEidUri(new EidUri(LispAddressStringifier.getURIString(key)));
    mb.setOrigin(origin);
    mb.setMappingRecord(new MappingRecordBuilder().setEid(key).build());
    return mb.build();
}
Also used : MappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder) XtrIdMappingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMappingBuilder) MappingRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder) EidUri(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)

Example 35 with Mapping

use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping in project lispflowmapping by opendaylight.

the class MappingMergeUtil method getCommonLocatorRecords.

private static List<LocatorRecord> getCommonLocatorRecords(MappingRecord nbMapping, MappingRecord sbMapping) {
    // Return null when NB is a negative mapping
    if (nbMapping.getLocatorRecord() == null || nbMapping.getLocatorRecord().isEmpty()) {
        return null;
    }
    List<LocatorRecord> sbLocators = sbMapping.getLocatorRecord();
    // We assume locators are unique and don't show up several times (with different or identical p/w/mp/mw),
    // so we create a HashMap of the locators from the SB mapping record, keyed by the Rloc
    Map<Rloc, LocatorRecord> sbLocatorMap = new HashMap<Rloc, LocatorRecord>();
    for (LocatorRecord locator : sbLocators) {
        sbLocatorMap.put(locator.getRloc(), locator);
    }
    // Gradually building final list of common locators, in order that they appear in NB Mapping
    List<LocatorRecord> commonLocators = new ArrayList<LocatorRecord>();
    for (LocatorRecord nbLocator : nbMapping.getLocatorRecord()) {
        Rloc nbRloc = nbLocator.getRloc();
        if (sbLocatorMap.containsKey(nbRloc)) {
            if (sbLocatorMap.get(nbRloc).getPriority() == (short) 255) {
                // if SB locator has p == 255 then common locator takes all NB fields except for p
                // which must be set to 255
                LocatorRecordBuilder lrb = new LocatorRecordBuilder(nbLocator);
                lrb.setPriority((short) 255);
                commonLocators.add(lrb.build());
            } else {
                commonLocators.add(nbLocator);
            }
        }
    }
    return commonLocators;
}
Also used : LocatorRecordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Rloc(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc) ArrayList(java.util.ArrayList) LocatorRecord(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord)

Aggregations

MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)34 Test (org.junit.Test)32 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)32 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)26 ArrayList (java.util.ArrayList)21 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 MappingRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder)16 MappingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.MappingBuilder)14 BigInteger (java.math.BigInteger)13 Mapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping)13 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 LocatorRecordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecordBuilder)11 EidUri (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri)11 Rloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc)10 ItrRloc (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequest.ItrRloc)9 Subscriber (org.opendaylight.lispflowmapping.interfaces.dao.Subscriber)8 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)8 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)8 MappingRecordItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder)8 XtrIdMapping (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.mapping.XtrIdMapping)8