#define ARP_STRUCT_SIZE \
sizeof(struct ether_arp)
-#define IP6_NA_STRUCT_SIZE sizeof(struct ether_header) + \
+#define IP6_NA_STRUCT_SIZE \
sizeof(struct ip6_hdr) + \
sizeof(struct nd_neighbor_advert) + \
sizeof(struct nd_opt_hdr) + \
size_t buflen,
const struct sockaddr_in6 *addr,
const struct ether_addr *hwaddr,
- struct ether_addr **ether_dhost,
size_t *len)
{
size_t l = IP6_NA_BUFFER_SIZE;
- struct ether_header *eh;
struct ip6_hdr *ip6;
/*
* IPv6 all nodes link-level multicast address: (see RFC2373,
memset(buffer, 0 , l);
- eh = (struct ether_header *)buffer;
- ret = ip6_ll_multicast_build(eh->ether_dhost, ETH_ALEN);
- if (ret != 0) {
- return ret;
- }
- memcpy(eh->ether_shost, hwaddr, ETH_ALEN);
- eh->ether_type = htons(ETHERTYPE_IP6);
-
- ip6 = (struct ip6_hdr *)(buffer + sizeof(struct ether_header));
+ ip6 = (struct ip6_hdr *)buffer;
ip6->ip6_vfc = 6 << 4;
ip6->ip6_plen = htons(sizeof(struct nd_neighbor_advert) +
sizeof(struct nd_opt_hdr) +
}
nd_na = (struct nd_neighbor_advert *)(buffer +
- sizeof(struct ether_header) +
sizeof(struct ip6_hdr));
nd_na->nd_na_type = ND_NEIGHBOR_ADVERT;
nd_na->nd_na_code = 0;
/* Option: Target link-layer address */
nd_oh = (struct nd_opt_hdr *)(buffer +
- sizeof(struct ether_header) +
sizeof(struct ip6_hdr) +
sizeof(struct nd_neighbor_advert));
nd_oh->nd_opt_type = ND_OPT_TARGET_LINKADDR;
nd_oh->nd_opt_len = 1; /* multiple of 8 octets */
ea = (struct ether_addr *)(buffer +
- sizeof(struct ether_header) +
sizeof(struct ip6_hdr) +
sizeof(struct nd_neighbor_advert) +
sizeof(struct nd_opt_hdr));
ntohs(ip6->ip6_plen),
ip6);
- *ether_dhost = (struct ether_addr *)eh->ether_dhost;
*len = l;
return 0;
}
},
};
struct ether_addr *hwaddr = NULL;
- struct ether_addr *ether_dhost = NULL;
size_t len = 0;
int ret = 0;
case AF_INET6:
/* Send IPv6 NA */
sall.sll_protocol = htons(ETH_P_IPV6);
+ ret = ip6_ll_multicast_build(&sall.sll_addr[0], ETH_ALEN);
+ if (ret != 0) {
+ DBG_ERR("Failed to build IPv6 link-level destination\n");
+ goto done;
+ }
+
ret = ip6_na_build(buffer,
sizeof(buffer),
&addr->ip6,
hwaddr,
- ðer_dhost,
&len);
if (ret != 0) {
DBG_ERR("Failed to build IPv6 neighbor advertisement\n");
goto done;
}
- memcpy(&sall.sll_addr[0], ether_dhost, sall.sll_halen);
-
ret = sendto(s,
- buffer + sizeof(struct ether_header),
- len - sizeof(struct ether_header),
+ buffer,
+ len,
0,
(struct sockaddr *)&sall,
sizeof(sall));
test_case "IPv6 neighbor advertisement"
ok <<EOF
-000000 33 33 00 00 00 01 12 34 56 78 9a bc 86 dd 60 00
-000010 00 00 00 20 3a ff fe 80 00 00 00 00 00 00 6a f7
-000020 28 ff fe fa d1 36 ff 02 00 00 00 00 00 00 00 00
-000030 00 00 00 00 00 01 88 00 8d e4 20 00 00 00 fe 80
-000040 00 00 00 00 00 00 6a f7 28 ff fe fa d1 36 02 01
-000050 12 34 56 78 9a bc
-000056
+000000 60 00 00 00 00 20 3a ff fe 80 00 00 00 00 00 00
+000010 6a f7 28 ff fe fa d1 36 ff 02 00 00 00 00 00 00
+000020 00 00 00 00 00 00 00 01 88 00 8d e4 20 00 00 00
+000030 fe 80 00 00 00 00 00 00 6a f7 28 ff fe fa d1 36
+000040 02 01 12 34 56 78 9a bc
+000048
EOF
arp_test "fe80::6af7:28ff:fefa:d136" "12:34:56:78:9a:bc"
uint16_t arpop)
{
ctdb_sock_addr addr;
- struct ether_addr *hw, *dhw;
+ struct ether_addr *hw = NULL;
uint8_t buf[512];
size_t buflen = sizeof(buf);
size_t len;
ret = arp_build(buf, buflen, &addr.ip, hw, arpop, &len);
break;
case AF_INET6:
- ret = ip6_na_build(buf, buflen, &addr.ip6, hw, &dhw, &len);
+ ret = ip6_na_build(buf, buflen, &addr.ip6, hw, &len);
break;
default:
abort();