|
Packit |
284210 |
/*
|
|
Packit |
284210 |
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
|
|
Packit |
284210 |
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* You may not use this file except in compliance with
|
|
Packit |
284210 |
* the License. You may obtain a copy of the License at
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
284210 |
*
|
|
Packit |
284210 |
* If any of the files related to licensing are missing or if you have any
|
|
Packit |
284210 |
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
|
Packit |
284210 |
* directly using the email address security@modsecurity.org.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#ifndef _ALP2_LL_H_
|
|
Packit |
284210 |
#define _ALP2_LL_H_
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#include <apr_general.h>
|
|
Packit |
284210 |
#include <apr_md5.h>
|
|
Packit |
284210 |
#include <apr_strings.h>
|
|
Packit |
284210 |
#include <apr_tables.h>
|
|
Packit |
284210 |
#include <apr_md5.h>
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* -- Constants -- */
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#define ALP2_MAX_LINE_SIZE 16384
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#define ALP2_ERROR_INCORRECT_STATE -1001
|
|
Packit |
284210 |
#define ALP2_ERROR_FATAL -1002
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#define ALP2_DONE 0
|
|
Packit |
284210 |
#define ALP2_NEED_DATA 1
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#define ALP2_EVENT_ENTRY_START 1
|
|
Packit |
284210 |
#define ALP2_EVENT_ENTRY_END 2
|
|
Packit |
284210 |
#define ALP2_EVENT_PART_START 3
|
|
Packit |
284210 |
#define ALP2_EVENT_PART_END 4
|
|
Packit |
284210 |
#define ALP2_EVENT_PART_DATA 5
|
|
Packit |
284210 |
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* -- Data structures -- */
|
|
Packit |
284210 |
|
|
Packit |
284210 |
typedef struct alp2_pp_part_t alp2_pp_part_t;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
struct alp2_pp_part_t {
|
|
Packit |
284210 |
int id; // XXX int here but unsigned int other places???
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* Relative to the beginning of the entry, not
|
|
Packit |
284210 |
* including the boundary lines. Just content.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
size_t offset;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
size_t size;
|
|
Packit |
284210 |
};
|
|
Packit |
284210 |
|
|
Packit |
284210 |
typedef struct alp2_pp_entry_t alp2_pp_entry_t;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
struct alp2_pp_entry_t {
|
|
Packit |
284210 |
apr_pool_t *mp;
|
|
Packit |
284210 |
apr_array_header_t *parts;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* Entry offset and size include
|
|
Packit |
284210 |
* the delimiting boundaries.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
size_t offset;
|
|
Packit |
284210 |
size_t size;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
const char *boundary;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
apr_md5_ctx_t *md5_context;
|
|
Packit |
284210 |
uint8_t md5_digest[APR_MD5_DIGESTSIZE];
|
|
Packit |
284210 |
};
|
|
Packit |
284210 |
|
|
Packit |
284210 |
typedef struct alp2_pp_t alp2_pp_t;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
struct alp2_pp_t {
|
|
Packit |
284210 |
void *user_data;
|
|
Packit |
284210 |
int (*callback)(alp2_pp_t *alp, int event_type);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* The memory pool used during the parsing of
|
|
Packit |
284210 |
* individual audit log entries. Cleared between
|
|
Packit |
284210 |
* entries.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
apr_pool_t *mp;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
unsigned int errored;
|
|
Packit |
284210 |
unsigned int done;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
const char *boundary;
|
|
Packit |
284210 |
char *last_processed_part;
|
|
Packit |
284210 |
char *current_line;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* The number of bytes processed since
|
|
Packit |
284210 |
* the beginning or the last reset.
|
|
Packit |
284210 |
*/
|
|
Packit |
284210 |
size_t current_offset;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
const char *input_buf;
|
|
Packit |
284210 |
size_t input_len;
|
|
Packit |
284210 |
size_t input_pos;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char *line_buf;
|
|
Packit |
284210 |
size_t line_pos;
|
|
Packit |
284210 |
size_t line_size;
|
|
Packit |
284210 |
unsigned int line_has_start;
|
|
Packit |
284210 |
size_t line_offset;
|
|
Packit |
284210 |
|
|
Packit |
284210 |
alp2_pp_part_t *current_part;
|
|
Packit |
284210 |
alp2_pp_entry_t *current_entry;
|
|
Packit |
284210 |
};
|
|
Packit |
284210 |
|
|
Packit |
284210 |
|
|
Packit |
284210 |
/* Functions. */
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int alp2_pp_init(alp2_pp_t *alp_pp, void *user_data,
|
|
Packit |
284210 |
int (*callback)(alp2_pp_t *alp, int event_type), apr_pool_t *mp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
int alp2_pp_process(alp2_pp_t *alp_pp, const char *data, size_t len);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
void alp2_pp_terminate(alp2_pp_t *alp_pp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
char *alp2_pp_line_chomp(alp2_pp_t *alp_pp);
|
|
Packit |
284210 |
|
|
Packit |
284210 |
#endif
|