Main Page | File List | Globals

libnet-headers.h

00001 /*
00002  *  $Id: libnet-headers.h,v 1.6 2003/10/27 15:23:22 kkuehl Exp $
00003  *
00004  *  libnet-headers.h - Network routine library headers header file
00005  *
00006  *  Copyright (c) 1998 - 2002 Mike D. Schiffman <mike@infonexus.com>
00007  *  All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00019  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00022  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00024  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00025  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00026  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00027  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00028  * SUCH DAMAGE.
00029  *
00030  */
00031 
00032 #ifndef __LIBNET_HEADERS_H
00033 #define __LIBNET_HEADERS_H
00034 
00035 #define LIBNET_802_1Q_H         0x12    /* 802.1Q header:       18 bytes */
00036 #define LIBNET_802_1X_H         0x04    /* 802.1X header:        4 bytes */
00037 #define LIBNET_802_2_H          0x03    /* 802.2 LLC header:     3 bytes */
00038 #define LIBNET_802_2SNAP_H      0x08    /* 802.2 LLC/SNAP header:8 bytes */
00039 #define LIBNET_802_3_H          0x0e    /* 802.3 header:        14 bytes */
00040 #define LIBNET_ARP_H            0x08    /* ARP header w/o addrs: 8 bytes */
00041 #define LIBNET_ARP_ETH_IP_H     0x1c    /* ARP w/ ETH and IP:   28 bytes */
00042 #define LIBNET_BGP4_HEADER_H    0x13    /* BGP header:          19 bytes */
00043 #define LIBNET_BGP4_OPEN_H      0x0a    /* BGP open header:     10 bytes */
00044 #define LIBNET_BGP4_UPDATE_H    0x04    /* BGP open header:      4 bytes */
00045 #define LIBNET_BGP4_NOTIFICATION_H 0x02 /* BGP notif. header:    2 bytes */
00046 #define LIBNET_CDP_H            0x08    /* CDP header base:      8 bytes */
00047 #define LIBNET_DHCPV4_H         0xf0    /* DHCP v4 header:     240 bytes */
00048 #define LIBNET_UDP_DNSV4_H      0x0c    /* UDP DNS v4 header:   12 bytes */
00049 #define LIBNET_TCP_DNSV4_H      0x0e    /* TCP DNS v4 header:   14 bytes */
00050 #define LIBNET_ETH_H            0x0e    /* Ethernet header:     14 bytes */
00051 #define LIBNET_FDDI_H           0x15    /* FDDI header:         21 bytes */
00052 #define LIBNET_ICMPV4_H         0x04    /* ICMP header base:     4 bytes */
00053 #define LIBNET_ICMPV4_ECHO_H    0x08    /* ICMP_ECHO header:     8 bytes */
00054 #define LIBNET_ICMPV4_MASK_H    0x0c    /* ICMP_MASK header:    12 bytes */
00055 #define LIBNET_ICMPV4_UNREACH_H  0x08   /* ICMP_UNREACH header:  8 bytes */
00056 #define LIBNET_ICMPV4_TIMXCEED_H 0x08   /* ICMP_TIMXCEED header: 8 bytes */
00057 #define LIBNET_ICMPV4_REDIRECT_H 0x08   /* ICMP_REDIRECT header: 8 bytes */
00058 #define LIBNET_ICMPV4_TS_H      0x14    /* ICMP_TIMESTAMP headr:20 bytes */
00059 #define LIBNET_ICMPV6_H         0x08    /* ICMP6 header base:    8 bytes */
00060 #define LIBNET_IGMP_H           0x08    /* IGMP header:          8 bytes */
00061 #define LIBNET_IPV4_H           0x14    /* IPv4 header:         20 bytes */
00062 #define LIBNET_IPV6_H           0x28    /* IPv6 header:         40 bytes */
00063 #define LIBNET_IPSEC_ESP_HDR_H  0x0c    /* IPSEC ESP header:    12 bytes */
00064 #define LIBNET_IPSEC_ESP_FTR_H  0x02    /* IPSEC ESP footer:     2 bytes */
00065 #define LIBNET_IPSEC_AH_H       0x10    /* IPSEC AH header:     16 bytes */
00066 #define LIBNET_ISL_H            0x1a    /* ISL header:          26 bytes */
00067 #define LIBNET_GRE_H            0x04    /* GRE header:           4 bytes */
00068 #define LIBNET_GRE_SRE_H        0x04    /* GRE SRE header:       4 bytes */
00069 #define LIBNET_MPLS_H           0x04    /* MPLS header:          4 bytes */
00070 #define LIBNET_OSPF_H           0x10    /* OSPF header:         16 bytes */
00071 #define LIBNET_OSPF_HELLO_H     0x18    /* OSPF hello header:   24 bytes */
00072 #define LIBNET_OSPF_DBD_H       0x08    /* OSPF DBD header:      8 bytes */
00073 #define LIBNET_OSPF_LSR_H       0x0c    /* OSPF LSR header:     12 bytes */
00074 #define LIBNET_OSPF_LSU_H       0x04    /* OSPF LSU header:      4 bytes */
00075 #define LIBNET_OSPF_LSA_H       0x14    /* OSPF LSA header:     20 bytes */
00076 #define LIBNET_OSPF_AUTH_H      0x08    /* OSPF AUTH header:     8 bytes */
00077 #define LIBNET_OSPF_CKSUM       0x10    /* OSPF CKSUM header:   16 bytes */
00078 #define LIBNET_OSPF_LS_RTR_H    0x10    /* OSPF LS RTR header:  16 bytes */
00079 #define LIBNET_OSPF_LS_NET_H    0x08    /* OSPF LS NET header:   8 bytes */
00080 #define LIBNET_OSPF_LS_SUM_H    0x0c    /* OSPF LS SUM header:  12 bytes */
00081 #define LIBNET_OSPF_LS_AS_EXT_H 0x10    /* OSPF LS AS header:   16 bytes */
00082 #define LIBNET_NTP_H            0x30    /* NTP header:          48 bytes */
00083 #define LIBNET_RIP_H            0x18    /* RIP header base:     24 bytes */
00084 #define LIBNET_RPC_CALL_H       0x28    /* RPC header:          40 bytes */
00085                                         /* (assuming 8 byte auth header) */
00086 #define LIBNET_RPC_CALL_TCP_H   0x2c    /* RPC header:          44 bytes */
00087                                         /* (with record marking)         */
00088 #define LIBNET_STP_CONF_H       0x23    /* STP conf header:     35 bytes */
00089 #define LIBNET_STP_TCN_H        0x04    /* STP tcn header:       4 bytes */
00090 #define LIBNET_TOKEN_RING_H     0x16    /* Token Ring header:   22 bytes */
00091 #define LIBNET_TCP_H            0x14    /* TCP header:          20 bytes */
00092 #define LIBNET_UDP_H            0x08    /* UDP header:           8 bytes */
00093 #define LIBNET_VRRP_H           0x08    /* VRRP header:          8 bytes */
00094 
00095 /*
00096  *  IEEE 802.1Q VLAN header (ethervlan)
00097  *  Virtual Local Area Network
00098  *  static header size: 18 bytes
00099  */
00100 struct libnet_802_1q_hdr
00101 {
00102     u_int8_t vlan_dhost[ETHER_ADDR_LEN];  /* destination ethernet address */
00103     u_int8_t vlan_shost[ETHER_ADDR_LEN];  /* source ethernet address */
00104     u_int16_t vlan_tpi;                   /* tag protocol ID */
00105     u_int16_t vlan_priority_c_vid;        /* priority | VLAN ID */
00106 #define LIBNET_802_1Q_PRIMASK   0x0007  /* priority mask */
00107 #define LIBNET_802_1Q_CFIMASK   0x0001  /* CFI mask */
00108 #define LIBNET_802_1Q_VIDMASK   0x0fff  /* vid mask */
00109     u_int16_t vlan_len;                   /* len / type (802.3 / Ethernet II) */
00110 };  
00111 
00112 /*
00113  *  IEEE 802.1X EAP header
00114  *  Extensible Authentication Protocol
00115  *  static header size: 4 bytes
00116  */
00117 struct libnet_802_1x_hdr
00118 {
00119     u_int8_t dot1x_version;       /* protocol version */
00120     u_int8_t dot1x_type;          /* frame type */
00121 #define LIBNET_802_1X_PACKET    0x00
00122 #define LIBNET_802_1X_START     0x01
00123 #define LIBNET_802_1X_LOGOFF    0x02
00124 #define LIBNET_802_1X_KEY       0x03
00125 #define LIBNET_802_1X_ENCASFAL  0x04
00126     u_int16_t dot1x_length;       /* total frame length */
00127 };  
00128 
00129 
00130 /*
00131  *  IEEE 802.2 LLC header
00132  *  Link Layer Control
00133  *  static header size: 3 bytes
00134  */
00135 struct libnet_802_2_hdr
00136 {
00137     u_int8_t llc_dsap;            /* destination service access point */
00138     u_int8_t llc_ssap;            /* source service access point */
00139 #define LIBNET_SAP_STP          0x42
00140 #define LIBNET_SAP_SNAP         0xaa
00141     u_int8_t llc_control;         /* control field */
00142 };
00143 
00144 
00145 /*
00146  *  IEEE 802.2 LLC/SNAP header
00147  *  SubNetwork Attachment Point
00148  *  static header size: 8 bytes
00149  */
00150 struct libnet_802_2snap_hdr
00151 {
00152     u_int8_t snap_dsap;           /* destination service access point */
00153     u_int8_t snap_ssap;           /* destination service access point */
00154     u_int8_t snap_control;        /* control field */
00155     u_int8_t snap_oui[3];         /* OUI */
00156     u_int16_t snap_type;          /* type */
00157 };
00158 
00159 
00160 /*
00161  *  802.3 header
00162  *  IEEE Ethernet
00163  *  Static header size: 14 bytes
00164  */
00165 struct libnet_802_3_hdr
00166 {
00167     u_int8_t  _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
00168     u_int8_t  _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */
00169     u_int16_t _802_3_len;                 /* packet type ID */
00170 };
00171 
00172 
00173 /* 
00174  *  ARP header
00175  *  Address Resolution Protocol
00176  *  Base header size: 8 bytes
00177  */
00178 struct libnet_arp_hdr
00179 {
00180     u_int16_t ar_hrd;         /* format of hardware address */
00181 #define ARPHRD_NETROM   0   /* from KA9Q: NET/ROM pseudo */
00182 #define ARPHRD_ETHER    1   /* Ethernet 10Mbps */
00183 #define ARPHRD_EETHER   2   /* Experimental Ethernet */
00184 #define ARPHRD_AX25     3   /* AX.25 Level 2 */
00185 #define ARPHRD_PRONET   4   /* PROnet token ring */
00186 #define ARPHRD_CHAOS    5   /* Chaosnet */
00187 #define ARPHRD_IEEE802  6   /* IEEE 802.2 Ethernet/TR/TB */
00188 #define ARPHRD_ARCNET   7   /* ARCnet */
00189 #define ARPHRD_APPLETLK 8   /* APPLEtalk */
00190 #define ARPHRD_LANSTAR  9   /* Lanstar */
00191 #define ARPHRD_DLCI     15  /* Frame Relay DLCI */
00192 #define ARPHRD_ATM      19  /* ATM */
00193 #define ARPHRD_METRICOM 23  /* Metricom STRIP (new IANA id) */
00194 #define ARPHRD_IPSEC    31  /* IPsec tunnel */
00195     u_int16_t ar_pro;         /* format of protocol address */
00196     u_int8_t  ar_hln;         /* length of hardware address */
00197     u_int8_t  ar_pln;         /* length of protocol addres */
00198     u_int16_t ar_op;          /* operation type */
00199 #define ARPOP_REQUEST    1  /* req to resolve address */
00200 #define ARPOP_REPLY      2  /* resp to previous request */
00201 #define ARPOP_REVREQUEST 3  /* req protocol address given hardware */
00202 #define ARPOP_REVREPLY   4  /* resp giving protocol address */
00203 #define ARPOP_INVREQUEST 8  /* req to identify peer */
00204 #define ARPOP_INVREPLY   9  /* resp identifying peer */
00205 
00206     /* address information allocated dynamically */
00207 };
00208 
00209 /*
00210  * BGP4 header
00211  * Border Gateway Protocol 4
00212  * Base header size : 19 bytes
00213  */
00214 struct libnet_bgp4_header_hdr
00215 {
00216 #define LIBNET_BGP4_MARKER_SIZE   16
00217     u_int8_t marker[LIBNET_BGP4_MARKER_SIZE];
00218     u_int16_t len;
00219     u_int8_t type;
00220 #define LIBNET_BGP4_OPEN          1
00221 #define LIBNET_BGP4_UPDATE        2
00222 #define LIBNET_BGP4_NOTIFICATION  3
00223 #define LIBNET_BGP4_KEEPALIVE     4
00224 };
00225 
00226 /*
00227  * BGP4 open header
00228  * Border Gateway Protocol 4
00229  * Base header size : 10 bytes
00230  */
00231 struct libnet_bgp4_open_hdr
00232 {
00233     u_int8_t version;
00234     u_int16_t src_as;
00235     u_int16_t hold_time;
00236     u_int32_t bgp_id;
00237     u_int8_t opt_len;
00238 };
00239 
00240 /*
00241  * BGP4 notification message
00242  *
00243  * Border Gateway Protocol 4
00244  * Base header size : 2 bytes
00245  *
00246  * Use payload if you need data
00247  */
00248 struct libnet_bgp4_notification_hdr
00249 {
00250 #define LIBNET_BGP4_MESSAGE_HEADER_ERROR  1
00251 #define LIBNET_BGP4_OPEN_MESSAGE_ERROR    2
00252 #define LIBNET_BGP4_UPDATE_MESSAGE_ERROR  3
00253 #define LIBNET_BGP4_HOLD_TIMER_EXPIRED    4
00254 #define LIBNET_BGP4_FINITE_STATE__ERROR   5
00255 #define LIBNET_BGP4_CEASE                 6
00256     u_int8_t err_code;
00257 
00258 /* Message Header Error subcodes */
00259 #define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED    1
00260 #define LIBNET_BGP4_BAD_MESSAGE_LENGTH             2
00261 #define LIBNET_BGP4_BAD_MESSAGE_TYPE               3
00262 /* OPEN Message Error subcodes */
00263 #define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER     1
00264 #define LIBNET_BGP4_BAD_PEER_AS                    2
00265 #define LIBNET_BGP4_BAD_BGP_IDENTIFIER             3
00266 #define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4
00267 #define LIBNET_BGP4_AUTHENTICATION_FAILURE         5
00268 #define LIBNET_BGP4_UNACCEPTABLE_HOLD_TIME         6
00269 /* UPDATE Message Error subcodes */
00270 #define LIBNET_BGP4_MALFORMED_ATTRIBUTE_LIST
00271 #define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE
00272 #define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE
00273 #define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR
00274 #define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR
00275 #define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE
00276 #define LIBNET_BGP4_AS_ROUTING_LOOP
00277 #define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE
00278 #define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR
00279 #define LIBNET_BGP4_INVALID_NETWORK_FIELD
00280 #define LIBNET_BGP4_MALFORMED_AS_PATH
00281     u_int8_t err_subcode;
00282 };
00283 
00284 
00285 
00286 /*
00287  *  CDP header
00288  *  Cisco Discovery Protocol
00289  *  Base header size: 8 bytes
00290  */
00291 
00292 /*
00293  *  For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
00294  *  Let's hope this one stays that way for a while!
00295  */
00296 #define LIBNET_PROTO_CDP    200
00297 struct libnet_cdp_hdr
00298 {
00299     u_int8_t cdp_version;     /* version (should always be 0x01) */
00300     u_int8_t cdp_ttl;         /* time reciever should hold info in this packet */
00301     u_int16_t cdp_sum;        /* checksum */
00302     u_int16_t cdp_type;       /* type */
00303 #define LIBNET_CDP_DEVID    0x1 /* device id */
00304 #define LIBNET_CDP_ADDRESS  0x2 /* address */
00305 #define LIBNET_CDP_PORTID   0x3 /* port id */
00306 #define LIBNET_CDP_CAPABIL  0x4 /* capabilities */
00307 #define LIBNET_CDP_VERSION  0x5 /* version */
00308 #define LIBNET_CDP_PLATFORM 0x6 /* platform */
00309 #define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */
00310     u_int16_t cdp_len;        /* type + length + value */
00311     /* value information done dynamically */
00312 
00313 /* CDP capabilities */
00314 #define LIBNET_CDP_CAP_L3R  0x01/* performs level 3 routing */
00315 #define LIBNET_CDP_CAP_L2B  0x02/* performs level 2 transparent bridging */
00316 #define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */
00317 #define LIBNET_CDP_CAP_L2S  0x08/* performs level 2 switching */
00318 #define LIBNET_CDP_CAP_SR   0x10/* sends and recieves packets on a network */
00319 #define LIBNET_CDP_CAP_NOI  0x20/* does not forward IGMP on non-router ports */
00320 #define LIBNET_CDP_CAP_L1F  0x40/* provides level 1 functionality */
00321 };
00322 
00323 
00324 /*
00325  *  Used as an overlay for type/len/values
00326  */
00327 struct libnet_cdp_value_hdr
00328 {
00329     u_int16_t cdp_type;
00330     u_int16_t cdp_len;
00331 };
00332 
00333 
00334 /*
00335  *  DHCP header
00336  *  Dynamic Host Configuration Protocol
00337  *  Static header size: f0 bytes
00338  */
00339 struct libnet_dhcpv4_hdr
00340 {
00341     u_int8_t dhcp_opcode;     /* opcode */
00342 #define LIBNET_DHCP_REQUEST 0x1
00343 #define LIBNET_DHCP_REPLY   0x2
00344     u_int8_t dhcp_htype;      /* hardware address type */
00345     u_int8_t dhcp_hlen;       /* hardware address length */
00346     u_int8_t dhcp_hopcount;   /* used by proxy servers */
00347     u_int32_t dhcp_xid;        /* transaction ID */
00348     u_int16_t dhcp_secs;      /* number of seconds since trying to bootstrap */
00349     u_int16_t dhcp_flags;     /* flags for DHCP, unused for BOOTP */
00350     u_int32_t dhcp_cip;        /* client's IP */
00351     u_int32_t dhcp_yip;        /* your IP */
00352     u_int32_t dhcp_sip;        /* server's IP */
00353     u_int32_t dhcp_gip;        /* gateway IP */
00354     u_int8_t dhcp_chaddr[16]; /* client hardware address */
00355     u_int8_t dhcp_sname[64];  /* server host name */
00356     u_int8_t dhcp_file[128];  /* boot file name */
00357     u_int32_t dhcp_magic;      /* BOOTP magic header */
00358 #define DHCP_MAGIC                  0x63825363
00359 #define LIBNET_BOOTP_MIN_LEN        0x12c
00360 #define LIBNET_DHCP_PAD             0x00
00361 #define LIBNET_DHCP_SUBNETMASK      0x01
00362 #define LIBNET_DHCP_TIMEOFFSET      0x02
00363 #define LIBNET_DHCP_ROUTER          0x03
00364 #define LIBNET_DHCP_TIMESERVER      0x04
00365 #define LIBNET_DHCP_NAMESERVER      0x05
00366 #define LIBNET_DHCP_DNS             0x06
00367 #define LIBNET_DHCP_LOGSERV         0x07
00368 #define LIBNET_DHCP_COOKIESERV      0x08
00369 #define LIBNET_DHCP_LPRSERV         0x09
00370 #define LIBNET_DHCP_IMPSERV         0x0a
00371 #define LIBNET_DHCP_RESSERV         0x0b
00372 #define LIBNET_DHCP_HOSTNAME        0x0c
00373 #define LIBNET_DHCP_BOOTFILESIZE    0x0d
00374 #define LIBNET_DHCP_DUMPFILE        0x0e
00375 #define LIBNET_DHCP_DOMAINNAME      0x0f
00376 #define LIBNET_DHCP_SWAPSERV        0x10
00377 #define LIBNET_DHCP_ROOTPATH        0x11
00378 #define LIBNET_DHCP_EXTENPATH       0x12
00379 #define LIBNET_DHCP_IPFORWARD       0x13
00380 #define LIBNET_DHCP_SRCROUTE        0x14
00381 #define LIBNET_DHCP_POLICYFILTER    0x15
00382 #define LIBNET_DHCP_MAXASMSIZE      0x16
00383 #define LIBNET_DHCP_IPTTL           0x17
00384 #define LIBNET_DHCP_MTUTIMEOUT      0x18
00385 #define LIBNET_DHCP_MTUTABLE        0x19
00386 #define LIBNET_DHCP_MTUSIZE         0x1a
00387 #define LIBNET_DHCP_LOCALSUBNETS    0x1b
00388 #define LIBNET_DHCP_BROADCASTADDR   0x1c
00389 #define LIBNET_DHCP_DOMASKDISCOV    0x1d
00390 #define LIBNET_DHCP_MASKSUPPLY      0x1e
00391 #define LIBNET_DHCP_DOROUTEDISC     0x1f
00392 #define LIBNET_DHCP_ROUTERSOLICIT   0x20
00393 #define LIBNET_DHCP_STATICROUTE     0x21
00394 #define LIBNET_DHCP_TRAILERENCAP    0x22
00395 #define LIBNET_DHCP_ARPTIMEOUT      0x23
00396 #define LIBNET_DHCP_ETHERENCAP      0x24
00397 #define LIBNET_DHCP_TCPTTL          0x25
00398 #define LIBNET_DHCP_TCPKEEPALIVE    0x26
00399 #define LIBNET_DHCP_TCPALIVEGARBAGE 0x27
00400 #define LIBNET_DHCP_NISDOMAIN       0x28
00401 #define LIBNET_DHCP_NISSERVERS      0x29
00402 #define LIBNET_DHCP_NISTIMESERV     0x2a
00403 #define LIBNET_DHCP_VENDSPECIFIC    0x2b
00404 #define LIBNET_DHCP_NBNS            0x2c
00405 #define LIBNET_DHCP_NBDD            0x2d
00406 #define LIBNET_DHCP_NBTCPIP         0x2e
00407 #define LIBNET_DHCP_NBTCPSCOPE      0x2f
00408 #define LIBNET_DHCP_XFONT           0x30
00409 #define LIBNET_DHCP_XDISPLAYMGR     0x31
00410 #define LIBNET_DHCP_DISCOVERADDR    0x32
00411 #define LIBNET_DHCP_LEASETIME       0x33
00412 #define LIBNET_DHCP_OPTIONOVERLOAD  0x34
00413 #define LIBNET_DHCP_MESSAGETYPE     0x35
00414 #define LIBNET_DHCP_SERVIDENT       0x36
00415 #define LIBNET_DHCP_PARAMREQUEST    0x37
00416 #define LIBNET_DHCP_MESSAGE         0x38
00417 #define LIBNET_DHCP_MAXMSGSIZE      0x39
00418 #define LIBNET_DHCP_RENEWTIME       0x3a
00419 #define LIBNET_DHCP_REBINDTIME      0x3b
00420 #define LIBNET_DHCP_CLASSSID        0x3c
00421 #define LIBNET_DHCP_CLIENTID        0x3d
00422 #define LIBNET_DHCP_NISPLUSDOMAIN   0x40
00423 #define LIBNET_DHCP_NISPLUSSERVERS  0x41
00424 #define LIBNET_DHCP_MOBILEIPAGENT   0x44
00425 #define LIBNET_DHCP_SMTPSERVER      0x45
00426 #define LIBNET_DHCP_POP3SERVER      0x46
00427 #define LIBNET_DHCP_NNTPSERVER      0x47
00428 #define LIBNET_DHCP_WWWSERVER       0x48
00429 #define LIBNET_DHCP_FINGERSERVER    0x49
00430 #define LIBNET_DHCP_IRCSERVER       0x4a
00431 #define LIBNET_DHCP_STSERVER        0x4b
00432 #define LIBNET_DHCP_STDASERVER      0x4c
00433 #define LIBNET_DHCP_END             0xff
00434 
00435 #define LIBNET_DHCP_MSGDISCOVER     0x01
00436 #define LIBNET_DHCP_MSGOFFER        0x02
00437 #define LIBNET_DHCP_MSGREQUEST      0x03
00438 #define LIBNET_DHCP_MSGDECLINE      0x04
00439 #define LIBNET_DHCP_MSGACK          0x05
00440 #define LIBNET_DHCP_MSGNACK         0x06
00441 #define LIBNET_DHCP_MSGRELEASE      0x07
00442 #define LIBNET_DHCP_MSGINFORM       0x08
00443 };
00444 
00445 
00446 /*
00447  *  Base DNSv4 header
00448  *  Domain Name System
00449  *  Base header size: 12/14 bytes
00450  */
00451 struct libnet_dnsv4_hdr
00452 {
00453     u_int16_t h_len;          /* length of the packet - only used with TCP */
00454     u_int16_t id;             /* DNS packet ID */
00455     u_int16_t flags;          /* DNS flags */
00456     u_int16_t num_q;          /* Number of questions */
00457     u_int16_t num_answ_rr;    /* Number of answer resource records */
00458     u_int16_t num_auth_rr;    /* Number of authority resource records */
00459     u_int16_t num_addi_rr;    /* Number of additional resource records */
00460 };
00461 
00462 
00463 /*
00464  *  Ethernet II header
00465  *  Static header size: 14 bytes
00466  */
00467 struct libnet_ethernet_hdr
00468 {
00469     u_int8_t  ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
00470     u_int8_t  ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
00471     u_int16_t ether_type;                 /* protocol */
00472 };
00473 
00474 #ifndef ETHERTYPE_PUP
00475 #define ETHERTYPE_PUP           0x0200  /* PUP protocol */
00476 #endif
00477 #ifndef ETHERTYPE_IP
00478 #define ETHERTYPE_IP            0x0800  /* IP protocol */
00479 #endif
00480 #ifndef ETHERTYPE_ARP
00481 #define ETHERTYPE_ARP           0x0806  /* addr. resolution protocol */
00482 #endif
00483 #ifndef ETHERTYPE_REVARP
00484 #define ETHERTYPE_REVARP        0x8035  /* reverse addr. resolution protocol */
00485 #endif
00486 #ifndef ETHERTYPE_VLAN
00487 #define ETHERTYPE_VLAN          0x8100  /* IEEE 802.1Q VLAN tagging */
00488 #endif
00489 #ifndef ETHERTYPE_EAP
00490 #define ETHERTYPE_EAP           0x888e  /* IEEE 802.1X EAP authentication */
00491 #endif
00492 #ifndef ETHERTYPE_MPLS
00493 #define ETHERTYPE_MPLS          0x8847  /* MPLS */
00494 #endif
00495 #ifndef ETHERTYPE_LOOPBACK
00496 #define ETHERTYPE_LOOPBACK      0x9000  /* used to test interfaces */
00497 #endif
00498 
00499 struct libnet_ether_addr
00500 {
00501     u_int8_t  ether_addr_octet[6];        /* Ethernet address */
00502 };
00503 
00504 /*
00505  *  Fiber Distributed Data Interface header
00506  *
00507  *  Static header size: 21 bytes (LLC and 48-bit address addr only)
00508  *
00509  *  Note: Organization field is 3 bytes which throws off the
00510  *        alignment of type.  Therefore fddi_type (19 bytes in) 
00511  *        is specified as two u_int8_ts.
00512  */
00513 struct libnet_fddi_hdr
00514 {
00515     u_int8_t  fddi_frame_control;                      /* Class/Format/Priority */
00516 #define LIBNET_FDDI_LLC_FRAME  0x10
00517 #define LIBNET_FDDI_48BIT_ADDR 0x40
00518 #define LIBNET_FDDI_FC_REQD    LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_ADDR 
00519     u_int8_t  fddi_dhost[FDDI_ADDR_LEN];               /* destination fddi address */
00520     u_int8_t  fddi_shost[FDDI_ADDR_LEN];               /* source fddi address */
00521     u_int8_t  fddi_llc_dsap;                           /* DSAP */
00522     u_int8_t  fddi_llc_ssap;                           /* SSAP */
00523     u_int8_t  fddi_llc_control_field;                  /* Class/Format/Priority */
00524     u_int8_t  fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code 3-bytes */
00525     u_int8_t  fddi_type;                               /* Protocol Type */
00526     u_int8_t  fddi_type1;                              /* see note above. */
00527 #define FDDI_TYPE_IP            0x0800  /* IP protocol */
00528 #define FDDI_TYPE_ARP           0x0806  /* addr. resolution protocol */
00529 #define FDDI_TYPE_REVARP        0x8035  /* reverse addr. resolution protocol */
00530 };
00531 
00532 
00533 struct libnet_fddi_addr
00534 {
00535     u_int8_t  fddi_addr_octet[6];        /* FDDI address */
00536 };
00537 
00538 
00539 /*
00540  * GRE header - RFC 1701 & 2637
00541  * Generic Routing Encapsulation (GRE) 
00542  * Base header size: 4 bytes
00543  */
00544 struct libnet_gre_hdr
00545 {
00546     u_int16_t flags_ver;
00547 #define GRE_CSUM                            0x8000
00548 #define GRE_ROUTING                         0x4000
00549 #define GRE_KEY                             0x2000
00550 #define GRE_SEQ                             0x1000
00551 #define GRE_STRICT                          0x0800
00552 #define GRE_REC                             0x0700
00553 #define GRE_ACK                             0x0080
00554 
00555 #define GRE_FLAGS_MASK                          0x00F8
00556 #define GRE_VERSION_MASK                        0x0007
00557 
00558 #define GRE_VERSION_0                           0x0000
00559 #define GRE_VERSION_1                           0x0001
00560 
00561     u_int16_t type;
00562 #define GRE_SNA                                 0x0004
00563 #define GRE_OSI_NETWORK_LAYER                   0x00FE
00564 #define GRE_PUP                                 0x0200
00565 #define GRE_XNS                                 0x0600
00566 #define GRE_IP                                  0x0800
00567 #define GRE_CHAOS                               0x0804
00568 #define GRE_RFC_826_ARP                         0x0806
00569 #define GRE_FRAME_RELAY_ARP                     0x0808
00570 #define GRE_VINES                               0x0BAD
00571 #define GRE_VINES_ECHO                          0x0BAE
00572 #define GRE_VINES_LOOPBACK                      0x0BAF
00573 #define GRE_DECNET                              0x6003
00574 #define GRE_TRANSPARENT_ETHERNET_BRIDGING       0x6558
00575 #define GRE_RAW_FRAME_RELAY                     0x6559
00576 #define GRE_APOLLO_DOMAIN                       0x8019
00577 #define GRE_ETHERTALK                           0x809B
00578 #define GRE_NOVELL_IPX                          0x8137
00579 #define GRE_RFC_1144_TCP_IP_COMPRESSION         0x876B
00580 #define GRE_IP_AUTONOMOUS_SYSTEMS               0x876C
00581 #define GRE_SECURE_DATA                         0x876D
00582 #define GRE_PPP                                 0x880b /* taken from RFC 2637 */
00583 
00584     union {
00585     struct {
00586         u_int16_t checksum;  /* optional */
00587         u_int16_t offset;    /* optional */
00588         u_int32_t key;        /* optional */
00589         u_int32_t seq;        /* optional */
00590     } _gre;
00591 
00592     struct {
00593         u_int16_t payload_s; /* optional */
00594         u_int16_t callID;    /* optional */
00595         u_int32_t seq;        /* optional */
00596         u_int32_t ack;        /* optional */
00597     } _egre;
00598     }_data;
00599 
00600 #define gre_checksum _data._gre.checksum
00601 #define gre_offset _data._gre.offset
00602 #define gre_key _data._gre.key
00603 #define gre_seq _data._gre.seq
00604 
00605 #define egre_payload_s _data._egre.payload_s
00606 #define egre_callID _data._egre.callID
00607 #define egre_seq _data._egre.seq
00608 #define egre_ack _data._egre.ack
00609 };
00610 
00611 
00612 #ifndef IPPROTO_GRE
00613 #define IPPROTO_GRE 47
00614 #endif
00615 
00616 /*
00617  * Source Route Entries (SRE)
00618  * This is used for GRE as the Routing field is a list of SREs - RFC 1701
00619  * Base header size: 4 bytes
00620  */
00621 struct libnet_gre_sre_hdr
00622 {
00623     u_int16_t af;  /* address familly */
00624     u_int8_t sre_offset;
00625     u_int8_t sre_length;
00626     u_int8_t *routing;
00627 };
00628 
00629 
00630 /*
00631  *  IPv4 header
00632  *  Internet Protocol, version 4
00633  *  Static header size: 20 bytes
00634  */
00635 struct libnet_ipv4_hdr
00636 {
00637 #if (LIBNET_LIL_ENDIAN)
00638     u_int8_t ip_hl:4,      /* header length */
00639            ip_v:4;         /* version */
00640 #endif
00641 #if (LIBNET_BIG_ENDIAN)
00642     u_int8_t ip_v:4,       /* version */
00643            ip_hl:4;        /* header length */
00644 #endif
00645     u_int8_t ip_tos;          /* type of service */
00646 #ifndef IPTOS_LOWDELAY
00647 #define IPTOS_LOWDELAY      0x10
00648 #endif
00649 #ifndef IPTOS_THROUGHPUT
00650 #define IPTOS_THROUGHPUT    0x08
00651 #endif
00652 #ifndef IPTOS_RELIABILITY
00653 #define IPTOS_RELIABILITY   0x04
00654 #endif
00655 #ifndef IPTOS_LOWCOST
00656 #define IPTOS_LOWCOST       0x02
00657 #endif
00658     u_int16_t ip_len;         /* total length */
00659     u_int16_t ip_id;          /* identification */
00660     u_int16_t ip_off;
00661 #ifndef IP_RF
00662 #define IP_RF 0x8000        /* reserved fragment flag */
00663 #endif
00664 #ifndef IP_DF
00665 #define IP_DF 0x4000        /* dont fragment flag */
00666 #endif
00667 #ifndef IP_MF
00668 #define IP_MF 0x2000        /* more fragments flag */
00669 #endif 
00670 #ifndef IP_OFFMASK
00671 #define IP_OFFMASK 0x1fff   /* mask for fragmenting bits */
00672 #endif
00673     u_int8_t ip_ttl;          /* time to live */
00674     u_int8_t ip_p;            /* protocol */
00675     u_int16_t ip_sum;         /* checksum */
00676     struct in_addr ip_src, ip_dst; /* source and dest address */
00677 };
00678 
00679 /*
00680  *  IP options
00681  */
00682 #ifndef IPOPT_EOL
00683 #define IPOPT_EOL       0   /* end of option list */
00684 #endif
00685 #ifndef IPOPT_NOP
00686 #define IPOPT_NOP       1   /* no operation */
00687 #endif   
00688 #ifndef IPOPT_RR
00689 #define IPOPT_RR        7   /* record packet route */
00690 #endif
00691 #ifndef IPOPT_TS
00692 #define IPOPT_TS        68  /* timestamp */
00693 #endif
00694 #ifndef IPOPT_SECURITY
00695 #define IPOPT_SECURITY  130 /* provide s,c,h,tcc */   
00696 #endif
00697 #ifndef IPOPT_LSRR
00698 #define IPOPT_LSRR      131 /* loose source route */
00699 #endif
00700 #ifndef IPOPT_SATID
00701 #define IPOPT_SATID     136 /* satnet id */
00702 #endif
00703 #ifndef IPOPT_SSRR
00704 #define IPOPT_SSRR      137 /* strict source route */
00705 #endif
00706 
00707 struct libnet_in6_addr
00708 {
00709     union
00710     {
00711         u_int8_t   __u6_addr8[16];
00712         u_int16_t  __u6_addr16[8];
00713         u_int32_t   __u6_addr32[4];
00714     } __u6_addr;            /* 128-bit IP6 address */
00715 };
00716 #define libnet_s6_addr __u6_addr.__u6_addr8
00717  
00718 
00719 /*
00720  *  IPv6 header
00721  *  Internet Protocol, version 6
00722  *  Static header size: 40 bytes
00723  */
00724 struct libnet_ipv6_hdr
00725 {
00726     u_int8_t ip_flags[4];     /* version, traffic class, flow label */
00727     u_int16_t ip_len;         /* total length */
00728     u_int8_t ip_nh;           /* next header */
00729     u_int8_t ip_hl;           /* hop limit */
00730     struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */
00731 
00732 };
00733 
00734 /*
00735  *  ICMP6 header
00736  *  Internet Control Message Protocol v6
00737  *  Base header size: 8 bytes
00738  */
00739 #ifndef IPPROTO_ICMP6
00740 #define IPPROTO_ICMP6   0x3a
00741 #endif
00742 struct libnet_icmpv6_hdr
00743 {
00744     u_int8_t icmp_type;       /* ICMP type */
00745 #ifndef ICMP6_ECHO
00746 #define ICMP6_ECHO          128
00747 #endif
00748 #ifndef ICMP6_ECHOREPLY
00749 #define ICMP6_ECHOREPLY     129
00750 #endif
00751 #ifndef ICMP6_UNREACH
00752 #define ICMP6_UNREACH       1
00753 #endif
00754 #ifndef ICMP6_PKTTOOBIG
00755 #define ICMP6_PKTTOOBIG     2
00756 #endif
00757 #ifndef ICMP6_TIMXCEED
00758 #define ICMP6_TIMXCEED      3
00759 #endif
00760 #ifndef ICMP6_PARAMPROB
00761 #define ICMP6_PARAMPROB     4
00762 #endif
00763     u_int8_t icmp_code;       /* ICMP code */
00764     u_int16_t icmp_sum;       /* ICMP Checksum */
00765     u_int16_t id;             /* ICMP id */
00766     u_int16_t seq;            /* ICMP sequence number */
00767 };
00768 
00769 
00770 
00771 /*
00772  *  ICMP header
00773  *  Internet Control Message Protocol
00774  *  Base header size: 4 bytes
00775  */
00776 struct libnet_icmpv4_hdr
00777 {
00778     u_int8_t icmp_type;       /* ICMP type */
00779 #ifndef     ICMP_ECHOREPLY
00780 #define     ICMP_ECHOREPLY                  0
00781 #endif
00782 #ifndef     ICMP_UNREACH
00783 #define     ICMP_UNREACH                    3
00784 #endif
00785 #ifndef     ICMP_SOURCEQUENCH
00786 #define     ICMP_SOURCEQUENCH               4
00787 #endif
00788 #ifndef     ICMP_REDIRECT
00789 #define     ICMP_REDIRECT                   5
00790 #endif
00791 #ifndef     ICMP_ECHO
00792 #define     ICMP_ECHO                       8
00793 #endif
00794 #ifndef     ICMP_ROUTERADVERT
00795 #define     ICMP_ROUTERADVERT               9
00796 #endif
00797 #ifndef     ICMP_ROUTERSOLICIT
00798 #define     ICMP_ROUTERSOLICIT              10
00799 #endif
00800 #ifndef     ICMP_TIMXCEED
00801 #define     ICMP_TIMXCEED                   11
00802 #endif
00803 #ifndef     ICMP_PARAMPROB
00804 #define     ICMP_PARAMPROB                  12
00805 #endif
00806 #ifndef     ICMP_TSTAMP
00807 #define     ICMP_TSTAMP                     13
00808 #endif
00809 #ifndef     ICMP_TSTAMPREPLY
00810 #define     ICMP_TSTAMPREPLY                14
00811 #endif
00812 #ifndef     ICMP_IREQ
00813 #define     ICMP_IREQ                       15
00814 #endif
00815 #ifndef     ICMP_IREQREPLY
00816 #define     ICMP_IREQREPLY                  16
00817 #endif
00818 #ifndef     ICMP_MASKREQ
00819 #define     ICMP_MASKREQ                    17
00820 #endif
00821 #ifndef     ICMP_MASKREPLY
00822 #define     ICMP_MASKREPLY                  18
00823 #endif
00824     u_int8_t icmp_code;       /* ICMP code */
00825 #ifndef     ICMP_UNREACH_NET
00826 #define     ICMP_UNREACH_NET                0
00827 #endif
00828 #ifndef     ICMP_UNREACH_HOST
00829 #define     ICMP_UNREACH_HOST               1
00830 #endif
00831 #ifndef     ICMP_UNREACH_PROTOCOL
00832 #define     ICMP_UNREACH_PROTOCOL           2
00833 #endif
00834 #ifndef     ICMP_UNREACH_PORT
00835 #define     ICMP_UNREACH_PORT               3
00836 #endif
00837 #ifndef     ICMP_UNREACH_NEEDFRAG
00838 #define     ICMP_UNREACH_NEEDFRAG           4
00839 #endif
00840 #ifndef     ICMP_UNREACH_SRCFAIL
00841 #define     ICMP_UNREACH_SRCFAIL            5
00842 #endif
00843 #ifndef     ICMP_UNREACH_NET_UNKNOWN
00844 #define     ICMP_UNREACH_NET_UNKNOWN        6
00845 #endif
00846 #ifndef     ICMP_UNREACH_HOST_UNKNOWN
00847 #define     ICMP_UNREACH_HOST_UNKNOWN       7
00848 #endif
00849 #ifndef     ICMP_UNREACH_ISOLATED
00850 #define     ICMP_UNREACH_ISOLATED           8
00851 #endif
00852 #ifndef     ICMP_UNREACH_NET_PROHIB
00853 #define     ICMP_UNREACH_NET_PROHIB         9
00854 #endif
00855 #ifndef     ICMP_UNREACH_HOST_PROHIB
00856 #define     ICMP_UNREACH_HOST_PROHIB        10
00857 #endif
00858 #ifndef     ICMP_UNREACH_TOSNET
00859 #define     ICMP_UNREACH_TOSNET             11
00860 #endif
00861 #ifndef     ICMP_UNREACH_TOSHOST
00862 #define     ICMP_UNREACH_TOSHOST            12
00863 #endif
00864 #ifndef     ICMP_UNREACH_FILTER_PROHIB
00865 #define     ICMP_UNREACH_FILTER_PROHIB      13
00866 #endif
00867 #ifndef     ICMP_UNREACH_HOST_PRECEDENCE
00868 #define     ICMP_UNREACH_HOST_PRECEDENCE    14
00869 #endif
00870 #ifndef     ICMP_UNREACH_PRECEDENCE_CUTOFF
00871 #define     ICMP_UNREACH_PRECEDENCE_CUTOFF  15
00872 #endif
00873 #ifndef     ICMP_REDIRECT_NET
00874 #define     ICMP_REDIRECT_NET               0
00875 #endif
00876 #ifndef     ICMP_REDIRECT_HOST
00877 #define     ICMP_REDIRECT_HOST              1
00878 #endif
00879 #ifndef     ICMP_REDIRECT_TOSNET
00880 #define     ICMP_REDIRECT_TOSNET            2
00881 #endif
00882 #ifndef     ICMP_REDIRECT_TOSHOST
00883 #define     ICMP_REDIRECT_TOSHOST           3
00884 #endif
00885 #ifndef     ICMP_TIMXCEED_INTRANS
00886 #define     ICMP_TIMXCEED_INTRANS           0
00887 #endif
00888 #ifndef     ICMP_TIMXCEED_REASS
00889 #define     ICMP_TIMXCEED_REASS             1
00890 #endif
00891 #ifndef     ICMP_PARAMPROB_OPTABSENT
00892 #define     ICMP_PARAMPROB_OPTABSENT        1
00893 #endif
00894 
00895     u_int16_t icmp_sum;   /* ICMP Checksum */
00896 
00897     union
00898     {
00899         struct
00900         {
00901             u_int16_t id; /* ICMP id */
00902             u_int16_t seq;/* ICMP sequence number */
00903         } echo;
00904 
00905 #undef icmp_id
00906 #undef icmp_seq
00907 #define icmp_id     hun.echo.id
00908 #define icmp_seq    hun.echo.seq
00909  
00910         u_int32_t gateway; /* gateway host */
00911         struct
00912         {
00913             u_int16_t pad;/* padding */
00914             u_int16_t mtu;/* MTU size */
00915         } frag;
00916     } hun;
00917     union
00918     {
00919         struct
00920         {
00921             n_time its_otime;
00922             n_time its_rtime;
00923             n_time its_ttime;
00924         } ts;
00925         struct
00926         {
00927             struct libnet_ipv4_hdr idi_ip;
00928             /* options and then 64 bits of data */
00929         } ip;
00930         u_int32_t mask;
00931         int8_t data[1];
00932 
00933 #undef icmp_mask
00934 #define icmp_mask    dun.mask
00935 #undef icmp_data
00936 #define icmp_data    dun.data
00937 
00938 #undef icmp_otime
00939 #define icmp_otime   dun.ts.its_otime
00940 #undef icmp_rtime
00941 #define icmp_rtime   dun.ts.its_rtime
00942 #undef icmp_ttime
00943 #define icmp_ttime   dun.ts.its_ttime
00944     }dun;
00945 };
00946 
00947 
00948 /*
00949  *  IGMP header
00950  *  Internet Group Message Protocol
00951  *  Static header size: 8 bytes
00952  */
00953 struct libnet_igmp_hdr
00954 {
00955     u_int8_t igmp_type;       /* IGMP type */
00956 #ifndef IGMP_MEMBERSHIP_QUERY
00957 #define IGMP_MEMBERSHIP_QUERY           0x11    /* membership query */
00958 #endif
00959 #ifndef IGMP_V1_MEMBERSHIP_REPORT
00960 #define IGMP_V1_MEMBERSHIP_REPORT       0x12    /* Ver. 1 membership report */
00961 #endif
00962 #ifndef IGMP_V2_MEMBERSHIP_REPORT
00963 #define IGMP_V2_MEMBERSHIP_REPORT       0x16    /* Ver. 2 membership report */
00964 #endif
00965 #ifndef IGMP_LEAVE_GROUP
00966 #define IGMP_LEAVE_GROUP                0x17    /* Leave-group message */
00967 #endif
00968     u_int8_t igmp_code;       /* IGMP code */
00969     u_int16_t igmp_sum;       /* IGMP checksum */
00970     struct in_addr igmp_group;/* IGMP host IP */
00971 };
00972 
00973 
00974 /*
00975  *  IPSEC header
00976  *  Internet Protocol Security Protocol
00977  *  Encapsulating Security Payload Header Static header size: 12 bytes
00978  *  Encapsulating Security Payload Footer Base header size: 2 bytes
00979  *  Authentication Header Static Size: 16 bytes
00980  */
00981 #ifndef IPPROTO_ESP
00982 #define IPPROTO_ESP 50      /* not everyone's got this */
00983 #endif
00984 struct libnet_esp_hdr
00985 {
00986    u_int32_t esp_spi;          /* security parameter index */
00987    u_int32_t esp_seq;          /* ESP sequence number */
00988    u_int32_t esp_iv;           /* initialization vector */
00989 };
00990 
00991 struct libnet_esp_ftr
00992 {
00993     u_int8_t esp_pad_len;     /* padding length */
00994     u_int8_t esp_nxt_hdr;     /* next header pointer */
00995     int8_t *esp_auth;         /* authentication data */
00996 };
00997  
00998 #ifndef IPPROTO_AH
00999 #define IPPROTO_AH 51       /* not everyone's got this */
01000 #endif
01001 struct libnet_ah_hdr
01002 {
01003     u_int8_t ah_nxt_hdr;      /* next header */
01004     u_int8_t ah_len;          /* payload length */
01005     u_int16_t ah_res;         /* reserved */
01006     u_int32_t ah_spi;          /* security parameter index  */
01007     u_int32_t ah_seq;          /* AH sequence number */
01008     u_int32_t ah_auth;         /* authentication data */
01009 };
01010 
01011 
01012 /*
01013  *  ISL header
01014  *  Cisco Inter-Switch Link
01015  *  Static header size: 26 bytes
01016  */
01017 /*
01018  *  For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001.
01019  *  Let's hope this one stays that way for a while!
01020  */
01021 #define LIBNET_PROTO_ISL    201
01022 struct libnet_isl_hdr
01023 {
01024     u_int8_t isl_dhost[5];    /* destination address "01:00:0c:00:00" */
01025 #if (LIBNET_LIL_ENDIAN)
01026     u_int8_t isl_type:4,      /* type of frame */
01027            isl_user:4;      /* user defined bits */
01028 #endif
01029 #if (LIBNET_BIG_ENDIAN)
01030     u_int8_t isl_user:4,      /* user defined bits */
01031            isl_type:4;      /* type of frame */
01032 #endif
01033     u_int8_t isl_shost[6];    /* source address */
01034     u_int16_t isl_len;        /* total length of packet - 18 bytes */
01035     u_int8_t isl_snap[6];     /* 0xaaaa03 + vendor code */
01036     u_int16_t isl_vid;        /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */
01037     u_int16_t isl_index;      /* port index */
01038     u_int16_t isl_reserved;   /* used for FDDI and token ring */
01039     /* ethernet frame and 4 byte isl crc */
01040 };
01041 
01042 #ifndef IPPROTO_OSPF
01043 #define IPPROTO_OSPF    89  /* not everyone's got this */
01044 #endif
01045 #define IPPROTO_OSPF_LSA    890     /* made this up.  Hope it's unused */
01046 #define LIBNET_MODX         4102    /* used in LSA checksum */
01047 
01048 /*
01049  *  Options used in multiple OSPF packets
01050  *  More info can be found in section A.2 of RFC 2328.
01051  */
01052 #define LIBNET_OPT_EBIT  0x02 /* describes the way AS-external-LSAs are flooded */
01053 #define LIBNET_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */
01054 #define LIBNET_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */
01055 #define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */
01056 #define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits */
01057 
01058 
01059 /*
01060  *  MPLS header
01061  *  Multi-Protocol Label Switching
01062  *  Static header size: 4 bytes
01063  */
01064 struct libnet_mpls_hdr
01065 {
01066     u_int32_t mpls_les;          /* 20 bits label, 3 bits exp, 1 bit bos, ttl */
01067 #define LIBNET_MPLS_BOS_ON    1
01068 #define LIBNET_MPLS_BOS_OFF   0
01069 };
01070 
01071 /*
01072  *  NTP header
01073  *  Network Time Protocol
01074  *  Static header size: 48 bytes
01075  */
01076 struct libnet_ntp_hdr_l_fp  /* int32_t floating point (64-bit) */
01077 {
01078     u_int32_t integer;         /* integer */
01079     u_int32_t fraction;        /* fraction */
01080 };
01081 
01082 struct libnet_ntp_hdr_s_fp  /* int16_t floating point (32-bit) */
01083 {
01084     u_int16_t integer;        /* integer */
01085     u_int16_t fraction;       /* fraction */
01086 };
01087 
01088 
01089 struct libnet_ntp_hdr
01090 {
01091     u_int8_t ntp_li_vn_mode;              /* leap indicator, version, mode */
01092 #define LIBNET_NTP_LI_NW    0x0         /* no warning */
01093 #define LIBNET_NTP_LI_AS    0x1         /* last minute has 61 seconds */
01094 #define LIBNET_NTP_LI_DS    0x2         /* last minute has 59 seconds */
01095 #define LIBNET_NTP_LI_AC    0x3         /* alarm condition */
01096 
01097 #define LIBNET_NTP_VN_2     0x2         /* version 2 */
01098 #define LIBNET_NTP_VN_3     0x3         /* version 3 */
01099 #define LIBNET_NTP_VN_4     0x4         /* version 4 */
01100 
01101 #define LIBNET_NTP_MODE_R   0x0         /* reserved */
01102 #define LIBNET_NTP_MODE_A   0x1         /* symmetric active */
01103 #define LIBNET_NTP_MODE_P   0x2         /* symmetric passive */
01104 #define LIBNET_NTP_MODE_C   0x3         /* client */
01105 #define LIBNET_NTP_MODE_S   0x4         /* server */
01106 #define LIBNET_NTP_MODE_B   0x5         /* broadcast */
01107 #define LIBNET_NTP_MODE_RC  0x6         /* reserved for NTP control message */
01108 #define LIBNET_NTP_MODE_RP  0x7         /* reserved for private use */
01109     u_int8_t ntp_stratum;                 /* stratum */
01110 #define LIBNET_NTP_STRATUM_UNAVAIL  0x0 /* unspecified or unavailable */
01111 #define LIBNET_NTP_STRATUM_PRIMARY  0x1 /* primary reference (radio clock) */
01112                                         /* 2 - 15 is secondary */
01113                                         /* 16 - 255 is reserved */
01114     u_int8_t ntp_poll;                    /* poll interval (should be 4 - 12) */
01115     u_int8_t ntp_precision;               /* local clock precision */
01116     struct libnet_ntp_hdr_s_fp ntp_delay;       /* roundtrip delay */
01117     struct libnet_ntp_hdr_s_fp ntp_dispersion;  /* nominal error */
01118     u_int32_t ntp_reference_id;                /* reference source id */
01119 #define LIBNET_NTP_REF_LOCAL    0x4c4f434c  /* uncalibrated local clock */
01120 #define LIBNET_NTP_REF_PPS      0x50505300  /* atomic / pulse-per-second clock */
01121 #define LIBNET_NTP_REF_ACTS     0x41435453  /* NIST dialup modem */
01122 #define LIBNET_NTP_REF_USNO     0x55534e4f  /* USNO modem service */
01123 #define LIBNET_NTP_REF_PTB      0x50544200  /* PTB (German) modem service */ 
01124 #define LIBNET_NTP_REF_TDF      0x54444600  /* Allouis (French) radio */
01125 #define LIBNET_NTP_REF_DCF      0x44434600  /* Mainflingen (German) radio */
01126 #define LIBNET_NTP_REF_MSF      0x4d534600  /* Rugby (UK) radio */
01127 #define LIBNET_NTP_REF_WWV      0x57575600  /* Ft Collins (US) radio */
01128 #define LIBNET_NTP_REF_WWVB     0x57575642  /* Boulder (US) radio */
01129 #define LIBNET_NTP_REF_WWVH     0x57575648  /* Kaui Hawaii (US) radio */
01130 #define LIBNET_NTP_REF_CHU      0x43485500  /* Ottaha (Canada) radio */
01131 #define LIBNET_NTP_REF_LORC     0x4c4f5243  /* LORAN-C radionavigation */
01132 #define LIBNET_NTP_REF_OMEG     0x4f4d4547  /* OMEGA radionavigation */
01133 #define LIBNET_NTP_REF_GPS      0x47505300  /* global positioning system */
01134 #define LIBNET_NTP_REF_GOES     0x474f4553  /* geostationary orbit env satellite */
01135     struct libnet_ntp_hdr_l_fp ntp_ref_ts;  /* reference timestamp */ 
01136     struct libnet_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */
01137     struct libnet_ntp_hdr_l_fp ntp_rec_ts;  /* receive timestamp */
01138     struct libnet_ntp_hdr_l_fp ntp_xmt_ts;  /* transmit timestamp */
01139 };
01140 
01141 
01142 /*
01143  *  OSPFv2 header
01144  *  Open Shortest Path First
01145  *  Static header size: 16 bytes
01146  */
01147 struct libnet_ospf_hdr
01148 {
01149     u_int8_t ospf_v;          /* version */
01150 #define OSPFVERSION         2
01151     u_int8_t ospf_type;       /* type */
01152 #define  LIBNET_OSPF_UMD    0   /* UMd monitoring packet */
01153 #define  LIBNET_OSPF_HELLO  1   /* HELLO packet */
01154 #define  LIBNET_OSPF_DBD    2   /* dataBase description packet */
01155 #define  LIBNET_OSPF_LSR    3   /* link state request packet */
01156 #define  LIBNET_OSPF_LSU    4   /* link state Update Packet */
01157 #define  LIBNET_OSPF_LSA    5   /* link state acknowledgement packet */
01158     u_int16_t   ospf_len;     /* length */
01159     struct in_addr ospf_rtr_id; /* source router ID */
01160     struct in_addr ospf_area_id;/* roam ID */
01161     u_int16_t ospf_cksum;         /* checksum */
01162     u_int16_t ospf_auth_type;     /* authentication type */
01163 #define LIBNET_OSPF_AUTH_NULL   0   /* null password */
01164 #define LIBNET_OSPF_AUTH_SIMPLE 1   /* simple, plaintext, 8 int8_t password */
01165 #define LIBNET_OSPF_AUTH_MD5    2   /* MD5 */
01166 };
01167 
01168 
01169 /*
01170  *  OSPF authentication header
01171  *  Open Shortest Path First
01172  *  Static header size: 8 bytes
01173  */
01174 struct libnet_auth_hdr
01175 {
01176     u_int16_t ospf_auth_null; /* NULL */
01177     u_int8_t ospf_auth_keyid; /* authentication key ID */
01178     u_int8_t ospf_auth_len;   /* auth data length */
01179     u_int ospf_auth_seq;    /* cryptographic sequence number */
01180 };
01181 
01182 
01183 /*
01184  *  OSPF hello header
01185  *  Open Shortest Path First
01186  *  Static header size: 28 bytes
01187  */
01188 struct libnet_ospf_hello_hdr
01189 {
01190     struct in_addr hello_nmask; /* netmask associated with the interface */
01191     u_int16_t hello_intrvl;       /* num of seconds between routers last packet */
01192     u_int8_t hello_opts;          /* Options for HELLO packets (look above) */
01193     u_int8_t hello_rtr_pri;       /* router's priority (if 0, can't be backup) */
01194     u_int hello_dead_intvl;     /* # of secs a router is silent till deemed down */
01195     struct in_addr hello_des_rtr;   /* Designated router on the network */
01196     struct in_addr hello_bkup_rtr;  /* Backup router */
01197     struct in_addr hello_nbr;       /* neighbor router, memcpy more as needed */
01198 };
01199 
01200 
01201 /*
01202  *  Database Description header.
01203  */
01204 struct libnet_dbd_hdr
01205 {
01206     u_int16_t dbd_mtu_len;    /* max length of IP dgram that this 'if' can use */
01207     u_int8_t dbd_opts;        /* DBD packet options (from above) */
01208     u_int8_t dbd_type;        /* type of exchange occurring */
01209 #define LIBNET_DBD_IBI      0x01    /* init */
01210 #define LIBNET_DBD_MBIT     0x02    /* more DBD packets are to come */
01211 #define LIBNET_DBD_MSBIT    0x04    /* If 1, sender is the master in the exchange */
01212     u_int  dbd_seq;         /* DBD sequence number */
01213 };
01214 
01215 
01216 /*
01217  *  used for the LS type field in all LS* headers
01218  */
01219 #define LIBNET_LS_TYPE_RTR      1   /* router-LSA */
01220 #define LIBNET_LS_TYPE_NET      2   /* network-LSA */
01221 #define LIBNET_LS_TYPE_IP       3   /* summary-LSA (IP Network) */
01222 #define LIBNET_LS_TYPE_ASBR     4   /* summary-LSA (ASBR) */
01223 #define LIBNET_LS_TYPE_ASEXT    5   /* AS-external-LSA */
01224 
01225 
01226 /*
01227  *  Link State Request header
01228  */
01229 struct libnet_lsr_hdr
01230 {
01231     u_int lsr_type;             /* type of LS being requested */
01232     u_int lsr_lsid;             /* link state ID */
01233     struct in_addr lsr_adrtr;   /* advertising router (memcpy more as needed) */
01234 };
01235 
01236 
01237 /*
01238  *  Link State Update header
01239  */
01240 struct libnet_lsu_hdr
01241 {
01242     u_int lsu_num;              /* number of LSAs that will be broadcasted */
01243 };
01244 
01245 
01246 /*
01247  *  Link State Acknowledgement header.
01248  */
01249 struct libnet_lsa_hdr
01250 {
01251     u_int16_t lsa_age;        /* time in seconds since the LSA was originated */
01252     u_int8_t lsa_opts;        /* look above for OPTS_* */
01253     u_int8_t lsa_type;        /* look below for LS_TYPE_* */
01254     u_int lsa_id;           /* link State ID */
01255     struct in_addr lsa_adv; /* router ID of Advertising router */
01256     u_int lsa_seq;          /* LSA sequence number to detect old/bad ones */
01257     u_int16_t lsa_cksum;      /* "Fletcher Checksum" of all fields minus age */
01258     u_int16_t lsa_len;        /* length in bytes including the 20 byte header */
01259 };
01260 
01261 
01262 /*
01263  *  Router LSA data format
01264  *
01265  *  Other stuff for TOS can be added for backward compatability, for this
01266  *  version, only OSPFv2 is being FULLY supported.
01267  */
01268 struct libnet_rtr_lsa_hdr
01269 {
01270     u_int16_t rtr_flags;      /* set to help describe packet */
01271 #define LIBNET_RTR_FLAGS_W  0x0100  /* W bit */
01272 #define LIBNET_RTR_FLAGS_E  0x0200  /* E bit */
01273 #define LIBNET_RTR_FLAGS_B  0x0400  /* B bit */
01274     u_int16_t rtr_num;        /* number of links within that packet */
01275     u_int rtr_link_id;      /* describes link_data (look below) */
01276 #define LIBNET_LINK_ID_NBR_ID   1   /* Neighbors router ID, also can be 4 */
01277 #define LIBNET_LINK_ID_IP_DES   2   /* IP address of designated router */
01278 #define LIBNET_LINK_ID_SUB      3   /* IP subnet number */
01279     u_int rtr_link_data;    /* Depending on link_id, info is here */
01280     u_int8_t rtr_type;        /* Description of router link */
01281 #define LIBNET_RTR_TYPE_PTP     1   /* Point-To-Point */
01282 #define LIBNET_RTR_TYPE_TRANS   2   /* Connection to a "transit network" */
01283 #define LIBNET_RTR_TYPE_STUB    3   /* Connectin to a "stub network" */
01284 #define RTR_TYPE_VRTL   4   /* connects to a "virtual link" */
01285     u_int8_t rtr_tos_num;     /* number of different TOS metrics for this link */
01286     u_int16_t rtr_metric;     /* the "cost" of using this link */
01287 };
01288 
01289 
01290 /*
01291  *  Network LSA data format.
01292  */
01293 struct libnet_net_lsa_hdr
01294 {
01295     struct in_addr net_nmask;   /* Netmask for that network */
01296     u_int  net_rtr_id;          /* ID of router attached to that network */
01297 };
01298  
01299  
01300 /*
01301  *  Summary LSA data format.
01302  */
01303 struct libnet_sum_lsa_hdr
01304 {
01305     struct in_addr sum_nmask;   /* Netmask of destination IP address */
01306     u_int  sum_metric;          /* Same as in rtr_lsa (&0xfff to use last 24bit */
01307     u_int  sum_tos_metric;      /* first 8bits are TOS, 24bits are TOS Metric */
01308 };
01309  
01310  
01311 /*
01312  *  AS External LSA data format.
01313  *  & 0xfff logic operator for as_metric to get last 24bits.
01314  */
01315 struct libnet_as_lsa_hdr
01316 {
01317     struct in_addr as_nmask;    /* Netmask for advertised destination */
01318     u_int  as_metric;           /* May have to set E bit in first 8bits */
01319 #define LIBNET_AS_E_BIT_ON 0x80000000  /* as_metric */
01320     struct in_addr as_fwd_addr; /* Forwarding address */
01321     u_int  as_rte_tag;          /* External route tag */
01322 };
01323 
01324 
01325 /*
01326  *  Base RIP header
01327  *  Routing Information Protocol
01328  *  Base header size: 24 bytes
01329  */
01330 struct libnet_rip_hdr
01331 {
01332     u_int8_t rip_cmd;         /* RIP command */
01333 #define RIPCMD_REQUEST   1  /* want info */
01334 #define RIPCMD_RESPONSE  2  /* responding to request */
01335 #define RIPCMD_TRACEON   3  /* turn tracing on */
01336 #define RIPCMD_TRACEOFF  4  /* turn it off */
01337 #define RIPCMD_POLL      5  /* like request, but anyone answers */
01338 #define RIPCMD_POLLENTRY 6  /* like poll, but for entire entry */
01339 #define RIPCMD_MAX       7  /* ? command */
01340     u_int8_t rip_ver;         /* RIP version */
01341 #define RIPVER_0         0
01342 #define RIPVER_1         1
01343 #define RIPVER_2         2
01344     u_int16_t rip_rd;         /* Zero (v1) or Routing Domain (v2) */
01345     u_int16_t rip_af;         /* Address family */
01346     u_int16_t rip_rt;         /* Zero (v1) or Route Tag (v2) */
01347     u_int32_t rip_addr;        /* IP address */
01348     u_int32_t rip_mask;        /* Zero (v1) or Subnet Mask (v2) */
01349     u_int32_t rip_next_hop;    /* Zero (v1) or Next hop IP address (v2) */
01350     u_int32_t rip_metric;      /* Metric */
01351 };
01352 
01353 /*
01354  *  RPC headers
01355  *  Remote Procedure Call
01356  */
01357 #define LIBNET_RPC_CALL  0
01358 #define LIBNET_RPC_REPLY 1
01359 #define LIBNET_RPC_VERS  2
01360 #define LIBNET_RPC_LAST_FRAG 0x80000000
01361 
01362 /*
01363  *  Portmap defines
01364  */
01365 #define LIBNET_PMAP_PROGRAM          100000
01366 #define LIBNET_PMAP_PROC_NULL        0
01367 #define LIBNET_PMAP_PROC_SET         1
01368 #define LIBNET_PMAP_PROC_UNSET       2
01369 #define LIBNET_PMAP_PROC_GETADDR     3
01370 #define LIBNET_PMAP_PROC_DUMP        4
01371 #define LIBNET_PMAP_PROC_CALLIT      5
01372 #define LIBNET_PMAP_PROC_BCAST       5 /* Not a typo */
01373 #define LIBNET_PMAP_PROC_GETTIME     6
01374 #define LIBNET_PMAP_PROC_UADDR2TADDR 7
01375 #define LIBNET_PMAP_PROC_TADDR2UADDR 8
01376 #define LIBNET_PMAP_PROC_GETVERSADDR 9
01377 #define LIBNET_PMAP_PROC_INDIRECT    10
01378 #define LIBNET_PMAP_PROC_GETADDRLIST 11
01379 #define LIBNET_PMAP_PROC_GETSTAT     12
01380 
01381 /* There will be more to add... */
01382 
01383 struct libnet_rpc_opaque_auth
01384 {
01385     u_int32_t rpc_auth_flavor;
01386     u_int32_t rpc_auth_length;
01387 //    u_int8_t *rpc_auth_data;
01388 };
01389 
01390 struct libnet_rpc_call
01391 {
01392     u_int32_t rpc_rpcvers;   /* RPC version - must be 2 */
01393     u_int32_t rpc_prognum;   /* Program Number */
01394     u_int32_t rpc_vers;      /* Program Version */
01395     u_int32_t rpc_procedure; /* RPC procedure */
01396     struct libnet_rpc_opaque_auth rpc_credentials;
01397     struct libnet_rpc_opaque_auth rpc_verifier;
01398 };
01399 
01400 struct libnet_rpc_call_hdr
01401 {
01402     u_int32_t rpc_xid;  /* xid (transaction identifier) */
01403     u_int32_t rpc_type;
01404     struct libnet_rpc_call  rpc_call;
01405 };
01406 
01407 struct libnet_rpc_call_tcp_hdr
01408 {
01409     u_int32_t rpc_record_marking; /* used with byte stream protocols */
01410     struct libnet_rpc_call_hdr rpc_common;
01411 };
01412 
01413 /*
01414  *  STP configuration header
01415  *  Spanning Tree Protocol
01416  *  Static header size: 35 bytes
01417  */
01418 struct libnet_stp_conf_hdr
01419 {
01420     u_int16_t stp_id;         /* protocol id */
01421     u_int8_t stp_version;     /* protocol version */
01422     u_int8_t stp_bpdu_type;   /* bridge protocol data unit type */
01423     u_int8_t stp_flags;       /* control flags */
01424     u_int8_t stp_rootid[8];   /* root id */
01425     u_int32_t stp_rootpc;      /* root path cost */
01426     u_int8_t stp_bridgeid[8]; /* bridge id */
01427     u_int16_t stp_portid;     /* port id */
01428     u_int16_t stp_mage;       /* message age */
01429     u_int16_t stp_maxage;     /* max age */
01430     u_int16_t stp_hellot;     /* hello time */
01431     u_int16_t stp_fdelay;     /* forward delay */
01432 };
01433 
01434 
01435 /*
01436  *  STP topology change notification header
01437  *  Spanning Tree Protocol
01438  *  Static header size: 4 bytes
01439  */
01440 struct libnet_stp_tcn_hdr
01441 {
01442     u_int16_t stp_id;         /* protocol id */
01443     u_int8_t stp_version;     /* protocol version */
01444     u_int8_t stp_bpdu_type;   /* bridge protocol data unit type */
01445 };
01446 
01447 
01448 /*
01449  *  TCP header
01450  *  Transmission Control Protocol
01451  *  Static header size: 20 bytes
01452  */
01453 struct libnet_tcp_hdr
01454 {
01455     u_int16_t th_sport;       /* source port */
01456     u_int16_t th_dport;       /* destination port */
01457     u_int32_t th_seq;          /* sequence number */
01458     u_int32_t th_ack;          /* acknowledgement number */
01459 #if (LIBNET_LIL_ENDIAN)
01460     u_int8_t th_x2:4,         /* (unused) */
01461            th_off:4;        /* data offset */
01462 #endif
01463 #if (LIBNET_BIG_ENDIAN)
01464     u_int8_t th_off:4,        /* data offset */
01465            th_x2:4;         /* (unused) */
01466 #endif
01467     u_int8_t  th_flags;       /* control flags */
01468 #ifndef TH_FIN
01469 #define TH_FIN    0x01      /* finished send data */
01470 #endif
01471 #ifndef TH_SYN
01472 #define TH_SYN    0x02      /* synchronize sequence numbers */
01473 #endif
01474 #ifndef TH_RST
01475 #define TH_RST    0x04      /* reset the connection */
01476 #endif
01477 #ifndef TH_PUSH
01478 #define TH_PUSH   0x08      /* push data to the app layer */
01479 #endif
01480 #ifndef TH_ACK
01481 #define TH_ACK    0x10      /* acknowledge */
01482 #endif
01483 #ifndef TH_URG
01484 #define TH_URG    0x20      /* urgent! */
01485 #endif
01486     u_int16_t th_win;         /* window */
01487     u_int16_t th_sum;         /* checksum */
01488     u_int16_t th_urp;         /* urgent pointer */
01489 };
01490 
01491 /*
01492  *  Token Ring Header
01493  */
01494 struct libnet_token_ring_hdr
01495 {
01496     u_int8_t  token_ring_access_control;
01497 #define LIBNET_TOKEN_RING_FRAME  0x10
01498     u_int8_t  token_ring_frame_control;
01499 #define LIBNET_TOKEN_RING_LLC_FRAME  0x40
01500     u_int8_t  token_ring_dhost[TOKEN_RING_ADDR_LEN];
01501     u_int8_t  token_ring_shost[TOKEN_RING_ADDR_LEN];
01502     u_int8_t  token_ring_llc_dsap;
01503     u_int8_t  token_ring_llc_ssap;
01504     u_int8_t  token_ring_llc_control_field;
01505     u_int8_t  token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE];
01506     u_int16_t token_ring_type;
01507 #define TOKEN_RING_TYPE_IP            0x0800  /* IP protocol */
01508 #define TOKEN_RING_TYPE_ARP           0x0806  /* addr. resolution protocol */
01509 #define TOKEN_RING_TYPE_REVARP        0x8035  /* reverse addr. resolution protocol */
01510 };
01511 
01512 struct libnet_token_ring_addr
01513 {
01514     u_int8_t  token_ring_addr_octet[6];        /* Token Ring address */
01515 };
01516 
01517 /*
01518  *  UDP header
01519  *  User Data Protocol
01520  *  Static header size: 8 bytes
01521  */
01522 struct libnet_udp_hdr
01523 {
01524     u_int16_t uh_sport;       /* soure port */
01525     u_int16_t uh_dport;       /* destination port */
01526     u_int16_t uh_ulen;        /* length */
01527     u_int16_t uh_sum;         /* checksum */
01528 };
01529 
01530 
01531 /*
01532  *  VRRP header
01533  *  Virtual Router Redundancy Protocol
01534  *  Static header size: 8 bytes
01535  */
01536 #ifndef IPPROTO_VRRP
01537 #define IPPROTO_VRRP 112    /* not everyone's got this */
01538 #endif
01539 struct libnet_vrrp_hdr
01540 {
01541 #if (LIBNET_LIL_ENDIAN)
01542     u_int8_t vrrp_v:4,        /* protocol version */
01543            vrrp_t:4;        /* packet type */
01544 #endif
01545 #if (LIBNET_BIG_ENDIAN)
01546     u_int8_t vrrp_t:4,        /* packet type */
01547            vrrp_v:4;        /* protocol version */
01548 #endif
01549 #define LIBNET_VRRP_VERSION_01  0x1
01550 #define LIBNET_VRRP_VERSION_02  0x2
01551 #define LIBNET_VRRP_TYPE_ADVERT 0x1
01552     u_int8_t vrrp_vrouter_id; /* virtual router id */
01553     u_int8_t vrrp_priority;   /* priority */
01554     u_int8_t vrrp_ip_count;   /* number of IP addresses */
01555     u_int8_t vrrp_auth_type;  /* authorization type */
01556 #define LIBNET_VRRP_AUTH_NONE   0x1
01557 #define LIBNET_VRRP_AUTH_PASSWD 0x2
01558 #define LIBNET_VRRP_AUTH_IPAH   0x3
01559     u_int8_t vrrp_advert_int; /* advertisement interval */
01560     u_int16_t vrrp_sum;       /* checksum */
01561     /* additional addresses */
01562     /* authentication info */
01563 };
01564 
01565 #endif  /* __LIBNET_HEADERS_H */
01566 
01567 /* EOF */

Generated on Wed Nov 12 09:57:54 2003 for libnet by doxygen 1.3.2