Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion netutils/ping/icmpv6_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#endif

#include <arpa/inet.h>
#include <netinet/icmp6.h>

#include <nuttx/clock.h>
#include <nuttx/net/icmpv6.h>
Expand Down Expand Up @@ -169,6 +170,7 @@ void icmp6_ping(FAR const struct ping6_info_s *info)
struct ping6_result_s result;
struct sockaddr_in6 destaddr;
struct sockaddr_in6 fromaddr;
struct icmp6_filter filter;
struct icmpv6_echo_request_s outhdr;
FAR struct icmpv6_echo_reply_s *inhdr;
struct pollfd recvfd;
Expand Down Expand Up @@ -210,7 +212,7 @@ void icmp6_ping(FAR const struct ping6_info_s *info)
return;
}

sockfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMP6);
sockfd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
if (sockfd < 0)
{
icmp6_callback(&result, ICMPv6_E_SOCKET, errno);
Expand All @@ -232,6 +234,20 @@ void icmp6_ping(FAR const struct ping6_info_s *info)
}
#endif

memset(&filter, 0xff, sizeof(filter));

/* ICMPv6_ECHO_REPLY >> 5 = 4 */

filter.icmp6_filt[4] &= ~(1 << (ICMPv6_ECHO_REPLY & 31));
if (setsockopt(sockfd, SOL_ICMPV6, ICMP6_FILTER, &filter,
sizeof(filter)) < 0)
{
icmp6_callback(&result, ICMPv6_E_SOCKET, errno);
close(sockfd);
free(iobuffer);
return;
}

kickoff = clock();

memset(&destaddr, 0, sizeof(struct sockaddr_in6));
Expand Down
Loading