📄 libnet-headers.h
字号:
/* * $Id: libnet-headers.h,v 1.1.1.1 2000/05/25 00:28:49 route Exp $ * * libnet-headers.h - Network routine library headers header file * * Copyright (c) 1998 - 2001 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/* * Standard (IPv4) header sizes in bytes. */#define LIBNET_ARP_H 0x1c /* ARP header: 28 bytes */#define LIBNET_DNS_H 0xc /* DNS header base: 12 bytes */#define LIBNET_ETH_H 0xe /* Etherner header: 14 bytes */#define LIBNET_ICMP_H 0x4 /* ICMP header base: 4 bytes */#define LIBNET_ICMP_ECHO_H 0x8 /* ICMP_ECHO header: 8 bytes */#define LIBNET_ICMP_MASK_H 0xc /* ICMP_MASK header: 12 bytes */#define LIBNET_ICMP_UNREACH_H 0x8 /* ICMP_UNREACH header: 8 bytes */#define LIBNET_ICMP_TIMXCEED_H 0x8 /* ICMP_TIMXCEED header: 8 bytes */#define LIBNET_ICMP_REDIRECT_H 0x8 /* ICMP_REDIRECT header: 8 bytes */#define LIBNET_ICMP_TS_H 0x14 /* ICMP_TIMESTAMP headr:20 bytes */#define LIBNET_IGMP_H 0x8 /* IGMP header: 8 bytes */#define LIBNET_IP_H 0x14 /* IP header: 20 bytes *//* See libnet-ospf.h for OSPF related header sizes */#define LIBNET_RIP_H 0x18 /* RIP header base: 24 bytes */#define LIBNET_TCP_H 0x14 /* TCP header: 20 bytes */#define LIBNET_UDP_H 0x8 /* UDP header: 8 bytes */#define LIBNET_VRRP_H 0x8 /* VRRP header: 8 bytes *//* * Concession to legacy naming scheme. */#define ARP_H LIBNET_ARP_H#define DNS_H LIBNET_DNS_H#define ETH_H LIBNET_ETH_H#define ICMP_H LIBNET_ICMP_H#define ICMP_ECHO_H LIBNET_ICMP_ECHO_H#define ICMP_MASK_H LIBNET_ICMP_MASK_H#define ICMP_UNREACH_H LIBNET_ICMP_UNREACH_H#define ICMP_TIMXCEED_H LIBNET_ICMP_TIMXCEED_H#define ICMP_REDIRECT_H LIBNET_ICMP_REDIRECT_H#define ICMP_TS_H LIBNET_ICMP_TS_H#define IGMP_H LIBNET_IGMP_H#define IP_H LIBNET_IP_H#define RIP_H LIBNET_RIP_H#define TCP_H LIBNET_TCP_H#define UDP_H LIBNET_UDP_H/* * IPv4 packet header prototype. */struct libnet_ip_hdr{#if (LIBNET_LIL_ENDIAN) u_char ip_hl:4, /* header length */ ip_v:4; /* version */#endif#if (LIBNET_BIG_ENDIAN) u_char ip_v:4, /* version */ ip_hl:4; /* header length */#endif u_char ip_tos; /* type of service */ u_short ip_len; /* total length */ u_short ip_id; /* identification */ u_short 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_char ip_ttl; /* time to live */ u_char ip_p; /* protocol */ u_short ip_sum; /* checksum */ struct in_addr ip_src, ip_dst; /* source and dest address */};/* * TCP packet header prototype. */struct libnet_tcp_hdr{ u_short th_sport; /* source port */ u_short th_dport; /* destination port */ u_long th_seq; /* sequence number */ u_long th_ack; /* acknowledgement number */#if (LIBNET_LIL_ENDIAN) u_char th_x2:4, /* (unused) */ th_off:4; /* data offset */#endif#if (LIBNET_BIG_ENDIAN) u_char th_off:4, /* data offset */ th_x2:4; /* (unused) */#endif u_char th_flags; /* control flags */#ifndef TH_FIN#define TH_FIN 0x01#endif#ifndef TH_SYN#define TH_SYN 0x02#endif#ifndef TH_RST#define TH_RST 0x04#endif#ifndef TH_PUSH#define TH_PUSH 0x08#endif#ifndef TH_ACK#define TH_ACK 0x10#endif#ifndef TH_URG#define TH_URG 0x20#endif u_short th_win; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */};/* * UDP packet header prototype. */struct libnet_udp_hdr{ u_short uh_sport; /* soure port */ u_short uh_dport; /* destination port */ u_short uh_ulen; /* length */ u_short uh_sum; /* checksum */};/* * ICMP packet header prototype. */struct libnet_icmp_hdr{ u_char icmp_type;/* * ICMP types. */#ifndef ICMP_ECHOREPLY#define ICMP_ECHOREPLY 0#endif#ifndef ICMP_UNREACH#define ICMP_UNREACH 3#endif#ifndef ICMP_SOURCEQUENCH#define ICMP_SOURCEQUENCH 4#endif#ifndef ICMP_REDIRECT#define ICMP_REDIRECT 5#endif#ifndef ICMP_ECHO#define ICMP_ECHO 8#endif#ifndef ICMP_ROUTERADVERT#define ICMP_ROUTERADVERT 9#endif#ifndef ICMP_ROUTERSOLICIT#define ICMP_ROUTERSOLICIT 10#endif#ifndef ICMP_TIMXCEED#define ICMP_TIMXCEED 11#endif#ifndef ICMP_PARAMPROB#define ICMP_PARAMPROB 12#endif#ifndef ICMP_TSTAMP#define ICMP_TSTAMP 13#endif#ifndef ICMP_TSTAMPREPLY#define ICMP_TSTAMPREPLY 14#endif#ifndef ICMP_IREQ#define ICMP_IREQ 15#endif#ifndef ICMP_IREQREPLY#define ICMP_IREQREPLY 16#endif#ifndef ICMP_MASKREQ#define ICMP_MASKREQ 17#endif#ifndef ICMP_MASKREPLY#define ICMP_MASKREPLY 18#endif u_char icmp_code;/* * ICMP codes. */#ifndef ICMP_UNREACH_NET#define ICMP_UNREACH_NET 0#endif#ifndef ICMP_UNREACH_HOST#define ICMP_UNREACH_HOST 1#endif#ifndef ICMP_UNREACH_PROTOCOL#define ICMP_UNREACH_PROTOCOL 2#endif#ifndef ICMP_UNREACH_PORT#define ICMP_UNREACH_PORT 3#endif#ifndef ICMP_UNREACH_NEEDFRAG#define ICMP_UNREACH_NEEDFRAG 4#endif#ifndef ICMP_UNREACH_SRCFAIL#define ICMP_UNREACH_SRCFAIL 5#endif#ifndef ICMP_UNREACH_NET_UNKNOWN#define ICMP_UNREACH_NET_UNKNOWN 6#endif#ifndef ICMP_UNREACH_HOST_UNKNOWN#define ICMP_UNREACH_HOST_UNKNOWN 7#endif#ifndef ICMP_UNREACH_ISOLATED#define ICMP_UNREACH_ISOLATED 8#endif#ifndef ICMP_UNREACH_NET_PROHIB#define ICMP_UNREACH_NET_PROHIB 9#endif#ifndef ICMP_UNREACH_HOST_PROHIB#define ICMP_UNREACH_HOST_PROHIB 10#endif#ifndef ICMP_UNREACH_TOSNET#define ICMP_UNREACH_TOSNET 11#endif#ifndef ICMP_UNREACH_TOSHOST#define ICMP_UNREACH_TOSHOST 12#endif#ifndef ICMP_UNREACH_FILTER_PROHIB#define ICMP_UNREACH_FILTER_PROHIB 13
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -