xref: /titanic_50/usr/src/cmd/cmd-inet/usr.sbin/traceroute/traceroute.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*
7*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997
8*7c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
9*7c478bd9Sstevel@tonic-gate  *
10*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
11*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that: (1) source code distributions
12*7c478bd9Sstevel@tonic-gate  * retain the above copyright notice and this paragraph in its entirety, (2)
13*7c478bd9Sstevel@tonic-gate  * distributions including binary code include the above copyright notice and
14*7c478bd9Sstevel@tonic-gate  * this paragraph in its entirety in the documentation or other materials
15*7c478bd9Sstevel@tonic-gate  * provided with the distribution, and (3) all advertising materials mentioning
16*7c478bd9Sstevel@tonic-gate  * features or use of this software display the following acknowledgement:
17*7c478bd9Sstevel@tonic-gate  * ``This product includes software developed by the University of California,
18*7c478bd9Sstevel@tonic-gate  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
19*7c478bd9Sstevel@tonic-gate  * the University nor the names of its contributors may be used to endorse
20*7c478bd9Sstevel@tonic-gate  * or promote products derived from this software without specific prior
21*7c478bd9Sstevel@tonic-gate  * written permission.
22*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
23*7c478bd9Sstevel@tonic-gate  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
24*7c478bd9Sstevel@tonic-gate  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  * @(#)$Header: traceroute.c,v 1.49 97/06/13 02:30:23 leres Exp $ (LBL)
28*7c478bd9Sstevel@tonic-gate  */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifndef _TRACEROUTE_H
31*7c478bd9Sstevel@tonic-gate #define	_TRACEROUTE_H
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
36*7c478bd9Sstevel@tonic-gate extern "C" {
37*7c478bd9Sstevel@tonic-gate #endif
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #define	MAX_PORT	65535		/* max port value for UDP */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #define	REPLY_SHORT_PKT		0	/* check_reply() has a short packet */
42*7c478bd9Sstevel@tonic-gate #define	REPLY_GOT_GATEWAY	1	/* ... rcvd a reply from an inter. gw */
43*7c478bd9Sstevel@tonic-gate #define	REPLY_GOT_TARGET	2	/* ... rcvd the reply from the target */
44*7c478bd9Sstevel@tonic-gate #define	REPLY_GOT_OTHER		3	/* ... received other */
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * this is the max it can be, yet another factor is PMTU, which is ignored
48*7c478bd9Sstevel@tonic-gate  * here
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate #define	MAX_GWS6	127
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate /*
53*7c478bd9Sstevel@tonic-gate  * Maximum number of gateways (include room for one noop).
54*7c478bd9Sstevel@tonic-gate  * 'in_addr_t' is 32 bits, size of IPv4 address.
55*7c478bd9Sstevel@tonic-gate  * Note that the actual number of gateways that can be used for source
56*7c478bd9Sstevel@tonic-gate  * routing is one less than the value below. This is because the API requires
57*7c478bd9Sstevel@tonic-gate  * the last gateway to be the target address.
58*7c478bd9Sstevel@tonic-gate  */
59*7c478bd9Sstevel@tonic-gate #define	MAX_GWS		9
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /* maximum of max_gws */
62*7c478bd9Sstevel@tonic-gate #define	MAXMAX_GWS	MAX(MAX_GWS, MAX_GWS6)
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate #define	A_CNT(ARRAY)	(sizeof (ARRAY) / sizeof ((ARRAY)[0]))
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #define	Fprintf		(void)fprintf
67*7c478bd9Sstevel@tonic-gate #define	Printf		(void)printf
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate struct icmptype_table {
70*7c478bd9Sstevel@tonic-gate 	int type;		/* ICMP type */
71*7c478bd9Sstevel@tonic-gate 	char *message;		/* corresponding string message */
72*7c478bd9Sstevel@tonic-gate };
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /* Data section of the probe packet */
75*7c478bd9Sstevel@tonic-gate struct outdata {
76*7c478bd9Sstevel@tonic-gate 	uchar_t seq;		/* sequence number of this packet */
77*7c478bd9Sstevel@tonic-gate 	uchar_t ttl;		/* ttl packet left with */
78*7c478bd9Sstevel@tonic-gate 	struct timeval tv;	/* time packet left */
79*7c478bd9Sstevel@tonic-gate };
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate extern boolean_t docksum;	/* do checksum (IPv4 only) */
82*7c478bd9Sstevel@tonic-gate extern int gw_count;		/* number of LSRR gateways */
83*7c478bd9Sstevel@tonic-gate extern char *hostname;
84*7c478bd9Sstevel@tonic-gate extern ushort_t ident;		/* identity of this traceroute run */
85*7c478bd9Sstevel@tonic-gate extern boolean_t nflag;		/* numeric flag */
86*7c478bd9Sstevel@tonic-gate extern ushort_t off;		/* set DF bit (IPv4 only) */
87*7c478bd9Sstevel@tonic-gate extern int packlen;		/* packet length */
88*7c478bd9Sstevel@tonic-gate extern ushort_t port;		/* seed of destination port */
89*7c478bd9Sstevel@tonic-gate extern char *prog;		/* program name */
90*7c478bd9Sstevel@tonic-gate extern boolean_t raw_req;	/* if sndsock for IPv4 must be raw */
91*7c478bd9Sstevel@tonic-gate extern boolean_t settos;	/* set type-of-service (IPv4 only) */
92*7c478bd9Sstevel@tonic-gate extern unsigned char tos;	/* value of tos to set */
93*7c478bd9Sstevel@tonic-gate extern boolean_t useicmp;	/* use ICMP or UDP */
94*7c478bd9Sstevel@tonic-gate extern boolean_t verbose;
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
97*7c478bd9Sstevel@tonic-gate }
98*7c478bd9Sstevel@tonic-gate #endif
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #endif /* _TRACEROUTE_H */
101