Examples of OFMatch


Examples of org.openflow.protocol.OFMatch

      i++;

      OFRule rule = new OFRule();

      rule.setPort(actionPort);
      OFMatch match = new OFMatch();
      match.setDataLayerType(ETHERTYPE_IP);
      match.setNetworkProtocol(protocol);
      rule.setPriority(this.priority);

      if (direction == 0) {
        match.setTransportSource((short) portMatch);
        match.setWildcards(OFMatch.OFPFW_ALL ^ OFMatch.OFPFW_DL_TYPE
            ^ OFMatch.OFPFW_NW_PROTO ^ OFMatch.OFPFW_TP_SRC);
      } else if (direction == 1) {
        match.setTransportDestination((short) portMatch);
        match.setWildcards(OFMatch.OFPFW_ALL ^ OFMatch.OFPFW_DL_TYPE
            ^ OFMatch.OFPFW_NW_PROTO ^ OFMatch.OFPFW_TP_DST);
      }

      rule.setMatch(match);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

      i++;

      OFRule rule = new OFRule();
      rule.setPriority(this.priority);
      rule.setPort(actionPort);
      OFMatch match = new OFMatch();
      match.setDataLayerType((short) etherTypeMatch);
      rule.setWildcards(OFMatch.OFPFW_ALL ^ OFMatch.OFPFW_DL_TYPE);
      match.setWildcards((short) rule.getWildcards());
      rule.setMatch(match);

      groupRules.add(rule);

    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

    try {

      // 1) delete all flows

      OFFlowMod ofDeleteAll = new OFFlowMod();
      OFMatch ofMatchAll = new OFMatch();
      ofMatchAll.setWildcards(OFMatch.OFPFW_ALL);
      ofDeleteAll.setMatch(ofMatchAll);
      ofDeleteAll.setCommand(OFFlowMod.OFPFC_DELETE);

      // 2) inset default drop rule to avoid sending any packet to the
      // controller
      OFFlowMod ofDefaultDropRule = new OFFlowMod();

      ofDefaultDropRule.setPriority((short) defaultRulePriority);
      ofDefaultDropRule.setMatch(ofMatchAll);
      ofDefaultDropRule.setIdleTimeout((short) 0);
      ofDefaultDropRule.setHardTimeout((short) 0);
      ArrayList<OFAction> emptyActions = new ArrayList<OFAction>();

      ofDefaultDropRule.setActions(emptyActions);
      ArrayList<OFFlowMod> mirroringOFFlowMods = new ArrayList<OFFlowMod>();
      // 3) insert mirroring rules for UISO flowscale
      if (mirroringRules == null) {
        logger.info("no mirroring rules configured");
      } else {
        String[] mirrorValues = mirroringRules.split(";");

        // loop over comma separated value

        OFFlowMod mirrorFlowMod;
        OFMatch mirrorMatch;
        ArrayList<OFAction> mirrorOutput;
        OFActionOutput mirrorAction;
        for (String mirrorValue : mirrorValues) {

          String[] mirrorIndex = mirrorValue.split("-");

          short inputPort = Short.parseShort(mirrorIndex[0]);

          String[] mirrorPortValues = mirrorIndex[1].split(",");

          // add the flows

          mirrorFlowMod = new OFFlowMod();
          mirrorMatch = new OFMatch();
          mirrorMatch.setWildcards(OFMatch.OFPFW_ALL
              ^ OFMatch.OFPFW_IN_PORT);
          mirrorMatch.setInputPort(inputPort);
          mirrorFlowMod.setMatch(mirrorMatch);

          mirrorFlowMod.setIdleTimeout((short) 0);
          mirrorFlowMod.setHardTimeout((short) 0);
          mirrorFlowMod.setPriority(mirrorPriority);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

      HashMap<Short, Short> mirroredPorts, ArrayList<OFFlowMod> flowMods) {
    for (Short increasedPort : newFlows.keySet()) {

      for (LoadFlow changedFlow : newFlows.get(increasedPort)) {

        OFMatch ofMatch = null;

        Pattern pattern = Pattern
            .compile("nw_src=([0-9]+.[0-9]+.[0-9]+.[0-9]+)/([0-9]*)");

        Matcher matcher = pattern.matcher(changedFlow.getFlowString());

        while (matcher.find()) {
          String fullValue = matcher.group()
              .replaceAll("nw_src=", "");

          String[] ipAndSubnet = fullValue.split("/");

          try {
            logger.debug("ip address is {} and subnet is {}",

            matcher.group(1), matcher.group(2));

          } catch (IndexOutOfBoundsException ioe) {
            break;
          }
          IPv4Address ipv4Address = new IPv4Address(ipAndSubnet[0]);
          ipv4Address.setSubnet(Integer.parseInt(ipAndSubnet[1]));
          int ipAddressInt = ipv4Address.getIPv4AddressInt();

          IPAddress ipAddress = new IPAddress();
          ipAddress.setIpAddressValue(ipAddressInt);
          ipAddress.setSubnet(Integer.parseInt(ipAndSubnet[1]));

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

          OFMatch ofMatchSource = new OFMatch();
          ofMatchSource.setDataLayerType((short) 0x0800);

          ofMatchSource.setNetworkSource(ipAddress
              .getIpAddressValue());

          ofMatchSource.setWildcards(wildCardSource);
          ofMatch = ofMatchSource;
          OFFlowMod flowModRule = new OFFlowMod();
          flowModRule.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
          flowModRule.setPriority(changedFlow.getPriority());
          flowModRule.setHardTimeout((short) 0);
          flowModRule.setIdleTimeout((short) 0);
         
          flowModRule.setBufferId(-1);
          flowModRule.setMatch(ofMatch);
     

         
          OFActionOutput ofAction = new OFActionOutput();
          ofAction.setPort(increasedPort);
          ArrayList<OFAction> actions = new ArrayList<OFAction>();
          actions.add(ofAction);
          if (mirroredPorts.get(increasedPort) != null) {
            OFActionOutput ofActionMirror = new OFActionOutput();
            ofActionMirror
                .setPort(mirroredPorts.get(increasedPort));
            actions.add(ofActionMirror);
          }

          flowModRule.setActions(actions);

 

          flowMods.add(flowModRule);

          OFMatch ofMatchDest = new OFMatch();
          ofMatchDest.setDataLayerType((short) 0x0800);
          ofMatchDest.setNetworkDestination(ipAddress
              .getIpAddressValue());

          int wildCardDest = OFMatch.OFPFW_ALL
              ^ OFMatch.OFPFW_DL_TYPE
              ^ OFMatch.OFPFW_NW_DST_ALL
              ^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_DST_SHIFT);

          ofMatchDest.setWildcards(wildCardDest);

          OFFlowMod flowModRule1 = new OFFlowMod();
          flowModRule1.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
          flowModRule1.setPriority(changedFlow.getPriority());
          flowModRule1.setHardTimeout((short) 0);
          flowModRule1.setIdleTimeout((short) 0);
          flowModRule1.setBufferId(-1);
          flowModRule1.setMatch(ofMatchDest);

          flowModRule1.setActions(actions);

       

          flowMods.add(flowModRule1);

        }

        pattern = Pattern
            .compile("nw_dst=([0-9]+.[0-9]+.[0-9]+.[0-9]+)/([0-9]*)");

        matcher = pattern.matcher(changedFlow.getFlowString());

        while (matcher.find()) {

          try {
            logger.debug("ip address is {} and subnet is {}",

            matcher.group(1), matcher.group(2));

          } catch (IndexOutOfBoundsException ioe) {
            break;
          }
          IPv4Address ipv4Address = new IPv4Address(matcher.group(1));
          ipv4Address.setSubnet(Integer.parseInt(matcher.group(2)));
          int ipAddressInt = ipv4Address.getIPv4AddressInt();

          IPAddress ipAddress = new IPAddress();
          ipAddress.setIpAddressValue(ipAddressInt);
          ipAddress.setSubnet(Integer.parseInt(matcher.group(2)));

          short maskingBits = (short) (ipAddress.getSubnet());
          int wildCardDestination = OFMatch.OFPFW_ALL
              ^ OFMatch.OFPFW_DL_TYPE
              ^ OFMatch.OFPFW_NW_DST_ALL
              ^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_DST_SHIFT);

          OFMatch ofMatchDestination = new OFMatch();
          ofMatchDestination.setDataLayerType((short) 0x0800);

          ofMatchDestination.setNetworkDestination(ipAddress
              .getIpAddressValue());

          ofMatchDestination.setWildcards(wildCardDestination);
          ofMatch = ofMatchDestination;
          OFFlowMod flowModRule = new OFFlowMod();
          flowModRule.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
          flowModRule.setHardTimeout((short) 0);
          flowModRule.setIdleTimeout((short) 0);
          flowModRule.setBufferId(-1);
          flowModRule.setMatch(ofMatch);
          flowModRule.setPriority(changedFlow.getPriority());
         
          OFActionOutput ofAction = new OFActionOutput();
          ofAction.setPort(increasedPort);
          ArrayList<OFAction> actions = new ArrayList<OFAction>();
          actions.add(ofAction);
          if (mirroredPorts.get(increasedPort) != null) {
            OFActionOutput ofActionMirror = new OFActionOutput();
            ofActionMirror
                .setPort(mirroredPorts.get(increasedPort));
            actions.add(ofActionMirror);
          }
          flowModRule.setActions(actions);

       

          flowMods.add(flowModRule);

          OFMatch ofMatchSrc = new OFMatch();
          ofMatchSrc.setDataLayerType((short) 0x0800);
          ofMatchSrc.setNetworkSource(ipAddress.getIpAddressValue());

          int wildCardSrc = OFMatch.OFPFW_ALL
              ^ OFMatch.OFPFW_DL_TYPE
              ^ OFMatch.OFPFW_NW_SRC_ALL
              ^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_SRC_SHIFT);

          ofMatchSrc.setWildcards(wildCardSrc);

          OFFlowMod flowModRule1 = new OFFlowMod();
          flowModRule1.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
          flowModRule1.setPriority(changedFlow.getPriority());
          flowModRule1.setHardTimeout((short) 0);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

    }

    @Override
    public void readFrom(ByteBuffer data) {
        if (this.match == null)
            this.match = new OFMatch();
        this.match.readFrom(data);
        this.tableId = data.get();
        data.get(); // pad
        this.outPort = data.getShort();
    }
View Full Code Here

Examples of org.openflow.protocol.OFMatch

    public void readFrom(ByteBuffer data) {
        this.length = data.getShort();
        this.tableId = data.get();
        data.get(); // pad
        if (this.match == null)
            this.match = new OFMatch();
        this.match.readFrom(data);
        this.durationSeconds = data.getInt();
        this.durationNanoseconds = data.getInt();
        this.priority = data.getShort();
        this.idleTimeout = data.getShort();
View Full Code Here

Examples of org.openflow.protocol.OFMatch

            this.stream = stream;
        }

        public void handlePacketIn(OFPacketIn pi) {
            // Build the Match
            OFMatch match = new OFMatch();
            match.loadFromPacket(pi.getPacketData(), pi.getInPort());
            byte[] dlDst = match.getDataLayerDestination();
            Integer dlDstKey = Arrays.hashCode(dlDst);
            byte[] dlSrc = match.getDataLayerSource();
            Integer dlSrcKey = Arrays.hashCode(dlSrc);
            int bufferId = pi.getBufferId();

            // if the src is not multicast, learn it
            if ((dlSrc[0] & 0x1) == 0) {
                if (!macTable.containsKey(dlSrcKey) ||
                        !macTable.get(dlSrcKey).equals(pi.getInPort())) {
                    macTable.put(dlSrcKey, pi.getInPort());
                }
            }

            Short outPort = null;
            // if the destination is not multicast, look it up
            if ((dlDst[0] & 0x1) == 0) {
                outPort = macTable.get(dlDstKey);
            }

            // push a flow mod if we know where the packet should be going
            if (outPort != null) {
                OFFlowMod fm = (OFFlowMod) factory.getMessage(OFType.FLOW_MOD);
                fm.setBufferId(bufferId);
                fm.setCommand((short) 0);
                fm.setCookie(0);
                fm.setFlags((short) 0);
                fm.setHardTimeout((short) 0);
                fm.setIdleTimeout((short) 5);
                match.setInputPort(pi.getInPort());
                match.setWildcards(0);
                fm.setMatch(match);
                fm.setOutPort((short) OFPort.OFPP_NONE.getValue());
                fm.setPriority((short) 0);
                OFActionOutput action = new OFActionOutput();
                action.setMaxLength((short) 0);
View Full Code Here

Examples of org.openflow.protocol.OFMatch

    }

    @Override
    public void readFrom(ByteBuffer data) {
        if (this.match == null)
            this.match = new OFMatch();
        this.match.readFrom(data);
        this.tableId = data.get();
        data.get(); // pad
        this.outPort = data.getShort();
    }
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.