]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: export route map structures and functions
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 30 Sep 2019 13:17:33 +0000 (10:17 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 4 Feb 2020 17:05:43 +0000 (14:05 -0300)
These exported items are going to be used by the new northbound CLI.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
lib/routemap.c
lib/routemap.h

index 14fec0283cafebcb98f9e6559f3b61a5a0172afd..a8feebd3138ed495f0f5c66fd40cb81e48a80f9a 100644 (file)
@@ -50,178 +50,7 @@ static vector route_match_vec;
 /* Vector for route set rules. */
 static vector route_set_vec;
 
-struct route_map_match_set_hooks {
-       /* match interface */
-       int (*match_interface)(struct vty *vty, struct route_map_index *index,
-                              const char *command, const char *arg,
-                              route_map_event_t type);
-
-       /* no match interface */
-       int (*no_match_interface)(struct vty *vty,
-                                 struct route_map_index *index,
-                                 const char *command, const char *arg,
-                                 route_map_event_t type);
-
-       /* match ip address */
-       int (*match_ip_address)(struct vty *vty, struct route_map_index *index,
-                               const char *command, const char *arg,
-                               route_map_event_t type);
-
-       /* no match ip address */
-       int (*no_match_ip_address)(struct vty *vty,
-                                  struct route_map_index *index,
-                                  const char *command, const char *arg,
-                                  route_map_event_t type);
-
-       /* match ip address prefix list */
-       int (*match_ip_address_prefix_list)(struct vty *vty,
-                                           struct route_map_index *index,
-                                           const char *command,
-                                           const char *arg,
-                                           route_map_event_t type);
-
-       /* no match ip address prefix list */
-       int (*no_match_ip_address_prefix_list)(struct vty *vty,
-                                              struct route_map_index *index,
-                                              const char *command,
-                                              const char *arg,
-                                              route_map_event_t type);
-
-       /* match ip next hop */
-       int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index,
-                                const char *command, const char *arg,
-                                route_map_event_t type);
-
-       /* no match ip next hop */
-       int (*no_match_ip_next_hop)(struct vty *vty,
-                                   struct route_map_index *index,
-                                   const char *command, const char *arg,
-                                   route_map_event_t type);
-
-       /* match ip next hop prefix list */
-       int (*match_ip_next_hop_prefix_list)(struct vty *vty,
-                                            struct route_map_index *index,
-                                            const char *command,
-                                            const char *arg,
-                                            route_map_event_t type);
-
-       /* no match ip next hop prefix list */
-       int (*no_match_ip_next_hop_prefix_list)(struct vty *vty,
-                                               struct route_map_index *index,
-                                               const char *command,
-                                               const char *arg,
-                                               route_map_event_t type);
-
-       /* match ip next-hop type */
-       int (*match_ip_next_hop_type)(struct vty *vty,
-                                            struct route_map_index *index,
-                                            const char *command,
-                                            const char *arg,
-                                            route_map_event_t type);
-
-       /* no match ip next-hop type */
-       int (*no_match_ip_next_hop_type)(struct vty *vty,
-                                               struct route_map_index *index,
-                                               const char *command,
-                                               const char *arg,
-                                               route_map_event_t type);
-
-       /* match ipv6 address */
-       int (*match_ipv6_address)(struct vty *vty,
-                                 struct route_map_index *index,
-                                 const char *command, const char *arg,
-                                 route_map_event_t type);
-
-       /* no match ipv6 address */
-       int (*no_match_ipv6_address)(struct vty *vty,
-                                    struct route_map_index *index,
-                                    const char *command, const char *arg,
-                                    route_map_event_t type);
-
-
-       /* match ipv6 address prefix list */
-       int (*match_ipv6_address_prefix_list)(struct vty *vty,
-                                             struct route_map_index *index,
-                                             const char *command,
-                                             const char *arg,
-                                             route_map_event_t type);
-
-       /* no match ipv6 address prefix list */
-       int (*no_match_ipv6_address_prefix_list)(struct vty *vty,
-                                                struct route_map_index *index,
-                                                const char *command,
-                                                const char *arg,
-                                                route_map_event_t type);
-
-       /* match ipv6 next-hop type */
-       int (*match_ipv6_next_hop_type)(struct vty *vty,
-                                             struct route_map_index *index,
-                                             const char *command,
-                                             const char *arg,
-                                             route_map_event_t type);
-
-       /* no match ipv6 next-hop type */
-       int (*no_match_ipv6_next_hop_type)(struct vty *vty,
-                                          struct route_map_index *index,
-                                          const char *command, const char *arg,
-                                          route_map_event_t type);
-
-       /* match metric */
-       int (*match_metric)(struct vty *vty, struct route_map_index *index,
-                           const char *command, const char *arg,
-                           route_map_event_t type);
-
-       /* no match metric */
-       int (*no_match_metric)(struct vty *vty, struct route_map_index *index,
-                              const char *command, const char *arg,
-                              route_map_event_t type);
-
-       /* match tag */
-       int (*match_tag)(struct vty *vty, struct route_map_index *index,
-                        const char *command, const char *arg,
-                        route_map_event_t type);
-
-       /* no match tag */
-       int (*no_match_tag)(struct vty *vty, struct route_map_index *index,
-                           const char *command, const char *arg,
-                           route_map_event_t type);
-
-       /* set ip nexthop */
-       int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
-                             const char *command, const char *arg);
-
-       /* no set ip nexthop */
-       int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
-                                const char *command, const char *arg);
-
-       /* set ipv6 nexthop local */
-       int (*set_ipv6_nexthop_local)(struct vty *vty,
-                                     struct route_map_index *index,
-                                     const char *command, const char *arg);
-
-       /* no set ipv6 nexthop local */
-       int (*no_set_ipv6_nexthop_local)(struct vty *vty,
-                                        struct route_map_index *index,
-                                        const char *command, const char *arg);
-
-       /* set metric */
-       int (*set_metric)(struct vty *vty, struct route_map_index *index,
-                         const char *command, const char *arg);
-
-       /* no set metric */
-       int (*no_set_metric)(struct vty *vty, struct route_map_index *index,
-                            const char *command, const char *arg);
-
-       /* set tag */
-       int (*set_tag)(struct vty *vty, struct route_map_index *index,
-                      const char *command, const char *arg);
-
-       /* no set tag */
-       int (*no_set_tag)(struct vty *vty, struct route_map_index *index,
-                         const char *command, const char *arg);
-};
-
-static struct route_map_match_set_hooks rmap_match_set_hook;
+struct route_map_match_set_hooks rmap_match_set_hook;
 
 /* match interface */
 void route_map_match_interface_hook(int (*func)(
@@ -595,35 +424,9 @@ int generic_set_delete(struct vty *vty, struct route_map_index *index,
 }
 
 
-/* Route map rule. This rule has both `match' rule and `set' rule. */
-struct route_map_rule {
-       /* Rule type. */
-       const struct route_map_rule_cmd *cmd;
-
-       /* For pretty printing. */
-       char *rule_str;
-
-       /* Pre-compiled match rule. */
-       void *value;
-
-       /* Linked list. */
-       struct route_map_rule *next;
-       struct route_map_rule *prev;
-};
-
-/* Making route map list. */
-struct route_map_list {
-       struct route_map *head;
-       struct route_map *tail;
-
-       void (*add_hook)(const char *);
-       void (*delete_hook)(const char *);
-       void (*event_hook)(const char *);
-};
-
 /* Master list of route map. */
-static struct route_map_list route_map_master = {NULL, NULL, NULL, NULL, NULL};
-static struct hash *route_map_master_hash = NULL;
+struct route_map_list route_map_master = {NULL, NULL, NULL, NULL, NULL};
+struct hash *route_map_master_hash = NULL;
 
 static unsigned int route_map_hash_key_make(const void *p)
 {
@@ -691,8 +494,6 @@ static void route_map_rule_delete(struct route_map_rule_list *,
                                  struct route_map_rule *);
 static bool rmap_debug;
 
-static void route_map_index_delete(struct route_map_index *, int);
-
 /* New route map allocation. Please note route map's name must be
    specified. */
 static struct route_map *route_map_new(const char *name)
@@ -784,7 +585,7 @@ static void route_map_free_map(struct route_map *map)
 }
 
 /* Route map delete from list. */
-static void route_map_delete(struct route_map *map)
+void route_map_delete(struct route_map *map)
 {
        struct route_map_index *index;
        char *name;
@@ -883,7 +684,7 @@ static int route_map_clear_updated(struct route_map *map)
 
 /* Lookup route map.  If there isn't route map create one and return
    it. */
-static struct route_map *route_map_get(const char *name)
+struct route_map *route_map_get(const char *name)
 {
        struct route_map *map;
 
@@ -1097,7 +898,7 @@ static struct route_map_index *route_map_index_new(void)
 }
 
 /* Free route map index. */
-static void route_map_index_delete(struct route_map_index *index, int notify)
+void route_map_index_delete(struct route_map_index *index, int notify)
 {
        struct route_map_rule *rule;
 
@@ -1202,7 +1003,7 @@ route_map_index_add(struct route_map *map, enum route_map_type type, int pref)
 }
 
 /* Get route map index. */
-static struct route_map_index *
+struct route_map_index *
 route_map_index_get(struct route_map *map, enum route_map_type type, int pref)
 {
        struct route_map_index *index;
index 1ffd0525ae66eeec801555e0c7f04cfe19e5a735..41959c24e564ac53b0b6603aaa708f9309305281 100644 (file)
@@ -140,6 +140,22 @@ enum rmap_compile_rets {
 
 };
 
+/* Route map rule. This rule has both `match' rule and `set' rule. */
+struct route_map_rule {
+       /* Rule type. */
+       const struct route_map_rule_cmd *cmd;
+
+       /* For pretty printing. */
+       char *rule_str;
+
+       /* Pre-compiled match rule. */
+       void *value;
+
+       /* Linked list. */
+       struct route_map_rule *next;
+       struct route_map_rule *prev;
+};
+
 /* Route map rule list. */
 struct route_map_rule_list {
        struct route_map_rule *head;
@@ -435,6 +451,199 @@ extern void route_map_counter_increment(struct route_map *map);
 /* Decrement the route-map used counter */
 extern void route_map_counter_decrement(struct route_map *map);
 
+/* Route map hooks data structure. */
+struct route_map_match_set_hooks {
+       /* match interface */
+       int (*match_interface)(struct vty *vty, struct route_map_index *index,
+                              const char *command, const char *arg,
+                              route_map_event_t type);
+
+       /* no match interface */
+       int (*no_match_interface)(struct vty *vty,
+                                 struct route_map_index *index,
+                                 const char *command, const char *arg,
+                                 route_map_event_t type);
+
+       /* match ip address */
+       int (*match_ip_address)(struct vty *vty, struct route_map_index *index,
+                               const char *command, const char *arg,
+                               route_map_event_t type);
+
+       /* no match ip address */
+       int (*no_match_ip_address)(struct vty *vty,
+                                  struct route_map_index *index,
+                                  const char *command, const char *arg,
+                                  route_map_event_t type);
+
+       /* match ip address prefix list */
+       int (*match_ip_address_prefix_list)(struct vty *vty,
+                                           struct route_map_index *index,
+                                           const char *command,
+                                           const char *arg,
+                                           route_map_event_t type);
+
+       /* no match ip address prefix list */
+       int (*no_match_ip_address_prefix_list)(struct vty *vty,
+                                              struct route_map_index *index,
+                                              const char *command,
+                                              const char *arg,
+                                              route_map_event_t type);
+
+       /* match ip next hop */
+       int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index,
+                                const char *command, const char *arg,
+                                route_map_event_t type);
+
+       /* no match ip next hop */
+       int (*no_match_ip_next_hop)(struct vty *vty,
+                                   struct route_map_index *index,
+                                   const char *command, const char *arg,
+                                   route_map_event_t type);
+
+       /* match ip next hop prefix list */
+       int (*match_ip_next_hop_prefix_list)(struct vty *vty,
+                                            struct route_map_index *index,
+                                            const char *command,
+                                            const char *arg,
+                                            route_map_event_t type);
+
+       /* no match ip next hop prefix list */
+       int (*no_match_ip_next_hop_prefix_list)(struct vty *vty,
+                                               struct route_map_index *index,
+                                               const char *command,
+                                               const char *arg,
+                                               route_map_event_t type);
+
+       /* match ip next-hop type */
+       int (*match_ip_next_hop_type)(struct vty *vty,
+                                            struct route_map_index *index,
+                                            const char *command,
+                                            const char *arg,
+                                            route_map_event_t type);
+
+       /* no match ip next-hop type */
+       int (*no_match_ip_next_hop_type)(struct vty *vty,
+                                               struct route_map_index *index,
+                                               const char *command,
+                                               const char *arg,
+                                               route_map_event_t type);
+
+       /* match ipv6 address */
+       int (*match_ipv6_address)(struct vty *vty,
+                                 struct route_map_index *index,
+                                 const char *command, const char *arg,
+                                 route_map_event_t type);
+
+       /* no match ipv6 address */
+       int (*no_match_ipv6_address)(struct vty *vty,
+                                    struct route_map_index *index,
+                                    const char *command, const char *arg,
+                                    route_map_event_t type);
+
+
+       /* match ipv6 address prefix list */
+       int (*match_ipv6_address_prefix_list)(struct vty *vty,
+                                             struct route_map_index *index,
+                                             const char *command,
+                                             const char *arg,
+                                             route_map_event_t type);
+
+       /* no match ipv6 address prefix list */
+       int (*no_match_ipv6_address_prefix_list)(struct vty *vty,
+                                                struct route_map_index *index,
+                                                const char *command,
+                                                const char *arg,
+                                                route_map_event_t type);
+
+       /* match ipv6 next-hop type */
+       int (*match_ipv6_next_hop_type)(struct vty *vty,
+                                             struct route_map_index *index,
+                                             const char *command,
+                                             const char *arg,
+                                             route_map_event_t type);
+
+       /* no match ipv6 next-hop type */
+       int (*no_match_ipv6_next_hop_type)(struct vty *vty,
+                                          struct route_map_index *index,
+                                          const char *command, const char *arg,
+                                          route_map_event_t type);
+
+       /* match metric */
+       int (*match_metric)(struct vty *vty, struct route_map_index *index,
+                           const char *command, const char *arg,
+                           route_map_event_t type);
+
+       /* no match metric */
+       int (*no_match_metric)(struct vty *vty, struct route_map_index *index,
+                              const char *command, const char *arg,
+                              route_map_event_t type);
+
+       /* match tag */
+       int (*match_tag)(struct vty *vty, struct route_map_index *index,
+                        const char *command, const char *arg,
+                        route_map_event_t type);
+
+       /* no match tag */
+       int (*no_match_tag)(struct vty *vty, struct route_map_index *index,
+                           const char *command, const char *arg,
+                           route_map_event_t type);
+
+       /* set ip nexthop */
+       int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
+                             const char *command, const char *arg);
+
+       /* no set ip nexthop */
+       int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
+                                const char *command, const char *arg);
+
+       /* set ipv6 nexthop local */
+       int (*set_ipv6_nexthop_local)(struct vty *vty,
+                                     struct route_map_index *index,
+                                     const char *command, const char *arg);
+
+       /* no set ipv6 nexthop local */
+       int (*no_set_ipv6_nexthop_local)(struct vty *vty,
+                                        struct route_map_index *index,
+                                        const char *command, const char *arg);
+
+       /* set metric */
+       int (*set_metric)(struct vty *vty, struct route_map_index *index,
+                         const char *command, const char *arg);
+
+       /* no set metric */
+       int (*no_set_metric)(struct vty *vty, struct route_map_index *index,
+                            const char *command, const char *arg);
+
+       /* set tag */
+       int (*set_tag)(struct vty *vty, struct route_map_index *index,
+                      const char *command, const char *arg);
+
+       /* no set tag */
+       int (*no_set_tag)(struct vty *vty, struct route_map_index *index,
+                         const char *command, const char *arg);
+};
+
+extern struct route_map_match_set_hooks rmap_match_set_hook;
+
+/* Making route map list. */
+struct route_map_list {
+       struct route_map *head;
+       struct route_map *tail;
+
+       void (*add_hook)(const char *);
+       void (*delete_hook)(const char *);
+       void (*event_hook)(const char *);
+};
+
+extern struct route_map_list route_map_master;
+
+extern struct route_map *route_map_get(const char *name);
+extern void route_map_delete(struct route_map *map);
+extern struct route_map_index *route_map_index_get(struct route_map *map,
+                                                  enum route_map_type type,
+                                                  int pref);
+extern void route_map_index_delete(struct route_map_index *index, int notify);
+
 #ifdef __cplusplus
 }
 #endif