suricata
|
Go to the source code of this file.
Macros | |
#define | MAX_LIMIT 10485760 |
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) |
void | MemBufferPrintToFP (MemBuffer *buffer, FILE *fp) |
Write a buffer to the file pointer. More... | |
size_t | MemBufferPrintToFPAsString (MemBuffer *b, FILE *fp) |
Write a buffer to the file pointer as a printable char string. More... | |
void | MemBufferPrintToFPAsHex (MemBuffer *b, FILE *fp) |
Write a buffer in hex format. More... | |
uint32_t | MemBufferWriteRaw (MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len) |
Write a raw buffer to the MemBuffer dst. More... | |
void | MemBufferWriteString (MemBuffer *dst, const char *fmt,...) |
Definition in file util-buffer.c.
#define MAX_LIMIT 10485760 |
Definition at line 31 of file util-buffer.c.
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, SCCalloc, SCLogWarning, 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 60 of file util-buffer.c.
References MAX_LIMIT, SCLogDebug, SCLogWarning, SCRealloc, MemBuffer_::size, and unlikely.
Referenced by OutputJSONMemBufferCallback().
void MemBufferFree | ( | MemBuffer * | buffer | ) |
Definition at line 86 of file util-buffer.c.
References SCFree.
Referenced by CreateEveThreadCtx(), FreeEveThreadCtx(), JsonLogThreadInit(), LogHttpLogThreadDeinit(), LogStatsLogThreadDeinit(), and LogTcpDataLogThreadDeinit().
void MemBufferPrintToFP | ( | MemBuffer * | buffer, |
FILE * | 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 91 of file util-buffer.c.
References MemBuffer_::buffer, and MemBuffer_::offset.
void MemBufferPrintToFPAsHex | ( | MemBuffer * | b, |
FILE * | fp | ||
) |
Write a buffer in hex format.
b | Pointer to the src MemBuffer instance to write. |
fp | Pointer to the file instance to write to. |
Definition at line 106 of file util-buffer.c.
References MemBuffer_::buffer, and MEMBUFFER_OFFSET.
size_t MemBufferPrintToFPAsString | ( | MemBuffer * | b, |
FILE * | fp | ||
) |
Write a buffer to the file pointer as a printable char string.
b | Pointer to the src MemBuffer instance to write. |
fp | Pointer to the file instance to write to. |
size_t | bytes written by fwrite() |
Definition at line 101 of file util-buffer.c.
References MEMBUFFER_BUFFER, and MEMBUFFER_OFFSET.
uint32_t MemBufferWriteRaw | ( | MemBuffer * | dst, |
const uint8_t * | raw, | ||
const uint32_t | raw_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. |
write_len | Bytes written. If less than raw_len, the buffer is full. |
Definition at line 115 of file util-buffer.c.
References dst, and SCLogDebug.
Referenced by OutputJSONBuffer(), and OutputJSONMemBufferCallback().
void MemBufferWriteString | ( | MemBuffer * | dst, |
const char * | fmt, | ||
... | |||
) |
Definition at line 130 of file util-buffer.c.
References dst, MIN, and SCLogDebug.
Referenced by LogFileWrite().