@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[option-type: ") .append(type) .append("] [option-length: ") .append(getLengthAsInt()) .append(" bytes] [option-data: 0x") .append(ByteArrays.toHexString(data, "")) .append("]"); return sb.toString(); }
private UnknownIpV4Option(byte[] rawData, int offset, int length) throws IllegalRawDataException { if (length < 2) { StringBuilder sb = new StringBuilder(100); sb.append("The raw data length must be more than 1. rawData: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.type = IpV4OptionType.getInstance(rawData[offset]); this.length = rawData[1 + offset]; int lengthFieldAsInt = getLengthAsInt(); if (length < lengthFieldAsInt) { StringBuilder sb = new StringBuilder(100); sb.append("The raw data is too short to build this option (") .append(lengthFieldAsInt) .append("). data: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.data = ByteArrays.getSubArray(rawData, 2 + offset, lengthFieldAsInt - 2); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("[option-type: ") .append(type) .append("] [option-length: ") .append(getLengthAsInt()) .append(" bytes] [option-data: 0x") .append(ByteArrays.toHexString(data, "")) .append("]"); return sb.toString(); }
private UnknownIpV4Option(byte[] rawData, int offset, int length) throws IllegalRawDataException { if (length < 2) { StringBuilder sb = new StringBuilder(100); sb.append("The raw data length must be more than 1. rawData: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.type = IpV4OptionType.getInstance(rawData[offset]); this.length = rawData[1 + offset]; int lengthFieldAsInt = getLengthAsInt(); if (length < lengthFieldAsInt) { StringBuilder sb = new StringBuilder(100); sb.append("The raw data is too short to build this option (") .append(lengthFieldAsInt) .append("). data: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.data = ByteArrays.getSubArray(rawData, 2 + offset, lengthFieldAsInt - 2); }