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 #ifndef FDDI_ADDR_LEN
00103 #define FDDI_ADDR_LEN 0x6
00104 #endif
00105
00106
00107 #ifndef TOKEN_RING_ADDR_LEN
00108 #define TOKEN_RING_ADDR_LEN 0x6
00109 #endif
00110
00111
00112 #define LIBNET_ORG_CODE_SIZE 0x3
00113
00117 #define LIBNET_ERRBUF_SIZE 0x100
00118
00122 #define LIBNET_MAXOPTION_SIZE 0x28
00123
00124
00125 #if (LIBNET_BSD_BYTE_SWAP)
00126 #define FIX(n) ntohs(n)
00127 #define UNFIX(n) htons(n)
00128 #else
00129 #define FIX(n) (n)
00130 #define UNFIX(n) (n)
00131 #endif
00132
00133
00134 #define LIBNET_CKSUM_CARRY(x) \
00135 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
00136
00137
00138 #define LIBNET_OSPF_AUTHCPY(x, y) \
00139 memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00140 #define LIBNET_OSPF_CKSUMBUF(x, y) \
00141 memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00142
00143
00144 #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
00145 ((u_int8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
00146
00147
00148 #ifdef IFF_LOOPBACK
00149 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
00150 #else
00151 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)
00152 #endif
00153
00154
00155 #define LIBNET_ISADVMODE(x) (x & 0x08)
00156
00157
00158 #define LIBNET_LABEL_SIZE 64
00159 #define LIBNET_LABEL_DEFAULT "cardshark"
00160 #define CQ_LOCK_UNLOCKED (u_int)0x00000000
00161 #define CQ_LOCK_READ (u_int)0x00000001
00162 #define CQ_LOCK_WRITE (u_int)0x00000002
00163
00169 #define for_each_context_in_cq(l) \
00170 for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
00171
00172
00173 #define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
00174
00175
00176 #define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
00177
00178
00179 #define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
00180
00181
00182 #define check_cq_lock(x) (l_cqd.cq_lock & x)
00183
00184 #endif
00185
00186