]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_advertise.h
lib: hashing functions should take const arguments
[mirror_frr.git] / bgpd / bgp_advertise.h
index 1912aec1bfa5b3941e39f31c7a2f6fc13e6472d1..7d2fdf1f0b2e35454d286294bd7dd7b0a4b9ff66 100644 (file)
 #ifndef _QUAGGA_BGP_ADVERTISE_H
 #define _QUAGGA_BGP_ADVERTISE_H
 
-#include <lib/fifo.h>
+#include "lib/typesafe.h"
 
-struct update_subgroup;
+PREDECL_LIST(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 {
@@ -46,7 +41,7 @@ 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;
@@ -65,11 +60,12 @@ struct bgp_advertise {
        struct bgp_path_info *pathi;
 };
 
+DECLARE_LIST(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;
@@ -89,6 +85,10 @@ struct bgp_adj_out {
        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.  */
@@ -107,9 +107,9 @@ struct bgp_adj_in {
 
 /* 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.  */
@@ -134,38 +134,6 @@ struct bgp_synchronize {
 
 #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);
@@ -176,7 +144,7 @@ extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
 
 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);