Examples of OFMatch


Examples of org.openflow.protocol.OFMatch

            .setActions(Arrays.asList(new OFAction[] {
                    new OFActionOutput().setPort((short) 2).setMaxLength((short) -1)}))
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setCommand(OFFlowMod.OFPFC_ADD)
            .setIdleTimeout((short) 5)
            .setMatch(new OFMatch()
                .loadFromPacket(testPacketSerialized, (short) 1)
                .setWildcards(OFMatch.OFPFW_NW_PROTO | OFMatch.OFPFW_TP_SRC | OFMatch.OFPFW_TP_DST
                        | OFMatch.OFPFW_NW_TOS))
            .setOutPort(OFPort.OFPP_NONE.getValue())
            .setCookie(1L << 52)
            .setPriority((short) 100)
            .setFlags((short)(1 << 0))
            .setLengthU(OFFlowMod.MINIMUM_LENGTH+OFActionOutput.MINIMUM_LENGTH);
        OFMessage fm2 = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD))
            .setActions(Arrays.asList(new OFAction[] {
                    new OFActionOutput().setPort((short) 1).setMaxLength((short) -1)}))
            .setBufferId(-1)
            .setCommand(OFFlowMod.OFPFC_ADD)
            .setIdleTimeout((short) 5)
            .setMatch(new OFMatch()
                .loadFromPacket(testPacketReplySerialized, (short) 2)
                .setWildcards(OFMatch.OFPFW_NW_PROTO | OFMatch.OFPFW_TP_SRC | OFMatch.OFPFW_TP_DST
                        | OFMatch.OFPFW_NW_TOS))
            .setOutPort(OFPort.OFPP_NONE.getValue())
            .setCookie(1L << 52)
View Full Code Here

