summaryrefslogtreecommitdiff
path: root/lib/attrs.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-30 16:21:48 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-30 16:21:48 +0200
commit0097f24e2e8b3feb56d4ae5c5b56a8defd9f7d2e (patch)
tree501f4338c51b61362e31b3da8e39f48b2069f028 /lib/attrs.h
parent86ac1045d7497af8c7556c5051d4b005fbfcdbe1 (diff)
parentde86040b2cf4ec9bfbb64f0e208a19d4d7e51adc (diff)
Merge commit 'de86040b2cf4ec9bfbb64f0e208a19d4d7e51adc' into haugesund
Diffstat (limited to 'lib/attrs.h')
-rw-r--r--lib/attrs.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/attrs.h b/lib/attrs.h
index e0595846..fcb70230 100644
--- a/lib/attrs.h
+++ b/lib/attrs.h
@@ -11,7 +11,35 @@
#include <stdint.h>
#include "lib/unaligned.h"
-#include "lib/route.h"
+
+typedef struct adata {
+ uint length; /* Length of data */
+ byte data[0];
+} adata;
+
+#define ADATA_SIZE(s) BIRD_CPU_ALIGN(sizeof(struct adata) + s)
+
+extern const adata null_adata; /* adata of length 0 */
+
+static inline struct adata *
+lp_alloc_adata(struct linpool *pool, uint len)
+{
+ struct adata *ad = lp_alloc(pool, sizeof(struct adata) + len);
+ ad->length = len;
+ return ad;
+}
+
+static inline struct adata *
+lp_store_adata(struct linpool *pool, const void *buf, uint len)
+{
+ struct adata *ad = lp_alloc_adata(pool, len);
+ memcpy(ad->data, buf, len);
+ return ad;
+}
+
+static inline int adata_same(const struct adata *a, const struct adata *b)
+{ return (a->length == b->length && !memcmp(a->data, b->data, a->length)); }
+
/* a-path.c */