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