summaryrefslogtreecommitdiffstats
path: root/lib/nexthop_group.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-03-10 21:12:52 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-03-14 13:32:39 +0100
commit31919191561fa9b978f8c3cf713e30ed6fb20889 (patch)
tree59c41374f64717c5301f8dc1087892886e892494 /lib/nexthop_group.h
parentMerge pull request #1880 from pguibert6WIND/enforce_vrf_netns_enable (diff)
downloadfrr-31919191561fa9b978f8c3cf713e30ed6fb20889.tar.xz
frr-31919191561fa9b978f8c3cf713e30ed6fb20889.zip
lib: Add nexthop-group cli
Add a nexthop-group cli: nexthop-group NAME nexthop A nexthop B nexthop C ! This will allow interested parties to hook into the cli for nexthops. Users can add callback functions for add/delete of a nexthop group as well as add/delete of each individual nexthop. Future work( PBR and static routes ) will take advantage of this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop_group.h')
-rw-r--r--lib/nexthop_group.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
index 561fe9642..563799dc8 100644
--- a/lib/nexthop_group.h
+++ b/lib/nexthop_group.h
@@ -33,9 +33,11 @@ struct nexthop_group {
struct nexthop *nexthop;
};
-void nexthop_group_init(void);
+struct nexthop_group *nexthop_group_new(void);
+void nexthop_group_delete(struct nexthop_group **nhg);
void nexthop_add(struct nexthop **target, struct nexthop *nexthop);
+void nexthop_del(struct nexthop_group *nhg, struct nexthop *nexthop);
void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
struct nexthop *rparent);
@@ -51,4 +53,36 @@ void copy_nexthops(struct nexthop **tnh, struct nexthop *nh,
(nhop) = (head.nexthop); \
(nhop); \
(nhop) = nexthop_next(nhop)
+
+struct nexthop_group_cmd {
+
+ RB_ENTRY(nexthop_group_cmd) nhgc_entry;
+
+ char name[80];
+
+ struct nexthop_group nhg;
+
+ QOBJ_FIELDS
+};
+RB_HEAD(nhgc_entry_head, nexthp_group_cmd);
+RB_PROTOTYPE(nhgc_entry_head, nexthop_group_cmd, nhgc_entry,
+ nexthop_group_cmd_compare)
+DECLARE_QOBJ_TYPE(nexthop_group_cmd)
+
+/*
+ * Initialize nexthop_groups. If you are interested in when
+ * a nexthop_group is added/deleted/modified, then set the
+ * appropriate callback functions to handle it in your
+ * code
+ */
+void nexthop_group_init(
+ void (*new)(const char *name),
+ void (*add_nexthop)(const struct nexthop_group_cmd *nhgc,
+ const struct nexthop *nhop),
+ void (*del_nexthop)(const struct nexthop_group_cmd *nhgc,
+ const struct nexthop *nhop),
+ void (*delete)(const char *name));
+
+extern struct nexthop *nexthop_exists(struct nexthop_group *nhg,
+ struct nexthop *nh);
#endif