summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2018-07-12 16:05:19 -0400
committerMark Stapp <mjs@voltanet.io>2018-07-23 10:34:35 -0400
commit123214efb82f6348cd80c387be15a1e2e21ce63e (patch)
tree9120c8e331acfb05b30eed616f34967fae8b30c0 /lib
parentc4aee4fe3133127f16d3967e74e52b262438d57f (diff)
libs, daemons: use const in route-map apply
Use 'const prefix *' in route-map apply apis; led to some corresponding changes in several daemons. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/filter.c9
-rw-r--r--lib/filter.h3
-rw-r--r--lib/plist.c13
-rw-r--r--lib/plist.h5
-rw-r--r--lib/routemap.c5
-rw-r--r--lib/routemap.h8
6 files changed, 25 insertions, 18 deletions
diff --git a/lib/filter.c b/lib/filter.c
index 670c65374a..0528b0f2ad 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -157,7 +157,7 @@ static const char *filter_type_str(struct filter *filter)
}
/* If filter match to the prefix then return 1. */
-static int filter_match_cisco(struct filter *mfilter, struct prefix *p)
+static int filter_match_cisco(struct filter *mfilter, const struct prefix *p)
{
struct filter_cisco *filter;
struct in_addr mask;
@@ -181,7 +181,7 @@ static int filter_match_cisco(struct filter *mfilter, struct prefix *p)
}
/* If filter match to the prefix then return 1. */
-static int filter_match_zebra(struct filter *mfilter, struct prefix *p)
+static int filter_match_zebra(struct filter *mfilter, const struct prefix *p)
{
struct filter_zebra *filter = NULL;
@@ -372,10 +372,11 @@ static struct access_list *access_list_get(afi_t afi, const char *name)
}
/* Apply access list to object (which should be struct prefix *). */
-enum filter_type access_list_apply(struct access_list *access, void *object)
+enum filter_type access_list_apply(struct access_list *access,
+ const void *object)
{
struct filter *filter;
- struct prefix *p = (struct prefix *)object;
+ const struct prefix *p = (const struct prefix *)object;
if (access == NULL)
return FILTER_DENY;
diff --git a/lib/filter.h b/lib/filter.h
index c02516409b..97854b1e97 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -59,6 +59,7 @@ extern void access_list_reset(void);
extern void access_list_add_hook(void (*func)(struct access_list *));
extern void access_list_delete_hook(void (*func)(struct access_list *));
extern struct access_list *access_list_lookup(afi_t, const char *);
-extern enum filter_type access_list_apply(struct access_list *, void *);
+extern enum filter_type access_list_apply(struct access_list *access,
+ const void *object);
#endif /* _ZEBRA_FILTER_H */
diff --git a/lib/plist.c b/lib/plist.c
index 056b737f54..2b666f256f 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -656,7 +656,7 @@ static const char *prefix_list_type_str(struct prefix_list_entry *pentry)
}
static int prefix_list_entry_match(struct prefix_list_entry *pentry,
- struct prefix *p)
+ const struct prefix *p)
{
int ret;
@@ -683,14 +683,15 @@ static int prefix_list_entry_match(struct prefix_list_entry *pentry,
return 1;
}
-enum prefix_list_type prefix_list_apply_which_prefix(struct prefix_list *plist,
- struct prefix **which,
- void *object)
+enum prefix_list_type prefix_list_apply_which_prefix(
+ struct prefix_list *plist,
+ const struct prefix **which,
+ const void *object)
{
struct prefix_list_entry *pentry, *pbest = NULL;
- struct prefix *p = (struct prefix *)object;
- uint8_t *byte = p->u.val;
+ const struct prefix *p = (const struct prefix *)object;
+ const uint8_t *byte = p->u.val;
size_t depth;
size_t validbits = p->prefixlen;
struct pltrie_table *table;
diff --git a/lib/plist.h b/lib/plist.h
index 67e345a485..fecbe0e2ce 100644
--- a/lib/plist.h
+++ b/lib/plist.h
@@ -61,8 +61,9 @@ extern struct prefix_list *prefix_list_lookup(afi_t, const char *);
* If it is a empty plist return a NULL pointer.
*/
extern enum prefix_list_type
-prefix_list_apply_which_prefix(struct prefix_list *plist, struct prefix **which,
- void *object);
+prefix_list_apply_which_prefix(struct prefix_list *plist,
+ const struct prefix **which,
+ const void *object);
#define prefix_list_apply(A, B) prefix_list_apply_which_prefix((A), NULL, (B))
extern struct prefix_list *prefix_bgp_orf_lookup(afi_t, const char *);
diff --git a/lib/routemap.c b/lib/routemap.c
index 056c793454..6c4585365a 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1387,7 +1387,7 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
static route_map_result_t
route_map_apply_match(struct route_map_rule_list *match_list,
- struct prefix *prefix, route_map_object_t type,
+ const struct prefix *prefix, route_map_object_t type,
void *object)
{
route_map_result_t ret = RMAP_NOMATCH;
@@ -1417,7 +1417,8 @@ route_map_apply_match(struct route_map_rule_list *match_list,
}
/* Apply route map to the object. */
-route_map_result_t route_map_apply(struct route_map *map, struct prefix *prefix,
+route_map_result_t route_map_apply(struct route_map *map,
+ const struct prefix *prefix,
route_map_object_t type, void *object)
{
static int recursion = 0;
diff --git a/lib/routemap.h b/lib/routemap.h
index 0aeba7e1f6..0f7c391f84 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -87,8 +87,10 @@ struct route_map_rule_cmd {
const char *str;
/* Function for value set or match. */
- route_map_result_t (*func_apply)(void *, struct prefix *,
- route_map_object_t, void *);
+ route_map_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 *);
@@ -208,7 +210,7 @@ extern struct route_map *route_map_lookup_by_name(const char *name);
/* Apply route map to the object. */
extern route_map_result_t route_map_apply(struct route_map *map,
- struct prefix *,
+ const struct prefix *prefix,
route_map_object_t object_type,
void *object);