summaryrefslogtreecommitdiffstats
path: root/sys/netatm/port.h
blob: a9daf4b64a64067c83e41e6add91ba0b017f647e (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
/*
 *
 * ===================================
 * HARP  |  Host ATM Research Platform
 * ===================================
 *
 *
 * This Host ATM Research Platform ("HARP") file (the "Software") is
 * made available by Network Computing Services, Inc. ("NetworkCS")
 * "AS IS".  NetworkCS does not provide maintenance, improvements or
 * support of any kind.
 *
 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
 * In no event shall NetworkCS be responsible for any damages, including
 * but not limited to consequential damages, arising from or relating to
 * any use of the Software or related support.
 *
 * Copyright 1994-1998 Network Computing Services, Inc.
 *
 * Copies of this Software may be made, however, the above copyright
 * notice must be reproduced on all copies.
 *
 *	@(#) $FreeBSD$
 *
 */

/*
 * System Configuration
 * --------------------
 *
 * Porting aides
 *
 */

#ifndef _NETATM_PORT_H
#define	_NETATM_PORT_H

/*
 * Try to ensure that this system is supported
 */
#if (defined(BSD) && (BSD >= 199103))

	/* 4.3 BSD Net2 based */

#elif defined(sun)

	/* SunOS4.x */

#else

	/* Ooops */
	#error "Undefined/unsupported system type"

#endif


/*
 * Kernel memory management
 *
 * KM_ALLOC(size, type, flags)
 *			Returns an allocated kernel memory chunk of size bytes.
 * KM_FREE(addr, size, type)
 *			Free a kernel memory chunk of size bytes.
 * KM_CMP(b1, b2, len)
 *			Compares len bytes of data from b1 against b2.
 * KM_COPY(from, to, len)
 *			Copies len bytes of data from from to to.
 * KM_ZERO(addr, len)
 *			Zeros len bytes of data from addr.
 *
 */
#ifdef _KERNEL
#if (defined(BSD) && (BSD >= 199103))
#include <sys/malloc.h>
#define	KM_ALLOC(size, type, flags)	malloc((size), (type), (flags))
#define	KM_FREE(addr, size, type)	free((addr), (type))
#elif defined(sun)
#include <sys/kmem_alloc.h>
#define	KM_ALLOC(size, type, flags)	kmem_alloc(size)
#define	KM_FREE(addr, size, type)	kmem_free((addr), (size))
#endif

#if defined(BSD)
#define	KM_CMP(b1, b2, len)		bcmp((void *)(b1), (void *)(b2),\
						(len))
#define	KM_COPY(from, to, len)		bcopy((const void *)(from), (void *)(to),\
						(len))
#define	KM_ZERO(addr, len)		bzero((void *)(addr), (len))
#endif
#define	XM_COPY(f, t, l)	KM_COPY((f), (t), (l))

#else

/*
 * User-space memory management
 *
 * UM_ALLOC(size)	Returns an allocated kernel memory chunk of size bytes.
 * UM_FREE(addr)	Free a kernel memory chunk of size bytes.
 * UM_COPY(from, to, len)
 *			Copies len bytes of data from from to to.
 * UM_ZERO(addr, len)	Zeros len bytes of data from addr.
 *
 */
#if (defined(BSD) && (BSD >= 199103))
#define	UM_ALLOC(size)		malloc((size_t)(size))
#define	UM_FREE(addr)		free((void *)(addr))
#define	UM_COPY(from, to, len)	bcopy((void *)(from), (void *)(to),\
						(size_t)(len))
#define	UM_ZERO(addr, len)	bzero((void *)(addr), (size_t)(len))
#elif defined(sun)
#define	UM_ALLOC(size)		malloc(size)
#define	UM_FREE(addr)		free((char *)(addr))
#define	UM_COPY(from, to, len)	bcopy((char *)(from), (char *)(to), (len))
#define	UM_ZERO(addr, len)	bzero((char *)(addr), (len))

#endif
#define	XM_COPY(f, t, l)	UM_COPY((f), (t), (l))

#endif	/* _KERNEL */


