Package model.tools.flowmanager

Examples of model.tools.flowmanager.Match


  // This parses JSON from the restAPI to get all the match of a flow for the controller overview
  public static Match getMatch(JSONObject obj)
      throws JSONException, IOException {
   
    Match match = new Match();
   
    // Here we check the values, if they are default we set them empty strings.
    // This way they don't confuse the user into thinking they set something
    // they didn't
    if (!obj.getString("dataLayerDestination").equals("00:00:00:00:00:00"))
      match.setDataLayerDestination(obj.getString("dataLayerDestination"));
    if (!obj.getString("dataLayerSource").equals("00:00:00:00:00:00"))
      match.setDataLayerSource(obj.getString("dataLayerSource"));
    if (!obj.getString("dataLayerType").equals("0x0000"))
      match.setDataLayerType(obj.getString("dataLayerType"));
    if (obj.getInt("dataLayerVirtualLan") > 0)
      match.setDataLayerVLAN(String.valueOf(obj
          .getInt("dataLayerVirtualLan")));
    if (obj.getInt("dataLayerVirtualLanPriorityCodePoint") != 0)
      match.setDataLayerPCP(String.valueOf(obj
          .getInt("dataLayerVirtualLanPriorityCodePoint")));
    if (obj.getInt("inputPort") != 0)
      match.setInputPort(String.valueOf(obj.getInt("inputPort")));
    if (!obj.getString("networkDestination").equals("0.0.0.0"))
      match.setNetworkDestination(obj.getString("networkDestination"));
    // match.setNetworkDestinationMaskLength(String.valueOf(obj.getInt("networkDestinationMaskLen")));
    if (obj.getInt("networkProtocol") != 0)
      match.setNetworkProtocol(String.valueOf(obj
          .getInt("networkProtocol")));
    if (!obj.getString("networkSource").equals("0.0.0.0"))
      match.setNetworkSource(obj.getString("networkSource"));
    // match.setNetworkSourceMaskLength(String.valueOf(obj.getInt("networkSourceMaskLen")));
    if (obj.getInt("networkTypeOfService") != 0)
      match.setNetworkTypeOfService(String.valueOf(obj
          .getInt("networkTypeOfService")));
    if (obj.getInt("transportDestination") != 0)
      match.setTransportDestination(String.valueOf(obj
          .getInt("transportDestination")));
    if (obj.getInt("transportSource") != 0)
      match.setTransportSource(String.valueOf(obj
          .getInt("transportSource")));
    if(obj.getLong("wildcards") != 4194302)
      match.setWildcards(String.valueOf(obj.getLong("wildcards")));

    return match;
  }
View Full Code Here


public class MatchManagerPusher {

  public static Match addMatch(TableItem[] items) {

    Match match = new Match();
    if (!items[0].getText(1).isEmpty())
      match.setDataLayerDestination(items[0].getText(1));
    if (!items[1].getText(1).isEmpty())
      match.setDataLayerSource(items[1].getText(1));
    if (!items[2].getText(1).isEmpty()){
        // Check and see if they entere it as a hex value (ie. 0x800)
        if(!items[2].getText(1).contains("x"))
            match.setDataLayerType(String.valueOf(Integer.parseInt(items[2].getText(1),16)));
        else
            match.setDataLayerType(items[2].getText(1));
    }
    if (!items[3].getText(1).isEmpty())
      match.setDataLayerVLAN(items[3].getText(1));
    if (!items[4].getText(1).isEmpty())
      match.setDataLayerPCP(items[4].getText(1));
    if (!items[5].getText(1).isEmpty())
      match.setInputPort(items[5].getText(1));
    if (!items[6].getText(1).isEmpty())
      match.setNetworkDestination(items[6].getText(1));
    if (!items[7].getText(1).isEmpty())
      match.setNetworkProtocol(items[7].getText(1));
    if (!items[8].getText(1).isEmpty())
      match.setNetworkSource(items[8].getText(1));
    if (!items[9].getText(1).isEmpty())
      match.setNetworkTypeOfService(items[9].getText(1));
    if (!items[10].getText(1).isEmpty())
      match.setTransportDestination(items[10].getText(1));
    if (!items[11].getText(1).isEmpty())
      match.setTransportSource(items[11].getText(1));
    if (!items[12].getText(1).isEmpty())
      match.setWildcards(items[12].getText(1));
   
    if((match.getNetworkDestination() != null || match.getNetworkSource() != null) && match.getDataLayerType() == null)
        match.setDataLayerType("0x0800");

    return match;
  }
View Full Code Here

  private static Future<Object> future;

  // This parses JSON from the restAPI to get the match of a flow and all it's values
  public static Match getMatch(String dpid, String flowName)
      throws JSONException, IOException {
    Match match = new Match();
    // Get the match object
    future = Deserializer.readJsonObjectFromURL("http://" + IP
        + ":" + PORT + "/wm/staticflowentrypusher/list/" + dpid + "/json");
    try {
      obj = (JSONObject) future.get(5, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ExecutionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (TimeoutException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    obj = obj.getJSONObject(dpid).getJSONObject(flowName)
        .getJSONObject("match");

    // Here we check the values, if they are default we set them to emptry strings.
    // This way they don't confuse the user into thinking they set something
    // they didn't
    if (!obj.getString("dataLayerDestination").equals("00:00:00:00:00:00"))
      match.setDataLayerDestination(obj.getString("dataLayerDestination"));
    if (!obj.getString("dataLayerSource").equals("00:00:00:00:00:00"))
      match.setDataLayerSource(obj.getString("dataLayerSource"));
    if (!obj.getString("dataLayerType").equals("0x0000"))
      match.setDataLayerType(obj.getString("dataLayerType"));
    if (obj.getInt("dataLayerVirtualLan") != -1)
      match.setDataLayerVLAN(String.valueOf(obj
          .getInt("dataLayerVirtualLan")));
    if (obj.getInt("dataLayerVirtualLanPriorityCodePoint") != 0)
      match.setDataLayerPCP(String.valueOf(obj
          .getInt("dataLayerVirtualLanPriorityCodePoint")));
    if (obj.getInt("inputPort") != 0)
      match.setInputPort(String.valueOf(obj.getInt("inputPort")));
    if (!obj.getString("networkDestination").equals("0.0.0.0"))
      match.setNetworkDestination(obj.getString("networkDestination"));
    // match.setNetworkDestinationMaskLength(String.valueOf(obj.getInt("networkDestinationMaskLen")));
    if (obj.getInt("networkProtocol") != 0)
      match.setNetworkProtocol(String.valueOf(obj
          .getInt("networkProtocol")));
    if (!obj.getString("networkSource").equals("0.0.0.0"))
      match.setNetworkSource(obj.getString("networkSource"));
    // match.setNetworkSourceMaskLength(String.valueOf(obj.getInt("networkSourceMaskLen")));
    if (obj.getInt("networkTypeOfService") != 0)
      match.setNetworkTypeOfService(String.valueOf(obj
          .getInt("networkTypeOfService")));
    if (obj.getInt("transportDestination") != 0)
      match.setTransportDestination(String.valueOf(obj
          .getInt("transportDestination")));
    if (obj.getInt("transportSource") != 0)
      match.setTransportSource(String.valueOf(obj
          .getInt("transportSource")));
    if(obj.getLong("wildcards") != 4194303)
      match.setWildcards(String.valueOf(obj.getLong("wildcards")));

    return match;
  }
View Full Code Here

TOP

Related Classes of model.tools.flowmanager.Match

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.