Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / vera / niu_ippktgen / C / wrapper / include / libnet / libnet-structures.h
CommitLineData
86530b38
AT
1/*
2 * $Id: libnet-structures.h,v 1.19 2005/11/29 22:44:33 carlosc Exp $
3 *
4 * libnet-structures.h - Network routine library structures header file
5 *
6 * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 */
31
32#ifndef __LIBNET_STRUCTURES_H
33#define __LIBNET_STRUCTURES_H
34
35#if ((__WIN32__) && !(__CYGWIN__))
36#include "Packet32.h"
37#endif
38
39/* port list chain structure */
40typedef struct libnet_port_list_chain libnet_plist_t;
41struct libnet_port_list_chain
42{
43 u_int16_t node; /* node number */
44 u_int16_t bport; /* beggining port */
45 u_int16_t eport; /* terminating port */
46 u_int8_t id; /* global array offset */
47 libnet_plist_t *next; /* next node in the list */
48};
49
50
51/* libnet statistics structure */
52struct libnet_stats
53{
54#if (!defined(__WIN32__) || (__CYGWIN__))
55 u_int64_t packets_sent; /* packets sent */
56 u_int64_t packet_errors; /* packets errors */
57 u_int64_t bytes_written; /* bytes written */
58#else
59 __int64 packets_sent; /* packets sent */
60 __int64 packet_errors; /* packets errors */
61 __int64 bytes_written; /* bytes written */
62#endif
63};
64
65
66/*
67 * Libnet ptags are how we identify specific protocol blocks inside the
68 * list.
69 */
70typedef int32_t libnet_ptag_t;
71#define LIBNET_PTAG_INITIALIZER 0
72
73
74/*
75 * Libnet generic protocol block memory object. Sort of a poor man's mbuf.
76 */
77struct libnet_protocol_block
78{
79 u_int8_t *buf; /* protocol buffer */
80 u_int32_t b_len; /* length of buf */
81 u_int16_t h_len; /* header length (for checksumming) */
82 u_int32_t ip_offset; /* offset to IP header for csums */
83 u_int32_t copied; /* bytes copied */
84 u_int8_t type; /* type of pblock */
85/* this needs to be updated every time a new packet builder is added */
86#define LIBNET_PBLOCK_ARP_H 0x01 /* ARP header */
87#define LIBNET_PBLOCK_DHCPV4_H 0x02 /* DHCP v4 header */
88#define LIBNET_PBLOCK_DNSV4_H 0x03 /* DNS v4 header */
89#define LIBNET_PBLOCK_ETH_H 0x04 /* Ethernet header */
90#define LIBNET_PBLOCK_ICMPV4_H 0x05 /* ICMP v4 base header */
91#define LIBNET_PBLOCK_ICMPV4_ECHO_H 0x06 /* ICMP v4 echo header */
92#define LIBNET_PBLOCK_ICMPV4_MASK_H 0x07 /* ICMP v4 mask header */
93#define LIBNET_PBLOCK_ICMPV4_UNREACH_H 0x08 /* ICMP v4 unreach header */
94#define LIBNET_PBLOCK_ICMPV4_TIMXCEED_H 0x09 /* ICMP v4 exceed header */
95#define LIBNET_PBLOCK_ICMPV4_REDIRECT_H 0x0a /* ICMP v4 redirect header */
96#define LIBNET_PBLOCK_ICMPV4_TS_H 0x0b /* ICMP v4 timestamp header */
97#define LIBNET_PBLOCK_IGMP_H 0x0c /* IGMP header */
98#define LIBNET_PBLOCK_IPV4_H 0x0d /* IP v4 header */
99#define LIBNET_PBLOCK_IPO_H 0x0e /* IP v4 options */
100#define LIBNET_PBLOCK_IPDATA 0x0f /* IP data */
101#define LIBNET_PBLOCK_OSPF_H 0x10 /* OSPF base header */
102#define LIBNET_PBLOCK_OSPF_HELLO_H 0x11 /* OSPF hello header */
103#define LIBNET_PBLOCK_OSPF_DBD_H 0x12 /* OSPF dbd header */
104#define LIBNET_PBLOCK_OSPF_LSR_H 0x13 /* OSPF lsr header */
105#define LIBNET_PBLOCK_OSPF_LSU_H 0x14 /* OSPF lsu header */
106#define LIBNET_PBLOCK_OSPF_LSA_H 0x15 /* OSPF lsa header */
107#define LIBNET_PBLOCK_OSPF_AUTH_H 0x16 /* OSPF auth header */
108#define LIBNET_PBLOCK_OSPF_CKSUM 0x17 /* OSPF checksum header */
109#define LIBNET_PBLOCK_LS_RTR_H 0x18 /* linkstate rtr header */
110#define LIBNET_PBLOCK_LS_NET_H 0x19 /* linkstate net header */
111#define LIBNET_PBLOCK_LS_SUM_H 0x1a /* linkstate as sum header */
112#define LIBNET_PBLOCK_LS_AS_EXT_H 0x1b /* linkstate as ext header */
113#define LIBNET_PBLOCK_NTP_H 0x1c /* NTP header */
114#define LIBNET_PBLOCK_RIP_H 0x1d /* RIP header */
115#define LIBNET_PBLOCK_TCP_H 0x1e /* TCP header */
116#define LIBNET_PBLOCK_TCPO_H 0x1f /* TCP options */
117#define LIBNET_PBLOCK_TCPDATA 0x20 /* TCP data */
118#define LIBNET_PBLOCK_UDP_H 0x21 /* UDP header */
119#define LIBNET_PBLOCK_VRRP_H 0x22 /* VRRP header */
120#define LIBNET_PBLOCK_DATA_H 0x23 /* generic data */
121#define LIBNET_PBLOCK_CDP_H 0x24 /* CDP header */
122#define LIBNET_PBLOCK_IPSEC_ESP_HDR_H 0x25 /* IPSEC ESP header */
123#define LIBNET_PBLOCK_IPSEC_ESP_FTR_H 0x26 /* IPSEC ESP footer */
124#define LIBNET_PBLOCK_IPSEC_AH_H 0x27 /* IPSEC AH header */
125#define LIBNET_PBLOCK_802_1Q_H 0x28 /* 802.1q header */
126#define LIBNET_PBLOCK_802_2_H 0x29 /* 802.2 header */
127#define LIBNET_PBLOCK_802_2SNAP_H 0x2a /* 802.2 SNAP header */
128#define LIBNET_PBLOCK_802_3_H 0x2b /* 802.3 header */
129#define LIBNET_PBLOCK_STP_CONF_H 0x2c /* STP configuration header */
130#define LIBNET_PBLOCK_STP_TCN_H 0x2d /* STP TCN header */
131#define LIBNET_PBLOCK_ISL_H 0x2e /* ISL header */
132#define LIBNET_PBLOCK_IPV6_H 0x2f /* IP v6 header */
133#define LIBNET_PBLOCK_802_1X_H 0x30 /* 802.1x header */
134#define LIBNET_PBLOCK_RPC_CALL_H 0x31 /* RPC Call header */
135#define LIBNET_PBLOCK_MPLS_H 0x32 /* MPLS header */
136#define LIBNET_PBLOCK_FDDI_H 0x33 /* FDDI header */
137#define LIBNET_PBLOCK_TOKEN_RING_H 0x34 /* TOKEN RING header */
138#define LIBNET_PBLOCK_BGP4_HEADER_H 0x35 /* BGP4 header */
139#define LIBNET_PBLOCK_BGP4_OPEN_H 0x36 /* BGP4 open header */
140#define LIBNET_PBLOCK_BGP4_UPDATE_H 0x37 /* BGP4 update header */
141#define LIBNET_PBLOCK_BGP4_NOTIFICATION_H 0x38 /* BGP4 notification header */
142#define LIBNET_PBLOCK_GRE_H 0x39 /* GRE header */
143#define LIBNET_PBLOCK_GRE_SRE_H 0x3a /* GRE SRE header */
144#define LIBNET_PBLOCK_IPV6_FRAG_H 0x3b /* IPv6 frag header */
145#define LIBNET_PBLOCK_IPV6_ROUTING_H 0x3c /* IPv6 routing header */
146#define LIBNET_PBLOCK_IPV6_DESTOPTS_H 0x3d /* IPv6 dest opts header */
147#define LIBNET_PBLOCK_IPV6_HBHOPTS_H 0x3e /* IPv6 hop/hop opts header */
148#define LIBNET_PBLOCK_SEBEK_H 0x3f /* Sebek header */
149#define LIBNET_PBLOCK_SCTP_H 0x40 /* SCTP header type */
150#define LIBNET_PBLOCK_SCTP_CHNK_DATA 0x41 /* SCTP chunk data type */
151#define LIBNET_PBLOCK_PIM_H 0x42 /* PIM header type */
152#define LIBNET_PBLOCK_RSVP_H 0x43 /* RSVP header type */
153#define LIBNET_PBLOCK_RSVP_OBJ 0x44 /* RSVP object type */
154 u_int8_t flags; /* control flags */
155#define LIBNET_PBLOCK_DO_CHECKSUM 0x01 /* needs a checksum */
156 libnet_ptag_t ptag; /* protocol block tag */
157 struct libnet_protocol_block *next; /* next pblock */
158 struct libnet_protocol_block *prev; /* prev pblock */
159};
160typedef struct libnet_protocol_block libnet_pblock_t;
161
162
163/*
164 * Libnet context
165 * Opaque structure. Nothing in here should ever been touched first hand by
166 * the applications programmer.
167 */
168struct libnet_context
169{
170#if ((__WIN32__) && !(__CYGWIN__))
171 SOCKET fd;
172 LPADAPTER lpAdapter;
173#else
174 int fd; /* file descriptor of packet device */
175#endif
176 int injection_type; /* raw (ipv4 or ipv6) or link */
177#define LIBNET_LINK 0x00 /* link-layer interface */
178#define LIBNET_RAW4 0x01 /* raw socket interface (ipv4) */
179#define LIBNET_RAW6 0x02 /* raw socket interface (ipv6) */
180/* the following should actually set a flag in the flags variable above */
181#define LIBNET_LINK_ADV 0x08 /* advanced mode link-layer */
182#define LIBNET_RAW4_ADV 0x09 /* advanced mode raw socket (ipv4) */
183#define LIBNET_RAW6_ADV 0x0a /* advanced mode raw socket (ipv6) */
184#define LIBNET_ADV_MASK 0x08 /* mask to determine adv mode */
185
186 libnet_pblock_t *protocol_blocks; /* protocol headers / data */
187 libnet_pblock_t *pblock_end; /* last node in list */
188 u_int32_t n_pblocks; /* number of pblocks */
189
190 int link_type; /* link-layer type */
191 int link_offset; /* link-layer header size */
192 int aligner; /* used to align packets */
193 char *device; /* device name */
194
195 struct libnet_stats stats; /* statistics */
196 libnet_ptag_t ptag_state; /* state holder for pblock tag */
197 char label[LIBNET_LABEL_SIZE]; /* textual label for cq interface */
198
199 char err_buf[LIBNET_ERRBUF_SIZE]; /* error buffer */
200 u_int32_t total_size; /* total size */
201};
202typedef struct libnet_context libnet_t;
203
204/*
205 * Libnet context queue structure
206 * Opaque structure. Nothing in here should ever been touched first hand by
207 * the applications programmer.
208 */
209typedef struct _libnet_context_queue libnet_cq_t;
210struct _libnet_context_queue
211{
212 libnet_t *context; /* pointer to libnet context */
213 libnet_cq_t *next; /* next node in the list */
214 libnet_cq_t *prev; /* previous node in the list */
215};
216
217struct _libnet_context_queue_descriptor
218{
219 u_int32_t node; /* number of nodes in the list */
220 u_int32_t cq_lock; /* lock status */
221 libnet_cq_t *current; /* current context */
222};
223typedef struct _libnet_context_queue_descriptor libnet_cqd_t;
224
225#endif /* __LIBNET_STRUCTURES_H */
226
227/* EOF */