Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #ifndef _PACKET_H |
2 | #define _PACKET_H | |
3 | ||
4 | #ifdef __cplusplus | |
5 | extern "C" { | |
6 | #endif | |
7 | ||
8 | // Layer 4 defines | |
9 | #define L4_PKT_TYPE_TCP 0x1 | |
10 | #define L4_PKT_TYPE_UDP 0x2 | |
11 | #define L4_PKT_TYPE_SCTP 0x4 | |
12 | #define L4_PKT_TYPE_AH 0x8 | |
13 | #define L4_PKT_TYPE_ESP 0x10 | |
14 | #define L4_PKT_TYPE_ICMP 0x20 | |
15 | #define L4_PKT_TYPE_IGMP 0x40 | |
16 | #define L4_PKT_TYPE_GRE 0x80 | |
17 | #define L4_PKT_TYPE_EGRE 0x100 | |
18 | #define L4_PKT_TYPE_PIM 0x200 | |
19 | #define L4_PKT_TYPE_RSVP 0x400 | |
20 | ||
21 | // Layer 3 defines | |
22 | #define L3_PKT_TYPE_FRAG 0x8 | |
23 | #define L3_PKT_TYPE_OPT 0x4 | |
24 | #define L3_PKT_TYPE_IPV6 0x2 | |
25 | #define L3_PKT_TYPE_IPV4 0x1 | |
26 | ||
27 | // Layer 2 defines | |
28 | #define L2_PKT_TYPE_LLCSNAP 0x10 | |
29 | #define L2_PKT_TYPE_TAGGED 0x8 | |
30 | // Need some defines for ARP, etc | |
31 | // sbehera | |
32 | #define L2_PKT_TYPE_RARP 0x4 | |
33 | #define L2_PKT_TYPE_ARP 0x2 | |
34 | ||
35 | ||
36 | #define L2_PKT 0x1 | |
37 | #define L2_RUNT 0x40 | |
38 | ||
39 | ||
40 | // defines from old pktgen - only for compatibility | |
41 | #define PKTGEN_TCP 16 | |
42 | #define PKTGEN_UDP 13 | |
43 | ||
44 | // Class Type Definitions | |
45 | // | |
46 | // // IPv4 defines | |
47 | #define PKTGEN_CL_ARP 0 | |
48 | #define PKTGEN_CL_RARP 1 | |
49 | #define PKTGEN_CL_RSVP 2 | |
50 | #define PKTGEN_CL_IGMP 3 | |
51 | #define PKTGEN_CL_ICMP 4 | |
52 | #define PKTGEN_CL_PIM 5 | |
53 | #define PKTGEN_CL_GRE 6 | |
54 | #define PKTGEN_CL_IP 7 | |
55 | #define PKTGEN_CL_IP_OPT 8 | |
56 | #define PKTGEN_CL_IP_FRAG 9 | |
57 | #define PKTGEN_CL_IP_ROUTE 10 | |
58 | #define PKTGEN_CL_IP_SEC_AH 11 | |
59 | #define PKTGEN_CL_IP_SEC_ESP 12 | |
60 | #define PKTGEN_CL_UDP 13 | |
61 | #define PKTGEN_CL_UDP_FRAG 14 | |
62 | #define PKTGEN_CL_UDP_OPT 15 | |
63 | #define PKTGEN_CL_TCP 16 | |
64 | #define PKTGEN_CL_TCP_FRAG 17 | |
65 | #define PKTGEN_CL_TCP_OPT 18 | |
66 | #define PKTGEN_CL_SCTP 19 | |
67 | #define PKTGEN_CL_SCTP_OPT 20 | |
68 | #define PKTGEN_CL_SCTP_FRAG 21 | |
69 | ||
70 | #define PKTGEN_DELTA 22 | |
71 | ||
72 | // IPv6 defines | |
73 | // (Values must be a DETLA apart from their IPv4 class) | |
74 | #define PKTGEN_CL_ARP_IP_V6 PKTGEN_DELTA + 0 | |
75 | #define PKTGEN_CL_RARP_IP_V6 PKTGEN_DELTA + 1 | |
76 | #define PKTGEN_CL_RSVP_IP_V6 PKTGEN_DELTA + 2 | |
77 | #define PKTGEN_CL_IGMP_IP_V6 PKTGEN_DELTA + 3 | |
78 | #define PKTGEN_CL_ICMP_IP_V6 PKTGEN_DELTA + 4 | |
79 | #define PKTGEN_CL_PIM_IP_V6 PKTGEN_DELTA + 5 | |
80 | #define PKTGEN_CL_GRE_IP_V6 PKTGEN_DELTA + 6 | |
81 | #define PKTGEN_CL_IP_V6 PKTGEN_DELTA + 7 | |
82 | #define PKTGEN_CL_IP_V6_OPT PKTGEN_DELTA + 8 | |
83 | #define PKTGEN_CL_IP_V6_FRAG PKTGEN_DELTA + 9 | |
84 | #define PKTGEN_CL_IP_V6_ROUTE PKTGEN_DELTA + 10 | |
85 | #define PKTGEN_CL_IP_V6_SEC_AH PKTGEN_DELTA + 11 | |
86 | #define PKTGEN_CL_IP_V6_SEC_ESP PKTGEN_DELTA + 12 | |
87 | #define PKTGEN_CL_UDP_IP_V6 PKTGEN_DELTA + 13 | |
88 | #define PKTGEN_CL_UDP_FRAG_IP_V6 PKTGEN_DELTA + 14 | |
89 | #define PKTGEN_CL_UDP_OPT_IP_V6 PKTGEN_DELTA + 15 | |
90 | #define PKTGEN_CL_TCP_IP_V6 PKTGEN_DELTA + 16 | |
91 | #define PKTGEN_CL_TCP_FRAG_IP_V6 PKTGEN_DELTA + 17 | |
92 | #define PKTGEN_CL_TCP_OPT_IP_V6 PKTGEN_DELTA + 18 | |
93 | ||
94 | #define PKTGEN_CL_IP_TUN_V4_V4 PKTGEN_DELTA + 19 | |
95 | #define PKTGEN_CL_IP_TUN_V4_V6 PKTGEN_DELTA + 20 | |
96 | #define PKTGEN_CL_IP_TUN_V6_V4 PKTGEN_DELTA + 21 | |
97 | #define PKTGEN_CL_IP_TUN_V6_V6 PKTGEN_DELTA + 22 | |
98 | #define PKTGEN_CL_SCTP_IP_V6 PKTGEN_DELTA + 23 | |
99 | #define PKTGEN_CL_IP_V6_LAST_VALUE PKTGEN_CL_IP_TUN_V6_V6 | |
100 | // | |
101 | ||
102 | #define PKTGEN_CL_RUNT 200 | |
103 | ||
104 | // ERROR DEFINES | |
105 | ||
106 | #define PG_CHKSUM_ERR 0x1 | |
107 | #define PG_CHKSUM_USER_MODE 0x2 | |
108 | #define PG_CRC_ERR 0x4 | |
109 | #define PG_TYPE_LEN_ERR 0x8 | |
110 | #define PG_L4_PROTO_USER_MODE 0x10 | |
111 | #define PG_TYPE_LEN_USER_MODE 0x20 | |
112 | ||
113 | struct ether_packet_desc { | |
114 | uint8_t src_addr[6]; | |
115 | uint8_t dst_addr[6]; | |
116 | uint16_t vlan_id; | |
117 | uint16_t tci; | |
118 | uint16_t proto; | |
119 | } ether_packet_desc_t; | |
120 | ||
121 | struct arp_packet_desc { | |
122 | uint16_t hw_type; /* format of hardware addr, 0x01 for | |
123 | ethernet */ | |
124 | uint16_t proto_type; /* format of protocol addr, 0x0800 for | |
125 | IP */ | |
126 | uint8_t hw_len; /* length of hardware addr, 0x06 for | |
127 | ethernet */ | |
128 | uint8_t proto_len; /* length of protocol addr, 0x04 for | |
129 | IP */ | |
130 | uint16_t op_code; /* ARP opcode, 0x01 - ARP req, | |
131 | 0x02 - ARP reply, 0x03 - RARP req, | |
132 | 0x04 - RARP reply */ | |
133 | ||
134 | uint8_t src_ha[6]; /* sender hardware address */ | |
135 | uint8_t src_ip[4]; /* sender IP address */ | |
136 | uint8_t tgt_ha[6]; /* target hardware address */ | |
137 | uint8_t tgt_ip[4]; /* target IP address */ | |
138 | } arp_packet_desc_t; | |
139 | ||
140 | ||
141 | struct ip_packet_desc { | |
142 | // IPV4 ONLY | |
143 | uint32_t src_addr; | |
144 | uint32_t dst_addr; | |
145 | uint16_t proto; | |
146 | uint8_t options; | |
147 | uint8_t tos; | |
148 | uint16_t frag; | |
149 | } ip_packet_desc_t; | |
150 | struct ipv6_packet_desc { | |
151 | // IPV4 ONLY | |
152 | uint8_t src_addr[16]; | |
153 | uint8_t dst_addr[16]; | |
154 | uint8_t nexthdr; | |
155 | uint8_t tc; | |
156 | uint16_t frag; | |
157 | uint32_t ipv6FragId; | |
158 | } ipv6_packet_desc_t; | |
159 | ||
160 | ||
161 | struct tcp_packet_desc { | |
162 | uint8_t tcp_flags; | |
163 | uint16_t service; | |
164 | uint16_t src_port; | |
165 | uint16_t dst_port; | |
166 | uint16_t window; | |
167 | uint32_t seq_no; | |
168 | uint32_t ack_no; | |
169 | uint16_t checksum; | |
170 | } tcp_packet_desc_t; | |
171 | ||
172 | ||
173 | struct udp_packet_desc { | |
174 | uint16_t service; | |
175 | uint16_t src_port; | |
176 | uint16_t dst_port; | |
177 | uint16_t checksum; | |
178 | } udp_packet_desc_t; | |
179 | ||
180 | struct ipsec_ah_packet_desc { | |
181 | u_int8_t nh; | |
182 | u_int8_t len; | |
183 | u_int16_t res; | |
184 | u_int32_t spi; | |
185 | u_int32_t seq; | |
186 | u_int32_t auth; | |
187 | } ipsec_ah_packet_desc_t; | |
188 | ||
189 | struct sctp_packet_desc { | |
190 | u_int16_t src_port; /* source port */ | |
191 | u_int16_t dst_port; /* destination port */ | |
192 | u_int32_t vtag; /* verification tag */ | |
193 | u_int32_t checksum; /* checksum */ | |
194 | } sctp_packet_desc_t; | |
195 | // sbehera | |
196 | struct icmp_packet_desc { | |
197 | u_int8_t type; | |
198 | #define ICMP_TYPE_ECHO_REQ 1 | |
199 | #define ICMP_TYPE_ECHO_REPLY 2 | |
200 | u_int16_t checksum; | |
201 | u_int16_t id; | |
202 | u_int16_t seq; | |
203 | } icmp_packet_desc_t; | |
204 | ||
205 | // sbehera | |
206 | struct igmp_packet_desc { | |
207 | u_int8_t type; | |
208 | u_int16_t checksum; | |
209 | u_int32_t grp_ip; /* IGMP host IP */ | |
210 | } igmp_packet_desc_t; | |
211 | ||
212 | // sbehera | |
213 | struct pim_packet_desc { | |
214 | u_int8_t version; | |
215 | u_int8_t type; | |
216 | u_int16_t checksum; | |
217 | } pim_packet_desc_t; | |
218 | ||
219 | // sbehera | |
220 | struct rsvp_packet_desc { | |
221 | u_int8_t version; | |
222 | u_int8_t flags; | |
223 | u_int8_t type; | |
224 | u_int8_t ttl; | |
225 | u_int16_t checksum; | |
226 | int do_chksum; | |
227 | } rsvp_packet_desc_t; | |
228 | ||
229 | // sbehera | |
230 | /* GRE version 0 */ | |
231 | struct gre_packet_desc { | |
232 | uint8_t csum : 1, | |
233 | rout : 1, | |
234 | key : 1, | |
235 | seq : 1, | |
236 | rsvd : 4; | |
237 | uint16_t checksum; | |
238 | uint32_t key_val; | |
239 | uint32_t seq_num; | |
240 | } gre_packet_desc_t; | |
241 | ||
242 | // sbehera | |
243 | /* Enhanced GRE (GRE version 1) */ | |
244 | struct egre_packet_desc { | |
245 | uint8_t seq:1, | |
246 | ack:1, | |
247 | rsvd:6; | |
248 | uint16_t call_id; | |
249 | uint32_t seq_num; | |
250 | uint32_t ack_num; | |
251 | } egre_packet_desc_t; | |
252 | ||
253 | ||
254 | ||
255 | ||
256 | struct psd_hdr { | |
257 | uint32_t src_addr; | |
258 | uint32_t dst_addr; | |
259 | uint32_t zero:8; | |
260 | uint32_t proto:8; | |
261 | uint32_t len:16; | |
262 | } psd_hdr_t; | |
263 | ||
264 | struct payload_desc { | |
265 | uint32_t data_type ; | |
266 | uint32_t data_seed ; | |
267 | uint32_t error_code; | |
268 | uint32_t error_data; // used for user input based upon the error code | |
269 | uint32_t gId ; | |
270 | uint32_t data_length; | |
271 | uint32_t l2_pad_length; | |
272 | } payload_t; | |
273 | ||
274 | struct packet_desc { | |
275 | uint8_t frame_type; | |
276 | uint8_t frame_class; | |
277 | ||
278 | uint8_t l4_flag; /* Packet Type */ | |
279 | ||
280 | uint16_t l2_len; /* Ethernet packet len */ | |
281 | uint8_t l2_pkt_type; /* Packet Type */ | |
282 | uint16_t l2_hdr; /*l2 hdr length*/ | |
283 | ||
284 | uint16_t l3_len; /* L3 packet len */ | |
285 | uint8_t l3_pkt_type; /* Packet Type */ | |
286 | uint16_t l3_hdr; /*l3 hdr length*/ | |
287 | ||
288 | uint16_t l4_len; /* L4 packet len */ | |
289 | uint16_t l4_pkt_type; /* Packet Type */ | |
290 | uint16_t l4_hdr; /*l4 hdr length*/ | |
291 | ||
292 | uint8_t *buffer; /* Allocated Ethernet Buffer */ | |
293 | ||
294 | struct tcp_packet_desc tcp; | |
295 | struct udp_packet_desc udp; | |
296 | struct icmp_packet_desc icmp; | |
297 | struct igmp_packet_desc igmp; | |
298 | struct pim_packet_desc pim; | |
299 | struct gre_packet_desc gre; | |
300 | struct rsvp_packet_desc rsvp; | |
301 | struct egre_packet_desc egre; | |
302 | ||
303 | struct ip_packet_desc ip; | |
304 | struct sctp_packet_desc sctp; | |
305 | struct arp_packet_desc arp; | |
306 | struct ipv6_packet_desc ipv6; | |
307 | struct ipsec_ah_packet_desc ipsec_ah; | |
308 | struct ether_packet_desc ether; | |
309 | struct payload_desc payload; | |
310 | } packet_desc_t; | |
311 | ||
312 | ||
313 | ||
314 | #ifdef __cplusplus | |
315 | } | |
316 | #endif | |
317 | ||
318 | #endif /* _PACKET_H */ |