Examples of OFActionOutput


Examples of org.openflow.protocol.action.OFActionOutput

        packetOutMessage.setActionsLength((short)OFActionOutput.MINIMUM_LENGTH);
        packetOutLength += OFActionOutput.MINIMUM_LENGTH;

        // set actions
        List<OFAction> actions = new ArrayList<OFAction>(1);
        actions.add(new OFActionOutput(egressPort, (short) 0));
        packetOutMessage.setActions(actions);

        // set data - only if buffer_id == -1
        if (packetInMessage.getBufferId() == OFPacketOut.BUFFER_ID_NONE) {
            byte[] packetData = packetInMessage.getPacketData();
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

        SubActionStruct sa = null;
        Matcher n;
       
        n = Pattern.compile("output=(?:((?:0x)?\\d+)|(all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(subaction);
        if (n.matches()) {
            OFActionOutput action = new OFActionOutput();
            action.setMaxLength(Short.MAX_VALUE);
            short port = OFPort.OFPP_NONE.getValue();
            if (n.group(1) != null) {
                try {
                    port = get_short(n.group(1));
                }
                catch (NumberFormatException e) {
                    log.debug("Invalid port in: '{}' (error ignored)", subaction);
                    return null;
                }
            }
            else if (n.group(2) != null)
                port = OFPort.OFPP_ALL.getValue();
            else if (n.group(3) != null)
                port = OFPort.OFPP_CONTROLLER.getValue();
            else if (n.group(4) != null)
                port = OFPort.OFPP_LOCAL.getValue();
            else if (n.group(5) != null)
                port = OFPort.OFPP_IN_PORT.getValue();
            else if (n.group(6) != null)
                port = OFPort.OFPP_NORMAL.getValue();
            else if (n.group(7) != null)
                port = OFPort.OFPP_FLOOD.getValue();
            action.setPort(port);
            log.debug("action {}", action);
           
            sa = new SubActionStruct();
            sa.action = action;
            sa.len = OFActionOutput.MINIMUM_LENGTH;
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

             (OFPacketOut) getMockFloodlightProvider().getOFMessageFactory().
                 getMessage(OFType.PACKET_OUT);
     arpReplyPacketOut1.setBufferId(OFPacketOut.BUFFER_ID_NONE)
         .setInPort(OFPort.OFPP_NONE.getValue());
     List<OFAction> poactions = new ArrayList<OFAction>();
     poactions.add(new OFActionOutput(arpRequestPacketIn1.getInPort(), (short) 0xffff));
     arpReplyPacketOut1.setActions(poactions)
         .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
         .setPacketData(arpReply1Serialized)
         .setLengthU(OFPacketOut.MINIMUM_LENGTH+
                     arpReplyPacketOut1.getActionsLength()+
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

        OFPacketOut packetOut =
                (OFPacketOut) mockFloodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT);
        packetOut.setBufferId(pi.getBufferId())
        .setInPort(pi.getInPort());
        List<OFAction> poactions = new ArrayList<OFAction>();
        poactions.add(new OFActionOutput(OFPort.OFPP_TABLE.getValue(), (short) 0));
        packetOut.setActions(poactions)
        .setActionsLength((short) OFActionOutput.MINIMUM_LENGTH)
        .setPacketData(testPacketSerialized)
        .setLengthU(OFPacketOut.MINIMUM_LENGTH+packetOut.getActionsLength()+testPacketSerialized.length);
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

     
      ArrayList<OFAction> flowActions = new ArrayList<OFAction>();
     
      if(cliArguments.get("actions") != null){
      Short  actions = Short.parseShort(cliArguments.get("actions"));
      OFActionOutput actionOutput = new OFActionOutput();
      actionOutput.setPort(actions);
     
     
      flowActions.add(actionOutput);
      oFFlowMod.setActions(flowActions);
      }
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

     * To facilitating mirroring, this method adds the specified mirroring port to the rule
     * (see documentation on how mirroring works)
     * @param port
     */
    public void setMirrorPort(int port){
      OFActionOutput mirrorAction = new OFActionOutput();
      mirrorAction.setPort((short)port);
      actions.add(mirrorAction);
    }
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

        if (port == -1){
            actions = null;
            return;
        }
       
        OFActionOutput action = new OFActionOutput();
       action.setPort((short)port);
       actions.add(action);
     
    }
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

                outputSwitch.getId());

        if (switchMirrors != null) {
          FlowscaleController.logger.debug("Mirror hashmap {}",
              switchMirrors.toString());
          OFActionOutput actionPort = null;
          try {
            FlowscaleController.logger.debug("Mirror actions = {}",
                rule.getActions());
            if (rule.getActions() != null) {

              actionPort = ((OFActionOutput) rule.getActions()
                  .get(0));

              FlowscaleController.logger.debug(
                  "Action port for Mirror is {}",
                  actionPort.getPort());
            }
            Short mirrorPortValue = switchMirrors.get(actionPort
                .getPort());
            if (mirrorPortValue != null) {
              FlowscaleController.logger
                  .debug("mirror {} for switch {} set ",
                      actionPort.getPort()
                          + ","
                          + mirrorPortValue
                              .toString(),
                      HexString.toHexString(outputSwitch
                          .getId()));
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

          continue;
        }

        if (i % ruleDistribution == 0) {

          OFActionOutput ofActionOutput = new OFActionOutput();
          ofActionOutput.setPort(portNum);

          String thisMatchString = ofRule.getMatch().toString();
          String otherMatchString = "";
          OFRule otherDirectionRule = null;
          if (thisMatchString.indexOf("nw_src") != -1) {
            otherMatchString = thisMatchString.replace("nw_src",
                "nw_dst");

          } else if (thisMatchString.indexOf("nw_dst") != -1) {
            otherMatchString = thisMatchString.replace("nw_dst",
                "nw_src");
          }

          if (this.type == IP_TYPE) {

            for (OFRule ofRule2 : this.groupRules) {

              if (ofRule2.getMatch().toString()
                  .equals(otherMatchString)) {
                otherDirectionRule = ofRule2;
                checkedRules.add(ofRule2);
                break;
              }

            }

          }

          ArrayList<OFAction> actionList = ofRule.getActions();
          actionList.clear();
          HashMap<Short, Short> switchMirrors = flowscaleController
              .getSwitchFlowMirrorPortsHashMap().get(sw.getId());
          actionList.add(ofActionOutput);
          if (switchMirrors != null) {
            Short mirrorPort = switchMirrors.get(portNum);
            if (mirrorPort != null) {
              OFActionOutput mirrorAction = new OFActionOutput();
              mirrorAction.setPort(mirrorPort);
              actionList.add(mirrorAction);

            }

          }

          updateFlow.setMatch(ofRule.getMatch());
          updateFlow.setBufferId(-1);
          updateFlow.setPriority(ofRule.getPriority());

          updateFlow.setActions(actionList);
          updateFlow.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH
              + OFActionOutput.MINIMUM_LENGTH));

          if (this.type == IP_TYPE) {

            updateFlow2 = new OFFlowMod();

            updateFlow2.setType(OFType.FLOW_MOD);
            updateFlow2.setCommand(OFFlowMod.OFPFC_ADD);
            updateFlow2.setHardTimeout((short) 0);
            updateFlow2.setIdleTimeout((short) 0);

            ArrayList<OFAction> actionList2 = otherDirectionRule
                .getActions();
            actionList2.clear();
            HashMap<Short, Short> switchMirrors2 = flowscaleController
                .getSwitchFlowMirrorPortsHashMap().get(
                    sw.getId());
            actionList2.add(ofActionOutput);
            if (switchMirrors2 != null) {
              Short mirrorPort = switchMirrors2.get(portNum);
              if (mirrorPort != null) {
                OFActionOutput mirrorAction = new OFActionOutput();
                mirrorAction.setPort(mirrorPort);
                actionList2.add(mirrorAction);

              }

            }

            updateFlow2.setMatch(otherDirectionRule.getMatch());
            updateFlow2.setBufferId(-1);
            updateFlow2.setPriority(otherDirectionRule
                .getPriority());

            updateFlow2.setActions(actionList2);
            updateFlow2.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH
                + OFActionOutput.MINIMUM_LENGTH));
          }

          try {
            FlowscaleController.logger.trace("modifying flow   {}",
                updateFlow);

            sw.getOutputStream().write(updateFlow);
            if (this.type == IP_TYPE) {
              sw.getOutputStream().write(updateFlow2);
            }

          } catch (IOException e) {
            // TODO Auto-generated catch block
            FlowscaleController.logger.error("{}", e);
          }

        }

        i++;
      }
      FlowscaleController.logger.info("Modification of flows completed");

      break;
    case 1:

      i = 0;
      FlowscaleController.logger.trace("outputPortUp before removal {}",
          outputPortsUp);

      outputPortsUp.remove(new Short(physicalPort.getPortNumber()));
      FlowscaleController.logger.trace("outputPortsUp after removal {}",
          outputPortsUp);

      FlowscaleController.logger
          .info("port {} for switch {} is down so flows for this will be updated",
              physicalPort.getPortNumber(),
              HexString.toHexString(sw.getId()));
      int count = 0;

      ArrayList<OFRule> checkedRulesonPortDown = new ArrayList<OFRule>();

      for (OFRule ofRule : this.groupRules) {

        if (checkedRulesonPortDown.contains(ofRule)) {
          continue;
        }

        OFActionOutput ofActionOutput = (OFActionOutput) ofRule
            .getActions().get(0);

        FlowscaleController.logger.trace(
            "match here is {} and port is {}", ofRule.getMatch(),
            ofActionOutput.getPort());

        if (ofActionOutput.getPort() == portNum) {
          short newPort = 0;
          try {
            newPort = this.outputPortsUp.get(i++
                % outputPortsUp.size());
            ofActionOutput.setPort(newPort);

          } catch (ArithmeticException aeException) {
            FlowscaleController.logger
                .info("No group ports are up , ...no flows redirected");
            continue;
          }
          ArrayList<OFAction> actionList = ofRule.getActions();
          actionList.clear();
          // add mirror ports if there are any

          HashMap<Short, Short> switchMirrors = flowscaleController
              .getSwitchFlowMirrorPortsHashMap().get(sw.getId());
          actionList.add(ofActionOutput);
          if (switchMirrors != null) {
            Short mirrorPort = switchMirrors.get(newPort);
            if (mirrorPort != null) {
              OFActionOutput mirrorAction = new OFActionOutput();
              mirrorAction.setPort(mirrorPort);
              actionList.add(mirrorAction);

            }

          }
          String thisMatchString = ofRule.getMatch().toString();
          String otherMatchString = "";
          OFRule otherDirectionRule = null;
          if (thisMatchString.indexOf("nw_src") != -1) {
            otherMatchString = thisMatchString.replace("nw_src",
                "nw_dst");

          } else if (thisMatchString.indexOf("nw_dst") != -1) {
            otherMatchString = thisMatchString.replace("nw_dst",
                "nw_src");
          }
          if (this.type == IP_TYPE) {

            for (OFRule ofRule2 : this.groupRules) {

              if (ofRule2.getMatch().toString()
                  .equals(otherMatchString)) {
                otherDirectionRule = ofRule2;
                checkedRulesonPortDown.add(ofRule2);
                break;

              }

            }

          }

          updateFlow.setMatch(ofRule.getMatch());
          updateFlow.setBufferId(-1);
       
          updateFlow.setPriority(ofRule.getPriority());

          updateFlow.setActions(actionList);

          if (this.type == IP_TYPE) {

            updateFlow2 = new OFFlowMod();
            updateFlow2.setType(OFType.FLOW_MOD);
            updateFlow2.setCommand(OFFlowMod.OFPFC_ADD);
            updateFlow2.setHardTimeout((short) 0);
            updateFlow2.setIdleTimeout((short) 0);

            ArrayList<OFAction> actionList2 = otherDirectionRule
                .getActions();
            actionList2.clear();
            HashMap<Short, Short> switchMirrors2 = flowscaleController
                .getSwitchFlowMirrorPortsHashMap().get(
                    sw.getId());
            actionList2.add(ofActionOutput);
            if (switchMirrors2 != null) {
              Short mirrorPort = switchMirrors2.get(portNum);
              if (mirrorPort != null) {
                OFActionOutput mirrorAction = new OFActionOutput();
                mirrorAction.setPort(mirrorPort);
                actionList2.add(mirrorAction);

              }

            }
View Full Code Here

Examples of org.openflow.protocol.action.OFActionOutput

        // 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);

          mirrorOutput = new ArrayList<OFAction>();

          for (String mirrorPortValue : mirrorPortValues) {

            mirrorAction = new OFActionOutput();
            mirrorAction.setPort(Short.parseShort(mirrorPortValue));

            mirrorOutput.add(mirrorAction);

          }
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.