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
00083
00084
00085
00086 u_int32_t ip_offset;
00087
00088
00089
00090
00091
00092
00093 u_int32_t copied;
00094
00095 u_int8_t type;
00096
00097 #define LIBNET_PBLOCK_ARP_H 0x01
00098 #define LIBNET_PBLOCK_DHCPV4_H 0x02
00099 #define LIBNET_PBLOCK_DNSV4_H 0x03
00100 #define LIBNET_PBLOCK_ETH_H 0x04
00101 #define LIBNET_PBLOCK_ICMPV4_H 0x05
00102 #define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06
00103 #define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07
00104 #define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08
00105 #define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09
00106 #define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a
00107 #define LIBNET_PBLOCK_ICMPV4_TS_H 0x0b
00108 #define LIBNET_PBLOCK_IGMP_H 0x0c
00109 #define LIBNET_PBLOCK_IPV4_H 0x0d
00110 #define LIBNET_PBLOCK_IPO_H 0x0e
00111 #define LIBNET_PBLOCK_IPDATA 0x0f
00112 #define LIBNET_PBLOCK_OSPF_H 0x10
00113 #define LIBNET_PBLOCK_OSPF_HELLO_H 0x11
00114 #define LIBNET_PBLOCK_OSPF_DBD_H 0x12
00115 #define LIBNET_PBLOCK_OSPF_LSR_H 0x13
00116 #define LIBNET_PBLOCK_OSPF_LSU_H 0x14
00117 #define LIBNET_PBLOCK_OSPF_LSA_H 0x15
00118 #define LIBNET_PBLOCK_OSPF_AUTH_H 0x16
00119 #define LIBNET_PBLOCK_OSPF_CKSUM 0x17
00120 #define LIBNET_PBLOCK_LS_RTR_H 0x18
00121 #define LIBNET_PBLOCK_LS_NET_H 0x19
00122 #define LIBNET_PBLOCK_LS_SUM_H 0x1a
00123 #define LIBNET_PBLOCK_LS_AS_EXT_H 0x1b
00124 #define LIBNET_PBLOCK_NTP_H 0x1c
00125 #define LIBNET_PBLOCK_RIP_H 0x1d
00126 #define LIBNET_PBLOCK_TCP_H 0x1e
00127 #define LIBNET_PBLOCK_TCPO_H 0x1f
00128 #define LIBNET_PBLOCK_TCPDATA 0x20
00129 #define LIBNET_PBLOCK_UDP_H 0x21
00130 #define LIBNET_PBLOCK_VRRP_H 0x22
00131 #define LIBNET_PBLOCK_DATA_H 0x23
00132 #define LIBNET_PBLOCK_CDP_H 0x24
00133 #define LIBNET_PBLOCK_IPSEC_ESP_HDR_H 0x25
00134 #define LIBNET_PBLOCK_IPSEC_ESP_FTR_H 0x26
00135 #define LIBNET_PBLOCK_IPSEC_AH_H 0x27
00136 #define LIBNET_PBLOCK_802_1Q_H 0x28
00137 #define LIBNET_PBLOCK_802_2_H 0x29
00138 #define LIBNET_PBLOCK_802_2SNAP_H 0x2a
00139 #define LIBNET_PBLOCK_802_3_H 0x2b
00140 #define LIBNET_PBLOCK_STP_CONF_H 0x2c
00141 #define LIBNET_PBLOCK_STP_TCN_H 0x2d
00142 #define LIBNET_PBLOCK_ISL_H 0x2e
00143 #define LIBNET_PBLOCK_IPV6_H 0x2f
00144 #define LIBNET_PBLOCK_802_1X_H 0x30
00145 #define LIBNET_PBLOCK_RPC_CALL_H 0x31
00146 #define LIBNET_PBLOCK_MPLS_H 0x32
00147 #define LIBNET_PBLOCK_FDDI_H 0x33
00148 #define LIBNET_PBLOCK_TOKEN_RING_H 0x34
00149 #define LIBNET_PBLOCK_BGP4_HEADER_H 0x35
00150 #define LIBNET_PBLOCK_BGP4_OPEN_H 0x36
00151 #define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37
00152 #define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38
00153 #define LIBNET_PBLOCK_GRE_H 0x39
00154 #define LIBNET_PBLOCK_GRE_SRE_H 0x3a
00155 #define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b
00156 #define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c
00157 #define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d
00158 #define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e
00159 #define LIBNET_PBLOCK_SEBEK_H 0x3f
00160 #define LIBNET_PBLOCK_HSRP_H 0x40
00161 u_int8_t flags;
00162 #define LIBNET_PBLOCK_DO_CHECKSUM 0x01
00163 libnet_ptag_t ptag;
00164 struct libnet_protocol_block *next;
00165 struct libnet_protocol_block *prev;
00166 };
00167 typedef struct libnet_protocol_block libnet_pblock_t;
00168
00169
00170
00171
00172
00173
00174
00175 struct libnet_context
00176 {
00177 #if ((__WIN32__) && !(__CYGWIN__))
00178 SOCKET fd;
00179 LPADAPTER lpAdapter;
00180 #else
00181 int fd;
00182 #endif
00183 int injection_type;
00184 #define LIBNET_LINK 0x00
00185 #define LIBNET_RAW4 0x01
00186 #define LIBNET_RAW6 0x02
00187
00188 #define LIBNET_LINK_ADV 0x08
00189 #define LIBNET_RAW4_ADV 0x09
00190 #define LIBNET_RAW6_ADV 0x0a
00191 #define LIBNET_ADV_MASK 0x08
00192
00193 libnet_pblock_t *protocol_blocks;
00194 libnet_pblock_t *pblock_end;
00195 u_int32_t n_pblocks;
00196
00197 int link_type;
00198 int link_offset;
00199 int aligner;
00200 char *device;
00201
00202 struct libnet_stats stats;
00203 libnet_ptag_t ptag_state;
00204 char label[LIBNET_LABEL_SIZE];
00205
00206 char err_buf[LIBNET_ERRBUF_SIZE];
00207 u_int32_t total_size;
00208 };
00209 typedef struct libnet_context libnet_t;
00210
00211
00212
00213
00214
00215
00216 typedef struct _libnet_context_queue libnet_cq_t;
00217 struct _libnet_context_queue
00218 {
00219 libnet_t *context;
00220 libnet_cq_t *next;
00221 libnet_cq_t *prev;
00222 };
00223
00224 struct _libnet_context_queue_descriptor
00225 {
00226 u_int32_t node;
00227 u_int32_t cq_lock;
00228 libnet_cq_t *current;
00229 };
00230 typedef struct _libnet_context_queue_descriptor libnet_cqd_t;
00231
00232 #endif
00233
00234