summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-31 19:55:59 +0100
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2017-01-31 20:36:18 +0100
commit988355d5bb62405f3bd3fbaade1f26ba4b2c274e (patch)
tree7406c71252aef416061e255d41352b105afbeac5 /include
parent45a8dd4ccb3874c411dac287cf7ce862f051aa14 (diff)
downloadouroboros-988355d5bb62405f3bd3fbaade1f26ba4b2c274e.tar.gz
ouroboros-988355d5bb62405f3bd3fbaade1f26ba4b2c274e.zip
lib: Add packing and unpacking RIB
The rib_pack function allows packing a subtree of the RIB for dissemination. The options PACK_HASH_ROOT and PACK_HASH_ALL will add the hashes for the root object of the packed subtree or every object to the packed message respectively. Checking of the hashes is currently only performed at the top level object, verifying the complete operation. The rib_unpack function unpacks a packed message and inserts its contents in the RIB. The option UNPACK_CREATE flags that the unpack operation is allowed to create new objects, else it will only update existing objects. More advanced options could be added in the future. The packed message structure uses Google Protocol Buffers, as defined in ro.proto. It adds tests for these functions to the rib_test.
Diffstat (limited to 'include')
-rw-r--r--include/ouroboros/rib.h54
1 files changed, 34 insertions, 20 deletions
diff --git a/include/ouroboros/rib.h b/include/ouroboros/rib.h
index 1d0661a7..50747498 100644
--- a/include/ouroboros/rib.h
+++ b/include/ouroboros/rib.h
@@ -25,40 +25,54 @@
#define OUROBOROS_LIB_RIB_H
#include <sys/types.h>
+#include <stdint.h>
#include <stdbool.h>
#define RIB_ROOT ""
-int rib_init(void);
+#define PACK_HASH_ROOT 0x0001
+#define PACK_HASH_ALL 0x0002
-void rib_fini(void);
+#define UNPACK_CREATE 0x0001
-int rib_add(const char * parent,
- const char * name);
+int rib_init(void);
-int rib_del(char * path);
+void rib_fini(void);
-ssize_t rib_read(const char * path,
- void * data,
- size_t len);
+int rib_add(const char * parent,
+ const char * name);
-int rib_write(const char * path,
- const void * data,
+int rib_del(char * path);
+
+ssize_t rib_read(const char * path,
+ void * data,
+ size_t len);
+
+int rib_write(const char * path,
+ const void * data,
+ size_t len);
+
+int rib_put(const char * path,
+ void * data,
size_t len);
-int rib_put(const char * path,
- void * data,
- size_t len);
+bool rib_has(const char * path);
+
+ssize_t rib_children(const char * path,
+ char *** children);
-bool rib_has(const char * path);
+char * rib_path_append(char * path,
+ const char * name);
-ssize_t rib_children(const char * path,
- char *** children);
+char * rib_name_gen(void * data,
+ size_t len);
-char * rib_path_append(char * path,
- const char * name);
+ssize_t rib_pack(const char * path,
+ uint8_t ** buf,
+ uint32_t flags);
-char * rib_name_gen(void * data,
- size_t len);
+int rib_unpack(uint8_t * packed,
+ size_t len,
+ uint32_t flags);
#endif /* OUROBOROS_LIB_RIB_H */