Examples of IOFSwitch


Examples of net.floodlightcontroller.core.IOFSwitch

    }

    private Command dispatchPacketIn(long swId, OFPacketIn pi,
                                     FloodlightContext cntx) {
        IOFSwitch sw = mockFloodlightProvider.getSwitch(swId);
        Ethernet eth = new Ethernet();
        eth.deserialize(pi.getPacketData(), 0, pi.getPacketData().length);
        IFloodlightProviderService.bcStore.put(cntx,
                IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                eth);
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        List<NodePortTuple> switchPortList = route.getPath();

        for (int indx = switchPortList.size()-1; indx > 0; indx -= 2) {
            // indx and indx-1 will always have the same switch DPID.
            long switchDPID = switchPortList.get(indx).getNodeId();
            IOFSwitch sw = floodlightProvider.getSwitch(switchDPID);
            if (sw == null) {
                if (log.isWarnEnabled()) {
                    log.warn("Unable to push route, switch at DPID {} " +
                            "not available", switchDPID);
                }
                return srcSwitchIncluded;
            }

            // set the match.
            fm.setMatch(wildcard(match, sw, wildcard_hints));

            // set buffer id if it is the source switch
            if (1 == indx) {
                // Set the flag to request flow-mod removal notifications only for the
                // source switch. The removal message is used to maintain the flow
                // cache. Don't set the flag for ARP messages - TODO generalize check
                if ((reqeustFlowRemovedNotifn)
                        && (match.getDataLayerType() != Ethernet.TYPE_ARP)) {
                    /**with new flow cache design, we don't need the flow removal message from switch anymore
                    fm.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
                    */
                    match.setWildcards(fm.getMatch().getWildcards());
                }
            }

            short outPort = switchPortList.get(indx).getPortId();
            short inPort = switchPortList.get(indx-1).getPortId();
            // set input and output ports on the switch
            fm.getMatch().setInputPort(inPort);
            ((OFActionOutput)fm.getActions().get(0)).setPort(outPort);

            try {
                counterStore.updatePktOutFMCounterStoreLocal(sw, fm);
                if (log.isTraceEnabled()) {
                    log.trace("Pushing Route flowmod routeIndx={} " +
                            "sw={} inPort={} outPort={}",
                            new Object[] {indx,
                                          sw,
                                          fm.getMatch().getInputPort(),
                                          outPort });
                }
                messageDamper.write(sw, fm, cntx);
                if (doFlush) {
                    sw.flush();
                    counterStore.updateFlush();
                }

                // Push the packet out the source switch
                if (sw.getId() == pinSwitch) {
                    // TODO: Instead of doing a packetOut here we could also
                    // send a flowMod with bufferId set....
                    pushPacket(sw, pi, false, outPort, cntx);
                    srcSwitchIncluded = true;
                }
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        if (sw_tup == null) {
            return false;
        }

        IOFSwitch sw =
                floodlightProvider.getSwitch(sw_tup.getSwitchDPID());
        if (sw == null) return false;
        int inputPort = sw_tup.getPort();
        log.debug("blockHost sw={} port={} mac={}",
                  new Object[] { sw, sw_tup.getPort(), Long.valueOf(host_mac) });

        // Create flow-mod based on packet-in and src-switch
        OFFlowMod fm =
                (OFFlowMod) floodlightProvider.getOFMessageFactory()
                                              .getMessage(OFType.FLOW_MOD);
        OFMatch match = new OFMatch();
        List<OFAction> actions = new ArrayList<OFAction>(); // Set no action to
                                                            // drop
        match.setInputPort((short)inputPort);
        if (host_mac != -1L) {
            match.setDataLayerSource(Ethernet.toByteArray(host_mac))
                .setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_DL_SRC
                               & ~OFMatch.OFPFW_IN_PORT);
        } else {
            match.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_IN_PORT);
        }
        fm.setCookie(cookie)
          .setHardTimeout(hardTimeout)
          .setIdleTimeout(FLOWMOD_DEFAULT_IDLE_TIMEOUT)
          .setBufferId(OFPacketOut.BUFFER_ID_NONE)
          .setMatch(match)
          .setActions(actions)
          .setLengthU(OFFlowMod.MINIMUM_LENGTH); // +OFActionOutput.MINIMUM_LENGTH);

        try {
            log.debug("write drop flow-mod sw={} match={} flow-mod={}",
                      new Object[] { sw, match, fm });
            // TODO: can't use the message damper sine this method is static
            sw.write(fm, null);
        } catch (IOException e) {
            log.error("Failure writing deny flow mod", e);
            return false;
        }
        return true;
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

            .setPacketData(this.testPacketSerialized);
        po.setLengthU(OFPacketOut.MINIMUM_LENGTH + po.getActionsLengthU()
                + this.testPacketSerialized.length);

        // Mock up our expected behavior
        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
        expect(mockSwitch.getStringId()).andReturn("00:11:22:33:44:55:66:77").anyTimes();
        mockSwitch.write(po, null);

        // Start recording the replay on the mocks
        replay(mockSwitch);
        // Get the listener and trigger the packet in
        IOFMessageListener listener = mockFloodlightProvider.getListeners().get(
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        .setPacketData(null)
        .setLength((short) (OFPacketOut.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
        packetOut.setActionFactory(mockFloodlightProvider.getOFMessageFactory());

        // Mock up our expected behavior
        IOFSwitch mockSwitch = createMock(IOFSwitch.class);
        expect(mockSwitch.getId()).andReturn(1L).anyTimes();
        expect(mockSwitch.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).andReturn((OFMatch.OFPFW_IN_PORT | OFMatch.OFPFW_NW_PROTO
                | OFMatch.OFPFW_TP_SRC | OFMatch.OFPFW_TP_DST | OFMatch.OFPFW_NW_SRC_ALL
                | OFMatch.OFPFW_NW_DST_ALL | OFMatch.OFPFW_NW_TOS));
        expect(mockSwitch.getBuffers()).andReturn(100).anyTimes();
        mockSwitch.write(packetOut, null);
        mockSwitch.write(fm1, null);
        mockSwitch.write(fm2, null);

        // Start recording the replay on the mocks
        replay(mockSwitch);

        // Populate the MAC table
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

    @Override
    public OFPacketOut generateLLDPMessage(long sw, short port,
                                       boolean isStandard, boolean isReverse) {

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

        if (log.isTraceEnabled()) {
            log.trace("Sending LLDP packet out of swich: {}, port: {}",
                      HexString.toHexString(sw), port);
        }
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

    }

    private Command handleLldp(LLDP lldp, long sw, short inPort,
                               boolean isStandard, FloodlightContext cntx) {
        // If LLDP is suppressed on this port, ignore received packet as well
        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);

        if (!isIncomingDiscoveryAllowed(sw, inPort, isStandard))
            return Command.STOP;

        // If this is a malformed LLDP exit
        if (lldp.getPortId() == null || lldp.getPortId().getLength() != 3) {
            return Command.STOP;
        }

        long myId = ByteBuffer.wrap(controllerTLV.getValue()).getLong();
        long otherId = 0;
        boolean myLLDP = false;
        Boolean isReverse = null;

        ByteBuffer portBB = ByteBuffer.wrap(lldp.getPortId().getValue());
        portBB.position(1);

        Short remotePort = portBB.getShort();
        IOFSwitch remoteSwitch = null;

        // Verify this LLDP packet matches what we're looking for
        for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) {
            if (lldptlv.getType() == 127 && lldptlv.getLength() == 12
                && lldptlv.getValue()[0] == 0x0
                && lldptlv.getValue()[1] == 0x26
                && lldptlv.getValue()[2] == (byte) 0xe1
                && lldptlv.getValue()[3] == 0x0) {
                ByteBuffer dpidBB = ByteBuffer.wrap(lldptlv.getValue());
                remoteSwitch = floodlightProvider.getSwitch(dpidBB.getLong(4));
            } else if (lldptlv.getType() == 12 && lldptlv.getLength() == 8) {
                otherId = ByteBuffer.wrap(lldptlv.getValue()).getLong();
                if (myId == otherId) myLLDP = true;
            } else if (lldptlv.getType() == TLV_DIRECTION_TYPE
                       && lldptlv.getLength() == TLV_DIRECTION_LENGTH) {
                if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_FORWARD[0])
                    isReverse = false;
                else if (lldptlv.getValue()[0] == TLV_DIRECTION_VALUE_REVERSE[0])
                    isReverse = true;
            }
        }

        if (myLLDP == false) {
            // This is not the LLDP sent by this controller.
            // If the LLDP message has multicast bit set, then we need to
            // broadcast the packet as a regular packet (after checking IDs)
            if (isStandard) {
                if (log.isTraceEnabled()) {
                    log.trace("Got a standard LLDP=[{}] that was not sent by" +
                              " this controller. Not fowarding it.", lldp.toString());
                }
                return Command.STOP;
            } else if (myId < otherId) {
                if (log.isTraceEnabled()) {
                    log.trace("Getting BDDP packets from a different controller"
                              + "and letting it go through normal processing chain.");
                }
                return Command.CONTINUE;
            }
            return Command.STOP;
        }

        if (remoteSwitch == null) {
            // Ignore LLDPs not generated by Floodlight, or from a switch that
            // has recently
            // disconnected, or from a switch connected to another Floodlight
            // instance
            if (log.isTraceEnabled()) {
                log.trace("Received LLDP from remote switch not connected to the controller");
            }
            return Command.STOP;
        }

        if (!remoteSwitch.portEnabled(remotePort)) {
            if (log.isTraceEnabled()) {
                log.trace("Ignoring link with disabled source port: switch {} port {} {}",
                          new Object[] { remoteSwitch.getStringId(),
                                         remotePort,
                                         remoteSwitch.getPort(remotePort)});
            }
            return Command.STOP;
        }
        if (suppressLinkDiscovery.contains(new NodePortTuple(
                                                             remoteSwitch.getId(),
                                                             remotePort))) {
            if (log.isTraceEnabled()) {
                log.trace("Ignoring link with suppressed src port: switch {} port {} {}",
                          new Object[] { remoteSwitch.getStringId(),
                                         remotePort,
                                         remoteSwitch.getPort(remotePort)});
            }
            return Command.STOP;
        }
        if (!iofSwitch.portEnabled(inPort)) {
            if (log.isTraceEnabled()) {
                log.trace("Ignoring link with disabled dest port: switch {} port {} {}",
                          new Object[] { HexString.toHexString(sw),
                                         inPort,
                                         iofSwitch.getPort(inPort)});
            }
            return Command.STOP;
        }

        // Store the time of update to this link, and push it out to
        // routingEngine
        Link lt = new Link(remoteSwitch.getId(), remotePort,
                           iofSwitch.getId(), inPort);

        if (!isLinkAllowed(lt.getSrc(), lt.getSrcPort(),
                           lt.getDst(), lt.getDstPort()))
            return Command.STOP;
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        if (isLinkDiscoverySuppressed(sw, p)) {
            // Do nothing as link discovery is suppressed.
            return;
        }

        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
        if (iofSwitch == null) return;

        if (autoPortFastFeature && iofSwitch.isFastPort(p)) {
            // Do nothing as the port is a fast port.
            return;
        }
        NodePortTuple npt = new NodePortTuple(sw, p);
        discover(sw, p);
        // if it is not a fast port, add it to quarantine.
        if (!iofSwitch.isFastPort(p)) {
            addToQuarantineQueue(npt);
        } else {
            // Add to maintenance queue to ensure that BDDP packets
            // are sent out.
            addToMaintenanceQueue(npt);
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

    }

    private void generateSwitchPortStatusUpdate(long sw, short port) {
        UpdateOperation operation;

        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
        if (iofSwitch == null) return;

        OFPhysicalPort ofp = iofSwitch.getPort(port).toOFPhysicalPort();
        if (ofp == null) return;

        int srcPortState = ofp.getState();
        boolean portUp = ((srcPortState & OFPortState.OFPPS_STP_MASK.getValue())
                               != OFPortState.OFPPS_STP_BLOCK.getValue());
View Full Code Here

Examples of net.floodlightcontroller.core.IOFSwitch

        if (isLinkDiscoverySuppressed(sw, port)) {
            /* Do not process LLDPs from this port as suppressLLDP is set */
            return false;
        }

        IOFSwitch iofSwitch = floodlightProvider.getSwitch(sw);
        if (iofSwitch == null) {
            return false;
        }

        if (port == OFPort.OFPP_LOCAL.getValue()) return false;

        ImmutablePort ofpPort = iofSwitch.getPort(port);
        if (ofpPort == null) {
            if (log.isTraceEnabled()) {
                log.trace("Null physical port. sw={}, port={}",
                          HexString.toHexString(sw), port);
            }
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.