#ifdef _KERNEL
/*
 * Kernel buffers
 *
 * KBuffer 		Typedef for a kernel buffer.
 *
 * KB_NEXT(bfr)		Access next buffer in chain (r/w).
 * KB_LEN(bfr)		Access length of data in this buffer (r/w).
 * KB_QNEXT(bfr)	Access next buffer in queue (r/w).
 *
 * KB_ALLOC(bfr, size, flags, type)
 *			Allocates a new kernel buffer of at least size bytes.
 * KB_ALLOCPKT(bfr, size, flags, type)
 *			Allocates a new kernel packet header buffer of at
 *			least size bytes.
 * KB_ALLOCEXT(bfr, size, flags, type)
 *			Allocates a new kernel buffer with external storage
 *			of at least size bytes.
 * KB_FREEONE(bfr, nxt)	Free buffer bfr and set next buffer in chain in nxt.
 * KB_FREEALL(bfr)	Free bfr's entire buffer chain.
 * KB_COPY(bfr, off, len, new, flags)
 *			Copy len bytes of user data from buffer bfr starting at
 *			byte offset off and return new buffer chain in new.
 *			If len is KB_COPYALL, copy until end of chain.
 * KB_COPYDATA(bfr, off, len, datap)
 *			Copy data from buffer bfr starting at byte offset off
 *			for len bytes into the data area pointed to by datap.
 *			Returns the number of bytes not copied to datap.
 * KB_PULLUP(bfr, n, new)
 *			Get at least the first n bytes of data in the buffer 
 *			chain headed by bfr contiguous in the first buffer.
 *			Returns the (potentially new) head of the chain in new.
 *			On failure the chain is freed and NULL is returned.
 * KB_LINKHEAD(new, head)
 *			Link the kernel buffer new at the head of the buffer
 *			chain headed by head.  If both new and head are
 *			packet header buffers, new will become the packet
 *			header for the chain.
 * KB_LINK(new, prev)
 *			Link the kernel buffer new into the buffer chain
 *			after the buffer prev.
 * KB_UNLINKHEAD(head, next)
 *			Unlink the kernel buffer from the head of the buffer
 *			chain headed by head.  The buffer head will be freed
 *			and the new chain head will be placed in next.
 * KB_UNLINK(old, prev, next)
 *			Unlink the kernel buffer old with previous buffer prev
 *			from its buffer chain.  The following buffer in the
 *			chain will be placed in next and the buffer old will
 *			be freed.
 * KB_ISPKT(bfr)	Tests whether bfr is a packet header buffer.
 * KB_ISEXT(bfr)	Tests whether bfr has external storage.
 * KB_BFRSTART(bfr, x, t)
 *			Sets x (cast to type t) to point to the start of the
 *			buffer space in bfr.
 * KB_BFREND(bfr, x, t)
 *			Sets x (cast to type t) to point one byte past the end
 *			of the buffer space in bfr.
 * KB_BFRLEN(bfr)	Returns length of buffer space in bfr.
 * KB_DATASTART(bfr, x, t)
 *			Sets x (cast to type t) to point to the start of the
 *			buffer data contained in bfr.
 * KB_DATAEND(bfr, x, t)
 *			Sets x (cast to type t) to point one byte past the end
 *			of the buffer data contained in bfr.
 * KB_HEADSET(bfr, n)	Sets the start address for buffer data in buffer bfr to
 *			n bytes from the beginning of the buffer space.
 * KB_HEADMOVE(bfr, n) 	Adjust buffer data controls to move data down (n > 0) 
 *			or up (n < 0) n bytes in the buffer bfr.
 * KB_HEADADJ(bfr, n) 	Adjust buffer data controls to add (n > 0) or subtract
 *			(n < 0) n bytes of data to/from the beginning of bfr.
 * KB_TAILADJ(bfr, n)	Adjust buffer data controls to add (n > 0) or subtract
 *			(n < 0) n bytes of data to/from the end of bfr.
 * KB_TAILALIGN(bfr, n)	Set buffer data controls to place an object of size n
 *			at the end of bfr, longword aligned.
 * KB_HEADROOM(bfr, n)	Set n to the amount of buffer space available before
 *			the start of data in bfr.
 * KB_TAILROOM(bfr, n)	Set n to the amount of buffer space available after
 *			the end of data in bfr.
 * KB_PLENGET(bfr, n)	Set n to bfr's packet length.
 * KB_PLENSET(bfr, n)	Set bfr's packet length to n.
 * KB_PLENADJ(bfr, n)	Adjust total packet length by n bytes.
 *
 */
#if defined(BSD)
#include <sys/mbuf.h>
typedef struct mbuf	KBuffer;

#define	KB_F_WAIT	M_TRYWAIT
#define	KB_F_NOWAIT	M_DONTWAIT

#define	KB_T_HEADER	MT_HEADER
#define	KB_T_DATA	MT_DATA

#define	KB_COPYALL	M_COPYALL

#if BSD >= 199103

