17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3c58dfd6Sjbeck * Common Development and Distribution License, (the "License"). 6*3c58dfd6Sjbeck * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*3c58dfd6Sjbeck * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _PING_H 287c478bd9Sstevel@tonic-gate #define _PING_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #define MAX_PORT 65535 /* max port number for UDP probes */ 377c478bd9Sstevel@tonic-gate #define MAX_ICMP_SEQ 65535 /* max icmp sequence value */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate /* 407c478bd9Sstevel@tonic-gate * Maximum number of source route space. Please note that because of the API, 417c478bd9Sstevel@tonic-gate * we can only specify 8 gateways, the last address has to be the target 427c478bd9Sstevel@tonic-gate * address. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate #define MAX_GWS 9 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * This is the max it can be. But another limiting factor is the PMTU, 487c478bd9Sstevel@tonic-gate * so in any instance, it can be less than 127. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate #define MAX_GWS6 127 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* maximum of above two */ 537c478bd9Sstevel@tonic-gate #define MAXMAX_GWS MAX(MAX_GWS, MAX_GWS6) 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* size of buffer to store the IPv4 gateway addresses */ 567c478bd9Sstevel@tonic-gate #define ROUTE_SIZE (IPOPT_OLEN + IPOPT_OFFSET + \ 577c478bd9Sstevel@tonic-gate MAX_GWS * sizeof (struct in_addr)) 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define A_CNT(ARRAY) (sizeof (ARRAY) / sizeof ((ARRAY)[0])) 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #define Printf (void) printf 637c478bd9Sstevel@tonic-gate #define Fprintf (void) fprintf 647c478bd9Sstevel@tonic-gate 65*3c58dfd6Sjbeck #define TIMEFORMAT "%#.3f" 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * For each target IP address we are going to probe, we store required info, 707c478bd9Sstevel@tonic-gate * such as address family, IP address of target, source IP address to use 717c478bd9Sstevel@tonic-gate * for that target address, and number of probes to send in the targetaddr 727c478bd9Sstevel@tonic-gate * structure. 737c478bd9Sstevel@tonic-gate * All target addresses are also linked to each other and used in 747c478bd9Sstevel@tonic-gate * scheduling probes. Each targetaddr structure identifies a batch of probes to 757c478bd9Sstevel@tonic-gate * send : where to send, how many to send. We capture state information, such as 767c478bd9Sstevel@tonic-gate * number of probes already sent (in this batch only), whether target replied 777c478bd9Sstevel@tonic-gate * as we probe it, whether we are done with probing this address (can happen 787c478bd9Sstevel@tonic-gate * in regular (!stats) mode when we get a reply for a probe sent in current 797c478bd9Sstevel@tonic-gate * batch), and starting sequence number which is used together with number of 807c478bd9Sstevel@tonic-gate * probes sent to determine if the incoming reply is for a probe we sent in 817c478bd9Sstevel@tonic-gate * current batch. 827c478bd9Sstevel@tonic-gate */ 837c478bd9Sstevel@tonic-gate struct targetaddr { 847c478bd9Sstevel@tonic-gate int family; 857c478bd9Sstevel@tonic-gate union any_in_addr dst_addr; /* dst address for the probe */ 867c478bd9Sstevel@tonic-gate union any_in_addr src_addr; /* src addr to use for this dst addr */ 877c478bd9Sstevel@tonic-gate int num_probes; /* num of probes to send to this dst */ 887c478bd9Sstevel@tonic-gate int num_sent; /* number of probes already sent */ 897c478bd9Sstevel@tonic-gate boolean_t got_reply; /* received a reply from dst while */ 907c478bd9Sstevel@tonic-gate /* still probing it */ 917c478bd9Sstevel@tonic-gate boolean_t probing_done; /* skip without sending all probes */ 927c478bd9Sstevel@tonic-gate ushort_t starting_seq_num; /* initial icmp_seq/UDP port, used */ 937c478bd9Sstevel@tonic-gate /* for authenticating replies */ 947c478bd9Sstevel@tonic-gate struct targetaddr *next; /* next targetaddr item in the list */ 957c478bd9Sstevel@tonic-gate }; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate struct hostinfo { 987c478bd9Sstevel@tonic-gate char *name; /* hostname */ 997c478bd9Sstevel@tonic-gate int family; /* address family */ 1007c478bd9Sstevel@tonic-gate int num_addr; /* number of addresses */ 1017c478bd9Sstevel@tonic-gate union any_in_addr *addrs; /* address list */ 1027c478bd9Sstevel@tonic-gate }; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate struct icmptype_table { 1057c478bd9Sstevel@tonic-gate int type; /* ICMP type */ 1067c478bd9Sstevel@tonic-gate char *message; /* corresponding string message */ 1077c478bd9Sstevel@tonic-gate }; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate extern struct targetaddr *current_targetaddr; 1107c478bd9Sstevel@tonic-gate extern int nreceived; 1117c478bd9Sstevel@tonic-gate extern int nreceived_last_target; 1127c478bd9Sstevel@tonic-gate extern int npackets; 1137c478bd9Sstevel@tonic-gate extern boolean_t is_alive; 1147c478bd9Sstevel@tonic-gate extern int datalen; 1157c478bd9Sstevel@tonic-gate extern boolean_t nflag; 1167c478bd9Sstevel@tonic-gate extern int ident; 1177c478bd9Sstevel@tonic-gate extern boolean_t probe_all; 1187c478bd9Sstevel@tonic-gate extern char *progname; 1197c478bd9Sstevel@tonic-gate extern boolean_t rr_option; 1207c478bd9Sstevel@tonic-gate extern boolean_t stats; 1217c478bd9Sstevel@tonic-gate extern boolean_t strict; 1227c478bd9Sstevel@tonic-gate extern char *targethost; 1237c478bd9Sstevel@tonic-gate extern long long tmax; 1247c478bd9Sstevel@tonic-gate extern long long tmin; 1257c478bd9Sstevel@tonic-gate extern int ts_flag; 1267c478bd9Sstevel@tonic-gate extern boolean_t ts_option; 1277c478bd9Sstevel@tonic-gate extern int64_t tsum; 1287c478bd9Sstevel@tonic-gate extern int64_t tsum2; 1297c478bd9Sstevel@tonic-gate extern boolean_t use_icmp_ts; 1307c478bd9Sstevel@tonic-gate extern boolean_t use_udp; 1317c478bd9Sstevel@tonic-gate extern boolean_t verbose; 1327c478bd9Sstevel@tonic-gate extern boolean_t send_reply; 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1357c478bd9Sstevel@tonic-gate } 1367c478bd9Sstevel@tonic-gate #endif 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #endif /* _PING_H */ 139