📄 libnet-headers.h
字号:
u_int8_t ospf_auth_keyid; /* authentication key ID */ u_int8_t ospf_auth_len; /* auth data length */ u_int ospf_auth_seq; /* cryptographic sequence number */};/* * OSPF hello header * Open Shortest Path First * Static header size: 28 bytes */struct libnet_ospf_hello_hdr{ struct in_addr hello_nmask; /* netmask associated with the interface */ u_int16_t hello_intrvl; /* num of seconds between routers last packet */ u_int8_t hello_opts; /* Options for HELLO packets (look above) */ u_int8_t hello_rtr_pri; /* router's priority (if 0, can't be backup) */ u_int hello_dead_intvl; /* # of secs a router is silent till deemed down */ struct in_addr hello_des_rtr; /* Designated router on the network */ struct in_addr hello_bkup_rtr; /* Backup router */ struct in_addr hello_nbr; /* neighbor router, memcpy more as needed */};/* * Database Description header. */struct libnet_dbd_hdr{ u_int16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can use */ u_int8_t dbd_opts; /* DBD packet options (from above) */ u_int8_t dbd_type; /* type of exchange occurring */#define LIBNET_DBD_IBI 0x01 /* init */#define LIBNET_DBD_MBIT 0x02 /* more DBD packets are to come */#define LIBNET_DBD_MSBIT 0x04 /* If 1, sender is the master in the exchange */ u_int dbd_seq; /* DBD sequence number */};/* * used for the LS type field in all LS* headers */#define LIBNET_LS_TYPE_RTR 1 /* router-LSA */#define LIBNET_LS_TYPE_NET 2 /* network-LSA */#define LIBNET_LS_TYPE_IP 3 /* summary-LSA (IP Network) */#define LIBNET_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */#define LIBNET_LS_TYPE_ASEXT 5 /* AS-external-LSA *//* * Link State Request header */struct libnet_lsr_hdr{ u_int lsr_type; /* type of LS being requested */ u_int lsr_lsid; /* link state ID */ struct in_addr lsr_adrtr; /* advertising router (memcpy more as needed) */};/* * Link State Update header */struct libnet_lsu_hdr{ u_int lsu_num; /* number of LSAs that will be broadcasted */};/* * Link State Acknowledgement header. */struct libnet_lsa_hdr{ u_int16_t lsa_age; /* time in seconds since the LSA was originated */ u_int8_t lsa_opts; /* look above for OPTS_* */ u_int8_t lsa_type; /* look below for LS_TYPE_* */ u_int lsa_id; /* link State ID */ struct in_addr lsa_adv; /* router ID of Advertising router */ u_int lsa_seq; /* LSA sequence number to detect old/bad ones */ u_int16_t lsa_cksum; /* "Fletcher Checksum" of all fields minus age */ u_int16_t lsa_len; /* length in bytes including the 20 byte header */};/* * Router LSA data format * * Other stuff for TOS can be added for backward compatability, for this * version, only OSPFv2 is being FULLY supported. */struct libnet_rtr_lsa_hdr{ u_int16_t rtr_flags; /* set to help describe packet */#define LIBNET_RTR_FLAGS_W 0x0100 /* W bit */#define LIBNET_RTR_FLAGS_E 0x0200 /* E bit */#define LIBNET_RTR_FLAGS_B 0x0400 /* B bit */ u_int16_t rtr_num; /* number of links within that packet */ u_int rtr_link_id; /* describes link_data (look below) */#define LIBNET_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 */#define LIBNET_LINK_ID_IP_DES 2 /* IP address of designated router */#define LIBNET_LINK_ID_SUB 3 /* IP subnet number */ u_int rtr_link_data; /* Depending on link_id, info is here */ u_int8_t rtr_type; /* Description of router link */#define LIBNET_RTR_TYPE_PTP 1 /* Point-To-Point */#define LIBNET_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */#define LIBNET_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */#define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */ u_int8_t rtr_tos_num; /* number of different TOS metrics for this link */ u_int16_t rtr_metric; /* the "cost" of using this link */};/* * Network LSA data format. */struct libnet_net_lsa_hdr{ struct in_addr net_nmask; /* Netmask for that network */ u_int net_rtr_id; /* ID of router attached to that network */}; /* * Summary LSA data format. */struct libnet_sum_lsa_hdr{ struct in_addr sum_nmask; /* Netmask of destination IP address */ u_int sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24bit */ u_int sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metric */}; /* * AS External LSA data format. * & 0xfff logic operator for as_metric to get last 24bits. */struct libnet_as_lsa_hdr{ struct in_addr as_nmask; /* Netmask for advertised destination */ u_int as_metric; /* May have to set E bit in first 8bits */#define LIBNET_AS_E_BIT_ON 0x80000000 /* as_metric */ struct in_addr as_fwd_addr; /* Forwarding address */ u_int as_rte_tag; /* External route tag */};/* * Base RIP header * Routing Information Protocol * Base header size: 24 bytes */struct libnet_rip_hdr{ u_int8_t rip_cmd; /* RIP command */#define RIPCMD_REQUEST 1 /* want info */#define RIPCMD_RESPONSE 2 /* responding to request */#define RIPCMD_TRACEON 3 /* turn tracing on */#define RIPCMD_TRACEOFF 4 /* turn it off */#define RIPCMD_POLL 5 /* like request, but anyone answers */#define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */#define RIPCMD_MAX 7 /* ? command */ u_int8_t rip_ver; /* RIP version */#define RIPVER_0 0#define RIPVER_1 1#define RIPVER_2 2 u_int16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */ u_int16_t rip_af; /* Address family */ u_int16_t rip_rt; /* Zero (v1) or Route Tag (v2) */ u_int32_t rip_addr; /* IP address */ u_int32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */ u_int32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */ u_int32_t rip_metric; /* Metric */};/* * RPC headers * Remote Procedure Call */#define LIBNET_RPC_CALL 0#define LIBNET_RPC_REPLY 1#define LIBNET_RPC_VERS 2#define LIBNET_RPC_LAST_FRAG 0x80000000/* * Portmap defines */#define LIBNET_PMAP_PROGRAM 100000#define LIBNET_PMAP_PROC_NULL 0#define LIBNET_PMAP_PROC_SET 1#define LIBNET_PMAP_PROC_UNSET 2#define LIBNET_PMAP_PROC_GETADDR 3#define LIBNET_PMAP_PROC_DUMP 4#define LIBNET_PMAP_PROC_CALLIT 5#define LIBNET_PMAP_PROC_BCAST 5 /* Not a typo */#define LIBNET_PMAP_PROC_GETTIME 6#define LIBNET_PMAP_PROC_UADDR2TADDR 7#define LIBNET_PMAP_PROC_TADDR2UADDR 8#define LIBNET_PMAP_PROC_GETVERSADDR 9#define LIBNET_PMAP_PROC_INDIRECT 10#define LIBNET_PMAP_PROC_GETADDRLIST 11#define LIBNET_PMAP_PROC_GETSTAT 12/* There will be more to add... */struct libnet_rpc_opaque_auth{ u_int32_t rpc_auth_flavor; u_int32_t rpc_auth_length;// u_int8_t *rpc_auth_data;};struct libnet_rpc_call{ u_int32_t rpc_rpcvers; /* RPC version - must be 2 */ u_int32_t rpc_prognum; /* Program Number */ u_int32_t rpc_vers; /* Program Version */ u_int32_t rpc_procedure; /* RPC procedure */ struct libnet_rpc_opaque_auth rpc_credentials; struct libnet_rpc_opaque_auth rpc_verifier;};struct libnet_rpc_call_hdr{ u_int32_t rpc_xid; /* xid (transaction identifier) */ u_int32_t rpc_type; struct libnet_rpc_call rpc_call;};struct libnet_rpc_call_tcp_hdr{ u_int32_t rpc_record_marking; /* used with byte stream protocols */ struct libnet_rpc_call_hdr rpc_common;};/* * STP configuration header * Spanning Tree Protocol * Static header size: 35 bytes */struct libnet_stp_conf_hdr{ u_int16_t stp_id; /* protocol id */ u_int8_t stp_version; /* protocol version */ u_int8_t stp_bpdu_type; /* bridge protocol data unit type */ u_int8_t stp_flags; /* control flags */ u_int8_t stp_rootid[8]; /* root id */ u_int32_t stp_rootpc; /* root path cost */ u_int8_t stp_bridgeid[8]; /* bridge id */ u_int16_t stp_portid; /* port id */ u_int16_t stp_mage; /* message age */ u_int16_t stp_maxage; /* max age */ u_int16_t stp_hellot; /* hello time */ u_int16_t stp_fdelay; /* forward delay */};/* * STP topology change notification header * Spanning Tree Protocol * Static header size: 4 bytes */struct libnet_stp_tcn_hdr{ u_int16_t stp_id; /* protocol id */ u_int8_t stp_version; /* protocol version */ u_int8_t stp_bpdu_type; /* bridge protocol data unit type */};/* * TCP header * Transmission Control Protocol * Static header size: 20 bytes */struct libnet_tcp_hdr{ u_int16_t th_sport; /* source port */ u_int16_t th_dport; /* destination port */ u_int32_t th_seq; /* sequence number */ u_int32_t th_ack; /* acknowledgement number */#if (LIBNET_LIL_ENDIAN) u_int8_t th_x2:4, /* (unused) */ th_off:4; /* data offset */#endif#if (LIBNET_BIG_ENDIAN) u_int8_t th_off:4, /* data offset */ th_x2:4; /* (unused) */#endif u_int8_t th_flags; /* control flags */#ifndef TH_FIN#define TH_FIN 0x01 /* finished send data */#endif#ifndef TH_SYN#define TH_SYN 0x02 /* synchronize sequence numbers */#endif#ifndef TH_RST#define TH_RST 0x04 /* reset the connection */#endif#ifndef TH_PUSH#define TH_PUSH 0x08 /* push data to the app layer */#endif#ifndef TH_ACK#define TH_ACK 0x10 /* acknowledge */#endif#ifndef TH_URG#define TH_URG 0x20 /* urgent! */#endif u_int16_t th_win; /* window */ u_int16_t th_sum; /* checksum */ u_int16_t th_urp; /* urgent pointer */};/* * Token Ring Header */struct libnet_token_ring_hdr{ u_int8_t token_ring_access_control;#define LIBNET_TOKEN_RING_FRAME 0x10 u_int8_t token_ring_frame_control;#define LIBNET_TOKEN_RING_LLC_FRAME 0x40 u_int8_t token_ring_dhost[TOKEN_RING_ADDR_LEN]; u_int8_t token_ring_shost[TOKEN_RING_ADDR_LEN]; u_int8_t token_ring_llc_dsap; u_int8_t token_ring_llc_ssap; u_int8_t token_ring_llc_control_field; u_int8_t token_ring_llc_org_code[LIBNET_ORG_CODE_SIZE]; u_int16_t token_ring_type;#define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */#define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */#define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */};struct libnet_token_ring_addr{ u_int8_t token_ring_addr_octet[6]; /* Token Ring address */};/* * UDP header * User Data Protocol * Static header size: 8 bytes */struct libnet_udp_hdr{ u_int16_t uh_sport; /* soure port */ u_int16_t uh_dport; /* destination port */ u_int16_t uh_ulen; /* length */ u_int16_t uh_sum; /* checksum */};/* * VRRP header * Virtual Router Redundancy Protocol * Static header size: 8 bytes */#ifndef IPPROTO_VRRP#define IPPROTO_VRRP 112 /* not everyone's got this */#endifstruct libnet_vrrp_hdr{#if (LIBNET_LIL_ENDIAN) u_int8_t vrrp_v:4, /* protocol version */ vrrp_t:4; /* packet type */#endif#if (LIBNET_BIG_ENDIAN) u_int8_t vrrp_t:4, /* packet type */ vrrp_v:4; /* protocol version */#endif#define LIBNET_VRRP_VERSION_01 0x1#define LIBNET_VRRP_VERSION_02 0x2#define LIBNET_VRRP_TYPE_ADVERT 0x1 u_int8_t vrrp_vrouter_id; /* virtual router id */ u_int8_t vrrp_priority; /* priority */ u_int8_t vrrp_ip_count; /* number of IP addresses */ u_int8_t vrrp_auth_type; /* authorization type */#define LIBNET_VRRP_AUTH_NONE 0x1#define LIBNET_VRRP_AUTH_PASSWD 0x2#define LIBNET_VRRP_AUTH_IPAH 0x3 u_int8_t vrrp_advert_int; /* advertisement interval */ u_int16_t vrrp_sum; /* checksum */ /* additional addresses */ /* authentication info */};#endif /* __LIBNET_HEADERS_H *//* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -