Exemple #1
0
 public void readFrom(ByteBuffer data) {
   this.queueId = data.getInt();
   this.portNumber = data.getInt();
   this.length = data.getShort();
   data.getShort(); // pad
   data.getInt(); // pad
   if (this.queuePropertyFactory == null)
     throw new RuntimeException("OFQueuePropertyFactory not set");
   this.properties =
       queuePropertyFactory.parseQueueProperties(data, U16.f(this.length) - MINIMUM_LENGTH);
 }
Exemple #2
0
  /**
   * Output a dpctl-styled string, i.e., only list the elements that are not wildcarded
   *
   * <p>A match-everything OFMatch outputs "OFMatch[]"
   *
   * @return "OFMatch[dl_src:00:20:01:11:22:33,nw_src:192.168.0.0/24,tp_dst:80]"
   */
  @Override
  public String toString() {

    String str = "";

    // l1
    if ((wildcards & OFPFW_IN_PORT) == 0) str += "," + STR_IN_PORT + "=" + U16.f(this.inputPort);

    // l2
    if ((wildcards & OFPFW_DL_DST) == 0)
      str += "," + STR_DL_DST + "=" + HexString.toHexString(this.dataLayerDestination);
    if ((wildcards & OFPFW_DL_SRC) == 0)
      str += "," + STR_DL_SRC + "=" + HexString.toHexString(this.dataLayerSource);
    if ((wildcards & OFPFW_DL_TYPE) == 0)
      str += "," + STR_DL_TYPE + "=0x" + Integer.toHexString(U16.f(this.dataLayerType));
    if ((wildcards & OFPFW_DL_VLAN) == 0)
      str += "," + STR_DL_VLAN + "=" + U16.f(this.dataLayerVirtualLan);
    if ((wildcards & OFPFW_DL_VLAN_PCP) == 0)
      str += "," + STR_DL_VLAN_PCP + "=" + U8.f(this.dataLayerVirtualLanPriorityCodePoint);

    // l3
    if (getNetworkDestinationMaskLen() > 0)
      str +=
          "," + STR_NW_DST + "=" + cidrToString(networkDestination, getNetworkDestinationMaskLen());
    if (getNetworkSourceMaskLen() > 0)
      str += "," + STR_NW_SRC + "=" + cidrToString(networkSource, getNetworkSourceMaskLen());
    if ((wildcards & OFPFW_NW_PROTO) == 0) str += "," + STR_NW_PROTO + "=" + this.networkProtocol;
    if ((wildcards & OFPFW_NW_TOS) == 0) str += "," + STR_NW_TOS + "=" + this.networkTypeOfService;

    // l4
    if ((wildcards & OFPFW_TP_DST) == 0) str += "," + STR_TP_DST + "=" + this.transportDestination;
    if ((wildcards & OFPFW_TP_SRC) == 0) str += "," + STR_TP_SRC + "=" + this.transportSource;
    if ((str.length() > 0) && (str.charAt(0) == ','))
      str = str.substring(1); // trim the leading ","
    // done
    return "OFMatch[" + str + "]";
  }
 /*
  * (non-Javadoc)
  *
  * @see org.flowvisor.api.FVUserAPI#getDeviceInfo()
  */
 @Override
 public Map<String, String> getDeviceInfo(String dpidStr) throws DPIDNotFound {
   Map<String, String> map = new HashMap<String, String>();
   long dpid = HexString.toLong(dpidStr);
   FVClassifier fvClassifier = null;
   for (FVEventHandler handler : FlowVisor.getInstance().getHandlersCopy()) {
     if (handler instanceof FVClassifier) {
       OFFeaturesReply featuresReply = ((FVClassifier) handler).getSwitchInfo();
       if (featuresReply != null && featuresReply.getDatapathId() == dpid) {
         fvClassifier = (FVClassifier) handler;
         break;
       }
     }
   }
   if (fvClassifier == null)
     throw new DPIDNotFound("dpid does not exist: " + dpidStr + " ::" + String.valueOf(dpid));
   OFFeaturesReply config = fvClassifier.getSwitchInfo();
   map.put("dpid", FlowSpaceUtil.dpidToString(dpid));
   if (config != null) {
     map.put("nPorts", String.valueOf(config.getPorts().size()));
     String portList = "";
     String portNames = "";
     int p;
     for (Iterator<OFPhysicalPort> it = config.getPorts().iterator(); it.hasNext(); ) {
       OFPhysicalPort port = it.next();
       p = U16.f(port.getPortNumber());
       portList += p;
       portNames += port.getName() + "(" + p + ")";
       if (it.hasNext()) {
         portList += ",";
         portNames += ",";
       }
     }
     map.put("portList", portList);
     map.put("portNames", portNames);
   } else {
     FVLog.log(LogLevel.WARN, null, "null config for: " + dpidStr);
   }
   map.put("remote", String.valueOf(fvClassifier.getConnectionName()));
   return map;
 }
Exemple #4
0
 /**
  * Get the length of this message, unsigned
  *
  * @return
  */
 public int getLengthU() {
   return U16.f(length);
 }