HTP  0.5
Functions
htp_multipart.c File Reference
#include "htp_config_auto.h"
#include "htp_private.h"

Functions

htp_multipart_thtp_mpartp_get_multipart (htp_mpartp_t *parser)
 
htp_status_t htp_mpart_part_parse_c_d (htp_multipart_part_t *part)
 
htp_status_t htp_mpart_part_process_headers (htp_multipart_part_t *part)
 
htp_status_t htp_mpartp_parse_header (htp_multipart_part_t *part, const unsigned char *data, size_t len)
 
htp_multipart_part_thtp_mpart_part_create (htp_mpartp_t *parser)
 
void htp_mpart_part_destroy (htp_multipart_part_t *part, int gave_up_data)
 
htp_status_t htp_mpart_part_finalize_data (htp_multipart_part_t *part)
 
htp_status_t htp_mpartp_run_request_file_data_hook (htp_multipart_part_t *part, const unsigned char *data, size_t len)
 
htp_status_t htp_mpart_part_handle_data (htp_multipart_part_t *part, const unsigned char *data, size_t len, int is_line)
 
htp_mpartp_thtp_mpartp_create (htp_cfg_t *cfg, bstr *boundary, uint64_t flags)
 
void htp_mpartp_destroy (htp_mpartp_t *parser)
 
htp_status_t htp_mpartp_finalize (htp_mpartp_t *parser)
 
htp_status_t htp_mpartp_parse (htp_mpartp_t *parser, const void *_data, size_t len)
 
htp_status_t htp_mpartp_find_boundary (bstr *content_type, bstr **boundary, uint64_t *flags)
 

Detailed Description

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

Function Documentation

htp_multipart_part_t* htp_mpart_part_create ( htp_mpartp_t parser)

Creates a new Multipart part.

Parameters
[in]parser
Returns
New part instance, or NULL on memory allocation failure.
void htp_mpart_part_destroy ( htp_multipart_part_t part,
int  gave_up_data 
)

Destroys a part.

Parameters
[in]part
[in]gave_up_data
htp_status_t htp_mpart_part_finalize_data ( htp_multipart_part_t part)

Finalizes part processing.

Parameters
[in]part
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t htp_mpart_part_handle_data ( htp_multipart_part_t part,
const unsigned char *  data,
size_t  len,
int  is_line 
)

Handles part data.

Parameters
[in]part
[in]data
[in]len
[in]is_line
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t htp_mpart_part_parse_c_d ( htp_multipart_part_t part)

Parses the Content-Disposition part header.

Parameters
[in]part
Returns
HTP_OK on success (header found and parsed), HTP_DECLINED if there is no C-D header or if it could not be processed, and HTP_ERROR on fatal error.
htp_status_t htp_mpart_part_process_headers ( htp_multipart_part_t part)

Processes part headers.

Parameters
[in]part
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_mpartp_t* htp_mpartp_create ( htp_cfg_t cfg,
bstr boundary,
uint64_t  flags 
)

Creates a new multipart/form-data parser. On a successful invocation, the ownership of the boundary parameter is transferred to the parser.

Parameters
[in]cfg
[in]boundary
[in]flags
Returns
New parser instance, or NULL on memory allocation failure.
void htp_mpartp_destroy ( htp_mpartp_t parser)

Destroys the provided parser.

Parameters
[in]parser
htp_status_t htp_mpartp_finalize ( htp_mpartp_t parser)

Finalize parsing.

Parameters
[in]parser
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t htp_mpartp_find_boundary ( bstr content_type,
bstr **  boundary,
uint64_t *  multipart_flags 
)

Looks for boundary in the supplied Content-Type request header. The extracted boundary will be allocated on the heap.

Parameters
[in]content_type
[out]boundary
[out]multipart_flagsMultipart flags, which are not compatible from general LibHTP flags.
Returns
HTP_OK on success (boundary found), HTP_DECLINED if boundary was not found, and HTP_ERROR on failure. Flags may be set on HTP_OK and HTP_DECLINED. For example, if a boundary could not be extracted but there is indication that one is present, HTP_MULTIPART_HBOUNDARY_INVALID will be set.
htp_multipart_t* htp_mpartp_get_multipart ( htp_mpartp_t parser)

Returns the multipart structure created by the parser.

Parameters
[in]parser
Returns
The main multipart structure.
htp_status_t htp_mpartp_parse ( htp_mpartp_t parser,
const void *  data,
size_t  len 
)

Parses a chunk of multipart/form-data data. This function should be called as many times as necessary until all data has been consumed.

Parameters
[in]parser
[in]data
[in]len
Returns
HTP_OK on success, HTP_ERROR on failure.
htp_status_t htp_mpartp_parse_header ( htp_multipart_part_t part,
const unsigned char *  data,
size_t  len 
)

Parses one part header.

Parameters
[in]part
[in]data
[in]len
Returns
HTP_OK on success, HTP_DECLINED on parsing error, HTP_ERROR on fatal error.
htp_status_t htp_mpartp_run_request_file_data_hook ( htp_multipart_part_t part,
const unsigned char *  data,
size_t  len 
)