-
Notifications
You must be signed in to change notification settings - Fork 0
/
global_as_found.h
155 lines (125 loc) · 3.72 KB
/
global_as_found.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//*****************************************************************************
// FILE: global.h
// derived from WinMTRGlobal.h (WinMTR 0.8)
//
// Copyleft (C) 2000-2002, Vasile Laurentiu Stanimir ( [email protected] )
// Modified 2009, Steve Harvey ([email protected])
//
// DESCRIPTION:
//
//
// NOTES:
//
//
//*****************************************************************************
#ifndef GLOBAL_H_
#define GLOBAL_H_
#define VC_EXTRALEAN
#if defined (linux) || defined(__APPLE__)
typedef unsigned char __int8;
typedef unsigned short __int16;
typedef unsigned int __int32;
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#ifndef BOOL
#define BOOL bool
#define TRUE 1
#define FALSE 0
#endif
#if defined (linux) || defined(__APPLE__)
#include <unistd.h>
#define Sleep(x) usleep((x)*1000)
#include <sys/time.h>
#else
#include <process.h>
#include <io.h>
#endif
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <memory.h>
#include <math.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <sys/stat.h>
#ifdef WIN32
//#pragma comment(lib, "wininet.lib")
#pragma comment(lib, "WS2_32.Lib")
#endif
// exit status codes
#define ES_NORMAL 0 // no errors
#define ES_INCONSIST 1 // traceroute got inconsistent host addrs
#define ES_INITWINSOCK 2 // Win32: unable to initialize WinSock
#define ES_UNKOPTION 3 // unknown command line option
#define ES_RAWSOCK_CANT 4 // can't get raw socket (PreOpen)
#define ES_HOSTNAME_CANT 5 // can't resolve hostname
#define ES_LOCALHOST_CANT 6 // can't resolve localhost
#define ES_RAWSOCK_FAIL 7 // can't get raw socket (Open)
#define ES_SETSOCKOPT_FAIL 8 // setsockopt failed
#define ES_BAD_HOSTNAME 9 // missing or invalid hostname
#define WMTRCMD_VERSION "0.1"
#define WMTRCMD_LICENSE "GPL - GNU Public License"
#define WMTRCMD_ORIG_COPYRIGHT "Copyleft @2000-2002, Vasile Laurentiu Stanimir ([email protected])"
#define WMTRCMD_COPYRIGHT "Copyright 2009 Steve Harvey ([email protected])"
#define DEFAULT_PING_SIZE 64
#define DEFAULT_INTERVAL 1.0
#define DEFAULT_DNS TRUE
#define DEFAULT_MAX_ATT 5
#define SAVED_PINGS 100
#define MaxHost 256 //! maximum+1 number of hops, sizes host table
//#define MaxSequence 65536
#define MaxSequence 32767 //! maximum sequence number for ICMP headers and sizes sequence table
//#define MaxSequence 5
#define MAXPACKET 4096 //! maximum out-going packet size: IPv4 header + ICMP + payload
#define MINPACKET 64 //! minimum out-going packet size: IPv4 header + ICMP + payload
#define MaxTransit 4
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
#define ICMP_TSTAMP 13
#define ICMP_TSTAMPREPLY 14
#define ICMP_TIME_EXCEEDED 11
#define ICMP_HOST_UNREACHABLE 3
#define MAX_UNKNOWN_HOSTS 10
#define IP_HEADER_LENGTH 20
#define MTR_NR_COLS 9
const char MTR_COLS[ MTR_NR_COLS ][10] = {
"Hostname",
"Nr",
"Loss %",
"Sent",
"Recv",
"Best",
"Avrg",
"Worst",
"Last"
};
const int MTR_COL_LENGTH[ MTR_NR_COLS ] = {
190, 30, 50, 40, 40, 50, 50, 50, 50
};
#if defined (linux) || defined(__APPLE__)
// extern "C" {
// int gettimeofday(struct timeval* tv, struct timezone *tz);
// }
typedef int clockid_t;
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC 1
#endif
extern "C" {
int clock_gettime (clockid_t clk_id, struct timespec *tp);
}
#else
// int gettimeofday(struct timeval* tv, struct timezone *tz);
int clock_gettime (clockid_t clk_id, struct timespec *tp);
#endif
#endif // ifndef GLOBAL_H_