private boolean isAllowed(ConnectPoint circuitCp, ConnectPoint connectivityCp) { ConnectPoint staticPort = staticPort(circuitCp); return staticPort == null || staticPort.equals(connectivityCp); }
@Override public Set<Link> getEgressLinks(ConnectPoint src) { Set<Link> egress = new HashSet<>(); synchronized (srcLinks) { for (LinkKey linkKey : srcLinks.get(src.deviceId())) { if (linkKey.src().equals(src)) { egress.add(links.get(linkKey)); } } } return egress; }
@Override public Set<Link> getIngressLinks(ConnectPoint dst) { Set<Link> ingress = new HashSet<>(); synchronized (dstLinks) { for (LinkKey linkKey : dstLinks.get(dst.deviceId())) { if (linkKey.dst().equals(dst)) { ingress.add(links.get(linkKey)); } } } return ingress; }
/** * Builder of a point to point intent. */ public static final class Builder extends ConnectivityIntent.Builder { NetworkId networkId; ConnectPoint ingressPoint; ConnectPoint egressPoint; /** * Builder constructor. */ private Builder() { // Hide constructor } @Override public Builder appId(ApplicationId appId) { return (Builder) super.appId(appId); } @Override public Builder key(Key key) { return (Builder) super.key(key); } @Override public Builder selector(TrafficSelector selector) { return (Builder) super.selector(selector); }
@Override protected List<String> choices() { DeviceService deviceService = getService(DeviceService.class); LinkService linkService = getService(LinkService.class); Optional<ConnectPoint> port = Arrays.asList(commandLine.getArguments()).stream() .filter(s -> s.contains(":") && s.contains("/")) .map(s -> { try { return deviceConnectPoint(s); } catch (IllegalArgumentException e) { // silently ill-formed String return null; } }) .filter(Objects::nonNull) .filter(cp -> deviceService.getPort(cp) != null) .findFirst(); if (!port.isPresent()) { // no candidate return Collections.emptyList(); } final ConnectPoint cp = port.get(); return linkService.getLinks(cp).stream() .flatMap(l -> Stream.of(l.src(), l.dst())) .filter(peer -> !cp.equals(peer)) .distinct() .map(ConnectPoint::toString) .collect(Collectors.toList()); }
@Override public void flood(NeighbourMessageContext context) { Tools.stream(edgeService.getEdgePoints()) .filter(cp -> !cp.equals(context.inPort())) .forEach(cp -> sendTo(context.packet(), cp)); }
@Override public void event(InterfaceEvent event) { Interface intf = event.subject(); Interface prevIntf = event.prevSubject(); switch (event.type()) { case INTERFACE_ADDED: if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { provisionInterface(intf); } break; case INTERFACE_UPDATED: if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { updateInterface(prevIntf, intf); } break; case INTERFACE_REMOVED: if (intf != null && !intf.connectPoint().equals(controlPlaneConnectPoint)) { removeInterface(intf); } break; default: break; } } }
private void removeInterface(Interface intf) { synchronized (this) { for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) { MultiPointToSinglePointIntent intent = entry.getValue(); if (intent.egressPoint().equals(intf.connectPoint())) { // This intent just lost its head. Remove it and let // higher layer routing reroute. intentSynchronizer.withdraw(routeIntents.remove(entry.getKey())); } else { if (intent.ingressPoints().contains(intf.connectPoint())) { Set<ConnectPoint> ingress = Sets.newHashSet(intent.ingressPoints()); ingress.remove(intf.connectPoint()); MultiPointToSinglePointIntent newIntent = MultiPointToSinglePointIntent.builder(intent) .ingressPoints(ingress) .build(); routeIntents.put(entry.getKey(), newIntent); intentSynchronizer.submit(newIntent); } } } } }
.filter(fcp -> fcp.connectPoint().equals(new ConnectPoint(deviceId, inPort))) .filter(fcp -> selector.criteria().containsAll(fcp.trafficSelector().criteria())) .findFirst()
private LinkedList<PcepValueType> createEroSubObj(Path path) { LinkedList<PcepValueType> subObjects = new LinkedList<>(); List<Link> links = path.links(); ConnectPoint source = null; ConnectPoint destination = null; IpAddress ipDstAddress = null; IpAddress ipSrcAddress = null; PcepValueType subObj = null; long portNo; for (Link link : links) { source = link.src(); if (!(source.equals(destination))) { //set IPv4SubObject for ERO object portNo = source.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipSrcAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt()); subObjects.add(subObj); } destination = link.dst(); portNo = destination.port().toLong(); portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; ipDstAddress = Ip4Address.valueOf((int) portNo); subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt()); subObjects.add(subObj); } return subObjects; }
if (!(source.equals(destination))) {
ConnectPoint srcStaticPort = staticPort(intent.getSrc()); if (srcStaticPort != null) { return ScalarWeight.toWeight(srcStaticPort.equals(edge.link().src()) ? 1 : -1); ConnectPoint dstStaticPort = staticPort(intent.getDst()); if (dstStaticPort != null) { return ScalarWeight.toWeight(dstStaticPort.equals(edge.link().dst()) ? 1 : -1);