/** * Instantiates a new port. */ protected Port(final OFPhysicalPort ofPort) { super(); this.portNumber = ofPort.getPortNumber(); this.hardwareAddress = ofPort.getHardwareAddress(); this.name = ofPort.getName(); this.config = ofPort.getConfig(); this.state = ofPort.getState(); this.currentFeatures = ofPort.getCurrentFeatures(); this.advertisedFeatures = ofPort.getAdvertisedFeatures(); this.supportedFeatures = ofPort.getSupportedFeatures(); this.peerFeatures = ofPort.getPeerFeatures(); if (this.hardwareAddress == null) { this.hardwareAddress = new byte[] {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF, (byte) 0xCA, (byte) 0xFE}; } this.mac = new MACAddress(this.hardwareAddress); this.isEdge = false; this.parentSwitch = null; this.portLink = null; }
/** * Adds a default OpenFlow port to the give list of physical ports. * * @param ports the list of ports */ protected void addDefaultPort(final LinkedList<OFPhysicalPort> ports) { final OFPhysicalPort port = new OFPhysicalPort(); port.setPortNumber(OFPort.OFPP_LOCAL.getValue()); port.setName("OpenFlow Local Port"); port.setConfig(1); final byte[] addr = {(byte) 0xA4, (byte) 0x23, (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x00}; port.setHardwareAddress(addr); port.setState(1); port.setAdvertisedFeatures(0); port.setCurrentFeatures(0); port.setSupportedFeatures(0); ports.add(port); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof Port)) { return false; } Port other = (Port) obj; if (parentSwitch == null) { if (other.parentSwitch != null) { return false; } } else if (!parentSwitch.equals(other.parentSwitch)) { return false; } return true; }
/** * Changes the attribute of this port according to a MODIFY PortStatus. * * @param portstat the virtual port status */ public void applyPortStatus(OVXPortStatus portstat) { if (portstat.getReason() != OFPortReason.OFPPR_MODIFY.getReasonCode()) { return; } OFPhysicalPort psport = portstat.getDesc(); this.config = psport.getConfig(); this.state = psport.getState(); this.peerFeatures = psport.getPeerFeatures(); }
public static Set<Property> OFPortToProps(OFPhysicalPort port) { Set<Property> props = new HashSet<Property>(); Bandwidth bw = InventoryServiceHelper.OFPortToBandWidth(port .getCurrentFeatures()); if (bw != null) { props.add(bw); Bandwidth abw = InventoryServiceHelper.OFPortToBandWidth(port.getAdvertisedFeatures()); if (abw != null) { AdvertisedBandwidth a = new AdvertisedBandwidth(abw.getValue()); Bandwidth sbw = InventoryServiceHelper.OFPortToBandWidth(port.getSupportedFeatures()); if (sbw != null) { SupportedBandwidth s = new SupportedBandwidth(sbw.getValue()); Bandwidth pbw = InventoryServiceHelper.OFPortToBandWidth(port.getPeerFeatures()); if (pbw != null) { PeerBandwidth p = new PeerBandwidth(pbw.getValue()); props.add(new Name(port.getName())); props.add(InventoryServiceHelper.OFPortToConfig(port.getConfig())); props.add(InventoryServiceHelper.OFPortToState(port.getState())); return props;
@Override public boolean isPortEnabled(OFPhysicalPort port) { if (port == null) { return false; } int portConfig = port.getConfig(); int portState = port.getState(); if ((portConfig & OFPortConfig.OFPPC_PORT_DOWN.getValue()) > 0) { return false; } if ((portState & OFPortState.OFPPS_LINK_DOWN.getValue()) > 0) { return false; } if ((portState & OFPortState.OFPPS_STP_MASK.getValue()) == OFPortState.OFPPS_STP_BLOCK.getValue()) { return false; } return true; }
private void updatePhysicalPort(OFPhysicalPort port) { Short portNumber = port.getPortNumber(); physicalPorts.put(portNumber, port); portBandwidth .put(portNumber, port.getCurrentFeatures() & (OFPortFeatures.OFPPF_10MB_FD.getValue() | OFPortFeatures.OFPPF_10MB_HD.getValue() | OFPortFeatures.OFPPF_100MB_FD.getValue() | OFPortFeatures.OFPPF_100MB_HD.getValue() | OFPortFeatures.OFPPF_1GB_FD.getValue() | OFPortFeatures.OFPPF_1GB_HD.getValue() | OFPortFeatures.OFPPF_10GB_FD .getValue())); }
private void deletePhysicalPort(OFPhysicalPort port) { Short portNumber = port.getPortNumber(); physicalPorts.remove(portNumber); portBandwidth.remove(portNumber); }
@Override public void readFrom(final ChannelBuffer data) { super.readFrom(data); this.reason = data.readByte(); data.readerIndex(data.readerIndex() + 7); // skip 7 bytes of padding if (this.desc == null) { this.desc = new OFPhysicalPort(); } this.desc.readFrom(data); }
public boolean isState(OFPortState state) { return this.desc.getState() == state.getValue(); }
@Override public String toString() { return "OVXPortStatus: reason[" + OFPortReason.fromReasonCode(this.reason).name() + "]" + " port[" + this.desc.getPortNumber() + "]"; }
@Override public void readFrom(final ChannelBuffer data) { super.readFrom(data); this.datapathId = data.readLong(); this.buffers = data.readInt(); this.tables = data.readByte(); data.readerIndex(data.readerIndex() + 3); // pad this.capabilities = data.readInt(); this.actions = data.readInt(); if (this.ports == null) { this.ports = new ArrayList<OFPhysicalPort>(); } else { this.ports.clear(); } final int portCount = (super.getLengthU() - 32) / OFPhysicalPort.MINIMUM_LENGTH; OFPhysicalPort port; for (int i = 0; i < portCount; ++i) { port = new OFPhysicalPort(); port.readFrom(data); this.ports.add(port); } }
/** * Changes the attribute of this port according to a MODIFY PortStatus. * * @param portstat * the port status */ public void applyPortStatus(OVXPortStatus portstat) { if (!portstat.isReason(OFPortReason.OFPPR_MODIFY)) { return; } OFPhysicalPort psport = portstat.getDesc(); this.portNumber = psport.getPortNumber(); this.hardwareAddress = psport.getHardwareAddress(); this.name = psport.getName(); this.config = psport.getConfig(); this.state = psport.getState(); this.currentFeatures = psport.getCurrentFeatures(); this.advertisedFeatures = psport.getAdvertisedFeatures(); this.supportedFeatures = psport.getSupportedFeatures(); this.peerFeatures = psport.getPeerFeatures(); }
final LinkedList<OFPhysicalPort> portList = new LinkedList<OFPhysicalPort>(); for (final OVXPort ovxPort : this.portMap.values()) { final OFPhysicalPort ofPort = new OFPhysicalPort(); ofPort.setPortNumber(ovxPort.getPortNumber()); ofPort.setName(ovxPort.getName()); ofPort.setConfig(ovxPort.getConfig()); ofPort.setHardwareAddress(ovxPort.getHardwareAddress()); ofPort.setState(ovxPort.getState()); ofPort.setAdvertisedFeatures(ovxPort.getAdvertisedFeatures()); ofPort.setCurrentFeatures(ovxPort.getCurrentFeatures()); ofPort.setSupportedFeatures(ovxPort.getSupportedFeatures()); portList.add(ofPort);
private void addDiscovery(Node node) { Map<Long, ISwitch> switches = controller.getSwitches(); ISwitch sw = switches.get(node.getID()); if (sw == null) { //switch could be removed by now, stop propagation return; } List<OFPhysicalPort> ports = sw.getEnabledPorts(); for (OFPhysicalPort port : ports) { NodeConnector nodeConnector = NodeConnectorCreator.createOFNodeConnector(port.getPortNumber(), node); if (!readyListHi.contains(nodeConnector)) { readyListHi.add(nodeConnector); } } }
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof OFPortStatus)) { return false; } final OFPortStatus other = (OFPortStatus) obj; if (this.desc == null) { if (other.desc != null) { return false; } } else if (!this.desc.equals(other.desc)) { return false; } if (this.reason != other.reason) { return false; } return true; } }
for (OFPhysicalPort port : sw.getEnabledPorts()) { Node node = NodeCreator.createOFNode(sw.getId()); NodeConnector nodeConnector = NodeConnectorCreator.createOFNodeConnector(port.getPortNumber(), node); if (!isTracked(nodeConnector)) { stagingList.add(nodeConnector);
protected void handlePortStatusMessage(ISwitch sw, OFPortStatus m) { Node node = NodeCreator.createOFNode(sw.getId()); NodeConnector nodeConnector = PortConverter.toNodeConnector( m.getDesc().getPortNumber(), node); // get node connector properties Set<Property> props = InventoryServiceHelper.OFPortToProps(m.getDesc()); UpdateType type = null; if (m.getReason() == (byte) OFPortReason.OFPPR_ADD.ordinal()) { type = UpdateType.ADDED; nodeConnectorProps.put(nodeConnector, props); } else if (m.getReason() == (byte) OFPortReason.OFPPR_DELETE.ordinal()) { type = UpdateType.REMOVED; nodeConnectorProps.remove(nodeConnector); } else if (m.getReason() == (byte) OFPortReason.OFPPR_MODIFY.ordinal()) { type = UpdateType.CHANGED; nodeConnectorProps.put(nodeConnector, props); } logger.trace("handlePortStatusMessage {} type {}", nodeConnector, type); if (type != null) { notifyInventoryShimListener(nodeConnector, type, props); } }
@Override public void virtualize(final PhysicalSwitch sw) { Mappable map = sw.getMap(); PhysicalPort p = sw.getPort(this.desc.getPortNumber()); if (p == null) { handlePortAdd(sw, p);