-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPECIALping.h
138 lines (120 loc) · 3.58 KB
/
SPECIALping.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* static char sccsid[] = "@(#)ping.h";
*/
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ctype.h>
#include <signal.h>
#ifndef __STDC__
#define const
#endif /* __STDC__ */
#ifdef MORESTATS
#include <math.h>
#endif /* MORESTATS */
#define MAXWAIT 10 /* max time to wait for response, sec. */
#define MAXPACKET 65536 /* max packet size */
#define MAXDATA MAXPACKET-sizeof(struct timeval)-ICMP_MINLEN /* max data length */
#define NROUTES 9 /* number of record route slots */
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 64
#endif
#define MAX_PROBES 10
#define RECV_BUF 48*1024 /* Size of receive buffer to specify */
#define OF_VERBOSE 0x01 /* verbose flag */
#define OF_QUIET 0x02 /* quiet flag */
#define OF_FLOOD 0x04 /* floodping flag */
#define OF_RROUTE 0x08 /* record route flag */
#define OF_CISCO 0x10 /* Cisco style pings */
#define OF_NUMERIC 0x20 /* Numeric IP addresses only */
#define OF_MISSING 0x40 /* Print table of missing responses */
#define OF_FAST 0x80 /* Send an echo request whenever we get a response */
#define OF_FILLED 0x0100 /* Fill packets with specified data */
#define OF_LSROUTE 0x0200 /* Loose source routing */
#define OF_SSROUTE 0x0400 /* Strict source routing */
#define OF_DONTROUTE 0x0800 /* Don't use routing table */
#define OF_DEBUG 0x1000 /* Turn on socket debugging */
#define OF_SRCADDR 0x2000 /* Turn on socket debugging */
/* time in microseconds */
typedef unsigned long hw_time_t;
/*
* Structure for storing responses for a specific route
*/
typedef struct _optstr {
struct _optstr *next;
/* stats optstats; BC - don't need this, do we?*/
char optval[MAX_IPOPTLEN];
} optstr;
struct opt_names {
char op_letter;
const char *op_arg;
const char *op_name;
};
/* References to packet fields */
#define out_icmp ((struct icmp *) outpack)
#define out_tp ((hw_time_t *) (outpack + ICMP_MINLEN))
#define out_pattern ((u_char *) out_tp + sizeof(*out_tp))
/*
* Shared data
*/
extern int timing; /* Packets are long enough to time */
extern int got_one; /* Received a packet this period */
extern int datalen;
extern int column; /* For keeping track of output column */
extern u_long pingflags; /* User specified options */
extern struct timezone tz;
extern u_char outpack[]; /* Outgoing packet buffer */
extern u_char packet[]; /* Incoming packet buffer */
extern int mx_dup_ck;
extern char rcvd_tbl[];
/*
* Routine type declarations
*/
void recv_alarm();
void prefinish();
void finish();
void record_stats();
void tvsub();
void usage();
#ifdef __STDC__
void pr_retip(struct ip *ip);
u_short in_cksum(u_short *, int);
hw_time_t timesub(hw_time_t *first, hw_time_t *second);
char *a2sockaddr(struct sockaddr_in *, char *, char *);
int recv_icmp(int, u_char *, int);
void send_icmp(int, int, struct sockaddr_in *);
u_short in_cksum(u_short *, int);
void pr_icmph(struct icmp *);
void pr_iph(struct ip *);
void pr_retip(struct ip *);
void pr_rroption(char *);
char *pr_addr(struct in_addr);
char *pr_quad_addr(struct in_addr);
#else /* __STDC__ */
int recv_icmp();
void send_icmp();
u_short in_cksum();
void pr_icmph();
void pr_iph();
void pr_retip();
void pr_rroption();
void pr_stats();
char *pr_addr();
char *pr_quad_addr();
#endif /* __STDC__ */
/* System routines */
extern char *inet_ntoa();
extern int optind;
extern int errno;