HTP  0.5
Functions
htp_connection_parser.h File Reference

Go to the source code of this file.

Functions

void htp_connp_clear_error (htp_connp_t *connp)
 
void htp_connp_close (htp_connp_t *connp, const htp_time_t *timestamp)
 
htp_connp_thtp_connp_create (htp_cfg_t *cfg)
 
void htp_connp_destroy (htp_connp_t *connp)
 
void htp_connp_destroy_all (htp_connp_t *connp)
 
htp_conn_thtp_connp_get_connection (const htp_connp_t *connp)
 
htp_tx_thtp_connp_get_in_tx (const htp_connp_t *connp)
 
htp_log_thtp_connp_get_last_error (const htp_connp_t *connp)
 
htp_tx_thtp_connp_get_out_tx (const htp_connp_t *connp)
 
void * htp_connp_get_user_data (const htp_connp_t *connp)
 
void htp_connp_open (htp_connp_t *connp, const char *client_addr, int client_port, const char *server_addr, int server_port, htp_time_t *timestamp)
 
void htp_connp_set_user_data (htp_connp_t *connp, const void *user_data)
 
int htp_connp_req_data (htp_connp_t *connp, const htp_time_t *timestamp, const void *data, size_t len)
 
size_t htp_connp_req_data_consumed (htp_connp_t *connp)
 
int htp_connp_res_data (htp_connp_t *connp, const htp_time_t *timestamp, const void *data, size_t len)
 
size_t htp_connp_res_data_consumed (htp_connp_t *connp)
 
htp_tx_thtp_connp_tx_create (htp_connp_t *connp)
 

Detailed Description

Author
Ivan Ristic ivanr.nosp@m.@web.nosp@m.kreat.nosp@m.or.c.nosp@m.om

Function Documentation

void htp_connp_clear_error ( htp_connp_t connp)

Clears the most recent error, if any.

Parameters
[in]connp
void htp_connp_close ( htp_connp_t connp,
const htp_time_t timestamp 
)

Closes the connection associated with the supplied parser.

Parameters
[in]connp
[in]timestampOptional.
htp_connp_t* htp_connp_create ( htp_cfg_t cfg)

Creates a new connection parser using the provided configuration. Because the configuration structure is used directly, in a multithreaded environment you are not allowed to change the structure, ever. If you have a need to change configuration on per-connection basis, make a copy of the configuration structure to go along with every connection parser.

Parameters
[in]cfg
Returns
New connection parser instance, or NULL on error.
void htp_connp_destroy ( htp_connp_t connp)

Destroys the connection parser and its data structures, leaving all the data (connection, transactions, etc) intact.

Parameters
[in]connp
void htp_connp_destroy_all ( htp_connp_t connp)

Destroys the connection parser, its data structures, as well as the connection and its transactions.

Parameters
[in]connp
htp_conn_t* htp_connp_get_connection ( const htp_connp_t connp)

Returns the connection associated with the connection parser.

Parameters
[in]connp
Returns
htp_conn_t instance, or NULL if one is not available.
htp_tx_t* htp_connp_get_in_tx ( const htp_connp_t connp)

Retrieves the pointer to the active inbound transaction. In connection parsing mode there can be many open transactions, and up to 2 active transactions at any one time. This is due to HTTP pipelining. Can be NULL.

Parameters
[in]connp
Returns
Active inbound transaction, or NULL if there isn't one.
htp_log_t* htp_connp_get_last_error ( const htp_connp_t connp)

Returns the last error that occurred with this connection parser. Do note, however, that the value in this field will only be valid immediately after an error condition, but it is not guaranteed to remain valid if the parser is invoked again.

Parameters
[in]connp
Returns
A pointer to an htp_log_t instance if there is an error, or NULL if there isn't.
htp_tx_t* htp_connp_get_out_tx ( const htp_connp_t connp)

Retrieves the pointer to the active outbound transaction. In connection parsing mode there can be many open transactions, and up to 2 active transactions at any one time. This is due to HTTP pipelining. Can be NULL.

Parameters
[in]connp
Returns
Active outbound transaction, or NULL if there isn't one.
void* htp_connp_get_user_data ( const htp_connp_t connp)

Retrieve the user data associated with this connection parser.

Parameters
[in]connp
Returns
User data, or NULL if there isn't any.
void htp_connp_open ( htp_connp_t connp,
const char *  client_addr,
int  client_port,
const char *  server_addr,
int  server_port,
htp_time_t timestamp 
)

Opens connection.

Parameters
[in]connp
[in]client_addrClient address
[in]client_portClient port
[in]server_addrServer address
[in]server_portServer port
[in]timestampOptional.
int htp_connp_req_data ( htp_connp_t connp,
const htp_time_t timestamp,
const void *  data,
size_t  len 
)
Parameters
[in]connp
[in]timestamp
[in]data
[in]len
Returns
HTP_STREAM_DATA, HTP_STREAM_ERROR or STEAM_STATE_DATA_OTHER (see QUICK_START). HTP_STREAM_CLOSED and HTP_STREAM_TUNNEL are also possible.
size_t htp_connp_req_data_consumed ( htp_connp_t connp)

Returns the number of bytes consumed from the most recent inbound data chunk. Normally, an invocation of htp_connp_req_data() will consume all data from the supplied buffer, but there are circumstances where only partial consumption is possible. In such cases HTP_STREAM_DATA_OTHER will be returned. Consumed bytes are no longer necessary, but the remainder of the buffer will be need to be saved for later.

Parameters
[in]connp
Returns
The number of bytes consumed from the last data chunk sent for inbound processing.

Returns how many bytes from the current data chunks were consumed so far.

Parameters
[in]connp
Returns
The number of bytes consumed.
int htp_connp_res_data ( htp_connp_t connp,
const htp_time_t timestamp,
const void *  data,
size_t  len 
)

Process a chunk of outbound (server or response) data.

Parameters
[in]connp
[in]timestampOptional.
[in]data
[in]len
Returns
HTP_OK on state change, HTP_ERROR on error, or HTP_DATA when more data is needed
size_t htp_connp_res_data_consumed ( htp_connp_t connp)

Returns the number of bytes consumed from the most recent outbound data chunk. Normally, an invocation of htp_connp_res_data() will consume all data from the supplied buffer, but there are circumstances where only partial consumption is possible. In such cases HTP_STREAM_DATA_OTHER will be returned. Consumed bytes are no longer necessary, but the remainder of the buffer will be need to be saved for later.

Parameters
[in]connp
Returns
The number of bytes consumed from the last data chunk sent for outbound processing.
void htp_connp_set_user_data ( htp_connp_t connp,
const void *  user_data 
)

Associate user data with the supplied parser.

Parameters
[in]connp
[in]user_data
htp_tx_t* htp_connp_tx_create ( htp_connp_t connp)

Create a new transaction using the connection parser provided.

Parameters
[in]connp
Returns
Transaction instance on success, NULL on failure.