3.8. TCP

3.8.1. Types

struct tcp

Opaque TCP dissector data.

struct tcp_connection

TCP connection structure.

struct tcp_stream

TCP stream structure.

3.8.2. Functions

TCP connection

struct tcp_connection *tcp_connection_new(const struct tcp *tcp)

Create a new TCP connection for the given TCP packet. tcp is the packet going from the client to the server.

struct tcp_connection *tcp_connection_get(const struct tcp *tcp, bool *direction_in, bool *dropped)

Get the TCP connection if any associated with the given TCP packet.

Parameters:
  • direction_in – Filled with the direction of the given tcp packet. It is set to true if the packet follow the input direction, false otherwise.
  • dropped – Filled with true if the connection have previously been dropped.
struct stream *tcp_connection_get_stream(struct tcp_connection *conn, bool direction_in)

Get the stream associated with a TCP connection.

Parameters:
  • direction_in – Stream direction, input if true, output otherwise.
void tcp_connection_close(struct tcp_connection *tcp_conn)

Close the TCP connection.

void tcp_connection_drop(struct tcp_connection *tcp_conn)

Drop the TCP connection.

TCP stream

struct stream *tcp_stream_create()

Create a new tcp stream.

bool tcp_stream_push(struct stream *stream, struct tcp *tcp)

Push data into a tcp stream.

Returns:true if successful, false otherwise (see clear_error() to get more details about the error).
struct tcp *tcp_stream_pop(struct stream *stream)

Pop data from a tcp stream.

Returns:A tcp packet if available. This function will pop all packets that have data before the current position in the stream.
void tcp_stream_init(struct stream *stream, uint32 seq)

Initialize the stream sequence number. This function must be called before starting pushing packet into the stream.

void tcp_stream_ack(struct stream *stream, struct tcp *tcp)

Offset the ack number of the packet.

void tcp_stream_seq(struct stream *stream, struct tcp *tcp)

Offset the seq number of the packet.