libnet  latest
A Portable Framework for Low-Level Network Packet Construction
libnet-headers.h
1 /*
2  *
3  * libnet-headers.h - Network routine library headers header file
4  *
5  * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 
31 #ifndef __LIBNET_HEADERS_H
32 #define __LIBNET_HEADERS_H
33 /*
34  * @file libnet-headers.h
35  * @brief libnet header information
36  */
37 
38 /*
39  * Libnet defines header sizes for every builder function exported.
40  */
41 #define LIBNET_802_1Q_H 0x12
42 #define LIBNET_802_1X_H 0x04
43 #define LIBNET_802_2_H 0x03
44 #define LIBNET_802_2SNAP_H 0x08
45 #define LIBNET_802_3_H 0x0e
46 #define LIBNET_ARP_H 0x08
47 #define LIBNET_ARP_ETH_IP_H 0x1c
48 #define LIBNET_BGP4_HEADER_H 0x13
49 #define LIBNET_BGP4_OPEN_H 0x0a
50 #define LIBNET_BGP4_UPDATE_H 0x04
51 #define LIBNET_BGP4_NOTIFICATION_H 0x02
52 #define LIBNET_CDP_H 0x08
53 #define LIBNET_DHCPV4_H 0xf0
54 #define LIBNET_UDP_DNSV4_H 0x0c
55 #define LIBNET_TCP_DNSV4_H 0x0e
56 #define LIBNET_ETH_H 0x0e
57 #define LIBNET_FDDI_H 0x15
58 #define LIBNET_ICMPV4_H 0x04
59 #define LIBNET_ICMPV4_ECHO_H 0x08
60 #define LIBNET_ICMPV4_MASK_H 0x0c
61 #define LIBNET_ICMPV4_UNREACH_H 0x08
62 #define LIBNET_ICMPV4_TIMXCEED_H 0x08
63 #define LIBNET_ICMPV4_REDIRECT_H 0x08
64 #define LIBNET_ICMPV4_TS_H 0x14
65 #define LIBNET_ICMPV6_COMMON_H 0x04
66 #define LIBNET_ICMPV6_H 0x08
67 #define LIBNET_ICMPV6_UNREACH_H 0x08
68 #define LIBNET_ICMPV6_ECHO_H 0x08
69 #define LIBNET_ICMPV6_NDP_NSOL_H 24
70 #define LIBNET_ICMPV6_NDP_NADV_H 24
71 #define LIBNET_ICMPV6_NDP_OPT_H 0x02
72 #define LIBNET_IGMP_H 0x08
73 #define LIBNET_IPV4_H 0x14
74 #define LIBNET_IPV6_H 0x28
75 #define LIBNET_IPV6_FRAG_H 0x08
76 #define LIBNET_IPV6_ROUTING_H 0x04
77 #define LIBNET_IPV6_DESTOPTS_H 0x02
78 #define LIBNET_IPV6_HBHOPTS_H 0x02
79 #define LIBNET_IPSEC_ESP_HDR_H 0x0c
80 #define LIBNET_IPSEC_ESP_FTR_H 0x02
81 #define LIBNET_IPSEC_AH_H 0x10
82 #define LIBNET_ISL_H 0x1a
83 #define LIBNET_GRE_H 0x04
84 #define LIBNET_GRE_SRE_H 0x04
85 #define LIBNET_MPLS_H 0x04
86 #define LIBNET_OSPF_H 0x10
87 #define LIBNET_OSPF_HELLO_H 0x18
88 #define LIBNET_OSPF_DBD_H 0x08
89 #define LIBNET_OSPF_LSR_H 0x0c
90 #define LIBNET_OSPF_LSU_H 0x04
91 #define LIBNET_OSPF_LSA_H 0x14
92 #define LIBNET_OSPF_AUTH_H 0x08
93 #define LIBNET_OSPF_CKSUM 0x10
94 #define LIBNET_OSPF_LS_RTR_H 0x10
95 #define LIBNET_OSPF_LS_NET_H 0x08
96 #define LIBNET_OSPF_LS_SUM_H 0x0c
97 #define LIBNET_OSPF_LS_AS_EXT_H 0x10
98 #define LIBNET_NTP_H 0x30
99 #define LIBNET_RIP_H 0x18
100 #define LIBNET_RPC_CALL_H 0x28
103 #define LIBNET_RPC_CALL_TCP_H 0x2c
106 #define LIBNET_SEBEK_H 0x30 /* sebek header: 48 bytes */
107 #define LIBNET_STP_CONF_H 0x23
108 #define LIBNET_STP_TCN_H 0x04
109 #define LIBNET_TOKEN_RING_H 0x16
110 #define LIBNET_TCP_H 0x14
111 #define LIBNET_UDP_H 0x08
112 #define LIBNET_VRRP_H 0x08
113 #define LIBNET_HSRP_H 0x14
115 /*
116  * IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header
117  * size: 18 bytes
118  */
119 struct libnet_802_1q_hdr
120 {
121  uint8_t vlan_dhost[ETHER_ADDR_LEN];
122  uint8_t vlan_shost[ETHER_ADDR_LEN];
123  uint16_t vlan_tpi;
124  uint16_t vlan_priority_c_vid;
125 #define LIBNET_802_1Q_PRIMASK 0x0007
126 #define LIBNET_802_1Q_CFIMASK 0x0001
127 #define LIBNET_802_1Q_VIDMASK 0x0fff
128  uint16_t vlan_len;
129 };
130 
131 /*
132  * IEEE 802.1X EAP (Extensible Authentication Protocol) header, static header
133  * size: 4 bytes
134  */
135 struct libnet_802_1x_hdr
136 {
137  uint8_t dot1x_version;
138  uint8_t dot1x_type;
139 #define LIBNET_802_1X_PACKET 0x00
140 #define LIBNET_802_1X_START 0x01
141 #define LIBNET_802_1X_LOGOFF 0x02
142 #define LIBNET_802_1X_KEY 0x03
143 #define LIBNET_802_1X_ENCASFAL 0x04
144  uint16_t dot1x_length;
145 };
146 
147 /*
148  * IEEE 802.2 LLC header
149  * Link Layer Control
150  * static header size: 3 bytes
151  */
152 struct libnet_802_2_hdr
153 {
154  uint8_t llc_dsap; /* destination service access point */
155  uint8_t llc_ssap; /* source service access point */
156 #define LIBNET_SAP_STP 0x42
157 #define LIBNET_SAP_SNAP 0xaa
158  uint8_t llc_control; /* control field */
159 };
160 
161 
162 /*
163  * IEEE 802.2 LLC/SNAP header
164  * SubNetwork Attachment Point
165  * static header size: 8 bytes
166  */
168 {
169  uint8_t snap_dsap; /* destination service access point */
170  uint8_t snap_ssap; /* destination service access point */
171  uint8_t snap_control; /* control field */
172  uint8_t snap_oui[3]; /* OUI */
173  uint16_t snap_type; /* type */
174 };
175 
176 
177 /*
178  * 802.3 header
179  * IEEE Ethernet
180  * Static header size: 14 bytes
181  */
182 struct libnet_802_3_hdr
183 {
184  uint8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
185  uint8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */
186  uint16_t _802_3_len; /* packet type ID */
187 };
188 
189 
190 /*
191  * ARP header
192  * Address Resolution Protocol
193  * Base header size: 8 bytes
194  */
195 struct libnet_arp_hdr
196 {
197  uint16_t ar_hrd; /* format of hardware address */
198 #define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */
199 #define ARPHRD_ETHER 1 /* Ethernet 10Mbps */
200 #define ARPHRD_EETHER 2 /* Experimental Ethernet */
201 #define ARPHRD_AX25 3 /* AX.25 Level 2 */
202 #define ARPHRD_PRONET 4 /* PROnet token ring */
203 #define ARPHRD_CHAOS 5 /* Chaosnet */
204 #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */
205 #define ARPHRD_ARCNET 7 /* ARCnet */
206 #define ARPHRD_APPLETLK 8 /* APPLEtalk */
207 #define ARPHRD_LANSTAR 9 /* Lanstar */
208 #define ARPHRD_DLCI 15 /* Frame Relay DLCI */
209 #define ARPHRD_ATM 19 /* ATM */
210 #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */
211 #define ARPHRD_IPSEC 31 /* IPsec tunnel */
212  uint16_t ar_pro; /* format of protocol address */
213  uint8_t ar_hln; /* length of hardware address */
214  uint8_t ar_pln; /* length of protocol address */
215  uint16_t ar_op; /* operation type */
216 #define ARPOP_REQUEST 1 /* req to resolve address */
217 #define ARPOP_REPLY 2 /* resp to previous request */
218 #define ARPOP_REVREQUEST 3 /* req protocol address given hardware */
219 #define ARPOP_REVREPLY 4 /* resp giving protocol address */
220 #define ARPOP_INVREQUEST 8 /* req to identify peer */
221 #define ARPOP_INVREPLY 9 /* resp identifying peer */
222  /* address information allocated dynamically */
223 };
224 
225 /*
226  * BGP4 header
227  * Border Gateway Protocol 4
228  * Base header size : 19 bytes
229  */
231 {
232 #define LIBNET_BGP4_MARKER_SIZE 16
233  uint8_t marker[LIBNET_BGP4_MARKER_SIZE];
234  uint16_t len;
235  uint8_t type;
236 #define LIBNET_BGP4_OPEN 1
237 #define LIBNET_BGP4_UPDATE 2
238 #define LIBNET_BGP4_NOTIFICATION 3
239 #define LIBNET_BGP4_KEEPALIVE 4
240 };
241 
242 /*
243  * BGP4 open header
244  * Border Gateway Protocol 4
245  * Base header size : 10 bytes
246  */
248 {
249  uint8_t version;
250  uint16_t src_as;
251  uint16_t hold_time;
252  uint32_t bgp_id;
253  uint8_t opt_len;
254 };
255 
256 /*
257  * BGP4 notification message
258  *
259  * Border Gateway Protocol 4
260  * Base header size : 2 bytes
261  *
262  * Use payload if you need data
263  */
265 {
266 #define LIBNET_BGP4_MESSAGE_HEADER_ERROR 1
267 #define LIBNET_BGP4_OPEN_MESSAGE_ERROR 2
268 #define LIBNET_BGP4_UPDATE_MESSAGE_ERROR 3
269 #define LIBNET_BGP4_HOLD_TIMER_EXPIRED 4
270 #define LIBNET_BGP4_FINITE_STATE__ERROR 5
271 #define LIBNET_BGP4_CEASE 6
272  uint8_t err_code;
273 
274 /* Message Header Error subcodes */
275 #define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED 1
276 #define LIBNET_BGP4_BAD_MESSAGE_LENGTH 2
277 #define LIBNET_BGP4_BAD_MESSAGE_TYPE 3
278 /* OPEN Message Error subcodes */
279 #define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER 1
280 #define LIBNET_BGP4_BAD_PEER_AS 2
281 #define LIBNET_BGP4_BAD_BGP_IDENTIFIER 3
282 #define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
283 #define LIBNET_BGP4_AUTHENTICATION_FAILURE 5
284 #define LIBNET_BGP4_UNACCEPTABLE_HOLD_TIME 6
285 /* UPDATE Message Error subcodes */
286 #define LIBNET_BGP4_MALFORMED_ATTRIBUTE_LIST
287 #define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
288 #define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
289 #define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR
290 #define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR
291 #define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE
292 #define LIBNET_BGP4_AS_ROUTING_LOOP
293 #define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
294 #define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR
295 #define LIBNET_BGP4_INVALID_NETWORK_FIELD
296 #define LIBNET_BGP4_MALFORMED_AS_PATH
297  uint8_t err_subcode;
298 };
299 
300 
301 
302 /*
303  * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
304  * Let's hope this one stays that way for a while!
305  */
306 #define LIBNET_PROTO_CDP 200
307 
308 /*
309  * CDP header
310  * Cisco Discovery Protocol
311  * Base header size: 8 bytes
312  */
313 struct libnet_cdp_hdr
314 {
315  uint8_t cdp_version; /* version (should always be 0x01) */
316  uint8_t cdp_ttl; /* time receiver should hold info in this packet */
317  uint16_t cdp_sum; /* checksum */
318  uint16_t cdp_type; /* type */
319 #define LIBNET_CDP_DEVID 0x1 /* device id */
320 #define LIBNET_CDP_ADDRESS 0x2 /* address */
321 #define LIBNET_CDP_PORTID 0x3 /* port id */
322 #define LIBNET_CDP_CAPABIL 0x4 /* capabilities */
323 #define LIBNET_CDP_VERSION 0x5 /* version */
324 #define LIBNET_CDP_PLATFORM 0x6 /* platform */
325 #define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */
326  uint16_t cdp_len; /* type + length + value */
327  /* value information done dynamically */
328 
329 /* CDP capabilities */
330 #define LIBNET_CDP_CAP_L3R 0x01/* performs level 3 routing */
331 #define LIBNET_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */
332 #define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */
333 #define LIBNET_CDP_CAP_L2S 0x08/* performs level 2 switching */
334 #define LIBNET_CDP_CAP_SR 0x10/* sends and recieves packets on a network */
335 #define LIBNET_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router ports */
336 #define LIBNET_CDP_CAP_L1F 0x40/* provides level 1 functionality */
337 };
338 
339 
340 /*
341  * Used as an overlay for type/len/values
342  */
343 #define LIBNET_CDP_VALUE_H 0x04 /*< CDP value header base: 4 bytes */
345 {
346  uint16_t cdp_type;
347  uint16_t cdp_len;
348 };
349 
350 
351 /*
352  * DHCP header
353  * Dynamic Host Configuration Protocol
354  * Static header size: f0 bytes
355  */
356 struct libnet_dhcpv4_hdr
357 {
358  uint8_t dhcp_opcode; /* opcode */
359 #define LIBNET_DHCP_REQUEST 0x1
360 #define LIBNET_DHCP_REPLY 0x2
361  uint8_t dhcp_htype; /* hardware address type */
362  uint8_t dhcp_hlen; /* hardware address length */
363  uint8_t dhcp_hopcount; /* used by proxy servers */
364  uint32_t dhcp_xid; /* transaction ID */
365  uint16_t dhcp_secs; /* number of seconds since trying to bootstrap */
366  uint16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */
367  uint32_t dhcp_cip; /* client's IP */
368  uint32_t dhcp_yip; /* your IP */
369  uint32_t dhcp_sip; /* server's IP */
370  uint32_t dhcp_gip; /* gateway IP */
371  uint8_t dhcp_chaddr[16]; /* client hardware address, len is dhcp_hlen */
372  char dhcp_sname[64]; /* server host name, null terminated string */
373  char dhcp_file[128]; /* boot file name, null terminated string */
374  uint32_t dhcp_magic; /* BOOTP magic header */
375 #define DHCP_MAGIC 0x63825363
376 #define LIBNET_BOOTP_MIN_LEN 0x12c
377 #define LIBNET_DHCP_PAD 0x00
378 #define LIBNET_DHCP_SUBNETMASK 0x01
379 #define LIBNET_DHCP_TIMEOFFSET 0x02
380 #define LIBNET_DHCP_ROUTER 0x03
381 #define LIBNET_DHCP_TIMESERVER 0x04
382 #define LIBNET_DHCP_NAMESERVER 0x05
383 #define LIBNET_DHCP_DNS 0x06
384 #define LIBNET_DHCP_LOGSERV 0x07
385 #define LIBNET_DHCP_COOKIESERV 0x08
386 #define LIBNET_DHCP_LPRSERV 0x09
387 #define LIBNET_DHCP_IMPSERV 0x0a
388 #define LIBNET_DHCP_RESSERV 0x0b
389 #define LIBNET_DHCP_HOSTNAME 0x0c
390 #define LIBNET_DHCP_BOOTFILESIZE 0x0d
391 #define LIBNET_DHCP_DUMPFILE 0x0e
392 #define LIBNET_DHCP_DOMAINNAME 0x0f
393 #define LIBNET_DHCP_SWAPSERV 0x10
394 #define LIBNET_DHCP_ROOTPATH 0x11
395 #define LIBNET_DHCP_EXTENPATH 0x12
396 #define LIBNET_DHCP_IPFORWARD 0x13
397 #define LIBNET_DHCP_SRCROUTE 0x14
398 #define LIBNET_DHCP_POLICYFILTER 0x15
399 #define LIBNET_DHCP_MAXASMSIZE 0x16
400 #define LIBNET_DHCP_IPTTL 0x17
401 #define LIBNET_DHCP_MTUTIMEOUT 0x18
402 #define LIBNET_DHCP_MTUTABLE 0x19
403 #define LIBNET_DHCP_MTUSIZE 0x1a
404 #define LIBNET_DHCP_LOCALSUBNETS 0x1b
405 #define LIBNET_DHCP_BROADCASTADDR 0x1c
406 #define LIBNET_DHCP_DOMASKDISCOV 0x1d
407 #define LIBNET_DHCP_MASKSUPPLY 0x1e
408 #define LIBNET_DHCP_DOROUTEDISC 0x1f
409 #define LIBNET_DHCP_ROUTERSOLICIT 0x20
410 #define LIBNET_DHCP_STATICROUTE 0x21
411 #define LIBNET_DHCP_TRAILERENCAP 0x22
412 #define LIBNET_DHCP_ARPTIMEOUT 0x23
413 #define LIBNET_DHCP_ETHERENCAP 0x24
414 #define LIBNET_DHCP_TCPTTL 0x25
415 #define LIBNET_DHCP_TCPKEEPALIVE 0x26
416 #define LIBNET_DHCP_TCPALIVEGARBAGE 0x27
417 #define LIBNET_DHCP_NISDOMAIN 0x28
418 #define LIBNET_DHCP_NISSERVERS 0x29
419 #define LIBNET_DHCP_NISTIMESERV 0x2a
420 #define LIBNET_DHCP_VENDSPECIFIC 0x2b
421 #define LIBNET_DHCP_NBNS 0x2c
422 #define LIBNET_DHCP_NBDD 0x2d
423 #define LIBNET_DHCP_NBTCPIP 0x2e
424 #define LIBNET_DHCP_NBTCPSCOPE 0x2f
425 #define LIBNET_DHCP_XFONT 0x30
426 #define LIBNET_DHCP_XDISPLAYMGR 0x31
427 #define LIBNET_DHCP_DISCOVERADDR 0x32
428 #define LIBNET_DHCP_LEASETIME 0x33
429 #define LIBNET_DHCP_OPTIONOVERLOAD 0x34
430 #define LIBNET_DHCP_MESSAGETYPE 0x35
431 #define LIBNET_DHCP_SERVIDENT 0x36
432 #define LIBNET_DHCP_PARAMREQUEST 0x37
433 #define LIBNET_DHCP_MESSAGE 0x38
434 #define LIBNET_DHCP_MAXMSGSIZE 0x39
435 #define LIBNET_DHCP_RENEWTIME 0x3a
436 #define LIBNET_DHCP_REBINDTIME 0x3b
437 #define LIBNET_DHCP_CLASSSID 0x3c
438 #define LIBNET_DHCP_CLIENTID 0x3d
439 #define LIBNET_DHCP_NISPLUSDOMAIN 0x40
440 #define LIBNET_DHCP_NISPLUSSERVERS 0x41
441 #define LIBNET_DHCP_MOBILEIPAGENT 0x44
442 #define LIBNET_DHCP_SMTPSERVER 0x45
443 #define LIBNET_DHCP_POP3SERVER 0x46
444 #define LIBNET_DHCP_NNTPSERVER 0x47
445 #define LIBNET_DHCP_WWWSERVER 0x48
446 #define LIBNET_DHCP_FINGERSERVER 0x49
447 #define LIBNET_DHCP_IRCSERVER 0x4a
448 #define LIBNET_DHCP_STSERVER 0x4b
449 #define LIBNET_DHCP_STDASERVER 0x4c
450 #define LIBNET_DHCP_END 0xff
451 
452 #define LIBNET_DHCP_MSGDISCOVER 0x01
453 #define LIBNET_DHCP_MSGOFFER 0x02
454 #define LIBNET_DHCP_MSGREQUEST 0x03
455 #define LIBNET_DHCP_MSGDECLINE 0x04
456 #define LIBNET_DHCP_MSGACK 0x05
457 #define LIBNET_DHCP_MSGNACK 0x06
458 #define LIBNET_DHCP_MSGRELEASE 0x07
459 #define LIBNET_DHCP_MSGINFORM 0x08
460 };
461 
462 
463 /* this little guy got left out in the cold */
464 #define LIBNET_DNS_H LIBNET_UDP_DNSV4_H
465 /*
466  * Base DNSv4 header
467  * Domain Name System
468  * Base header size: 12/14 bytes
469  */
470 struct libnet_dnsv4_hdr
471 {
472  uint16_t h_len; /* length of the packet - only used with TCP */
473  uint16_t id; /* DNS packet ID */
474  uint16_t flags; /* DNS flags */
475  uint16_t num_q; /* Number of questions */
476  uint16_t num_answ_rr; /* Number of answer resource records */
477  uint16_t num_auth_rr; /* Number of authority resource records */
478  uint16_t num_addi_rr; /* Number of additional resource records */
479 };
480 
481 #define LIBNET_DNS_H LIBNET_UDP_DNSV4_H
482 struct libnet_dnsv4udp_hdr
483 {
484  uint16_t id; /* DNS packet ID */
485  uint16_t flags; /* DNS flags */
486  uint16_t num_q; /* Number of questions */
487  uint16_t num_answ_rr; /* Number of answer resource records */
488  uint16_t num_auth_rr; /* Number of authority resource records */
489  uint16_t num_addi_rr; /* Number of additional resource records */
490 };
491 
492 /*
493  * Ethernet II header
494  * Static header size: 14 bytes
495  */
496 struct libnet_ethernet_hdr
497 {
498  uint8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
499  uint8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
500  uint16_t ether_type; /* protocol */
501 };
502 
503 #ifndef ETHERTYPE_PUP
504 #define ETHERTYPE_PUP 0x0200 /* PUP protocol */
505 #endif
506 #ifndef ETHERTYPE_IP
507 #define ETHERTYPE_IP 0x0800 /* IP protocol */
508 #endif
509 #ifndef ETHERTYPE_IPV6
510 #define ETHERTYPE_IPV6 0x86dd /* IPv6 protocol */
511 #endif
512 #ifndef ETHERTYPE_ARP
513 #define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */
514 #endif
515 #ifndef ETHERTYPE_REVARP
516 #define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
517 #endif
518 #ifndef ETHERTYPE_VLAN
519 #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */
520 #endif
521 #ifndef ETHERTYPE_EAP
522 #define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */
523 #endif
524 #ifndef ETHERTYPE_MPLS
525 #define ETHERTYPE_MPLS 0x8847 /* MPLS */
526 #endif
527 #ifndef ETHERTYPE_LOOPBACK
528 #define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */
529 #endif
530 
531 struct libnet_ether_addr
532 {
533  uint8_t ether_addr_octet[6]; /* Ethernet address */
534 };
536 /*
537  * Fiber Distributed Data Interface header
538  *
539  * Static header size: 21 bytes (LLC and 48-bit address addr only)
540  *
541  * Note: Organization field is 3 bytes which throws off the
542  * alignment of type. Therefore fddi_type (19 bytes in)
543  * is specified as two uint8_ts.
544  */
545 struct libnet_fddi_hdr
546 {
547  uint8_t fddi_frame_control; /* Class/Format/Priority */
548 #define LIBNET_FDDI_LLC_FRAME 0x10
549 #define LIBNET_FDDI_48BIT_ADDR 0x40
550 #define LIBNET_FDDI_FC_REQD LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_ADDR
551  uint8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */
552  uint8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */
553  uint8_t fddi_llc_dsap; /* DSAP */
554  uint8_t fddi_llc_ssap; /* SSAP */
555  uint8_t fddi_llc_control_field; /* Class/Format/Priority */
556  uint8_t fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code 3-bytes */
557  uint8_t fddi_type; /* Protocol Type */
558  uint8_t fddi_type1; /* see note above. */
559 #define FDDI_TYPE_IP 0x0800 /* IP protocol */
560 #define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */
561 #define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
562 };
563 
564 
565 struct libnet_fddi_addr
566 {
567  uint8_t fddi_addr_octet[6]; /* FDDI address */
568 };
570 
571 /*
572  * GRE header - RFC 1701 & 2637
573  * Generic Routing Encapsulation (GRE)
574  * Base header size: 4 bytes
575  */
576 struct libnet_gre_hdr
577 {
578  uint16_t flags_ver;
579 #define GRE_CSUM 0x8000
580 #define GRE_ROUTING 0x4000
581 #define GRE_KEY 0x2000
582 #define GRE_SEQ 0x1000
583 #define GRE_STRICT 0x0800
584 #define GRE_REC 0x0700
585 #define GRE_ACK 0x0080
586 
587 #define GRE_FLAGS_MASK 0x00F8
588 #define GRE_VERSION_MASK 0x0007
589 
590 #define GRE_VERSION_0 0x0000
591 #define GRE_VERSION_1 0x0001
592 
593  uint16_t type;
594 #define GRE_SNA 0x0004
595 #define GRE_OSI_NETWORK_LAYER 0x00FE
596 #define GRE_PUP 0x0200
597 #define GRE_XNS 0x0600
598 #define GRE_IP 0x0800
599 #define GRE_CHAOS 0x0804
600 #define GRE_RFC_826_ARP 0x0806
601 #define GRE_FRAME_RELAY_ARP 0x0808
602 #define GRE_VINES 0x0BAD
603 #define GRE_VINES_ECHO 0x0BAE
604 #define GRE_VINES_LOOPBACK 0x0BAF
605 #define GRE_DECNET 0x6003
606 #define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558
607 #define GRE_RAW_FRAME_RELAY 0x6559
608 #define GRE_APOLLO_DOMAIN 0x8019
609 #define GRE_ETHERTALK 0x809B
610 #define GRE_NOVELL_IPX 0x8137
611 #define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B
612 #define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C
613 #define GRE_SECURE_DATA 0x876D
614 #define GRE_PPP 0x880b /* taken from RFC 2637 */
615 
616  union {
617  struct {
618  uint16_t sum; /* optional */
619  uint16_t offset; /* optional */
620  uint32_t key; /* optional */
621  uint32_t seq; /* optional */
622  } _gre;
623 
624  struct {
625  uint16_t payload_s; /* optional */
626  uint16_t callID; /* optional */
627  uint32_t seq; /* optional */
628  uint32_t ack; /* optional */
629  } _egre;
630  }_data;
631 
632 #define gre_sum _data._gre.sum
633 #define gre_offset _data._gre.offset
634 #define gre_key _data._gre.key
635 #define gre_seq _data._gre.seq
636 
637 #define egre_payload_s _data._egre.payload_s
638 #define egre_callID _data._egre.callID
639 #define egre_seq _data._egre.seq
640 #define egre_ack _data._egre.ack
641 };
642 
643 
644 #ifndef IPPROTO_GRE
645 #define IPPROTO_GRE 47
646 #endif
647 
648 /*
649  * Source Route Entries (SRE)
650  * This is used for GRE as the Routing field is a list of SREs - RFC 1701
651  * Base header size: 4 bytes
652  */
653 struct libnet_gre_sre_hdr
654 {
655  uint16_t af; /* address familly */
656  uint8_t sre_offset;
657  uint8_t sre_length;
658  uint8_t *routing;
659 };
660 
661 
662 /*
663  * IPv4 header
664  * Internet Protocol, version 4
665  * Static header size: 20 bytes
666  */
667 struct libnet_ipv4_hdr
668 {
669 #if (LIBNET_LIL_ENDIAN)
670  uint8_t ip_hl:4, /* header length */
671  ip_v:4; /* version */
672 #endif
673 #if (LIBNET_BIG_ENDIAN)
674  uint8_t ip_v:4, /* version */
675  ip_hl:4; /* header length */
676 #endif
677  uint8_t ip_tos; /* type of service */
678 #ifndef IPTOS_LOWDELAY
679 #define IPTOS_LOWDELAY 0x10
680 #endif
681 #ifndef IPTOS_THROUGHPUT
682 #define IPTOS_THROUGHPUT 0x08
683 #endif
684 #ifndef IPTOS_RELIABILITY
685 #define IPTOS_RELIABILITY 0x04
686 #endif
687 #ifndef IPTOS_LOWCOST
688 #define IPTOS_LOWCOST 0x02
689 #endif
690  uint16_t ip_len; /* total length */
691  uint16_t ip_id; /* identification */
692  uint16_t ip_off;
693 #ifndef IP_RF
694 #define IP_RF 0x8000 /* reserved fragment flag */
695 #endif
696 #ifndef IP_DF
697 #define IP_DF 0x4000 /* dont fragment flag */
698 #endif
699 #ifndef IP_MF
700 #define IP_MF 0x2000 /* more fragments flag */
701 #endif
702 #ifndef IP_OFFMASK
703 #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
704 #endif
705  uint8_t ip_ttl; /* time to live */
706  uint8_t ip_p; /* protocol */
707  uint16_t ip_sum; /* checksum */
708  struct in_addr ip_src, ip_dst; /* source and dest address */
709 };
710 
711 /*
712  * IP options
713  */
714 #ifndef IPOPT_EOL
715 #define IPOPT_EOL 0 /* end of option list */
716 #endif
717 #ifndef IPOPT_NOP
718 #define IPOPT_NOP 1 /* no operation */
719 #endif
720 #ifndef IPOPT_RR
721 #define IPOPT_RR 7 /* record packet route */
722 #endif
723 #ifndef IPOPT_TS
724 #define IPOPT_TS 68 /* timestamp */
725 #endif
726 #ifndef IPOPT_SECURITY
727 #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
728 #endif
729 #ifndef IPOPT_LSRR
730 #define IPOPT_LSRR 131 /* loose source route */
731 #endif
732 #ifndef IPOPT_SATID
733 #define IPOPT_SATID 136 /* satnet id */
734 #endif
735 #ifndef IPOPT_SSRR
736 #define IPOPT_SSRR 137 /* strict source route */
737 #endif
738 
739 /*
740  * IPv6 address
741  */
742 struct libnet_in6_addr
743 {
744  union
745  {
746  uint8_t __u6_addr8[16];
747  uint16_t __u6_addr16[8];
748  uint32_t __u6_addr32[4];
749  } __u6_addr; /* 128-bit IP6 address */
750 };
751 #define libnet_s6_addr __u6_addr.__u6_addr8
752 
753 /*
754  * IPv6 header
755  * Internet Protocol, version 6
756  * Static header size: 40 bytes
757  */
758 struct libnet_ipv6_hdr
759 {
760  uint8_t ip_flags[4]; /* version, traffic class, flow label */
761  uint16_t ip_len; /* total length */
762  uint8_t ip_nh; /* next header */
763  uint8_t ip_hl; /* hop limit */
764  struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */
765 
766 };
767 
768 /*
769  * IPv6 frag header
770  * Internet Protocol, version 6
771  * Static header size: 8 bytes
772  */
773 #define LIBNET_IPV6_NH_FRAGMENT 44
775 {
776  uint8_t ip_nh; /* next header */
777  uint8_t ip_reserved; /* reserved */
778  uint16_t ip_frag; /* fragmentation stuff */
779  uint32_t ip_id; /* id */
780 };
781 
782 /*
783  * IPv6 routing header
784  * Internet Protocol, version 6
785  * Base header size: 4 bytes
786  */
787 #define LIBNET_IPV6_NH_ROUTING 43
789 {
790  uint8_t ip_nh; /* next header */
791  uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
792  uint8_t ip_rtype; /* routing type */
793  uint8_t ip_segments; /* segments left */
794  /* routing information allocated dynamically */
795 };
796 
797 /*
798  * IPv6 destination options header
799  * Internet Protocol, version 6
800  * Base header size: 2 bytes
801  */
802 #define LIBNET_IPV6_NH_DESTOPTS 60
804 {
805  uint8_t ip_nh; /* next header */
806  uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
807  /* destination options information allocated dynamically */
808 };
809 
810 /*
811  * IPv6 hop by hop options header
812  * Internet Protocol, version 6
813  * Base header size: 2 bytes
814  */
815 #define LIBNET_IPV6_NH_HBH 0
817 {
818  uint8_t ip_nh; /* next header */
819  uint8_t ip_len; /* length of header in 8 octet units (sans 1st) */
820  /* destination options information allocated dynamically */
821 };
822 
823 /*
824  * ICMP6 header
825  * Internet Control Message Protocol v6
826  * Base header size: 4 bytes
827  */
828 #ifndef IPPROTO_ICMPV6
829 #define IPPROTO_ICMPV6 58
830 #endif
831 struct libnet_icmpv6_hdr
832 {
833  uint8_t icmp_type; /* ICMP type */
834 /* Don't define if <netinet/icmp6.h> has defined them. */
835 #ifndef ICMP6_ECHO_REQUEST
836 #define ICMP6_ECHO_REQUEST 128
837 #endif
838 #ifndef ICMP6_ECHO_REPLY
839 #define ICMP6_ECHO_REPLY 129
840 #endif
841 #ifndef ICMP6_DST_UNREACH
842 #define ICMP6_DST_UNREACH 1
843 #endif
844 #ifndef ICMP6_PACKET_TOO_BIG
845 #define ICMP6_PACKET_TOO_BIG 2
846 #endif
847 #ifndef ICMP6_TIME_EXCEEDED
848 #define ICMP6_TIME_EXCEEDED 3
849 #endif
850 #ifndef ICMP6_PARAM_PROB
851 #define ICMP6_PARAM_PROB 4
852 #endif
853 
854 #ifndef ND_ROUTER_SOLICIT
855 #define ND_ROUTER_SOLICIT 133
856 #endif
857 #ifndef ND_ROUTER_ADVERT
858 #define ND_ROUTER_ADVERT 134
859 #endif
860 #ifndef ND_NEIGHBOR_SOLICIT
861 #define ND_NEIGHBOR_SOLICIT 135
862 #endif
863 #ifndef ND_NEIGHBOR_ADVERT
864 #define ND_NEIGHBOR_ADVERT 136
865 #endif
866 
867  uint8_t icmp_code; /* ICMP code */
868 #ifndef ICMP6_DST_UNREACH_NOROUTE
869 #define ICMP6_DST_UNREACH_NOROUTE 0
870 #endif
871 #ifndef ICMP6_DST_UNREACH_ADMIN
872 #define ICMP6_DST_UNREACH_ADMIN 1
873 #endif
874 #ifndef ICMP6_DST_UNREACH_BEYONDSCOPE
875 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2
876 #endif
877 #ifndef ICMP6_DST_UNREACH_ADDR
878 #define ICMP6_DST_UNREACH_ADDR 3
879 #endif
880 #ifndef ICMP6_DST_UNREACH_NOPORT
881 #define ICMP6_DST_UNREACH_NOPORT 4
882 #endif
883  uint16_t icmp_sum; /* ICMP Checksum */
884 
885  /* This is confusing: id/seq are used only for echo req/reply, but must
886  * exist in struct for backwards compatibility. */
887  uint16_t id; /* ICMP id (unused, for backwards compatibility) */
888  uint16_t seq; /* ICMP sequence number (unused, for backwards compatibility) */
889 
890  /* Non-standard names, for libnet backwards compatibility, don't use. */
891  /* ipproto: */
892 #define IPPROTO_ICMP6 58
893  /* types: */
894 #define ICMP6_ECHO 128
895 #define ICMP6_ECHOREPLY 129
896 #define ICMP6_UNREACH 1
897 #define ICMP6_PKTTOOBIG 2
898 #define ICMP6_TIMXCEED 3
899 #define ICMP6_PARAMPROB 4
900  /* codes: */
901 #define ICMP6_NOROUTE 0
902 #define ICMP6_ADM_PROHIBITED 1
903 #define ICMP6_NOT_NEIGHBOUR 2
904 #define ICMP6_ADDR_UNREACH 3
905 #define ICMP6_PORT_UNREACH 4
906 };
907 
908 /* All of this stuff follows base ICMPv6 header */
909 
910 struct libnet_icmpv6_unreach {
911  uint32_t unused;
912 };
913 
915  uint16_t id;
916  uint16_t seq;
917 };
919 struct libnet_icmpv6_ndp_nsol {
920  uint32_t reserved;
921  struct libnet_in6_addr target_addr;
922 };
924 struct libnet_icmpv6_ndp_nadv {
925  uint32_t flags;
926 #ifndef ND_NA_FLAG_ROUTER
927 #define ND_NA_FLAG_ROUTER 0x80000000
928 #endif
929 #ifndef ND_NA_FLAG_SOLICITED
930 #define ND_NA_FLAG_SOLICITED 0x40000000
931 #endif
932 #ifndef ND_NA_FLAG_OVERRIDE
933 #define ND_NA_FLAG_OVERRIDE 0x20000000
934 #endif
935  struct libnet_in6_addr target_addr;
936 };
937 
938 struct libnet_icmpv6_ndp_opt {
939  uint8_t type;
940 #ifndef ND_OPT_SOURCE_LINKADDR
941 #define ND_OPT_SOURCE_LINKADDR 1
942 #endif
943 #ifndef ND_OPT_TARGET_LINKADDR
944 #define ND_OPT_TARGET_LINKADDR 2
945 #endif
946 #ifndef ND_OPT_PREFIX_INFORMATION
947 #define ND_OPT_PREFIX_INFORMATION 3
948 #endif
949 #ifndef ND_OPT_REDIRECTED_HEADER
950 #define ND_OPT_REDIRECTED_HEADER 4
951 #endif
952 #ifndef ND_OPT_MTU
953 #define ND_OPT_MTU 5
954 #endif
955 #ifndef ND_OPT_RTR_ADV_INTERVAL
956 #define ND_OPT_RTR_ADV_INTERVAL 7
957 #endif
958 #ifndef ND_OPT_HOME_AGENT_INFO
959 #define ND_OPT_HOME_AGENT_INFO 8
960 #endif
961  uint8_t len;
962 };
963 
964 
965 /*
966  * ICMP header
967  * Internet Control Message Protocol
968  * Base header size: 4 bytes
969  */
970 struct libnet_icmpv4_hdr
971 {
972  uint8_t icmp_type; /* ICMP type */
973 #ifndef ICMP_ECHOREPLY
974 #define ICMP_ECHOREPLY 0
975 #endif
976 #ifndef ICMP_UNREACH
977 #define ICMP_UNREACH 3
978 #endif
979 #ifndef ICMP_SOURCEQUENCH
980 #define ICMP_SOURCEQUENCH 4
981 #endif
982 #ifndef ICMP_REDIRECT
983 #define ICMP_REDIRECT 5
984 #endif
985 #ifndef ICMP_ECHO
986 #define ICMP_ECHO 8
987 #endif
988 #ifndef ICMP_ROUTERADVERT
989 #define ICMP_ROUTERADVERT 9
990 #endif
991 #ifndef ICMP_ROUTERSOLICIT
992 #define ICMP_ROUTERSOLICIT 10
993 #endif
994 #ifndef ICMP_TIMXCEED
995 #define ICMP_TIMXCEED 11
996 #endif
997 #ifndef ICMP_PARAMPROB
998 #define ICMP_PARAMPROB 12
999 #endif
1000 #ifndef ICMP_TSTAMP
1001 #define ICMP_TSTAMP 13
1002 #endif
1003 #ifndef ICMP_TSTAMPREPLY
1004 #define ICMP_TSTAMPREPLY 14
1005 #endif
1006 #ifndef ICMP_IREQ
1007 #define ICMP_IREQ 15
1008 #endif
1009 #ifndef ICMP_IREQREPLY
1010 #define ICMP_IREQREPLY 16
1011 #endif
1012 #ifndef ICMP_MASKREQ
1013 #define ICMP_MASKREQ 17
1014 #endif
1015 #ifndef ICMP_MASKREPLY
1016 #define ICMP_MASKREPLY 18
1017 #endif
1018  uint8_t icmp_code; /* ICMP code */
1019 #ifndef ICMP_UNREACH_NET
1020 #define ICMP_UNREACH_NET 0
1021 #endif
1022 #ifndef ICMP_UNREACH_HOST
1023 #define ICMP_UNREACH_HOST 1
1024 #endif
1025 #ifndef ICMP_UNREACH_PROTOCOL
1026 #define ICMP_UNREACH_PROTOCOL 2
1027 #endif
1028 #ifndef ICMP_UNREACH_PORT
1029 #define ICMP_UNREACH_PORT 3
1030 #endif
1031 #ifndef ICMP_UNREACH_NEEDFRAG
1032 #define ICMP_UNREACH_NEEDFRAG 4
1033 #endif
1034 #ifndef ICMP_UNREACH_SRCFAIL
1035 #define ICMP_UNREACH_SRCFAIL 5
1036 #endif
1037 #ifndef ICMP_UNREACH_NET_UNKNOWN
1038 #define ICMP_UNREACH_NET_UNKNOWN 6
1039 #endif
1040 #ifndef ICMP_UNREACH_HOST_UNKNOWN
1041 #define ICMP_UNREACH_HOST_UNKNOWN 7
1042 #endif
1043 #ifndef ICMP_UNREACH_ISOLATED
1044 #define ICMP_UNREACH_ISOLATED 8
1045 #endif
1046 #ifndef ICMP_UNREACH_NET_PROHIB
1047 #define ICMP_UNREACH_NET_PROHIB 9
1048 #endif
1049 #ifndef ICMP_UNREACH_HOST_PROHIB
1050 #define ICMP_UNREACH_HOST_PROHIB 10
1051 #endif
1052 #ifndef ICMP_UNREACH_TOSNET
1053 #define ICMP_UNREACH_TOSNET 11
1054 #endif
1055 #ifndef ICMP_UNREACH_TOSHOST
1056 #define ICMP_UNREACH_TOSHOST 12
1057 #endif
1058 #ifndef ICMP_UNREACH_FILTER_PROHIB
1059 #define ICMP_UNREACH_FILTER_PROHIB 13
1060 #endif
1061 #ifndef ICMP_UNREACH_HOST_PRECEDENCE
1062 #define ICMP_UNREACH_HOST_PRECEDENCE 14
1063 #endif
1064 #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
1065 #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
1066 #endif
1067 #ifndef ICMP_REDIRECT_NET
1068 #define ICMP_REDIRECT_NET 0
1069 #endif
1070 #ifndef ICMP_REDIRECT_HOST
1071 #define ICMP_REDIRECT_HOST 1
1072 #endif
1073 #ifndef ICMP_REDIRECT_TOSNET
1074 #define ICMP_REDIRECT_TOSNET 2
1075 #endif
1076 #ifndef ICMP_REDIRECT_TOSHOST
1077 #define ICMP_REDIRECT_TOSHOST 3
1078 #endif
1079 #ifndef ICMP_TIMXCEED_INTRANS
1080 #define ICMP_TIMXCEED_INTRANS 0
1081 #endif
1082 #ifndef ICMP_TIMXCEED_REASS
1083 #define ICMP_TIMXCEED_REASS 1
1084 #endif
1085 #ifndef ICMP_PARAMPROB_OPTABSENT
1086 #define ICMP_PARAMPROB_OPTABSENT 1
1087 #endif
1088 
1089  uint16_t icmp_sum; /* ICMP Checksum */
1090 
1091  union
1092  {
1093  struct
1094  {
1095  uint16_t id; /* ICMP id */
1096  uint16_t seq;/* ICMP sequence number */
1097  } echo;
1098 
1099  /* TODO this hack conflicts with the system headers, which is why we
1100  * undef what they do, and it also damages dnet/dumbnet's headers if
1101  * they are included after ours. Fixing will break API, though, so
1102  * we leave it for now.
1103  */
1104 #undef icmp_id
1105 #undef icmp_seq
1106 #define icmp_id hun.echo.id
1107 #define icmp_seq hun.echo.seq
1108 
1109  uint32_t gateway; /* gateway host */
1110  struct
1111  {
1112  uint16_t pad;/* padding */
1113  uint16_t mtu;/* MTU size */
1114  } frag;
1115  } hun;
1116  union
1117  {
1118  struct
1119  {
1120  uint32_t its_otime;
1121  uint32_t its_rtime;
1122  uint32_t its_ttime;
1123  } ts;
1124  struct
1125  {
1126  struct libnet_ipv4_hdr idi_ip;
1127  /* options and then 64 bits of data */
1128  } ip;
1129  uint32_t mask;
1130  int8_t data[1];
1131 
1132 #undef icmp_mask
1133 #define icmp_mask dun.mask
1134 #undef icmp_data
1135 #define icmp_data dun.data
1136 
1137 #undef icmp_otime
1138 #define icmp_otime dun.ts.its_otime
1139 #undef icmp_rtime
1140 #define icmp_rtime dun.ts.its_rtime
1141 #undef icmp_ttime
1142 #define icmp_ttime dun.ts.its_ttime
1143  }dun;
1144 };
1145 
1146 
1147 /*
1148  * IGMP header
1149  * Internet Group Message Protocol
1150  * Static header size: 8 bytes
1151  */
1152 struct libnet_igmp_hdr
1153 {
1154  uint8_t igmp_type; /* IGMP type */
1155 #ifndef IGMP_MEMBERSHIP_QUERY
1156 #define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */
1157 #endif
1158 #ifndef IGMP_V1_MEMBERSHIP_REPORT
1159 #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */
1160 #endif
1161 #ifndef IGMP_V2_MEMBERSHIP_REPORT
1162 #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */
1163 #endif
1164 #ifndef IGMP_LEAVE_GROUP
1165 #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
1166 #endif
1167  uint8_t igmp_code; /* IGMP reserved field (0), mistakenly called 'code' in early libnet versions */
1168  uint16_t igmp_sum; /* IGMP checksum */
1169  struct in_addr igmp_group;/* IGMP host IP */
1170 };
1171 
1172 
1173 /*
1174  * IPSEC header
1175  * Internet Protocol Security Protocol
1176  * Encapsulating Security Payload Header Static header size: 12 bytes
1177  * Encapsulating Security Payload Footer Base header size: 2 bytes
1178  * Authentication Header Static Size: 16 bytes
1179  */
1180 #ifndef IPPROTO_ESP
1181 #define IPPROTO_ESP 50 /* not everyone's got this */
1182 #endif
1183 struct libnet_esp_hdr
1184 {
1185  uint32_t esp_spi; /* security parameter index */
1186  uint32_t esp_seq; /* ESP sequence number */
1187  uint32_t esp_iv; /* initialization vector */
1188 };
1189 
1190 struct libnet_esp_ftr
1191 {
1192  uint8_t esp_pad_len; /* padding length */
1193  uint8_t esp_nh; /* next header pointer */
1194  int8_t *esp_auth; /* authentication data */
1195 };
1196 
1197 #ifndef IPPROTO_AH
1198 #define IPPROTO_AH 51 /* not everyone's got this */
1199 #endif
1200 struct libnet_ah_hdr
1201 {
1202  uint8_t ah_nh; /* next header */
1203  uint8_t ah_len; /* payload length */
1204  uint16_t ah_res; /* reserved */
1205  uint32_t ah_spi; /* security parameter index */
1206  uint32_t ah_seq; /* AH sequence number */
1207  uint32_t ah_auth; /* authentication data */
1208 };
1209 
1210 
1211 /*
1212  * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
1213  * Let's hope this one stays that way for a while!
1214  */
1215 #define LIBNET_PROTO_ISL 201
1216 /*
1217  * ISL header
1218  * Cisco Inter-Switch Link
1219  * Static header size: 26 bytes
1220  */
1221 struct libnet_isl_hdr
1222 {
1223  uint8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */
1224 #if (LIBNET_LIL_ENDIAN)
1225  uint8_t isl_type:4, /* type of frame */
1226  isl_user:4; /* user defined bits */
1227 #endif
1228 #if (LIBNET_BIG_ENDIAN)
1229  uint8_t isl_user:4, /* user defined bits */
1230  isl_type:4; /* type of frame */
1231 #endif
1232  uint8_t isl_shost[6]; /* source address */
1233  uint16_t isl_len; /* total length of packet - 18 bytes */
1234  uint8_t isl_snap[6]; /* 0xaaaa03 + vendor code */
1235  uint16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */
1236  uint16_t isl_index; /* port index */
1237  uint16_t isl_reserved; /* used for FDDI and token ring */
1238  /* ethernet frame and 4 byte isl crc */
1239 };
1240 
1241 #ifndef IPPROTO_OSPF
1242 #define IPPROTO_OSPF 89 /* not everyone's got this */
1243 #endif
1244 #define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */
1245 #define LIBNET_MODX 4102 /* used in LSA checksum */
1246 
1247 /*
1248  * Options used in multiple OSPF packets
1249  * More info can be found in section A.2 of RFC 2328.
1250  */
1251 #define LIBNET_OPT_EBIT 0x02 /* describes the way AS-external-LSAs are flooded */
1252 #define LIBNET_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */
1253 #define LIBNET_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */
1254 #define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */
1255 #define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits */
1256 
1257 
1258 /*
1259  * MPLS header
1260  * Multi-Protocol Label Switching
1261  * Static header size: 4 bytes
1262  */
1263 struct libnet_mpls_hdr
1264 {
1265  uint32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, ttl */
1266 #define LIBNET_MPLS_BOS_ON 1
1267 #define LIBNET_MPLS_BOS_OFF 0
1268 };
1269 
1270 /*
1271  * NTP header
1272  * Network Time Protocol
1273  * Static header size: 48 bytes
1274  */
1275 struct libnet_ntp_hdr_l_fp /* int32_t floating point (64-bit) */
1276 {
1277  uint32_t integer; /* integer */
1278  uint32_t fraction; /* fraction */
1279 };
1280 
1281 struct libnet_ntp_hdr_s_fp /* int16_t floating point (32-bit) */
1282 {
1283  uint16_t integer; /* integer */
1284  uint16_t fraction; /* fraction */
1285 };
1286 
1287 
1288 struct libnet_ntp_hdr
1289 {
1290  uint8_t ntp_li_vn_mode; /* leap indicator, version, mode */
1291 #define LIBNET_NTP_LI_NW 0x0 /* no warning */
1292 #define LIBNET_NTP_LI_AS 0x1 /* last minute has 61 seconds */
1293 #define LIBNET_NTP_LI_DS 0x2 /* last minute has 59 seconds */
1294 #define LIBNET_NTP_LI_AC 0x3 /* alarm condition */
1295 
1296 #define LIBNET_NTP_VN_2 0x2 /* version 2 */
1297 #define LIBNET_NTP_VN_3 0x3 /* version 3 */
1298 #define LIBNET_NTP_VN_4 0x4 /* version 4 */
1299 
1300 #define LIBNET_NTP_MODE_R 0x0 /* reserved */
1301 #define LIBNET_NTP_MODE_A 0x1 /* symmetric active */
1302 #define LIBNET_NTP_MODE_P 0x2 /* symmetric passive */
1303 #define LIBNET_NTP_MODE_C 0x3 /* client */
1304 #define LIBNET_NTP_MODE_S 0x4 /* server */
1305 #define LIBNET_NTP_MODE_B 0x5 /* broadcast */
1306 #define LIBNET_NTP_MODE_RC 0x6 /* reserved for NTP control message */
1307 #define LIBNET_NTP_MODE_RP 0x7 /* reserved for private use */
1308  uint8_t ntp_stratum; /* stratum */
1309 #define LIBNET_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */
1310 #define LIBNET_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */
1311  /* 2 - 15 is secondary */
1312  /* 16 - 255 is reserved */
1313  uint8_t ntp_poll; /* poll interval (should be 4 - 12) */
1314  uint8_t ntp_precision; /* local clock precision */
1315  struct libnet_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */
1316  struct libnet_ntp_hdr_s_fp ntp_dispersion; /* nominal error */
1317  uint32_t ntp_reference_id; /* reference source id */
1318 #define LIBNET_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */
1319 #define LIBNET_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second clock */
1320 #define LIBNET_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */
1321 #define LIBNET_NTP_REF_USNO 0x55534e4f /* USNO modem service */
1322 #define LIBNET_NTP_REF_PTB 0x50544200 /* PTB (German) modem service */
1323 #define LIBNET_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */
1324 #define LIBNET_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio */
1325 #define LIBNET_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */
1326 #define LIBNET_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */
1327 #define LIBNET_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */
1328 #define LIBNET_NTP_REF_WWVH 0x57575648 /* Kaui Hawaii (US) radio */
1329 #define LIBNET_NTP_REF_CHU 0x43485500 /* Ottaha (Canada) radio */
1330 #define LIBNET_NTP_REF_LORC 0x4c4f5243 /* LORAN-C radionavigation */
1331 #define LIBNET_NTP_REF_OMEG 0x4f4d4547 /* OMEGA radionavigation */
1332 #define LIBNET_NTP_REF_GPS 0x47505300 /* global positioning system */
1333 #define LIBNET_NTP_REF_GOES 0x474f4553 /* geostationary orbit env satellite */
1334  struct libnet_ntp_hdr_l_fp ntp_ref_ts; /* reference timestamp */
1335  struct libnet_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */
1336  struct libnet_ntp_hdr_l_fp ntp_rec_ts; /* receive timestamp */
1337  struct libnet_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */
1338 };
1339 
1340 
1341 /*
1342  * OSPFv2 header
1343  * Open Shortest Path First
1344  * Static header size: 16 bytes
1345  */
1346 struct libnet_ospf_hdr
1347 {
1348  uint8_t ospf_v; /* version */
1349 #define OSPFVERSION 2
1350  uint8_t ospf_type; /* type */
1351 #define LIBNET_OSPF_UMD 0 /* UMd monitoring packet */
1352 #define LIBNET_OSPF_HELLO 1 /* HELLO packet */
1353 #define LIBNET_OSPF_DBD 2 /* dataBase description packet */
1354 #define LIBNET_OSPF_LSR 3 /* link state request packet */
1355 #define LIBNET_OSPF_LSU 4 /* link state Update Packet */
1356 #define LIBNET_OSPF_LSA 5 /* link state acknowledgement packet */
1357  uint16_t ospf_len; /* length */
1358  struct in_addr ospf_rtr_id; /* source router ID */
1359  struct in_addr ospf_area_id;/* roam ID */
1360  uint16_t ospf_sum; /* checksum */
1361  uint16_t ospf_auth_type; /* authentication type */
1362 #define LIBNET_OSPF_AUTH_NULL 0 /* null password */
1363 #define LIBNET_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */
1364 #define LIBNET_OSPF_AUTH_MD5 2 /* MD5 */
1365 };
1366 
1367 
1368 /*
1369  * OSPF authentication header
1370  * Open Shortest Path First
1371  * Static header size: 8 bytes
1372  */
1373 struct libnet_auth_hdr
1374 {
1375  uint16_t ospf_auth_null; /* NULL */
1376  uint8_t ospf_auth_keyid; /* authentication key ID */
1377  uint8_t ospf_auth_len; /* auth data length */
1378  uint32_t ospf_auth_seq; /* cryptographic sequence number */
1379 };
1380 
1381 
1382 /*
1383  * OSPF hello header
1384  * Open Shortest Path First
1385  * Static header size: 28 bytes
1386  */
1387 struct libnet_ospf_hello_hdr
1388 {
1389  struct in_addr hello_nmask; /* netmask associated with the interface */
1390  uint16_t hello_intrvl; /* num of seconds between routers last packet */
1391  uint8_t hello_opts; /* Options for HELLO packets (look above) */
1392  uint8_t hello_rtr_pri; /* router's priority (if 0, can't be backup) */
1393  uint32_t hello_dead_intvl; /* # of secs a router is silent till deemed down */
1394  struct in_addr hello_des_rtr; /* Designated router on the network */
1395  struct in_addr hello_bkup_rtr; /* Backup router */
1396  struct in_addr hello_nbr; /* neighbor router, memcpy more as needed */
1397 };
1398 
1399 
1400 /*
1401  * Database Description header.
1402  */
1403 struct libnet_dbd_hdr
1404 {
1405  uint16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can use */
1406  uint8_t dbd_opts; /* DBD packet options (from above) */
1407  uint8_t dbd_type; /* type of exchange occurring */
1408 #define LIBNET_DBD_IBI 0x01 /* init */
1409 #define LIBNET_DBD_MBIT 0x02 /* more DBD packets are to come */
1410 #define LIBNET_DBD_MSBIT 0x04 /* If 1, sender is the master in the exchange */
1411  uint32_t dbd_seq; /* DBD sequence number */
1412 };
1413 
1414 
1415 /*
1416  * used for the LS type field in all LS* headers
1417  */
1418 #define LIBNET_LS_TYPE_RTR 1 /* router-LSA */
1419 #define LIBNET_LS_TYPE_NET 2 /* network-LSA */
1420 #define LIBNET_LS_TYPE_IP 3 /* summary-LSA (IP Network) */
1421 #define LIBNET_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */
1422 #define LIBNET_LS_TYPE_ASEXT 5 /* AS-external-LSA */
1423 
1424 
1425 /*
1426  * Link State Request header
1427  */
1428 struct libnet_lsr_hdr
1429 {
1430  uint32_t lsr_type; /* type of LS being requested */
1431  uint32_t lsr_lsid; /* link state ID */
1432  struct in_addr lsr_adrtr; /* advertising router (memcpy more as needed) */
1433 };
1434 
1435 
1436 /*
1437  * Link State Update header
1438  */
1439 struct libnet_lsu_hdr
1440 {
1441  uint32_t lsu_num; /* number of LSAs that will be broadcasted */
1442 };
1444 
1445 /*
1446  * Link State Acknowledgement header.
1447  */
1448 struct libnet_lsa_hdr
1449 {
1450  uint16_t lsa_age; /* time in seconds since the LSA was originated */
1451  uint8_t lsa_opts; /* look above for OPTS_* */
1452  uint8_t lsa_type; /* look below for LS_TYPE_* */
1453  uint32_t lsa_id; /* link State ID */
1454  struct in_addr lsa_adv; /* router ID of Advertising router */
1455  uint32_t lsa_seq; /* LSA sequence number to detect old/bad ones */
1456  uint16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age */
1457  uint16_t lsa_len; /* length in bytes including the 20 byte header */
1458 };
1459 
1460 
1461 /*
1462  * Router LSA data format
1463  *
1464  * Other stuff for TOS can be added for backward compatability, for this
1465  * version, only OSPFv2 is being FULLY supported.
1466  */
1467 struct libnet_rtr_lsa_hdr
1468 {
1469  uint16_t rtr_flags; /* set to help describe packet */
1470 #define LIBNET_RTR_FLAGS_W 0x0100 /* W bit */
1471 #define LIBNET_RTR_FLAGS_E 0x0200 /* E bit */
1472 #define LIBNET_RTR_FLAGS_B 0x0400 /* B bit */
1473  uint16_t rtr_num; /* number of links within that packet */
1474  uint32_t rtr_link_id; /* describes link_data (look below) */
1475 #define LIBNET_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 */
1476 #define LIBNET_LINK_ID_IP_DES 2 /* IP address of designated router */
1477 #define LIBNET_LINK_ID_SUB 3 /* IP subnet number */
1478  uint32_t rtr_link_data; /* Depending on link_id, info is here */
1479  uint8_t rtr_type; /* Description of router link */
1480 #define LIBNET_RTR_TYPE_PTP 1 /* Point-To-Point */
1481 #define LIBNET_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */
1482 #define LIBNET_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */
1483 #define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */
1484  uint8_t rtr_tos_num; /* number of different TOS metrics for this link */
1485  uint16_t rtr_metric; /* the "cost" of using this link */
1486 };
1487 
1488 
1489 /*
1490  * Network LSA data format.
1491  */
1492 struct libnet_net_lsa_hdr
1493 {
1494  struct in_addr net_nmask; /* Netmask for that network */
1495  uint32_t net_rtr_id; /* ID of router attached to that network */
1496 };
1497 
1498 
1499 /*
1500  * Summary LSA data format.
1501  */
1502 struct libnet_sum_lsa_hdr
1503 {
1504  struct in_addr sum_nmask; /* Netmask of destination IP address */
1505  uint32_t sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24bit */
1506  uint32_t sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metric */
1507 };
1508 
1509 
1510 /*
1511  * AS External LSA data format.
1512  * & 0xfff logic operator for as_metric to get last 24bits.
1513  */
1514 struct libnet_as_lsa_hdr
1515 {
1516  struct in_addr as_nmask; /* Netmask for advertised destination */
1517  uint32_t as_metric; /* May have to set E bit in first 8bits */
1518 #define LIBNET_AS_E_BIT_ON 0x80000000 /* as_metric */
1519  struct in_addr as_fwd_addr; /* Forwarding address */
1520  uint32_t as_rte_tag; /* External route tag */
1521 };
1522 
1523 
1524 /*
1525  * Base RIP header
1526  * Routing Information Protocol
1527  * Base header size: 24 bytes
1528  */
1529 struct libnet_rip_hdr
1530 {
1531  uint8_t rip_cmd; /* RIP command */
1532 #define RIPCMD_REQUEST 1 /* want info */
1533 #define RIPCMD_RESPONSE 2 /* responding to request */
1534 #define RIPCMD_TRACEON 3 /* turn tracing on */
1535 #define RIPCMD_TRACEOFF 4 /* turn it off */
1536 #define RIPCMD_POLL 5 /* like request, but anyone answers */
1537 #define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */
1538 #define RIPCMD_MAX 7 /* ? command */
1539  uint8_t rip_ver; /* RIP version */
1540 #define RIPVER_0 0
1541 #define RIPVER_1 1
1542 #define RIPVER_2 2
1543  uint16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */
1544  uint16_t rip_af; /* Address family */
1545  uint16_t rip_rt; /* Zero (v1) or Route Tag (v2) */
1546  uint32_t rip_addr; /* IP address */
1547  uint32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */
1548  uint32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */
1549  uint32_t rip_metric; /* Metric */
1550 };
1551 
1552 /*
1553  * RPC headers
1554  * Remote Procedure Call
1555  */
1556 #define LIBNET_RPC_CALL 0
1557 #define LIBNET_RPC_REPLY 1
1558 #define LIBNET_RPC_VERS 2
1559 #define LIBNET_RPC_LAST_FRAG 0x80000000
1560 
1561 /*
1562  * Portmap defines
1563  */
1564 #define LIBNET_PMAP_PROGRAM 100000
1565 #define LIBNET_PMAP_PROC_NULL 0
1566 #define LIBNET_PMAP_PROC_SET 1
1567 #define LIBNET_PMAP_PROC_UNSET 2
1568 #define LIBNET_PMAP_PROC_GETADDR 3
1569 #define LIBNET_PMAP_PROC_DUMP 4
1570 #define LIBNET_PMAP_PROC_CALLIT 5
1571 #define LIBNET_PMAP_PROC_BCAST 5 /* Not a typo */
1572 #define LIBNET_PMAP_PROC_GETTIME 6
1573 #define LIBNET_PMAP_PROC_UADDR2TADDR 7
1574 #define LIBNET_PMAP_PROC_TADDR2UADDR 8
1575 #define LIBNET_PMAP_PROC_GETVERSADDR 9
1576 #define LIBNET_PMAP_PROC_INDIRECT 10
1577 #define LIBNET_PMAP_PROC_GETADDRLIST 11
1578 #define LIBNET_PMAP_PROC_GETSTAT 12
1579 
1580 /* There will be more to add... */
1581 
1583 {
1584  uint32_t rpc_auth_flavor;
1585  uint32_t rpc_auth_length;
1586 #if 0
1587  uint8_t *rpc_auth_data;
1588 #endif
1589 };
1590 
1591 struct libnet_rpc_call
1592 {
1593  uint32_t rpc_rpcvers; /* RPC version - must be 2 */
1594  uint32_t rpc_prognum; /* Program Number */
1595  uint32_t rpc_vers; /* Program Version */
1596  uint32_t rpc_procedure; /* RPC procedure */
1597  struct libnet_rpc_opaque_auth rpc_credentials;
1598  struct libnet_rpc_opaque_auth rpc_verifier;
1599 };
1600 
1601 struct libnet_rpc_call_hdr
1602 {
1603  uint32_t rpc_xid; /* xid (transaction identifier) */
1604  uint32_t rpc_type;
1605  struct libnet_rpc_call rpc_call;
1606 };
1607 
1609 {
1610  uint32_t rpc_record_marking; /* used with byte stream protocols */
1611  struct libnet_rpc_call_hdr rpc_common;
1612 };
1613 
1614 /*
1615  * STP configuration header
1616  * Spanning Tree Protocol
1617  * Static header size: 35 bytes
1618  */
1619 struct libnet_stp_conf_hdr
1620 {
1621  uint16_t stp_id; /* protocol id */
1622  uint8_t stp_version; /* protocol version */
1623  uint8_t stp_bpdu_type; /* bridge protocol data unit type */
1624  uint8_t stp_flags; /* control flags */
1625  uint8_t stp_rootid[8]; /* root id */
1626  uint32_t stp_rootpc; /* root path cost */
1627  uint8_t stp_bridgeid[8]; /* bridge id */
1628  uint16_t stp_portid; /* port id */
1629  uint16_t stp_mage; /* message age */
1630  uint16_t stp_maxage; /* max age */
1631  uint16_t stp_hellot; /* hello time */
1632  uint16_t stp_fdelay; /* forward delay */
1633 };
1634 
1635 
1636 /*
1637  * STP topology change notification header
1638  * Spanning Tree Protocol
1639  * Static header size: 4 bytes
1640  */
1641 struct libnet_stp_tcn_hdr
1642 {
1643  uint16_t stp_id; /* protocol id */
1644  uint8_t stp_version; /* protocol version */
1645  uint8_t stp_bpdu_type; /* bridge protocol data unit type */
1646 };
1647 
1648 
1649 /*
1650  * TCP header
1651  * Transmission Control Protocol
1652  * Static header size: 20 bytes
1653  */
1654 struct libnet_tcp_hdr
1655 {
1656  uint16_t th_sport; /* source port */
1657  uint16_t th_dport; /* destination port */
1658  uint32_t th_seq; /* sequence number */
1659  uint32_t th_ack; /* acknowledgement number */
1660 #if (LIBNET_LIL_ENDIAN)
1661  uint8_t th_x2:4, /* (unused) */
1662  th_off:4; /* data offset */
1663 #endif
1664 #if (LIBNET_BIG_ENDIAN)
1665  uint8_t th_off:4, /* data offset */
1666  th_x2:4; /* (unused) */
1667 #endif
1668  uint8_t th_flags; /* control flags */
1669 #ifndef TH_FIN
1670 #define TH_FIN 0x01 /* finished send data */
1671 #endif
1672 #ifndef TH_SYN
1673 #define TH_SYN 0x02 /* synchronize sequence numbers */
1674 #endif
1675 #ifndef TH_RST
1676 #define TH_RST 0x04 /* reset the connection */
1677 #endif
1678 #ifndef TH_PUSH
1679 #define TH_PUSH 0x08 /* push data to the app layer */
1680 #endif
1681 #ifndef TH_ACK
1682 #define TH_ACK 0x10 /* acknowledge */
1683 #endif
1684 #ifndef TH_URG
1685 #define TH_URG 0x20 /* urgent! */
1686 #endif
1687 #ifndef TH_ECE
1688 #define TH_ECE 0x40
1689 #endif
1690 #ifndef TH_CWR
1691 #define TH_CWR 0x80
1692 #endif
1693  uint16_t th_win; /* window */
1694  uint16_t th_sum; /* checksum */
1695  uint16_t th_urp; /* urgent pointer */
1696 };
1697 
1698 /*
1699  * Token Ring Header
1700  */
1701 struct libnet_token_ring_hdr
1702 {
1703  uint8_t token_ring_access_control;
1704 #define LIBNET_TOKEN_RING_FRAME 0x10
1705  uint8_t token_ring_frame_control;
1706 #define LIBNET_TOKEN_RING_LLC_FRAME 0x40
1707  uint8_t token_ring_dhost[TOKEN_RING_ADDR_LEN];
1708  uint8_t token_ring_shost[TOKEN_RING_ADDR_LEN];
1709  uint8_t token_ring_llc_dsap;
1710  uint8_t token_ring_llc_ssap;
1711  uint8_t token_ring_llc_control_field;
1712  uint8_t token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE];
1713  uint16_t token_ring_type;
1714 #define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */
1715 #define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */
1716 #define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */
1717 };
1718 
1720 {
1721  uint8_t token_ring_addr_octet[6]; /* Token Ring address */
1722 };
1724 /*
1725  * UDP header
1726  * User Data Protocol
1727  * Static header size: 8 bytes
1728  */
1729 struct libnet_udp_hdr
1730 {
1731  uint16_t uh_sport; /* source port */
1732  uint16_t uh_dport; /* destination port */
1733  uint16_t uh_ulen; /* length */
1734  uint16_t uh_sum; /* checksum */
1735 };
1736 
1737 /*
1738  * Sebek header
1739  * Static header size: 48 bytes
1740  */
1741 struct libnet_sebek_hdr
1742 {
1743  uint32_t magic; /* identify packets that should be hidden */
1744  uint16_t version; /* protocol version, currently 1 */
1745 #define SEBEK_PROTO_VERSION 1
1746  uint16_t type; /* type of record (read data is type 0, write data is type 1) */
1747 #define SEBEK_TYPE_READ 0 /* Currently, only read is supported */
1748 #define SEBEK_TYPE_WRITE 1
1749  uint32_t counter; /* PDU counter used to identify when packet are lost */
1750  uint32_t time_sec; /* seconds since EPOCH according to the honeypot */
1751  uint32_t time_usec; /* residual microseconds */
1752  uint32_t pid; /* PID */
1753  uint32_t uid; /* UID */
1754  uint32_t fd; /* FD */
1755 #define SEBEK_CMD_LENGTH 12
1756  uint8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command */
1757  uint32_t length; /* length in bytes of the PDU's body */
1758 };
1759 
1760 
1761 /*
1762  * VRRP header
1763  * Virtual Router Redundancy Protocol
1764  * Static header size: 8 bytes
1765  */
1766 #ifndef IPPROTO_VRRP
1767 #define IPPROTO_VRRP 112 /* not everyone's got this */
1768 #endif
1769 struct libnet_vrrp_hdr
1770 {
1771 #if (LIBNET_LIL_ENDIAN)
1772  uint8_t vrrp_v:4, /* protocol version */
1773  vrrp_t:4; /* packet type */
1774 #endif
1775 #if (LIBNET_BIG_ENDIAN)
1776  uint8_t vrrp_t:4, /* packet type */
1777  vrrp_v:4; /* protocol version */
1778 #endif
1779 #define LIBNET_VRRP_VERSION_01 0x1
1780 #define LIBNET_VRRP_VERSION_02 0x2
1781 #define LIBNET_VRRP_TYPE_ADVERT 0x1
1782  uint8_t vrrp_vrouter_id; /* virtual router id */
1783  uint8_t vrrp_priority; /* priority */
1784  uint8_t vrrp_ip_count; /* number of IP addresses */
1785  uint8_t vrrp_auth_type; /* authorization type */
1786 #define LIBNET_VRRP_AUTH_NONE 0x1
1787 #define LIBNET_VRRP_AUTH_PASSWD 0x2
1788 #define LIBNET_VRRP_AUTH_IPAH 0x3
1789  uint8_t vrrp_advert_int; /* advertisement interval */
1790  uint16_t vrrp_sum; /* checksum */
1791  /* additional addresses */
1792  /* authentication info */
1793 };
1794 
1795 
1796 /*
1797  * HSRP header
1798  * Static header size: 20 bytes
1799  */
1800 struct libnet_hsrp_hdr
1801 {
1802 #define LIBNET_HSRP_VERSION 0x0
1803  uint8_t version; /* Version of the HSRP messages */
1804 #define LIBNET_HSRP_TYPE_HELLO 0x0
1805 #define LIBNET_HSRP_TYPE_COUP 0x1
1806 #define LIBNET_HSRP_TYPE_RESIGN 0x2
1807  uint8_t opcode; /* Type of message */
1808 #define LIBNET_HSRP_STATE_INITIAL 0x0
1809 #define LIBNET_HSRP_STATE_LEARN 0x1
1810 #define LIBNET_HSRP_STATE_LISTEN 0x2
1811 #define LIBNET_HSRP_STATE_SPEAK 0x4
1812 #define LIBNET_HSRP_STATE_STANDBY 0x8
1813 #define LIBNET_HSRP_STATE_ACTIVE 0x10
1814  uint8_t state; /* Current state of the router */
1815  uint8_t hello_time; /* Period in seconds between hello messages */
1816  uint8_t hold_time; /* Seconds that the current hello message is valid */
1817  uint8_t priority; /* Priority for the election proccess */
1818  uint8_t group; /* Standby group */
1819  uint8_t reserved; /* Reserved field */
1820 #define HSRP_AUTHDATA_LENGTH 8
1821  uint8_t authdata[HSRP_AUTHDATA_LENGTH]; /* Password */
1822  uint32_t virtual_ip; /* Virtual IP address */
1823 };
1824 
1825 #endif /* __LIBNET_HEADERS_H */
1826 
Definition: libnet-headers.h:1496
uint16_t vlan_priority_c_vid
priority | VLAN ID
Definition: libnet-headers.h:128
Definition: libnet-headers.h:486
Definition: libnet-headers.h:360
Definition: libnet-headers.h:1443
Definition: libnet-headers.h:1723
Definition: libnet-headers.h:923
Definition: libnet-headers.h:1452
Definition: libnet-headers.h:820
Definition: libnet-headers.h:1292
Definition: libnet-headers.h:746
Definition: libnet-headers.h:1804
Definition: libnet-headers.h:474
uint8_t vlan_dhost[ETHER_ADDR_LEN]
destination ethernet address
Definition: libnet-headers.h:125
Definition: libnet-headers.h:974
Definition: libnet-headers.h:1623
Definition: libnet-headers.h:918
Definition: libnet-headers.h:1204
Definition: libnet-headers.h:1645
Definition: libnet-headers.h:657
Definition: libnet-headers.h:835
Definition: libnet-headers.h:1391
Definition: libnet-headers.h:1745
Definition: libnet-headers.h:186
Definition: libnet-headers.h:1285
Definition: libnet-headers.h:778
Definition: libnet-headers.h:914
uint8_t vlan_shost[ETHER_ADDR_LEN]
source ethernet address
Definition: libnet-headers.h:126
Definition: libnet-headers.h:348
Definition: libnet-headers.h:1605
Definition: libnet-headers.h:1658
Definition: libnet-headers.h:1705
Definition: libnet-headers.h:569
Definition: libnet-headers.h:171
Definition: libnet-headers.h:792
Definition: libnet-headers.h:1267
Definition: libnet-headers.h:1533
Definition: libnet-headers.h:1187
Definition: libnet-headers.h:1156
Definition: libnet-headers.h:1194
Definition: libnet-headers.h:199
Definition: libnet-headers.h:1586
Definition: libnet-headers.h:1432
Definition: libnet-headers.h:317
Definition: libnet-headers.h:1279
Definition: libnet-headers.h:549
Definition: libnet-headers.h:1773
uint16_t vlan_tpi
tag protocol ID
Definition: libnet-headers.h:127
Definition: libnet-headers.h:234
Definition: libnet-headers.h:1595
Definition: libnet-headers.h:762
Definition: libnet-headers.h:807
Definition: libnet-headers.h:1733
Definition: libnet-headers.h:268
Definition: libnet-headers.h:156
Definition: libnet-headers.h:251
Definition: libnet-headers.h:1225
Definition: libnet-headers.h:123
Definition: libnet-headers.h:1518
Definition: libnet-headers.h:1471
Definition: libnet-headers.h:942
Definition: libnet-headers.h:139
Definition: libnet-headers.h:1407
Definition: libnet-headers.h:1377
Definition: libnet-headers.h:1612
Definition: libnet-headers.h:500
Definition: libnet-headers.h:1350
Definition: libnet-headers.h:1506
Definition: libnet-headers.h:580
Definition: libnet-headers.h:535
Definition: libnet-headers.h:671
Definition: libnet-headers.h:928