xref: /haiku/src/bin/network/ping/main.h (revision 3bf4cdb73bb197b51310633f7abb72aecaf695ad)
1*3bf4cdb7SJérôme Duval /*-
2*3bf4cdb7SJérôme Duval  * SPDX-License-Identifier: BSD-2-Clause
3*3bf4cdb7SJérôme Duval  *
4*3bf4cdb7SJérôme Duval  * Copyright (C) 2019 Jan Sucan <jansucan@FreeBSD.org>
5*3bf4cdb7SJérôme Duval  * All rights reserved.
6*3bf4cdb7SJérôme Duval  *
7*3bf4cdb7SJérôme Duval  * Redistribution and use in source and binary forms, with or without
8*3bf4cdb7SJérôme Duval  * modification, are permitted provided that the following conditions
9*3bf4cdb7SJérôme Duval  * are met:
10*3bf4cdb7SJérôme Duval  * 1. Redistributions of source code must retain the above copyright
11*3bf4cdb7SJérôme Duval  *    notice, this list of conditions and the following disclaimer.
12*3bf4cdb7SJérôme Duval  * 2. Redistributions in binary form must reproduce the above copyright
13*3bf4cdb7SJérôme Duval  *    notice, this list of conditions and the following disclaimer in the
14*3bf4cdb7SJérôme Duval  *    documentation and/or other materials provided with the distribution.
15*3bf4cdb7SJérôme Duval  *
16*3bf4cdb7SJérôme Duval  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*3bf4cdb7SJérôme Duval  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*3bf4cdb7SJérôme Duval  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*3bf4cdb7SJérôme Duval  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*3bf4cdb7SJérôme Duval  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*3bf4cdb7SJérôme Duval  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*3bf4cdb7SJérôme Duval  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*3bf4cdb7SJérôme Duval  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*3bf4cdb7SJérôme Duval  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*3bf4cdb7SJérôme Duval  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*3bf4cdb7SJérôme Duval  * SUCH DAMAGE.
27*3bf4cdb7SJérôme Duval  */
28*3bf4cdb7SJérôme Duval 
29*3bf4cdb7SJérôme Duval #ifndef MAIN_H
30*3bf4cdb7SJérôme Duval #define MAIN_H 1
31*3bf4cdb7SJérôme Duval 
32*3bf4cdb7SJérôme Duval #ifdef IPSEC
33*3bf4cdb7SJérôme Duval #include <netipsec/ipsec.h>
34*3bf4cdb7SJérôme Duval #endif /*IPSEC*/
35*3bf4cdb7SJérôme Duval 
36*3bf4cdb7SJérôme Duval #if defined(INET) && defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
37*3bf4cdb7SJérôme Duval  #define PING4ADDOPTS "P:"
38*3bf4cdb7SJérôme Duval #else
39*3bf4cdb7SJérôme Duval  #define PING4ADDOPTS
40*3bf4cdb7SJérôme Duval #endif
41*3bf4cdb7SJérôme Duval #define PING4OPTS ".::4AaC:c:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:" PING4ADDOPTS
42*3bf4cdb7SJérôme Duval 
43*3bf4cdb7SJérôme Duval #if defined(INET6) && defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
44*3bf4cdb7SJérôme Duval  #define PING6ADDOPTS "P:"
45*3bf4cdb7SJérôme Duval #elif defined(INET6) && defined(IPSEC) && !defined(IPSEC_POLICY_IPSEC)
46*3bf4cdb7SJérôme Duval  #define PING6ADDOPTS "ZE"
47*3bf4cdb7SJérôme Duval #else
48*3bf4cdb7SJérôme Duval  #define PING6ADDOPTS
49*3bf4cdb7SJérôme Duval #endif
50*3bf4cdb7SJérôme Duval #define PING6OPTS ".::6Aab:C:c:Dde:fHI:i:k:l:m:nNoOp:qS:s:t:uvyYW:z:" PING6ADDOPTS
51*3bf4cdb7SJérôme Duval 
52*3bf4cdb7SJérôme Duval /* various options */
53*3bf4cdb7SJérôme Duval extern u_int options;
54*3bf4cdb7SJérôme Duval #define	F_HOSTNAME	0x0004
55*3bf4cdb7SJérôme Duval 
56*3bf4cdb7SJérôme Duval extern char *hostname;
57*3bf4cdb7SJérôme Duval 
58*3bf4cdb7SJérôme Duval /* counters */
59*3bf4cdb7SJérôme Duval extern long nreceived;		/* # of packets we got back */
60*3bf4cdb7SJérôme Duval extern long nrepeats;		/* number of duplicates */
61*3bf4cdb7SJérôme Duval extern long ntransmitted;	/* sequence # for outbound packets = #sent */
62*3bf4cdb7SJérôme Duval extern long nrcvtimeout;	/* # of packets we got back after waittime */
63*3bf4cdb7SJérôme Duval 
64*3bf4cdb7SJérôme Duval /* nonzero if we've been told to finish up */
65*3bf4cdb7SJérôme Duval extern volatile sig_atomic_t seenint;
66*3bf4cdb7SJérôme Duval extern volatile sig_atomic_t seeninfo;
67*3bf4cdb7SJérôme Duval 
68*3bf4cdb7SJérôme Duval /* timing */
69*3bf4cdb7SJérôme Duval extern int timing;		/* flag to do timing */
70*3bf4cdb7SJérôme Duval extern double tmin;		/* minimum round trip time */
71*3bf4cdb7SJérôme Duval extern double tmax;		/* maximum round trip time */
72*3bf4cdb7SJérôme Duval extern double tsum;		/* sum of all times, for doing average */
73*3bf4cdb7SJérôme Duval extern double tsumsq;		/* sum of all times squared, for std. dev. */
74*3bf4cdb7SJérôme Duval 
75*3bf4cdb7SJérôme Duval void onsignal(int);
76*3bf4cdb7SJérôme Duval void pr_summary(FILE * __restrict);
77*3bf4cdb7SJérôme Duval void usage(void) __dead2;
78*3bf4cdb7SJérôme Duval 
79*3bf4cdb7SJérôme Duval #endif
80