suricata
|
Go to the source code of this file.
Data Structures | |
struct | MemBuffer_ |
Macros | |
#define | MemBufferReset(mem_buffer) |
Reset the mem buffer. More... | |
#define | MEMBUFFER_BUFFER(mem_buffer) (mem_buffer)->buffer |
Get the MemBuffers underlying buffer. More... | |
#define | MEMBUFFER_OFFSET(mem_buffer) (mem_buffer)->offset |
Get the MemBuffers current offset. More... | |
#define | MEMBUFFER_SIZE(mem_buffer) (mem_buffer)->size |
Get the MemBuffers current size. More... | |
#define | MemBufferPrintToFP(buffer, fp) |
Write a buffer to the file pointer. More... | |
#define | MemBufferPrintToFPAsString(mem_buffer, fp) |
Write a buffer to the file pointer as a printable char string. More... | |
#define | MemBufferPrintToFPAsHex(mem_buffer, fp) |
Write a buffer in hex format. More... | |
#define | MemBufferWriteRaw(dst, raw_buffer, raw_buffer_len) |
Write a raw buffer to the MemBuffer dst. More... | |
#define | MemBufferWriteString(dst, ...) |
Write a string buffer to the Membuffer dst. More... | |
Typedefs | |
typedef struct MemBuffer_ | MemBuffer |
Functions | |
MemBuffer * | MemBufferCreateNew (uint32_t size) |
int | MemBufferExpand (MemBuffer **buffer, uint32_t expand_by) |
expand membuffer by size of 'expand_by' More... | |
void | MemBufferFree (MemBuffer *buffer) |
Definition in file util-buffer.h.
#define MEMBUFFER_BUFFER | ( | mem_buffer | ) | (mem_buffer)->buffer |
Get the MemBuffers underlying buffer.
Definition at line 51 of file util-buffer.h.
#define MEMBUFFER_OFFSET | ( | mem_buffer | ) | (mem_buffer)->offset |
Get the MemBuffers current offset.
Definition at line 56 of file util-buffer.h.
#define MEMBUFFER_SIZE | ( | mem_buffer | ) | (mem_buffer)->size |
Get the MemBuffers current size.
Definition at line 61 of file util-buffer.h.
#define MemBufferPrintToFP | ( | buffer, | |
fp | |||
) |
Write a buffer to the file pointer.
Accepted buffers can contain both printable and non-printable characters. Printable characters are written in the printable format and the non-printable chars are written in hex codes using the |XX| format. For example this would be the kind of output in the file - onetwo|EF|three|ED|five
buffer | Pointer to the src MemBuffer instance to write. |
fp | Pointer to the file instance to write to. |
Definition at line 77 of file util-buffer.h.
#define MemBufferPrintToFPAsHex | ( | mem_buffer, | |
fp | |||
) |
Write a buffer in hex format.
buffer | Pointer to the src MemBuffer instance to write. |
fp | Pointer to the file instance to write to. |
Definition at line 104 of file util-buffer.h.
#define MemBufferPrintToFPAsString | ( | mem_buffer, | |
fp | |||
) |
Write a buffer to the file pointer as a printable char string.
buffer | Pointer to the src MemBuffer instance to write. |
fp | Pointer to the file instance to write to. |
Definition at line 94 of file util-buffer.h.
#define MemBufferReset | ( | mem_buffer | ) |
Reset the mem buffer.
mem_buffer | Pointer to the mem buffer instance. |
Definition at line 43 of file util-buffer.h.
#define MemBufferWriteRaw | ( | dst, | |
raw_buffer, | |||
raw_buffer_len | |||
) |
Write a raw buffer to the MemBuffer dst.
When we say raw buffer it indicates a buffer that need not be purely a string buffer. It can be a pure string buffer or not or a mixture of both. Hence we don't accept any format strings. If the remaining space on the buffer is lesser than the length of the buffer to write, it is truncated to fit into the empty space. Also after every write a '\0' is appended. This would indicate that the total available space to write in the buffer is MemBuffer->size - 1 and not Membuffer->size. The reason we append the '\0' is for supporting writing pure string buffers as well, that can later be used by other string handling funcs.
raw_buffer | The buffer to write. |
raw_buffer_len | Length of the above buffer. |
Definition at line 134 of file util-buffer.h.
#define MemBufferWriteString | ( | dst, | |
... | |||
) |
Write a string buffer to the Membuffer dst.
This function takes a format string and arguments for the format string like sprintf. An example usage of this is - MemBufferWriteString(mem_buffer_instance, \"%d - %s\", 10, \"one\");
dst | The dst MemBuffer instance. |
format | The format string. |
... | Variable arguments. |
Definition at line 163 of file util-buffer.h.
typedef struct MemBuffer_ MemBuffer |
MemBuffer* MemBufferCreateNew | ( | uint32_t | size | ) |
Definition at line 32 of file util-buffer.c.
References MAX_LIMIT, SC_EINVAL, SC_ENOMEM, sc_errno, SC_OK, SCLogWarning, SCMalloc, and unlikely.
Referenced by CreateEveThreadCtx(), JsonLogThreadInit(), LogHttpLogThreadInit(), LogStatsLogThreadInit(), and LogTcpDataLogThreadInit().
int MemBufferExpand | ( | MemBuffer ** | buffer, |
uint32_t | expand_by | ||
) |
expand membuffer by size of 'expand_by'
If expansion failed, buffer will still be valid.
result | 0 ok, -1 expansion failed |
Definition at line 64 of file util-buffer.c.
References MAX_LIMIT, SCLogDebug, SCLogWarning, SCRealloc, MemBuffer_::size, and unlikely.
Referenced by OutputJsonBuilderBuffer(), and OutputJSONMemBufferCallback().
void MemBufferFree | ( | MemBuffer * | buffer | ) |
Definition at line 87 of file util-buffer.c.
References SCFree.
Referenced by CreateEveThreadCtx(), FreeEveThreadCtx(), JsonLogThreadInit(), LogHttpLogThreadDeinit(), LogStatsLogThreadDeinit(), and LogTcpDataLogThreadDeinit().