summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-03-10 13:00:32 -0500
committerDavid Lamparter <equinox@diac24.net>2021-03-14 22:56:07 +0100
commitd47b448de5f997632d675ebb60d2c345690b4e11 (patch)
treefb3fe7c5386352638443d09e40d0eb1ffcf611cb
parent4f278784d6a3b8e620b24a1d3548bf127777f7ba (diff)
ospf6d: Convert to use builtin printf functionality
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
-rw-r--r--ospf6d/ospf6_message.c68
-rw-r--r--ospf6d/ospf6_zebra.c10
2 files changed, 24 insertions, 54 deletions
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 349dc50b8c..6f6e2e1589 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -86,13 +86,9 @@ const uint16_t ospf6_lsa_minlen[OSPF6_LSTYPE_SIZE] = {
static void ospf6_header_print(struct ospf6_header *oh)
{
- char router_id[16], area_id[16];
- inet_ntop(AF_INET, &oh->router_id, router_id, sizeof(router_id));
- inet_ntop(AF_INET, &oh->area_id, area_id, sizeof(area_id));
-
- zlog_debug(" OSPFv%d Type:%d Len:%hu Router-ID:%s", oh->version,
- oh->type, ntohs(oh->length), router_id);
- zlog_debug(" Area-ID:%s Cksum:%hx Instance-ID:%d", area_id,
+ zlog_debug(" OSPFv%d Type:%d Len:%hu Router-ID:%pI4", oh->version,
+ oh->type, ntohs(oh->length), &oh->router_id);
+ zlog_debug(" Area-ID:%pI4 Cksum:%hx Instance-ID:%d", &oh->area_id,
ntohs(oh->checksum), oh->instance_id);
}
@@ -100,7 +96,6 @@ void ospf6_hello_print(struct ospf6_header *oh)
{
struct ospf6_hello *hello;
char options[16];
- char drouter[16], bdrouter[16], neighbor[16];
char *p;
ospf6_header_print(oh);
@@ -109,8 +104,6 @@ void ospf6_hello_print(struct ospf6_header *oh)
hello = (struct ospf6_hello *)((caddr_t)oh
+ sizeof(struct ospf6_header));
- inet_ntop(AF_INET, &hello->drouter, drouter, sizeof(drouter));
- inet_ntop(AF_INET, &hello->bdrouter, bdrouter, sizeof(bdrouter));
ospf6_options_printbuf(hello->options, options, sizeof(options));
zlog_debug(" I/F-Id:%ld Priority:%d Option:%s",
@@ -118,14 +111,12 @@ void ospf6_hello_print(struct ospf6_header *oh)
options);
zlog_debug(" HelloInterval:%hu DeadInterval:%hu",
ntohs(hello->hello_interval), ntohs(hello->dead_interval));
- zlog_debug(" DR:%s BDR:%s", drouter, bdrouter);
+ zlog_debug(" DR:%pI4 BDR:%pI4", &hello->drouter, &hello->bdrouter);
for (p = (char *)((caddr_t)hello + sizeof(struct ospf6_hello));
p + sizeof(uint32_t) <= OSPF6_MESSAGE_END(oh);
- p += sizeof(uint32_t)) {
- inet_ntop(AF_INET, (void *)p, neighbor, sizeof(neighbor));
- zlog_debug(" Neighbor: %s", neighbor);
- }
+ p += sizeof(uint32_t))
+ zlog_debug(" Neighbor: %pI4", p);
assert(p == OSPF6_MESSAGE_END(oh));
}
@@ -162,7 +153,6 @@ void ospf6_dbdesc_print(struct ospf6_header *oh)
void ospf6_lsreq_print(struct ospf6_header *oh)
{
- char id[16], adv_router[16];
char *p;
ospf6_header_print(oh);
@@ -172,11 +162,9 @@ void ospf6_lsreq_print(struct ospf6_header *oh)
p + sizeof(struct ospf6_lsreq_entry) <= OSPF6_MESSAGE_END(oh);
p += sizeof(struct ospf6_lsreq_entry)) {
struct ospf6_lsreq_entry *e = (struct ospf6_lsreq_entry *)p;
- inet_ntop(AF_INET, &e->adv_router, adv_router,
- sizeof(adv_router));
- inet_ntop(AF_INET, &e->id, id, sizeof(id));
- zlog_debug(" [%s Id:%s Adv:%s]", ospf6_lstype_name(e->type),
- id, adv_router);
+
+ zlog_debug(" [%s Id:%pI4 Adv:%pI4]",
+ ospf6_lstype_name(e->type), &e->id, &e->adv_router);
}
assert(p == OSPF6_MESSAGE_END(oh));
@@ -856,15 +844,11 @@ static void ospf6_lsreq_recv(struct in6_addr *src, struct in6_addr *dst,
/* Find database copy */
lsa = ospf6_lsdb_lookup(e->type, e->id, e->adv_router, lsdb);
if (lsa == NULL) {
- char id[16], adv_router[16];
if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) {
- inet_ntop(AF_INET, &e->id, id, sizeof(id));
- inet_ntop(AF_INET, &e->adv_router, adv_router,
- sizeof(adv_router));
zlog_debug(
- "Can't find requested [%s Id:%s Adv:%s]",
- ospf6_lstype_name(e->type), id,
- adv_router);
+ "Can't find requested [%s Id:%pI4 Adv:%pI4]",
+ ospf6_lstype_name(e->type), &e->id,
+ &e->adv_router);
}
thread_add_event(master, bad_lsreq, on, 0, NULL);
return;
@@ -1321,7 +1305,6 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi,
struct ospf6_header *oh,
const unsigned bytesonwire)
{
- char buf[2][INET_ADDRSTRLEN];
if (MSG_OK != ospf6_packet_examin(oh, bytesonwire))
return MSG_NG;
@@ -1335,13 +1318,10 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi,
oi->interface->name);
else
zlog_warn(
- "VRF %s: I/F %s Area-ID mismatch (my %s, rcvd %s)",
+ "VRF %s: I/F %s Area-ID mismatch (my %pI4, rcvd %pI4)",
vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name,
- inet_ntop(AF_INET, &oi->area->area_id, buf[0],
- INET_ADDRSTRLEN),
- inet_ntop(AF_INET, &oh->area_id, buf[1],
- INET_ADDRSTRLEN));
+ oi->interface->name, &oi->area->area_id,
+ &oh->area_id);
return MSG_NG;
}
@@ -1356,11 +1336,9 @@ static int ospf6_rxpacket_examin(struct ospf6_interface *oi,
/* Router-ID check */
if (oh->router_id == oi->area->ospf6->router_id) {
- zlog_warn("VRF %s: I/F %s Duplicate Router-ID (%s)",
+ zlog_warn("VRF %s: I/F %s Duplicate Router-ID (%pI4)",
vrf_id_to_name(oi->interface->vrf_id),
- oi->interface->name,
- inet_ntop(AF_INET, &oh->router_id, buf[0],
- INET_ADDRSTRLEN));
+ oi->interface->name, &oh->router_id);
return MSG_NG;
}
return MSG_OK;
@@ -1541,7 +1519,6 @@ int ospf6_receive(struct thread *thread)
{
int sockfd;
unsigned int len;
- char srcname[64], dstname[64];
struct in6_addr src, dst;
ifindex_t ifindex;
struct iovec iovector[2];
@@ -1598,13 +1575,11 @@ int ospf6_receive(struct thread *thread)
/* Log */
if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) {
- inet_ntop(AF_INET6, &src, srcname, sizeof(srcname));
- inet_ntop(AF_INET6, &dst, dstname, sizeof(dstname));
zlog_debug("%s received on %s",
lookup_msg(ospf6_message_type_str, oh->type, NULL),
oi->interface->name);
- zlog_debug(" src: %s", srcname);
- zlog_debug(" dst: %s", dstname);
+ zlog_debug(" src: %pI4", &src);
+ zlog_debug(" dst: %pI4", &dst);
switch (oh->type) {
case OSPF6_MESSAGE_TYPE_HELLO:
@@ -1659,7 +1634,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst,
struct ospf6_interface *oi, struct ospf6_header *oh)
{
unsigned int len;
- char srcname[64], dstname[64];
+ char srcname[64];
struct iovec iovector[2];
/* initialize */
@@ -1680,7 +1655,6 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst,
/* Log */
if (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND)) {
- inet_ntop(AF_INET6, dst, dstname, sizeof(dstname));
if (src)
inet_ntop(AF_INET6, src, srcname, sizeof(srcname));
else
@@ -1689,7 +1663,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst,
lookup_msg(ospf6_message_type_str, oh->type, NULL),
oi->interface->name);
zlog_debug(" src: %s", srcname);
- zlog_debug(" dst: %s", dstname);
+ zlog_debug(" dst: %pI4", dst);
switch (oh->type) {
case OSPF6_MESSAGE_TYPE_HELLO:
diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c
index 2b7072d34f..9b9453ce24 100644
--- a/ospf6d/ospf6_zebra.c
+++ b/ospf6d/ospf6_zebra.c
@@ -96,13 +96,9 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
return 0;
o->router_id_zebra = router_id.u.prefix4;
- if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
- char buf[INET_ADDRSTRLEN];
-
- zlog_debug("%s: zebra router-id %s update", __func__,
- inet_ntop(AF_INET, &router_id.u.prefix4, buf,
- INET_ADDRSTRLEN));
- }
+ if (IS_OSPF6_DEBUG_ZEBRA(RECV))
+ zlog_debug("%s: zebra router-id %pI4 update", __func__,
+ &router_id.u.prefix4);
ospf6_router_id_update(o);