diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/nexthop_group.c | 26 | ||||
| -rw-r--r-- | lib/nexthop_group.h | 4 | ||||
| -rw-r--r-- | lib/nexthop_group_private.h | 45 | ||||
| -rw-r--r-- | lib/subdir.am | 1 |
4 files changed, 59 insertions, 17 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 7b3fb15625..5602018b30 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -23,6 +23,7 @@ #include <sockunion.h> #include <nexthop.h> #include <nexthop_group.h> +#include <nexthop_group_private.h> #include <vty.h> #include <command.h> #include <jhash.h> @@ -112,7 +113,7 @@ void nexthop_group_delete(struct nexthop_group **nhg) } /* Add nexthop to the end of a nexthop list. */ -void nexthop_add(struct nexthop **target, struct nexthop *nexthop) +void _nexthop_add(struct nexthop **target, struct nexthop *nexthop) { struct nexthop *last; @@ -125,8 +126,8 @@ void nexthop_add(struct nexthop **target, struct nexthop *nexthop) nexthop->prev = last; } -void nexthop_group_add_sorted(struct nexthop_group *nhg, - struct nexthop *nexthop) +void _nexthop_group_add_sorted(struct nexthop_group *nhg, + struct nexthop *nexthop) { struct nexthop *position, *prev; @@ -151,11 +152,10 @@ void nexthop_group_add_sorted(struct nexthop_group *nhg, prev->next = nexthop; else nhg->nexthop = nexthop; - } /* Delete nexthop from a nexthop list. */ -void nexthop_del(struct nexthop_group *nhg, struct nexthop *nh) +void _nexthop_del(struct nexthop_group *nhg, struct nexthop *nh) { struct nexthop *nexthop; @@ -186,7 +186,7 @@ void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh, for (nh1 = nh; nh1; nh1 = nh1->next) { nexthop = nexthop_dup(nh1, rparent); - nexthop_add(tnh, nexthop); + _nexthop_add(tnh, nexthop); if (CHECK_FLAG(nh1->flags, NEXTHOP_FLAG_RECURSIVE)) copy_nexthops(&nexthop->resolved, nh1->resolved, @@ -217,7 +217,7 @@ static void nhgc_delete_nexthops(struct nexthop_group_cmd *nhgc) while (nexthop) { struct nexthop *next = nexthop_next(nexthop); - nexthop_del(&nhgc->nhg, nexthop); + _nexthop_del(&nhgc->nhg, nexthop); if (nhg_hooks.del_nexthop) nhg_hooks.del_nexthop(nhgc, nexthop); @@ -481,7 +481,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, if (no) { nexthop_group_unsave_nhop(nhgc, name, addr, intf); if (nh) { - nexthop_del(&nhgc->nhg, nh); + _nexthop_del(&nhgc->nhg, nh); if (nhg_hooks.del_nexthop) nhg_hooks.del_nexthop(nhgc, nh); @@ -494,7 +494,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd, nh = nexthop_new(); memcpy(nh, &nhop, sizeof(nhop)); - nexthop_add(&nhgc->nhg.nexthop, nh); + _nexthop_add(&nhgc->nhg.nexthop, nh); } nexthop_group_save_nhop(nhgc, name, addr, intf); @@ -618,7 +618,7 @@ void nexthop_group_enable_vrf(struct vrf *vrf) nh = nexthop_new(); memcpy(nh, &nhop, sizeof(nhop)); - nexthop_add(&nhgc->nhg.nexthop, nh); + _nexthop_add(&nhgc->nhg.nexthop, nh); if (nhg_hooks.add_nexthop) nhg_hooks.add_nexthop(nhgc, nh); @@ -651,7 +651,7 @@ void nexthop_group_disable_vrf(struct vrf *vrf) if (nh->vrf_id != vrf->vrf_id) continue; - nexthop_del(&nhgc->nhg, nh); + _nexthop_del(&nhgc->nhg, nh); if (nhg_hooks.del_nexthop) nhg_hooks.del_nexthop(nhgc, nh); @@ -701,7 +701,7 @@ void nexthop_group_interface_state_change(struct interface *ifp, nh = nexthop_new(); memcpy(nh, &nhop, sizeof(nhop)); - nexthop_add(&nhgc->nhg.nexthop, nh); + _nexthop_add(&nhgc->nhg.nexthop, nh); if (nhg_hooks.add_nexthop) nhg_hooks.add_nexthop(nhgc, nh); @@ -725,7 +725,7 @@ void nexthop_group_interface_state_change(struct interface *ifp, if (oldifindex != nh->ifindex) continue; - nexthop_del(&nhgc->nhg, nh); + _nexthop_del(&nhgc->nhg, nh); if (nhg_hooks.del_nexthop) nhg_hooks.del_nexthop(nhgc, nh); diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 104e2051f5..4f4d40eb33 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -42,12 +42,8 @@ struct nexthop_group { 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_group_add_sorted(struct nexthop_group *nhg, - struct nexthop *nexthop); void nexthop_group_copy(struct nexthop_group *to, struct nexthop_group *from); -void nexthop_del(struct nexthop_group *nhg, struct nexthop *nexthop); void copy_nexthops(struct nexthop **tnh, const struct nexthop *nh, struct nexthop *rparent); diff --git a/lib/nexthop_group_private.h b/lib/nexthop_group_private.h new file mode 100644 index 0000000000..cdd0df0ab3 --- /dev/null +++ b/lib/nexthop_group_private.h @@ -0,0 +1,45 @@ +/* + * Nexthop Group Private Functions. + * Copyright (C) 2019 Cumulus Networks, Inc. + * Stephen Worley + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * These functions should only be used internally for nexthop groups + * and in certain special cases. Please use `lib/nexthop_group.h` for + * any general nexthop_group api needs. + */ + +#ifndef __NEXTHOP_GROUP_PRIVATE__ +#define __NEXTHOP_GROUP_PRIVATE__ + +#include <nexthop_group.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void _nexthop_add(struct nexthop **target, struct nexthop *nexthop); +void _nexthop_del(struct nexthop_group *nhg, struct nexthop *nexthop); +void _nexthop_group_add_sorted(struct nexthop_group *nhg, + struct nexthop *nexthop); + +#ifdef __cplusplus +} +#endif + +#endif /* __NEXTHOP_GROUP_PRIVATE__ */ diff --git a/lib/subdir.am b/lib/subdir.am index 8b6cbe2aeb..8223bd547c 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -188,6 +188,7 @@ pkginclude_HEADERS += \ lib/network.h \ lib/nexthop.h \ lib/nexthop_group.h \ + lib/nexthop_group_private.h \ lib/northbound.h \ lib/northbound_cli.h \ lib/northbound_db.h \ |
