1 /*
2  * Argus Software
3  * Copyright (c) 2000-2016 QoSient, LLC
4  * All rights reserved.
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 as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21 
22 /*
23  * Copyright (c) 1993, 1994 Carnegie Mellon University.
24  * All rights reserved.
25  *
26  * Permission to use, copy, modify, and distribute this software and
27  * its documentation for any purpose and without fee is hereby granted,
28  * provided that the above copyright notice appear in all copies and
29  * that both that copyright notice and this permission notice appear
30  * in supporting documentation, and that the name of CMU not be
31  * used in advertising or publicity pertaining to distribution of the
32  * software without specific, written prior permission.
33  *
34  * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
35  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
36  * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
37  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
38  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
39  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
40  * SOFTWARE.
41  *
42  */
43 
44 /*
45  * $Id: //depot/argus/clients/include/argus_compat.h#12 $
46  * $DateTime: 2016/06/01 15:17:28 $
47  * $Change: 3148 $
48  */
49 
50 #if !defined(Argus_compat_h)
51 #define Argus_compat_h
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #include "argus_config.h"
58 
59 #if defined(HAVE_SYS_TYPES_H)
60 #include <sys/types.h>
61 #endif
62 
63 #if defined(HAVE_SYS_WAIT_H)
64 #include <sys/wait.h>
65 #endif
66 
67 #define argtimeval timeval
68 
69 #include <string.h>
70 
71 #if defined(ARGUS_SOLARIS)
72 #include <strings.h>
73 #include <sys/byteorder.h>
74 #endif
75 
76 #if defined(linux)
77 #include <endian.h>
78 #define __FAVOR_BSD
79 #endif
80 
81 #if defined(CYGWIN)
82 #define _LITTLE_ENDIAN
83 #define USE_IPV6
84 #else
85 
86 #if defined(ARGUS_SOLARIS)
87 #include <sys/ethernet.h>
88 #else
89 #if defined(__OpenBSD__) && !defined(__APPLE__)
90 #include <net/ethertypes.h>
91 #endif
92 #endif
93 
94 #include <argus_os.h>
95 
96 #if defined(__DragonFly__)
97 #include <sys/endian.h>
98 #ifndef __BYTE_ORDER
99 #define __BYTE_ORDER	_BYTE_ORDER
100 #define __LITTLE_ENDIAN	_LITTLE_ENDIAN
101 #define __BIG_ENDIANG	_BIG_ENDIAN
102 #endif
103 #endif
104 
105 #if defined(__FreeBSD__) && !defined(__DragonFly__)
106 #if defined(BYTE_ORDER)
107 #define __BYTE_ORDER    BYTE_ORDER
108 #endif
109 #if defined(LITTLE_ENDIAN)
110 #define __LITTLE_ENDIAN LITTLE_ENDIAN
111 #endif
112 #if defined(BIG_ENDIAN)
113 #define __BIG_ENDIAN    BIG_ENDIAN
114 #endif
115 #endif
116 
117 #if !defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
118 #if __BYTE_ORDER == __LITTLE_ENDIAN
119 #define _LITTLE_ENDIAN
120 #else
121 #define _BIG_ENDIAN
122 #endif
123 #endif
124 #endif
125 
126 #if !defined(HAVE_STRTOF) && !defined(CYGWIN)
127 //float strtof (char *, char **);
128 #endif
129 
130 #if defined(__sgi__) || defined(ARGUS_SOLARIS) || defined(ultrix) || defined(__osf__) || defined(linux) || defined(bsdi) || defined(AIX) | defined(CYGWIN)
131 
132 #define timelocal mktime
133 
134 #if defined(__sgi__)
135 #include <bstring.h>
136 #include <ulimit.h>
137 
138 #if _MIPS_SZLONG == 64
139 #undef argtimeval
140 #define argtimeval irix5_timeval
141 #endif
142 
143 #undef TCPSTATES
144 #endif
145 
146 #if defined(linux)
147 #include <time.h>
148 #endif
149 
150 #if defined(__sgi) || defined(bsdi)
151 struct ether_addr {
152         u_char  ether_addr_octet[6];
153 };
154 #endif
155 
156 
157 #if defined(AIX)
158 #define _SUN
159 #include <sys/select.h>
160 #include <net/nh.h>
161 #endif
162 #endif
163 
164 #define arg_uint8   u_char
165 #define arg_int8    char
166 #define arg_uint16  u_short
167 #define arg_int16   short
168 
169 #if HOST_BITS_PER_INT == 32
170 #define arg_uint32  u_int
171 #define arg_int32   int
172 #else
173 #define arg_uint32  u_long
174 #define arg_int32   long
175 #endif
176 
177 #if defined(__FreeBSD__)
178 #include <sys/socket.h>
179 #include <netinet/if_ether.h>
180 #endif
181 
182 #if !defined(ICMP_ROUTERADVERT)
183 #define	ICMP_ROUTERADVERT	9	/* router advertisement */
184 #endif
185 
186 #if !defined(ICMP_ROUTERSOLICIT)
187 #define	ICMP_ROUTERSOLICIT	10	/* router solicitation */
188 #endif
189 
190 #if !defined(TCPOPT_WSCALE)
191 #define	TCPOPT_WSCALE		3	/* window scale factor (rfc1072) */
192 #endif
193 #if !defined(TCPOPT_SACKOK)
194 #define	TCPOPT_SACKOK		4	/* selective ack ok (rfc1072) */
195 #endif
196 #if !defined(TCPOPT_SACK)
197 #define	TCPOPT_SACK		5	/* selective ack (rfc1072) */
198 #endif
199 #if !defined(TCPOPT_ECHO)
200 #define	TCPOPT_ECHO		6	/* echo (rfc1072) */
201 #endif
202 #if !defined(TCPOPT_ECHOREPLY)
203 #define	TCPOPT_ECHOREPLY	7	/* echo (rfc1072) */
204 #endif
205 #if !defined(TCPOPT_TIMESTAMP)
206 #define TCPOPT_TIMESTAMP	8	/* timestamps (rfc1323) */
207 #endif
208 #if !defined(TCPOPT_CC)
209 #define TCPOPT_CC		11	/* T/TCP CC options (rfc1644) */
210 #endif
211 #if !defined(TCPOPT_CCNEW)
212 #define TCPOPT_CCNEW		12	/* T/TCP CC options (rfc1644) */
213 #endif
214 #if !defined(TCPOPT_CCECHO)
215 #define TCPOPT_CCECHO		13	/* T/TCP CC options (rfc1644) */
216 #endif
217 
218 #if !defined(ETHERTYPE_SPRITE)
219 #define	ETHERTYPE_SPRITE	0x0500
220 #endif
221 #if !defined(ETHERTYPE_NS)
222 #define ETHERTYPE_NS		0x0600
223 #endif
224 #if !defined(ETHERTYPE_IP)
225 #define ETHERTYPE_IP		0x0800
226 #endif
227 #if !defined(ETHERTYPE_X25L3)
228 #define ETHERTYPE_X25L3		0x0805
229 #endif
230 #if !defined(ETHERTYPE_ARP)
231 #define ETHERTYPE_ARP		0x0806
232 #endif
233 #if !defined(ETHERTYPE_VINES)
234 #define ETHERTYPE_VINES		0x0bad
235 #endif
236 #if !defined(ETHERTYPE_TRAIL)
237 #define ETHERTYPE_TRAIL		0x1000
238 #endif
239 #if !defined(ETHERTYPE_TRAIN)
240 #define ETHERTYPE_TRAIN		0x1984
241 #endif
242 #if !defined(ETHERTYPE_3C_NBP_DGRAM)
243 #define ETHERTYPE_3C_NBP_DGRAM	0x3c07
244 #endif
245 #if !defined(ETHERTYPE_DEC)
246 #define ETHERTYPE_DEC		0x6000
247 #endif
248 #if !defined(ETHERTYPE_MOPDL)
249 #define	ETHERTYPE_MOPDL		0x6001
250 #endif
251 #if !defined(ETHERTYPE_MOPRC)
252 #define	ETHERTYPE_MOPRC		0x6002
253 #endif
254 #if !defined(ETHERTYPE_DN)
255 #define	ETHERTYPE_DN		0x6003
256 #endif
257 #if !defined(ETHERTYPE_LAT)
258 #define ETHERTYPE_LAT		0x6004
259 #endif
260 #if !defined(ETHERTYPE_DEC_DIAG)
261 #define ETHERTYPE_DEC_DIAG	0x6005
262 #endif
263 #if !defined(ETHERTYPE_DEC_CUST)
264 #define ETHERTYPE_DEC_CUST	0x6006
265 #endif
266 #if !defined(ETHERTYPE_SCA)
267 #define ETHERTYPE_SCA		0x6007
268 #endif
269 #if !defined(ETHERTYPE_REVARP)
270 #define ETHERTYPE_REVARP	0x8035
271 #endif
272 #if !defined(ETHERTYPE_LANBRIDGE)
273 #define	ETHERTYPE_LANBRIDGE	0x8038
274 #endif
275 #if !defined(ETHERTYPE_DECDNS)
276 #define	ETHERTYPE_DECDNS	0x803c
277 #endif
278 #if !defined(ETHERTYPE_DECDTS)
279 #define	ETHERTYPE_DECDTS	0x803e
280 #endif
281 #if !defined(ETHERTYPE_VEXP)
282 #define	ETHERTYPE_VEXP		0x805b
283 #endif
284 #if !defined(ETHERTYPE_VPROD)
285 #define	ETHERTYPE_VPROD		0x805c
286 #endif
287 #if !defined(ETHERTYPE_ATALK)
288 #define ETHERTYPE_ATALK		0x809b
289 #endif
290 #if !defined(ETHERTYPE_AARP)
291 #define ETHERTYPE_AARP		0x80f3
292 #endif
293 #if !defined(ETHERTYPE_8021Q)
294 #define	ETHERTYPE_8021Q		0x8100
295 #endif
296 #if !defined(ETHERTYPE_IPX)
297 #define ETHERTYPE_IPX		0x8137
298 #endif
299 #if !defined(ETHERTYPE_SNMP)
300 #define ETHERTYPE_SNMP		0x814c
301 #endif
302 #if !defined(ETHERTYPE_IPV6)
303 #define ETHERTYPE_IPV6		0x86dd
304 #endif
305 #if !defined(ETHERTYPE_MPLS)
306 #define ETHERTYPE_MPLS		0x8847
307 #endif
308 #if !defined(ETHERTYPE_MPLS_MULTI)
309 #define ETHERTYPE_MPLS_MULTI	0x8848
310 #endif
311 #if !defined(ETHERTYPE_PPPOED)
312 #define ETHERTYPE_PPPOED	0x8863
313 #endif
314 #if !defined(ETHERTYPE_PPPOES)
315 #define ETHERTYPE_PPPOES	0x8864
316 #endif
317 #if !defined(ETHERTYPE_LOOPBACK)
318 #define	ETHERTYPE_LOOPBACK	0x9000
319 #endif
320 
321 #ifdef __cplusplus
322 }
323 #endif
324 #endif /* Argus_compat_h */
325