Examples of org.openflow.protocol.OFMatch

        route.getPath().add(new NodePortTuple(1L, (short)1));
        route.getPath().add(new NodePortTuple(1L, (short)3));
        expect(routingEngine.getRoute(1L, (short)1, 1L, (short)3, 0)).andReturn(route).atLeastOnce();

        // Expected Flow-mods
        OFMatch match = new OFMatch();
        match.loadFromPacket(testPacketSerialized, (short) 1);
        OFActionOutput action = new OFActionOutput((short)3, (short)0xffff);
        List<OFAction> actions = new ArrayList<OFAction>();
        actions.add(action);

        OFFlowMod fm1 =
                (OFFlowMod) mockFloodlightProvider.getOFMessageFactory().
                    getMessage(OFType.FLOW_MOD);
        fm1.setIdleTimeout((short)5)
            .setMatch(match.clone()
                    .setWildcards(expected_wildcards))
            .setActions(actions)
            .setBufferId(OFPacketOut.BUFFER_ID_NONE)
            .setCookie(2L << 52)
            .setLengthU(OFFlowMod.MINIMUM_LENGTH +
View Full Code Here

Examples of org.openflow.protocol.OFMatch

     * @param cntx
     * @return
     */
    private Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
        // Read in packet data headers by using OFMatch
        OFMatch match = new OFMatch();
        match.loadFromPacket(pi.getPacketData(), pi.getInPort());
        Long sourceMac = Ethernet.toLong(match.getDataLayerSource());
        Long destMac = Ethernet.toLong(match.getDataLayerDestination());
        Short vlan = match.getDataLayerVirtualLan();
        if ((destMac & 0xfffffffffff0L) == 0x0180c2000000L) {
            if (log.isTraceEnabled()) {
                log.trace("ignoring packet addressed to 802.1D/Q reserved addr: switch {} vlan {} dest MAC {}",
                          new Object[]{ sw, vlan, HexString.toHexString(destMac) });
            }
            return Command.STOP;
        }
        if ((sourceMac & 0x010000000000L) == 0) {
            // If source MAC is a unicast address, learn the port for this MAC/VLAN
            this.addToPortMap(sw, sourceMac, vlan, pi.getInPort());
        }

        // Now output flow-mod and/or packet
        Short outPort = getFromPortMap(sw, destMac, vlan);
        if (outPort == null) {
            // If we haven't learned the port for the dest MAC/VLAN, flood it
            // Don't flood broadcast packets if the broadcast is disabled.
            // XXX For LearningSwitch this doesn't do much. The sourceMac is removed
            //     from port map whenever a flow expires, so you would still see
            //     a lot of floods.
            this.writePacketOutForPacketIn(sw, pi, OFPort.OFPP_FLOOD.getValue());
        } else if (outPort == match.getInputPort()) {
            log.trace("ignoring packet that arrived on same port as learned destination:"
                    + " switch {} vlan {} dest MAC {} port {}",
                    new Object[]{ sw, vlan, HexString.toHexString(destMac), outPort });
        } else {
            // Add flow table entry matching source MAC, dest MAC, VLAN and input port
            // that sends to the port we previously learned for the dest MAC/VLAN.  Also
            // add a flow table entry with source and destination MACs reversed, and
            // input and output ports reversed.  When either entry expires due to idle
            // timeout, remove the other one.  This ensures that if a device moves to
            // a different port, a constant stream of packets headed to the device at
            // its former location does not keep the stale entry alive forever.
            // FIXME: current HP switches ignore DL_SRC and DL_DST fields, so we have to match on
            // NW_SRC and NW_DST as well
            match.setWildcards(((Integer)sw.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).intValue()
                    & ~OFMatch.OFPFW_IN_PORT
                    & ~OFMatch.OFPFW_DL_VLAN & ~OFMatch.OFPFW_DL_SRC & ~OFMatch.OFPFW_DL_DST
                    & ~OFMatch.OFPFW_NW_SRC_MASK & ~OFMatch.OFPFW_NW_DST_MASK);
            // We write FlowMods with Buffer ID none then explicitly PacketOut the buffered packet
            this.pushPacket(sw, match, pi, outPort);
            this.writeFlowMod(sw, OFFlowMod.OFPFC_ADD, OFPacketOut.BUFFER_ID_NONE, match, outPort);
            if (LEARNING_SWITCH_REVERSE_FLOW) {
                this.writeFlowMod(sw, OFFlowMod.OFPFC_ADD, -1, match.clone()
                    .setDataLayerSource(match.getDataLayerDestination())
                    .setDataLayerDestination(match.getDataLayerSource())
                    .setNetworkSource(match.getNetworkDestination())
                    .setNetworkDestination(match.getNetworkSource())
                    .setTransportSource(match.getTransportDestination())
                    .setTransportDestination(match.getTransportSource())
                    .setInputPort(outPort),
                    match.getInputPort());
            }
        }
        return Command.CONTINUE;
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

                log.warn("Skipping entry with bad data: {} :: {} ",
                        e.getMessage(), e.getStackTrace());
            }
        }

        OFMatch ofMatch = new OFMatch();
        String match = matchString.toString();
        try {
            ofMatch.fromString(match);
        } catch (IllegalArgumentException e) {
            log.debug(
                    "ignoring flow entry {} on switch {} with illegal OFMatch() key: "
                            + match, entryName, switchName);
            return;
View Full Code Here

Examples of org.openflow.protocol.OFMatch

            return Command.CONTINUE;
        }
        if (log.isTraceEnabled()) {
            log.trace("{} flow entry removed {}", sw, flowRemovedMessage);
        }
        OFMatch match = flowRemovedMessage.getMatch();
        // When a flow entry expires, it means the device with the matching source
        // MAC address and VLAN either stopped sending packets or moved to a different
        // port.  If the device moved, we can't know where it went until it sends
        // another packet, allowing us to re-learn its port.  Meanwhile we remove
        // it from the macVlanToPortMap to revert to flooding packets to this device.
        this.removeFromPortMap(sw, Ethernet.toLong(match.getDataLayerSource()),
            match.getDataLayerVirtualLan());

        // Also, if packets keep coming from another device (e.g. from ping), the
        // corresponding reverse flow entry will never expire on its own and will
        // send the packets to the wrong port (the matching input port of the
        // expired flow entry), so we must delete the reverse entry explicitly.
        this.writeFlowMod(sw, OFFlowMod.OFPFC_DELETE, -1, match.clone()
                .setWildcards(((Integer)sw.getAttribute(IOFSwitch.PROP_FASTWILDCARDS)).intValue()
                        & ~OFMatch.OFPFW_DL_VLAN & ~OFMatch.OFPFW_DL_SRC & ~OFMatch.OFPFW_DL_DST
                        & ~OFMatch.OFPFW_NW_SRC_MASK & ~OFMatch.OFPFW_NW_DST_MASK)
                .setDataLayerSource(match.getDataLayerDestination())
                .setDataLayerDestination(match.getDataLayerSource())
                .setNetworkSource(match.getNetworkDestination())
                .setNetworkDestination(match.getNetworkSource())
                .setTransportSource(match.getTransportDestination())
                .setTransportDestination(match.getTransportSource()),
                match.getInputPort());
        return Command.CONTINUE;
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

     * @param name The name of this static flow entry
     * @return A Map representation of the storage entry
     */
    public static Map<String, Object> flowModToStorageEntry(OFFlowMod fm, String sw, String name) {
        Map<String, Object> entry = new HashMap<String, Object>();
        OFMatch match = fm.getMatch();
        entry.put(StaticFlowEntryPusher.COLUMN_NAME, name);
        entry.put(StaticFlowEntryPusher.COLUMN_SWITCH, sw);
        entry.put(StaticFlowEntryPusher.COLUMN_ACTIVE, Boolean.toString(true));
        entry.put(StaticFlowEntryPusher.COLUMN_PRIORITY, Short.toString(fm.getPriority()));
        entry.put(StaticFlowEntryPusher.COLUMN_WILDCARD, Integer.toString(match.getWildcards()));
       
        if ((fm.getActions() != null) && (fm.getActions().size() > 0))
          entry.put(StaticFlowEntryPusher.COLUMN_ACTIONS, StaticFlowEntries.flowModActionsToString(fm.getActions()));
       
        if (match.getInputPort() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_IN_PORT, Short.toString(match.getInputPort()));
       
        if (!Arrays.equals(match.getDataLayerSource(), zeroMac))
          entry.put(StaticFlowEntryPusher.COLUMN_DL_SRC, HexString.toHexString(match.getDataLayerSource()));

        if (!Arrays.equals(match.getDataLayerDestination(), zeroMac))
          entry.put(StaticFlowEntryPusher.COLUMN_DL_DST, HexString.toHexString(match.getDataLayerDestination()));
       
        if (match.getDataLayerVirtualLan() != -1)
          entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN, Short.toString(match.getDataLayerVirtualLan()));
       
        if (match.getDataLayerVirtualLanPriorityCodePoint() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_DL_VLAN_PCP, Short.toString(match.getDataLayerVirtualLanPriorityCodePoint()));
       
        if (match.getDataLayerType() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_DL_TYPE, Short.toString(match.getDataLayerType()));
       
        if (match.getNetworkTypeOfService() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_NW_TOS, Short.toString(match.getNetworkTypeOfService()));
       
        if (match.getNetworkProtocol() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_NW_PROTO, Short.toString(match.getNetworkProtocol()));
       
        if (match.getNetworkSource() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_NW_SRC, IPv4.fromIPv4Address(match.getNetworkSource()));
       
        if (match.getNetworkDestination() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_NW_DST, IPv4.fromIPv4Address(match.getNetworkDestination()));
       
        if (match.getTransportSource() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_TP_SRC, Short.toString(match.getTransportSource()));
       
        if (match.getTransportDestination() != 0)
          entry.put(StaticFlowEntryPusher.COLUMN_TP_DST, Short.toString(match.getTransportDestination()));
       
        return entry;
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

