Guardtime KSI c SDK
|
Data Structures | |
struct | KSI_TlvTemplate_st |
Macros | |
#define | KSI_TLV_TEMPLATE(name) name##_template |
#define | KSI_IMPORT_TLV_TEMPLATE(name) KSI_DEFINE_EXTERN(const KSI_TlvTemplate KSI_TLV_TEMPLATE(name)[]) |
#define | KSI_TLV_TEMPLATE_OBJECT 1 |
#define | KSI_TLV_TEMPLATE_COMPOSITE 2 |
#define | KSI_TLV_TEMPLATE_LIST 3 |
#define | KSI_TLV_TMPL_FLG_NONE 0x00 |
#define | KSI_TLV_TMPL_FLG_FORWARD 0x01 |
#define | KSI_TLV_TMPL_FLG_NONCRITICAL 0x02 |
#define | KSI_TLV_TMPL_FLG_MANDATORY 0x04 |
#define | KSI_TLV_TMPL_FLG_LEAST_ONE_G0 0x08 |
#define | KSI_TLV_TMPL_FLG_LEAST_ONE_G1 0x10 |
#define | KSI_TLV_TMPL_FLG_MORE_DEFS 0x20 |
#define | KSI_TLV_TMPL_FLG_NO_SERIALIZE 0x40 |
#define | KSI_TLV_TMPL_FLG_MOST_ONE_G0 0x80 |
#define | KSI_TLV_TMPL_FLG_MOST_ONE_G1 0x100 |
#define | KSI_TLV_TMPL_FLG_FIXED_ORDER 0x200 |
#define | KSI_TLV_TMPL_FLG_FIRST 0x400 |
#define | KSI_TLV_TMPL_FLG_LAST 0x800 |
#define | KSI_TLV_TMPL_FLG_NO_VALUE 0x1000 |
#define | KSI_TLV_TMPL_FLG_MANTATORY_MOST_ONE_G0 (KSI_TLV_TMPL_FLG_LEAST_ONE_G0 | KSI_TLV_TMPL_FLG_MOST_ONE_G0) |
#define | KSI_TLV_TMPL_FLG_MANTATORY_MOST_ONE_G1 (KSI_TLV_TMPL_FLG_LEAST_ONE_G1 | KSI_TLV_TMPL_FLG_MOST_ONE_G1) |
#define | KSI_TLV_FULL_TEMPLATE_DEF(typ, tg, flg, gttr, sttr, constr, destr, subTmpl, list_append, mul, list_new, list_free, list_len, list_elAt, fromTlv, toTlv, descr, parser, p_opt, setRaw) |
#define | KSI_TLV_PRIMITIVE_TEMPLATE_DEF(typ, tg, flg, gttr, sttr, descr) KSI_TLV_FULL_TEMPLATE_DEF(typ, tg, flg, gttr, sttr, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, descr, NULL, 0, NULL) |
#define | KSI_DEFINE_TLV_TEMPLATE(name) const KSI_TlvTemplate name##_template[] = { |
#define | KSI_TLV_OBJECT(tg, flg, gttr, sttr, fromTlv, toTlv, destr, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, NULL, NULL, 0, NULL, NULL, NULL, NULL, fromTlv, toTlv, descr, NULL, 0, NULL) |
#define | KSI_TLV_WRAP_OBJECT(tg, flg, gttr, sttr, parser, toTlv, destr, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, toTlv, descr, (parser), 0, NULL) |
#define | KSI_TLV_COMPOSITE_OBJECT(tg, flg, gttr, sttr, fromTlv, toTlv, destr, tmpl, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, (tmpl), NULL, 0, NULL, NULL, NULL, NULL, fromTlv, toTlv, descr, NULL, 0, NULL) |
#define | KSI_TLV_UTF8_STRING(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_Utf8String_fromTlv, KSI_Utf8String_toTlv, KSI_Utf8String_free, descr) |
#define | KSI_TLV_INTEGER(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_Integer_fromTlv, KSI_Integer_toTlv, KSI_Integer_free, descr) |
#define | KSI_TLV_OCTET_STRING(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_OctetString_fromTlv, KSI_OctetString_toTlv, KSI_OctetString_free, descr) |
#define | KSI_TLV_IMPRINT(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_DataHash_fromTlv, KSI_DataHash_toTlv, KSI_DataHash_free, descr) |
#define | KSI_TLV_WRAP_IMPRINT(tg, flg, gttr, sttr, descr) KSI_TLV_WRAP_OBJECT(tg, flg, gttr, sttr, KSI_DataHash_parse, KSI_DataHash_toTlv, KSI_DataHash_free, descr) |
#define | KSI_TLV_TIME_S KSI_TLV_INTEGER |
#define | KSI_TLV_TIME_US KSI_TLV_INTEGER |
#define | KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, obj, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, obj##_free, NULL, KSI_List_append, 1, obj##List_new, obj##List_free, KSI_List_length, KSI_List_elementAt, obj##_fromTlv, obj##_toTlv, descr, NULL, 0, NULL) |
#define | KSI_TLV_OCTET_STRING_LIST(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_OctetString, descr) |
#define | KSI_TLV_UTF8_STRING_LIST(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_Utf8String, descr) |
#define | KSI_TLV_INTEGER_LIST(tg, flg, gttr, sttr, descr) KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_Integer, descr) |
#define | KSI_TLV_COMPOSITE(tg, flg, gttr, sttr, sub, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_COMPOSITE, tg, flg, gttr, sttr, sub##_new, sub##_free, sub##_template, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, descr, NULL, 0, NULL) |
#define | KSI_TLV_COMPOSITE_LIST(tg, flg, gttr, sttr, sub, descr) KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_COMPOSITE, tg, flg, gttr, sttr, sub##_new, sub##_free, sub##_template, KSI_List_append, 1, sub##List_new, sub##List_free, KSI_List_length, KSI_List_elementAt, NULL, NULL, descr, NULL, 0, NULL) |
#define | KSI_END_TLV_TEMPLATE { -1, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL}}; |
#define | KSI_IMPLEMENT_OBJECT_PARSE(type, tag) |
#define | KSI_IMPLEMENT_OBJECT_SERIALIZE(type, tag, nc, fwd) |
#define | KSI_IMPLEMENT_WRITE_BYTES(typ, tag, nc, fwd) |
Typedefs | |
typedef int(* | getter_t) (const void *, void **) |
typedef int(* | setter_t) (void *, void *) |
typedef int(* | cb_decode_t) (KSI_CTX *ctx, const KSI_TLV *, void *, const KSI_TlvTemplate *) |
typedef int(* | cb_encode_t) (KSI_CTX *, KSI_TLV *, const void *, const KSI_TlvTemplate *) |
typedef int(* | parse_t) (KSI_CTX *, unsigned char *, size_t, int, void *) |
Functions | |
int | KSI_TlvTemplate_extract (KSI_CTX *ctx, void *payload, KSI_TLV *tlv, const KSI_TlvTemplate *tmpl) |
int | KSI_TlvTemplate_parse (KSI_CTX *ctx, const unsigned char *raw, size_t raw_len, const KSI_TlvTemplate *tmpl, void *payload) |
int | KSI_TlvTemplate_extractGenerator (KSI_CTX *ctx, void *payload, void *generatorCtx, const KSI_TlvTemplate *tmpl, int(*generator)(void *, KSI_TLV **)) |
int | KSI_TlvTemplate_construct (KSI_CTX *ctx, KSI_TLV *tlv, const void *payload, const KSI_TlvTemplate *tmpl) |
int | KSI_TlvTemplate_serializeObject (KSI_CTX *ctx, const void *obj, unsigned tag, int isNc, int isFwd, const KSI_TlvTemplate *tmpl, unsigned char **raw, size_t *raw_len) |
int | KSI_TlvTemplate_writeBytes (KSI_CTX *ctx, const void *obj, unsigned tag, int isNc, int isFwd, const KSI_TlvTemplate *tmpl, unsigned char *raw, size_t raw_size, size_t *raw_len, int opt) |
The TLV templates are used to convert plain c structs into KSI_TLV object trees and back.
#define KSI_DEFINE_TLV_TEMPLATE | ( | name | ) | const KSI_TlvTemplate name##_template[] = { |
This macro starts a KSI_TlvTemplate definition. The definition is ended with KSI_END_TLV_TEMPLATE .
[in] | name | Template name - recommended to use the object type name. |
#define KSI_END_TLV_TEMPLATE { -1, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL}}; |
This macro ends the KSI_TlvTemplate definition started by KSI_TLV_TEMPLATE.
#define KSI_IMPLEMENT_OBJECT_PARSE | ( | type, | |
tag | |||
) |
Macro to generate object parsers.
[in] | type | Type name. |
[in] | tag | Tag of the concrete TLV. |
#define KSI_IMPLEMENT_OBJECT_SERIALIZE | ( | type, | |
tag, | |||
nc, | |||
fwd | |||
) |
Macro to generate object serializer.
[in] | type | Type name. |
[in] | tag | Tag of the concrete TLV. |
[in] | nc | Non-critical flag. |
[in] | fwd | Forward flag. |
#define KSI_IMPLEMENT_WRITE_BYTES | ( | typ, | |
tag, | |||
nc, | |||
fwd | |||
) |
#define KSI_IMPORT_TLV_TEMPLATE | ( | name | ) | KSI_DEFINE_EXTERN(const KSI_TlvTemplate KSI_TLV_TEMPLATE(name)[]) |
This macro is used to import predefined templates.
#define KSI_TLV_COMPOSITE | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
sub, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_COMPOSITE, tg, flg, gttr, sttr, sub##_new, sub##_free, sub##_template, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, descr, NULL, 0, NULL) |
TLV template for composite objects.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | sub | Composite element template. |
[in] | descr | Short description. |
#define KSI_TLV_COMPOSITE_LIST | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
sub, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_COMPOSITE, tg, flg, gttr, sttr, sub##_new, sub##_free, sub##_template, KSI_List_append, 1, sub##List_new, sub##List_free, KSI_List_length, KSI_List_elementAt, NULL, NULL, descr, NULL, 0, NULL) |
TLV template for list of composite objects.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | sub | Composite element template. |
[in] | descr | Short description. |
#define KSI_TLV_COMPOSITE_OBJECT | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
fromTlv, | |||
toTlv, | |||
destr, | |||
tmpl, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, (tmpl), NULL, 0, NULL, NULL, NULL, NULL, fromTlv, toTlv, descr, NULL, 0, NULL) |
#define KSI_TLV_FULL_TEMPLATE_DEF | ( | typ, | |
tg, | |||
flg, | |||
gttr, | |||
sttr, | |||
constr, | |||
destr, | |||
subTmpl, | |||
list_append, | |||
mul, | |||
list_new, | |||
list_free, | |||
list_len, | |||
list_elAt, | |||
fromTlv, | |||
toTlv, | |||
descr, | |||
parser, | |||
p_opt, | |||
setRaw | |||
) |
A helper macro for defining a single template with all parameters.
[in] | typ | Template internal type. |
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | constr | Constructor function. |
[in] | destr | Destructor function. |
[in] | subTmpl | Sub-template. |
[in] | list_append | List append function. |
[in] | mul | Are multiple values allowed inside a single TLV? |
[in] | list_new | List object constructor function. |
[in] | list_free | List object destructor function. |
[in] | list_len | List length function. |
[in] | list_elAt | List elements random access function. |
[in] | fromTlv | Create object from TLV function. |
[in] | toTlv | Create TLV from object function. |
[in] | descr | Short description. |
[in] | parser | Create object from raw data. |
[in] | p_opt | Parser option. |
[in] | setRaw | Not used. |
#define KSI_TLV_IMPRINT | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_DataHash_fromTlv, KSI_DataHash_toTlv, KSI_DataHash_free, descr) |
TLV template for KSI_DataHash type.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_INTEGER | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_Integer_fromTlv, KSI_Integer_toTlv, KSI_Integer_free, descr) |
TLV template for KSI_Integer type.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_INTEGER_LIST | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_Integer, descr) |
TLV template for list of KSI_Integer types.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_OBJECT | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
fromTlv, | |||
toTlv, | |||
destr, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, NULL, NULL, 0, NULL, NULL, NULL, NULL, fromTlv, toTlv, descr, NULL, 0, NULL) |
Generic TLV template for objects for which fromTlv
and toTlv
functions are defined.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | fromTlv | Function to create the object from TLV. |
[in] | toTlv | Function to create a TLV from the object. |
[in] | destr | Destructor function pointer. |
[in] | descr | Short description. |
#define KSI_TLV_OBJECT_LIST | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
obj, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, obj##_free, NULL, KSI_List_append, 1, obj##List_new, obj##List_free, KSI_List_length, KSI_List_elementAt, obj##_fromTlv, obj##_toTlv, descr, NULL, 0, NULL) |
Generic object list template. The obj
parameter may be only a type for which there is a list type defined (see KSI_DEFINE_LIST and KSI_IMPLEMENT_LIST).
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | obj | Type of object stored in the list. |
[in] | descr | Short description. |
#define KSI_TLV_OCTET_STRING | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_OctetString_fromTlv, KSI_OctetString_toTlv, KSI_OctetString_free, descr) |
TLV template for KSI_OctetString type.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_OCTET_STRING_LIST | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_OctetString, descr) |
TLV template for list of KSI_OctetString types.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_PRIMITIVE_TEMPLATE_DEF | ( | typ, | |
tg, | |||
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(typ, tg, flg, gttr, sttr, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, descr, NULL, 0, NULL) |
A helper macro for defining primitive templates.
[in] | typ | Template internal type. |
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_TEMPLATE | ( | name | ) | name##_template |
Derive template actual object name.
[in] | name | Template name. |
#define KSI_TLV_TEMPLATE_COMPOSITE 2 |
Composite (a nested TLV) KSI_TlvTemplate type.
#define KSI_TLV_TEMPLATE_LIST 3 |
List KSI_TlvTemplate type.
#define KSI_TLV_TEMPLATE_OBJECT 1 |
Generic KSI_TlvTemplate type.
#define KSI_TLV_TIME_S KSI_TLV_INTEGER |
TLV templates for time representation
#define KSI_TLV_TIME_US KSI_TLV_INTEGER |
#define KSI_TLV_TMPL_FLG_FIRST 0x400 |
Element with this flag enabled, if present, must be the first element.
#define KSI_TLV_TMPL_FLG_FIXED_ORDER 0x200 |
All the sub elements with this flag enabled may be present in the TLV only in the same order as they appear in the template.
#define KSI_TLV_TMPL_FLG_FORWARD 0x01 |
Should the template be forwarded if it is unknown for the parser?
#define KSI_TLV_TMPL_FLG_LAST 0x800 |
Element with this flag enabled, if present, must be the last element.
#define KSI_TLV_TMPL_FLG_LEAST_ONE_G0 0x08 |
At least one TLV of the group 0 should be present.
#define KSI_TLV_TMPL_FLG_LEAST_ONE_G1 0x10 |
At least one TLV of the group 1 should be present.
#define KSI_TLV_TMPL_FLG_MANDATORY 0x04 |
Is this TLV object mandatory?.
#define KSI_TLV_TMPL_FLG_MANTATORY_MOST_ONE_G0 (KSI_TLV_TMPL_FLG_LEAST_ONE_G0 | KSI_TLV_TMPL_FLG_MOST_ONE_G0) |
One and only one of the group 0 must be present.
#define KSI_TLV_TMPL_FLG_MANTATORY_MOST_ONE_G1 (KSI_TLV_TMPL_FLG_LEAST_ONE_G1 | KSI_TLV_TMPL_FLG_MOST_ONE_G1) |
One and only one of the group 1 must be present.
#define KSI_TLV_TMPL_FLG_MORE_DEFS 0x20 |
This flags specifies that there can be more definitions for parsing the TLV. If this flag is not set, the remaining templates are not searched.
#define KSI_TLV_TMPL_FLG_MOST_ONE_G0 0x80 |
None or at most one TLV in the group 0 may be present.
#define KSI_TLV_TMPL_FLG_MOST_ONE_G1 0x100 |
None or at most one TLV in the group 1 may be present.
#define KSI_TLV_TMPL_FLG_NO_SERIALIZE 0x40 |
This flag prevents the serialization.
#define KSI_TLV_TMPL_FLG_NO_VALUE 0x1000 |
Element with this flag enabled does not have any payload.
#define KSI_TLV_TMPL_FLG_NONCRITICAL 0x02 |
Is the TLV non-critical i.e should it be an error if this TLV is unknown to the parser?
#define KSI_TLV_TMPL_FLG_NONE 0x00 |
Empty placeholder for a template with no flags set.
#define KSI_TLV_UTF8_STRING | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT(tg, flg, gttr, sttr, KSI_Utf8String_fromTlv, KSI_Utf8String_toTlv, KSI_Utf8String_free, descr) |
TLV template for KSI_Utf8String type.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_UTF8_STRING_LIST | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_OBJECT_LIST(tg, flg, gttr, sttr, KSI_Utf8String, descr) |
TLV template for list of KSI_Utf8String types.
[in] | tg | TLV tag value. |
[in] | flg | Flags for the template. |
[in] | gttr | Getter function. |
[in] | sttr | Setter function. |
[in] | descr | Short description. |
#define KSI_TLV_WRAP_IMPRINT | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
descr | |||
) | KSI_TLV_WRAP_OBJECT(tg, flg, gttr, sttr, KSI_DataHash_parse, KSI_DataHash_toTlv, KSI_DataHash_free, descr) |
#define KSI_TLV_WRAP_OBJECT | ( | tg, | |
flg, | |||
gttr, | |||
sttr, | |||
parser, | |||
toTlv, | |||
destr, | |||
descr | |||
) | KSI_TLV_FULL_TEMPLATE_DEF(KSI_TLV_TEMPLATE_OBJECT, tg, flg, gttr, sttr, NULL, destr, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, toTlv, descr, (parser), 0, NULL) |
typedef int(* cb_decode_t) (KSI_CTX *ctx, const KSI_TLV *, void *, const KSI_TlvTemplate *) |
Generic decode function type.
typedef int(* cb_encode_t) (KSI_CTX *, KSI_TLV *, const void *, const KSI_TlvTemplate *) |
Generic encode function type.
typedef int(* getter_t) (const void *, void **) |
Generic value getter function type.
typedef int(* parse_t) (KSI_CTX *, unsigned char *, size_t, int, void *) |
typedef int(* setter_t) (void *, void *) |
Generic value setter function type.
int KSI_TlvTemplate_construct | ( | KSI_CTX * | ctx, |
KSI_TLV * | tlv, | ||
const void * | payload, | ||
const KSI_TlvTemplate * | tmpl | ||
) |
Given a payload object, template and a initialized target TLV, this function constructs a TLV using the template and the values from the payload.
[in] | ctx | KSI context. |
[in] | tlv | An empty target TLV. |
[in] | payload | Evaluated payload. |
[in] | tmpl | Template of the TLV expected structure. |
int KSI_TlvTemplate_extract | ( | KSI_CTX * | ctx, |
void * | payload, | ||
KSI_TLV * | tlv, | ||
const KSI_TlvTemplate * | tmpl | ||
) |
Given a TLV object, template and a initialized target payload, this function evaluates the payload objects with the data from the TLV.
[in] | ctx | KSI context. |
[in] | payload | Preinitialized empty object to be evaluated with the TLV values. |
[in] | tlv | TLV value which has the structure represented in template . |
[in] | tmpl | Template of the TLV expected structure. |
KSI_OK
, when operation succeeded, otherwise an error code). int KSI_TlvTemplate_extractGenerator | ( | KSI_CTX * | ctx, |
void * | payload, | ||
void * | generatorCtx, | ||
const KSI_TlvTemplate * | tmpl, | ||
int(*)(void *, KSI_TLV **) | generator | ||
) |
This function acts similarly as KSI_TlvTemplate_extract but allows the caller to specify how the top level TLV's are retrieved (e.g. read from a file).
[in] | ctx | KSI context. |
[in] | payload | Preinitialized empty object to be evaluated with the TLV values. |
[in] | generatorCtx | Context for the generator. |
[in] | tmpl | Template of the TLV expected structure. |
[in] | generator | Generator function. The generatorCtx is passed as the first parameter and a KSI_TLV object is expected to be returned by the second parameter - a NULL value is interpreted as end of input. The function is expected to return KSI_OK on success. |
KSI_OK
, when operation succeeded, otherwise an error code). int KSI_TlvTemplate_parse | ( | KSI_CTX * | ctx, |
const unsigned char * | raw, | ||
size_t | raw_len, | ||
const KSI_TlvTemplate * | tmpl, | ||
void * | payload | ||
) |
Parses a given raw data into a pre-existing element. The caller needs to know the outcome type and create it.
[in] | ctx | KSI context. |
[in] | raw | Pointer to the raw data. |
[in] | raw_len | Length of the raw data. |
[in] | tmpl | Template. |
[in] | payload | Pointer to the payload which will be populated with the parsed data. |
KSI_OK
, when operation succeeded, otherwise an error code). int KSI_TlvTemplate_serializeObject | ( | KSI_CTX * | ctx, |
const void * | obj, | ||
unsigned | tag, | ||
int | isNc, | ||
int | isFwd, | ||
const KSI_TlvTemplate * | tmpl, | ||
unsigned char ** | raw, | ||
size_t * | raw_len | ||
) |
Serializes an object using KSI_TlvTemplate.
[in] | ctx | KSI context. |
[in] | obj | Object to be serialized. |
[in] | tag | Tag of the serialized object. |
[in] | isNc | TLV flag is-non-critical. |
[in] | isFwd | TLV flag is-forward. |
[in] | tmpl | Template to be used. |
[out] | raw | Pointer to the receiving pointer to the serialized value. |
[out] | raw_len | Length of the serialized value. |
int KSI_TlvTemplate_writeBytes | ( | KSI_CTX * | ctx, |
const void * | obj, | ||
unsigned | tag, | ||
int | isNc, | ||
int | isFwd, | ||
const KSI_TlvTemplate * | tmpl, | ||
unsigned char * | raw, | ||
size_t | raw_size, | ||
size_t * | raw_len, | ||
int | opt | ||
) |
This function serializes the given object based on the template.
[in] | ctx | KSI context. |
[in] | obj | Object to be serialized. |
[in] | tag | Tag of the outer TLV. |
[in] | isNc | Flag of the outer TLV: is non-critical |
[in] | isFwd | Flag of the outer TLV: is forward |
[in] | tmpl | Template |
[in] | raw | Pointer to target buffer |
[in] | raw_size | Size of the target buffer |
[out] | raw_len | Length of the serialization. |
[in] | opt | Options. |