Go to the documentation of this file.
32 #ifndef __LIBNET_MACROS_H
33 #define __LIBNET_MACROS_H
40 #if defined(NO_SNPRINTF)
41 #define snprintf(buf, len, args...) sprintf(buf, ##args)
49 #define LIBNET_DONT_RESOLVE 0
55 #define LIBNET_RESOLVE 1
70 #ifndef IN6ADDR_ERROR_INIT
71 #define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
72 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
82 #define LIBNET_PRu16 3
84 #define LIBNET_PRu32 5
85 #define LIBNET_PRAND_MAX 0xffffffff
90 #define LIBNET_MAX_PACKET 0xffff
92 #define IP_MAXPACKET 0xffff
97 #ifndef ETHER_ADDR_LEN
98 #define ETHER_ADDR_LEN 0x6
102 #ifndef FDDI_ADDR_LEN
103 #define FDDI_ADDR_LEN 0x6
107 #ifndef TOKEN_RING_ADDR_LEN
108 #define TOKEN_RING_ADDR_LEN 0x6
112 #define LIBNET_ORG_CODE_SIZE 0x3
117 #define LIBNET_ERRBUF_SIZE 0x100
122 #define LIBNET_MAXOPTION_SIZE 0x28
125 #if (LIBNET_BSD_BYTE_SWAP)
126 #define FIX(n) ntohs(n)
127 #define UNFIX(n) htons(n)
134 #define LIBNET_DO_PAYLOAD(l, p) \
135 if (payload_s && !payload) \
137 snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, \
138 "%s(): payload inconsistency\n", __func__); \
143 n = libnet_pblock_append(l, p, payload, payload_s); \
144 if (n == (uint32_t) - 1) \
152 #define LIBNET_CKSUM_CARRY(x) \
153 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
156 #define LIBNET_OSPF_AUTHCPY(x, y) \
157 memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
158 #define LIBNET_OSPF_CKSUMBUF(x, y) \
159 memcpy((uint8_t *)x, (uint8_t *)y, sizeof(y))
162 #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
163 ((uint8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
167 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
169 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo") == 0)
173 #define LIBNET_ISADVMODE(x) (x & 0x08)
176 #define LIBNET_LABEL_SIZE 64
177 #define LIBNET_LABEL_DEFAULT "cardshark"
178 #define CQ_LOCK_UNLOCKED (u_int)0x00000000
179 #define CQ_LOCK_READ (u_int)0x00000001
180 #define CQ_LOCK_WRITE (u_int)0x00000002
187 #define for_each_context_in_cq(l) \
188 for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
191 #define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
194 #define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
197 #define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
200 #define check_cq_lock(x) (l_cqd.cq_lock & x)