#ifndef _QUAGGA_BGP_ADVERTISE_H
#define _QUAGGA_BGP_ADVERTISE_H
-#include <lib/fifo.h>
+#include "lib/typesafe.h"
-struct update_subgroup;
+PREDECL_DLIST(bgp_adv_fifo)
-/* BGP advertise FIFO. */
-struct bgp_advertise_fifo {
- struct bgp_advertise *next;
- struct bgp_advertise *prev;
- uint32_t count;
-};
+struct update_subgroup;
/* BGP advertise attribute. */
struct bgp_advertise_attr {
struct bgp_advertise {
/* FIFO for advertisement. */
- struct bgp_advertise_fifo fifo;
+ struct bgp_adv_fifo_item fifo;
/* Link list for same attribute advertise. */
struct bgp_advertise *next;
struct bgp_path_info *pathi;
};
+DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo)
+
/* BGP adjacency out. */
struct bgp_adj_out {
- /* Lined list pointer. */
- struct bgp_adj_out *next;
- struct bgp_adj_out *prev;
+ /* RB Tree of adjacency entries */
+ RB_ENTRY(bgp_adj_out) adj_entry;
/* Advertised subgroup. */
struct update_subgroup *subgroup;
struct bgp_advertise *adv;
};
+RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
+RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
+ bgp_adj_out_compare);
+
/* BGP adjacency in. */
struct bgp_adj_in {
/* Linked list pointer. */
/* Received attribute. */
struct attr *attr;
+ /* timestamp (monotime) */
+ time_t uptime;
+
/* Addpath identifier */
uint32_t addpath_rx_id;
};
/* BGP advertisement list. */
struct bgp_synchronize {
- struct bgp_advertise_fifo update;
- struct bgp_advertise_fifo withdraw;
- struct bgp_advertise_fifo withdraw_low;
+ struct bgp_adv_fifo_head update;
+ struct bgp_adv_fifo_head withdraw;
+ struct bgp_adv_fifo_head withdraw_low;
};
/* BGP adjacency linked list. */
#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
-#define BGP_ADJ_OUT_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_out)
-#define BGP_ADJ_OUT_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_out)
-
-#define BGP_ADV_FIFO_ADD(F, N) \
- do { \
- FIFO_ADD((F), (N)); \
- (F)->count++; \
- } while (0)
-
-#define BGP_ADV_FIFO_DEL(F, N) \
- do { \
- FIFO_DEL((N)); \
- (F)->count--; \
- } while (0)
-
-#define BGP_ADV_FIFO_INIT(F) \
- do { \
- FIFO_INIT((F)); \
- (F)->count = 0; \
- } while (0)
-
-#define BGP_ADV_FIFO_COUNT(F) (F)->count
-
-#define BGP_ADV_FIFO_EMPTY(F) \
- (((struct bgp_advertise_fifo *)(F))->next \
- == (struct bgp_advertise *)(F))
-
-#define BGP_ADV_FIFO_HEAD(F) \
- ((((struct bgp_advertise_fifo *)(F))->next \
- == (struct bgp_advertise *)(F)) \
- ? NULL \
- : (F)->next)
/* Prototypes. */
extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
extern void bgp_sync_init(struct peer *);
extern void bgp_sync_delete(struct peer *);
-extern unsigned int baa_hash_key(void *p);
+extern unsigned int baa_hash_key(const void *p);
extern bool baa_hash_cmp(const void *p1, const void *p2);
extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
struct bgp_advertise *adv);