summaryrefslogtreecommitdiff
path: root/lib/srv6.h
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2021-06-04 13:41:55 -0400
committerGitHub <noreply@github.com>2021-06-04 13:41:55 -0400
commite4768d32b82f0054192f1bf1a455f5fd4e5d895e (patch)
tree7f16a15f33ce2356bf013dad4ac8eb82c0e25576 /lib/srv6.h
parentdd553fb39b02cd4391d50ffb84b45da7248906ed (diff)
parent2ba6be5b24c9c572d167248004fb1e3c4b57e0a2 (diff)
Merge pull request #5865 from slankdev/slankdev-zebra-srv6-manager
zebra: srv6 manager
Diffstat (limited to 'lib/srv6.h')
-rw-r--r--lib/srv6.h70
1 files changed, 67 insertions, 3 deletions
diff --git a/lib/srv6.h b/lib/srv6.h
index 24c7ffc3a2..715fc3723b 100644
--- a/lib/srv6.h
+++ b/lib/srv6.h
@@ -21,10 +21,14 @@
#define _FRR_SRV6_H
#include <zebra.h>
+#include "prefix.h"
+#include "json.h"
+
#include <arpa/inet.h>
#include <netinet/in.h>
#define SRV6_MAX_SIDS 16
+#define SRV6_LOCNAME_SIZE 256
#ifdef __cplusplus
extern "C" {
@@ -69,6 +73,59 @@ struct seg6local_context {
uint32_t table;
};
+struct srv6_locator {
+ char name[SRV6_LOCNAME_SIZE];
+ struct prefix_ipv6 prefix;
+
+ /*
+ * Bit length of SRv6 locator described in
+ * draft-ietf-bess-srv6-services-05#section-3.2.1
+ */
+ uint8_t block_bits_length;
+ uint8_t node_bits_length;
+ uint8_t function_bits_length;
+ uint8_t argument_bits_length;
+
+ int algonum;
+ uint64_t current;
+ bool status_up;
+ struct list *chunks;
+
+ QOBJ_FIELDS;
+};
+DECLARE_QOBJ_TYPE(srv6_locator);
+
+struct srv6_locator_chunk {
+ char locator_name[SRV6_LOCNAME_SIZE];
+ struct prefix_ipv6 prefix;
+
+ /*
+ * Bit length of SRv6 locator described in
+ * draft-ietf-bess-srv6-services-05#section-3.2.1
+ */
+ uint8_t block_bits_length;
+ uint8_t node_bits_length;
+ uint8_t function_bits_length;
+ uint8_t argument_bits_length;
+
+ /*
+ * For Zclient communication values
+ */
+ uint8_t keep;
+ uint8_t proto;
+ uint16_t instance;
+ uint32_t session_id;
+};
+
+struct nexthop_srv6 {
+ /* SRv6 localsid info for Endpoint-behaviour */
+ enum seg6local_action_t seg6local_action;
+ struct seg6local_context seg6local_ctx;
+
+ /* SRv6 Headend-behaviour */
+ struct in6_addr seg6_segs;
+};
+
static inline const char *seg6_mode2str(enum seg6_mode_t mode)
{
switch (mode) {
@@ -119,13 +176,20 @@ static inline void *sid_copy(struct in6_addr *dst,
const char *
seg6local_action2str(uint32_t action);
-const char *
-seg6local_context2str(char *str, size_t size,
- struct seg6local_context *ctx, uint32_t action);
+const char *seg6local_context2str(char *str, size_t size,
+ const struct seg6local_context *ctx,
+ uint32_t action);
int snprintf_seg6_segs(char *str,
size_t size, const struct seg6_segs *segs);
+extern struct srv6_locator *srv6_locator_alloc(const char *name);
+extern struct srv6_locator_chunk *srv6_locator_chunk_alloc(void);
+extern void srv6_locator_free(struct srv6_locator *locator);
+extern void srv6_locator_chunk_free(struct srv6_locator_chunk *chunk);
+json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk);
+json_object *srv6_locator_json(const struct srv6_locator *loc);
+
#ifdef __cplusplus
}
#endif