1: /*
2: mtr -- a network diagnostic tool
3: Copyright (C) 1997,1998 Matt Kimball
4: Copyright (C) 2005 R.E.Wolff@BitWizard.nl
5:
6: This program is free software; you can redistribute it and/or modify
7: it under the terms of the GNU General Public License version 2 as
8: published by the Free Software Foundation.
9:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License along
16: with this program; if not, write to the Free Software Foundation, Inc.,
17: 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18: */
19:
20: #ifndef MTR_MTR_H
21: #define MTR_MTR_H
22:
23: #include "config.h"
24:
25: #include <stdint.h>
26: #include <sys/socket.h>
27: #include <arpa/inet.h>
28:
29: #ifdef HAVE_NETINET_IN_H
30: #include <netinet/in.h>
31: #endif
32:
33: /* Typedefs */
34: #ifdef ENABLE_IPV6
35: typedef struct in6_addr ip_t;
36: #else
37: typedef struct in_addr ip_t;
38: #endif
39:
40: #ifndef HAVE_TIME_T
41: typedef int time_t;
42: #endif
43:
44: /* The __unused__ attribute was added in gcc 3.2.7. */
45: #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
46: #define ATTRIBUTE_UNUSED __attribute__((__unused__))
47: #else
48: #define ATTRIBUTE_UNUSED /* empty */
49: #endif
50:
51: /* The __const__ attribute was added in gcc 2.95. */
52: #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
53: #define ATTRIBUTE_CONST __attribute__ ((__const__))
54: #else
55: #define ATTRIBUTE_CONST /* empty */
56: #endif
57:
58: /* stuff used by display such as report, curses... */
59: #define MAXFLD 20 /* max stats fields to display */
60: #define FLD_INDEX_SZ 256
61:
62: /* net related definitions */
63: #define SAVED_PINGS 200
64: #define MAX_PATH 8
65: #define MaxHost 256
66: #define MinPort 1024
67: #define MaxPort 65535
68: #define MAXPACKET 4470 /* largest test packet size */
69: #define MINPACKET 28 /* 20 bytes IP header and 8 bytes ICMP or UDP */
70: #define MAXLABELS 8 /* http://kb.juniper.net/KB2190 (+ 3 just in case) */
71:
72: /* Stream Control Transmission Protocol is defined in netinet/in.h */
73: #ifdef IPPROTO_SCTP
74: #define HAS_SCTP 1
75: #endif
76:
77: #ifndef HAVE_SOCKLEN_T
78: typedef int socklen_t;
79: #endif
80:
81: struct mtr_ctl {
82: int MaxPing;
83: float WaitTime;
84: float GraceTime;
85: char *Hostname;
86: char *InterfaceName;
87: char *InterfaceAddress;
88: char LocalHostname[128];
89: int ipinfo_no;
90: int ipinfo_max;
91: int cpacketsize; /* packet size used by ping */
92: int bitpattern; /* packet bit pattern used by ping */
93: int tos; /* type of service set in ping packet */
94: #ifdef SO_MARK
95: uint32_t mark;
96: #endif
97: ip_t unspec_addr;
98: int af; /* address family of remote target */
99: int mtrtype; /* type of query packet used */
100: int fstTTL; /* initial hub(ttl) to ping byMin */
101: int maxTTL; /* last hub to ping byMin */
102: int maxUnknown; /* stop ping threshold */
103: int remoteport; /* target port for TCP tracing */
104: int localport; /* source port for UDP tracing */
105: int probe_timeout; /* timeout for probe sockets */
106: unsigned char fld_active[2 * MAXFLD]; /* SO_MARK to set for ping packet */
107: int display_mode; /* display mode selector */
108: int fld_index[FLD_INDEX_SZ]; /* default display field (defined by key in net.h) and order */
109: char available_options[MAXFLD];
110: int display_offset; /* only used in text mode */
111: void *gtk_data; /* pointer to hold arbitrary gtk data */
112: unsigned int /* bit field to hold named booleans */
113: ForceMaxPing:1,
114: use_dns:1,
115: show_ips:1,
116: enablempls:1, dns:1, reportwide:1, Interactive:1, DisplayMode:5;
117: };
118:
119: /* dynamic field drawing */
120: struct fields {
121: const unsigned char key;
122: const char *descr;
123: const char *title;
124: const char *format;
125: const int length;
126: int (
127: *net_xxx) (
128: int);
129: };
130: /* defined in mtr.c */
131: extern const struct fields data_fields[MAXFLD];
132:
133: /* MPLS label object */
134: struct mplslen {
135: unsigned long label[MAXLABELS]; /* label value */
136: uint8_t tc[MAXLABELS]; /* Traffic Class bits */
137: uint8_t ttl[MAXLABELS]; /* MPLS TTL */
138: char s[MAXLABELS]; /* bottom of stack */
139: char labels; /* how many labels did we get? */
140: };
141:
142:
143: #ifdef USING_CYGWIN
144: #define running_as_root() 1
145: #else
146: #define running_as_root() (getuid() == 0)
147: #endif
148:
149: #endif /* MTR_MTR_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>