I'm trying to ping over IPv6, I need it to get a MAC address from a remote host. As far as I understand, IPv6 does not use the ARP table, but with the help of the so-called ICMPv6 it is possible to get the MAC address, I used tcpdump and saw MAC addresses. If I'm wrong about something, please correct me. So, I am using Windows and C++,I'm trying to use the Icmp6SendEcho2() function from IcmpAPI.h and ran into an error 11050 which says that "IP_GENERAL_FAILURE, A general failure. This error can be returned for some malformed ICMP packets.", and I don't know what to do next.
ULONG icmpReplyCount = 0;
HANDLE icmpHandle = INVALID_HANDLE_VALUE;
CHAR icmpEchoBuffer[2048] = { 0 };
IP_OPTION_INFORMATION pingOptions = { 255, 0, IP_FLAG_DF, 0 };
CHAR icmpReplyBuffer [2048];
ULONG icmpReplyLength = 0;
DWORD timeout = 5;
DWORD lastErr = 0;
icmpHandle = Icmp6CreateFile();
struct sockaddr_storage sockStoreLocal = {};
sockaddr_in6* icmp6LocalAddr = (struct sockaddr_in6*)&sockStoreLocal;
icmp6LocalAddr->sin6_family = AF_INET6;
icmp6LocalAddr->sin6_flowinfo = 0;
icmp6LocalAddr->sin6_port = htons(0);
inet_pton(AF_INET6, "fc00:1:1::48", &icmp6LocalAddr->sin6_addr);
struct sockaddr_storage sockStoreRemoute = {};
sockaddr_in6* icmp6RemoteAddr = (struct sockaddr_in6*)&sockStoreRemoute;
icmp6RemoteAddr->sin6_family = AF_INET6;
icmp6RemoteAddr->sin6_port = htons(58);
inet_pton(AF_INET6, "fc00:1:1::109", &icmp6RemoteAddr->sin6_addr);
icmpReplyCount = Icmp6SendEcho2(icmpHandle, NULL, NULL, NULL, icmp6LocalAddr, icmp6RemoteAddr, icmpEchoBuffer, sizeof(icmpEchoBuffer), &pingOptions, icmpReplyBuffer, sizeof(icmpReplyBuffer), timeout);
lastErr = GetLastError();
Maybe I'm converting the IPv6 address incorrectly or what I'm doing wrong with the buffers. icmpReplyCount = 0 and lastErr = 11050
I found the answer, the buffers were not large enough, I increased the size and everything worked, no errors returned)))