luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
Classes | Macros | Typedefs | Enumerations | Functions
heka_message.h File Reference

Heka message representation. More...

#include <stdbool.h>
#include <stddef.h>
#include "input_buffer.h"
#include "output_buffer.h"
#include "string.h"
#include "util.h"
Include dependency graph for heka_message.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lsb_heka_field
 
struct  lsb_heka_message
 
struct  lsb_read_value
 

Macros

#define LSB_UUID_SIZE   16
 
#define LSB_UUID_STR_SIZE   36
 
#define LSB_HDR_FRAME_SIZE   3
 
#define LSB_MIN_HDR_SIZE   14
 
#define LSB_MAX_HDR_SIZE   (255 + LSB_HDR_FRAME_SIZE)
 
#define LSB_UUID   "Uuid"
 
#define LSB_TIMESTAMP   "Timestamp"
 
#define LSB_TYPE   "Type"
 
#define LSB_LOGGER   "Logger"
 
#define LSB_SEVERITY   "Severity"
 
#define LSB_PAYLOAD   "Payload"
 
#define LSB_ENV_VERSION   "EnvVersion"
 
#define LSB_PID   "Pid"
 
#define LSB_HOSTNAME   "Hostname"
 
#define LSB_FIELDS   "Fields"
 
#define LSB_RAW   "raw"
 
#define LSB_FRAMED   "framed"
 
#define LSB_SIZE   "size"
 

Typedefs

typedef struct lsb_heka_field lsb_heka_field
 
typedef struct lsb_heka_message lsb_heka_message
 

Enumerations

enum  lsb_pb_message {
  LSB_PB_UUID = 1, LSB_PB_TIMESTAMP = 2, LSB_PB_TYPE = 3, LSB_PB_LOGGER = 4,
  LSB_PB_SEVERITY = 5, LSB_PB_PAYLOAD = 6, LSB_PB_ENV_VERSION = 7, LSB_PB_PID = 8,
  LSB_PB_HOSTNAME = 9, LSB_PB_FIELDS = 10
}
 
enum  lsb_pb_field {
  LSB_PB_NAME = 1, LSB_PB_VALUE_TYPE = 2, LSB_PB_REPRESENTATION = 3, LSB_PB_VALUE_STRING = 4,
  LSB_PB_VALUE_BYTES = 5, LSB_PB_VALUE_INTEGER = 6, LSB_PB_VALUE_DOUBLE = 7, LSB_PB_VALUE_BOOL = 8
}
 
enum  lsb_pb_value_types {
  LSB_PB_STRING = 0, LSB_PB_BYTES = 1, LSB_PB_INTEGER = 2, LSB_PB_DOUBLE = 3,
  LSB_PB_BOOL = 4
}
 
enum  lsb_read_type { LSB_READ_NIL, LSB_READ_NUMERIC, LSB_READ_STRING, LSB_READ_BOOL }
 

Functions

LSB_UTIL_EXPORT lsb_err_value lsb_init_heka_message (lsb_heka_message *m, int num_fields)
 Zero the structure and allocate memory for at least 'size' fields. More...
 
LSB_UTIL_EXPORT void lsb_free_heka_message (lsb_heka_message *m)
 Frees the memory allocated for the message fields. More...
 
LSB_UTIL_EXPORT void lsb_clear_heka_message (lsb_heka_message *m)
 Resets the message headers and fields zeroing the allocated memory. More...
 
LSB_UTIL_EXPORT bool lsb_find_heka_message (lsb_heka_message *m, lsb_input_buffer *ib, bool decode, size_t *discarded_bytes, lsb_logger *logger)
 Locates a framed Heka message in an input buffer. More...
 
LSB_UTIL_EXPORT bool lsb_decode_heka_message (lsb_heka_message *m, const char *buf, size_t len, lsb_logger *logger)
 Decodes an array of bytes into a Heka message. More...
 
LSB_UTIL_EXPORT bool lsb_read_heka_field (const lsb_heka_message *m, lsb_const_string *name, int fi, int ai, lsb_read_value *val)
 Reads a dynamic field from the Heka message. More...
 
LSB_UTIL_EXPORT lsb_err_value lsb_write_heka_uuid (lsb_output_buffer *ob, const char *uuid, size_t len)
 Writes a binary UUID to the output buffer. More...
 
LSB_UTIL_EXPORT size_t lsb_write_heka_header (char *buf, size_t len)
 Writes the Heka framing header to the specified buffer. More...
 

Detailed Description

Heka message representation.

Definition in file heka_message.h.

Macro Definition Documentation

#define LSB_ENV_VERSION   "EnvVersion"

Definition at line 32 of file heka_message.h.

#define LSB_FIELDS   "Fields"

Definition at line 35 of file heka_message.h.

#define LSB_FRAMED   "framed"

Definition at line 37 of file heka_message.h.

#define LSB_HDR_FRAME_SIZE   3

Definition at line 22 of file heka_message.h.

#define LSB_HOSTNAME   "Hostname"

Definition at line 34 of file heka_message.h.

#define LSB_LOGGER   "Logger"

Definition at line 29 of file heka_message.h.

#define LSB_MAX_HDR_SIZE   (255 + LSB_HDR_FRAME_SIZE)

