7.4. Tcp¶
Tcp state-less dissector module.
Usage:
local tcp = require('protocol/tcp')
7.4.1. Dissector¶
- dissector TcpDissector¶
Name : 'tcp' Extend : haka.helper.PacketDissector Dissector data for a TCP packet. This dissector is state-less. It will only parse the packet headers.
- tcp.create(ip) → tcp¶
Parameters: - ip (Ipv4Dissector) – IPv4 packet.
Returns: - tcp (TcpDissector) – Created packet.
Create a new TCP packet on top of the given IP packet.
- <TcpDissector>.srcport¶
- <TcpDissector>.dstport¶
- <TcpDissector>.seq¶
- <TcpDissector>.ack_seq¶
- <TcpDissector>.res¶
- <TcpDissector>.hdr_len¶
- <TcpDissector>.window_size¶
- <TcpDissector>.checksum¶
- <TcpDissector>.urgent_pointer¶
Type: number TCP fields.
- <TcpDissector>.flags.fin¶
- <TcpDissector>.flags.syn¶
- <TcpDissector>.flags.rst¶
- <TcpDissector>.flags.psh¶
- <TcpDissector>.flags.ack¶
- <TcpDissector>.flags.urg¶
- <TcpDissector>.flags.ecn¶
- <TcpDissector>.flags.cwr¶
Type: boolean TCP flags.
- <TcpDissector>.flags.all¶
Type: number All flags raw value.
- const <TcpDissector>.ip¶
Type: Ipv4Dissector IPv4 packet.
- <TcpDissector>:verify_checksum() → correct¶
Returns: - correct (boolean) – true if the checksum is correct.
Verify if the checksum is correct.
- <TcpDissector>:compute_checksum()¶
Recompute the checksum and set the resulting value in the packet.
- <TcpDissector>:drop()¶
Drop the TCP packet.
- <TcpDissector>:send()¶
Send the packet.
- <TcpDissector>:inject()¶
Inject the packet.
7.4.2. Events¶
- event tcp.events.receive_packet(pkt)¶
Parameters: - pkt (TcpDissector) – TCP packet.
Event that is triggered whenever a new packet is received.
- event tcp.events.send_packet(pkt)¶
Parameters: - pkt (TcpDissector) – TCP packet.
Event that is triggered just before sending a packet on the network.
7.4.3. Utilities¶
Warning
This section introduces advanced feature of Haka.
- object tcp_stream¶
TCP stream helper object.
- tcp.tcp_stream() → stream¶
Returns: - stream (tcp_stream) – New TCP stream.
Create a new TCP stream.
- <tcp_stream>:init(seq)¶
Parameters: - seq (number) – Initial sequence number for this stream.
Initialize the initial sequence number of the stream.
- <tcp_stream>:push(tcp)¶
Parameters: - tcp (TcpDissector) – TCP packet.
Push a tcp packet into the stream.
- <tcp_stream>:pop() → tcp¶
Returns: - tcp (TcpDissector) – TCP packet.
Pop a tcp packet out of the stream.
- <tcp_stream>:seq(tcp)¶
Parameters: - tcp (TcpDissector) – TCP packet.
Update the sequence number of a tcp packet.
- <tcp_stream>:ack(tcp)¶
Parameters: - tcp (TcpDissector) – TCP packet.
Update the ack number of a packet.
- <tcp_stream>:clear()¶
Clear the stream and drop all remaining packets.
- <tcp_stream>.stream¶
Type: vbuffer_stream Associated raw stream.
- const <tcp_stream>.lastseq¶
Type: number Last received sequence number.