2 * $Id: libnet-macros.h,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
4 * libnet-macros.h - Network routine library macro header file
6 * Copyright (c) 1998 - 2001 Mike D. Schiffman <mike@infonexus.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef __LIBNET_MACROS_H
33 #define __LIBNET_MACROS_H
36 * for libnet_hostlookup
38 #define LIBNET_DONT_RESOLVE 0
39 #define LIBNET_RESOLVE 1
47 #define LIBNET_PRu16 3
49 #define LIBNET_PRu32 5
50 #define LIBNET_PRAND_MAX 0xffffffff
53 * Concession to legacy naming scheme
55 #define PR2 LIBNET_PR2
56 #define PR8 LIBNET_PR8
57 #define PR16 LIBNET_PR16
58 #define PRu16 LIBNET_PRu16
59 #define PR32 LIBNET_PR32
60 #define PRu32 LIBNET_PRu32
61 #define PRAND_MAX LIBNET_PRAND_MAX
64 * Misc packet sizes for malloc
66 #define LIBNET_PACKET LIBNET_IP_H + LIBNET_TCP_H /* IP, UDP or TCP */
67 #define LIBNET_OPTS 0x34 /* options! options! options! */
68 #define LIBNET_MAX_PACKET 0xffff /* as big as we can get */
72 * Error handling constants.
74 #define LIBNET_ERR_WARNING 1
75 #define LIBNET_ERR_CRITICAL 2
76 #define LIBNET_ERR_FATAL 3
79 * Concession to legacy naming scheme
81 #define LN_ERR_WARNING LIBNET_ERR_WARNING
82 #define LN_ERR_CRITICAL LIBNET_ERR_CRITICAL
83 #define LN_ERR_FATAL LIBNET_ERR_FATAL
86 #define LIBNET_ERRBUF_SIZE 256
90 * Some BSD variants have this endianess problem.
92 #if (LIBNET_BSD_BYTE_SWAP)
93 #define FIX(n) ntohs(n)
94 #define UNFIX(n) htons(n)
103 #define LIBNET_GET_ARENA_SIZE(a) (a.size)
104 #define LIBNET_GET_ARENA_REMAINING_BYTES(a) (a.size - a.current)
110 #define LIBNET_CKSUM_CARRY(x) \
111 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
117 #define LIBNET_OSPF_AUTHCPY(x,y) memcpy((u_char *)x, (u_char *)y, sizeof(y))
118 #define LIBNET_OSPF_CKSUMBUF(x,y) memcpy((u_char *)x, (u_char *)y, sizeof(y))
121 * Not all systems have IFF_LOOPBACK
125 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
127 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)
130 #define LIBNET_PRINT_ETH_ADDR(e) \
133 for (i = 0; i < 6; i++) \
135 printf("%x", e.ether_addr_octet[i]); \
144 #endif /* __LIBNET_MACROS_H */