Go to the source code of this file.
Data Structures | |
struct | lwes_event_deserialize_tmp |
Storage for use when deserializing strings from events. More... | |
struct | lwes_event |
Structure representing an event. More... | |
struct | lwes_event_attribute |
Structure representing an attribute. More... | |
struct | lwes_event_enumeration |
Structure for enumerating over the values in the event. More... | |
Functions | |
lwes_event * | lwes_event_create_no_name (struct lwes_event_type_db *db) |
Create the memory for an event with no name. | |
lwes_event * | lwes_event_create (struct lwes_event_type_db *db, LWES_CONST_SHORT_STRING name) |
Create the memory for an event. | |
lwes_event * | lwes_event_create_with_encoding (struct lwes_event_type_db *db, LWES_CONST_SHORT_STRING name, LWES_INT_16 encoding) |
Create the memory for an event with encoding. | |
int | lwes_event_destroy (struct lwes_event *event) |
Cleanup the memory for an event. | |
int | lwes_event_set_name (struct lwes_event *event, LWES_CONST_SHORT_STRING name) |
Set the name of the event. | |
int | lwes_event_set_encoding (struct lwes_event *event, LWES_INT_16 encoding) |
Set the encoding of the event. | |
int | lwes_event_set_U_INT_16 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_16 value) |
Add a LWES_U_INT_16 attribute to the event. | |
int | lwes_event_set_INT_16 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_16 value) |
Add a LWES_INT_16 attribute to the event. | |
int | lwes_event_set_U_INT_32 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_32 value) |
Add a LWES_U_INT_32 attribute to the event. | |
int | lwes_event_set_INT_32 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_32 value) |
Add a LWES_INT_32 attribute to the event. | |
int | lwes_event_set_U_INT_64 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_64 value) |
Add a LWES_U_INT_64 attribute to the event. | |
int | lwes_event_set_U_INT_64_w_string (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_CONST_SHORT_STRING value) |
Add a LWES_U_INT_64 attribute to the event with a string value. | |
int | lwes_event_set_INT_64 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_64 value) |
Add a LWES_INT_64 attribute to the event. | |
int | lwes_event_set_INT_64_w_string (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_CONST_SHORT_STRING value) |
Add a LWES_INT_64 attribute to the event with a string value. | |
int | lwes_event_set_STRING (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_CONST_LONG_STRING value) |
Add an LWES_LONG_STRING attribute to the event. | |
int | lwes_event_set_IP_ADDR (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_IP_ADDR value) |
Add an LWES_IP_ADDR attribute to the event. | |
int | lwes_event_set_IP_ADDR_w_string (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_CONST_SHORT_STRING value) |
Add a LWES_IP_ADDR attribute to the event with a string value. | |
int | lwes_event_set_BOOLEAN (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_BOOLEAN value) |
Add an LWES_BOOLEAN attribute to the event. | |
int | lwes_event_get_name (struct lwes_event *event, LWES_SHORT_STRING *name) |
Get the name of the event. | |
int | lwes_event_get_number_of_attributes (struct lwes_event *event, LWES_U_INT_16 *number) |
Get the number of attributes in the event. | |
int | lwes_event_get_encoding (struct lwes_event *event, LWES_INT_16 *encoding) |
Get the encoding of the event. | |
int | lwes_event_get_U_INT_16 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_16 *value) |
Get an LWES_U_INT_16 attribute from the event. | |
int | lwes_event_get_INT_16 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_16 *value) |
Get an LWES_INT_16 attribute from the event. | |
int | lwes_event_get_U_INT_32 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_32 *value) |
Get an LWES_U_INT_32 attribute from the event. | |
int | lwes_event_get_INT_32 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_32 *value) |
Get an LWES_INT_32 attribute from the event. | |
int | lwes_event_get_U_INT_64 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_U_INT_64 *value) |
Get an LWES_U_INT_64 attribute from the event. | |
int | lwes_event_get_INT_64 (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_INT_64 *value) |
Get an LWES_INT_64 attribute from the event. | |
int | lwes_event_get_STRING (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_LONG_STRING *value) |
Get an LWES_LONG_STRING attribute to the event. | |
int | lwes_event_get_IP_ADDR (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_IP_ADDR *value) |
Get an LWES_IP_ADDR attribute from the event. | |
int | lwes_event_get_BOOLEAN (struct lwes_event *event, LWES_CONST_SHORT_STRING name, LWES_BOOLEAN *value) |
Get an LWES_BOOLEAN attribute from the event. | |
int | lwes_event_to_bytes (struct lwes_event *event, LWES_BYTE_P bytes, size_t num_bytes, size_t offset) |
Serialize an event. | |
int | lwes_event_from_bytes (struct lwes_event *event, LWES_BYTE_P bytes, size_t num_bytes, size_t offset, struct lwes_event_deserialize_tmp *dtmp) |
Deserialize an event. | |
int | lwes_event_keys (struct lwes_event *event, struct lwes_event_enumeration *enumeration) |
Start an enumeration over the keys of the event. | |
int | lwes_event_enumeration_next_element (struct lwes_event_enumeration *enumeration, LWES_CONST_SHORT_STRING *key, LWES_TYPE *type) |
Get the next element from the event. |
|
Create the memory for an event with no name. This is used when deserializing an event from a byte array
|
|
Create the memory for an event. This allocate's space for name, so you don't have to dynamically allocate the memory for it.
|
|
Create the memory for an event with encoding. This allocate's space for name, so you don't have to dynamically allocate the memory for it
|
|
Cleanup the memory for an event.
|
|
Set the name of the event. Usually only used when lwes_event_create_no_name is used. This sets the name of the event, clears the memory of previous settings, allocates new memory as necessary.
|
|
Set the encoding of the event. Note the encoding is just advisory, it is up to the user of the library to insure the encoding of strings matches what is placed here
|
|
Add a LWES_U_INT_16 attribute to the event.
|
|
Add a LWES_INT_16 attribute to the event.
|
|
Add a LWES_U_INT_32 attribute to the event.
|
|
Add a LWES_INT_32 attribute to the event.
|
|
Add a LWES_U_INT_64 attribute to the event.
|
|
Add a LWES_U_INT_64 attribute to the event with a string value. Internally converts the string to an LWES_U_INT_64
|
|
Add a LWES_INT_64 attribute to the event.
|
|
Add a LWES_INT_64 attribute to the event with a string value. Internally converts the string to an LWES_INT_64
|
|
Add an LWES_LONG_STRING attribute to the event.
|
|
Add an LWES_IP_ADDR attribute to the event.
|
|
Add a LWES_IP_ADDR attribute to the event with a string value. The string should be of the form xxx.xxx.xxx.xxx, in other words dotted quad notation. Internally converts the string from a dotted quad string to an LWES_IP_ADDR.
|
|
Add an LWES_BOOLEAN attribute to the event.
|
|
Get the name of the event.
|
|
Get the number of attributes in the event.
|
|
Get the encoding of the event. Note the encoding is just advisory, it is up to the user of the library to insure the encoding of strings matches what is placed here
|
|
Get an LWES_U_INT_16 attribute from the event.
|
|
Get an LWES_INT_16 attribute from the event.
|
|
Get an LWES_U_INT_32 attribute from the event.
|
|
Get an LWES_INT_32 attribute from the event.
|
|
Get an LWES_U_INT_64 attribute from the event.
|
|
Get an LWES_INT_64 attribute from the event.
|
|
Get an LWES_LONG_STRING attribute to the event.
|
|
Get an LWES_IP_ADDR attribute from the event.
|
|
Get an LWES_BOOLEAN attribute from the event.
|
|
Serialize an event. Serialization format is
1 byte event name length ( 1 < b <= 255 ) b bytes 2 bytes num_attributes ( 0 < n < 65535, 65535 is a theoretical limit ) foreach attribute 1 byte attribute name length ( 1 < a <= 255 ) a bytes of attribute name 1 byte type id n bytes data
We want to determine the maximum possible number of attributes ( the real upper bound on n above ).
So we need to minimize all the fields,
Event name = 1 byte of length + 1 byte of data = 2 bytes Num Attributes = 2 bytes
So the minimum is 4 bytes, that leaves 65531 to play with
For attributes,
minimum attribute length = (minimum attr name length = 1 byte) + (minimum attr name value, given minimum length= 1 byte) + (type id length = 1 byte) + (minimum size of attribute);
Where
minimum size boolean attribute = 1 byte minimum size uint16 attribute = 2 bytes minimum size int16 attribute = 2 bytes minimum size uint32 attribute = 4 bytes minimum size int32 attribute = 4 bytes minimum size uint64 attribute = 8 bytes minimum size int64 attribute = 8 bytes minimum size ipaddr attribute = 4 bytes minimum size string attribute = 2 bytes length + 1 byte data = 3 bytes
so
minimum boolean attribute = 4 byte minimum uint16 attribute = 5 bytes minimum int16 attribute = 5 bytes minimum uint32 attribute = 7 bytes minimum int32 attribute = 7 bytes minimum uint64 attribute = 11 bytes minimum int64 attribute = 11 bytes minimum ipaddr attribute = 7 bytes minimum string attribute = 6 bytes
If attribute names are allowed to be duplicated for a type, then the maximum number of attributes is
floor ( (65535 - 4) / 4) = 16382
However, attribute names are not allowed to be duplicated for any one type, so that puts a cap of 254, 1 non-zero byte attribute names ( 1 -> 255 ) for a single type, this means the actual number of attributes is actually less.
To maximally pack attributes we would start with the smallest in terms of number of bytes, then work our way upward calculating the number of attributes of a certain attribute name length of the smallest current type, so to start the chain
4 bytes overhead = 4
1 byte attribute booleans 254*4 = 1016
2 byte attribute booleans 254*5 = 1270 1 byte attribute uint16 254*5 = 1270 1 byte attribute int16 254*5 = 1270
1 byte attribute string 254*6 = 1524 3 byte attribute booleans 254*6 = 1524 2 byte attribute uint16 254*6 = 1524 2 byte attribute int16 254*6 = 1524
1 byte attribute uint32 254*7 = 1778 1 byte attribute int32 254*7 = 1778 2 byte attribute string 254*7 = 1778 4 byte attribute booleans 254*7 = 1778 3 byte attribute uint16 254*7 = 1778 3 byte attribute int16 254*7 = 1778 1 byte attribute ipaddr 254*7 = 1778
2 byte attribute uint32 254*8 = 2032 2 byte attribute int32 254*8 = 2032 3 byte attribute string 254*8 = 2032 5 byte attribute booleans 254*8 = 2032 4 byte attribute uint16 254*8 = 2032 4 byte attribute int16 254*8 = 2032 2 byte attribute ipaddr 254*8 = 2032
3 byte attribute uint32 254*9 = 2286 3 byte attribute int32 254*9 = 2286 4 byte attribute string 254*9 = 2286 6 byte attribute booleans 254*9 = 2286 5 byte attribute uint16 254*9 = 2286 5 byte attribute int16 254*9 = 2286 3 byte attribute ipaddr 254*9 = 2286
4 byte attribute uint32 254*10 = 2540 4 byte attribute int32 254*10 = 2540 5 byte attribute string 254*10 = 2540 7 byte attribute booleans 254*10 = 2540
6 byte attribute uint16 177*10 = 1770
7 bytes left over = 7
total attrs = 33 * 254 + 177 = 8559
|
|
Deserialize an event.
|
|
Start an enumeration over the keys of the event. The pattern for enumerating is as follows struct lwes_event_enumeration e; if (lwes_event_keys (event, &e)) { LWES_CONST_SHORT_STRING key; LWES_TYPE type; while (lwes_event_enumeration_next_element (&e, &key, &type)) { switch (type) { case LWES_TYPE_U_INT_16: { LWES_U_INT_16 value; lwes_event_get_U_INT_16 (event, key, &value); } break; // ... cases for rest of types } } }
|
|
Get the next element from the event.
|