private IcmpV4CommonHeader(byte[] rawData, int offset, int length) throws IllegalRawDataException { if (length < ICMPV4_COMMON_HEADER_SIZE) { StringBuilder sb = new StringBuilder(80); sb.append("The data is too short to build an ICMPv4 common header(") .append(ICMPV4_COMMON_HEADER_SIZE) .append(" bytes). data: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.type = IcmpV4Type.getInstance(ByteArrays.getByte(rawData, TYPE_OFFSET + offset)); this.code = IcmpV4Code.getInstance(type.value(), ByteArrays.getByte(rawData, CODE_OFFSET + offset)); this.checksum = ByteArrays.getShort(rawData, CHECKSUM_OFFSET + offset); }
code = IcmpV4Code.getInstance(type.value(), Byte.parseByte(strCode)); } catch (NumberFormatException e) { throw new IllegalArgumentException("args[1]: " + strType, e);
private IcmpV4CommonHeader(byte[] rawData, int offset, int length) throws IllegalRawDataException { if (length < ICMPV4_COMMON_HEADER_SIZE) { StringBuilder sb = new StringBuilder(80); sb.append("The data is too short to build an ICMPv4 common header(") .append(ICMPV4_COMMON_HEADER_SIZE) .append(" bytes). data: ") .append(ByteArrays.toHexString(rawData, " ")) .append(", offset: ") .append(offset) .append(", length: ") .append(length); throw new IllegalRawDataException(sb.toString()); } this.type = IcmpV4Type.getInstance(ByteArrays.getByte(rawData, TYPE_OFFSET + offset)); this.code = IcmpV4Code.getInstance(type.value(), ByteArrays.getByte(rawData, CODE_OFFSET + offset)); this.checksum = ByteArrays.getShort(rawData, CHECKSUM_OFFSET + offset); }
code = IcmpV4Code.getInstance(type.value(), Byte.parseByte(strCode)); } catch (NumberFormatException e) { throw new IllegalArgumentException("args[1]: " + strType, e);