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_STRUCTURES_H
00033 #define __LIBNET_STRUCTURES_H
00034
00035 #if ((__WIN32__) && !(__CYGWIN__))
00036 #include "Packet32.h"
00037 #endif
00038
00039
00040 typedef struct libnet_port_list_chain libnet_plist_t;
00041 struct libnet_port_list_chain
00042 {
00043 u_int16_t node;
00044 u_int16_t bport;
00045 u_int16_t eport;
00046 u_int8_t id;
00047 libnet_plist_t *next;
00048 };
00049
00050
00051
00052 struct libnet_stats
00053 {
00054 #if (!defined(__WIN32__) || (__CYGWIN__))
00055 u_int64_t packets_sent;
00056 u_int64_t packet_errors;
00057 u_int64_t bytes_written;
00058 #else
00059 __int64 packets_sent;
00060 __int64 packet_errors;
00061 __int64 bytes_written;
00062 #endif
00063 };
00064
00065
00066
00067
00068
00069
00070 typedef int32_t libnet_ptag_t;
00071 #define LIBNET_PTAG_INITIALIZER 0
00072
00073
00074
00075
00076
00077 struct libnet_protocol_block
00078 {
00079 u_int8_t *buf;
00080 u_int32_t b_len;
00081 u_int16_t h_len;
00082 u_int32_t copied;
00083 u_int8_t type;
00084
00085 #define LIBNET_PBLOCK_ARP_H 0x01
00086 #define LIBNET_PBLOCK_DHCPV4_H 0x02
00087 #define LIBNET_PBLOCK_DNSV4_H 0x03
00088 #define LIBNET_PBLOCK_ETH_H 0x04
00089 #define LIBNET_PBLOCK_ICMPV4_H 0x05
00090 #define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06
00091 #define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07
00092 #define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08
00093 #define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09
00094 #define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a
00095 #define LIBNET_PBLOCK_ICMPV4_TS_H 0x0b
00096 #define LIBNET_PBLOCK_IGMP_H 0x0c
00097 #define LIBNET_PBLOCK_IPV4_H 0x0d
00098 #define LIBNET_PBLOCK_IPO_H 0x0e
00099 #define LIBNET_PBLOCK_IPDATA 0x0f
00100 #define LIBNET_PBLOCK_OSPF_H 0x10
00101 #define LIBNET_PBLOCK_OSPF_HELLO_H 0x11
00102 #define LIBNET_PBLOCK_OSPF_DBD_H 0x12
00103 #define LIBNET_PBLOCK_OSPF_LSR_H 0x13
00104 #define LIBNET_PBLOCK_OSPF_LSU_H 0x14
00105 #define LIBNET_PBLOCK_OSPF_LSA_H 0x15
00106 #define LIBNET_PBLOCK_OSPF_AUTH_H 0x16
00107 #define LIBNET_PBLOCK_OSPF_CKSUM 0x17
00108 #define LIBNET_PBLOCK_LS_RTR_H 0x18
00109 #define LIBNET_PBLOCK_LS_NET_H 0x19
00110 #define LIBNET_PBLOCK_LS_SUM_H 0x1a
00111 #define LIBNET_PBLOCK_LS_AS_EXT_H 0x1b
00112 #define LIBNET_PBLOCK_NTP_H 0x1c
00113 #define LIBNET_PBLOCK_RIP_H 0x1d
00114 #define LIBNET_PBLOCK_TCP_H 0x1e
00115 #define LIBNET_PBLOCK_TCPO_H 0x1f
00116 #define LIBNET_PBLOCK_TCPDATA 0x20
00117 #define LIBNET_PBLOCK_UDP_H 0x21
00118 #define LIBNET_PBLOCK_VRRP_H 0x22
00119 #define LIBNET_PBLOCK_DATA_H 0x23
00120 #define LIBNET_PBLOCK_CDP_H 0x24
00121 #define LIBNET_PBLOCK_IPSEC_ESP_HDR_H 0x25
00122 #define LIBNET_PBLOCK_IPSEC_ESP_FTR_H 0x26
00123 #define LIBNET_PBLOCK_IPSEC_AH_H 0x27
00124 #define LIBNET_PBLOCK_802_1Q_H 0x28
00125 #define LIBNET_PBLOCK_802_2_H 0x29
00126 #define LIBNET_PBLOCK_802_2SNAP_H 0x2a
00127 #define LIBNET_PBLOCK_802_3_H 0x2b
00128 #define LIBNET_PBLOCK_STP_CONF_H 0x2c
00129 #define LIBNET_PBLOCK_STP_TCN_H 0x2d
00130 #define LIBNET_PBLOCK_ISL_H 0x2e
00131 #define LIBNET_PBLOCK_IPV6_H 0x2f
00132 #define LIBNET_PBLOCK_802_1X_H 0x30
00133 #define LIBNET_PBLOCK_RPC_CALL_H 0x31
00134 #define LIBNET_PBLOCK_MPLS_H 0x32
00135 #define LIBNET_PBLOCK_FDDI_H 0x33
00136 #define LIBNET_PBLOCK_TOKEN_RING_H 0x34
00137 #define LIBNET_PBLOCK_BGP4_HEADER_H 0x35
00138 #define LIBNET_PBLOCK_BGP4_OPEN_H 0x36
00139 #define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37
00140 #define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38
00141 #define LIBNET_PBLOCK_GRE_H 0x39
00142 #define LIBNET_PBLOCK_GRE_SRE_H 0x3a
00143 #define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b
00144 #define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c
00145 #define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d
00146 #define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e
00147 #define LIBNET_PBLOCK_SEBEK_H 0x3f
00148 u_int8_t flags;
00149 #define LIBNET_PBLOCK_DO_CHECKSUM 0x01
00150 libnet_ptag_t ptag;
00151 struct libnet_protocol_block *next;
00152 struct libnet_protocol_block *prev;
00153 };
00154 typedef struct libnet_protocol_block libnet_pblock_t;
00155
00156
00157
00158
00159
00160
00161
00162 struct libnet_context
00163 {
00164 #if ((__WIN32__) && !(__CYGWIN__))
00165 SOCKET fd;
00166 LPADAPTER lpAdapter;
00167 #else
00168 int fd;
00169 #endif
00170 int injection_type;
00171 #define LIBNET_LINK 0x00
00172 #define LIBNET_RAW4 0x01
00173 #define LIBNET_RAW6 0x02
00174
00175 #define LIBNET_LINK_ADV 0x08
00176 #define LIBNET_RAW4_ADV 0x09
00177 #define LIBNET_RAW6_ADV 0x0a
00178 #define LIBNET_ADV_MASK 0x08
00179
00180 libnet_pblock_t *protocol_blocks;
00181 libnet_pblock_t *pblock_end;
00182
00183 int link_type;
00184 int link_offset;
00185 int aligner;
00186 char *device;
00187
00188 struct libnet_stats stats;
00189 libnet_ptag_t ptag_state;
00190 char label[LIBNET_LABEL_SIZE];
00191
00192 char err_buf[LIBNET_ERRBUF_SIZE];
00193 u_int32_t total_size;
00194 };
00195 typedef struct libnet_context libnet_t;
00196
00197
00198
00199
00200
00201
00202 typedef struct _libnet_context_queue libnet_cq_t;
00203 struct _libnet_context_queue
00204 {
00205 libnet_t *context;
00206 libnet_cq_t *next;
00207 libnet_cq_t *prev;
00208 };
00209
00210 struct _libnet_context_queue_descriptor
00211 {
00212 u_int32_t node;
00213 u_int32_t cq_lock;
00214 libnet_cq_t *current;
00215 };
00216 typedef struct _libnet_context_queue_descriptor libnet_cqd_t;
00217
00218 #endif
00219
00220