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
00035
00036 #if defined(NO_SNPRINTF)
00037 #define snprintf(buf, len, args...) sprintf(buf, ##args)
00038 #endif
00039
00040
00041
00042 #define LIBNET_DONT_RESOLVE 0
00043 #define LIBNET_RESOLVE 1
00044
00045
00046 #define LIBNET_ON 0
00047 #define LIBNET_OFF 1
00048
00049
00050 #ifndef IN6ADDR_ERROR_INIT
00051 #define IN6ADDR_ERROR_INIT { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00052 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
00053 0xff, 0xff } } }
00054 #endif
00055
00056
00057 #define LIBNET_PR2 0
00058 #define LIBNET_PR8 1
00059 #define LIBNET_PR16 2
00060 #define LIBNET_PRu16 3
00061 #define LIBNET_PR32 4
00062 #define LIBNET_PRu32 5
00063 #define LIBNET_PRAND_MAX 0xffffffff
00064
00065 #define LIBNET_MAX_PACKET 0xffff
00066 #ifndef IP_MAXPACKET
00067 #define IP_MAXPACKET 0xffff
00068 #endif
00069 #ifndef ETHER_ADDR_LEN
00070 #define ETHER_ADDR_LEN 0x6
00071 #endif
00072
00073 #define FDDI_ADDR_LEN 0x6
00074 #define TOKEN_RING_ADDR_LEN 0x6
00075
00076
00077 #define LIBNET_ORG_CODE_SIZE 0x3
00078
00079 #define LIBNET_ERRBUF_SIZE 0x100
00080 #define LIBNET_MAXOPTION_SIZE 0x28
00081
00082
00083 #if (LIBNET_BSD_BYTE_SWAP)
00084 #define FIX(n) ntohs(n)
00085 #define UNFIX(n) htons(n)
00086 #else
00087 #define FIX(n) (n)
00088 #define UNFIX(n) (n)
00089 #endif
00090
00091
00092 #define LIBNET_CKSUM_CARRY(x) \
00093 (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff))
00094
00095
00096 #define LIBNET_OSPF_AUTHCPY(x, y) memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00097 #define LIBNET_OSPF_CKSUMBUF(x, y) memcpy((u_int8_t *)x, (u_int8_t *)y, sizeof(y))
00098
00099
00100 #define LIBNET_NTP_DO_LI_VN_MODE(li, vn, md) \
00101 ((u_int8_t)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
00102
00103
00104 #ifdef IFF_LOOPBACK
00105 #define LIBNET_ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK)
00106 #else
00107 #define LIBNET_ISLOOPBACK(p) (strcmp((p)->ifr_name, "lo0") == 0)
00108 #endif
00109
00110
00111 #define LIBNET_ISADVMODE(x) (x & 0x08)
00112
00113
00114 #define LIBNET_LABEL_SIZE 64
00115 #define LIBNET_LABEL_DEFAULT "cardshark"
00116 #define CQ_LOCK_UNLOCKED (u_int)0x00000000
00117 #define CQ_LOCK_READ (u_int)0x00000001
00118 #define CQ_LOCK_WRITE (u_int)0x00000002
00119
00120
00121 #define for_each_context_in_cq(l) \
00122 for (l = libnet_cq_head(); libnet_cq_last(); l = libnet_cq_next())
00123
00124
00125 #define cq_is_wlocked() (l_cqd.cq_lock & CQ_LOCK_WRITE)
00126
00127
00128 #define cq_is_rlocked() (l_cqd.cq_lock & CQ_LOCK_READ)
00129
00130
00131 #define cq_is_locked() (l_cqd.cq_lock & (CQ_LOCK_READ | CQ_LOCK_WRITE))
00132
00133 #define check_cq_lock(x) (l_cqd.cq_lock & x)
00134
00135 #endif
00136
00137