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;
}
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);
}
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;
}
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();
}
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;
}
Aggregations