xref: /titanic_50/usr/src/cmd/cmd-inet/usr.sbin/ping/ping.h (revision ba7866cd2cbdf574f47d4e38a1301b90744dd677)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 
27 #ifndef _PING_H
28 #define	_PING_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	MAX_PORT	65535   /* max port number for UDP probes */
37 #define	MAX_ICMP_SEQ	65535   /* max icmp sequence value */
38 
39 /*
40  * Maximum number of source route space. Please note that because of the API,
41  * we can only specify 8 gateways, the last address has to be the target
42  * address.
43  */
44 #define	MAX_GWS		9
45 
46 /*
47  * This is the max it can be. But another limiting factor is the PMTU,
48  * so in any instance, it can be less than 127.
49  */
50 #define	MAX_GWS6 	127
51 
52 /* maximum of above two */
53 #define	MAXMAX_GWS	MAX(MAX_GWS, MAX_GWS6)
54 
55 /* size of buffer to store the IPv4 gateway addresses */
56 #define	ROUTE_SIZE 	(IPOPT_OLEN + IPOPT_OFFSET + \
57 			MAX_GWS * sizeof (struct in_addr))
58 
59 #define	A_CNT(ARRAY) (sizeof (ARRAY) / sizeof ((ARRAY)[0]))
60 
61 
62 #define	Printf (void) printf
63 #define	Fprintf (void) fprintf
64 
65 #define	TIMEFORMAT "%#.3f"
66 
67 
68 /*
69  * For each target IP address we are going to probe, we store required info,
70  * such as address family, IP address of target, source IP address to use
71  * for that target address, and number of probes to send in the targetaddr
72  * structure.
73  * All target addresses are also linked to each other and used in
74  * scheduling probes. Each targetaddr structure identifies a batch of probes to
75  * send : where to send, how many to send. We capture state information, such as
76  * number of probes already sent (in this batch only), whether target replied
77  * as we probe it, whether we are done with probing this address (can happen
78  * in regular (!stats) mode when we get a reply for a probe sent in current
79  * batch), and starting sequence number which is used together with number of
80  * probes sent to determine if the incoming reply is for a probe we sent in
81  * current batch.
82  */
83 struct targetaddr {
84 	int family;
85 	union any_in_addr dst_addr;	/* dst address for the probe */
86 	union any_in_addr src_addr;	/* src addr to use for this dst addr */
87 	int num_probes;			/* num of probes to send to this dst */
88 	int num_sent;			/* number of probes already sent */
89 	boolean_t got_reply;		/* received a reply from dst while */
90 					/* still probing it */
91 	boolean_t probing_done;		/* skip without sending all probes */
92 	ushort_t starting_seq_num;	/* initial icmp_seq/UDP port, used */
93 					/* for authenticating replies */
94 	struct targetaddr *next;	/* next targetaddr item in the list */
95 };
96 
97 struct hostinfo {
98 	char *name;			/* hostname */
99 	int family;			/* address family */
100 	int num_addr;			/* number of addresses */
101 	union any_in_addr *addrs;	/* address list */
102 };
103 
104 struct icmptype_table {
105 	int type;		/* ICMP type */
106 	char *message;		/* corresponding string message */
107 };
108 
109 extern struct targetaddr *current_targetaddr;
110 extern int nreceived;
111 extern int nreceived_last_target;
112 extern int npackets;
113 extern boolean_t is_alive;
114 extern int datalen;
115 extern boolean_t nflag;
116 extern int ident;
117 extern boolean_t probe_all;
118 extern char *progname;
119 extern boolean_t rr_option;
120 extern boolean_t stats;
121 extern boolean_t strict;
122 extern char *targethost;
123 extern long long tmax;
124 extern long long tmin;
125 extern int ts_flag;
126 extern boolean_t ts_option;
127 extern int64_t tsum;
128 extern int64_t tsum2;
129 extern boolean_t use_icmp_ts;
130 extern boolean_t use_udp;
131 extern boolean_t verbose;
132 extern boolean_t send_reply;
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif /* _PING_H */
139