]> git.ipfire.org Git - thirdparty/lldpd.git/commit - src/marshal.h
Add a new serialization engine.
authorVincent Bernat <bernat@luffy.cx>
Sat, 21 Jan 2012 13:42:42 +0000 (14:42 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 21 Jan 2012 18:59:56 +0000 (19:59 +0100)
commitdb3235553830b700ab5c94e11e88b3ed92714dd6
tree6e4eaa36a19935cc93af1f774d419292421aa568
parentf3324c93b10173311d99a621178d0ec9f26f6c7d
Add a new serialization engine.

The chosen approach is totally different compared to the existing
packing mechanism. Instead of describing the struct with some string
and trying to decode the structure like the compiler would do (with
alignments problem), the structure is now described by its size and
the list of pointers in it. Macros are provided to make this
easy. Here is an example:

struct struct_simpleentry {
TAILQ_ENTRY(struct_simpleentry) s_entries;
int g1;
struct struct_simple *g2;
struct struct_simple g3;
};
MARSHAL_DECLARE_BEGIN(struct_simpleentry)
MARSHAL_ADD_TQE(struct_simpleentry, s_entries)
MARSHAL_ADD_POINTER(struct_simpleentry, struct_simple, g2)
MARSHAL_ADD_SUBSTRUCT(struct_simpleentry, struct_simple, g3)
MARSHAL_DECLARE_END(struct_simpleentry);

This enables the use of pointers, with detection of circular
references and therefore support of lists.

While only pointers need to be described, it is also possible to add
sub structure to avoid specifying (again) its list of pointers if it
has already been specified.

The use of this mechanism should simplify the client/server code.
src/Makefile.am
src/lldpd.h
src/marshal.c [new file with mode: 0644]
src/marshal.h [new file with mode: 0644]
tests/Makefile.am
tests/check_marshal.c [new file with mode: 0644]