⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libnet-headers.h

📁 tcp数据流重放工具
💻 H
📖 第 1 页 / 共 4 页
字号:
/* *  $Id: libnet-headers.h,v 1.5 2003/09/23 22:36:54 mike Exp $ * *  libnet-headers.h - Network routine library headers header file * *  Copyright (c) 1998 - 2002 Mike D. Schiffman <mike@infonexus.com> *  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */#ifndef __LIBNET_HEADERS_H#define __LIBNET_HEADERS_H#define LIBNET_802_1Q_H         0x12    /* 802.1Q header:       18 bytes */#define LIBNET_802_1X_H         0x04    /* 802.1X header:        4 bytes */#define LIBNET_802_2_H          0x03    /* 802.2 LLC header:     3 bytes */#define LIBNET_802_2SNAP_H      0x08    /* 802.2 LLC/SNAP header:8 bytes */#define LIBNET_802_3_H          0x0e    /* 802.3 header:        14 bytes */#define LIBNET_ARP_H            0x08    /* ARP header w/o addrs: 8 bytes */#define LIBNET_ARP_ETH_IP_H     0x1c    /* ARP w/ ETH and IP:   28 bytes */#define LIBNET_BGP4_HEADER_H    0x13    /* BGP header:          19 bytes */#define LIBNET_BGP4_OPEN_H      0x0a    /* BGP open header:     10 bytes */#define LIBNET_BGP4_UPDATE_H    0x04    /* BGP open header:      4 bytes */#define LIBNET_BGP4_NOTIFICATION_H 0x02 /* BGP notif. header:    2 bytes */#define LIBNET_CDP_H            0x08    /* CDP header base:      8 bytes */#define LIBNET_DHCPV4_H         0xf0    /* DHCP v4 header:     240 bytes */#define LIBNET_UDP_DNSV4_H      0x0c    /* UDP DNS v4 header:   12 bytes */#define LIBNET_TCP_DNSV4_H      0x0e    /* TCP DNS v4 header:   14 bytes */#define LIBNET_ETH_H            0x0e    /* Ethernet header:     14 bytes */#define LIBNET_FDDI_H           0x15    /* FDDI header:         21 bytes */#define LIBNET_ICMPV4_H         0x04    /* ICMP header base:     4 bytes */#define LIBNET_ICMPV4_ECHO_H    0x08    /* ICMP_ECHO header:     8 bytes */#define LIBNET_ICMPV4_MASK_H    0x0c    /* ICMP_MASK header:    12 bytes */#define LIBNET_ICMPV4_UNREACH_H  0x08   /* ICMP_UNREACH header:  8 bytes */#define LIBNET_ICMPV4_TIMXCEED_H 0x08   /* ICMP_TIMXCEED header: 8 bytes */#define LIBNET_ICMPV4_REDIRECT_H 0x08   /* ICMP_REDIRECT header: 8 bytes */#define LIBNET_ICMPV4_TS_H      0x14    /* ICMP_TIMESTAMP headr:20 bytes */#define LIBNET_ICMPV6_H         0x08    /* ICMP6 header base:    8 bytes */#define LIBNET_IGMP_H           0x08    /* IGMP header:          8 bytes */#define LIBNET_IPV4_H           0x14    /* IPv4 header:         20 bytes */#define LIBNET_IPV6_H           0x28    /* IPv6 header:         40 bytes */#define LIBNET_IPSEC_ESP_HDR_H  0x0c    /* IPSEC ESP header:    12 bytes */#define LIBNET_IPSEC_ESP_FTR_H  0x02    /* IPSEC ESP footer:     2 bytes */#define LIBNET_IPSEC_AH_H       0x10    /* IPSEC AH header:     16 bytes */#define LIBNET_ISL_H            0x1a    /* ISL header:          26 bytes */#define LIBNET_GRE_H            0x04    /* GRE header:           4 bytes */#define LIBNET_GRE_SRE_H        0x04    /* GRE SRE header:       4 bytes */#define LIBNET_MPLS_H           0x04    /* MPLS header:          4 bytes */#define LIBNET_OSPF_H           0x10    /* OSPF header:         16 bytes */#define LIBNET_OSPF_HELLO_H     0x18    /* OSPF hello header:   24 bytes */#define LIBNET_OSPF_DBD_H       0x08    /* OSPF DBD header:      8 bytes */#define LIBNET_OSPF_LSR_H       0x0c    /* OSPF LSR header:     12 bytes */#define LIBNET_OSPF_LSU_H       0x04    /* OSPF LSU header:      4 bytes */#define LIBNET_OSPF_LSA_H       0x14    /* OSPF LSA header:     20 bytes */#define LIBNET_OSPF_AUTH_H      0x08    /* OSPF AUTH header:     8 bytes */#define LIBNET_OSPF_CKSUM       0x10    /* OSPF CKSUM header:   16 bytes */#define LIBNET_OSPF_LS_RTR_H    0x10    /* OSPF LS RTR header:  16 bytes */#define LIBNET_OSPF_LS_NET_H    0x08    /* OSPF LS NET header:   8 bytes */#define LIBNET_OSPF_LS_SUM_H    0x0c    /* OSPF LS SUM header:  12 bytes */#define LIBNET_OSPF_LS_AS_EXT_H 0x10    /* OSPF LS AS header:   16 bytes */#define LIBNET_NTP_H            0x30    /* NTP header:          48 bytes */#define LIBNET_RIP_H            0x18    /* RIP header base:     24 bytes */#define LIBNET_RPC_CALL_H       0x28    /* RPC header:          40 bytes */                                        /* (assuming 8 byte auth header) */#define LIBNET_RPC_CALL_TCP_H   0x2c    /* RPC header:          44 bytes */                                        /* (with record marking)         */#define LIBNET_STP_CONF_H       0x23    /* STP conf header:     35 bytes */#define LIBNET_STP_TCN_H        0x04    /* STP tcn header:       4 bytes */#define LIBNET_TOKEN_RING_H     0x16    /* Token Ring header:   22 bytes */#define LIBNET_TCP_H            0x14    /* TCP header:          20 bytes */#define LIBNET_UDP_H            0x08    /* UDP header:           8 bytes */#define LIBNET_VRRP_H           0x08    /* VRRP header:          8 bytes *//* *  IEEE 802.1Q VLAN header (ethervlan) *  Virtual Local Area Network *  static header size: 18 bytes */struct libnet_802_1q_hdr{    u_int8_t vlan_dhost[ETHER_ADDR_LEN];  /* destination ethernet address */    u_int8_t vlan_shost[ETHER_ADDR_LEN];  /* source ethernet address */    u_int16_t vlan_tpi;                   /* tag protocol ID */    u_int16_t vlan_priority_c_vid;        /* priority | VLAN ID */#define LIBNET_802_1Q_PRIMASK   0x0007  /* priority mask */#define LIBNET_802_1Q_CFIMASK   0x0001  /* CFI mask */#define LIBNET_802_1Q_VIDMASK   0x0fff  /* vid mask */    u_int16_t vlan_len;                   /* len / type (802.3 / Ethernet II) */};  /* *  IEEE 802.1X EAP header *  Extensible Authentication Protocol *  static header size: 4 bytes */struct libnet_802_1x_hdr{    u_int8_t dot1x_version;       /* protocol version */    u_int8_t dot1x_type;          /* frame type */#define LIBNET_802_1X_PACKET    0x00#define LIBNET_802_1X_START     0x01#define LIBNET_802_1X_LOGOFF    0x02#define LIBNET_802_1X_KEY       0x03#define LIBNET_802_1X_ENCASFAL  0x04    u_int16_t dot1x_length;       /* total frame length */};  /* *  IEEE 802.2 LLC header *  Link Layer Control *  static header size: 3 bytes */struct libnet_802_2_hdr{    u_int8_t llc_dsap;            /* destination service access point */    u_int8_t llc_ssap;            /* source service access point */#define LIBNET_SAP_STP          0x42#define LIBNET_SAP_SNAP         0xaa    u_int8_t llc_control;         /* control field */};/* *  IEEE 802.2 LLC/SNAP header *  SubNetwork Attachment Point *  static header size: 8 bytes */struct libnet_802_2snap_hdr{    u_int8_t snap_dsap;           /* destination service access point */    u_int8_t snap_ssap;           /* destination service access point */    u_int8_t snap_control;        /* control field */    u_int8_t snap_oui[3];         /* OUI */    u_int16_t snap_type;          /* type */};/* *  802.3 header *  IEEE Ethernet *  Static header size: 14 bytes */struct libnet_802_3_hdr{    u_int8_t  _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */    u_int8_t  _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */    u_int16_t _802_3_len;                 /* packet type ID */};/*  *  ARP header *  Address Resolution Protocol *  Base header size: 8 bytes */struct libnet_arp_hdr{    u_int16_t ar_hrd;         /* format of hardware address */#define ARPHRD_NETROM   0   /* from KA9Q: NET/ROM pseudo */#define ARPHRD_ETHER    1   /* Ethernet 10Mbps */#define ARPHRD_EETHER   2   /* Experimental Ethernet */#define ARPHRD_AX25     3   /* AX.25 Level 2 */#define ARPHRD_PRONET   4   /* PROnet token ring */#define ARPHRD_CHAOS    5   /* Chaosnet */#define ARPHRD_IEEE802  6   /* IEEE 802.2 Ethernet/TR/TB */#define ARPHRD_ARCNET   7   /* ARCnet */#define ARPHRD_APPLETLK 8   /* APPLEtalk */#define ARPHRD_LANSTAR  9   /* Lanstar */#define ARPHRD_DLCI     15  /* Frame Relay DLCI */#define ARPHRD_ATM      19  /* ATM */#define ARPHRD_METRICOM 23  /* Metricom STRIP (new IANA id) */#define ARPHRD_IPSEC    31  /* IPsec tunnel */    u_int16_t ar_pro;         /* format of protocol address */    u_int8_t  ar_hln;         /* length of hardware address */    u_int8_t  ar_pln;         /* length of protocol addres */    u_int16_t ar_op;          /* operation type */#define ARPOP_REQUEST    1  /* req to resolve address */#define ARPOP_REPLY      2  /* resp to previous request */#define ARPOP_REVREQUEST 3  /* req protocol address given hardware */#define ARPOP_REVREPLY   4  /* resp giving protocol address */#define ARPOP_INVREQUEST 8  /* req to identify peer */#define ARPOP_INVREPLY   9  /* resp identifying peer */    /* address information allocated dynamically */};/* * BGP4 header * Border Gateway Protocol 4 * Base header size : 19 bytes */struct libnet_bgp4_header_hdr{#define LIBNET_BGP4_MARKER_SIZE   16    u_int8_t marker[LIBNET_BGP4_MARKER_SIZE];    u_int16_t len;    u_int8_t type;#define LIBNET_BGP4_OPEN          1#define LIBNET_BGP4_UPDATE        2#define LIBNET_BGP4_NOTIFICATION  3#define LIBNET_BGP4_KEEPALIVE     4};/* * BGP4 open header * Border Gateway Protocol 4 * Base header size : 10 bytes */struct libnet_bgp4_open_hdr{    u_int8_t version;    u_int16_t src_as;    u_int16_t hold_time;    u_int32_t bgp_id;    u_int8_t opt_len;};/* * BGP4 notification message * * Border Gateway Protocol 4 * Base header size : 2 bytes * * Use payload if you need data */struct libnet_bgp4_notification_hdr{#define LIBNET_BGP4_MESSAGE_HEADER_ERROR  1#define LIBNET_BGP4_OPEN_MESSAGE_ERROR    2#define LIBNET_BGP4_UPDATE_MESSAGE_ERROR  3#define LIBNET_BGP4_HOLD_TIMER_EXPIRED    4#define LIBNET_BGP4_FINITE_STATE__ERROR   5#define LIBNET_BGP4_CEASE                 6    u_int8_t err_code;/* Message Header Error subcodes */#define LIBNET_BGP4_CONNECTION_NOT_SYNCHRONIZED    1#define LIBNET_BGP4_BAD_MESSAGE_LENGTH             2#define LIBNET_BGP4_BAD_MESSAGE_TYPE               3/* OPEN Message Error subcodes */#define LIBNET_BGP4_UNSUPPORTED_VERSION_NUMBER     1#define LIBNET_BGP4_BAD_PEER_AS                    2#define LIBNET_BGP4_BAD_BGP_IDENTIFIER             3#define LIBNET_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4#define LIBNET_BGP4_AUTHENTICATION_FAILURE         5#define LIBNET_BGP4_UNACCEPTABLE_HOLD_TIME         6/* UPDATE Message Error subcodes */#define LIBNET_BGP4_MALFORMED_ATTRIBUTE_LIST#define LIBNET_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE#define LIBNET_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE#define LIBNET_BGP4_ATTRIBUTE_FLAGS_ERROR#define LIBNET_BGP4_ATTRIBUTE_LENGTH_ERROR#define LIBNET_BGP4_INVALID_ORIGIN_ATTRIBUTE#define LIBNET_BGP4_AS_ROUTING_LOOP#define LIBNET_BGP4_INVALID_NEXT_HOP_ATTRIBUTE#define LIBNET_BGP4_OPTIONAL_ATTRIBUTE_ERROR#define LIBNET_BGP4_INVALID_NETWORK_FIELD#define LIBNET_BGP4_MALFORMED_AS_PATH    u_int8_t err_subcode;};/* *  CDP header *  Cisco Discovery Protocol *  Base header size: 8 bytes *//* *  For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001. *  Let's hope this one stays that way for a while! */#define LIBNET_PROTO_CDP    200struct libnet_cdp_hdr{    u_int8_t cdp_version;     /* version (should always be 0x01) */    u_int8_t cdp_ttl;         /* time reciever should hold info in this packet */    u_int16_t cdp_sum;        /* checksum */    u_int16_t cdp_type;       /* type */#define LIBNET_CDP_DEVID    0x1 /* device id */#define LIBNET_CDP_ADDRESS  0x2 /* address */#define LIBNET_CDP_PORTID   0x3 /* port id */#define LIBNET_CDP_CAPABIL  0x4 /* capabilities */#define LIBNET_CDP_VERSION  0x5 /* version */#define LIBNET_CDP_PLATFORM 0x6 /* platform */#define LIBNET_CDP_IPPREFIX 0x7 /* ip prefix */    u_int16_t cdp_len;        /* type + length + value */    /* value information done dynamically *//* CDP capabilities */#define LIBNET_CDP_CAP_L3R  0x01/* performs level 3 routing */#define LIBNET_CDP_CAP_L2B  0x02/* performs level 2 transparent bridging */#define LIBNET_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */#define LIBNET_CDP_CAP_L2S  0x08/* performs level 2 switching */#define LIBNET_CDP_CAP_SR   0x10/* sends and recieves packets on a network */#define LIBNET_CDP_CAP_NOI  0x20/* does not forward IGMP on non-router ports */#define LIBNET_CDP_CAP_L1F  0x40/* provides level 1 functionality */};/* *  Used as an overlay for type/len/values */struct libnet_cdp_value_hdr{    u_int16_t cdp_type;    u_int16_t cdp_len;};/* *  DHCP header *  Dynamic Host Configuration Protocol *  Static header size: f0 bytes */struct libnet_dhcpv4_hdr{    u_int8_t dhcp_opcode;     /* opcode */#define LIBNET_DHCP_REQUEST 0x1#define LIBNET_DHCP_REPLY   0x2    u_int8_t dhcp_htype;      /* hardware address type */    u_int8_t dhcp_hlen;       /* hardware address length */    u_int8_t dhcp_hopcount;   /* used by proxy servers */    u_int32_t dhcp_xid;        /* transaction ID */    u_int16_t dhcp_secs;      /* number of seconds since trying to bootstrap */    u_int16_t dhcp_flags;     /* flags for DHCP, unused for BOOTP */    u_int32_t dhcp_cip;        /* client's IP */    u_int32_t dhcp_yip;        /* your IP */    u_int32_t dhcp_sip;        /* server's IP */    u_int32_t dhcp_gip;        /* gateway IP */    u_int8_t dhcp_chaddr[16]; /* client hardware address */    u_int8_t dhcp_sname[64];  /* server host name */    u_int8_t dhcp_file[128];  /* boot file name */    u_int32_t dhcp_magic;      /* BOOTP magic header */#define DHCP_MAGIC                  0x63825363#define LIBNET_BOOTP_MIN_LEN        0x12c#define LIBNET_DHCP_PAD             0x00#define LIBNET_DHCP_SUBNETMASK      0x01#define LIBNET_DHCP_TIMEOFFSET      0x02#define LIBNET_DHCP_ROUTER          0x03#define LIBNET_DHCP_TIMESERVER      0x04#define LIBNET_DHCP_NAMESERVER      0x05#define LIBNET_DHCP_DNS             0x06#define LIBNET_DHCP_LOGSERV         0x07#define LIBNET_DHCP_COOKIESERV      0x08#define LIBNET_DHCP_LPRSERV         0x09#define LIBNET_DHCP_IMPSERV         0x0a#define LIBNET_DHCP_RESSERV         0x0b#define LIBNET_DHCP_HOSTNAME        0x0c#define LIBNET_DHCP_BOOTFILESIZE    0x0d#define LIBNET_DHCP_DUMPFILE        0x0e#define LIBNET_DHCP_DOMAINNAME      0x0f#define LIBNET_DHCP_SWAPSERV        0x10#define LIBNET_DHCP_ROOTPATH        0x11#define LIBNET_DHCP_EXTENPATH       0x12#define LIBNET_DHCP_IPFORWARD       0x13#define LIBNET_DHCP_SRCROUTE        0x14#define LIBNET_DHCP_POLICYFILTER    0x15#define LIBNET_DHCP_MAXASMSIZE      0x16#define LIBNET_DHCP_IPTTL           0x17#define LIBNET_DHCP_MTUTIMEOUT      0x18#define LIBNET_DHCP_MTUTABLE        0x19#define LIBNET_DHCP_MTUSIZE         0x1a#define LIBNET_DHCP_LOCALSUBNETS    0x1b#define LIBNET_DHCP_BROADCASTADDR   0x1c#define LIBNET_DHCP_DOMASKDISCOV    0x1d#define LIBNET_DHCP_MASKSUPPLY      0x1e#define LIBNET_DHCP_DOROUTEDISC     0x1f#define LIBNET_DHCP_ROUTERSOLICIT   0x20

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -