From 2bd8bc157d0368c28ed312c6ab7e76d67921115b Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Thu, 22 Oct 2020 14:27:38 -0400 Subject: [PATCH] babeld: replace inet_ntoa Replace use of inet_ntoa, using pI4, pFX, or inet_pton. Signed-off-by: Mark Stapp --- babeld/babel_filter.c | 32 ++++++++------------------------ babeld/babel_interface.c | 4 +++- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/babeld/babel_filter.c b/babeld/babel_filter.c index 28ba8e16a2..731ad1ba8b 100644 --- a/babeld/babel_filter.c +++ b/babeld/babel_filter.c @@ -59,24 +59,16 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, if (access_list_apply (babel_ifp->list[distribute], &p) == FILTER_DENY) { debugf(BABEL_DEBUG_FILTER, - "%s/%d filtered by distribute %s", - p.family == AF_INET ? - inet_ntoa(p.u.prefix4) : - inet6_ntoa (p.u.prefix6), - p.prefixlen, - output ? "out" : "in"); + "%pFX filtered by distribute %s", + &p, output ? "out" : "in"); return INFINITY; } } if (babel_ifp != NULL && babel_ifp->prefix[distribute]) { if (prefix_list_apply (babel_ifp->prefix[distribute], &p) == PREFIX_DENY) { - debugf(BABEL_DEBUG_FILTER, "%s/%d filtered by distribute %s", - p.family == AF_INET ? - inet_ntoa(p.u.prefix4) : - inet6_ntoa (p.u.prefix6), - p.prefixlen, - output ? "out" : "in"); + debugf(BABEL_DEBUG_FILTER, "%pFX filtered by distribute %s", + &p, output ? "out" : "in"); return INFINITY; } } @@ -91,12 +83,8 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, if (alist) { if (access_list_apply (alist, &p) == FILTER_DENY) { - debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s", - p.family == AF_INET ? - inet_ntoa(p.u.prefix4) : - inet6_ntoa (p.u.prefix6), - p.prefixlen, - output ? "out" : "in"); + debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s", + &p, output ? "out" : "in"); return INFINITY; } } @@ -105,12 +93,8 @@ babel_filter(int output, const unsigned char *prefix, unsigned short plen, plist = prefix_list_lookup (p.family, dist->prefix[distribute]); if (plist) { if (prefix_list_apply (plist, &p) == PREFIX_DENY) { - debugf(BABEL_DEBUG_FILTER,"%s/%d filtered by distribute %s", - p.family == AF_INET ? - inet_ntoa(p.u.prefix4) : - inet6_ntoa (p.u.prefix6), - p.prefixlen, - output ? "out" : "in"); + debugf(BABEL_DEBUG_FILTER,"%pFX filtered by distribute %s", + &p, output ? "out" : "in"); return INFINITY; } } diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index 1702d9277c..ae8b161b01 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -1106,6 +1106,7 @@ DEFUN (show_babel_route_addr, { struct in_addr addr; char buf[INET_ADDRSTRLEN + 8]; + char buf1[INET_ADDRSTRLEN + 8]; struct route_stream *routes = NULL; struct xroute_stream *xroutes = NULL; struct prefix prefix; @@ -1118,7 +1119,8 @@ DEFUN (show_babel_route_addr, } /* Quagga has no convenient prefix constructors. */ - snprintf(buf, sizeof(buf), "%s/%d", inet_ntoa(addr), 32); + snprintf(buf, sizeof(buf), "%s/%d", + inet_ntop(AF_INET, &addr, buf1, sizeof(buf1)), 32); ret = str2prefix(buf, &prefix); if (ret == 0) { -- 2.39.5