/** * removed physical port from discovery process. * @param port the port number */ public void removePort(PortNumber port) { ports.remove(port.toLong()); }
private static List<PortStatistics> sortByPort(Iterable<PortStatistics> portStats) { List<PortStatistics> portStatsList = Lists.newArrayList(portStats); portStatsList.sort(Comparator.comparing(ps -> ps.portNumber().toLong())); return portStatsList; } }
@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final PortCriterion portCriterion = (PortCriterion) criterion; return root.put(CriterionCodec.PORT, portCriterion.port().toLong()); } }
private OFPort buildPort(PortNumber port) { return OFPort.of((int) port.toLong()); }
/** * Returns the point where the OLT is connected to the fabric given a * connect point on the agent device. * * @param agentConnectPoint connect point on the agent device * @return point were OLT is connected to fabric */ public Optional<ConnectPoint> getOltConnectPoint(ConnectPoint agentConnectPoint) { int index = ((int) agentConnectPoint.port().toLong()) / CHIP_PORT_RANGE_SIZE; if (index >= sortedOltChips.size()) { return Optional.empty(); } return Optional.of(sortedOltChips.get(index).getKey()); }
@Override public ObjectNode encode(NiciraResubmit niciraResubmit, CodecContext context) { checkNotNull(niciraResubmit, "Nicira Resubmit cannot be null"); ObjectNode root = context.mapper().createObjectNode() .put(RESUBMIT_PORT, niciraResubmit.inPort().toLong()) .put(RESUBMIT_TABLE, niciraResubmit.table()); return root; }
@Override public ObjectNode encode(NiciraResubmitTable niciraResubmitTable, CodecContext context) { checkNotNull(niciraResubmitTable, "Nicira Resubmit Table cannot be null"); ObjectNode root = context.mapper().createObjectNode() .put(RESUBMIT_PORT, niciraResubmitTable.inPort().toLong()) .put(RESUBMIT_TABLE, niciraResubmitTable.table()); return root; }
@Override protected List<String> choices() { DeviceId deviceId = lookForDeviceId(); if (deviceId == null) { return Collections.emptyList(); } DeviceService deviceService = getService(DeviceService.class); return StreamSupport.stream(deviceService.getPorts(deviceId).spliterator(), false) .map(port -> Long.toString(port.number().toLong())) .collect(Collectors.toList()); } }
public String pathToString(List<Link> links) { StringBuilder builder = new StringBuilder(); builder.append("{"); for (Link link : links) { builder.append("(Device:" + link.src().deviceId() + " Port:" + link.src().port().toLong()); builder.append(" Device:" + link.dst().deviceId() + " Port:" + link.dst().port().toLong()); builder.append(")"); } builder.append("}"); return builder.toString(); }
/** * Add physical port to discovery process. * Send out initial LLDP and label it as slow port. * * @param port the port */ public void addPort(Port port) { boolean newPort = ports.add(port.number().toLong()); boolean isMaster = context.mastershipService().isLocalMaster(device.id()); if (newPort && isMaster) { log.debug("Sending initial probe to port {}@{}", port.number().toLong(), device.id()); sendProbes(port.number().toLong()); } }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { PortCriterion c = (PortCriterion) criterion; initAsExactMatch(copyFrom(c.port().toLong()), bitWidth); } }
private OFPortDesc portDesc(PortNumber port) { OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc(); builder.setPortNo(OFPort.of((int) port.toLong())); return builder.build(); }
/** * Returns a collection of port statistics for given ports using the given BMv2 device agent. * * @param deviceAgent a device agent * @param ports a collection of ports * @return a collection of port statistics */ static Collection<PortStatistics> getPortStatistics(Bmv2DeviceAgent deviceAgent, Collection<Port> ports) { List<PortStatistics> ps = Lists.newArrayList(); for (Port port : ports) { int portNumber = (int) port.number().toLong(); try { Pair<Long, Long> egressCounter = deviceAgent.readCounter(EGRESS_COUNTER, portNumber); Pair<Long, Long> ingressCounter = deviceAgent.readCounter(INGRESS_COUNTER, portNumber); ps.add(DefaultPortStatistics.builder() .setPort(portNumber) .setBytesSent(egressCounter.getLeft()) .setPacketsSent(egressCounter.getRight()) .setBytesReceived(ingressCounter.getLeft()) .setPacketsReceived(ingressCounter.getRight()) .build()); } catch (Bmv2RuntimeException e) { log.info("Unable to read port statistics from {}: {}", port, e.explain()); } } return ps; }
@Override public void write(Kryo kryo, Output output, PortNumber object) { output.writeBoolean(object.hasName()); output.writeLong(object.toLong()); if (object.hasName()) { output.writeString(object.name()); } }
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 (ins != null) { Instructions.OutputInstruction out = (Instructions.OutputInstruction) ins; ofPort = OFPort.of((int) ((out.port().toLong())));
@Override public void addLink(IsisLink isisLink) { log.debug("Addlink {}", isisLink.localSystemId()); LinkDescription linkDes = buildLinkDes(isisLink); //Updating ports of the link //If already link exists, return if (linkService.getLink(linkDes.src(), linkDes.dst()) != null || linkProviderService == null) { return; } ConnectPoint destconnectPoint = linkDes.dst(); PortNumber destport = destconnectPoint.port(); if (destport.toLong() != 0) { deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(), linkDes.src().port())); deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(), linkDes.dst().port())); registerBandwidth(linkDes, isisLink); linkProviderService.linkDetected(linkDes); System.out.println("link desc " + linkDes.toString()); } }
@Override public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) { final Dpid dpid = dpid(deviceId.uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null || !sw.isConnected()) { LOG.error("Failed to change portState on device {}", deviceId); return; } OFPortMod.Builder pmb = sw.factory().buildPortMod(); OFPort port = OFPort.of((int) portNumber.toLong()); pmb.setPortNo(port); if (enable) { pmb.setConfig(0x0); // port_down bit 0 } else { pmb.setConfig(0x1); // port_down bit 1 } pmb.setMask(0x1); pmb.setAdvertise(0x0); for (OFPortDesc pd : sw.getPorts()) { if (pd.getPortNo().equals(port)) { pmb.setHwAddr(pd.getHwAddr()); break; } } sw.sendMsg(Collections.singletonList(pmb.build())); }
bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong())); } else { bucketBuilder.setWatchPort(OFPort.ANY);