public byte[] getRawData() {
   byte[] rawData = new byte[length()];
   Iterator<TimestampWithAddress> iter = timestampsWithAddresses.iterator();
   for (int i = 0; i < rawData.length; i += INT_SIZE_IN_BYTES * 2) {
     TimestampWithAddress twa = iter.next();
     System.arraycopy(ByteArrays.toByteArray(twa.address), 0, rawData, i, INT_SIZE_IN_BYTES);
     if (twa.timestamp != null) {
       System.arraycopy(
           ByteArrays.toByteArray(twa.timestamp),
           0,
           rawData,
           i + INT_SIZE_IN_BYTES,
           INT_SIZE_IN_BYTES);
     }
   }
   return rawData;
 }
Example #2
0
    @Override
    protected String buildString() {
      StringBuilder sb = new StringBuilder();
      String ls = System.getProperty("line.separator");

      sb.append("[ICMPv4 Redirect Header (").append(length()).append(" bytes)]").append(ls);
      sb.append("  Gateway Internet Address: ").append(gatewayInternetAddress).append(ls);

      return sb.toString();
    }
Example #3
0
  @Override
  public byte[] getRawData() {
    byte[] rawData = new byte[length()];
    rawData[0] = kind.value();
    rawData[1] = length;

    int offset = 2;
    for (Sack sack : sacks) {
      System.arraycopy(
          ByteArrays.toByteArray(sack.leftEdge), 0, rawData, offset, INT_SIZE_IN_BYTES);
      System.arraycopy(
          ByteArrays.toByteArray(sack.rightEdge),
          0,
          rawData,
          offset + INT_SIZE_IN_BYTES,
          INT_SIZE_IN_BYTES);
      offset += INT_SIZE_IN_BYTES * 2;
    }

    return rawData;
  }
    @Override
    protected String buildString() {
      StringBuilder sb = new StringBuilder();
      String ls = System.getProperty("line.separator");

      sb.append("[ICMPv6 Neighbor Advertisement Header (")
          .append(length())
          .append(" bytes)]")
          .append(ls);
      sb.append("  Router flag: ").append(routerFlag).append(ls);
      sb.append("  Solicited flag: ").append(solicitedFlag).append(ls);
      sb.append("  Override flag: ").append(overrideFlag).append(ls);
      sb.append("  Reserved: ").append(reserved).append(ls);
      sb.append("  Target Address: ").append(targetAddress).append(ls);
      for (IpV6NeighborDiscoveryOption opt : options) {
        sb.append("  Option: ").append(opt).append(ls);
      }

      return sb.toString();
    }