Examples of IOFSwitch


Examples of net.beaconcontroller.core.IOFSwitch

        SwitchDevice switchDevice = flowscaleController
            .getSwitchDevices().get(
                HexString.toLong(datapathIdString));

        IOFSwitch sw = switchDevice.getOpenFlowSwitch();
        List<OFPhysicalPort> switchPorts = switchDevice.getPortStates();
        OFPhysicalPort updatedPort = null;

        for (OFPhysicalPort ofPort : switchPorts) {

          if (ofPort.getPortNumber() == Short
              .parseShort(sensorIdString)) {
            updatedPort = ofPort;
            break;

          }

        }

        updatedPort.setConfig(0);

        OFPortMod portMod = new OFPortMod();

        if (updateStatus.equals("down")) {
          portMod.setConfig(OFPhysicalPort.OFPortConfig.OFPPC_PORT_DOWN
              .getValue());
        } else if (updateStatus.equals("up")) {
          portMod.setConfig(0);
        }

        portMod.setMask(1);
        portMod.setPortNumber(updatedPort.getPortNumber());
        portMod.setHardwareAddress(updatedPort.getHardwareAddress());
        portMod.setType(OFType.PORT_MOD);

        sw.getOutputStream().write(portMod);
        sw.getOutputStream().flush();
        obj = new JSONObject();
        obj.put("result", "success");
        obj.put("desc", "sensor "+sensorIdString+" marked as "+updateStatus +
            " on switch "+ datapathIdString);
        response.getWriter().print(obj);
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

            for (OFMatchReconcile ofmr : ofmRcList) {
                // We only care about OFMatchReconcile objects that wish to
                // update the path to a switch
                if (ofmr.rcAction.equals(OFMatchReconcile.ReconcileAction.UPDATE_PATH)) {
                    // Get the switch object from the OFMatchReconcile
                    IOFSwitch sw = floodlightProvider
                            .getSwitch(ofmr.ofmWithSwDpid.getSwitchDataPathId());

                    // Map data structure that holds the invalid matches and the
                    // ingress ports of those matches
                    Map<Short, List<OFMatch>> invalidBaseIngressAndMatches = new HashMap<Short, List<OFMatch>>();

                    // Get the invalid flows
                    List<OFFlowStatisticsReply> flows = getFlows(sw,
                                                                 ofmr.outPort);

                    // Analyze all the flows with outPorts equaling the downed
                    // port and extract OFMatch's to trace back to neighbors
                    for (OFFlowStatisticsReply flow : flows) {
                        // Create a reference to the match for ease
                        OFMatch match = flow.getMatch();

                        // Here we utilize an index of input ports which point
                        // to multiple invalid matches
                        if (invalidBaseIngressAndMatches.containsKey(match.getInputPort()))
                            // If the input port is already in the index, add
                            // the match to it's list
                            invalidBaseIngressAndMatches.get(match.getInputPort())
                                                        .add(match);
                        else {
                            // Otherwise create a new list and add it to the
                            // index
                            List<OFMatch> matches = new ArrayList<OFMatch>();
                            matches.add(match);
                            invalidBaseIngressAndMatches.put(match.getInputPort(),
                                                             matches);
                        }
                    }

                    // Remove invalid flows from the base switch, if they exist
                    if (!flows.isEmpty()) {
                        log.debug("Removing flows on switch : " + sw.getId()
                                  + " with outport: " + ofmr.outPort);
                        clearFlowMods(sw, ofmr.outPort);
                    }

                    // Create a list of neighboring switches we need to remove
                    // invalid flows from
                    Map<IOFSwitch, Map<Short, List<OFMatch>>> neighborSwitches = new HashMap<IOFSwitch, Map<Short, List<OFMatch>>>();

                    // Loop through all the links
                    for (Link link : links.keySet()) {
                        // Filter out links we care about
                        if (link.getDst() == sw.getId()) {
                            // Loop through the links to neighboring switches
                            // which have invalid flows
                            for (Entry<Short, List<OFMatch>> invalidBaseIngressAndMatch : invalidBaseIngressAndMatches.entrySet()) {
                                // Find links on the network which link to the
                                // ingress ports that have invalidly routed
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

            switches = new HashSet<Long>();
            switches.add(pinSwitch);
        }

        for(long sid: switches) {
            IOFSwitch sw = floodlightProvider.getSwitch(sid);
            if (sw == null) continue;
            Collection<Short> enabledPorts = sw.getEnabledPortNumbers();
            if (enabledPorts == null)
                continue;
            Set<Short> ports = new HashSet<Short>();
            ports.addAll(enabledPorts);
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

    /**
     *  Switch methods
     */
    @Override
    public Set<Short> getPorts(long sw) {
        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
        if (iofSwitch == null) return Collections.emptySet();

        Collection<Short> ofpList = iofSwitch.getEnabledPortNumbers();
        if (ofpList == null) return Collections.emptySet();

        Set<Short> ports = new HashSet<Short>(ofpList);
        Set<Short> qPorts = linkDiscovery.getQuarantinedPorts(sw);
        if (qPorts != null)
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        // Check whether the port is a physical port. We should not learn
        // attachment points on "special" ports.
        if ((port & 0xff00) == 0xff00 && port != (short)0xfffe) return false;

        // Make sure that the port is enabled.
        IOFSwitch sw = floodlightProvider.getSwitch(switchid);
        if (sw == null) return false;
        return (sw.portEnabled(port));
    }
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

                    switchRemovedFromStore(key);
                    continue;
                }
                SwitchSyncRepresentation storedSwitch =
                        versionedSwitch.getValue();
                IOFSwitch sw = getOFSwitchInstance(storedSwitch.getDescription());
                sw.setFeaturesReply(storedSwitch.getFeaturesReply());
                if (!key.equals(storedSwitch.getFeaturesReply().getDatapathId())) {
                    counters.storeSyncError.updateCounterWithFlush();
                    log.error("Inconsistent DPIDs from switch sync store: " +
                              "key is {} but sw.getId() says {}. Ignoring",
                              HexString.toHexString(key), sw.getStringId());
                    continue;
                }
                switchAddedToStore(sw);
            }
        }
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

                return; // only react to switch connections when master
                // FIXME: should we disconnect the switch? When can this happen?
            }
            Long dpid = sw.getId();
            counters.switchActivated.updateCounterWithFlush();
            IOFSwitch oldSw = this.activeSwitches.put(dpid, sw);
            // Update event history
            evSwitch.updateEventWithFlush(new SwitchEvent(dpid, "connected"));

            if (oldSw == sw)  {
                // Note == for object equality, not .equals for value
                // TODO: should we wipe the flow table if
                // alwaysClearFlowsOnSwAdd is set? OTOH this case should
                // really never happen.
                counters.errorSameSwitchReactivated.updateCounterWithFlush();
                log.error("Switch {} activated but was already active", sw);
                addSwitchToStore(sw);
                return;
            }

            if (oldSw != null) {
                // This happens either when we have switches with duplicate
                // DPIDs or when a switch reconnects before we saw the
                // disconnect
                counters.switchWithSameDpidActivated.updateCounterWithFlush();
                log.warn("New switch added {} for already-added switch {}",
                          sw, oldSw);
                // We need to disconnect and remove the old switch
                // TODO: we notify switch listeners that the switch has been
                // removed and then we notify them that the new one has been
                // added. One could argue that a switchChanged notification
                // might be more appropriate in this case....
                oldSw.cancelAllStatisticsReplies();
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.REMOVED));
                oldSw.disconnectOutputStream();
                // Add the new switch and clear FlowMods
                // TODO: if this is the same switch re-connecting rather than
                // a DPID collision it would make sense to not wipe the flow
                // table.
                sw.clearAllFlowMods();
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.ADDED));
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.ACTIVATED));
                addSwitchToStore(sw);
                return;
            }

            IOFSwitch storedSwitch = this.syncedSwitches.remove(sw.getId());
            if (storedSwitch == null) {
                // The switch isn't known to the controller cluster. We
                // need to send a switchAdded notification and clear all
                // flows.
                if (!swConnectCache.update(sw.getId()))
                    sw.clearAllFlowMods();
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.ADDED));
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.ACTIVATED));
                counters.newSwitchActivated.updateCounterWithFlush();
            } else {
                // FIXME: switch was in store. check if ports or anything else
                // has changed and send update.
                if (alwaysClearFlowsOnSwActivate) {
                    sw.clearAllFlowMods();
                }
                if (sw.attributeEquals(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, true)) {
                    // We have a stored switch and the newly activated switch
                    // supports roles. This indicates that the switch was
                    // previously connected as slave. Since we don't update
                    // ports while slave, we need to set the ports on the
                    // new switch from the ports on the stored switch
                    // No need to send notifications, since we've dispatched
                    // them as we receive them from the store
                    sw.setPorts(storedSwitch.getPorts());
                }
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.ACTIVATED));
                sendNotificationsIfSwitchDiffers(storedSwitch, sw);
                counters.syncedSwitchActivated.updateCounterWithFlush();
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

                counters.invalidStoreEventWhileMaster.updateCounterWithFlush();
                return; // only read from store if slave
            }
            Long dpid = sw.getId();

            IOFSwitch oldSw = syncedSwitches.put(dpid, sw);
            if (oldSw == null)  {
                counters.newSwitchFromStore.updateCounterWithFlush();
                addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
            } else {
                // The switch already exists in storage, see if anything
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        private synchronized void switchRemovedFromStore(long dpid) {
            if (role != Role.SLAVE) {
                counters.invalidStoreEventWhileMaster.updateCounterWithFlush();
                return; // only read from store if slave
            }
            IOFSwitch oldSw = syncedSwitches.remove(dpid);
            if (oldSw != null) {
                counters.syncedSwitchRemoved.updateCounterWithFlush();
                addUpdateToQueue(new SwitchUpdate(dpid,
                                                  SwitchUpdateType.REMOVED));
            } else {
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

            // TODO: this is asymmetric with respect to connect event
            //       in switchActivated(). Should we have events on the
            //       slave as well?
            evSwitch.updateEventWithFlush(new SwitchEvent(dpid, "disconnected"));
            counters.switchDisconnected.updateCounterWithFlush();
            IOFSwitch oldSw = this.activeSwitches.get(dpid);
            if (oldSw != sw) {
                // This can happen if the disconnected switch was inactive
                // (SLAVE) then oldSw==null. Or if we previously had the
                // "added switch for already added switch case".
                // Either way we shouldn't notify or do anything else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.