--- /dev/null
+/*
+ * BIRD Internet Routing Daemon -- MPLS Structures
+ *
+ * (c) 2022 Ondrej Zajicek <santiago@crfreenet.org>
+ * (c) 2022 CZ.NIC z.s.p.o.
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_MPLS_INTERNAL_H_
+#define _BIRD_MPLS_INTERNAL_H_
+
+#include "nest/bird.h"
+#include "lib/bitmap.h"
+#include "lib/hash.h"
+#include "nest/route.h"
+#include "nest/protocol.h"
+#include "nest/mpls.h"
+
+
+struct mpls_domain {
+ node n; /* Node in global list of MPLS domains (mpls_domains) */
+ struct mpls_domain_config *cf; /* Our config */
+ const char *name;
+ pool *pool; /* Pool for the domain and associated objects */
+
+ struct lmap labels; /* Bitmap of allocated labels */
+ uint label_count; /* Number of allocated labels */
+ uint use_count; /* Reference counter */
+
+ struct config *removed; /* Deconfigured, waiting for zero use_count,
+ while keeping config obstacle */
+
+ list ranges; /* List of label ranges (struct mpls_range) */
+ list handles; /* List of label handles (struct mpls_handle) */
+};
+
+struct mpls_range {
+ node n; /* Node in mpls_domain.ranges */
+ struct mpls_range_config *cf; /* Our config */
+ const char *name;
+
+ uint lo, hi; /* Label range interval */
+ uint label_count; /* Number of allocated labels */
+ uint use_count; /* Reference counter */
+ u8 removed; /* Deconfigured, waiting for zero use_count */
+};
+
+struct mpls_handle {
+ node n; /* Node in mpls_domain.handles */
+
+ struct mpls_range *range; /* Associated range, keeping reference */
+ uint label_count; /* Number of allocated labels */
+};
+
+uint mpls_new_label(struct mpls_domain *m, struct mpls_handle *h, uint n);
+void mpls_free_label(struct mpls_domain *m, struct mpls_handle *h, uint n);
+void mpls_move_label(struct mpls_domain *m, struct mpls_handle *fh, struct mpls_handle *th, uint n);
+
+#endif
struct mpls_range_config *dynamic_range; /* Default dynamic label range */
};
-struct mpls_domain {
- node n; /* Node in global list of MPLS domains (mpls_domains) */
- struct mpls_domain_config *cf; /* Our config */
- const char *name;
- pool *pool; /* Pool for the domain and associated objects */
-
- struct lmap labels; /* Bitmap of allocated labels */
- uint label_count; /* Number of allocated labels */
- uint use_count; /* Reference counter */
-
- struct config *removed; /* Deconfigured, waiting for zero use_count,
- while keeping config obstacle */
-
- list ranges; /* List of label ranges (struct mpls_range) */
- list handles; /* List of label handles (struct mpls_handle) */
-};
-
struct mpls_range_config {
node n; /* Node in mpls_domain_config.ranges */
struct mpls_range *range; /* Our instance */
u8 implicit; /* Implicitly defined range */
};
-struct mpls_range {
- node n; /* Node in mpls_domain.ranges */
- struct mpls_range_config *cf; /* Our config */
- const char *name;
-
- uint lo, hi; /* Label range interval */
- uint label_count; /* Number of allocated labels */
- uint use_count; /* Reference counter */
- u8 removed; /* Deconfigured, waiting for zero use_count */
-};
-
-struct mpls_handle {
- node n; /* Node in mpls_domain.handles */
-
- struct mpls_range *range; /* Associated range, keeping reference */
- uint label_count; /* Number of allocated labels */
-};
+struct mpls_handle;
void mpls_init(void);
struct mpls_range_config * mpls_range_config_new(struct mpls_domain_config *m, struct symbol *s);
void mpls_preconfig(struct config *c);
void mpls_commit(struct config *new, struct config *old);
-uint mpls_new_label(struct mpls_domain *m, struct mpls_handle *h, uint n);
-void mpls_free_label(struct mpls_domain *m, struct mpls_handle *h, uint n);
-void mpls_move_label(struct mpls_domain *m, struct mpls_handle *fh, struct mpls_handle *th, uint n);
static inline struct mpls_domain_config *cf_default_mpls_domain(struct config *cfg)
{ return EMPTY_LIST(cfg->mpls_domains) ? NULL : HEAD(cfg->mpls_domains); }