Esempio n. 1
0
 public String toString() {
   return ";fid="
       + fieldId
       + ";ofst="
       + offset
       + ";len="
       + length
       + ";val="
       + HexString.toHex(value)
       + ";mask="
       + HexString.toHex(mask);
 }
Esempio n. 2
0
  public String getFullHexMask() {
    String fullHexMaskString = "";
    if (mask == null) {
      fullHexMaskString += HexString.Zero((length - 1) / 8 + 1);
    } else {
      if (mask.length >= OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        fullHexMaskString += HexString.toHex(mask, 0, OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
      } else {
        fullHexMaskString += HexString.toHex(mask);
        // fullHexMaskString += HexString.Zero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - mask.length);
      }
    }

    return fullHexMaskString;
  }
Esempio n. 3
0
  public String getFullHexValue() {
    String fullHexValueString = "";
    if (value == null) {
      fullHexValueString += HexString.Zero((length - 1) / 8 + 1);
    } else {
      if (value.length >= OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        fullHexValueString += HexString.toHex(value, 0, OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
      } else {
        fullHexValueString += HexString.toHex(value);
        // fullHexValueString += HexString.Zero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE -
        // value.length);
      }
    }

    return fullHexValueString;
  }
Esempio n. 4
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;
  }
Esempio n. 5
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;
  }
 public String toBytesString() {
   return super.toBytesString()
       + HexString.toHex(fieldPosition)
       + HexString.ByteZeroEnd(2)
       + HexString.toHex(fieldLength);
 }