diff options
author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2004-12-02 08:44:14 (GMT) |
---|---|---|
committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2004-12-02 08:44:14 (GMT) |
commit | 3c925e8c0c01f6b4ae966183af19d22b46046785 (patch) | |
tree | 2a691570510e28c8cb1f48cb4fcac41ec1204cd8 /plugins/linux.h | |
parent | 0eb4526bdaf714dea03af28dde5f4d8e5aea5722 (diff) | |
download | monitoring-plugins-3c925e8c0c01f6b4ae966183af19d22b46046785.tar.gz |
For check_icmp plugin from A Ericsson
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@974 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/linux.h')
-rw-r--r-- | plugins/linux.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/plugins/linux.h b/plugins/linux.h new file mode 100644 index 0000000..3b39d32 --- /dev/null +++ b/plugins/linux.h | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * Special compatibility definitions for linux. | ||
3 | * | ||
4 | * On the linux platform, several IP-related structures have | ||
5 | * different names. Also some of the structure fields have | ||
6 | * other names, although the layout is (obviously) fixed. | ||
7 | * Several constants are not defined in the standard files. | ||
8 | * | ||
9 | * @(#)linux.h e07@nikhef.nl (Eric Wassenaar) 960301 | ||
10 | * | ||
11 | * XXX [src] - This is a complete ripoff from the fping program | ||
12 | */ | ||
13 | |||
14 | #if defined(linux) | ||
15 | |||
16 | #include <endian.h> /* to get the proper BYTE_ORDER */ | ||
17 | |||
18 | #if !defined(BYTE_ORDER) || (BYTE_ORDER != BIG_ENDIAN && \ | ||
19 | BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != PDP_ENDIAN) | ||
20 | error "Undefined or invalid BYTE_ORDER"; | ||
21 | #endif | ||
22 | |||
23 | /* | ||
24 | * Structure of an ip header, without options. | ||
25 | */ | ||
26 | |||
27 | #define IPVERSION 4 | ||
28 | |||
29 | struct ip { | ||
30 | #if (BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN) | ||
31 | u_char ip_hl:4, /* header length */ | ||
32 | ip_v:4; /* version */ | ||
33 | #else | ||
34 | u_char ip_v:4, /* version */ | ||
35 | ip_hl:4; /* header length */ | ||
36 | #endif | ||
37 | u_char ip_tos; /* type of service */ | ||
38 | short ip_len; /* total length */ | ||
39 | u_short ip_id; /* identification */ | ||
40 | short ip_off; /* fragment offset field */ | ||
41 | #define IP_DF 0x4000 /* dont fragment flag */ | ||
42 | #define IP_MF 0x2000 /* more fragments flag */ | ||
43 | u_char ip_ttl; /* time to live */ | ||
44 | u_char ip_p; /* protocol */ | ||
45 | u_short ip_sum; /* checksum */ | ||
46 | struct in_addr ip_src, ip_dst; /* source and dest address */ | ||
47 | }; | ||
48 | |||
49 | #define IP_MAXPACKET 65535 /* maximum packet size */ | ||
50 | |||
51 | /* | ||
52 | * Structure of an icmp header. | ||
53 | */ | ||
54 | |||
55 | struct icmp { | ||
56 | u_char icmp_type; /* type of message, see below */ | ||
57 | u_char icmp_code; /* type sub code */ | ||
58 | u_short icmp_cksum; /* ones complement cksum of struct */ | ||
59 | union { | ||
60 | u_char ih_pptr; /* ICMP_PARAMPROB */ | ||
61 | struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ | ||
62 | struct ih_idseq { | ||
63 | n_short icd_id; | ||
64 | n_short icd_seq; | ||
65 | } ih_idseq; | ||
66 | int ih_void; | ||
67 | } icmp_hun; | ||
68 | #define icmp_pptr icmp_hun.ih_pptr | ||
69 | #define icmp_gwaddr icmp_hun.ih_gwaddr | ||
70 | #define icmp_id icmp_hun.ih_idseq.icd_id | ||
71 | #define icmp_seq icmp_hun.ih_idseq.icd_seq | ||
72 | #define icmp_void icmp_hun.ih_void | ||
73 | union { | ||
74 | struct id_ts { | ||
75 | n_time its_otime; | ||
76 | n_time its_rtime; | ||
77 | n_time its_ttime; | ||
78 | } id_ts; | ||
79 | struct id_ip { | ||
80 | struct ip idi_ip; | ||
81 | /* options and then 64 bits of data */ | ||
82 | } id_ip; | ||
83 | u_long id_mask; | ||
84 | char id_data[1]; | ||
85 | } icmp_dun; | ||
86 | #define icmp_otime icmp_dun.id_ts.its_otime | ||
87 | #define icmp_rtime icmp_dun.id_ts.its_rtime | ||
88 | #define icmp_ttime icmp_dun.id_ts.its_ttime | ||
89 | #define icmp_ip icmp_dun.id_ip.idi_ip | ||
90 | #define icmp_mask icmp_dun.id_mask | ||
91 | #define icmp_data icmp_dun.id_data | ||
92 | }; | ||
93 | |||
94 | #define ICMP_MINLEN 8 /* abs minimum */ | ||
95 | |||
96 | /* | ||
97 | * Definition of icmp type and code field values. | ||
98 | */ | ||
99 | |||
100 | #define ICMP_ECHOREPLY 0 /* echo reply */ | ||
101 | #define ICMP_UNREACH 3 /* dest unreachable, codes: */ | ||
102 | #define ICMP_UNREACH_NET 0 /* bad net */ | ||
103 | #define ICMP_UNREACH_HOST 1 /* bad host */ | ||
104 | #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ | ||
105 | #define ICMP_UNREACH_PORT 3 /* bad port */ | ||
106 | #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ | ||
107 | #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ | ||
108 | #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ | ||
109 | #define ICMP_REDIRECT 5 /* shorter route, codes: */ | ||
110 | #define ICMP_REDIRECT_NET 0 /* for network */ | ||
111 | #define ICMP_REDIRECT_HOST 1 /* for host */ | ||
112 | #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ | ||
113 | #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ | ||
114 | #define ICMP_ECHO 8 /* echo service */ | ||
115 | #define ICMP_TIMXCEED 11 /* time exceeded, codes: */ | ||
116 | #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ | ||
117 | #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ | ||
118 | #define ICMP_PARAMPROB 12 /* ip header bad */ | ||
119 | #define ICMP_TSTAMP 13 /* timestamp request */ | ||
120 | #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ | ||
121 | #define ICMP_IREQ 15 /* information request */ | ||
122 | #define ICMP_IREQREPLY 16 /* information reply */ | ||
123 | #define ICMP_MASKREQ 17 /* address mask request */ | ||
124 | #define ICMP_MASKREPLY 18 /* address mask reply */ | ||
125 | |||
126 | /* | ||
127 | * Definitions needed for the udp header structure. | ||
128 | */ | ||
129 | |||
130 | #define uh_sport source | ||
131 | #define uh_dport dest | ||
132 | #define uh_ulen len | ||
133 | #define uh_sum check | ||
134 | |||
135 | #endif /* linux */ | ||