10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1311Sjbeck * Common Development and Distribution License, (the "License"). 6*1311Sjbeck * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1311Sjbeck * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _PING_H 280Sstevel@tonic-gate #define _PING_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #define MAX_PORT 65535 /* max port number for UDP probes */ 370Sstevel@tonic-gate #define MAX_ICMP_SEQ 65535 /* max icmp sequence value */ 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* 400Sstevel@tonic-gate * Maximum number of source route space. Please note that because of the API, 410Sstevel@tonic-gate * we can only specify 8 gateways, the last address has to be the target 420Sstevel@tonic-gate * address. 430Sstevel@tonic-gate */ 440Sstevel@tonic-gate #define MAX_GWS 9 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate * This is the max it can be. But another limiting factor is the PMTU, 480Sstevel@tonic-gate * so in any instance, it can be less than 127. 490Sstevel@tonic-gate */ 500Sstevel@tonic-gate #define MAX_GWS6 127 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* maximum of above two */ 530Sstevel@tonic-gate #define MAXMAX_GWS MAX(MAX_GWS, MAX_GWS6) 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* size of buffer to store the IPv4 gateway addresses */ 560Sstevel@tonic-gate #define ROUTE_SIZE (IPOPT_OLEN + IPOPT_OFFSET + \ 570Sstevel@tonic-gate MAX_GWS * sizeof (struct in_addr)) 580Sstevel@tonic-gate 590Sstevel@tonic-gate #define A_CNT(ARRAY) (sizeof (ARRAY) / sizeof ((ARRAY)[0])) 600Sstevel@tonic-gate 610Sstevel@tonic-gate 620Sstevel@tonic-gate #define Printf (void) printf 630Sstevel@tonic-gate #define Fprintf (void) fprintf 640Sstevel@tonic-gate 65*1311Sjbeck #define TIMEFORMAT "%#.3f" 660Sstevel@tonic-gate 670Sstevel@tonic-gate 680Sstevel@tonic-gate /* 690Sstevel@tonic-gate * For each target IP address we are going to probe, we store required info, 700Sstevel@tonic-gate * such as address family, IP address of target, source IP address to use 710Sstevel@tonic-gate * for that target address, and number of probes to send in the targetaddr 720Sstevel@tonic-gate * structure. 730Sstevel@tonic-gate * All target addresses are also linked to each other and used in 740Sstevel@tonic-gate * scheduling probes. Each targetaddr structure identifies a batch of probes to 750Sstevel@tonic-gate * send : where to send, how many to send. We capture state information, such as 760Sstevel@tonic-gate * number of probes already sent (in this batch only), whether target replied 770Sstevel@tonic-gate * as we probe it, whether we are done with probing this address (can happen 780Sstevel@tonic-gate * in regular (!stats) mode when we get a reply for a probe sent in current 790Sstevel@tonic-gate * batch), and starting sequence number which is used together with number of 800Sstevel@tonic-gate * probes sent to determine if the incoming reply is for a probe we sent in 810Sstevel@tonic-gate * current batch. 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate struct targetaddr { 840Sstevel@tonic-gate int family; 850Sstevel@tonic-gate union any_in_addr dst_addr; /* dst address for the probe */ 860Sstevel@tonic-gate union any_in_addr src_addr; /* src addr to use for this dst addr */ 870Sstevel@tonic-gate int num_probes; /* num of probes to send to this dst */ 880Sstevel@tonic-gate int num_sent; /* number of probes already sent */ 890Sstevel@tonic-gate boolean_t got_reply; /* received a reply from dst while */ 900Sstevel@tonic-gate /* still probing it */ 910Sstevel@tonic-gate boolean_t probing_done; /* skip without sending all probes */ 920Sstevel@tonic-gate ushort_t starting_seq_num; /* initial icmp_seq/UDP port, used */ 930Sstevel@tonic-gate /* for authenticating replies */ 940Sstevel@tonic-gate struct targetaddr *next; /* next targetaddr item in the list */ 950Sstevel@tonic-gate }; 960Sstevel@tonic-gate 970Sstevel@tonic-gate struct hostinfo { 980Sstevel@tonic-gate char *name; /* hostname */ 990Sstevel@tonic-gate int family; /* address family */ 1000Sstevel@tonic-gate int num_addr; /* number of addresses */ 1010Sstevel@tonic-gate union any_in_addr *addrs; /* address list */ 1020Sstevel@tonic-gate }; 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate struct icmptype_table { 1050Sstevel@tonic-gate int type; /* ICMP type */ 1060Sstevel@tonic-gate char *message; /* corresponding string message */ 1070Sstevel@tonic-gate }; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate extern struct targetaddr *current_targetaddr; 1100Sstevel@tonic-gate extern int nreceived; 1110Sstevel@tonic-gate extern int nreceived_last_target; 1120Sstevel@tonic-gate extern int npackets; 1130Sstevel@tonic-gate extern boolean_t is_alive; 1140Sstevel@tonic-gate extern int datalen; 1150Sstevel@tonic-gate extern boolean_t nflag; 1160Sstevel@tonic-gate extern int ident; 1170Sstevel@tonic-gate extern boolean_t probe_all; 1180Sstevel@tonic-gate extern char *progname; 1190Sstevel@tonic-gate extern boolean_t rr_option; 1200Sstevel@tonic-gate extern boolean_t stats; 1210Sstevel@tonic-gate extern boolean_t strict; 1220Sstevel@tonic-gate extern char *targethost; 1230Sstevel@tonic-gate extern long long tmax; 1240Sstevel@tonic-gate extern long long tmin; 1250Sstevel@tonic-gate extern int ts_flag; 1260Sstevel@tonic-gate extern boolean_t ts_option; 1270Sstevel@tonic-gate extern int64_t tsum; 1280Sstevel@tonic-gate extern int64_t tsum2; 1290Sstevel@tonic-gate extern boolean_t use_icmp_ts; 1300Sstevel@tonic-gate extern boolean_t use_udp; 1310Sstevel@tonic-gate extern boolean_t verbose; 1320Sstevel@tonic-gate extern boolean_t send_reply; 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate #ifdef __cplusplus 1350Sstevel@tonic-gate } 1360Sstevel@tonic-gate #endif 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate #endif /* _PING_H */ 139