Package net.floodlightcontroller.core

Examples of net.floodlightcontroller.core.IOFSwitch


        // Takes care of all checks including null pointer checks.
        if (!isOutgoingDiscoveryAllowed(sw, port, isStandard, isReverse))
            return;

        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
        OFPhysicalPort ofpPort = iofSwitch.getPort(port).toOFPhysicalPort();

        if (log.isTraceEnabled()) {
            log.trace("Sending LLDP packet out of swich: {}, port: {}",
                      HexString.toHexString(sw), port);
        }
        OFPacketOut po = generateLLDPMessage(sw, port, isStandard, isReverse);

        // Add actions
        List<OFAction> actions = getDiscoveryActions(iofSwitch, ofpPort);
        po.setActions(actions);
        short  actionLength = 0;
        Iterator <OFAction> actionIter = actions.iterator();
        while (actionIter.hasNext()) {
            actionLength += actionIter.next().getLength();
        }
        po.setActionsLength(actionLength);

        // po already has the minimum length + data length set
        // simply add the actions length to this.
        po.setLengthU(po.getLengthU() + po.getActionsLength());

        // send
        try {
            iofSwitch.write(po, null);
            iofSwitch.flush();
        } catch (IOException e) {
            log.error("Failure sending LLDP out port {} on switch {}",
                      new Object[] { port, iofSwitch.getStringId() }, e);
        }
    }
View Full Code Here


        if (log.isTraceEnabled()) {
            log.trace("Sending LLDP packets out of all the enabled ports");
        }
        // Send standard LLDPs
        for (long sw : floodlightProvider.getAllSwitchDpids()) {
            IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
            if (iofSwitch == null) continue;
            if (iofSwitch.getEnabledPorts() != null) {
                for (ImmutablePort ofp : iofSwitch.getEnabledPorts()) {
                    if (isLinkDiscoverySuppressed(sw, ofp.getPortNumber()))
                                                                           continue;
                    if (autoPortFastFeature
                        && iofSwitch.isFastPort(ofp.getPortNumber()))
                                                                     continue;

                    // sends forward LLDP only non-fastports.
                    sendDiscoveryMessage(sw, ofp.getPortNumber(), true,
                                         false);
View Full Code Here

    }

    @Override
    public void switchActivated(long switchId) {
        IOFSwitch sw = floodlightProvider.getSwitch(switchId);
        if (sw.getEnabledPortNumbers() != null) {
            for (Short p : sw.getEnabledPortNumbers()) {
                processNewPort(sw.getId(), p);
            }
        }
        LDUpdate update = new LDUpdate(sw.getId(), null,
                                       UpdateOperation.SWITCH_UPDATED);
        updates.add(update);
    }
View Full Code Here

        }

        ArrayList<IOFSwitch> updated_switches = new ArrayList<IOFSwitch>();
        for (Object key : rowKeys) {
            Long swId = new Long(HexString.toLong((String) key));
            IOFSwitch sw = floodlightProvider.getSwitch(swId);
            if (sw != null) {
                boolean curr_status = sw.hasAttribute(IOFSwitch.SWITCH_IS_CORE_SWITCH);
                boolean new_status = false;
                IResultSet resultSet = null;

                try {
                    resultSet = storageSource.getRow(tableName, key);
                    for (Iterator<IResultSet> it = resultSet.iterator(); it.hasNext();) {
                        // In case of multiple rows, use the status in last row?
                        Map<String, Object> row = it.next().getRow();
                        if (row.containsKey(SWITCH_CONFIG_CORE_SWITCH)) {
                            new_status = ((String) row.get(SWITCH_CONFIG_CORE_SWITCH)).equals("true");
                        }
                    }
                } finally {
                    if (resultSet != null) resultSet.close();
                }

                if (curr_status != new_status) {
                    updated_switches.add(sw);
                }
            } else {
                if (log.isTraceEnabled()) {
                    log.trace("Update for switch which has no entry in switch "
                                      + "list (dpid={}), a delete action.",
                              key);
                }
            }
        }

        for (IOFSwitch sw : updated_switches) {
            // Set SWITCH_IS_CORE_SWITCH to it's inverse value
            if (sw.hasAttribute(IOFSwitch.SWITCH_IS_CORE_SWITCH)) {
                sw.removeAttribute(IOFSwitch.SWITCH_IS_CORE_SWITCH);
                if (log.isTraceEnabled()) {
                    log.trace("SWITCH_IS_CORE_SWITCH set to False for {}",
                              sw);
                }
                updates.add(new LDUpdate(sw.getId(),
                                         SwitchType.BASIC_SWITCH,
                                         UpdateOperation.SWITCH_UPDATED));
            } else {
                sw.setAttribute(IOFSwitch.SWITCH_IS_CORE_SWITCH,
                                new Boolean(true));
                if (log.isTraceEnabled()) {
                    log.trace("SWITCH_IS_CORE_SWITCH set to True for {}", sw);
                }
                updates.add(new LDUpdate(sw.getId(), SwitchType.CORE_SWITCH,
                                         UpdateOperation.SWITCH_UPDATED));
            }
        }
    }
