trace.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "unp.h"
  2. #include <netinet/in_systm.h>
  3. #include <netinet/ip.h>
  4. #include <netinet/ip_icmp.h>
  5. #include <netinet/udp.h>
  6. #define BUFSIZE 1500
  7. struct rec { /* format of outgoing UDP data */
  8. u_short rec_seq; /* sequence number */
  9. u_short rec_ttl; /* TTL packet left with */
  10. struct timeval rec_tv; /* time packet left */
  11. };
  12. /* globals */
  13. char recvbuf[BUFSIZE];
  14. char sendbuf[BUFSIZE];
  15. int datalen; /* # bytes of data following ICMP header */
  16. char *host;
  17. u_short sport, dport;
  18. int nsent; /* add 1 for each sendto() */
  19. pid_t pid; /* our PID */
  20. int probe, nprobes;
  21. int sendfd, recvfd; /* send on UDP sock, read on raw ICMP sock */
  22. int ttl, max_ttl;
  23. int verbose;
  24. /* function prototypes */
  25. const char *icmpcode_v4(int);
  26. const char *icmpcode_v6(int);
  27. int recv_v4(int, struct timeval *);
  28. int recv_v6(int, struct timeval *);
  29. void sig_alrm(int);
  30. void traceloop(void);
  31. void tv_sub(struct timeval *, struct timeval *);
  32. struct proto {
  33. const char *(*icmpcode)(int);
  34. int (*recv)(int, struct timeval *);
  35. struct sockaddr *sasend; /* sockaddr{} for send, from getaddrinfo */
  36. struct sockaddr *sarecv; /* sockaddr{} for receiving */
  37. struct sockaddr *salast; /* last sockaddr{} for receiving */
  38. struct sockaddr *sabind; /* sockaddr{} for binding source port */
  39. socklen_t salen; /* length of sockaddr{}s */
  40. int icmpproto; /* IPPROTO_xxx value for ICMP */
  41. int ttllevel; /* setsockopt() level to set TTL */
  42. int ttloptname; /* setsockopt() name to set TTL */
  43. } *pr;
  44. #ifdef IPV6
  45. #include <netinet/ip6.h>
  46. #include <netinet/icmp6.h>
  47. #endif