From 52bed1e72bcfad889293f64c6db848560e72c4c2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 3 Jul 2018 18:07:46 -0500 Subject: [PATCH] common/ipaddr: expose netmask_ipv[46] Signed-off-by: Sage Weil --- src/common/ipaddr.cc | 8 ++++---- src/include/ipaddr.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/ipaddr.cc b/src/common/ipaddr.cc index c880bfd402e..0ee96eb9dcc 100644 --- a/src/common/ipaddr.cc +++ b/src/common/ipaddr.cc @@ -11,7 +11,7 @@ #include "include/ipaddr.h" -static void netmask_ipv4(const struct in_addr *addr, +void netmask_ipv4(const struct in_addr *addr, unsigned int prefix_len, struct in_addr *out) { uint32_t mask; @@ -57,9 +57,9 @@ const struct ifaddrs *find_ipv4_in_subnet(const struct ifaddrs *addrs, } -static void netmask_ipv6(const struct in6_addr *addr, - unsigned int prefix_len, - struct in6_addr *out) { +void netmask_ipv6(const struct in6_addr *addr, + unsigned int prefix_len, + struct in6_addr *out) { if (prefix_len > 128) prefix_len = 128; diff --git a/src/include/ipaddr.h b/src/include/ipaddr.h index e4c9d4cf0c5..5ded4200a93 100644 --- a/src/include/ipaddr.h +++ b/src/include/ipaddr.h @@ -24,4 +24,11 @@ const struct ifaddrs *find_ip_in_subnet(const struct ifaddrs *addrs, */ bool parse_network(const char *s, struct sockaddr_storage *network, unsigned int *prefix_len); +void netmask_ipv6(const struct in6_addr *addr, + unsigned int prefix_len, + struct in6_addr *out); + +void netmask_ipv4(const struct in_addr *addr, + unsigned int prefix_len, + struct in_addr *out); #endif -- 2.47.3