#define	KB_NEXT(bfr)		(bfr)->m_next
#define	KB_LEN(bfr)		(bfr)->m_len
#define	KB_QNEXT(bfr)		(bfr)->m_nextpkt
#define KB_ALLOC(bfr, size, flags, type) {		\
	if ((size) <= MLEN) {				\
		MGET((bfr), (flags), (type));		\
	} else						\
		(bfr) = NULL;				\
}
#define KB_ALLOCPKT(bfr, size, flags, type) {		\
	if ((size) <= MHLEN) {				\
		MGETHDR((bfr), (flags), (type));	\
	} else						\
		(bfr) = NULL;				\
}
#define KB_ALLOCEXT(bfr, size, flags, type) {		\
	if ((size) <= MCLBYTES)	{			\
		MGET((bfr), (flags), (type));		\
		if ((bfr) != NULL) {			\
			MCLGET((bfr), (flags));		\
			if (((bfr)->m_flags & M_EXT) == 0) {	\
				m_freem((bfr));		\
				(bfr) = NULL;		\
			}				\
		}					\
	} else						\
		(bfr) = NULL;				\
}
#define KB_FREEONE(bfr, nxt) {				\
	(nxt) = m_free(bfr);				\
}
#define KB_FREEALL(bfr) {				\
	m_freem(bfr);					\
}
#define	KB_COPY(bfr, off, len, new, flags) {		\
	(new) = m_copym((bfr), (off), (len), (flags));	\
}
#define	KB_COPYDATA(bfr, off, len, datap) 		\
	(m_copydata((bfr), (off), (len), (datap)), 0)
#define	KB_PULLUP(bfr, n, new) {			\
	(new) = m_pullup((bfr), (n));			\
}
#define	KB_LINKHEAD(new, head) {			\
	if ((head) && KB_ISPKT(new) && KB_ISPKT(head)) {\
		M_COPY_PKTHDR((new), (head));		\
		(head)->m_flags &= ~M_PKTHDR;		\
	}						\
	(new)->m_next = (head);				\
}
#define	KB_LINK(new, prev) {				\
	(new)->m_next = (prev)->m_next;			\
	(prev)->m_next = (new);				\
}
#define	KB_UNLINKHEAD(head, next) {			\
	(next) = m_free((head));			\
	(head) = NULL;					\
}
#define	KB_UNLINK(old, prev, next) {			\
	(next) = m_free((old));				\
	(old) = NULL;					\
	(prev)->m_next = (next);			\
}
#define	KB_ISPKT(bfr)		(((bfr)->m_flags & M_PKTHDR) != 0)
#define	KB_ISEXT(bfr)		(((bfr)->m_flags & M_EXT) != 0)
#define	KB_BFRSTART(bfr, x, t) {			\
	if ((bfr)->m_flags & M_EXT)			\
		(x) = (t)((bfr)->m_ext.ext_buf);	\
	else if ((bfr)->m_flags & M_PKTHDR)		\
		(x) = (t)(&(bfr)->m_pktdat);		\
	else						\
		(x) = (t)((bfr)->m_dat);		\
}
#define	KB_BFREND(bfr, x, t) {				\
	if ((bfr)->m_flags & M_EXT)			\
		(x) = (t)((bfr)->m_ext.ext_buf + (bfr)->m_ext.ext_size);\
	else if ((bfr)->m_flags & M_PKTHDR)		\
		(x) = (t)(&(bfr)->m_pktdat + MHLEN);	\
	else						\
		(x) = (t)((bfr)->m_dat + MLEN);		\
}
#define	KB_BFRLEN(bfr)					\
	(((bfr)->m_flags & M_EXT) ? (bfr)->m_ext.ext_size :	\
		(((bfr)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
#define	KB_DATASTART(bfr, x, t) {			\
	(x) = mtod((bfr), t);				\
}
#define	KB_DATAEND(bfr, x, t) {				\
	(x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len);	\
}
#define	KB_HEADSET(bfr, n) {				\
	if ((bfr)->m_flags & M_EXT)			\
		(bfr)->m_data = (bfr)->m_ext.ext_buf + (n);	\
	else if ((bfr)->m_flags & M_PKTHDR)		\
		(bfr)->m_data = (bfr)->m_pktdat + (n);	\
	else						\
		(bfr)->m_data = (bfr)->m_dat + (n);	\
}
#define	KB_HEADMOVE(bfr, n) {				\
	(bfr)->m_data += (n);				\
}
#define	KB_HEADADJ(bfr, n) {				\
	(bfr)->m_len += (n);				\
	(bfr)->m_data -= (n);				\
}
#define	KB_TAILADJ(bfr, n) {				\
	(bfr)->m_len += (n);				\
}
#define	KB_TAILALIGN(bfr, n) {				\
	(bfr)->m_len = (n);				\
	if ((bfr)->m_flags & M_EXT)			\
		(bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_ext.ext_buf	\
			+ (bfr)->m_ext.ext_size - (n)) & ~(sizeof(long) - 1));\
	else						\
		(bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_dat + MLEN - (n)) \
			& ~(sizeof(long) - 1));		\
}
#define	KB_HEADROOM(bfr, n) {				\
	/* n = M_LEADINGSPACE(bfr) XXX */		\
	(n) = ((bfr)->m_flags & M_EXT ? (bfr)->m_data - (bfr)->m_ext.ext_buf : \
		(bfr)->m_flags & M_PKTHDR ? (bfr)->m_data - (bfr)->m_pktdat : \
			(bfr)->m_data - (bfr)->m_dat);	\
}
#define	KB_TAILROOM(bfr, n) {				\
	(n) = M_TRAILINGSPACE(bfr);			\
}
#define	KB_PLENGET(bfr, n) {				\
	(n) = (bfr)->m_pkthdr.len;			\
}
#define	KB_PLENSET(bfr, n) {				\
	(bfr)->m_pkthdr.len = (n);			\
}
#define	KB_PLENADJ(bfr, n) {				\
	(bfr)->m_pkthdr.len += (n);			\
}


