From: Francois-Xavier Le Bail Date: Mon, 10 Jun 2019 13:32:20 +0000 (+0200) Subject: Use nd_ipv6 rather than struct in6_addr X-Git-Tag: tcpdump-4.99-bp~753 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/0c9cfdcb0d28414c1b6ffe45da1a0b6b9aec4977 Use nd_ipv6 rather than struct in6_addr --- diff --git a/addrtoname.c b/addrtoname.c index 1c80c39f..8e834d52 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -184,7 +184,7 @@ win32_gethostbyaddr(const char *addr, int len, int type) #endif /* _WIN32 */ struct h6namemem { - struct in6_addr addr; + nd_ipv6 addr; char *name; struct h6namemem *nxt; }; @@ -346,7 +346,7 @@ ip6addr_string(netdissect_options *ndo, const u_char *ap) { struct hostent *hp; union { - struct in6_addr addr; + nd_ipv6 addr; struct for_hash_addr { char fill[14]; uint16_t d; @@ -362,7 +362,7 @@ ip6addr_string(netdissect_options *ndo, const u_char *ap) if (memcmp(&p->addr, &addr, sizeof(addr)) == 0) return (p->name); } - p->addr = addr.addr; + memcpy(p->addr, addr.addr, sizeof(nd_ipv6)); p->nxt = newh6namemem(ndo); /* diff --git a/print-bgp.c b/print-bgp.c index 94de6757..85a82ef4 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -1233,7 +1233,7 @@ int decode_prefix6(netdissect_options *ndo, const u_char *pd, u_int itemlen, char *buf, size_t buflen) { - struct in6_addr addr; + nd_ipv6 addr; u_int plen, plenbytes; ND_TCHECK_1(pd); @@ -1249,7 +1249,7 @@ decode_prefix6(netdissect_options *ndo, ITEMCHECK(plenbytes); memcpy(&addr, pd + 1, plenbytes); if (plen % 8) { - addr.s6_addr[plenbytes - 1] &= + addr[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } nd_snprintf(buf, buflen, "%s/%u", ip6addr_string(ndo, (const u_char *)&addr), plen); @@ -1266,7 +1266,7 @@ static int decode_labeled_prefix6(netdissect_options *ndo, const u_char *pptr, u_int itemlen, char *buf, size_t buflen) { - struct in6_addr addr; + nd_ipv6 addr; u_int plen, plenbytes; /* prefix length and label = 4 bytes */ @@ -1288,7 +1288,7 @@ decode_labeled_prefix6(netdissect_options *ndo, ND_TCHECK_LEN(pptr + 4, plenbytes); memcpy(&addr, pptr + 4, plenbytes); if (plen % 8) { - addr.s6_addr[plenbytes - 1] &= + addr[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } /* the label may get offsetted by 4 bits so lets shift it right */ @@ -1311,7 +1311,7 @@ static int decode_labeled_vpn_prefix6(netdissect_options *ndo, const u_char *pptr, char *buf, size_t buflen) { - struct in6_addr addr; + nd_ipv6 addr; u_int plen; ND_TCHECK_1(pptr); @@ -1329,7 +1329,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo, ND_TCHECK_LEN(pptr + 12, (plen + 7) / 8); memcpy(&addr, pptr + 12, (plen + 7) / 8); if (plen % 8) { - addr.s6_addr[(plen + 7) / 8 - 1] &= + addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } /* the label may get offsetted by 4 bits so lets shift it right */ diff --git a/print-domain.c b/print-domain.c index 97a5fe20..63705db5 100644 --- a/print-domain.c +++ b/print-domain.c @@ -526,7 +526,7 @@ ns_rprint(netdissect_options *ndo, case T_A6: { - struct in6_addr a; + nd_ipv6 a; int pbit, pbyte; char ntop_buf[INET6_ADDRSTRLEN]; @@ -540,8 +540,8 @@ ns_rprint(netdissect_options *ndo, } else if (pbit < 128) { if (!ND_TTEST_LEN(cp + 1, sizeof(a) - pbyte)) return(NULL); - memset(&a, 0, sizeof(a)); - memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte); + memset(a, 0, sizeof(a)); + memcpy(a + pbyte, cp + 1, sizeof(a) - pbyte); ND_PRINT(" %u %s", pbit, addrtostr6(&a, ntop_buf, sizeof(ntop_buf))); } diff --git a/print-esp.c b/print-esp.c index f30563aa..9d8906e5 100644 --- a/print-esp.c +++ b/print-esp.c @@ -100,7 +100,7 @@ struct newesp { #ifdef HAVE_LIBCRYPTO union inaddr_u { nd_ipv4 in4; - struct in6_addr in6; + nd_ipv6 in6; }; struct sa_list { struct sa_list *next; diff --git a/print-icmp6.c b/print-icmp6.c index c1bce28b..1f0c24ba 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1438,7 +1438,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid) const struct nd_opt_homeagent_info *oph; const struct nd_opt_route_info *opri; const u_char *cp, *ep, *domp; - struct in6_addr in6; + nd_ipv6 in6; size_t l; u_int i; diff --git a/print-ip6.c b/print-ip6.c index 15e13c2b..a15206c2 100644 --- a/print-ip6.c +++ b/print-ip6.c @@ -44,7 +44,7 @@ * calculation. */ static void -ip6_finddst(netdissect_options *ndo, struct in6_addr *dst, +ip6_finddst(netdissect_options *ndo, nd_ipv6 *dst, const struct ip6_hdr *ip6) { const u_char *cp; @@ -177,8 +177,8 @@ nextproto6_cksum(netdissect_options *ndo, u_int len, u_int covlen, uint8_t next_proto) { struct { - struct in6_addr ph_src; - struct in6_addr ph_dst; + nd_ipv6 ph_src; + nd_ipv6 ph_dst; uint32_t ph_len; uint8_t ph_zero[3]; uint8_t ph_nxt; @@ -188,7 +188,7 @@ nextproto6_cksum(netdissect_options *ndo, /* pseudo-header */ memset(&ph, 0, sizeof(ph)); - UNALIGNED_MEMCPY(&ph.ph_src, ip6->ip6_src, sizeof (struct in6_addr)); + UNALIGNED_MEMCPY(&ph.ph_src, ip6->ip6_src, sizeof (nd_ipv6)); nh = GET_U_1(ip6->ip6_nxt); switch (nh) { @@ -208,7 +208,7 @@ nextproto6_cksum(netdissect_options *ndo, default: UNALIGNED_MEMCPY(&ph.ph_dst, ip6->ip6_dst, - sizeof (struct in6_addr)); + sizeof (nd_ipv6)); break; } ph.ph_len = htonl(len); diff --git a/print-isakmp.c b/print-isakmp.c index 66496666..8c46bce4 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -636,7 +636,7 @@ ikev1_print(netdissect_options *ndo, static int ninitiator = 0; union inaddr_u { nd_ipv4 in4; - struct in6_addr in6; + nd_ipv6 in6; }; static struct { cookie_t initiator; diff --git a/print-nfs.c b/print-nfs.c index a6755513..76bbfd3e 100644 --- a/print-nfs.c +++ b/print-nfs.c @@ -955,8 +955,8 @@ nfs_printfh(netdissect_options *ndo, struct xid_map_entry { uint32_t xid; /* transaction ID (net order) */ int ipver; /* IP version (4 or 6) */ - struct in6_addr client; /* client IP address (net order) */ - struct in6_addr server; /* server IP address (net order) */ + nd_ipv6 client; /* client IP address (net order) */ + nd_ipv6 server; /* server IP address (net order) */ uint32_t proc; /* call proc number (host order) */ uint32_t vers; /* program version (host order) */ }; diff --git a/print-tcp.c b/print-tcp.c index 58e1aef6..d5c5f6d6 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -81,8 +81,8 @@ struct tcp_seq_hash { }; struct tha6 { - struct in6_addr src; - struct in6_addr dst; + nd_ipv6 src; + nd_ipv6 dst; u_int port; };