init_v6.c 702 B

12345678910111213141516171819202122232425262728
  1. #include "ping.h"
  2. void
  3. init_v6()
  4. {
  5. #ifdef IPV6
  6. int on = 1;
  7. if (verbose == 0) {
  8. /* install a filter that only passes ICMP6_ECHO_REPLY unless verbose */
  9. struct icmp6_filter myfilt;
  10. ICMP6_FILTER_SETBLOCKALL(&myfilt);
  11. ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &myfilt);
  12. setsockopt(sockfd, IPPROTO_IPV6, ICMP6_FILTER, &myfilt, sizeof(myfilt));
  13. /* ignore error return; the filter is an optimization */
  14. }
  15. /* ignore error returned below; we just won't receive the hop limit */
  16. #ifdef IPV6_RECVHOPLIMIT
  17. /* RFC 3542 */
  18. setsockopt(sockfd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on));
  19. #else
  20. /* RFC 2292 */
  21. setsockopt(sockfd, IPPROTO_IPV6, IPV6_HOPLIMIT, &on, sizeof(on));
  22. #endif
  23. #endif
  24. }