From 257a6b0b7e76e17bdd6e107ae643db4466960654 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 3 Aug 2023 17:19:42 +1000 Subject: netlink: Split nl_route() into separate operation functions nl_route() can perform 3 quite different operations based on the 'op' parameter. Split this into separate functions for each one. This requires more lines of code, but makes the internal logic of each operation much easier to follow. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- netlink.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'netlink.h') diff --git a/netlink.h b/netlink.h index 5ac972d..36bbf9f 100644 --- a/netlink.h +++ b/netlink.h @@ -6,16 +6,11 @@ #ifndef NETLINK_H #define NETLINK_H -enum nl_op { - NL_GET, - NL_SET, - NL_DUP, -}; - void nl_sock_init(const struct ctx *c, bool ns); unsigned int nl_get_ext_if(sa_family_t af); -void nl_route(enum nl_op op, unsigned int ifi, unsigned int ifi_ns, - sa_family_t af, void *gw); +void nl_route_get_def(unsigned int ifi, sa_family_t af, void *gw); +void nl_route_set_def(unsigned int ifi, sa_family_t af, void *gw); +void nl_route_dup(unsigned int ifi, unsigned int ifi_ns, sa_family_t af); void nl_addr_get(unsigned int ifi, sa_family_t af, void *addr, int *prefix_len, void *addr_l); void nl_addr_set(unsigned int ifi, sa_family_t af, void *addr, int prefix_len); -- cgit v1.2.3