View Full Code Here

            try {
                IFloodlightProviderService floodlightProvider =
                        (IFloodlightProviderService)getContext().getAttributes().
                            get(IFloodlightProviderService.class.getCanonicalName());
                long dpid = HexString.toLong(switchId);
                IOFSwitch sw = floodlightProvider.getSwitch(dpid);
                allSwitchTableJson.put(HexString.toHexString(sw.getId()), getOneSwitchTable(table.get(sw)));
            } catch (NumberFormatException e) {
                log.error("Could not decode switch ID = " + switchId);
                setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            }
        }
View Full Code Here

     * while starting up.
     *
     * @param sw The switch to send entries to
     */
    protected void sendEntriesToSwitch(long switchId) {
        IOFSwitch sw = floodlightProvider.getSwitch(switchId);
        if (sw == null)
            return;
        String stringId = sw.getStringId();

        if ((entriesFromStorage != null) && (entriesFromStorage.containsKey(stringId))) {
            Map<String, OFFlowMod> entries = entriesFromStorage.get(stringId);
            List<String> sortedList = new ArrayList<String>(entries.keySet());
            // weird that Collections.sort() returns void
View Full Code Here

            message="Tried to write to switch {switch} but got {error}",
            explanation="An I/O error occured while trying to write a " +
                    "static flow to a switch",
            recommendation=LogMessageDoc.CHECK_SWITCH)
    private void writeOFMessagesToSwitch(long dpid, List<OFMessage> messages) {
        IOFSwitch ofswitch = floodlightProvider.getSwitch(dpid);
        if (ofswitch != null) {  // is the switch connected
            try {
                if (log.isDebugEnabled()) {
                    log.debug("Sending {} new entries to {}", messages.size(), dpid);
                }
                ofswitch.write(messages, null);
                ofswitch.flush();
            } catch (IOException e) {
                log.error("Tried to write to switch {} but got {}", dpid, e.getMessage());
            }
        }
    }
View Full Code Here

            message="Tried to write to switch {switch} but got {error}",
            explanation="An I/O error occured while trying to write a " +
                    "static flow to a switch",
            recommendation=LogMessageDoc.CHECK_SWITCH)
    private void writeOFMessageToSwitch(long dpid, OFMessage message) {
        IOFSwitch ofswitch = floodlightProvider.getSwitch(dpid);
        if (ofswitch != null) {  // is the switch connected
            try {
                if (log.isDebugEnabled()) {
                    log.debug("Sending 1 new entries to {}", HexString.toHexString(dpid));
                }
                ofswitch.write(message, null);
                ofswitch.flush();
            } catch (IOException e) {
                log.error("Tried to write to switch {} but got {}", dpid, e.getMessage());
            }
        }
    }
View Full Code Here

     * exists before it sends
     * @param dpid The data  to write the flow mod to
     * @param flowMod The OFFlowMod to write
     */
    private void writeFlowModToSwitch(long dpid, OFFlowMod flowMod) {
        IOFSwitch ofSwitch = floodlightProvider.getSwitch(dpid);
        if (ofSwitch == null) {
            if (log.isDebugEnabled()) {
                log.debug("Not deleting key {} :: switch {} not connected",
                          dpid);
            }
View Full Code Here

    public LinkDiscoveryManager getLinkDiscoveryManager() {
        return ldm;
    }

    private IOFSwitch createMockSwitch(Long id) {
        IOFSwitch mockSwitch = createNiceMock(IOFSwitch.class);
        expect(mockSwitch.getId()).andReturn(id).anyTimes();
        return mockSwitch;
    }
View Full Code Here

TOP

Related Classes of net.floodlightcontroller.core.IOFSwitch

Copyright © 2018 www.massapicom. 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.