Merge from vendor branch LIBPCAP:
[dragonfly.git] / sys / netproto / atm / port.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sys/netatm/port.h,v 1.2.2.2 2003/01/23 21:06:44 sam Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/port.h,v 1.3 2003/07/23 02:30:21 dillon Exp $
28  *
29  */
30
31 /*
32  * System Configuration
33  * --------------------
34  *
35  * Porting aides
36  *
37  */
38
39 #ifndef _NETATM_PORT_H
40 #define _NETATM_PORT_H
41
42 /*
43  * Try to ensure that this system is supported
44  */
45 #if (defined(BSD) && (BSD >= 199103))
46
47         /* 4.3 BSD Net2 based */
48
49 #elif defined(sun)
50
51         /* SunOS4.x */
52
53 #else
54
55         /* Ooops */
56         #error "Undefined/unsupported system type"
57
58 #endif
59
60
61 /*
62  * Kernel memory management
63  *
64  * KM_ALLOC(size, type, flags)
65  *                      Returns an allocated kernel memory chunk of size bytes.
66  * KM_FREE(addr, size, type)
67  *                      Free a kernel memory chunk of size bytes.
68  * KM_CMP(b1, b2, len)
69  *                      Compares len bytes of data from b1 against b2.
70  * KM_COPY(from, to, len)
71  *                      Copies len bytes of data from from to to.
72  * KM_ZERO(addr, len)
73  *                      Zeros len bytes of data from addr.
74  *
75  */
76 #ifdef ATM_KERNEL
77 #if (defined(BSD) && (BSD >= 199103))
78 #include <sys/malloc.h>
79 #define KM_ALLOC(size, type, flags)     malloc((size), (type), (flags))
80 #define KM_FREE(addr, size, type)       free((addr), (type))
81 #elif defined(sun)
82 #include <sys/kmem_alloc.h>
83 #define KM_ALLOC(size, type, flags)     kmem_alloc(size)
84 #define KM_FREE(addr, size, type)       kmem_free((addr), (size))
85 #endif
86
87 #if defined(BSD)
88 #define KM_CMP(b1, b2, len)             bcmp((b1), (b2), (len))
89 #define KM_COPY(from, to, len)          bcopy((from), (to), (len))
90 #define KM_ZERO(addr, len)              bzero((addr), (len))
91 #endif
92 #define XM_COPY(f, t, l)        KM_COPY((f), (t), (l))
93
94 #else
95
96 /*
97  * User-space memory management
98  *
99  * UM_ALLOC(size)       Returns an allocated kernel memory chunk of size bytes.
100  * UM_FREE(addr)        Free a kernel memory chunk of size bytes.
101  * UM_COPY(from, to, len)
102  *                      Copies len bytes of data from from to to.
103  * UM_ZERO(addr, len)   Zeros len bytes of data from addr.
104  *
105  */
106 #if (defined(BSD) && (BSD >= 199103))
107 #define UM_ALLOC(size)          malloc((size_t)(size))
108 #define UM_FREE(addr)           free((void *)(addr))
109 #define UM_COPY(from, to, len)  bcopy((void *)(from), (void *)(to),\
110                                                 (size_t)(len))
111 #define UM_ZERO(addr, len)      bzero((void *)(addr), (size_t)(len))
112 #elif defined(sun)
113 #define UM_ALLOC(size)          malloc(size)
114 #define UM_FREE(addr)           free((char *)(addr))
115 #define UM_COPY(from, to, len)  bcopy((char *)(from), (char *)(to), (len))
116 #define UM_ZERO(addr, len)      bzero((char *)(addr), (len))
117
118 #endif
119 #define XM_COPY(f, t, l)        UM_COPY((f), (t), (l))
120
121 #endif  /* ATM_KERNEL */
122
123
124 #ifdef ATM_KERNEL
125 /*
126  * Kernel buffers
127  *
128  * KBuffer              Typedef for a kernel buffer.
129  *
130  * KB_NEXT(bfr)         Access next buffer in chain (r/w).
131  * KB_LEN(bfr)          Access length of data in this buffer (r/w).
132  * KB_QNEXT(bfr)        Access next buffer in queue (r/w).
133  *
134  * KB_ALLOC(bfr, size, flags, type)
135  *                      Allocates a new kernel buffer of at least size bytes.
136  * KB_ALLOCPKT(bfr, size, flags, type)
137  *                      Allocates a new kernel packet header buffer of at
138  *                      least size bytes.
139  * KB_ALLOCEXT(bfr, size, flags, type)
140  *                      Allocates a new kernel buffer with external storage
141  *                      of at least size bytes.
142  * KB_FREEONE(bfr, nxt) Free buffer bfr and set next buffer in chain in nxt.
143  * KB_FREEALL(bfr)      Free bfr's entire buffer chain.
144  * KB_COPY(bfr, off, len, new, flags)
145  *                      Copy len bytes of user data from buffer bfr starting at
146  *                      byte offset off and return new buffer chain in new.
147  *                      If len is KB_COPYALL, copy until end of chain.
148  * KB_COPYDATA(bfr, off, len, datap)
149  *                      Copy data from buffer bfr starting at byte offset off
150  *                      for len bytes into the data area pointed to by datap.
151  *                      Returns the number of bytes not copied to datap.
152  * KB_PULLUP(bfr, n, new)
153  *                      Get at least the first n bytes of data in the buffer 
154  *                      chain headed by bfr contiguous in the first buffer.
155  *                      Returns the (potentially new) head of the chain in new.
156  *                      On failure the chain is freed and NULL is returned.
157  * KB_LINKHEAD(new, head)
158  *                      Link the kernel buffer new at the head of the buffer
159  *                      chain headed by head.  If both new and head are
160  *                      packet header buffers, new will become the packet
161  *                      header for the chain.
162  * KB_LINK(new, prev)
163  *                      Link the kernel buffer new into the buffer chain
164  *                      after the buffer prev.
165  * KB_UNLINKHEAD(head, next)
166  *                      Unlink the kernel buffer from the head of the buffer
167  *                      chain headed by head.  The buffer head will be freed
168  *                      and the new chain head will be placed in next.
169  * KB_UNLINK(old, prev, next)
170  *                      Unlink the kernel buffer old with previous buffer prev
171  *                      from its buffer chain.  The following buffer in the
172  *                      chain will be placed in next and the buffer old will
173  *                      be freed.
174  * KB_ISPKT(bfr)        Tests whether bfr is a packet header buffer.
175  * KB_ISEXT(bfr)        Tests whether bfr has external storage.
176  * KB_BFRSTART(bfr, x, t)
177  *                      Sets x (cast to type t) to point to the start of the
178  *                      buffer space in bfr.
179  * KB_BFREND(bfr, x, t)
180  *                      Sets x (cast to type t) to point one byte past the end
181  *                      of the buffer space in bfr.
182  * KB_BFRLEN(bfr)       Returns length of buffer space in bfr.
183  * KB_DATASTART(bfr, x, t)
184  *                      Sets x (cast to type t) to point to the start of the
185  *                      buffer data contained in bfr.
186  * KB_DATAEND(bfr, x, t)
187  *                      Sets x (cast to type t) to point one byte past the end
188  *                      of the buffer data contained in bfr.
189  * KB_HEADSET(bfr, n)   Sets the start address for buffer data in buffer bfr to
190  *                      n bytes from the beginning of the buffer space.
191  * KB_HEADMOVE(bfr, n)  Adjust buffer data controls to move data down (n > 0) 
192  *                      or up (n < 0) n bytes in the buffer bfr.
193  * KB_HEADADJ(bfr, n)   Adjust buffer data controls to add (n > 0) or subtract
194  *                      (n < 0) n bytes of data to/from the beginning of bfr.
195  * KB_TAILADJ(bfr, n)   Adjust buffer data controls to add (n > 0) or subtract
196  *                      (n < 0) n bytes of data to/from the end of bfr.
197  * KB_TAILALIGN(bfr, n) Set buffer data controls to place an object of size n
198  *                      at the end of bfr, longword aligned.
199  * KB_HEADROOM(bfr, n)  Set n to the amount of buffer space available before
200  *                      the start of data in bfr.
201  * KB_TAILROOM(bfr, n)  Set n to the amount of buffer space available after
202  *                      the end of data in bfr.
203  * KB_PLENGET(bfr, n)   Set n to bfr's packet length.
204  * KB_PLENSET(bfr, n)   Set bfr's packet length to n.
205  * KB_PLENADJ(bfr, n)   Adjust total packet length by n bytes.
206  *
207  */
208 #if defined(BSD)
209 #include <sys/mbuf.h>
210 typedef struct mbuf     KBuffer;
211
212 #define KB_F_WAIT       M_WAIT
213 #define KB_F_NOWAIT     M_DONTWAIT
214
215 #define KB_T_HEADER     MT_HEADER
216 #define KB_T_DATA       MT_DATA
217
218 #define KB_COPYALL      M_COPYALL
219
220 #if BSD >= 199103
221
222 #define KB_NEXT(bfr)            (bfr)->m_next
223 #define KB_LEN(bfr)             (bfr)->m_len
224 #define KB_QNEXT(bfr)           (bfr)->m_nextpkt
225 #define KB_ALLOC(bfr, size, flags, type) {              \
226         if ((size) <= MLEN) {                           \
227                 MGET((bfr), (flags), (type));           \
228         } else                                          \
229                 (bfr) = NULL;                           \
230 }
231 #define KB_ALLOCPKT(bfr, size, flags, type) {           \
232         if ((size) <= MHLEN) {                          \
233                 MGETHDR((bfr), (flags), (type));        \
234         } else                                          \
235                 (bfr) = NULL;                           \
236 }
237 #define KB_ALLOCEXT(bfr, size, flags, type) {           \
238         if ((size) <= MCLBYTES) {                       \
239                 MGET((bfr), (flags), (type));           \
240                 if ((bfr) != NULL) {                    \
241                         MCLGET((bfr), (flags));         \
242                         if (((bfr)->m_flags & M_EXT) == 0) {    \
243                                 m_freem((bfr));         \
244                                 (bfr) = NULL;           \
245                         }                               \
246                 }                                       \
247         } else                                          \
248                 (bfr) = NULL;                           \
249 }
250 #define KB_FREEONE(bfr, nxt) {                          \
251         (nxt) = m_free(bfr);                            \
252 }
253 #define KB_FREEALL(bfr) {                               \
254         m_freem(bfr);                                   \
255 }
256 #define KB_COPY(bfr, off, len, new, flags) {            \
257         (new) = m_copym((bfr), (off), (len), (flags));  \
258 }
259 #define KB_COPYDATA(bfr, off, len, datap)               \
260         (m_copydata((bfr), (off), (len), (datap)), 0)
261 #define KB_PULLUP(bfr, n, new) {                        \
262         (new) = m_pullup((bfr), (n));                   \
263 }
264 #define KB_LINKHEAD(new, head) {                        \
265         if ((head) && KB_ISPKT(new) && KB_ISPKT(head)) {\
266                 M_MOVE_PKTHDR((new), (head));           \
267         }                                               \
268         (new)->m_next = (head);                         \
269 }
270 #define KB_LINK(new, prev) {                            \
271         (new)->m_next = (prev)->m_next;                 \
272         (prev)->m_next = (new);                         \
273 }
274 #define KB_UNLINKHEAD(head, next) {                     \
275         next = m_free((head));                          \
276 }
277 #define KB_UNLINK(old, prev, next) {                    \
278         next = m_free((old));                           \
279         (prev)->m_next = (next);                        \
280 }
281 #define KB_ISPKT(bfr)           (((bfr)->m_flags & M_PKTHDR) != 0)
282 #define KB_ISEXT(bfr)           (((bfr)->m_flags & M_EXT) != 0)
283 #define KB_BFRSTART(bfr, x, t) {                        \
284         if ((bfr)->m_flags & M_EXT)                     \
285                 (x) = (t)((bfr)->m_ext.ext_buf);        \
286         else if ((bfr)->m_flags & M_PKTHDR)             \
287                 (x) = (t)(&(bfr)->m_pktdat);            \
288         else                                            \
289                 (x) = (t)((bfr)->m_dat);                \
290 }
291 #define KB_BFREND(bfr, x, t) {                          \
292         if ((bfr)->m_flags & M_EXT)                     \
293                 (x) = (t)((bfr)->m_ext.ext_buf + (bfr)->m_ext.ext_size);\
294         else if ((bfr)->m_flags & M_PKTHDR)             \
295                 (x) = (t)(&(bfr)->m_pktdat + MHLEN);    \
296         else                                            \
297                 (x) = (t)((bfr)->m_dat + MLEN);         \
298 }
299 #define KB_BFRLEN(bfr)                                  \
300         (((bfr)->m_flags & M_EXT) ? (bfr)->m_ext.ext_size :     \
301                 (((bfr)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
302 #define KB_DATASTART(bfr, x, t) {                       \
303         (x) = mtod((bfr), t);                           \
304 }
305 #define KB_DATAEND(bfr, x, t) {                         \
306         (x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len); \
307 }
308 #define KB_HEADSET(bfr, n) {                            \
309         if ((bfr)->m_flags & M_EXT)                     \
310                 (bfr)->m_data = (bfr)->m_ext.ext_buf + (n);     \
311         else if ((bfr)->m_flags & M_PKTHDR)             \
312                 (bfr)->m_data = (bfr)->m_pktdat + (n);  \
313         else                                            \
314                 (bfr)->m_data = (bfr)->m_dat + (n);     \
315 }
316 #define KB_HEADMOVE(bfr, n) {                           \
317         (bfr)->m_data += (n);                           \
318 }
319 #define KB_HEADADJ(bfr, n) {                            \
320         (bfr)->m_len += (n);                            \
321         (bfr)->m_data -= (n);                           \
322 }
323 #define KB_TAILADJ(bfr, n) {                            \
324         (bfr)->m_len += (n);                            \
325 }
326 #define KB_TAILALIGN(bfr, n) {                          \
327         (bfr)->m_len = (n);                             \
328         if ((bfr)->m_flags & M_EXT)                     \
329                 (bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_ext.ext_buf  \
330                         + (bfr)->m_ext.ext_size - (n)) & ~(sizeof(long) - 1));\
331         else                                            \
332                 (bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_dat + MLEN - (n)) \
333                         & ~(sizeof(long) - 1));         \
334 }
335 #define KB_HEADROOM(bfr, n) {                           \
336         /* n = M_LEADINGSPACE(bfr) XXX */               \
337         (n) = ((bfr)->m_flags & M_EXT ? (bfr)->m_data - (bfr)->m_ext.ext_buf : \
338                 (bfr)->m_flags & M_PKTHDR ? (bfr)->m_data - (bfr)->m_pktdat : \
339                         (bfr)->m_data - (bfr)->m_dat);  \
340 }
341 #define KB_TAILROOM(bfr, n) {                           \
342         (n) = M_TRAILINGSPACE(bfr);                     \
343 }
344 #define KB_PLENGET(bfr, n) {                            \
345         (n) = (bfr)->m_pkthdr.len;                      \
346 }
347 #define KB_PLENSET(bfr, n) {                            \
348         (bfr)->m_pkthdr.len = (n);                      \
349 }
350 #define KB_PLENADJ(bfr, n) {                            \
351         (bfr)->m_pkthdr.len += (n);                     \
352 }
353
354
355 #else   /* ! BSD >= 199103 */
356
357
358 #define KB_NEXT(bfr)            (bfr)->m_next
359 #define KB_LEN(bfr)             (bfr)->m_len
360 #define KB_QNEXT(bfr)           (bfr)->m_act
361 #define KB_ALLOC(bfr, size, flags, type) {              \
362         if ((size) <= MLEN) {                           \
363                 MGET((bfr), (flags), (type));           \
364         } else                                          \
365                 (bfr) = NULL;                           \
366 }
367 #define KB_ALLOCPKT(bfr, size, flags, type) {           \
368         if ((size) <= MLEN) {                           \
369                 MGET((bfr), (flags), (type));           \
370         } else                                          \
371                 (bfr) = NULL;                           \
372 }
373 #define KB_ALLOCEXT(bfr, size, flags, type) {           \
374         if ((size) <= MCLBYTES) {                       \
375                 MGET((bfr), (flags), (type));           \
376                 if ((bfr) != NULL) {                    \
377                         MCLGET(bfr);                    \
378                         if ((bfr)->m_len != MCLBYTES) { \
379                                 m_freem((bfr));         \
380                                 (bfr) = NULL;           \
381                         }                               \
382                 }                                       \
383         } else                                          \
384                 (bfr) = NULL;                           \
385 }
386 #define KB_FREEONE(bfr, nxt) {                          \
387         (nxt) = m_free(bfr);                            \
388 }
389 #define KB_FREEALL(bfr) {                               \
390         m_freem(bfr);                                   \
391 }
392 #define KB_COPY(bfr, off, len, new, flags) {            \
393         (new) = m_copy((bfr), (off), (len));            \
394 }
395 #define KB_COPYDATA(bfr, off, len, datap)               \
396         m_cpytoc((bfr), (off), (len), (datap))
397 #define KB_PULLUP(bfr, n, new) {                        \
398         (new) = m_pullup((bfr), (n));                   \
399 }
400 #define KB_LINKHEAD(new, head) {                        \
401         (new)->m_next = (head);                         \
402 }
403 #define KB_LINK(new, prev) {                            \
404         (new)->m_next = (prev)->m_next;                 \
405         (prev)->m_next = (new);                         \
406 }
407 #define KB_UNLINKHEAD(head, next) {                     \
408         next = m_free((head));                          \
409 }
410 #define KB_UNLINK(old, prev, next) {                    \
411         next = m_free((old));                           \
412         (prev)->m_next = (next);                        \
413 }
414 #define KB_ISPKT(bfr)           (0)
415 #define KB_ISEXT(bfr)           M_HASCL(bfr)
416 #define KB_BFRSTART(bfr, x, t) {                        \
417         if (M_HASCL(bfr)) {                             \
418                 if ((bfr)->m_cltype == MCL_STATIC)      \
419                         (x) = (t)(mtod((bfr), int) & ~(MCLBYTES - 1));  \
420                 else                                    \
421                         (x) = (t)NULL;                  \
422         } else                                          \
423                 (x) = (t)((bfr)->m_dat);                \
424 }
425 #define KB_BFREND(bfr, x, t) {                          \
426         if (M_HASCL(bfr)) {                             \
427                 if ((bfr)->m_cltype == MCL_STATIC)      \
428                         (x) = (t)((mtod((bfr), int) & ~(MCLBYTES - 1))  \
429                                 + MCLBYTES);            \
430                 else                                    \
431                         (x) = (t)NULL;                  \
432         } else                                          \
433                 (x) = (t)((bfr)->m_dat + MLEN);         \
434 }
435 #define KB_BFRLEN(bfr)                                  \
436         (M_HASCL(bfr) ? (((bfr)->m_cltype == MCL_STATIC) ? MCLBYTES : 0) : MLEN)
437 #define KB_DATASTART(bfr, x, t) {                       \
438         (x) = mtod((bfr), t);                           \
439 }
440 #define KB_DATAEND(bfr, x, t) {                         \
441         (x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len); \
442 }
443 #define KB_HEADSET(bfr, n) {                            \
444         if (M_HASCL(bfr)) {                             \
445                 /* Assume cluster buffer is empty XXX */\
446                 (bfr)->m_off += (n);                    \
447         } else                                          \
448                 (bfr)->m_off = MMINOFF + (n);           \
449 }
450 #define KB_HEADMOVE(bfr, n) {                           \
451         (bfr)->m_off += (n);                            \
452 }
453 #define KB_HEADADJ(bfr, n) {                            \
454         (bfr)->m_len += (n);                            \
455         (bfr)->m_off -= (n);                            \
456 }
457 #define KB_TAILADJ(bfr, n) {                            \
458         (bfr)->m_len += (n);                            \
459 }
460 #define KB_TAILALIGN(bfr, n) {                          \
461         (bfr)->m_len = (n);                             \
462         if (M_HASCL(bfr)) {                             \
463                 if ((bfr)->m_cltype == MCL_STATIC)      \
464                         (bfr)->m_off = (int)(((mtod((bfr), int)         \
465                                 & ~(MCLBYTES - 1)) + MCLBYTES - (n))    \
466                                 & ~(sizeof(long) - 1)) - (int)(bfr);    \
467                 /* Out of luck for loaned buffers */    \
468         } else                                          \
469                 (bfr)->m_off = (MMAXOFF - (n))  & ~(sizeof(long) - 1);  \
470 }
471 #define KB_HEADROOM(bfr, n) {                           \
472         if (M_HASCL(bfr)) {                             \
473                 if ((bfr)->m_cltype == MCL_STATIC)      \
474                         (n) = mtod((bfr), int) & (MCLBYTES - 1);        \
475                 else                                    \
476                         (n) = 0;                        \
477         } else                                          \
478                 (n) = (bfr)->m_off - MMINOFF;           \
479 }
480 #define KB_TAILROOM(bfr, n) {                           \
481         if (M_HASCL(bfr)) {                             \
482                 if ((bfr)->m_cltype == MCL_STATIC)      \
483                         (n) = MCLBYTES - ((mtod((bfr), int) + (bfr)->m_len) \
484                                 & (MCLBYTES - 1));      \
485                 else                                    \
486                         (n) = 0;                        \
487         } else                                          \
488                 (n) = MMAXOFF - ((bfr)->m_off + (bfr)->m_len);  \
489 }
490 #define KB_PLENGET(bfr, n) {                            \
491         struct mbuf     *zz;                            \
492         for ((n) = 0, zz = (bfr); zz; zz = zz->m_next)  \
493                 (n) += zz->m_len;                       \
494 }
495 #define KB_PLENSET(bfr, n) {                            \
496 }
497 #define KB_PLENADJ(bfr, n) {                            \
498 }
499
500
501 #endif  /* ! BSD >= 199103 */
502
503 #endif  /* defined(BSD) */
504
505
506 /*
507  * Kernel time
508  *
509  * KTimeout_ret         Typedef for timeout() function return
510  *
511  * KT_TIME(t)           Sets t to the current time.
512  *
513  */
514 #if (defined(BSD) && (BSD >= 199306))
515 typedef void    KTimeout_ret;
516 #else
517 typedef int     KTimeout_ret;
518 #endif
519 #if (defined(BSD) && (BSD >= 199103))
520 #define KT_TIME(t)      microtime(&t)
521 #elif defined(sun)
522 #define KT_TIME(t)      uniqtime(&t)
523 #else
524 #define KT_TIME(t)      ((t) = time)
525 #endif
526
527 #endif  /* ATM_KERNEL */
528
529 #ifndef NTOHL
530 #if BYTE_ORDER == BIG_ENDIAN
531 #define NTOHL(x)        (x)
532 #define NTOHS(x)        (x)
533 #define HTONL(x)        (x)
534 #define HTONS(x)        (x)
535 #else
536 #define NTOHL(x)        (x) = ntohl((u_long)(x))
537 #define NTOHS(x)        (x) = ntohs((u_short)(x))
538 #define HTONL(x)        (x) = htonl((u_long)(x))
539 #define HTONS(x)        (x) = htons((u_short)(x))
540 #endif
541 #endif  /* NTOHL */
542
543 #ifndef MAX
544 #define MAX(a,b)        max((a),(b))
545 #endif
546 #ifndef MIN
547 #define MIN(a,b)        min((a),(b))
548 #endif
549
550 #if (!(defined(BSD) && (BSD >= 199306)))
551 #ifndef __BIT_TYPES_DEFINED__
552 #define __BIT_TYPES_DEFINED__
553 typedef char            int8_t;
554 typedef unsigned char   u_int8_t;
555 typedef short           int16_t;
556 typedef unsigned short  u_int16_t;
557 typedef int             int32_t;
558 typedef unsigned int    u_int32_t;
559 #endif
560 #endif
561
562 #endif  /* _NETATM_PORT_H */