mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-05 08:31:53 +00:00
MPLS: Putting internal objects aside
This commit is contained in:
parent
f0da632b3c
commit
9815353c5e
60
nest/mpls-internal.h
Normal file
60
nest/mpls-internal.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
#include "nest/bird.h"
|
#include "nest/bird.h"
|
||||||
#include "nest/route.h"
|
#include "nest/route.h"
|
||||||
#include "nest/mpls.h"
|
#include "nest/mpls-internal.h"
|
||||||
#include "nest/cli.h"
|
#include "nest/cli.h"
|
||||||
|
|
||||||
static struct mpls_range *mpls_new_range(struct mpls_domain *m, struct mpls_range_config *cf);
|
static struct mpls_range *mpls_new_range(struct mpls_domain *m, struct mpls_range_config *cf);
|
||||||
|
38
nest/mpls.h
38
nest/mpls.h
@ -38,23 +38,6 @@ struct mpls_domain_config {
|
|||||||
struct mpls_range_config *dynamic_range; /* Default dynamic label range */
|
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 {
|
struct mpls_range_config {
|
||||||
node n; /* Node in mpls_domain_config.ranges */
|
node n; /* Node in mpls_domain_config.ranges */
|
||||||
struct mpls_range *range; /* Our instance */
|
struct mpls_range *range; /* Our instance */
|
||||||
@ -66,23 +49,7 @@ struct mpls_range_config {
|
|||||||
u8 implicit; /* Implicitly defined range */
|
u8 implicit; /* Implicitly defined range */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mpls_range {
|
struct mpls_handle;
|
||||||
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 */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void mpls_init(void);
|
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);
|
struct mpls_range_config * mpls_range_config_new(struct mpls_domain_config *m, struct symbol *s);
|
||||||
void mpls_preconfig(struct config *c);
|
void mpls_preconfig(struct config *c);
|
||||||
void mpls_commit(struct config *new, struct config *old);
|
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)
|
static inline struct mpls_domain_config *cf_default_mpls_domain(struct config *cfg)
|
||||||
{ return EMPTY_LIST(cfg->mpls_domains) ? NULL : HEAD(cfg->mpls_domains); }
|
{ return EMPTY_LIST(cfg->mpls_domains) ? NULL : HEAD(cfg->mpls_domains); }
|
||||||
|
Loading…
Reference in New Issue
Block a user