コード例 #1
0
  public String toBytesString() {
    String string =
        HexString.toHex(fieldId)
            + HexString.toHex(offset)
            + HexString.toHex(length)
            + HexString.ByteZeroEnd(2);

    if (value == null) {
      string += HexString.ByteZeroEnd(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
    } else {
      if (value.length > OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        string += HexString.toHex(value, 0, OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
        string += HexString.ZeroEnd(0);
      } else {
        // string += HexString.ZeroEnd(0);
        string += HexString.toHex(value);
        // string += HexString.ZeroEnd(0);
        string += HexString.ByteZeroEnd(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - value.length);
      }
    }

    if (mask == null) {
      string += HexString.ByteZeroEnd(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
    } else {
      if (mask.length > OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        string += HexString.toHex(mask, 0, OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
        string += HexString.ZeroEnd(0);
      } else {
        // string += HexString.ZeroEnd(0);
        string += HexString.toHex(mask);
        // string += HexString.ZeroEnd(0);
        string += HexString.ByteZeroEnd(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - mask.length);
      }
    }

    return string;
  }
コード例 #2
0
  public String toBytesString() {
    String string = super.toString();
    string +=
        HexString.toHex(command)
            + HexString.toHex(groupType)
            + HexString.toHex(actionNum)
            + HexString.ByteZeroEnd(1)
            + HexString.toHex(groupId)
            + HexString.toHex(counterId)
            + HexString.ByteZeroEnd(4);

    if (actionList == null) {
      string +=
          HexString.ByteZeroEnd(OFGlobal.OFP_MAX_ACTION_NUMBER_PER_GROUP * OFAction.MAXIMAL_LENGTH);
    } else {
      OFAction action;

      if (actionNum > actionList.size()) {
        throw new RuntimeException(
            "actionNum " + actionNum + " > actionList.size()" + actionList.size());
      }

      int i;
      for (i = 0; i < actionNum && i < OFGlobal.OFP_MAX_ACTION_NUMBER_PER_GROUP; i++) {
        action = actionList.get(i);
        if (action == null) {
          string += HexString.ByteZeroEnd(OFAction.MAXIMAL_LENGTH);
        } else {
          string += action.toBytesString();
          if (action.getLength() < OFAction.MAXIMAL_LENGTH) {
            string += HexString.ByteZeroEnd(OFAction.MAXIMAL_LENGTH - action.getLength());
          }
        }
      }
      if (i < OFGlobal.OFP_MAX_ACTION_NUMBER_PER_GROUP) {
        string +=
            HexString.ByteZeroEnd(
                (OFGlobal.OFP_MAX_ACTION_NUMBER_PER_GROUP - i) * OFAction.MAXIMAL_LENGTH);
      }
    }

    return string;
  }
コード例 #3
0
 public String toBytesString() {
   return super.toBytesString()
       + HexString.toHex(fieldPosition)
       + HexString.ByteZeroEnd(2)
       + HexString.toHex(fieldLength);
 }