00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LIBNET_MACROS_H
00033 #define __LIBNET_MACROS_H
00034
00039
00040 #if defined(NO_SNPRINTF)
00041 #define snprintf(buf, len, args...) sprintf(buf, ##args)
00042 #endif
00043
00044
00049 #define LIBNET_DONT_RESOLVE 0
00050
00055 #define LIBNET_RESOLVE 1
00056
00060 #define LIBNET_ON 0
00061
00065 #define LIBNET_OFF 1
00066
00070 #ifndef IN6ADDR_ERROR_INIT
00071 #define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00072 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00073 0xff, 0xff } } }
00074 #endif
00075
00079 #define LIBNET_PR2 0
00080 #define LIBNET_PR8 1
00081 #define LIBNET_PR16 2
00082 #define LIBNET_PRu16 3
00083 #define LIBNET_PR32 4
00084 #define LIBNET_PRu32 5
00085 #define LIBNET_PRAND_MAX 0xffffffff
00086
00090 #define LIBNET_MAX_PACKET 0xffff
00091 #ifndef IP_MAXPACKET
00092 #define IP_MAXPACKET 0xffff
00093 #endif
00094
00095
00096
00097 #ifndef ETHER_ADDR_LEN
00098 #define ETHER_ADDR_LEN 0x6
00099 #endif
00100
00101
00102 #define FDDI_ADDR_LEN 0x6
00103
00104
00105 #define TOKEN_RING_ADDR_LEN 0x6
00106
00107
00108 #define LIBNET_ORG_CODE_SIZE 0x3
00109
00113 #define LIBNET_ERRBUF_SIZE 0x100
00114
00118 #define LIBNET_MAXOPTION_SIZE 0x28
00119
00120
00121 #if (LIBNET_BSD_BYTE_SWAP)
00122 #define FIX(n) ntohs(n)
00123 #define UNFIX(n) htons(n)
00124 #else
00125 #define FIX(n) (n)
00126 #define UNFIX(n) (n)
00127 #endif
00128
00129
00130 #define LIBNET_CKSUM_CARRY(x) \
00131 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
00132
00133
00134 #define LIBNET_OSPF_AUTHCPY(x, y) \
00135 memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00136 #define LIBNET_OSPF_CKSUMBUF(x, y) \
00137 memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00138
00139
00140 #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
00141 ((u_int8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
00142
00143
00144 #ifdef IFF_LOOPBACK
00145 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
00146 #else
00147 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)
00148 #endif
00149
00150
00151 #define LIBNET_ISADVMODE(x) (x & 0x08)
00152
00153
00154 #define LIBNET_LABEL_SIZE 64
00155 #define LIBNET_LABEL_DEFAULT "cardshark"
00156 #define CQ_LOCK_UNLOCKED (u_int)0x00000000
00157 #define CQ_LOCK_READ (u_int)0x00000001
00158 #define CQ_LOCK_WRITE (u_int)0x00000002
00159
00160
00161 #define for_each_context_in_cq(l) \
00162 for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
00163
00164
00165 #define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
00166
00167
00168 #define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
00169
00170
00171 #define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
00172
00173
00174 #define check_cq_lock(x) (l_cqd.cq_lock & x)
00175
00176 #endif
00177
00178