]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_clist.h
Merge pull request #5793 from ton31337/fix/formatting_show_bgp_summary_failed
[mirror_frr.git] / bgpd / bgp_clist.h
index 0dbde2a45378ccca7c2f925617501d0470ddb880..c5718aecac58e863d6085bca94e154a62ef05ca2 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef _QUAGGA_BGP_CLIST_H
 #define _QUAGGA_BGP_CLIST_H
 
+#include "jhash.h"
+
 /* Master Community-list. */
 #define COMMUNITY_LIST_MASTER          0
 #define EXTCOMMUNITY_LIST_MASTER       1
@@ -34,6 +36,8 @@
 #define COMMUNITY_LIST_STRING          0
 #define COMMUNITY_LIST_NUMBER          1
 
+#define COMMUNITY_SEQ_NUMBER_AUTO     -1
+
 /* Community-list entry types.  */
 #define COMMUNITY_LIST_STANDARD        0 /* Standard community-list.  */
 #define COMMUNITY_LIST_EXPANDED        1 /* Expanded community-list.  */
@@ -47,6 +51,9 @@ struct community_list {
        /* Name of the community-list.  */
        char *name;
 
+       /* Stored hash value of name, to further speed up hash operations */
+       uint32_t name_hash;
+
        /* String or number.  */
        int sort;
 
@@ -76,6 +83,9 @@ struct community_entry {
        /* Any match.  */
        uint8_t any;
 
+       /* Sequence number. */
+       int64_t seq;
+
        /* Community structure.  */
        union {
                struct community *com;
@@ -100,6 +110,7 @@ struct community_list_list {
 struct community_list_master {
        struct community_list_list num;
        struct community_list_list str;
+       struct hash *hash;
 };
 
 /* Community-list handler.  community_list_init() returns this
@@ -129,38 +140,47 @@ extern struct community_list_handler *community_list_init(void);
 extern void community_list_terminate(struct community_list_handler *);
 
 extern int community_list_set(struct community_list_handler *ch,
-                             const char *name, const char *str, int direct,
-                             int style);
+                             const char *name, const char *str,
+                             const char *seq, int direct, int style);
 extern int community_list_unset(struct community_list_handler *ch,
-                               const char *name, const char *str, int direct,
-                               int style, int delete_all);
+                               const char *name, const char *str,
+                               const char *seq, int direct, int style);
 extern int extcommunity_list_set(struct community_list_handler *ch,
-                                const char *name, const char *str, int direct,
-                                int style);
+                                const char *name, const char *str,
+                                const char *seq, int direct, int style);
 extern int extcommunity_list_unset(struct community_list_handler *ch,
                                   const char *name, const char *str,
-                                  int direct, int style, int delete_all);
+                                  const char *seq, int direct, int style);
 extern int lcommunity_list_set(struct community_list_handler *ch,
-                              const char *name, const char *str, int direct,
-                              int style);
+                              const char *name, const char *str,
+                              const char *seq, int direct, int style);
 extern int lcommunity_list_unset(struct community_list_handler *ch,
-                                const char *name, const char *str, int direct,
-                                int style);
+                                const char *name, const char *str,
+                                const char *seq, int direct, int style);
 
 extern struct community_list_master *
 community_list_master_lookup(struct community_list_handler *, int);
 
 extern struct community_list *
-community_list_lookup(struct community_list_handler *, const char *, int);
+community_list_lookup(struct community_list_handler *c, const char *name,
+                     uint32_t name_hash, int master);
 
 extern int community_list_match(struct community *, struct community_list *);
 extern int ecommunity_list_match(struct ecommunity *, struct community_list *);
 extern int lcommunity_list_match(struct lcommunity *, struct community_list *);
 extern int community_list_exact_match(struct community *,
                                      struct community_list *);
+extern int lcommunity_list_exact_match(struct lcommunity *lcom,
+                                      struct community_list *list);
 extern struct community *community_list_match_delete(struct community *,
                                                     struct community_list *);
 extern struct lcommunity *
 lcommunity_list_match_delete(struct lcommunity *lcom,
                             struct community_list *list);
+
+static inline uint32_t bgp_clist_hash_key(char *name)
+{
+       return jhash(name, strlen(name), 0xdeadbeaf);
+}
+
 #endif /* _QUAGGA_BGP_CLIST_H */