private boolean locatorsNeedFixing(List<LocatorRecord> locatorRecords) { for (LocatorRecord record : locatorRecords) { if (record.getRloc().getAddress() instanceof ExplicitLocatorPath) { return true; } } return false; }
private static boolean isEqualIpVersion(IpAddressBinary srcRloc, Rloc rloc) { if (srcRloc.getIpv4AddressBinary() != null) { if (rloc.getAddressType() == Ipv4Afi.class || rloc.getAddressType() == Ipv4BinaryAfi.class || rloc.getAddressType() == Ipv4PrefixAfi.class || rloc.getAddressType() == Ipv4PrefixBinaryAfi.class) { return true; } } else if (rloc.getAddressType() == Ipv6Afi.class || rloc.getAddressType() == Ipv6BinaryAfi.class || rloc.getAddressType() == Ipv6PrefixAfi.class || rloc.getAddressType() == Ipv6PrefixBinaryAfi.class) { return true; } return false; }
private static int compareLocators(LocatorRecord one, LocatorRecord two) { byte[] oneIp = LispAddressUtil.ipAddressToByteArray(one.getRloc().getAddress()); byte[] twoIp = LispAddressUtil.ipAddressToByteArray(two.getRloc().getAddress()); return LispAddressUtil.compareIpAddressByteArrays(oneIp, twoIp); }
private SimpleAddress getNextELPHop(ExplicitLocatorPath elp, List<ItrRloc> itrRlocs) { SimpleAddress nextHop = null; List<Hop> hops = elp.getExplicitLocatorPath().getHop(); if (hops != null && hops.size() > 0) { // By default we return the first hop nextHop = hops.get(0).getAddress(); for (Hop hop : hops) { Address hopAddress = LispAddressUtil.addressFromSimpleAddress(hop.getAddress()); for (ItrRloc itrRloc : itrRlocs) { if (itrRloc.getRloc().getAddress().equals(hopAddress)) { int iterator = hops.indexOf(hop); if (iterator < hops.size() - 1) { nextHop = hops.get(iterator + 1).getAddress(); return nextHop; } } } } } return nextHop; }
int index = LispAddressUtil.STARTING_SERVICE_INDEX - (int) serviceIndex; Rloc rloc = locatorRecord.getRloc(); if (rloc.getAddress() instanceof Ipv4 || rloc.getAddress() instanceof Ipv6) { if (index != 0) { LOG.warn("Service Index should be 255 for simple IP RLOCs!"); } else if (rloc.getAddress() instanceof ExplicitLocatorPath) { ExplicitLocatorPath elp = (ExplicitLocatorPath) rloc.getAddress(); List<Hop> hops = elp.getExplicitLocatorPath().getHop();
private static List<LocatorRecord> convertToBinaryIfNecessary(List<LocatorRecord> originalLocators) { List<LocatorRecord> convertedLocators = null; for (LocatorRecord record : originalLocators) { if (LispAddressUtil.addressNeedsConversionToBinary(record.getRloc().getAddress())) { LocatorRecordBuilder lrb = new LocatorRecordBuilder(record); lrb.setRloc(LispAddressUtil.convertToBinary(record.getRloc())); if (convertedLocators == null) { convertedLocators = new ArrayList<LocatorRecord>(); } convertedLocators.add(lrb.build()); } } if (convertedLocators != null) { return convertedLocators; } return originalLocators; } }
private static List<LocatorRecord> convertFromBinaryIfNecessary(List<LocatorRecord> originalLocators) { List<LocatorRecord> convertedLocators = null; for (LocatorRecord record : originalLocators) { if (LispAddressUtil.addressNeedsConversionFromBinary(record.getRloc().getAddress())) { LocatorRecordBuilder lrb = new LocatorRecordBuilder(record); lrb.setRloc(LispAddressUtil.convertFromBinary(record.getRloc())); if (convertedLocators == null) { convertedLocators = new ArrayList<LocatorRecord>(); } convertedLocators.add(lrb.build()); } } if (convertedLocators != null) { return convertedLocators; } return originalLocators; }
private IpAddress findLastHop(Eid prefix) { Object[] methodParameters = { prefix }; MappingRecord reply = (MappingRecord) SfcLispUtil.submitCallable( new SfcLispFlowMappingApi(lfmService, SfcLispFlowMappingApi.Method.GET_MAPPING, methodParameters), OpendaylightSfc.getOpendaylightSfcObj().getExecutor()); if (reply == null) { return null; } for (LocatorRecord locator : reply.getLocatorRecord()) { Address address = locator.getRloc().getAddress(); if (address instanceof Ipv4) { Ipv4 ipv4 = (Ipv4) address; return new IpAddress(ipv4.getIpv4()); } else if (address instanceof Ipv6) { Ipv6 ipv6 = (Ipv6) address; return new IpAddress(ipv6.getIpv6()); } else { LOG.debug("Locator address type not supported for TE LCAF: {}", address); } } return null; }
private Rloc resolveRloc(List<ItrRloc> itrRlocList, IpAddressBinary srcRloc) { if (srcRloc == null) { return itrRlocList.get(0).getRloc(); } byte[] srcRlocByte; if (srcRloc.getIpv4AddressBinary() != null) { srcRlocByte = srcRloc.getIpv4AddressBinary().getValue(); } else { srcRlocByte = srcRloc.getIpv6AddressBinary().getValue(); } Rloc equalIpvRloc = null; for (ItrRloc itrRloc : itrRlocList) { final Rloc rloc = itrRloc.getRloc(); final byte[] itrRlocByte = LispAddressUtil.ipAddressToByteArray(rloc.getAddress()); // return an Rloc equal to the source Rloc if (itrRlocByte != null && LispAddressUtil.compareIpAddressByteArrays(srcRlocByte, itrRlocByte) == 0) { return rloc; } // else lookup the first Rloc with identical Ip version if (equalIpvRloc == null && isEqualIpVersion(srcRloc, rloc)) { equalIpvRloc = rloc; } } if (equalIpvRloc != null) { return equalIpvRloc; } else { // if none of the above, return the first Rloc return itrRlocList.get(0).getRloc(); } }
public static TransportAddress getTransportAddressFromRloc(Rloc rloc) { TransportAddressBuilder tab = new TransportAddressBuilder(); Address address = rloc.getAddress();
private ServiceFunction updateLispData(Lisp lispLocation, ServiceFunction serviceFunction) { Object[] methodParameters = { LispAddressUtil.toIpPrefixEid(lispLocation.getEid(), 0) }; MappingRecord reply = (MappingRecord) SfcLispUtil.submitCallable( new SfcLispFlowMappingApi(lfmService, SfcLispFlowMappingApi.Method.GET_MAPPING, methodParameters), OpendaylightSfc.getOpendaylightSfcObj().getExecutor()); if (reply == null) { return serviceFunction; } for (LocatorRecord locator : reply.getLocatorRecord()) { Address address = locator.getRloc().getAddress(); if (address instanceof ApplicationData) { ApplicationData applicationData = (ApplicationData) address; Ip locatorType = SfcLispUtil.createLocator(applicationData); SfDataPlaneLocatorName name = new SfDataPlaneLocatorName(lispLocation.getEid().toString()); SfDataPlaneLocatorKey key = new SfDataPlaneLocatorKey(name); SfDataPlaneLocator loc = new SfDataPlaneLocatorBuilder().setLocatorType(locatorType).setKey(key).setName(name).build(); ServiceFunctionBuilder fb = new ServiceFunctionBuilder(serviceFunction); fb.getSfDataPlaneLocator().add(loc); return fb.build(); } } return serviceFunction; }
if ((!(container.getAddress() instanceof ExplicitLocatorPath)) || elpPolicy.equalsIgnoreCase("default") || itrRlocs == null) { recordBuilder.getLocatorRecord().add( ExplicitLocatorPath teAddress = ((ExplicitLocatorPath) container.getAddress()); SimpleAddress nextHop = getNextELPHop(teAddress, itrRlocs); if (nextHop != null) {
Address address = locator.getRloc().getAddress(); if (address instanceof ApplicationData) { ApplicationData applicationData = (ApplicationData) address;