* @param checksum the checksum to set
*/
/*public IPv4 setChecksum() {
- short ipChecksum = computeChecksum();
+ short ipChecksum = computeChecksum();
byte[] checksum = BitBufferHelper.toByteArray(ipChecksum);
- fieldValues.put(CHECKSUM, checksum);
+ fieldValues.put(CHECKSUM, checksum);
return this;
}*/
/**
* Computes the IPv4 header checksum on the passed stream of bytes
* representing the packet
- *
+ *
* @param data
* The byte stream
* @param offset
* Deriving the Total Length here
*/
int payloadLength = 0;
- try {
- payloadLength = payload.serialize().length;
- } catch (PacketException e) {
- logger.error("", e);
+ if (payload != null) {
+ try {
+ payloadLength = payload.serialize().length;
+ } catch (PacketException e) {
+ logger.error("", e);
+ }
}
this.setTotalLength((short) (this.getHeaderLen() + payloadLength));