return this;
}
+ /**
+ * Returns the type field of the current ICMP packet
+ *
+ * @return The type code of the current ICMP packet
+ */
+ public byte getType() {
+ return BitBufferHelper.getByte(fieldValues.get(TYPE));
+ }
+
/**
* Sets the ICMP code (type subtype) for the current ICMP object instance
*
return this;
}
+ /**
+ * Gets the ICMP code (type subtype) for the current ICMP object instance
+ *
+ * @return The ICMP message type subtype
+ */
+ public byte getCode() {
+ return BitBufferHelper.getByte(fieldValues.get(CODE));
+ }
+
/**
* Sets the ICMP checksum for the current ICMP object instance
* @param short - checksum
}
/**
- * Sets the ICMP identifier for the current ICMP object instance
+ * Sets the ICMP identifier for the current ICMP object instance
* @param short - identifier
* @return ICMP
*/
return this;
}
+ /**
+ * Gets the ICMP identifier of the current ICMP object instance
+ *
+ * @return short - identifier
+ */
+
+ public short getIdentifier() {
+ return BitBufferHelper.getShort(fieldValues.get(IDENTIFIER));
+ }
+
/**
* Sets the ICMP sequence number for the current ICMP object instance
* @param short - seqNumber
return this;
}
+ /**
+ * Gets the ICMP sequence number of the current ICMP object instance
+ *
+ * @return short - seqNumber
+ */
+
+ public short getSequenceNumber() {
+ return BitBufferHelper.getShort(fieldValues.get(SEQNUMBER));
+ }
+
/**
* Gets the header size in bits
* @return The ICMP header size in bits
short computeChecksum(byte[] data, int start) {
int sum = 0, carry = 0, finalSum = 0;
int wordData;
- int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte
- + rawPayload.length;
- int checksumStartByte = start + getfieldOffset(CHECKSUM)
- / NetUtils.NumBitsInAByte;
+ int end = start + this.getHeaderSize() / NetUtils.NumBitsInAByte;
+ if (rawPayload != null) {
+ end += rawPayload.length;
+ }
+ int checksumStartByte = start + getfieldOffset(CHECKSUM) / NetUtils.NumBitsInAByte;
for (int i = start; i <= (end - 1); i = i + 2) {
// Skip, if the current bytes are checkSum bytes