+ for (LocatorRecord record : locatorRecords) {
+ Rloc container = record.getRloc();
+
+ // For non-ELP RLOCs, or when ELP policy is default, or itrRlocs is null, just add the locator and be
+ // done
+ if ((!(container.getAddress() instanceof ExplicitLocatorPath))
+ || elpPolicy.equalsIgnoreCase("default") || itrRlocs == null) {
+ recordBuilder.getLocatorRecord().add(
+ new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator())
+ .setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight())
+ .setPriority(record.getPriority()).setMulticastWeight(record.getMulticastWeight())
+ .setMulticastPriority(record.getMulticastPriority()).setRouted(record.isRouted())
+ .setRloc(container).setLocatorId(record.getLocatorId()).build());
+ continue;
+ }
+
+ ExplicitLocatorPath teAddress = ((ExplicitLocatorPath) container.getAddress());
+ SimpleAddress nextHop = getNextELPHop(teAddress, itrRlocs);
+ if (nextHop != null) {
+ java.lang.Short priority = record.getPriority();
+ if (elpPolicy.equalsIgnoreCase("both")) {
+ recordBuilder.getLocatorRecord().add(
+ new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator())
+ .setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight())
+ .setPriority(record.getPriority())
+ .setMulticastWeight(record.getMulticastWeight())
+ .setMulticastPriority(record.getMulticastPriority())
+ .setRouted(record.isRouted()).setRloc(container)
+ .setLocatorId(record.getLocatorId()).build());
+ // Make the priority of the added simple locator lower so that ELP is used by default if
+ // the xTR understands ELP. Exclude 255, since that means don't use for unicast forwarding
+ // XXX Complex cases like several ELPs with different priorities are not handled
+ if (priority != 254 || priority != 255) {
+ priority++;
+ }
+ }
+ // Build and add the simple RLOC
+ recordBuilder.getLocatorRecord().add(
+ new LocatorRecordBuilder().setLocalLocator(record.isLocalLocator())
+ .setRlocProbed(record.isRlocProbed()).setWeight(record.getWeight())
+ .setPriority(priority).setMulticastWeight(record.getMulticastWeight())
+ .setMulticastPriority(record.getMulticastPriority()).setRouted(record.isRouted())
+ .setRloc(LispAddressUtil.toRloc(nextHop)).setLocatorId(record.getLocatorId()).build());
+ }
+ }