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