aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2018-01-08 14:28:55 -0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-14 18:16:13 +0100
commit7805cde867e62884057d3fea3a2854f052f54d20 (patch)
treeb78551523df942a4cbed9cfa2599461f0b417dc1
parentaa0c5f6a3ce7a611413b0b61e0cc4044ccb5cc84 (diff)
downloadslirp-7805cde867e62884057d3fea3a2854f052f54d20.zip
slirp-7805cde867e62884057d3fea3a2854f052f54d20.tar.gz
slirp-7805cde867e62884057d3fea3a2854f052f54d20.tar.bz2
slirp: avoid IN6_IS_ADDR_UNSPECIFIED(), rather use in6_zero()
Host: Mac OS 10.12.5 Compiler: Apple LLVM version 8.1.0 (clang-802.0.42) slirp/ip6_icmp.c:80:38: warning: taking address of packed member 'ip_src' of class or structure 'ip6' may result in an unaligned pointer value [-Waddress-of-packed-member] IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) { ^~~~~~~~~~ /usr/include/netinet6/in6.h:238:42: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED' ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ ^ Reported-by: John Arbuckle <programmingkidx@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r--ip6_icmp.c7
-rw-r--r--ndp_table.c4
2 files changed, 5 insertions, 6 deletions
diff --git a/ip6_icmp.c b/ip6_icmp.c
index f48fd0c..c83f5ed 100644
--- a/ip6_icmp.c
+++ b/ip6_icmp.c
@@ -76,8 +76,7 @@ void icmp6_send_error(struct mbuf *m, uint8_t type, uint8_t code)
DEBUG_CALL("icmp6_send_error");
DEBUG_ARGS((dfd, " type = %d, code = %d\n", type, code));
- if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) ||
- IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
+ if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) || in6_zero(&ip->ip_src)) {
/* TODO icmp error? */
return;
}
@@ -272,7 +271,7 @@ static void ndp_send_na(Slirp *slirp, struct ip6 *ip, struct icmp6 *icmp)
struct mbuf *t = m_get(slirp);
struct ip6 *rip = mtod(t, struct ip6 *);
rip->ip_src = icmp->icmp6_nns.target;
- if (IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
+ if (in6_zero(&ip->ip_src)) {
rip->ip_dst = (struct in6_addr)ALLNODES_MULTICAST;
} else {
rip->ip_dst = ip->ip_src;
@@ -346,7 +345,7 @@ static void ndp_input(struct mbuf *m, Slirp *slirp, struct ip6 *ip,
if (ip->ip_hl == 255 && icmp->icmp6_code == 0 &&
!IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nns.target) &&
ntohs(ip->ip_pl) >= ICMP6_NDP_NS_MINLEN &&
- (!IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src) ||
+ (!in6_zero(&ip->ip_src) ||
in6_solicitednode_multicast(&ip->ip_dst))) {
if (in6_equal_host(&icmp->icmp6_nns.target)) {
/* Gratuitous NDP */
diff --git a/ndp_table.c b/ndp_table.c
index ba22088..bf0a8e4 100644
--- a/ndp_table.c
+++ b/ndp_table.c
@@ -22,7 +22,7 @@ void ndp_table_add(Slirp *slirp, struct in6_addr ip_addr,
DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n", ethaddr[0],
ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5]));
- if (IN6_IS_ADDR_MULTICAST(&ip_addr) || IN6_IS_ADDR_UNSPECIFIED(&ip_addr)) {
+ if (IN6_IS_ADDR_MULTICAST(&ip_addr) || in6_zero(&ip_addr)) {
/* Do not register multicast or unspecified addresses */
DEBUG_CALL(" abort: do not register multicast or unspecified address");
return;
@@ -59,7 +59,7 @@ bool ndp_table_search(Slirp *slirp, struct in6_addr ip_addr,
DEBUG_ARG("ip = %s", addrstr);
#endif
- assert(!IN6_IS_ADDR_UNSPECIFIED(&ip_addr));
+ assert(!in6_zero(&ip_addr));
/* Multicast address: fec0::abcd:efgh/8 -> 33:33:ab:cd:ef:gh */
if (IN6_IS_ADDR_MULTICAST(&ip_addr)) {