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