public class StaticPusher {

  public static String insertFlow(HashMap<String, String> cliArguments,
      IBeaconProvider ibeaconProvider) {

    OFMatch ofMatch = new OFMatch();
    int wildCard = OFMatch.OFPFW_ALL;

    for (String argKey : cliArguments.keySet()) {

      if (argKey.equals("in_port")) {

        ofMatch.setInputPort(Short.parseShort(cliArguments.get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_IN_PORT;

      } else if (argKey.equals("dl_src")) {
        ofMatch.setDataLayerSource(cliArguments.get(argKey));
        wildCard = wildCard ^ OFMatch.OFPFW_DL_SRC;
      } else if (argKey.equals("dl_dst")) {
        ofMatch.setDataLayerDestination(cliArguments.get(argKey));
        wildCard = wildCard ^ OFMatch.OFPFW_DL_DST;
      } else if (argKey.equals("dl_vlan")) {
        ofMatch.setDataLayerVirtualLan(Short.parseShort(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_DL_VLAN;
      } else if (argKey.equals("dl_vlan_pcp")) {
        ofMatch.setDataLayerVirtualLanPriorityCodePoint(Byte
            .parseByte(cliArguments.get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_DL_VLAN_PCP;
      } else if (argKey.equals("dl_type")) {
        ofMatch.setDataLayerType(Short.parseShort(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_DL_TYPE;
      } else if (argKey.equals("nw_tos")) {
        ofMatch.setNetworkTypeOfService(Byte.parseByte(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_NW_TOS;
      } else if (argKey.equals("nw_proto")) {
        ofMatch.setNetworkProtocol(Byte.parseByte(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_NW_PROTO;
       
      } else if (argKey.equals("nw_src")) {
        IPv4Address ipv4Address = new IPv4Address(
            cliArguments.get(argKey));
        ofMatch.setNetworkSource(ipv4Address.getIPv4AddressInt());
        wildCard = wildCard ^ OFMatch.OFPFW_NW_SRC_ALL ^
        ((31 << OFMatch.OFPFW_NW_SRC_SHIFT));
       
      } else if (argKey.equals("nw_dst")) {
        IPv4Address ipv4Address = new IPv4Address(
            cliArguments.get(argKey));
        ofMatch.setNetworkDestination(ipv4Address.getIPv4AddressInt());
        wildCard = wildCard ^ OFMatch.OFPFW_NW_DST_ALL ^
        ((31 << OFMatch.OFPFW_NW_DST_SHIFT));
      } else if (argKey.equals("tp_src")) {
        ofMatch.setTransportSource(Short.parseShort(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_TP_SRC;

      } else if (argKey.equals("tp_dst")) {
        ofMatch.setTransportDestination(Short.parseShort(cliArguments
            .get(argKey)));
        wildCard = wildCard ^ OFMatch.OFPFW_TP_DST;

      }
    }
      ofMatch.setWildcards(wildCard);
      OFFlowMod oFFlowMod = new OFFlowMod();
      oFFlowMod.setType(OFType.FLOW_MOD);
      oFFlowMod.setMatch(ofMatch);
      oFFlowMod.setCommand(OFFlowMod.OFPFC_ADD);
      oFFlowMod.setBufferId(-1);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

      ExecutionException, TimeoutException {
    IOFSwitch iofSwitch = this.openFlowSwitch;
    Future<List<OFStatistics>> future;
    OFStatisticsRequest req = new OFStatisticsRequest();
    OFFlowStatisticsRequest fsr = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(0xffffffff);
    fsr.setMatch(match);
    fsr.setOutPort(OFPort.OFPP_NONE.getValue());
    fsr.setTableId((byte) 0xff);
    req.setStatisticType(OFStatisticsType.FLOW);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
View Full Code Here

Examples of org.openflow.protocol.OFMatch

    if(iofSwitch == null){
      throw new NoSwitchException(HexString.toHexString(this.datapathId));
    }
    OFStatisticsRequest req = new OFStatisticsRequest();
    OFFlowStatisticsRequest fsr = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(0xffffffff);
    fsr.setMatch(match);
    fsr.setOutPort(OFPort.OFPP_NONE.getValue());
    fsr.setTableId((byte) 0xff);
    req.setStatisticType(OFStatisticsType.FLOW);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
View Full Code Here

Examples of org.openflow.protocol.OFMatch

          rulePriority = this.priority;
         
        }
       
        OFRule ofRuleSource = new OFRule();
        OFMatch ofMatchSource = new OFMatch();
        ofMatchSource.setDataLayerType((short) 0x0800);

        ofMatchSource.setNetworkSource(ipAddress.getIpAddressValue());

        short maskingBits = (short) (ipAddress.getSubnet() - 1);
        int wildCardSource = OFMatch.OFPFW_ALL ^ OFMatch.OFPFW_DL_TYPE
            ^ OFMatch.OFPFW_NW_SRC_ALL
            ^ (maskingBits << OFMatch.OFPFW_NW_SRC_SHIFT);

        ofMatchSource.setWildcards(wildCardSource);

        ofRuleSource.setMatch(ofMatchSource);
        ofRuleSource.setPriority(rulePriority);

        ofRuleSource.setPort(actionPort);

        FlowscaleController.logger.debug(
            "ip address match is {} and masking bit is {} ",
            ipAddress.getIpAddressValue(), ipAddress.getSubnet());

        FlowscaleController.logger.debug(
            "match is {} and wildcard is {}",
            ofMatchSource.toString(), wildCardSource);

        this.groupRules.add(ofRuleSource);

        // end set source rule

        // set destination rule:
        OFRule ofRuleDestination = new OFRule();
        OFMatch ofMatchDestination = new OFMatch();

        ofMatchDestination.setDataLayerType((short) 0x0800);
        ofMatchDestination.setNetworkDestination(ipAddress
            .getIpAddressValue());

        int wildCardDestination = OFMatch.OFPFW_ALL
            ^ OFMatch.OFPFW_DL_TYPE ^ OFMatch.OFPFW_NW_DST_ALL
            ^ (maskingBits << OFMatch.OFPFW_NW_DST_SHIFT);

        ofMatchDestination.setWildcards(wildCardDestination);

        ofRuleDestination.setMatch(ofMatchDestination);
        ofRuleDestination.setPriority(rulePriority);
        ofRuleDestination.setPort(actionPort);

        FlowscaleController.logger.debug(
            "ip address match is {} and masking bit is {} ",
            ipAddress.getIpAddressValue(), ipAddress.getSubnet());

        FlowscaleController.logger.debug(
            "match is {} and wildcard is {}",
            ofMatchDestination.toString(), wildCardDestination);

        this.groupRules.add(ofRuleDestination);

        // end set destination rules
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.