diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2016-10-29 14:37:11 -0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2016-11-28 16:18:35 -0200 |
| commit | 1a1a70655c869a1b66e363894e5aba19f4aa08f3 (patch) | |
| tree | 8eea443fc57ac5766128d41e27c9411a3c1c7afc /lib/vrf.h | |
| parent | c7fdd84f36a262d062a10c1439121df361ab78d3 (diff) | |
lib: convert vrf code to use red-black trees as well
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/vrf.h')
| -rw-r--r-- | lib/vrf.h | 45 |
1 files changed, 7 insertions, 38 deletions
@@ -23,6 +23,7 @@ #ifndef _ZEBRA_VRF_H #define _ZEBRA_VRF_H +#include "openbsd-tree.h" #include "linklist.h" #include "qobj.h" @@ -69,18 +70,18 @@ enum { struct vrf { + RB_ENTRY(vrf) id_entry; + /* Identifier, same as the vector index */ vrf_id_t vrf_id; - /* Name */ + /* Name */ char name[VRF_NAMSIZ + 1]; /* Zebra internal VRF status */ u_char status; #define VRF_ACTIVE (1 << 0) - struct route_node *node; - /* Master list of interfaces belonging to this VRF */ struct list *iflist; @@ -89,9 +90,12 @@ struct vrf QOBJ_FIELDS }; +RB_HEAD (vrf_id_head, vrf); +RB_PROTOTYPE (vrf_id_head, vrf, id_entry, vrf_id_compare) DECLARE_QOBJ_TYPE(vrf) +extern struct vrf_id_head vrfs_by_id; extern struct list *vrf_list; /* @@ -104,13 +108,6 @@ extern struct list *vrf_list; */ extern void vrf_add_hook (int, int (*)(vrf_id_t, const char *, void **)); -/* - * VRF iteration - */ - -typedef void * vrf_iter_t; -#define VRF_ITER_INVALID NULL /* invalid value of the iterator */ - extern struct vrf *vrf_lookup (vrf_id_t); extern struct vrf *vrf_lookup_by_name (const char *); extern struct vrf *vrf_list_lookup_by_name (const char *); @@ -136,34 +133,6 @@ extern vrf_id_t vrf_name_to_id (const char *); } while (0) /* - * VRF iteration utilities. Example for the usage: - * - * vrf_iter_t iter = vrf_first(); - * for (; iter != VRF_ITER_INVALID; iter = vrf_next (iter)) - * - * or - * - * vrf_iter_t iter = vrf_iterator (<a given VRF ID>); - * for (; iter != VRF_ITER_INVALID; iter = vrf_next (iter)) - */ - -/* Return the iterator of the first VRF. */ -extern vrf_iter_t vrf_first (void); -/* Return the next VRF iterator to the given iterator. */ -extern vrf_iter_t vrf_next (vrf_iter_t); -/* Return the VRF iterator of the given VRF ID. If it does not exist, - * the iterator of the next existing VRF is returned. */ -extern vrf_iter_t vrf_iterator (vrf_id_t); - -/* - * VRF iterator to properties - */ -extern vrf_id_t vrf_iter2id (vrf_iter_t); -extern struct vrf *vrf_iter2vrf (vrf_iter_t); -extern void *vrf_iter2info (vrf_iter_t); -extern struct list *vrf_iter2iflist (vrf_iter_t); - -/* * Utilities to obtain the user data */ |
