2. Packet

object packet

Object that represents a raw data packet. I.e a blob of binary data coming from the capture module. Nothing is known about its content.

haka.packet(size = 0) → pkt
Parameters:
  • size (number) – Size of the new packet.
Returns:
  • pkt (packet) – New packet.

Create a new packet of the given size.

const <packet>.payload
Type:vbuffer 

Data inside the packet.

<packet>:drop()

Drop the packet.

Note

The packet will be unusable after calling this function.

<packet>:send()

Send the packet on the network.

Note

The packet will be unusable after calling this function.

<packet>:inject()

Re-inject the packet. The packet will re-enter the Haka rules and dissector exactly like a new packet coming from the capture module.

haka.state() → state
Returns:
  • state (string) – State of the packet: 'forged', 'normal' or 'sent'.

Get the state of the packet.

haka.packet_mode() → mode
Returns:
  • mode (string) – Current packet mode ('normal' or 'passthrough').

Get the current packet mode for Haka. In passthrough mode, the packet cannot be modified nor dropped.