#include "string-util.h"
#include "util.h"
-int nexthop_new(NextHop **ret) {
+void nexthop_free(NextHop *nexthop) {
+ if (!nexthop)
+ return;
+
+ if (nexthop->network) {
+ LIST_REMOVE(nexthops, nexthop->network->static_nexthops, nexthop);
+
+ assert(nexthop->network->n_static_nexthops > 0);
+ nexthop->network->n_static_nexthops--;
+
+ if (nexthop->section)
+ hashmap_remove(nexthop->network->nexthops_by_section, nexthop->section);
+ }
+
+ network_config_section_free(nexthop->section);
+
+ if (nexthop->link) {
+ set_remove(nexthop->link->nexthops, nexthop);
+ set_remove(nexthop->link->nexthops_foreign, nexthop);
+ }
+
+ free(nexthop);
+}
+
+DEFINE_NETWORK_SECTION_FUNCTIONS(NextHop, nexthop_free);
+
+static int nexthop_new(NextHop **ret) {
_cleanup_(nexthop_freep) NextHop *nexthop = NULL;
nexthop = new(NextHop, 1);
return 0;
}
-void nexthop_free(NextHop *nexthop) {
- if (!nexthop)
- return;
-
- if (nexthop->network) {
- LIST_REMOVE(nexthops, nexthop->network->static_nexthops, nexthop);
-
- assert(nexthop->network->n_static_nexthops > 0);
- nexthop->network->n_static_nexthops--;
-
- if (nexthop->section)
- hashmap_remove(nexthop->network->nexthops_by_section, nexthop->section);
- }
-
- network_config_section_free(nexthop->section);
-
- if (nexthop->link) {
- set_remove(nexthop->link->nexthops, nexthop);
- set_remove(nexthop->link->nexthops_foreign, nexthop);
- }
-
- free(nexthop);
-}
-
static void nexthop_hash_func(const NextHop *nexthop, struct siphash *state) {
assert(nexthop);
return nexthop_compare_func(r1, r2) == 0;
}
-int nexthop_get(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_get(Link *link, NextHop *in, NextHop **ret) {
NextHop *existing;
assert(link);
return 0;
}
-int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret) {
return nexthop_add_internal(link, &link->nexthops_foreign, in, ret);
}
-int nexthop_add(Link *link, NextHop *in, NextHop **ret) {
+static int nexthop_add(Link *link, NextHop *in, NextHop **ret) {
NextHop *nexthop;
int r;
LIST_FIELDS(NextHop, nexthops);
};
-extern const struct hash_ops nexthop_hash_ops;
-
-int nexthop_new(NextHop **ret);
void nexthop_free(NextHop *nexthop);
int nexthop_remove(NextHop *nexthop, Link *link, link_netlink_message_handler_t callback);
int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);
-int nexthop_get(Link *link, NextHop *in, NextHop **ret);
-int nexthop_add(Link *link, NextHop *in, NextHop **ret);
-int nexthop_add_foreign(Link *link, NextHop *in, NextHop **ret);
bool nexthop_equal(NextHop *r1, NextHop *r2);
int nexthop_section_verify(NextHop *nexthop);
-DEFINE_NETWORK_SECTION_FUNCTIONS(NextHop, nexthop_free);
-
CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_id);
CONFIG_PARSER_PROTOTYPE(config_parse_nexthop_gateway);