summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/conf/files3
-rw-r--r--sys/dev/vmt.c7
-rw-r--r--sys/net/if.c14
-rw-r--r--sys/net/if_spppsubr.c18
-rw-r--r--sys/net/pf_osfp.c7
-rw-r--r--sys/net/pipex.c13
-rw-r--r--sys/netinet/if_ether.c36
-rw-r--r--sys/netinet/in.h4
-rw-r--r--sys/netinet/inet_ntop.c198
-rw-r--r--sys/netinet/ip_icmp.c31
-rw-r--r--sys/netinet/ip_input.c15
-rw-r--r--sys/netinet/ip_ipsp.c32
-rw-r--r--sys/netinet/ip_ipsp.h5
-rw-r--r--sys/netinet/ipsec_input.c26
-rw-r--r--sys/netinet6/frag6.c10
-rw-r--r--sys/netinet6/icmp6.c38
-rw-r--r--sys/netinet6/in6.c111
-rw-r--r--sys/netinet6/in6_src.c10
-rw-r--r--sys/netinet6/ip6_forward.c18
-rw-r--r--sys/netinet6/ip6_input.c9
-rw-r--r--sys/netinet6/ip6_mroute.c106
-rw-r--r--sys/netinet6/mld6.c8
-rw-r--r--sys/netinet6/nd6.c33
-rw-r--r--sys/netinet6/nd6_nbr.c83
-rw-r--r--sys/netinet6/nd6_rtr.c102
-rw-r--r--sys/nfs/krpc_subr.c6
-rw-r--r--sys/nfs/nfs_boot.c13
27 files changed, 667 insertions, 289 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 20a27803d57..7284beac2ab 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.561 2013/10/29 04:23:16 dlg Exp $
+# $OpenBSD: files,v 1.562 2013/11/11 09:15:34 mpi Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -820,6 +820,7 @@ file netinet/in.c inet
file netinet/in_pcb.c inet
file netinet/in_proto.c inet
file netinet/inet_nat64.c inet & pf
+file netinet/inet_ntop.c inet | inet6
file netinet/ip_divert.c inet & pf
file netinet/ip_icmp.c inet
file netinet/ip_id.c inet
diff --git a/sys/dev/vmt.c b/sys/dev/vmt.c
index 3c226e0a512..4ca86da4607 100644
--- a/sys/dev/vmt.c
+++ b/sys/dev/vmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmt.c,v 1.15 2013/10/26 21:05:09 deraadt Exp $ */
+/* $OpenBSD: vmt.c,v 1.16 2013/11/11 09:15:34 mpi Exp $ */
/*
* Copyright (c) 2007 David Crawshaw <david@zentus.com>
@@ -621,8 +621,11 @@ vmt_tclo_tick(void *xarg)
}
if (guest_ip != NULL) {
+ char ip[INET_ADDRSTRLEN];
+
+ inet_ntop(AF_INET, &guest_ip->sin_addr, ip, sizeof(ip));
if (vm_rpc_send_rpci_tx(sc, "info-set guestinfo.ip %s",
- inet_ntoa(guest_ip->sin_addr)) != 0) {
+ ip) != 0) {
printf("%s: unable to send guest IP address\n", DEVNAME(sc));
sc->sc_rpc_error = 1;
}
diff --git a/sys/net/if.c b/sys/net/if.c
index 5a3e042ef5a..04f0b6d389d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.274 2013/10/23 15:12:42 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.275 2013/11/11 09:15:34 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -2266,15 +2266,19 @@ ifa_print_rb(void)
struct ifaddr_item *ifai, *p;
RB_FOREACH(p, ifaddr_items, &ifaddr_items) {
for (ifai = p; ifai; ifai = ifai->ifai_next) {
+ char addr[INET6_ADDRSTRLEN];
+
switch (ifai->ifai_addr->sa_family) {
case AF_INET:
- printf("%s", inet_ntoa((satosin(
- ifai->ifai_addr))->sin_addr));
+ printf("%s", inet_ntop(AF_INET,
+ &satosin(ifai->ifai_addr)->sin_addr,
+ addr, sizeof(addr)));
break;
#ifdef INET6
case AF_INET6:
- printf("%s", ip6_sprintf(&(satosin6(
- ifai->ifai_addr))->sin6_addr));
+ printf("%s", inet_ntop(AF_INET6,
+ &(satosin6(ifai->ifai_addr))->sin6_addr,
+ addr, sizeof(addr)));
break;
#endif
case AF_LINK:
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 673b8436e56..b3ba8dc9c69 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_spppsubr.c,v 1.110 2013/11/05 15:32:48 stsp Exp $ */
+/* $OpenBSD: if_spppsubr.c,v 1.111 2013/11/11 09:15:34 mpi Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
* Keepalive protocol implemented in both Cisco and PPP modes.
@@ -3173,6 +3173,7 @@ sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
int ifidcount;
int type;
int collision, nohisaddr;
+ char addr[INET6_ADDRSTRLEN];
len -= 4;
origlen = len;
@@ -3268,7 +3269,8 @@ sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
if (debug) {
addlog(" %s [%s]",
- ip6_sprintf(&desiredaddr),
+ inet_ntop(AF_INET6, &desiredaddr,
+ addr, sizeof(addr)),
sppp_cp_type_name(type));
}
continue;
@@ -3290,7 +3292,9 @@ sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
bcopy(&suggestaddr.s6_addr[8], &p[2], 8);
}
if (debug)
- addlog(" %s [%s]", ip6_sprintf(&desiredaddr),
+ addlog(" %s [%s]",
+ inet_ntop(AF_INET6, &desiredaddr, addr,
+ sizeof(addr)),
sppp_cp_type_name(type));
break;
}
@@ -3312,7 +3316,9 @@ sppp_ipv6cp_RCR(struct sppp *sp, struct lcp_header *h, int len)
if (debug) {
addlog(" send %s suggest %s\n",
- sppp_cp_type_name(type), ip6_sprintf(&suggestaddr));
+ sppp_cp_type_name(type),
+ inet_ntop(AF_INET6, &suggestaddr, addr,
+ sizeof(addr)));
}
sppp_cp_send(sp, PPP_IPV6CP, type, h->ident, rlen, buf);
}
@@ -3368,6 +3374,7 @@ sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
struct ifnet *ifp = &sp->pp_if;
int debug = ifp->if_flags & IFF_DEBUG;
struct in6_addr suggestaddr;
+ char addr[INET6_ADDRSTRLEN];
len -= 4;
@@ -3397,7 +3404,8 @@ sppp_ipv6cp_RCN_nak(struct sppp *sp, struct lcp_header *h, int len)
sp->ipv6cp.opts |= (1 << IPV6CP_OPT_IFID);
if (debug)
addlog(" [suggestaddr %s]",
- ip6_sprintf(&suggestaddr));
+ inet_ntop(AF_INET6, &suggestaddr, addr,
+ sizeof(addr)));
#ifdef IPV6CP_MYIFID_DYN
/*
* When doing dynamic address assignment,
diff --git a/sys/net/pf_osfp.c b/sys/net/pf_osfp.c
index e778ecca255..7fbec60a355 100644
--- a/sys/net/pf_osfp.c
+++ b/sys/net/pf_osfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_osfp.c,v 1.27 2013/10/24 11:31:43 mpi Exp $ */
+/* $OpenBSD: pf_osfp.c,v 1.28 2013/11/11 09:15:34 mpi Exp $ */
/*
* Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
@@ -137,7 +137,7 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6,
if (ip->ip_off & htons(IP_DF))
fp.fp_flags |= PF_OSFP_DF;
#ifdef _KERNEL
- strlcpy(srcname, inet_ntoa(ip->ip_src), sizeof(srcname));
+ inet_ntop(AF_INET, &ip->ip_src, srcname, sizeof(srcname));
#else
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
@@ -160,8 +160,7 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6,
fp.fp_flags |= PF_OSFP_DF;
fp.fp_flags |= PF_OSFP_INET6;
#ifdef _KERNEL
- strlcpy(srcname, ip6_sprintf((struct in6_addr *)&ip6->ip6_src),
- sizeof(srcname));
+ inet_ntop(AF_INET6, &ip6->ip6_src, srcname, sizeof(srcname));
#else
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_family = AF_INET6;
diff --git a/sys/net/pipex.c b/sys/net/pipex.c
index 89cb33c71b0..9fc28deeeb6 100644
--- a/sys/net/pipex.c
+++ b/sys/net/pipex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex.c,v 1.47 2013/10/24 11:31:43 mpi Exp $ */
+/* $OpenBSD: pipex.c,v 1.48 2013/11/11 09:15:34 mpi Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -652,9 +652,12 @@ pipex_lookup_by_ip_address(struct in_addr addr)
&pipex_in4, &pipex_in4mask, &pipex_rd_head4);
#ifdef PIPEX_DEBUG
- if (session == NULL)
+ if (session == NULL) {
+ char buf[INET_ADDRSTRLEN];
+
PIPEX_DBG((NULL, LOG_DEBUG, "<%s> session not found (addr=%s)",
- __func__, inet_ntoa(addr)));
+ __func__, inet_ntop(AF_INET, &addr, buf, sizeof(buf))));
+ }
#endif
return (session);
@@ -1146,9 +1149,11 @@ pipex_ip_input(struct mbuf *m0, struct pipex_session *session)
ip = mtod(m0, struct ip *);
if ((ip->ip_src.s_addr & session->ip_netmask.sin_addr.s_addr) !=
session->ip_address.sin_addr.s_addr) {
+ char src[INET_ADDRSTRLEN];
+
pipex_session_log(session, LOG_DEBUG,
"ip packet discarded by ingress filter (src %s)",
- inet_ntoa(ip->ip_src));
+ inet_ntop(AF_INET, &ip->ip_src, src, sizeof(src)));
goto drop;
}
}
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index db35ff46051..dd3a641d76b 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ether.c,v 1.110 2013/10/31 18:10:21 bluhm Exp $ */
+/* $OpenBSD: if_ether.c,v 1.111 2013/11/11 09:15:34 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
@@ -346,6 +346,7 @@ arpresolve(struct arpcom *ac, struct rtentry *rt, struct mbuf *m,
struct llinfo_arp *la;
struct sockaddr_dl *sdl;
struct mbuf *mh;
+ char addr[INET_ADDRSTRLEN];
if (m->m_flags & M_BCAST) { /* broadcast */
bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
@@ -360,8 +361,8 @@ arpresolve(struct arpcom *ac, struct rtentry *rt, struct mbuf *m,
la = (struct llinfo_arp *)rt->rt_llinfo;
if (la == NULL)
log(LOG_DEBUG, "arpresolve: %s: route without link "
- "local address\n",
- inet_ntoa(satosin(dst)->sin_addr));
+ "local address\n", inet_ntop(AF_INET,
+ &satosin(dst)->sin_addr, addr, sizeof(addr)));
} else {
if ((la = arplookup(satosin(dst)->sin_addr.s_addr, RT_REPORT, 0,
ac->ac_if.if_rdomain)) != NULL)
@@ -369,7 +370,8 @@ arpresolve(struct arpcom *ac, struct rtentry *rt, struct mbuf *m,
else
log(LOG_DEBUG,
"arpresolve: %s: can't allocate llinfo\n",
- inet_ntoa(satosin(dst)->sin_addr));
+ inet_ntop(AF_INET, &satosin(dst)->sin_addr,
+ addr, sizeof(addr)));
}
if (la == 0 || rt == 0) {
m_freem(m);
@@ -545,6 +547,7 @@ in_arpinput(struct mbuf *m)
#if NCARP > 0
u_int8_t *ether_shost = NULL;
#endif
+ char addr[INET_ADDRSTRLEN];
int op;
ea = mtod(m, struct ether_arp *);
@@ -618,14 +621,16 @@ in_arpinput(struct mbuf *m)
if (ETHER_IS_MULTICAST(&ea->arp_sha[0]))
if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
sizeof (ea->arp_sha))) {
+ inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_ERR, "arp: ether address is broadcast for "
- "IP address %s!\n", inet_ntoa(isaddr));
+ "IP address %s!\n", addr);
goto out;
}
if (myaddr.s_addr && isaddr.s_addr == myaddr.s_addr) {
+ inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_ERR,
"duplicate IP address %s sent from ethernet address %s\n",
- inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
+ addr, ether_sprintf(ea->arp_sha));
itaddr = myaddr;
goto reply;
}
@@ -635,10 +640,10 @@ in_arpinput(struct mbuf *m)
if (sdl->sdl_alen) {
if (bcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) {
if (rt->rt_flags & RTF_PERMANENT_ARP) {
+ inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_WARNING,
"arp: attempt to overwrite permanent "
- "entry for %s by %s on %s\n",
- inet_ntoa(isaddr),
+ "entry for %s by %s on %s\n", addr,
ether_sprintf(ea->arp_sha),
ac->ac_if.if_xname);
goto out;
@@ -646,18 +651,22 @@ in_arpinput(struct mbuf *m)
#if NCARP > 0
if (ac->ac_if.if_type != IFT_CARP)
#endif
+ {
+ inet_ntop(AF_INET, &isaddr,
+ addr, sizeof(addr));
log(LOG_WARNING,
"arp: attempt to overwrite entry for"
- " %s on %s by %s on %s\n",
- inet_ntoa(isaddr),
+ " %s on %s by %s on %s\n", addr,
rt->rt_ifp->if_xname,
ether_sprintf(ea->arp_sha),
ac->ac_if.if_xname);
+ }
goto out;
} else {
+ inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_INFO,
"arp info overwritten for %s by %s on %s\n",
- inet_ntoa(isaddr),
+ addr,
ether_sprintf(ea->arp_sha),
ac->ac_if.if_xname);
rt->rt_expire = 1; /* no longer static */
@@ -675,10 +684,11 @@ in_arpinput(struct mbuf *m)
ac->ac_if.if_carpdev == rt->rt_ifp) &&
#endif
1) {
+ inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_WARNING,
"arp: attempt to add entry for %s "
- "on %s by %s on %s\n",
- inet_ntoa(isaddr), rt->rt_ifp->if_xname,
+ "on %s by %s on %s\n", addr,
+ rt->rt_ifp->if_xname,
ether_sprintf(ea->arp_sha),
ac->ac_if.if_xname);
goto out;
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 42b2728e8b9..bbca4a052a2 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.100 2013/10/23 15:12:42 mpi Exp $ */
+/* $OpenBSD: in.h,v 1.101 2013/11/11 09:15:34 mpi Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -842,6 +842,8 @@ char *inet_ntoa(struct in_addr);
int inet_nat64(int, const void *, void *, const void *, u_int8_t);
int inet_nat46(int, const void *, void *, const void *, u_int8_t);
+const char *inet_ntop(int, const void *, char *, socklen_t);
+
#define in_hosteq(s,t) ((s).s_addr == (t).s_addr)
#define in_nullhost(x) ((x).s_addr == INADDR_ANY)
diff --git a/sys/netinet/inet_ntop.c b/sys/netinet/inet_ntop.c
new file mode 100644
index 00000000000..6a7944af579
--- /dev/null
+++ b/sys/netinet/inet_ntop.c
@@ -0,0 +1,198 @@
+/* $OpenBSD: inet_ntop.c,v 1.1 2013/11/11 09:15:34 mpi Exp $ */
+
+/* Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#define IN6ADDRSZ 16
+#define INT16SZ 2
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
+#ifdef INET6
+static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
+#endif /* INET6 */
+
+/* char *
+ * inet_ntop(af, src, dst, size)
+ * convert a network format address to presentation format.
+ * return:
+ * pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ * Paul Vixie, 1996.
+ */
+const char *
+inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+ switch (af) {
+ case AF_INET:
+ return (inet_ntop4(src, dst, (size_t)size));
+#ifdef INET6
+ case AF_INET6:
+ return (inet_ntop6(src, dst, (size_t)size));
+#endif /* INET6 */
+ default:
+ return (NULL);
+ }
+ /* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ * format an IPv4 address, more or less like inet_ntoa()
+ * return:
+ * `dst' (as a const)
+ * notes:
+ * (1) uses no statics
+ * (2) takes a u_char* not an in_addr as input
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const u_char *src, char *dst, size_t size)
+{
+ static const char fmt[] = "%u.%u.%u.%u";
+ char tmp[sizeof "255.255.255.255"];
+ int l;
+
+ l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
+ if (l <= 0 || l >= size) {
+ return (NULL);
+ }
+ strlcpy(dst, tmp, size);
+ return (dst);
+}
+
+#ifdef INET6
+/* const char *
+ * inet_ntop6(src, dst, size)
+ * convert IPv6 binary address into presentation (printable) format
+ * author:
+ * Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop6(const u_char *src, char *dst, size_t size)
+{
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
+ char *tp, *ep;
+ struct { int base, len; } best, cur;
+ u_int words[IN6ADDRSZ / INT16SZ];
+ int i;
+ int advance;
+
+ /*
+ * Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ memset(words, '\0', sizeof words);
+ for (i = 0; i < IN6ADDRSZ; i++)
+ words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+ best.base = -1;
+ cur.base = -1;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
+ if (words[i] == 0) {
+ if (cur.base == -1)
+ cur.base = i, cur.len = 1;
+ else
+ cur.len++;
+ } else {
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
+ }
+ }
+ }
+ if (cur.base != -1) {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ }
+ if (best.base != -1 && best.len < 2)
+ best.base = -1;
+
+ /*
+ * Format the result.
+ */
+ tp = tmp;
+ ep = tmp + sizeof(tmp);
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
+ /* Are we inside the best run of 0x00's? */
+ if (best.base != -1 && i >= best.base &&
+ i < (best.base + best.len)) {
+ if (i == best.base) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ continue;
+ }
+ /* Are we following an initial run of 0x00s or any real hex? */
+ if (i != 0) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ /* Is this address an encapsulated IPv4? */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+ if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
+ return (NULL);
+ tp += strlen(tp);
+ break;
+ }
+ advance = snprintf(tp, ep - tp, "%x", words[i]);
+ if (advance <= 0 || advance >= ep - tp)
+ return (NULL);
+ tp += advance;
+ }
+ /* Was it a trailing run of 0x00's? */
+ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = ':';
+ }
+ if (tp + 1 >= ep)
+ return (NULL);
+ *tp++ = '\0';
+
+ /*
+ * Check for overflow, copy, and we're done.
+ */
+ if ((size_t)(tp - tmp) > size) {
+ return (NULL);
+ }
+ strlcpy(dst, tmp, size);
+ return (dst);
+}
+#endif /* INET6 */
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 65281ab8764..531d83fcd70 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.108 2013/10/21 12:27:11 deraadt Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.109 2013/11/11 09:15:34 mpi Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -323,11 +323,12 @@ icmp_input(struct mbuf *m, ...)
icmplen = ntohs(ip->ip_len) - hlen;
#ifdef ICMPPRINTFS
if (icmpprintfs) {
- char buf[4 * sizeof("123")];
+ char dst[INET_ADDRSTRLEN], src[INET_ADDRSTRLEN];
- strlcpy(buf, inet_ntoa(ip->ip_dst), sizeof buf);
- printf("icmp_input from %s to %s, len %d\n",
- inet_ntoa(ip->ip_src), buf, icmplen);
+ inet_ntop(AF_INET, &ip->ip_dst, dst, sizeof(dst));
+ inet_ntop(AF_INET, &ip->ip_src, src, sizeof(src));
+
+ printf("icmp_input from %s to %s, len %d\n", src, dst, icmplen);
}
#endif
if (icmplen < ICMP_MINLEN) {
@@ -614,12 +615,13 @@ reflect:
#ifdef ICMPPRINTFS
if (icmpprintfs) {
- char buf[4 * sizeof("123")];
- strlcpy(buf, inet_ntoa(icp->icmp_ip.ip_dst),
- sizeof buf);
+ char gw[INET_ADDRSTRLEN], dst[INET_ADDRSTRLEN];
+
+ inet_ntop(AF_INET, &icp->icmp_gwaddr, gw, sizeof(gw));
+ inet_ntop(AF_INET, &icp->icmp_ip.ip_dst,
+ dst, sizeof(dst));
- printf("redirect dst %s to %s\n",
- buf, inet_ntoa(icp->icmp_gwaddr));
+ printf("redirect dst %s to %s\n", dst, gw);
}
#endif
@@ -842,11 +844,12 @@ icmp_send(struct mbuf *m, struct mbuf *opts)
icp->icmp_cksum = in4_cksum(m, 0, hlen, ntohs(ip->ip_len) - hlen);
#ifdef ICMPPRINTFS
if (icmpprintfs) {
- char buf[4 * sizeof("123")];
+ char dst[INET_ADDRSTRLEN], src[INET_ADDRSTRLEN];
+
+ inet_ntop(AF_INET, &ip->ip_dst, dst, sizeof(dst));
+ inet_ntop(AF_INET, &ip->ip_src, src, sizeof(src));
- strlcpy(buf, inet_ntoa(ip->ip_dst), sizeof buf);
- printf("icmp_send dst %s src %s\n",
- buf, inet_ntoa(ip->ip_src));
+ printf("icmp_send dst %s src %s\n", dst, src);
}
#endif
(void)ip_output(m, opts, (void *)NULL, 0, (void *)NULL, (void *)NULL);
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 25af7a9b797..ff285013500 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.219 2013/10/23 19:09:28 deraadt Exp $ */
+/* $OpenBSD: ip_input.c,v 1.220 2013/11/11 09:15:34 mpi Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -124,19 +124,6 @@ struct ipstat ipstat;
void ip_ours(struct mbuf *);
int in_ouraddr(struct in_addr, struct mbuf *);
-char *
-inet_ntoa(ina)
- struct in_addr ina;
-{
- static char buf[4*sizeof "123"];
- unsigned char *ucp = (unsigned char *)&ina;
-
- snprintf(buf, sizeof buf, "%d.%d.%d.%d",
- ucp[0] & 0xff, ucp[1] & 0xff,
- ucp[2] & 0xff, ucp[3] & 0xff);
- return (buf);
-}
-
/*
* Used to save the IP options in case a protocol wants to respond
* to an incoming packet over the same route if the packet got here
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index 42acf37e8a6..0f53b582be8 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.191 2013/10/24 11:31:43 mpi Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.192 2013/11/11 09:15:34 mpi Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -981,34 +981,28 @@ tdb_add_inp(struct tdb *tdb, struct inpcb *inp, int inout)
}
#ifdef ENCDEBUG
-/* Return a printable string for the IPv4 address. */
-char *
-inet_ntoa4(struct in_addr ina)
-{
- static char buf[4][4 * sizeof "123" + 4];
- unsigned char *ucp = (unsigned char *) &ina;
- static int i = 3;
-
- i = (i + 1) % 4;
- snprintf(buf[i], sizeof buf[0], "%d.%d.%d.%d",
- ucp[0] & 0xff, ucp[1] & 0xff,
- ucp[2] & 0xff, ucp[3] & 0xff);
- return (buf[i]);
-}
-
/* Return a printable string for the address. */
-char *
+const char *
ipsp_address(union sockaddr_union sa)
{
+ static char ipspbuf[4][INET6_ADDRSTRLEN];
+ static int ipspround = 0;
+ char *buf;
+
+ ipspround = (ipspround + 1) % 4;
+ buf = ipspbuf[ipspround];
+
switch (sa.sa.sa_family) {
#ifdef INET
case AF_INET:
- return inet_ntoa4(sa.sin.sin_addr);
+ return inet_ntop(AF_INET, &sa.sin.sin_addr,
+ buf, INET_ADDRSTRLEN);
#endif /* INET */
#ifdef INET6
case AF_INET6:
- return ip6_sprintf(&sa.sin6.sin6_addr);
+ return inet_ntop(AF_INET6, &sa.sin6.sin6_addr,
+ buf, INET6_ADDRSTRLEN);
#endif /* INET6 */
default:
diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h
index c4ecfee8da3..5b700080960 100644
--- a/sys/netinet/ip_ipsp.h
+++ b/sys/netinet/ip_ipsp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.h,v 1.155 2013/07/04 09:48:49 mpi Exp $ */
+/* $OpenBSD: ip_ipsp.h,v 1.156 2013/11/11 09:15:35 mpi Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -503,8 +503,7 @@ do { \
/* Misc. */
uint8_t get_sa_require(struct inpcb *);
#ifdef ENCDEBUG
-char *inet_ntoa4(struct in_addr);
-char *ipsp_address(union sockaddr_union);
+const char *ipsp_address(union sockaddr_union);
#endif /* ENCDEBUG */
/* TDB management routines */
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index d503816c75b..1721aabe284 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.117 2013/10/23 15:12:42 mpi Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.118 2013/11/11 09:15:35 mpi Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -398,11 +398,15 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
tdbp->tdb_proxy.sin.sin_addr.s_addr) ||
(tdbp->tdb_proxy.sa.sa_family != AF_INET &&
tdbp->tdb_proxy.sa.sa_family != 0)) {
+#if ENCDEBUG
+ char addr[INET_ADDRSTRLEN];
+#endif
DPRINTF(("ipsec_common_input_cb(): inner "
"source address %s doesn't correspond to "
"expected proxy source %s, SA %s/%08x\n",
- inet_ntoa4(ipn.ip_src),
+ inet_ntop(AF_INET, &ipn.ip_src,
+ addr, sizeof(addr)),
ipsp_address(tdbp->tdb_proxy),
ipsp_address(tdbp->tdb_dst),
ntohl(tdbp->tdb_spi)));
@@ -439,11 +443,15 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
&tdbp->tdb_proxy.sin6.sin6_addr)) ||
(tdbp->tdb_proxy.sa.sa_family != AF_INET6 &&
tdbp->tdb_proxy.sa.sa_family != 0)) {
+#if ENCDEBUG
+ char addr[INET6_ADDRSTRLEN];
+#endif
DPRINTF(("ipsec_common_input_cb(): inner "
"source address %s doesn't correspond to "
"expected proxy source %s, SA %s/%08x\n",
- ip6_sprintf(&ip6n.ip6_src),
+ inet_ntop(AF_INET6, &ip6n.ip6_src,
+ addr, sizeof(addr)),
ipsp_address(tdbp->tdb_proxy),
ipsp_address(tdbp->tdb_dst),
ntohl(tdbp->tdb_spi)));
@@ -505,11 +513,15 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
tdbp->tdb_proxy.sin.sin_addr.s_addr) ||
(tdbp->tdb_proxy.sa.sa_family != AF_INET &&
tdbp->tdb_proxy.sa.sa_family != 0)) {
+#if ENCDEBUG
+ char addr[INET_ADDRSTRLEN];
+#endif
DPRINTF(("ipsec_common_input_cb(): inner "
"source address %s doesn't correspond to "
"expected proxy source %s, SA %s/%08x\n",
- inet_ntoa4(ipn.ip_src),
+ inet_ntop(AF_INET, &ipn.ip_src,
+ addr, sizeof(addr)),
ipsp_address(tdbp->tdb_proxy),
ipsp_address(tdbp->tdb_dst),
ntohl(tdbp->tdb_spi)));
@@ -546,11 +558,15 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
&tdbp->tdb_proxy.sin6.sin6_addr)) ||
(tdbp->tdb_proxy.sa.sa_family != AF_INET6 &&
tdbp->tdb_proxy.sa.sa_family != 0)) {
+#if ENCDEBUG
+ char addr[INET6_ADDRSTRLEN];
+#endif
DPRINTF(("ipsec_common_input_cb(): inner "
"source address %s doesn't correspond to "
"expected proxy source %s, SA %s/%08x\n",
- ip6_sprintf(&ip6n.ip6_src),
+ inet_ntop(AF_INET6, &ip6n.ip6_src,
+ addr, sizeof(addr)),
ipsp_address(tdbp->tdb_proxy),
ipsp_address(tdbp->tdb_dst),
ntohl(tdbp->tdb_spi)));
diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c
index bfb5c945018..18683a2e9f5 100644
--- a/sys/netinet6/frag6.c
+++ b/sys/netinet6/frag6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frag6.c,v 1.50 2013/10/20 11:03:02 phessler Exp $ */
+/* $OpenBSD: frag6.c,v 1.51 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@@ -423,9 +423,11 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
i = (paf6->ip6af_off + paf6->ip6af_frglen) - ip6af->ip6af_off;
if (i > 0) {
#if 0 /* suppress the noisy log */
+ char ip[INET6_ADDRSTRLEN];
log(LOG_ERR, "%d bytes of a fragment from %s "
"overlaps the previous fragment\n",
- i, ip6_sprintf(&q6->ip6q_src));
+ i,
+ inet_ntop(AF_INET6, &q6->ip6q_src, ip, sizeof(ip)));
#endif
free(ip6af, M_FTABLE);
goto flushfrags;
@@ -435,9 +437,11 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
i = (ip6af->ip6af_off + ip6af->ip6af_frglen) - af6->ip6af_off;
if (i > 0) {
#if 0 /* suppress the noisy log */
+ char ip[INET6_ADDRSTRLEN];
log(LOG_ERR, "%d bytes of a fragment from %s "
"overlaps the succeeding fragment",
- i, ip6_sprintf(&q6->ip6q_src));
+ i,
+ inet_ntop(AF_INET6, &q6->ip6q_src, ip, sizeof(ip)));
#endif
free(ip6af, M_FTABLE);
goto flushfrags;
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index ea643e4b205..df5f129acbc 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.135 2013/10/24 11:20:18 deraadt Exp $ */
+/* $OpenBSD: icmp6.c,v 1.136 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -391,6 +391,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
int off = *offp;
int icmp6len = m->m_pkthdr.len - *offp;
int code, sum, noff;
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_msg);
@@ -419,7 +420,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
if ((sum = in6_cksum(m, IPPROTO_ICMPV6, off, icmp6len)) != 0) {
nd6log((LOG_ERR,
"ICMP6 checksum error(%d|%x) %s\n",
- icmp6->icmp6_type, sum, ip6_sprintf(&ip6->ip6_src)));
+ icmp6->icmp6_type, sum,
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src))));
icmp6stat.icp6s_checksum++;
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error);
goto freeit;
@@ -823,8 +825,9 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
default:
nd6log((LOG_DEBUG,
"icmp6_input: unknown type %d(src=%s, dst=%s, ifid=%d)\n",
- icmp6->icmp6_type, ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ icmp6->icmp6_type,
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst)),
m->m_pkthdr.rcvif ? m->m_pkthdr.rcvif->if_index : 0));
if (icmp6->icmp6_type < ICMP6_ECHO_REQUEST) {
/* ICMPv6 error: MUST deliver it by spec... */
@@ -2060,6 +2063,7 @@ icmp6_reflect(struct mbuf *m, size_t off)
if (src == 0) {
int e;
struct route_in6 ro;
+ char addr[INET6_ADDRSTRLEN];
/*
* This case matches to multicasts, our anycast, or unicasts
@@ -2076,7 +2080,9 @@ icmp6_reflect(struct mbuf *m, size_t off)
nd6log((LOG_DEBUG,
"icmp6_reflect: source can't be determined: "
"dst=%s, error=%d\n",
- ip6_sprintf(&sa6_src.sin6_addr), e));
+ inet_ntop(AF_INET6, &sa6_src.sin6_addr,
+ addr, sizeof(addr)),
+ e));
goto bad;
}
}
@@ -2137,9 +2143,15 @@ const char *
icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6,
struct in6_addr *tgt6)
{
- static char buf[1024];
+ static char buf[1024]; /* XXX */
+ char src[INET6_ADDRSTRLEN];
+ char dst[INET6_ADDRSTRLEN];
+ char tgt[INET6_ADDRSTRLEN];
+
snprintf(buf, sizeof(buf), "(src=%s dst=%s tgt=%s)",
- ip6_sprintf(src6), ip6_sprintf(dst6), ip6_sprintf(tgt6));
+ inet_ntop(AF_INET6, src6, src, sizeof(src)),
+ inet_ntop(AF_INET6, dst6, dst, sizeof(dst)),
+ inet_ntop(AF_INET6, tgt6, tgt, sizeof(tgt)));
return buf;
}
@@ -2159,6 +2171,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
struct in6_addr redtgt6;
struct in6_addr reddst6;
union nd_opts ndopts;
+ char addr[INET6_ADDRSTRLEN];
if (!ifp)
return;
@@ -2186,14 +2199,16 @@ icmp6_redirect_input(struct mbuf *m, int off)
if (!IN6_IS_ADDR_LINKLOCAL(&src6)) {
nd6log((LOG_ERR,
"ICMP6 redirect sent from %s rejected; "
- "must be from linklocal\n", ip6_sprintf(&src6)));
+ "must be from linklocal\n",
+ inet_ntop(AF_INET6, &src6, addr, sizeof(addr))));
goto bad;
}
if (ip6->ip6_hlim != 255) {
nd6log((LOG_ERR,
"ICMP6 redirect sent from %s rejected; "
"hlim=%d (must be 255)\n",
- ip6_sprintf(&src6), ip6->ip6_hlim));
+ inet_ntop(AF_INET6, &src6, addr, sizeof(addr)),
+ ip6->ip6_hlim));
goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&reddst6)) {
@@ -2230,7 +2245,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
"ICMP6 redirect rejected; "
"not equal to gw-for-src=%s (must be same): "
"%s\n",
- ip6_sprintf(gw6),
+ inet_ntop(AF_INET6, gw6, addr, sizeof(addr)),
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
RTFREE(rt);
goto bad;
@@ -2279,7 +2294,8 @@ icmp6_redirect_input(struct mbuf *m, int off)
nd6log((LOG_INFO,
"icmp6_redirect_input: lladdrlen mismatch for %s "
"(if %d, icmp6 packet %d): %s\n",
- ip6_sprintf(&redtgt6), ifp->if_addrlen, lladdrlen - 2,
+ inet_ntop(AF_INET6, &redtgt6, addr, sizeof(addr)),
+ ifp->if_addrlen, lladdrlen - 2,
icmp6_redirect_diag(&src6, &reddst6, &redtgt6)));
goto bad;
}
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 8a319fbbf11..d4f76a8301a 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6.c,v 1.122 2013/10/24 11:20:18 deraadt Exp $ */
+/* $OpenBSD: in6.c,v 1.123 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */
/*
@@ -179,10 +179,13 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa)
e = rtrequest1(cmd, &info, RTP_CONNECTED, &nrt,
ifa->ifa_ifp->if_rdomain);
if (e != 0) {
+ char addr[INET6_ADDRSTRLEN];
log(LOG_ERR, "in6_ifloop_request: "
"%s operation failed for %s (errno=%d)\n",
cmd == RTM_ADD ? "ADD" : "DELETE",
- ip6_sprintf(&ifatoia6(ifa)->ia_addr.sin6_addr), e);
+ inet_ntop(AF_INET6,
+ &ifatoia6(ifa)->ia_addr.sin6_addr, addr, sizeof(addr)),
+ e);
}
/*
@@ -752,6 +755,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
struct in6_addrlifetime *lt;
struct in6_multi_mship *imm;
struct rtentry *rt;
+ char addr[INET6_ADDRSTRLEN];
splsoftassert(IPL_SOFTNET);
@@ -870,7 +874,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
*/
nd6log((LOG_INFO,
"in6_update_ifa: valid lifetime is 0 for %s\n",
- ip6_sprintf(&ifra->ifra_addr.sin6_addr)));
+ inet_ntop(AF_INET6, &ifra->ifra_addr.sin6_addr,
+ addr, sizeof(addr))));
if (ia == NULL)
return (0); /* there's nothing to do */
@@ -918,7 +923,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL) != plen) {
nd6log((LOG_INFO, "in6_update_ifa: the prefix length of an"
" existing (%s) address should not be changed\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr)));
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr))));
error = EINVAL;
goto unlink;
}
@@ -938,7 +944,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
(e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST)) != 0) {
nd6log((LOG_ERR, "in6_update_ifa: failed to remove "
"a route to the old destination: %s\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr)));
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr))));
/* proceed anyway... */
} else
ia->ia_flags &= ~IFA_ROUTE;
@@ -1019,7 +1026,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (!imm) {
nd6log((LOG_ERR, "in6_update_ifa: "
"addmulti failed for %s on %s (errno=%d)\n",
- ip6_sprintf(&llsol.sin6_addr),
+ inet_ntop(AF_INET6, &llsol.sin6_addr,
+ addr, sizeof(addr)),
ifp->if_xname, error));
goto cleanup;
}
@@ -1080,7 +1088,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
nd6log((LOG_WARNING,
"in6_update_ifa: addmulti failed for "
"%s on %s (errno=%d)\n",
- ip6_sprintf(&mltaddr.sin6_addr),
+ inet_ntop(AF_INET6, &mltaddr.sin6_addr,
+ addr, sizeof(addr)),
ifp->if_xname, error));
goto cleanup;
}
@@ -1094,7 +1103,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (!imm) {
nd6log((LOG_WARNING, "in6_update_ifa: "
"addmulti failed for %s on %s (errno=%d)\n",
- ip6_sprintf(&mltaddr.sin6_addr),
+ inet_ntop(AF_INET6, &mltaddr.sin6_addr,
+ addr, sizeof(addr)),
ifp->if_xname, error));
/* XXX not very fatal, go on... */
} else {
@@ -1145,7 +1155,8 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
if (!imm) {
nd6log((LOG_WARNING, "in6_update_ifa: "
"addmulti failed for %s on %s (errno=%d)\n",
- ip6_sprintf(&mltaddr.sin6_addr),
+ inet_ntop(AF_INET6, &mltaddr.sin6_addr,
+ addr, sizeof(addr)),
ifp->if_xname, error));
goto cleanup;
}
@@ -1198,11 +1209,13 @@ in6_purgeaddr(struct ifaddr *ifa)
if ((e = rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST))
!= 0) {
+ char addr[INET6_ADDRSTRLEN];
log(LOG_ERR, "in6_purgeaddr: failed to remove "
"a route to the p2p destination: %s on %s, "
"errno=%d\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr), ifp->if_xname,
- e);
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr)),
+ ifp->if_xname, e);
/* proceed anyway... */
} else
ia->ia_flags &= ~IFA_ROUTE;
@@ -1238,11 +1251,15 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp)
/* Release the reference to the base prefix. */
if (ia->ia6_ndpr == NULL) {
+ char addr[INET6_ADDRSTRLEN];
+
if (!IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia)) &&
!IN6_IS_ADDR_LOOPBACK(IA6_IN6(ia)) &&
!IN6_ARE_ADDR_EQUAL(IA6_MASKIN6(ia), &in6mask128))
log(LOG_NOTICE, "in6_unlink_ifa: interface address "
- "%s has no prefix\n", ip6_sprintf(IA6_IN6(ia)));
+ "%s has no prefix\n",
+ inet_ntop(AF_INET6, IA6_IN6(ia), addr,
+ sizeof(addr)));
} else {
ia->ia6_flags &= ~IN6_IFF_AUTOCONF;
if (--ia->ia6_ndpr->ndpr_refcnt == 0)
@@ -1904,59 +1921,6 @@ in6_ifpprefix(const struct ifnet *ifp, const struct in6_addr *addr)
}
/*
- * Convert IP6 address to printable (loggable) representation.
- */
-static char digits[] = "0123456789abcdef";
-static int ip6round = 0;
-char *
-ip6_sprintf(struct in6_addr *addr)
-{
- static char ip6buf[8][48];
- int i;
- char *cp;
- u_short *a = (u_short *)addr;
- u_char *d;
- int dcolon = 0;
-
- ip6round = (ip6round + 1) & 7;
- cp = ip6buf[ip6round];
-
- for (i = 0; i < 8; i++) {
- if (dcolon == 1) {
- if (*a == 0) {
- if (i == 7)
- *cp++ = ':';
- a++;
- continue;
- } else
- dcolon = 2;
- }
- if (*a == 0) {
- if (dcolon == 0 && *(a + 1) == 0) {
- if (i == 0)
- *cp++ = ':';
- *cp++ = ':';
- dcolon = 1;
- } else {
- *cp++ = '0';
- *cp++ = ':';
- }
- a++;
- continue;
- }
- d = (u_char *)a;
- *cp++ = digits[*d >> 4];
- *cp++ = digits[*d++ & 0xf];
- *cp++ = digits[*d >> 4];
- *cp++ = digits[*d & 0xf];
- *cp++ = ':';
- a++;
- }
- *--cp = 0;
- return (ip6buf[ip6round]);
-}
-
-/*
* Get a scope of the address. Node-local, link-local, site-local or global.
*/
int
@@ -2164,17 +2128,26 @@ in6_ifawithscope(struct ifnet *oifp, struct in6_addr *dst, u_int rdomain)
src_scope = in6_addrscope(IFA_IN6(ifa));
#ifdef ADDRSELECT_DEBUG /* should be removed after stabilization */
+ {
+ char adst[INET6_ADDRSTRLEN], asrc[INET6_ADDRSTRLEN];
+ char bestaddr[INET6_ADDRSTRLEN];
+
+
dscopecmp = IN6_ARE_SCOPE_CMP(src_scope, dst_scope);
printf("in6_ifawithscope: dst=%s bestaddr=%s, "
"newaddr=%s, scope=%x, dcmp=%d, bcmp=%d, "
"matchlen=%d, flgs=%x\n",
- ip6_sprintf(dst),
- ifa_best ? ip6_sprintf(&ifa_best->ia_addr.sin6_addr) : "none",
- ip6_sprintf(IFA_IN6(ifa)), src_scope,
- dscopecmp,
+ inet_ntop(AF_INET6, dst, adst, sizeof(adst)),
+ (ifa_best == NULL) ? "none" :
+ inet_ntop(AF_INET6, &ifa_best->ia_addr.sin6_addr,
+ bestaddr, sizeof(bestaddr)),
+ inet_ntop(AF_INET6, IFA_IN6(ifa),
+ asrc, sizeof(asrc)),
+ src_scope, dscopecmp,
ifa_best ? IN6_ARE_SCOPE_CMP(src_scope, best_scope) : -1,
in6_matchlen(IFA_IN6(ifa), dst),
ifatoia6(ifa)->ia6_flags);
+ }
#endif
/*
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 2b6eb5c8f1a..8569db45f08 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.35 2013/10/23 19:57:50 deraadt Exp $ */
+/* $OpenBSD: in6_src.c,v 1.36 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -330,15 +330,17 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
dst = &dstsock->sin6_addr;
#if 0
+ char ip[INET6_ADDRSTRLEN];
+
if (dstsock->sin6_addr.s6_addr32[0] == 0 &&
dstsock->sin6_addr.s6_addr32[1] == 0 &&
!IN6_IS_ADDR_LOOPBACK(&dstsock->sin6_addr)) {
printf("in6_selectroute: strange destination %s\n",
- ip6_sprintf(&dstsock->sin6_addr));
+ inet_ntop(AF_INET6, &dstsock->sin6_addr, ip, sizeof(ip)));
} else {
printf("in6_selectroute: destination = %s%%%d\n",
- ip6_sprintf(&dstsock->sin6_addr),
- dstsock->sin6_scope_id); /* for debug */
+ inet_ntop(AF_INET6, &dstsock->sin6_addr, ip, sizeof(ip)),
+ dstsock->sin6_scope_id); /* for debug */
}
#endif
diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c
index e7e3fde5354..01bf1ceaeb5 100644
--- a/sys/netinet6/ip6_forward.c
+++ b/sys/netinet6/ip6_forward.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_forward.c,v 1.62 2013/10/17 16:27:46 bluhm Exp $ */
+/* $OpenBSD: ip6_forward.c,v 1.63 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */
/*
@@ -105,6 +105,7 @@ ip6_forward(struct mbuf *m, int srcrt)
#endif
#endif /* IPSEC */
u_int rtableid = 0;
+ char src6[INET6_ADDRSTRLEN], dst6[INET6_ADDRSTRLEN];
/*
* Do not forward packets to multicast destination (should be handled
@@ -119,11 +120,12 @@ ip6_forward(struct mbuf *m, int srcrt)
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
+ inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6));
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ src6, dst6,
ip6->ip6_nxt,
m->m_pkthdr.rcvif->if_xname);
}
@@ -307,11 +309,12 @@ reroute:
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
+ inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6));
log(LOG_DEBUG,
"cannot forward "
"src %s, dst %s, nxt %d, rcvif %s, outif %s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ src6, dst6,
ip6->ip6_nxt,
m->m_pkthdr.rcvif->if_xname, rt->rt_ifp->if_xname);
}
@@ -432,10 +435,11 @@ reroute:
if ((rt->rt_flags & (RTF_BLACKHOLE|RTF_REJECT)) == 0)
#endif
{
+ inet_ntop(AF_INET6, &ip6->ip6_src, src6, sizeof(src6));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst6, sizeof(dst6));
printf("ip6_forward: outgoing interface is loopback. "
"src %s, dst %s, nxt %d, rcvif %s, outif %s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ src6, dst6,
ip6->ip6_nxt, m->m_pkthdr.rcvif->if_xname,
rt->rt_ifp->if_xname);
}
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 400a1b9bc56..4c3a41918c6 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.119 2013/10/28 21:02:35 deraadt Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.120 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -480,11 +480,14 @@ ip6_input(struct mbuf *m)
deliverifp = ia6->ia_ifp; /* correct? */
goto hbhcheck;
} else {
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst));
/* address is not ready, so discard the packet. */
nd6log((LOG_INFO,
"ip6_input: packet to an unready address %s->%s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst)));
+ src, dst));
goto bad;
}
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 3359a2a753a..6fd4661c280 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -704,6 +704,7 @@ add_m6fc(struct mf6cctl *mfccp)
u_long hash;
struct rtdetq *rte;
u_short nstl;
+ char orig[INET6_ADDRSTRLEN], mcast[INET6_ADDRSTRLEN];
int s;
MF6CFIND(mfccp->mf6cc_origin.sin6_addr,
@@ -712,11 +713,16 @@ add_m6fc(struct mf6cctl *mfccp)
/* If an entry already exists, just update the fields */
if (rt) {
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC)
+ if (mrt6debug & DEBUG_MFC) {
log(LOG_DEBUG,"add_m6fc update o %s g %s p %x\n",
- ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),
- ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_origin.sin6_addr,
+ orig, sizeof(orig)),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_mcastgrp.sin6_addr,
+ mcast, sizeof(mcast)),
mfccp->mf6cc_parent);
+ }
#endif
s = splsoftnet();
@@ -745,16 +751,24 @@ add_m6fc(struct mf6cctl *mfccp)
log(LOG_ERR,
"add_m6fc: %s o %s g %s p %x dbx %p\n",
"multiple kernel entries",
- ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),
- ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_origin.sin6_addr,
+ orig, sizeof(orig)),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_mcastgrp.sin6_addr,
+ mcast, sizeof(mcast)),
mfccp->mf6cc_parent, rt->mf6c_stall);
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_MFC)
log(LOG_DEBUG,
"add_m6fc o %s g %s p %x dbg %x\n",
- ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),
- ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_origin.sin6_addr,
+ orig, sizeof(orig)),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_mcastgrp.sin6_addr,
+ mcast, sizeof(mcast)),
mfccp->mf6cc_parent, rt->mf6c_stall);
#endif
@@ -793,8 +807,12 @@ add_m6fc(struct mf6cctl *mfccp)
log(LOG_DEBUG,
"add_m6fc no upcall h %d o %s g %s p %x\n",
hash,
- ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),
- ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_origin.sin6_addr,
+ orig, sizeof(orig)),
+ inet_ntop(AF_INET6,
+ &mfccp->mf6cc_mcastgrp.sin6_addr,
+ mcast, sizeof(mcast)),
mfccp->mf6cc_parent);
#endif
@@ -867,10 +885,13 @@ del_m6fc(struct mf6cctl *mfccp)
hash = MF6CHASH(origin.sin6_addr, mcastgrp.sin6_addr);
#ifdef MRT6DEBUG
- if (mrt6debug & DEBUG_MFC)
- log(LOG_DEBUG,"del_m6fc orig %s mcastgrp %s\n",
- ip6_sprintf(&origin.sin6_addr),
- ip6_sprintf(&mcastgrp.sin6_addr));
+ if (mrt6debug & DEBUG_MFC) {
+ char orig[INET6_ADDRSTRLEN], mcast[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, &origin.sin6_addr, orig, sizeof(orig));
+ inet_ntop(AF_INET6, &mcastgrp.sin6_addr, mcast, sizeof(mcast));
+ log(LOG_DEBUG,"del_m6fc orig %s mcastgrp %s\n", orig, mcast);
+ }
#endif
s = splsoftnet();
@@ -932,12 +953,14 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
int s;
mifi_t mifi;
struct sockaddr_in6 sin6;
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst));
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_FORWARD)
log(LOG_DEBUG, "ip6_mforward: src %s, dst %s, ifindex %d\n",
- ip6_sprintf(&ip6->ip6_src), ip6_sprintf(&ip6->ip6_dst),
- ifp->if_index);
+ src, dst, ifp->if_index);
#endif
/*
@@ -963,8 +986,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
log(LOG_DEBUG,
"cannot forward "
"from %s to %s nxt %d received on %s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ src, dst,
ip6->ip6_nxt,
m->m_pkthdr.rcvif->if_xname);
}
@@ -996,8 +1018,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
#ifdef MRT6DEBUG
if (mrt6debug & (DEBUG_FORWARD | DEBUG_MFC))
log(LOG_DEBUG, "ip6_mforward: no rte s %s g %s\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst));
+ src, dst);
#endif
/*
@@ -1187,10 +1208,17 @@ expire_upcalls(void *unused)
mfc->mf6c_expire != 0 &&
--mfc->mf6c_expire == 0) {
#ifdef MRT6DEBUG
+ char orig[INET6_ADDRSTRLEN];
+ char mcast[INET6_ADDRSTRLEN];
+
if (mrt6debug & DEBUG_EXPIRE)
log(LOG_DEBUG, "expire_upcalls: expiring (%s %s)\n",
- ip6_sprintf(&mfc->mf6c_origin.sin6_addr),
- ip6_sprintf(&mfc->mf6c_mcastgrp.sin6_addr));
+ inet_ntop(AF_INET6,
+ &mfc->mf6c_origin.sin6_addr,
+ orig, sizeof(orig)),
+ inet_ntop(AF_INET6,
+ &mfc->mf6c_mcastgrp.sin6_addr,
+ mcast, sizeof(mcast)));
#endif
/*
* drop all the packets
@@ -1461,13 +1489,17 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu);
else {
#ifdef MRT6DEBUG
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
+
if (mrt6debug & DEBUG_XMIT)
log(LOG_DEBUG,
"phyint_send: packet too big on %s o %s g %s"
" size %d(discarded)\n",
ifp->if_xname,
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst),
+ inet_ntop(AF_INET6, &ip6->ip6_src,
+ src, sizeof(src)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst,
+ dst, sizeof(dst)),
mb_copy->m_pkthdr.len);
#endif /* MRT6DEBUG */
m_freem(mb_copy); /* simply discard the packet */
@@ -1486,9 +1518,13 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m)
struct mrt6msg *im6;
#ifdef MRT6DEBUG
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src));
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst));
if (mrt6debug)
log(LOG_DEBUG, "** IPv6 register_send **\n src %s dst %s\n",
- ip6_sprintf(&ip6->ip6_src), ip6_sprintf(&ip6->ip6_dst));
+ src, dst);
#endif
++pim6stat.pim6s_snd_registers;
@@ -1646,6 +1682,9 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
struct mbuf *mcp;
struct ip6_hdr *eip6;
u_int32_t *reghdr;
+#ifdef MRT6DEBUG
+ char asrc[INET6_ADDRSTRLEN], adst[INET6_ADDRSTRLEN];
+#endif
++pim6stat.pim6s_rcv_registers;
@@ -1675,7 +1714,9 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
log(LOG_ERR,
"pim6_input: register packet size too "
"small %d from %s\n",
- pimlen, ip6_sprintf(&ip6->ip6_src));
+ pimlen,
+ inet_ntop(AF_INET6, &ip6->ip6_src,
+ asrc, sizeof(asrc)));
#endif
m_freem(m);
return (IPPROTO_DONE);
@@ -1687,8 +1728,10 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
log(LOG_DEBUG,
"pim6_input[register], eip6: %s -> %s, "
"eip6 plen %d\n",
- ip6_sprintf(&eip6->ip6_src),
- ip6_sprintf(&eip6->ip6_dst),
+ inet_ntop(AF_INET6, &eip6->ip6_src,
+ asrc, sizeof(asrc)),
+ inet_ntop(AF_INET6, &eip6->ip6_dst,
+ adst, sizeof(adst)),
ntohs(eip6->ip6_plen));
#endif
@@ -1712,7 +1755,8 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
log(LOG_DEBUG,
"pim6_input: inner packet of register "
"is not multicast %s\n",
- ip6_sprintf(&eip6->ip6_dst));
+ inet_ntop(AF_INET6, &eip6->ip6_dst,
+ adst, sizeof(adst)));
#endif
m_freem(m);
return (IPPROTO_DONE);
@@ -1741,8 +1785,10 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
log(LOG_DEBUG,
"pim6_input: forwarding decapsulated register: "
"src %s, dst %s, mif %d\n",
- ip6_sprintf(&eip6->ip6_src),
- ip6_sprintf(&eip6->ip6_dst),
+ inet_ntop(AF_INET6, &eip6->ip6_src,
+ asrc, sizeof(asrc)),
+ inet_ntop(AF_INET6, &eip6->ip6_dst,
+ adst, sizeof(adst)),
reg_mif_num);
}
#endif
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index d005e72e840..70b21840c9d 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mld6.c,v 1.31 2013/10/24 11:20:18 deraadt Exp $ */
+/* $OpenBSD: mld6.c,v 1.32 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
@@ -178,10 +178,12 @@ mld6_input(struct mbuf *m, int off)
ip6 = mtod(m, struct ip6_hdr *);/* in case mpullup */
if (!IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src)) {
#if 0
+ char src[INET6_ADDRSTRLEN], grp[INET6_ADDRSTRLEN];
+
log(LOG_ERR,
"mld_input: src %s is not link-local (grp=%s)\n",
- ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&mldh->mld_addr));
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)),
+ inet_ntop(AF_INET6, &mldh->mld_addr, grp, sizeof(grp)));
#endif
/*
* spec (RFC2710) does not explicitly
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index fbc0a64bf36..cb08b2fce5a 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.104 2013/10/28 12:33:32 mpi Exp $ */
+/* $OpenBSD: nd6.c,v 1.105 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -692,10 +692,12 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
&rt, ifp->if_rdomain)) != 0) {
#if 0
+ char ip[INET6_ADDRSTRLEN];
log(LOG_ERR,
"nd6_lookup: failed to add route for a "
"neighbor(%s), errno=%d\n",
- ip6_sprintf(addr6), e);
+ inet_ntop(AF_INET6, addr6, ip, sizeof(ip)),
+ e);
#endif
return (NULL);
}
@@ -726,9 +728,10 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp)
rt->rt_gateway->sa_family != AF_LINK || rt->rt_llinfo == NULL ||
(ifp && rt->rt_ifa->ifa_ifp != ifp)) {
if (create) {
+ char addr[INET6_ADDRSTRLEN];
nd6log((LOG_DEBUG,
"nd6_lookup: failed to lookup %s (if = %s)\n",
- ip6_sprintf(addr6),
+ inet_ntop(AF_INET6, addr6, addr, sizeof(addr)),
ifp ? ifp->if_xname : "unspec"));
}
return (NULL);
@@ -1186,9 +1189,12 @@ nd6_rtrequest(int req, struct rtentry *rt)
llsol.s6_addr8[12] = 0xff;
if (in6_addmulti(&llsol, ifp, &error)) {
+ char addr[INET6_ADDRSTRLEN];
nd6log((LOG_ERR, "%s: failed to join "
"%s (errno=%d)\n", ifp->if_xname,
- ip6_sprintf(&llsol), error));
+ inet_ntop(AF_INET6, &llsol,
+ addr, sizeof(addr)),
+ error));
}
}
}
@@ -1426,8 +1432,10 @@ fail:
*/
if (llchange) {
+ char addr[INET6_ADDRSTRLEN];
log(LOG_INFO, "ndp info overwritten for %s by %s on %s\n",
- ip6_sprintf(from), ether_sprintf(lladdr), ifp->if_xname);
+ inet_ntop(AF_INET6, from, addr, sizeof(addr)),
+ ether_sprintf(lladdr), ifp->if_xname);
}
if (lladdr) { /* (3-5) and (7) */
/*
@@ -1696,10 +1704,14 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
if (!ln || !rt) {
if ((ifp->if_flags & IFF_POINTOPOINT) == 0 &&
!(ND_IFINFO(ifp)->flags & ND6_IFF_PERFORMNUD)) {
+ char addr[INET6_ADDRSTRLEN];
+
log(LOG_DEBUG,
"nd6_output: can't allocate llinfo for %s "
"(ln=%p, rt=%p)\n",
- ip6_sprintf(&dst->sin6_addr), ln, rt);
+ inet_ntop(AF_INET6, &dst->sin6_addr,
+ addr, sizeof(addr)),
+ ln, rt);
senderr(EIO); /* XXX: good error? */
}
@@ -1852,9 +1864,12 @@ nd6_storelladdr(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
}
sdl = SDL(rt->rt_gateway);
if (sdl->sdl_alen == 0) {
+ char addr[INET6_ADDRSTRLEN];
/* this should be impossible, but we bark here for debugging */
printf("nd6_storelladdr: sdl_alen == 0, dst=%s, if=%s\n",
- ip6_sprintf(&satosin6(dst)->sin6_addr), ifp->if_xname);
+ inet_ntop(AF_INET6, &satosin6(dst)->sin6_addr,
+ addr, sizeof(addr)),
+ ifp->if_xname);
m_freem(m);
return (0);
}
@@ -1982,6 +1997,7 @@ fill_prlist(void *oldp, size_t *oldlenp, size_t ol)
struct sockaddr_in6 *sin6;
struct sockaddr_in6 *s6;
struct nd_pfxrouter *pfr;
+ char addr[INET6_ADDRSTRLEN];
if (oldp && p + 1 <= pe)
{
@@ -1993,7 +2009,8 @@ fill_prlist(void *oldp, size_t *oldlenp, size_t ol)
&p->prefix.sin6_addr, pr->ndpr_ifp) != 0)
log(LOG_ERR,
"scope error in prefix list (%s)\n",
- ip6_sprintf(&p->prefix.sin6_addr));
+ inet_ntop(AF_INET6, &p->prefix.sin6_addr,
+ addr, sizeof(addr)));
p->raflags = pr->ndpr_raf;
p->prefixlen = pr->ndpr_plen;
p->vltime = pr->ndpr_vltime;
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index ce214b09f7a..59af7e033ef 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.70 2013/10/24 11:20:18 deraadt Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.71 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -101,6 +101,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
int tlladdr;
union nd_opts ndopts;
struct sockaddr_dl *proxydl = NULL;
+ char addr[INET6_ADDRSTRLEN], addr0[INET6_ADDRSTRLEN];
IP6_EXTHDR_GET(nd_ns, struct nd_neighbor_solicit *, m, off, icmp6len);
if (nd_ns == NULL) {
@@ -113,8 +114,10 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
if (ip6->ip6_hlim != 255) {
nd6log((LOG_ERR,
"nd6_ns_input: invalid hlim (%d) from %s to %s on %s\n",
- ip6->ip6_hlim, ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst), ifp->if_xname));
+ ip6->ip6_hlim,
+ inet_ntop(AF_INET6, &ip6->ip6_src, addr, sizeof(addr)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst, addr0, sizeof(addr0)),
+ ifp->if_xname));
goto bad;
}
@@ -250,13 +253,14 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s "
"(if %d, NS packet %d)\n",
- ip6_sprintf(&taddr6), ifp->if_addrlen, lladdrlen - 2));
+ inet_ntop(AF_INET6, &taddr6, addr, sizeof(addr)),
+ ifp->if_addrlen, lladdrlen - 2));
goto bad;
}
if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) {
log(LOG_INFO, "nd6_ns_input: duplicate IP6 address %s\n",
- ip6_sprintf(&saddr6));
+ inet_ntop(AF_INET6, &saddr6, addr, sizeof(addr)));
goto freeit;
}
@@ -315,9 +319,12 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
- nd6log((LOG_ERR, "nd6_ns_input: src=%s\n", ip6_sprintf(&saddr6)));
- nd6log((LOG_ERR, "nd6_ns_input: dst=%s\n", ip6_sprintf(&daddr6)));
- nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n", ip6_sprintf(&taddr6)));
+ nd6log((LOG_ERR, "nd6_ns_input: src=%s\n",
+ inet_ntop(AF_INET6, &saddr6, addr, sizeof(addr))));
+ nd6log((LOG_ERR, "nd6_ns_input: dst=%s\n",
+ inet_ntop(AF_INET6, &daddr6, addr, sizeof(addr))));
+ nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n",
+ inet_ntop(AF_INET6, &taddr6, addr, sizeof(addr))));
icmp6stat.icp6s_badns++;
m_freem(m);
}
@@ -452,10 +459,14 @@ nd6_ns_output(struct ifnet *ifp, struct in6_addr *daddr6,
src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL,
&error, m->m_pkthdr.rdomain);
if (src0 == NULL) {
+ char addr[INET6_ADDRSTRLEN];
+
nd6log((LOG_DEBUG,
"nd6_ns_output: source can't be "
"determined: dst=%s, error=%d\n",
- ip6_sprintf(&dst_sa.sin6_addr), error));
+ inet_ntop(AF_INET6, &dst_sa.sin6_addr,
+ addr, sizeof(addr)),
+ error));
goto bad;
}
src_sa.sin6_addr = *src0;
@@ -563,12 +574,15 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
#if NCARP > 0
struct sockaddr_dl *proxydl = NULL;
#endif
+ char addr[INET6_ADDRSTRLEN], addr0[INET6_ADDRSTRLEN];
if (ip6->ip6_hlim != 255) {
nd6log((LOG_ERR,
"nd6_na_input: invalid hlim (%d) from %s to %s on %s\n",
- ip6->ip6_hlim, ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst), ifp->if_xname));
+ ip6->ip6_hlim,
+ inet_ntop(AF_INET6, &ip6->ip6_src, addr, sizeof(addr)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst, addr0, sizeof(addr0)),
+ ifp->if_xname));
goto bad;
}
@@ -589,7 +603,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
if (IN6_IS_ADDR_MULTICAST(&taddr6)) {
nd6log((LOG_ERR,
"nd6_na_input: invalid target address %s\n",
- ip6_sprintf(&taddr6)));
+ inet_ntop(AF_INET6, &taddr6, addr, sizeof(addr))));
goto bad;
}
if (is_solicited && IN6_IS_ADDR_MULTICAST(&daddr6)) {
@@ -643,7 +657,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
if (ifa) {
log(LOG_ERR,
"nd6_na_input: duplicate IP6 address %s\n",
- ip6_sprintf(&taddr6));
+ inet_ntop(AF_INET6, &taddr6, addr, sizeof(addr)));
goto freeit;
}
/*
@@ -657,7 +671,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO, "nd6_na_input: lladdrlen mismatch for %s "
- "(if %d, NA packet %d)\n", ip6_sprintf(&taddr6),
+ "(if %d, NA packet %d)\n",
+ inet_ntop(AF_INET6, &taddr6, addr, sizeof(addr)),
ifp->if_addrlen, lladdrlen - 2));
goto bad;
}
@@ -761,7 +776,9 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
*/
if (llchange) {
log(LOG_INFO, "ndp info overwritten for %s "
- "by %s on %s\n", ip6_sprintf(&taddr6),
+ "by %s on %s\n",
+ inet_ntop(AF_INET6, &taddr6,
+ addr, sizeof(addr)),
ether_sprintf(lladdr), ifp->if_xname);
}
if (lladdr) {
@@ -953,9 +970,12 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6,
src0 = in6_selectsrc(&dst_sa, NULL, NULL, &ro, NULL, &error,
m->m_pkthdr.rdomain);
if (src0 == NULL) {
+ char addr[INET6_ADDRSTRLEN];
+
nd6log((LOG_DEBUG, "nd6_na_output: source can't be "
"determined: dst=%s, error=%d\n",
- ip6_sprintf(&dst_sa.sin6_addr), error));
+ inet_ntop(AF_INET6, &dst_sa.sin6_addr, addr, sizeof(addr)),
+ error));
goto bad;
}
src_sa.sin6_addr = *src0;
@@ -1106,6 +1126,7 @@ nd6_dad_start(struct ifaddr *ifa, int *tick)
{
struct in6_ifaddr *ia = ifatoia6(ifa);
struct dadq *dp;
+ char addr[INET6_ADDRSTRLEN];
if (!dad_init) {
TAILQ_INIT(&dadq);
@@ -1122,7 +1143,8 @@ nd6_dad_start(struct ifaddr *ifa, int *tick)
log(LOG_DEBUG,
"nd6_dad_start: called with non-tentative address "
"%s(%s)\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr),
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
return;
}
@@ -1147,7 +1169,8 @@ nd6_dad_start(struct ifaddr *ifa, int *tick)
if (dp == NULL) {
log(LOG_ERR, "nd6_dad_start: memory allocation failed for "
"%s(%s)\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr),
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
return;
}
@@ -1156,7 +1179,7 @@ nd6_dad_start(struct ifaddr *ifa, int *tick)
ip6_dad_pending++;
nd6log((LOG_DEBUG, "%s: starting DAD for %s\n", ifa->ifa_ifp->if_xname,
- ip6_sprintf(&ia->ia_addr.sin6_addr)));
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr))));
/*
* Send NS packet for DAD, ip6_dad_count times.
@@ -1217,6 +1240,7 @@ nd6_dad_timer(struct ifaddr *ifa)
int s;
struct in6_ifaddr *ia = ifatoia6(ifa);
struct dadq *dp;
+ char addr[INET6_ADDRSTRLEN];
s = splsoftnet(); /* XXX */
@@ -1233,14 +1257,16 @@ nd6_dad_timer(struct ifaddr *ifa)
if (ia->ia6_flags & IN6_IFF_DUPLICATED) {
log(LOG_ERR, "nd6_dad_timer: called with duplicated address "
"%s(%s)\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr),
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
goto done;
}
if ((ia->ia6_flags & IN6_IFF_TENTATIVE) == 0) {
log(LOG_ERR, "nd6_dad_timer: called with non-tentative address "
"%s(%s)\n",
- ip6_sprintf(&ia->ia_addr.sin6_addr),
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
goto done;
}
@@ -1302,7 +1328,8 @@ nd6_dad_timer(struct ifaddr *ifa)
nd6log((LOG_DEBUG,
"%s: DAD complete for %s - no duplicates found\n",
ifa->ifa_ifp->if_xname,
- ip6_sprintf(&ia->ia_addr.sin6_addr)));
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr,
+ addr, sizeof(addr))));
TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list);
free(dp, M_IP6NDP);
@@ -1321,6 +1348,7 @@ nd6_dad_duplicated(struct ifaddr *ifa)
{
struct in6_ifaddr *ia = ifatoia6(ifa);
struct dadq *dp;
+ char addr[INET6_ADDRSTRLEN];
dp = nd6_dad_find(ifa);
if (dp == NULL) {
@@ -1330,7 +1358,8 @@ nd6_dad_duplicated(struct ifaddr *ifa)
log(LOG_ERR, "%s: DAD detected duplicate IPv6 address %s: "
"NS in/out=%d/%d, NA in=%d\n",
- ifa->ifa_ifp->if_xname, ip6_sprintf(&ia->ia_addr.sin6_addr),
+ ifa->ifa_ifp->if_xname,
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr)),
dp->dad_ns_icount, dp->dad_ns_ocount, dp->dad_na_icount);
ia->ia6_flags &= ~IN6_IFF_TENTATIVE;
@@ -1340,7 +1369,8 @@ nd6_dad_duplicated(struct ifaddr *ifa)
nd6_dad_stoptimer(dp);
log(LOG_ERR, "%s: DAD complete for %s - duplicate found\n",
- ifa->ifa_ifp->if_xname, ip6_sprintf(&ia->ia_addr.sin6_addr));
+ ifa->ifa_ifp->if_xname,
+ inet_ntop(AF_INET6, &ia->ia_addr.sin6_addr, addr, sizeof(addr)));
log(LOG_ERR, "%s: manual intervention required\n",
ifa->ifa_ifp->if_xname);
@@ -1393,9 +1423,12 @@ nd6_dad_ns_input(struct ifaddr *ifa)
/* Quickhack - completely ignore DAD NS packets */
if (dad_ignore_ns) {
+ char addr[INET6_ADDRSTRLEN];
+
nd6log((LOG_INFO,
"nd6_dad_ns_input: ignoring DAD NS packet for "
- "address %s(%s)\n", ip6_sprintf(taddr6),
+ "address %s(%s)\n",
+ inet_ntop(AF_INET6, taddr6, addr, sizeof(addr)),
ifa->ifa_ifp->if_xname));
return;
}
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index e4d08cb10e3..80c75d7a6bc 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.73 2013/10/20 11:03:02 phessler Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.74 2013/11/11 09:15:35 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -107,6 +107,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
int is_newentry;
#endif
union nd_opts ndopts;
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
/* If I'm not a router, ignore it. */
if (ip6_accept_rtadv != 0 || !ip6_forwarding)
@@ -116,8 +117,10 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
if (ip6->ip6_hlim != 255) {
nd6log((LOG_ERR,
"nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n",
- ip6->ip6_hlim, ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst), ifp->if_xname));
+ ip6->ip6_hlim,
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst)),
+ ifp->if_xname));
goto bad;
}
@@ -152,7 +155,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
nd6log((LOG_INFO,
"nd6_rs_input: lladdrlen mismatch for %s "
"(if %d, RS packet %d)\n",
- ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2));
+ inet_ntop(AF_INET6, &saddr6, src, sizeof(src)),
+ ifp->if_addrlen, lladdrlen - 2));
goto bad;
}
@@ -190,6 +194,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
#endif
union nd_opts ndopts;
struct nd_defrouter *dr;
+ char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN];
/*
* We only accept RAs only when
@@ -204,15 +209,17 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
if (ip6->ip6_hlim != 255) {
nd6log((LOG_ERR,
"nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n",
- ip6->ip6_hlim, ip6_sprintf(&ip6->ip6_src),
- ip6_sprintf(&ip6->ip6_dst), ifp->if_xname));
+ ip6->ip6_hlim,
+ inet_ntop(AF_INET6, &ip6->ip6_src, src, sizeof(src)),
+ inet_ntop(AF_INET6, &ip6->ip6_dst, dst, sizeof(dst)),
+ ifp->if_xname));
goto bad;
}
if (!IN6_IS_ADDR_LINKLOCAL(&saddr6)) {
nd6log((LOG_ERR,
"nd6_ra_input: src %s is not link-local\n",
- ip6_sprintf(&saddr6)));
+ inet_ntop(AF_INET6, &saddr6, src, sizeof(src))));
goto bad;
}
@@ -295,7 +302,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
nd6log((LOG_INFO,
"nd6_ra_input: invalid prefix "
"%s, ignored\n",
- ip6_sprintf(&pi->nd_opt_pi_prefix)));
+ inet_ntop(AF_INET6, &pi->nd_opt_pi_prefix,
+ src, sizeof(src))));
continue;
}
@@ -306,7 +314,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
"nd6_ra_input: invalid prefixlen "
"%d for rfc2374 prefix %s, ignored\n",
pi->nd_opt_pi_prefix_len,
- ip6_sprintf(&pi->nd_opt_pi_prefix)));
+ inet_ntop(AF_INET6, &pi->nd_opt_pi_prefix,
+ src, sizeof(src))));
continue;
}
@@ -345,7 +354,9 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
if (mtu < IPV6_MMTU) {
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu option "
"mtu=%lu sent from %s, ignoring\n",
- mtu, ip6_sprintf(&ip6->ip6_src)));
+ mtu,
+ inet_ntop(AF_INET6, &ip6->ip6_src,
+ src, sizeof(src))));
goto skip;
}
@@ -362,7 +373,10 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu "
"mtu=%lu sent from %s; "
"exceeds maxmtu %lu, ignoring\n",
- mtu, ip6_sprintf(&ip6->ip6_src), maxmtu));
+ mtu,
+ inet_ntop(AF_INET6, &ip6->ip6_src,
+ src, sizeof(src)),
+ maxmtu));
}
}
@@ -383,7 +397,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO,
"nd6_ra_input: lladdrlen mismatch for %s "
- "(if %d, RA packet %d)\n", ip6_sprintf(&saddr6),
+ "(if %d, RA packet %d)\n",
+ inet_ntop(AF_INET6, &saddr6, src, sizeof(src)),
ifp->if_addrlen, lladdrlen - 2));
goto bad;
}
@@ -954,12 +969,14 @@ nd6_prelist_add(struct nd_prefix *pr, struct nd_defrouter *dr,
/* ND_OPT_PI_FLAG_ONLINK processing */
if (new->ndpr_raf_onlink) {
+ char addr[INET6_ADDRSTRLEN];
int e;
if ((e = nd6_prefix_onlink(new)) != 0) {
nd6log((LOG_ERR, "nd6_prelist_add: failed to make "
"the prefix %s/%d on-link on %s (errno=%d)\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, pr->ndpr_ifp->if_xname, e));
/* proceed anyway. XXX: is it correct? */
}
@@ -993,9 +1010,11 @@ prelist_remove(struct nd_prefix *pr)
#endif
if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0 &&
(e = nd6_prefix_offlink(pr)) != 0) {
+ char addr[INET6_ADDRSTRLEN];
nd6log((LOG_ERR, "prelist_remove: failed to make %s/%d offlink "
"on %s, errno=%d\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, pr->ndpr_ifp->if_xname, e));
/* what should we do? */
}
@@ -1040,6 +1059,7 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m)
int tempaddr_preferred = 0, autoconf = 0, statique = 0;
int auth;
struct in6_addrlifetime lt6_tmp;
+ char addr[INET6_ADDRSTRLEN];
auth = 0;
if (m) {
@@ -1082,7 +1102,9 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m)
"prelist_update: failed to make "
"the prefix %s/%d on-link on %s "
"(errno=%d)\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6,
+ &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, pr->ndpr_ifp->if_xname, e));
/* proceed anyway. XXX: is it correct? */
}
@@ -1103,7 +1125,8 @@ prelist_update(struct nd_prefix *new, struct nd_defrouter *dr, struct mbuf *m)
nd6log((LOG_NOTICE, "prelist_update: "
"nd6_prelist_add failed for %s/%d on %s "
"errno=%d, returnpr=%p\n",
- ip6_sprintf(&new->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6, &new->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
new->ndpr_plen, new->ndpr_ifp->if_xname,
error, newpr));
goto end; /* we should just give up in this case. */
@@ -1402,6 +1425,7 @@ pfxlist_onlink_check(void)
{
struct nd_prefix *pr;
struct in6_ifaddr *ifa;
+ char addr[INET6_ADDRSTRLEN];
/*
* Check if there is a prefix that has a reachable advertising
@@ -1477,7 +1501,9 @@ pfxlist_onlink_check(void)
nd6log((LOG_ERR,
"pfxlist_onlink_check: failed to "
"make %s/%d offlink, errno=%d\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6,
+ &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, e));
}
}
@@ -1488,7 +1514,9 @@ pfxlist_onlink_check(void)
nd6log((LOG_ERR,
"pfxlist_onlink_check: failed to "
"make %s/%d offlink, errno=%d\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6,
+ &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, e));
}
}
@@ -1553,12 +1581,15 @@ nd6_prefix_onlink(struct nd_prefix *pr)
u_long rtflags;
int error = 0;
struct rtentry *rt = NULL;
+ char addr[INET6_ADDRSTRLEN];
/* sanity check */
if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0) {
nd6log((LOG_ERR,
"nd6_prefix_onlink: %s/%d is already on-link\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen));
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
+ pr->ndpr_plen));
return (EEXIST);
}
@@ -1605,7 +1636,8 @@ nd6_prefix_onlink(struct nd_prefix *pr)
nd6log((LOG_NOTICE,
"nd6_prefix_onlink: failed to find any ifaddr"
" to add route for a prefix(%s/%d) on %s\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, ifp->if_xname));
return (0);
}
@@ -1641,13 +1673,17 @@ nd6_prefix_onlink(struct nd_prefix *pr)
nd6_rtmsg(RTM_ADD, rt);
pr->ndpr_stateflags |= NDPRF_ONLINK;
} else {
+ char gw[INET6_ADDRSTRLEN], mask[INET6_ADDRSTRLEN];
nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add route for a"
" prefix (%s/%d) on %s, gw=%s, mask=%s, flags=%lx "
"errno = %d\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
pr->ndpr_plen, ifp->if_xname,
- ip6_sprintf(&satosin6(ifa->ifa_addr)->sin6_addr),
- ip6_sprintf(&mask6.sin6_addr), rtflags, error));
+ inet_ntop(AF_INET6, &satosin6(ifa->ifa_addr)->sin6_addr,
+ gw, sizeof(gw)),
+ inet_ntop(AF_INET6, &mask6.sin6_addr, mask, sizeof(mask)),
+ rtflags, error));
}
if (rt != NULL)
@@ -1665,12 +1701,15 @@ nd6_prefix_offlink(struct nd_prefix *pr)
struct nd_prefix *opr;
struct sockaddr_in6 sa6, mask6;
struct rtentry *rt = NULL;
+ char addr[INET6_ADDRSTRLEN];
/* sanity check */
if ((pr->ndpr_stateflags & NDPRF_ONLINK) == 0) {
nd6log((LOG_ERR,
"nd6_prefix_offlink: %s/%d is already off-link\n",
- ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen));
+ inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
+ pr->ndpr_plen));
return (EEXIST);
}
@@ -1726,7 +1765,9 @@ nd6_prefix_offlink(struct nd_prefix *pr)
"nd6_prefix_offlink: failed to "
"recover a prefix %s/%d from %s "
"to %s (errno = %d)\n",
- ip6_sprintf(&opr->ndpr_prefix.sin6_addr),
+ inet_ntop(AF_INET6,
+ &pr->ndpr_prefix.sin6_addr,
+ addr, sizeof(addr)),
opr->ndpr_plen, ifp->if_xname,
opr->ndpr_ifp->if_xname, e));
}
@@ -1737,8 +1778,8 @@ nd6_prefix_offlink(struct nd_prefix *pr)
nd6log((LOG_ERR,
"nd6_prefix_offlink: failed to delete route: "
"%s/%d on %s (errno = %d)\n",
- ip6_sprintf(&sa6.sin6_addr), pr->ndpr_plen, ifp->if_xname,
- error));
+ inet_ntop(AF_INET6, &sa6.sin6_addr, addr, sizeof(addr)),
+ pr->ndpr_plen, ifp->if_xname, error));
}
if (rt != NULL) {
@@ -1883,10 +1924,13 @@ in6_ifadd(struct nd_prefix *pr, int privacy)
splx(s);
if (error != 0) {
+ char addr[INET6_ADDRSTRLEN];
+
nd6log((LOG_ERR,
"in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n",
- ip6_sprintf(&ifra.ifra_addr.sin6_addr), ifp->if_xname,
- error));
+ inet_ntop(AF_INET6, &ifra.ifra_addr.sin6_addr,
+ addr, sizeof(addr)),
+ ifp->if_xname, error));
return (NULL); /* ifaddr must not have been allocated. */
}
diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c
index fcc02581c5f..31714070965 100644
--- a/sys/nfs/krpc_subr.c
+++ b/sys/nfs/krpc_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: krpc_subr.c,v 1.21 2013/08/27 03:32:12 deraadt Exp $ */
+/* $OpenBSD: krpc_subr.c,v 1.22 2013/11/11 09:15:35 mpi Exp $ */
/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
/*
@@ -215,6 +215,7 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
struct uio auio;
int error, rcvflg, timo, secs, len;
static u_int32_t xid = 0;
+ char addr[INET_ADDRSTRLEN];
int *ip;
struct timeval tv;
@@ -356,7 +357,8 @@ krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func,
timo++;
else
printf("RPC timeout for server %s (0x%x) prog %u\n",
- inet_ntoa(sin->sin_addr),
+ inet_ntop(AF_INET, &sin->sin_addr,
+ addr, sizeof(addr)),
ntohl(sin->sin_addr.s_addr), prog);
/*
diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c
index 3b1d26d9600..89c8b6d193d 100644
--- a/sys/nfs/nfs_boot.c
+++ b/sys/nfs/nfs_boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_boot.c,v 1.29 2013/09/20 23:51:44 fgsch Exp $ */
+/* $OpenBSD: nfs_boot.c,v 1.30 2013/11/11 09:15:35 mpi Exp $ */
/* $NetBSD: nfs_boot.c,v 1.26 1996/05/07 02:51:25 thorpej Exp $ */
/*
@@ -121,6 +121,7 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp)
struct sockaddr_in *sin;
struct ifnet *ifp;
struct socket *so;
+ char addr[INET_ADDRSTRLEN];
int error;
/*
@@ -171,7 +172,8 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp)
*/
if ((error = revarpwhoami(&my_ip, ifp)) != 0)
panic("reverse arp not answered by rarpd(8) or dhcpd(8)");
- printf("nfs_boot: client_addr=%s\n", inet_ntoa(my_ip));
+ inet_ntop(AF_INET, &my_ip, addr, sizeof(addr));
+ printf("nfs_boot: client_addr=%s\n", addr);
/*
* Do enough of ifconfig(8) so that the chosen interface
@@ -208,8 +210,8 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp)
error = bp_whoami(&bp_sin, &my_ip, &gw_ip);
if (error)
panic("nfs_boot: bootparam whoami, error=%d", error);
- printf("nfs_boot: server_addr=%s hostname=%s\n",
- inet_ntoa(bp_sin.sin_addr), hostname);
+ inet_ntop(AF_INET, &bp_sin.sin_addr, addr, sizeof(addr));
+ printf("nfs_boot: server_addr=%s hostname=%s\n", addr, hostname);
#ifdef NFS_BOOT_GATEWAY
/*
@@ -246,7 +248,8 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp)
info.rti_info[RTAX_NETMASK] = &mask;
info.rti_flags = (RTF_UP | RTF_GATEWAY | RTF_STATIC);
- printf("nfs_boot: gateway=%s\n", inet_ntoa(gw_ip));
+ inet_ntop(AF_INET, gw_ip, addr, sizeof(addr));
+ printf("nfs_boot: gateway=%s\n", addr);
/* add, dest, gw, mask, flags, 0 */
error = rtrequest1(RTM_ADD, &info, RTP_STATIC, NULL, 0);
if (error)