#else	/* ! BSD >= 199103 */


#define	KB_NEXT(bfr)		(bfr)->m_next
#define	KB_LEN(bfr)		(bfr)->m_len
#define	KB_QNEXT(bfr)		(bfr)->m_act
#define KB_ALLOC(bfr, size, flags, type) {		\
	if ((size) <= MLEN) {				\
		MGET((bfr), (flags), (type));		\
	} else						\
		(bfr) = NULL;				\
}
#define KB_ALLOCPKT(bfr, size, flags, type) {		\
	if ((size) <= MLEN) {				\
		MGET((bfr), (flags), (type));		\
	} else						\
		(bfr) = NULL;				\
}
#define KB_ALLOCEXT(bfr, size, flags, type) {		\
	if ((size) <= MCLBYTES)	{			\
		MGET((bfr), (flags), (type));		\
		if ((bfr) != NULL) {			\
			MCLGET(bfr);			\
			if ((bfr)->m_len != MCLBYTES) {	\
				m_freem((bfr));		\
				(bfr) = NULL;		\
			}				\
		}					\
	} else						\
		(bfr) = NULL;				\
}
#define KB_FREEONE(bfr, nxt) {				\
	(nxt) = m_free(bfr);				\
}
#define KB_FREEALL(bfr) {				\
	m_freem(bfr);					\
}
#define	KB_COPY(bfr, off, len, new, flags) {		\
	(new) = m_copy((bfr), (off), (len));		\
}
#define	KB_COPYDATA(bfr, off, len, datap) 		\
	m_cpytoc((bfr), (off), (len), (datap))
#define	KB_PULLUP(bfr, n, new) {			\
	(new) = m_pullup((bfr), (n));			\
}
#define	KB_LINKHEAD(new, head) {			\
	(new)->m_next = (head);				\
}
#define	KB_LINK(new, prev) {				\
	(new)->m_next = (prev)->m_next;			\
	(prev)->m_next = (new);				\
}
#define	KB_UNLINKHEAD(head, next) {			\
	(next) = m_free((head));			\
	(head) = NULL;					\
}
#define	KB_UNLINK(old, prev, next) {			\
	(next) = m_free((old));				\
	(old) = NULL;					\
	(prev)->m_next = (next);			\
}
#define	KB_ISPKT(bfr)		(0)
#define	KB_ISEXT(bfr)		M_HASCL(bfr)
#define	KB_BFRSTART(bfr, x, t) {			\
	if (M_HASCL(bfr)) {				\
		if ((bfr)->m_cltype == MCL_STATIC)	\
			(x) = (t)(mtod((bfr), int) & ~(MCLBYTES - 1));	\
		else					\
			(x) = (t)NULL;			\
	} else						\
		(x) = (t)((bfr)->m_dat);		\
}
#define	KB_BFREND(bfr, x, t) {				\
	if (M_HASCL(bfr)) {				\
		if ((bfr)->m_cltype == MCL_STATIC)	\
			(x) = (t)((mtod((bfr), int) & ~(MCLBYTES - 1))	\
				+ MCLBYTES);		\
		else					\
			(x) = (t)NULL;			\
	} else						\
		(x) = (t)((bfr)->m_dat + MLEN);		\
}
#define	KB_BFRLEN(bfr)					\
	(M_HASCL(bfr) ? (((bfr)->m_cltype == MCL_STATIC) ? MCLBYTES : 0) : MLEN)
