]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/routemap.h
Merge pull request #5746 from donaldsharp/bgp_sa
[mirror_frr.git] / lib / routemap.h
index d7acd7f3f7103657f0ebae21a68c00afd253969d..1ffd0525ae66eeec801555e0c7f04cfe19e5a735 100644 (file)
@@ -34,17 +34,25 @@ DECLARE_MTYPE(ROUTE_MAP_NAME)
 DECLARE_MTYPE(ROUTE_MAP_RULE)
 DECLARE_MTYPE(ROUTE_MAP_COMPILED)
 
+/* Route map's type. */
+enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };
+
+typedef enum {
+       RMAP_DENYMATCH,
+       RMAP_PERMITMATCH
+} route_map_result_t;
+
 /*
  * Route-map match or set result "Eg: match evpn vni xx"
  * route-map match cmd always returns match/nomatch/noop
  *    match--> found a match
  *    nomatch--> didnt find a match
- *    noop--> invalid
+ *    noop--> not applicable
  * route-map set retuns okay/error
  *    okay --> set was successful
  *    error --> set was not successful
  */
-enum route_map_match_result_t {
+enum route_map_cmd_result_t {
        /*
         * route-map match cmd results
         */
@@ -58,13 +66,6 @@ enum route_map_match_result_t {
        RMAP_ERROR
 };
 
-/* Route map's type. */
-enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };
-
-typedef enum {
-       RMAP_DENYMATCH,
-       RMAP_PERMITMATCH
-} route_map_result_t;
 
 typedef enum {
        RMAP_RIP,
@@ -112,20 +113,23 @@ struct route_map_rule_cmd {
        const char *str;
 
        /* Function for value set or match. */
-       enum route_map_match_result_t (*func_apply)(void *rule,
-                                                   const struct prefix *prefix,
-                                                   route_map_object_t type,
-                                                   void *object);
+       enum route_map_cmd_result_t (*func_apply)(void *rule,
+                                                 const struct prefix *prefix,
+                                                 route_map_object_t type,
+                                                 void *object);
 
        /* Compile argument and return result as void *. */
        void *(*func_compile)(const char *);
 
        /* Free allocated value by func_compile (). */
        void (*func_free)(void *);
+
+       /** To get the rule key after Compilation **/
+       void *(*func_get_rmap_rule_key)(void *val);
 };
 
 /* Route map apply error. */
-enum {
+enum rmap_compile_rets {
        RMAP_COMPILE_SUCCESS,
 
        /* Route map rule is missing. */
@@ -134,8 +138,6 @@ enum {
        /* Route map rule can't compile */
        RMAP_COMPILE_ERROR,
 
-       /* Route map rule is duplicate */
-       RMAP_DUPLICATE_RULE
 };
 
 /* Route map rule list. */
@@ -174,6 +176,7 @@ struct route_map_index {
 
        /* Keep track how many times we've try to apply */
        uint64_t applied;
+       uint64_t applied_clear;
 
        QOBJ_FIELDS
 };
@@ -198,6 +201,7 @@ struct route_map {
 
        /* How many times have we applied this route-map */
        uint64_t applied;
+       uint64_t applied_clear;
 
        /* Counter to track active usage of this route-map */
        uint16_t use_count;
@@ -217,28 +221,32 @@ extern void route_map_init(void);
 extern void route_map_finish(void);
 
 /* Add match statement to route map. */
-extern int route_map_add_match(struct route_map_index *index,
-                              const char *match_name, const char *match_arg,
-                              route_map_event_t type);
+extern enum rmap_compile_rets route_map_add_match(struct route_map_index *index,
+                                                 const char *match_name,
+                                                 const char *match_arg,
+                                                 route_map_event_t type);
 
 /* Delete specified route match rule. */
-extern int route_map_delete_match(struct route_map_index *index,
-                                 const char *match_name,
-                                 const char *match_arg);
+extern enum rmap_compile_rets
+route_map_delete_match(struct route_map_index *index,
+                      const char *match_name, const char *match_arg,
+                      route_map_event_t type);
 
 extern const char *route_map_get_match_arg(struct route_map_index *index,
                                           const char *match_name);
 
 /* Add route-map set statement to the route map. */
-extern int route_map_add_set(struct route_map_index *index,
-                            const char *set_name, const char *set_arg);
+extern enum rmap_compile_rets route_map_add_set(struct route_map_index *index,
+                                               const char *set_name,
+                                               const char *set_arg);
 
 /* Delete route map set rule. */
-extern int route_map_delete_set(struct route_map_index *index,
-                               const char *set_name, const char *set_arg);
+extern enum rmap_compile_rets
+route_map_delete_set(struct route_map_index *index,
+                    const char *set_name, const char *set_arg);
 
 /* Install rule command to the match list. */
-extern void route_map_install_match(struct route_map_rule_cmd *cmd);
+extern void route_map_install_match(const struct route_map_rule_cmd *cmd);
 
 /*
  * Install rule command to the set list.
@@ -249,7 +257,7 @@ extern void route_map_install_match(struct route_map_rule_cmd *cmd);
  * in the apply command).  See 'set metric' command
  * as it is handled in ripd/ripngd and ospfd.
  */
-extern void route_map_install_set(struct route_map_rule_cmd *cmd);
+extern void route_map_install_set(const struct route_map_rule_cmd *cmd);
 
 /* Lookup route map by name. */
 extern struct route_map *route_map_lookup_by_name(const char *name);