private Stream<Interface> getMatchingInterfacesStream(IpAddress ip) { return interfaces.values() .stream() .flatMap(Collection::stream) .filter(intf -> intf.ipAddressesList() .stream() .anyMatch(intfIp -> intfIp.subnetAddress().contains(ip))); }
private Collection<PointToPointIntent> buildSpeakerIntents(BgpConfig.BgpSpeakerConfig speaker) { List<PointToPointIntent> intents = new ArrayList<>(); // Get the BGP Speaker VLAN Id VlanId bgpSpeakerVlanId = speaker.vlan(); for (IpAddress peerAddress : speaker.peers()) { Interface peeringInterface = interfaceService.getMatchingInterface(peerAddress); if (peeringInterface == null) { log.debug("No peering interface found for peer {} on speaker {}", peerAddress, speaker); continue; } IpAddress bgpSpeakerAddress = null; for (InterfaceIpAddress address : peeringInterface.ipAddressesList()) { if (address.subnetAddress().contains(peerAddress)) { bgpSpeakerAddress = address.ipAddress(); break; } } checkNotNull(bgpSpeakerAddress); VlanId peerVlanId = peeringInterface.vlan(); intents.addAll(buildIntents(speaker.connectPoint(), bgpSpeakerVlanId, bgpSpeakerAddress, peeringInterface.connectPoint(), peerVlanId, peerAddress)); } return intents; }
/** * Sends an ARP or NDP request for the given IP address. * * @param targetIp IP address to send the request for */ private void sendRequest(IpAddress targetIp) { interfaceService.getMatchingInterfaces(targetIp).forEach(intf -> { if (!edgePortService.isEdgePoint(intf.connectPoint())) { log.warn("Aborting attempt to send probe out non-edge port: {}", intf); return; } intf.ipAddressesList().stream() .filter(ia -> ia.subnetAddress().contains(targetIp)) .forEach(ia -> { MacAddress probeMac = intf.mac(); IpAddress probeIp = !probeMac.equals(MacAddress.ONOS) ? ia.ipAddress() : (ia.ipAddress().isIp4() ? Ip4Address.ZERO : Ip6Address.ZERO); sendProbe(intf.connectPoint(), targetIp, probeIp, probeMac, intf.vlan()); // account for use-cases where tagged-vlan config is used if (!intf.vlanTagged().isEmpty()) { intf.vlanTagged().forEach(tag -> { sendProbe(intf.connectPoint(), targetIp, probeIp, probeMac, tag); }); } }); }); }
if (criterionMap.containsKey(Criterion.Type.IPV4_SRC)) { if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_SRC)).ip() .contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) { criterionMap.remove(Criterion.Type.IPV4_SRC); } else { if (criterionMap.containsKey(Criterion.Type.IPV4_DST)) { if (((IPCriterion) criterionMap.get(Criterion.Type.IPV4_DST)).ip() .contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) { criterionMap.remove(Criterion.Type.IPV4_DST); } else { if (criterionMap.containsKey(Criterion.Type.IPV6_SRC)) { if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_SRC)).ip() .contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) { criterionMap.remove(Criterion.Type.IPV6_SRC); } else { if (criterionMap.containsKey(Criterion.Type.IPV6_DST)) { if (((IPCriterion) criterionMap.get(Criterion.Type.IPV6_DST)).ip() .contains(((L3ModificationInstruction.ModIPInstruction) l3).ip())) { criterionMap.remove(Criterion.Type.IPV6_DST); } else {