#define	KB_DATASTART(bfr, x, t) {			\
	(x) = mtod((bfr), t);				\
}
#define	KB_DATAEND(bfr, x, t) {				\
	(x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len);	\
}
#define	KB_HEADSET(bfr, n) {				\
	if (M_HASCL(bfr)) {				\
		/* Assume cluster buffer is empty XXX */\
		(bfr)->m_off += (n);			\
	} else						\
		(bfr)->m_off = MMINOFF + (n);		\
}
#define	KB_HEADMOVE(bfr, n) {				\
	(bfr)->m_off += (n);				\
}
#define	KB_HEADADJ(bfr, n) {				\
	(bfr)->m_len += (n);				\
	(bfr)->m_off -= (n);				\
}
#define	KB_TAILADJ(bfr, n) {				\
	(bfr)->m_len += (n);				\
}
#define	KB_TAILALIGN(bfr, n) {				\
	(bfr)->m_len = (n);				\
	if (M_HASCL(bfr)) {				\
		if ((bfr)->m_cltype == MCL_STATIC)	\
			(bfr)->m_off = (int)(((mtod((bfr), int)		\
				& ~(MCLBYTES - 1)) + MCLBYTES - (n))	\
				& ~(sizeof(long) - 1)) - (int)(bfr);	\
		/* Out of luck for loaned buffers */	\
	} else						\
		(bfr)->m_off = (MMAXOFF - (n))	& ~(sizeof(long) - 1);	\
}
#define	KB_HEADROOM(bfr, n) {				\
	if (M_HASCL(bfr)) {				\
		if ((bfr)->m_cltype == MCL_STATIC)	\
			(n) = mtod((bfr), int) & (MCLBYTES - 1);	\
		else					\
			(n) = 0;			\
	} else						\
		(n) = (bfr)->m_off - MMINOFF;		\
}
#define	KB_TAILROOM(bfr, n) {				\
	if (M_HASCL(bfr)) {				\
		if ((bfr)->m_cltype == MCL_STATIC)	\
			(n) = MCLBYTES - ((mtod((bfr), int) + (bfr)->m_len) \
				& (MCLBYTES - 1));	\
		else					\
			(n) = 0;			\
	} else						\
		(n) = MMAXOFF - ((bfr)->m_off + (bfr)->m_len);	\
}
#define	KB_PLENGET(bfr, n) {				\
	struct mbuf	*zz;				\
	for ((n) = 0, zz = (bfr); zz; zz = zz->m_next)	\
		(n) += zz->m_len;			\
}
#define	KB_PLENSET(bfr, n) {				\
}
#define	KB_PLENADJ(bfr, n) {				\
}


#endif	/* ! BSD >= 199103 */

#endif	/* defined(BSD) */


/*
 * Kernel time
 *
 * KTimeout_ret		Typedef for timeout() function return
 *
 * KT_TIME(t)		Sets t to the current time.
 *
 */
#if (defined(BSD) && (BSD >= 199306))
typedef void	KTimeout_ret;
#else
typedef int	KTimeout_ret;
#endif
#if (defined(BSD) && (BSD >= 199103))
#define	KT_TIME(t)	microtime(&t)
#elif defined(sun)
#define	KT_TIME(t)	uniqtime(&t)
#else
#define	KT_TIME(t)	((t) = time)
#endif

#endif	/* _KERNEL */

#ifndef NTOHL
#if BYTE_ORDER == BIG_ENDIAN
#define	NTOHL(x)	(x)
#define	NTOHS(x)	(x)
#define	HTONL(x)	(x)
#define	HTONS(x)	(x)
#else
#define	NTOHL(x)	(x) = ntohl((u_long)(x))
#define	NTOHS(x)	(x) = ntohs((u_short)(x))
#define	HTONL(x)	(x) = htonl((u_long)(x))
#define	HTONS(x)	(x) = htons((u_short)(x))
#endif
#endif	/* NTOHL */

#ifndef MAX
#define	MAX(a,b)	max((a),(b))
#endif
#ifndef MIN
#define	MIN(a,b)	min((a),(b))
#endif

#if (!(defined(BSD) && (BSD >= 199306)))
#ifndef __BIT_TYPES_DEFINED__
#define	__BIT_TYPES_DEFINED__
typedef	char		int8_t;
typedef	unsigned char	u_int8_t;
typedef	short		int16_t;
typedef	unsigned short	u_int16_t;
typedef	int		int32_t;
typedef	unsigned int	u_int32_t;
#endif
#endif

#endif	/* _NETATM_PORT_H */
OpenPOWER on IntegriCloud