diff --git a/nest/mpls-internal.h b/nest/mpls-internal.h new file mode 100644 index 00000000..e5393b97 --- /dev/null +++ b/nest/mpls-internal.h @@ -0,0 +1,60 @@ +/* + * BIRD Internet Routing Daemon -- MPLS Structures + * + * (c) 2022 Ondrej Zajicek + * (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 diff --git a/nest/mpls.c b/nest/mpls.c index 944659f9..d384e41c 100644 --- a/nest/mpls.c +++ b/nest/mpls.c @@ -83,7 +83,7 @@ #include "nest/bird.h" #include "nest/route.h" -#include "nest/mpls.h" +#include "nest/mpls-internal.h" #include "nest/cli.h" static struct mpls_range *mpls_new_range(struct mpls_domain *m, struct mpls_range_config *cf); diff --git a/nest/mpls.h b/nest/mpls.h index 2c1ab50f..60c38295 100644 --- a/nest/mpls.h +++ b/nest/mpls.h @@ -38,23 +38,6 @@ struct mpls_domain_config { 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 */ @@ -66,23 +49,7 @@ struct mpls_range_config { 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); @@ -91,9 +58,6 @@ void mpls_domain_postconfig(struct mpls_domain_config *cf); 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); }