Definition at line 24 of file heka_message.h.

#define LSB_MIN_HDR_SIZE   14

Definition at line 23 of file heka_message.h.

#define LSB_PAYLOAD   "Payload"

Definition at line 31 of file heka_message.h.

#define LSB_PID   "Pid"

Definition at line 33 of file heka_message.h.

#define LSB_RAW   "raw"

Definition at line 36 of file heka_message.h.

#define LSB_SEVERITY   "Severity"

Definition at line 30 of file heka_message.h.

#define LSB_SIZE   "size"

Definition at line 38 of file heka_message.h.

#define LSB_TIMESTAMP   "Timestamp"

Definition at line 27 of file heka_message.h.

#define LSB_TYPE   "Type"

Definition at line 28 of file heka_message.h.

#define LSB_UUID   "Uuid"

Definition at line 26 of file heka_message.h.

#define LSB_UUID_SIZE   16

Definition at line 20 of file heka_message.h.

#define LSB_UUID_STR_SIZE   36

Definition at line 21 of file heka_message.h.

Typedef Documentation

Enumeration Type Documentation

Enumerator
LSB_PB_NAME 
LSB_PB_VALUE_TYPE 
LSB_PB_REPRESENTATION 
LSB_PB_VALUE_STRING 
LSB_PB_VALUE_BYTES 
LSB_PB_VALUE_INTEGER 
LSB_PB_VALUE_DOUBLE 
LSB_PB_VALUE_BOOL 

Definition at line 53 of file heka_message.h.

Enumerator
LSB_PB_UUID 
LSB_PB_TIMESTAMP 
LSB_PB_TYPE 
LSB_PB_LOGGER 
LSB_PB_SEVERITY 
LSB_PB_PAYLOAD 
LSB_PB_ENV_VERSION 
LSB_PB_PID 
LSB_PB_HOSTNAME 
LSB_PB_FIELDS 

Definition at line 40 of file heka_message.h.

Enumerator
LSB_PB_STRING 
LSB_PB_BYTES 
LSB_PB_INTEGER 
LSB_PB_DOUBLE 
LSB_PB_BOOL 

Definition at line 64 of file heka_message.h.

Enumerator
LSB_READ_NIL 
LSB_READ_NUMERIC 
LSB_READ_STRING 
LSB_READ_BOOL 

Definition at line 99 of file heka_message.h.

Function Documentation

LSB_UTIL_EXPORT void lsb_clear_heka_message ( lsb_heka_message m)

Resets the message headers and fields zeroing the allocated memory.

Parameters
mHeka message structure
LSB_UTIL_EXPORT bool lsb_decode_heka_message ( lsb_heka_message m,
const char *  buf,
size_t  len,
lsb_logger logger 
)

Decodes an array of bytes into a Heka message.

The message structure is cleared before decoding.

Parameters
mHeka message structure
bufProtobuf array
lenLength of the protobuf array
loggerLogger structure (can be set to NULL to disable logging)
Returns
bool True on success
LSB_UTIL_EXPORT bool lsb_find_heka_message ( lsb_heka_message m,
lsb_input_buffer ib,
bool  decode,
size_t *  discarded_bytes,
lsb_logger logger 
)

Locates a framed Heka message in an input buffer.

Parameters
mHeka message structure
ibInput buffer
decodeTrue if the framed message should be protobuf decoded
discarded_bytesUsed to track stream corruption
loggerLogger structure (can be set to NULL to disable logging)
Returns
bool True on success
LSB_UTIL_EXPORT void lsb_free_heka_message ( lsb_heka_message m)

Frees the memory allocated for the message fields.

Parameters
mHeka message structure
LSB_UTIL_EXPORT lsb_err_value lsb_init_heka_message ( lsb_heka_message m,
int  num_fields 
)

Zero the structure and allocate memory for at least 'size' fields.

Parameters
mHeka message structure
num_fieldsPreallocated number of fields (must be >0)
Returns
lsb_err_value NULL on success error message on failure
LSB_UTIL_EXPORT bool lsb_read_heka_field ( const lsb_heka_message m,
lsb_const_string name,
int  fi,
int  ai,
lsb_read_value val 
)

Reads a dynamic field from the Heka message.

Parameters
mHeka meassage structure
nameField name
fiField index
aiArray index into the field
valValue structure to be populated by the read
Returns
bool True on success
LSB_UTIL_EXPORT size_t lsb_write_heka_header ( char *  buf,
size_t  len 
)

Writes the Heka framing header to the specified buffer.

Parameters
bufBuffer to write the header to must be at least LSB_MIN_HDR_SIZE size.
lenLength of the message to encode into the header
Returns
LSB_UTIL_EXPORT size_t
LSB_UTIL_EXPORT lsb_err_value lsb_write_heka_uuid ( lsb_output_buffer ob,
const char *  uuid,
size_t  len 
)

Writes a binary UUID to the output buffer.

Parameters
obPointer to the output data buffer.
uuidUuid string to output (can be NULL, binary, human readable UUID)
lenLength of UUID (16 or 36 anything else will cause a new UUID to be created).
Returns
lsb_err_value NULL on success error message on failure