Package net.beaconcontroller.core

Examples of net.beaconcontroller.core.IOFSwitch


  }

  private void deleteAllRules() {
    // algorithm to nuke all rules from all switches
    IOFSwitch sw = flowscaleController.ibeaconProvider.getSwitches().get(
        this.outputSwitchDatapathId);
    OFFlowMod flowToDelete = new OFFlowMod();
    flowToDelete.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
    flowToDelete.setOutPort(OFPort.OFPP_NONE);
    for (OFRule ofRule : this.groupRules) {

      flowToDelete.setMatch(ofRule.getMatch());
      flowToDelete.setPriority(ofRule.getPriority());
      flowToDelete.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));

      try {

        FlowscaleController.logger.debug(
            " Attempting to delete flow  {}", flowToDelete);
        sw.getOutputStream().write(flowToDelete);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        FlowscaleController.logger.error("{}", e);
      }

    }

    try {
      sw.getOutputStream().flush();
    } catch (IOException ioe) {
      FlowscaleController.logger.error("{}", ioe);
    }

  }
View Full Code Here


    long datapathId = HexString.toLong(datapathIdString);

    SwitchDevice switchDevice = new SwitchDevice(datapathId);

    IOFSwitch ofSwitch = ibeaconProvider.getSwitches().get(datapathId);

    if (ofSwitch != null) {

      switchDevice.setOpenFlowSwitch(ofSwitch);

      switchDevice.setPhysicalPorts(ofSwitch.getFeaturesReply()
          .getPorts());

    }

    controllerSwitches.put(datapathId, switchDevice);
View Full Code Here

   * @param datapathId
   *            id of concerned switch that we desire to hotswap flows
   */
  public void injectFlows(ArrayList<OFFlowMod> ofFlowMods, long datapathId) {
    logger.info("injecting flows in controller");
    IOFSwitch sw = this.ibeaconProvider.getSwitches().get(datapathId);
    if (sw == null) {
      logger.error("no switch {} exists", datapathId);
      return;
    }
    for (OFFlowMod ofFlowMod : ofFlowMods) {
      logger.info("injecting flow {}", ofFlowMod);
      for (Integer groupKey : groupList.keySet()) {

        Group group = groupList.get(groupKey);

        ArrayList<OFRule> groupRules = (ArrayList<OFRule>) group
            .getGroupRules();

        for (OFRule rule : groupRules) {

          if (rule.getMatch().equals(ofFlowMod.getMatch())
              && group.getOutputSwitchDatapathId() == datapathId) {
            logger.info("rule equal", rule.getMatch().toString(),
                ofFlowMod.getMatch().toString());
           
            ofFlowMod.setPriority(rule.getPriority());
           
            ArrayList<OFAction> aList = rule.getActions();

            aList.clear();

            short port = ((OFActionOutput) ofFlowMod.getActions()
                .get(0)).getPort();
            rule.setPort(port);

            Short mirrorPort = 0;
            if (switchFlowMirrorPortsHashMap.get(datapathId) != null) {
              mirrorPort = switchFlowMirrorPortsHashMap.get(
                  datapathId).get(port);
            }
            if (mirrorPort != null) {
              rule.setMirrorPort(mirrorPort);
            }
            logger.info("new rule is {} and port is {}",
                rule.getMatch(), rule.getActions().get(0));

          }

        }

      }

      try {
        sw.getOutputStream().write(ofFlowMod);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        logger.error("{}", e);
      }

    }

    try {
      sw.getOutputStream().flush();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      logger.error("{}", e);
    }

View Full Code Here

TOP

Related Classes of net.beaconcontroller.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.