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