send_v6.c 541 B

123456789101112131415161718192021222324
  1. #include "ping.h"
  2. void
  3. send_v6()
  4. {
  5. #ifdef IPV6
  6. int len;
  7. struct icmp6_hdr *icmp6;
  8. icmp6 = (struct icmp6_hdr *) sendbuf;
  9. icmp6->icmp6_type = ICMP6_ECHO_REQUEST;
  10. icmp6->icmp6_code = 0;
  11. icmp6->icmp6_id = pid;
  12. icmp6->icmp6_seq = nsent++;
  13. memset((icmp6 + 1), 0xa5, datalen); /* fill with pattern */
  14. Gettimeofday((struct timeval *) (icmp6 + 1), NULL);
  15. len = 8 + datalen; /* 8-byte ICMPv6 header */
  16. Sendto(sockfd, sendbuf, len, 0, pr->sasend, pr->salen);
  17. /* 4kernel calculates and stores checksum for us */
  18. #endif /* IPV6 */
  19. }