- data = (char *)(buf + len);
- len += (packet_len < 64) ? packet_len : 64;
- memcpy(data, packet, (packet_len < 64) ? packet_len : 64);
+
+ /* ip header + first 8 bytes of payload */
+ if (packet_len > (sizeof(struct iphdr) + 8))
+ packet_len = sizeof(struct iphdr) + 8;
+
+ memcpy(buf + len, packet, packet_len);
+ len += packet_len;