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

📄 bao.h

📁 基与C 语言的winpcap 捕获数据包 也是在网上找的和大家一起分享
💻 H
字号:
#define  TRUE  1
#define  FALSE  0
#define IPVERSION       4
#define ETHERTYPE_IP            0x0800          
#define ETHERTYPE_ARP           0x0806 
struct ether_header
{
	u_int8_t  ether_dhost[6];      /* destination eth addr */
	u_int8_t  ether_shost[6];      /* source ether addr    */
	u_int16_t ether_type;          /* packet type ID field */
};

struct arphead
{
	u_int16_t arp_hardware_type;				 /* Format of hardware address.  */
	u_int16_t arp_protocol_type;				 /* Format of protocol address.  */
	u_int8_t arp_hardware_length;			 /* Length of hardware address.  */
	u_int8_t arp_protocol_length;			 /* Length of protocol address.  */
	u_int16_t arp_operation_code;			 /* ARP opcode (command).  */ //1为请求 2为回复
	u_int8_t arp_source_ethernet_address[6];		 /* Sender hardware address.  */
	u_int8_t arp_source_ip_address[4];			 /* Sender IP address.  */
	u_int8_t arp_destination_ethernet_address[6];   /* Target hardware address.  */
	u_int8_t arp_destination_ip_address[4];		 /* Target IP address.  */
};

struct iphead
{
	u_int8_t ip_header_length:4,ip_version:4;
	u_int8_t ip_tos;
	u_int16_t ip_length; 
	u_int16_t ip_id;
	u_int16_t ip_off;
	u_int8_t ip_ttl;
	u_int8_t ip_protocol;
	u_int16_t ip_checksum;
	struct in_addr ip_souce_address;
	struct in_addr ip_destination_address;
};


struct tcphead
  {
    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 */
    u_int8_t th_hlsv;
    u_int8_t th_flags;
    u_int16_t th_win;           /* window */
    u_int16_t th_sum;           /* checksum */
    u_int16_t th_urp;           /* urgent pointer */
};

struct udphead
{
	u_int16_t udp_source_port;
	u_int16_t udp_destinanion_port;
	u_int16_t udp_length;
	u_int16_t udp_checksum;
};

struct icmphead
{
	u_int8_t icmp_type;
	u_int8_t icmp_code;
	u_int16_t icmp_checksum;
	u_int16_t icmp_id;
	u_int16_t icmp_sequence;
};

⌨️ 快捷键说明

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