summaryrefslogtreecommitdiff
path: root/sbin/iked/vroute.c
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-06-13 12:34:13 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-06-13 12:34:13 +0000
commit86cafb24fd32eb7c1b50ad9aada3000d37624812 (patch)
tree965fd4d3e5fa993ac19eb7e2adcb4d3a5ee55984 /sbin/iked/vroute.c
parenteeab0fade1462dbbc6dd2a47c9bea03d2d20113d (diff)
iked: introduce and use print_addr()
The vast majority of print_host() callers cast the first argument (usually a sockaddr_storage *) to (struct sockaddr *) and pass both a NULL buffer and 0 length. Cast and useless arguments lead to awkward line wrapping in many places. Clean this up by introducing a helper. Make this helper take a void pointer, so all casts go away. ok claudio kn tobhe
Diffstat (limited to 'sbin/iked/vroute.c')
-rw-r--r--sbin/iked/vroute.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sbin/iked/vroute.c b/sbin/iked/vroute.c
index 7f900e771e3..5ef892d61ab 100644
--- a/sbin/iked/vroute.c
+++ b/sbin/iked/vroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vroute.c,v 1.18 2023/02/10 19:51:08 tobhe Exp $ */
+/* $OpenBSD: vroute.c,v 1.19 2023/06/13 12:34:12 tb Exp $ */
/*
* Copyright (c) 2021 Tobias Heider <tobhe@openbsd.org>
@@ -840,9 +840,9 @@ vroute_doroute(struct iked *env, int flags, int addrs, int rdomain, uint8_t type
flags & RTF_HOST ? "H" : "",
flags & RTF_GATEWAY ? "G" : "",
addrs,
- addrs & RTA_DST ? print_host(dest, NULL, 0) : "<>",
- addrs & RTA_NETMASK ? print_host(mask, NULL, 0) : "<>",
- addrs & RTA_GATEWAY ? print_host(addr, NULL, 0) : "<>");
+ addrs & RTA_DST ? print_addr(dest) : "<>",
+ addrs & RTA_NETMASK ? print_addr(mask) : "<>",
+ addrs & RTA_GATEWAY ? print_addr(addr) : "<>");
if (writev(ivr->ivr_rtsock, iov, iovcnt) == -1) {
if ((type == RTM_ADD && errno != EEXIST) ||
@@ -933,9 +933,7 @@ vroute_doaddr(struct iked *env, char *ifname, struct sockaddr *addr,
memcpy(&req.ifra_mask, mask, sizeof(req.ifra_addr));
log_debug("%s: %s inet %s netmask %s", __func__,
- add ? "add" : "del",
- print_host((struct sockaddr *)addr, NULL, 0),
- print_host((struct sockaddr *)mask, NULL, 0));
+ add ? "add" : "del", print_addr(addr), print_addr(mask));
ioreq = add ? SIOCAIFADDR : SIOCDIFADDR;
if (ioctl(ivr->ivr_iosock, ioreq, &req) == -1) {
@@ -955,9 +953,7 @@ vroute_doaddr(struct iked *env, char *ifname, struct sockaddr *addr,
sizeof(req6.ifra_prefixmask));
log_debug("%s: %s inet6 %s netmask %s", __func__,
- add ? "add" : "del",
- print_host((struct sockaddr *)addr, NULL, 0),
- print_host((struct sockaddr *)mask, NULL, 0));
+ add ? "add" : "del", print_addr(addr), print_addr(mask));
ioreq = add ? SIOCAIFADDR_IN6 : SIOCDIFADDR_IN6;
if (ioctl(ivr->ivr_iosock6, ioreq, &req6) == -1) {