📄 libnet-headers.h
字号:
#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_int8_t icmp_code; /* ICMP code */#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#endif#ifndef ICMP_UNREACH_HOST_PRECEDENCE#define ICMP_UNREACH_HOST_PRECEDENCE 14#endif#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15#endif#ifndef ICMP_REDIRECT_NET#define ICMP_REDIRECT_NET 0#endif#ifndef ICMP_REDIRECT_HOST#define ICMP_REDIRECT_HOST 1#endif#ifndef ICMP_REDIRECT_TOSNET#define ICMP_REDIRECT_TOSNET 2#endif#ifndef ICMP_REDIRECT_TOSHOST#define ICMP_REDIRECT_TOSHOST 3#endif#ifndef ICMP_TIMXCEED_INTRANS#define ICMP_TIMXCEED_INTRANS 0#endif#ifndef ICMP_TIMXCEED_REASS#define ICMP_TIMXCEED_REASS 1#endif#ifndef ICMP_PARAMPROB_OPTABSENT#define ICMP_PARAMPROB_OPTABSENT 1#endif u_int16_t icmp_sum; /* ICMP Checksum */ union { struct { u_int16_t id; /* ICMP id */ u_int16_t seq;/* ICMP sequence number */ } echo;#undef icmp_id#undef icmp_seq#define icmp_id hun.echo.id#define icmp_seq hun.echo.seq u_int32_t gateway; /* gateway host */ struct { u_int16_t pad;/* padding */ u_int16_t mtu;/* MTU size */ } frag; } hun; union { struct { n_time its_otime; n_time its_rtime; n_time its_ttime; } ts; struct { struct libnet_ipv4_hdr idi_ip; /* options and then 64 bits of data */ } ip; u_int32_t mask; int8_t data[1];#undef icmp_mask#define icmp_mask dun.mask#undef icmp_data#define icmp_data dun.data#undef icmp_otime#define icmp_otime dun.ts.its_otime#undef icmp_rtime#define icmp_rtime dun.ts.its_rtime#undef icmp_ttime#define icmp_ttime dun.ts.its_ttime }dun;};/* * IGMP header * Internet Group Message Protocol * Static header size: 8 bytes */struct libnet_igmp_hdr{ u_int8_t igmp_type; /* IGMP type */#ifndef IGMP_MEMBERSHIP_QUERY#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */#endif#ifndef IGMP_V1_MEMBERSHIP_REPORT#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */#endif#ifndef IGMP_V2_MEMBERSHIP_REPORT#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */#endif#ifndef IGMP_LEAVE_GROUP#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */#endif u_int8_t igmp_code; /* IGMP code */ u_int16_t igmp_sum; /* IGMP checksum */ struct in_addr igmp_group;/* IGMP host IP */};/* * IPSEC header * Internet Protocol Security Protocol * Encapsulating Security Payload Header Static header size: 12 bytes * Encapsulating Security Payload Footer Base header size: 2 bytes * Authentication Header Static Size: 16 bytes */#ifndef IPPROTO_ESP#define IPPROTO_ESP 50 /* not everyone's got this */#endifstruct libnet_esp_hdr{ u_int32_t esp_spi; /* security parameter index */ u_int32_t esp_seq; /* ESP sequence number */ u_int32_t esp_iv; /* initialization vector */};struct libnet_esp_ftr{ u_int8_t esp_pad_len; /* padding length */ u_int8_t esp_nxt_hdr; /* next header pointer */ int8_t *esp_auth; /* authentication data */}; #ifndef IPPROTO_AH#define IPPROTO_AH 51 /* not everyone's got this */#endifstruct libnet_ah_hdr{ u_int8_t ah_nxt_hdr; /* next header */ u_int8_t ah_len; /* payload length */ u_int16_t ah_res; /* reserved */ u_int32_t ah_spi; /* security parameter index */ u_int32_t ah_seq; /* AH sequence number */ u_int32_t ah_auth; /* authentication data */};/* * ISL header * Cisco Inter-Switch Link * Static header size: 26 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_ISL 201struct libnet_isl_hdr{ u_int8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */#if (LIBNET_LIL_ENDIAN) u_int8_t isl_type:4, /* type of frame */ isl_user:4; /* user defined bits */#endif#if (LIBNET_BIG_ENDIAN) u_int8_t isl_user:4, /* user defined bits */ isl_type:4; /* type of frame */#endif u_int8_t isl_shost[6]; /* source address */ u_int16_t isl_len; /* total length of packet - 18 bytes */ u_int8_t isl_snap[6]; /* 0xaaaa03 + vendor code */ u_int16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */ u_int16_t isl_index; /* port index */ u_int16_t isl_reserved; /* used for FDDI and token ring */ /* ethernet frame and 4 byte isl crc */};#ifndef IPPROTO_OSPF#define IPPROTO_OSPF 89 /* not everyone's got this */#endif#define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */#define LIBNET_MODX 4102 /* used in LSA checksum *//* * Options used in multiple OSPF packets * More info can be found in section A.2 of RFC 2328. */#define LIBNET_OPT_EBIT 0x02 /* describes the way AS-external-LSAs are flooded */#define LIBNET_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */#define LIBNET_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */#define LIBNET_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */#define LIBNET_OPT_DCBIT 0x20 /* describes handling of demand circuits *//* * MPLS header * Multi-Protocol Label Switching * Static header size: 4 bytes */struct libnet_mpls_hdr{ u_int32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, ttl */#define LIBNET_MPLS_BOS_ON 1#define LIBNET_MPLS_BOS_OFF 0};/* * NTP header * Network Time Protocol * Static header size: 48 bytes */struct libnet_ntp_hdr_l_fp /* int32_t floating point (64-bit) */{ u_int32_t integer; /* integer */ u_int32_t fraction; /* fraction */};struct libnet_ntp_hdr_s_fp /* int16_t floating point (32-bit) */{ u_int16_t integer; /* integer */ u_int16_t fraction; /* fraction */};struct libnet_ntp_hdr{ u_int8_t ntp_li_vn_mode; /* leap indicator, version, mode */#define LIBNET_NTP_LI_NW 0x0 /* no warning */#define LIBNET_NTP_LI_AS 0x1 /* last minute has 61 seconds */#define LIBNET_NTP_LI_DS 0x2 /* last minute has 59 seconds */#define LIBNET_NTP_LI_AC 0x3 /* alarm condition */#define LIBNET_NTP_VN_2 0x2 /* version 2 */#define LIBNET_NTP_VN_3 0x3 /* version 3 */#define LIBNET_NTP_VN_4 0x4 /* version 4 */#define LIBNET_NTP_MODE_R 0x0 /* reserved */#define LIBNET_NTP_MODE_A 0x1 /* symmetric active */#define LIBNET_NTP_MODE_P 0x2 /* symmetric passive */#define LIBNET_NTP_MODE_C 0x3 /* client */#define LIBNET_NTP_MODE_S 0x4 /* server */#define LIBNET_NTP_MODE_B 0x5 /* broadcast */#define LIBNET_NTP_MODE_RC 0x6 /* reserved for NTP control message */#define LIBNET_NTP_MODE_RP 0x7 /* reserved for private use */ u_int8_t ntp_stratum; /* stratum */#define LIBNET_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */#define LIBNET_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */ /* 2 - 15 is secondary */ /* 16 - 255 is reserved */ u_int8_t ntp_poll; /* poll interval (should be 4 - 12) */ u_int8_t ntp_precision; /* local clock precision */ struct libnet_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */ struct libnet_ntp_hdr_s_fp ntp_dispersion; /* nominal error */ u_int32_t ntp_reference_id; /* reference source id */#define LIBNET_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */#define LIBNET_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second clock */#define LIBNET_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */#define LIBNET_NTP_REF_USNO 0x55534e4f /* USNO modem service */#define LIBNET_NTP_REF_PTB 0x50544200 /* PTB (German) modem service */ #define LIBNET_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */#define LIBNET_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio */#define LIBNET_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */#define LIBNET_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */#define LIBNET_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */#define LIBNET_NTP_REF_WWVH 0x57575648 /* Kaui Hawaii (US) radio */#define LIBNET_NTP_REF_CHU 0x43485500 /* Ottaha (Canada) radio */#define LIBNET_NTP_REF_LORC 0x4c4f5243 /* LORAN-C radionavigation */#define LIBNET_NTP_REF_OMEG 0x4f4d4547 /* OMEGA radionavigation */#define LIBNET_NTP_REF_GPS 0x47505300 /* global positioning system */#define LIBNET_NTP_REF_GOES 0x474f4553 /* geostationary orbit env satellite */ struct libnet_ntp_hdr_l_fp ntp_ref_ts; /* reference timestamp */ struct libnet_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */ struct libnet_ntp_hdr_l_fp ntp_rec_ts; /* receive timestamp */ struct libnet_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */};/* * OSPFv2 header * Open Shortest Path First * Static header size: 16 bytes */struct libnet_ospf_hdr{ u_int8_t ospf_v; /* version */#define OSPFVERSION 2 u_int8_t ospf_type; /* type */#define LIBNET_OSPF_UMD 0 /* UMd monitoring packet */#define LIBNET_OSPF_HELLO 1 /* HELLO packet */#define LIBNET_OSPF_DBD 2 /* dataBase description packet */#define LIBNET_OSPF_LSR 3 /* link state request packet */#define LIBNET_OSPF_LSU 4 /* link state Update Packet */#define LIBNET_OSPF_LSA 5 /* link state acknowledgement packet */ u_int16_t ospf_len; /* length */ struct in_addr ospf_rtr_id; /* source router ID */ struct in_addr ospf_area_id;/* roam ID */ u_int16_t ospf_cksum; /* checksum */ u_int16_t ospf_auth_type; /* authentication type */#define LIBNET_OSPF_AUTH_NULL 0 /* null password */#define LIBNET_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */#define LIBNET_OSPF_AUTH_MD5 2 /* MD5 */};/* * OSPF authentication header * Open Shortest Path First * Static header size: 8 bytes */struct libnet_auth_hdr{ u_int16_t ospf_auth_null; /* NULL */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -