📄 libnet-headers.h
字号:
#define LIBNET_DHCP_STATICROUTE 0x21#define LIBNET_DHCP_TRAILERENCAP 0x22#define LIBNET_DHCP_ARPTIMEOUT 0x23#define LIBNET_DHCP_ETHERENCAP 0x24#define LIBNET_DHCP_TCPTTL 0x25#define LIBNET_DHCP_TCPKEEPALIVE 0x26#define LIBNET_DHCP_TCPALIVEGARBAGE 0x27#define LIBNET_DHCP_NISDOMAIN 0x28#define LIBNET_DHCP_NISSERVERS 0x29#define LIBNET_DHCP_NISTIMESERV 0x2a#define LIBNET_DHCP_VENDSPECIFIC 0x2b#define LIBNET_DHCP_NBNS 0x2c#define LIBNET_DHCP_NBDD 0x2d#define LIBNET_DHCP_NBTCPIP 0x2e#define LIBNET_DHCP_NBTCPSCOPE 0x2f#define LIBNET_DHCP_XFONT 0x30#define LIBNET_DHCP_XDISPLAYMGR 0x31#define LIBNET_DHCP_DISCOVERADDR 0x32#define LIBNET_DHCP_LEASETIME 0x33#define LIBNET_DHCP_OPTIONOVERLOAD 0x34#define LIBNET_DHCP_MESSAGETYPE 0x35#define LIBNET_DHCP_SERVIDENT 0x36#define LIBNET_DHCP_PARAMREQUEST 0x37#define LIBNET_DHCP_MESSAGE 0x38#define LIBNET_DHCP_MAXMSGSIZE 0x39#define LIBNET_DHCP_RENEWTIME 0x3a#define LIBNET_DHCP_REBINDTIME 0x3b#define LIBNET_DHCP_CLASSSID 0x3c#define LIBNET_DHCP_CLIENTID 0x3d#define LIBNET_DHCP_NISPLUSDOMAIN 0x40#define LIBNET_DHCP_NISPLUSSERVERS 0x41#define LIBNET_DHCP_MOBILEIPAGENT 0x44#define LIBNET_DHCP_SMTPSERVER 0x45#define LIBNET_DHCP_POP3SERVER 0x46#define LIBNET_DHCP_NNTPSERVER 0x47#define LIBNET_DHCP_WWWSERVER 0x48#define LIBNET_DHCP_FINGERSERVER 0x49#define LIBNET_DHCP_IRCSERVER 0x4a#define LIBNET_DHCP_STSERVER 0x4b#define LIBNET_DHCP_STDASERVER 0x4c#define LIBNET_DHCP_END 0xff#define LIBNET_DHCP_MSGDISCOVER 0x01#define LIBNET_DHCP_MSGOFFER 0x02#define LIBNET_DHCP_MSGREQUEST 0x03#define LIBNET_DHCP_MSGDECLINE 0x04#define LIBNET_DHCP_MSGACK 0x05#define LIBNET_DHCP_MSGNACK 0x06#define LIBNET_DHCP_MSGRELEASE 0x07#define LIBNET_DHCP_MSGINFORM 0x08};/* * Base DNSv4 header * Domain Name System * Base header size: 12/14 bytes */struct libnet_dnsv4_hdr{ u_int16_t h_len; /* length of the packet - only used with TCP */ u_int16_t id; /* DNS packet ID */ u_int16_t flags; /* DNS flags */ u_int16_t num_q; /* Number of questions */ u_int16_t num_answ_rr; /* Number of answer resource records */ u_int16_t num_auth_rr; /* Number of authority resource records */ u_int16_t num_addi_rr; /* Number of additional resource records */};/* * Ethernet II header * Static header size: 14 bytes */struct libnet_ethernet_hdr{ u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */ u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */ u_int16_t ether_type; /* protocol */};#ifndef ETHERTYPE_PUP#define ETHERTYPE_PUP 0x0200 /* PUP protocol */#endif#ifndef ETHERTYPE_IP#define ETHERTYPE_IP 0x0800 /* IP protocol */#endif#ifndef ETHERTYPE_ARP#define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */#endif#ifndef ETHERTYPE_REVARP#define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */#endif#ifndef ETHERTYPE_VLAN#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */#endif#ifndef ETHERTYPE_EAP#define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */#endif#ifndef ETHERTYPE_MPLS#define ETHERTYPE_MPLS 0x8847 /* MPLS */#endif#ifndef ETHERTYPE_LOOPBACK#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */#endifstruct libnet_ether_addr{ u_int8_t ether_addr_octet[6]; /* Ethernet address */};/* * Fiber Distributed Data Interface header * * Static header size: 21 bytes (LLC and 48-bit address addr only) * * Note: Organization field is 3 bytes which throws off the * alignment of type. Therefore fddi_type (19 bytes in) * is specified as two u_int8_ts. */struct libnet_fddi_hdr{ u_int8_t fddi_frame_control; /* Class/Format/Priority */#define LIBNET_FDDI_LLC_FRAME 0x10#define LIBNET_FDDI_48BIT_ADDR 0x40#define LIBNET_FDDI_FC_REQD LIBNET_FDDI_LLC_FRAME | LIBNET_FDDI_48BIT_ADDR u_int8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */ u_int8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */ u_int8_t fddi_llc_dsap; /* DSAP */ u_int8_t fddi_llc_ssap; /* SSAP */ u_int8_t fddi_llc_control_field; /* Class/Format/Priority */ u_int8_t fddi_llc_org_code[LIBNET_ORG_CODE_SIZE]; /* Organization Code 3-bytes */ u_int8_t fddi_type; /* Protocol Type */ u_int8_t fddi_type1; /* see note above. */#define FDDI_TYPE_IP 0x0800 /* IP protocol */#define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */#define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */};struct libnet_fddi_addr{ u_int8_t fddi_addr_octet[6]; /* FDDI address */};/* * GRE header - RFC 1701 & 2637 * Generic Routing Encapsulation (GRE) * Base header size: 4 bytes */struct libnet_gre_hdr{ u_int16_t flags_ver;#define GRE_CSUM 0x8000#define GRE_ROUTING 0x4000#define GRE_KEY 0x2000#define GRE_SEQ 0x1000#define GRE_STRICT 0x0800#define GRE_REC 0x0700#define GRE_ACK 0x0080#define GRE_FLAGS_MASK 0x00F8#define GRE_VERSION_MASK 0x0007#define GRE_VERSION_0 0x0000#define GRE_VERSION_1 0x0001 u_int16_t type;#define GRE_SNA 0x0004#define GRE_OSI_NETWORK_LAYER 0x00FE#define GRE_PUP 0x0200#define GRE_XNS 0x0600#define GRE_IP 0x0800#define GRE_CHAOS 0x0804#define GRE_RFC_826_ARP 0x0806#define GRE_FRAME_RELAY_ARP 0x0808#define GRE_VINES 0x0BAD#define GRE_VINES_ECHO 0x0BAE#define GRE_VINES_LOOPBACK 0x0BAF#define GRE_DECNET 0x6003#define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558#define GRE_RAW_FRAME_RELAY 0x6559#define GRE_APOLLO_DOMAIN 0x8019#define GRE_ETHERTALK 0x809B#define GRE_NOVELL_IPX 0x8137#define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B#define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C#define GRE_SECURE_DATA 0x876D#define GRE_PPP 0x880b /* taken from RFC 2637 */ union { struct { u_int16_t checksum; /* optional */ u_int16_t offset; /* optional */ u_int32_t key; /* optional */ u_int32_t seq; /* optional */ } _gre; struct { u_int16_t payload_s; /* optional */ u_int16_t callID; /* optional */ u_int32_t seq; /* optional */ u_int32_t ack; /* optional */ } _egre; }_data;#define gre_checksum _data._gre.checksum#define gre_offset _data._gre.offset#define gre_key _data._gre.key#define gre_seq _data._gre.seq#define egre_payload_s _data._egre.payload_s#define egre_callID _data._egre.callID#define egre_seq _data._egre.seq#define egre_ack _data._egre.ack};#ifndef IPPROTO_GRE#define IPPROTO_GRE 47#endif/* * Source Route Entries (SRE) * This is used for GRE as the Routing field is a list of SREs - RFC 1701 * Base header size: 4 bytes */struct libnet_gre_sre_hdr{ u_int16_t af; /* address familly */ u_int8_t sre_offset; u_int8_t sre_length; u_int8_t *routing;};/* * IPv4 header * Internet Protocol, version 4 * Static header size: 20 bytes */struct libnet_ipv4_hdr{#if (LIBNET_LIL_ENDIAN) u_int8_t ip_hl:4, /* header length */ ip_v:4; /* version */#endif#if (LIBNET_BIG_ENDIAN) u_int8_t ip_v:4, /* version */ ip_hl:4; /* header length */#endif u_int8_t ip_tos; /* type of service */#ifndef IPTOS_LOWDELAY#define IPTOS_LOWDELAY 0x10#endif#ifndef IPTOS_THROUGHPUT#define IPTOS_THROUGHPUT 0x08#endif#ifndef IPTOS_RELIABILITY#define IPTOS_RELIABILITY 0x04#endif#ifndef IPTOS_LOWCOST#define IPTOS_LOWCOST 0x02#endif u_int16_t ip_len; /* total length */ u_int16_t ip_id; /* identification */ u_int16_t ip_off;#ifndef IP_RF#define IP_RF 0x8000 /* reserved fragment flag */#endif#ifndef IP_DF#define IP_DF 0x4000 /* dont fragment flag */#endif#ifndef IP_MF#define IP_MF 0x2000 /* more fragments flag */#endif #ifndef IP_OFFMASK#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */#endif u_int8_t ip_ttl; /* time to live */ u_int8_t ip_p; /* protocol */ u_int16_t ip_sum; /* checksum */ struct in_addr ip_src, ip_dst; /* source and dest address */};/* * IP options */#ifndef IPOPT_EOL#define IPOPT_EOL 0 /* end of option list */#endif#ifndef IPOPT_NOP#define IPOPT_NOP 1 /* no operation */#endif #ifndef IPOPT_RR#define IPOPT_RR 7 /* record packet route */#endif#ifndef IPOPT_TS#define IPOPT_TS 68 /* timestamp */#endif#ifndef IPOPT_SECURITY#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ #endif#ifndef IPOPT_LSRR#define IPOPT_LSRR 131 /* loose source route */#endif#ifndef IPOPT_SATID#define IPOPT_SATID 136 /* satnet id */#endif#ifndef IPOPT_SSRR#define IPOPT_SSRR 137 /* strict source route */#endifstruct libnet_in6_addr{ union { u_int8_t __u6_addr8[16]; u_int16_t __u6_addr16[8]; u_int32_t __u6_addr32[4]; } __u6_addr; /* 128-bit IP6 address */};#define libnet_s6_addr __u6_addr.__u6_addr8 /* * IPv6 header * Internet Protocol, version 6 * Static header size: 40 bytes */struct libnet_ipv6_hdr{ u_int8_t ip_flags[4]; /* version, traffic class, flow label */ u_int16_t ip_len; /* total length */ u_int8_t ip_nh; /* next header */ u_int8_t ip_hl; /* hop limit */ struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */};/* * ICMP6 header * Internet Control Message Protocol v6 * Base header size: 8 bytes */#ifndef IPPROTO_ICMP6#define IPPROTO_ICMP6 0x3a#endifstruct libnet_icmpv6_hdr{ u_int8_t icmp_type; /* ICMP type */#ifndef ICMP6_ECHO#define ICMP6_ECHO 128#endif#ifndef ICMP6_ECHOREPLY#define ICMP6_ECHOREPLY 129#endif#ifndef ICMP6_UNREACH#define ICMP6_UNREACH 1#endif#ifndef ICMP6_PKTTOOBIG#define ICMP6_PKTTOOBIG 2#endif#ifndef ICMP6_TIMXCEED#define ICMP6_TIMXCEED 3#endif#ifndef ICMP6_PARAMPROB#define ICMP6_PARAMPROB 4#endif u_int8_t icmp_code; /* ICMP code */ u_int16_t icmp_sum; /* ICMP Checksum */ u_int16_t id; /* ICMP id */ u_int16_t seq; /* ICMP sequence number */};/* * ICMP header * Internet Control Message Protocol * Base header size: 4 bytes */struct libnet_icmpv4_hdr{ u_int8_t icmp_type; /* ICMP type */#ifndef ICMP_ECHOREPLY#define ICMP_ECHOREPLY 0#endif#ifndef ICMP_UNREACH#define ICMP_UNREACH 3#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -