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

📄 header.h

📁 bf533平台下的DM9000A的测试代码
💻 H
字号:

// Ethernet Header.


//
//        以太网首部 包格式:6字节,目的地MAC地址,/6字节,源MAC地址
//
//

//typedef	int			bool;
typedef	unsigned long		ulong;
typedef	unsigned short		ushort;
typedef	unsigned char		uchar;
//typedef	int			bool;
typedef struct
{
     uchar		et_dest[6];		// Destination Mac Address.
     uchar      et_src[6];		// Source Mac Address.
     ushort  	et_protlen;		// if ethernet header protocol, else length.
}ETH_HEADER;

#define	ETHER_HDR_SIZE			14
#define PROT_IP					0x0800
#define	PROT_ARP				0x0806
#define PROT_RARP				0x8035

// IP Header.
typedef struct
{
      char             ip_hl_v;                 //version and header length
      char             ip_tos;                  //type of service
      short            ip_len;                  //ip length
      short            ip_id;                   //identification 标识
      short            ip_off;                  //片偏移                  
      char             ip_ttl;                  //生存期
      char             ip_p;                    //protocol
      short	           ip_chksum;	        // checksum. 协议
      long             ip_src;		        // source ip address.
      long	           ip_dest;         	// destination ip address.     
}IP_HEADER;	
#define IP_HDR_SIZE		        20

// udp header.
typedef struct {
	ushort	udp_src;	// udp source port.
	ushort	udp_dest;	// udp destination port.
	ushort	udp_len;	// length of udp packet.
	ushort	udp_chksum;	// checksum.
} UDP_HEADER;
#define UDP_HDR_SIZE	8

// Address Resolution Protocol (ARP) header.
typedef struct {
	ushort		ar_hrd;		// Format of hardware address.
	ushort		ar_pro;		// Format of protocol address.
	uchar		ar_hln;		// Length of hardware address.
	uchar		ar_pln;		// Length of protocol address.
	ushort	 	ar_op;		// Operation.
	uchar		ar_data[0];
} ARP_HEADER;
#define ARP_HDR_SIZE			(8+20)	// Size assuming ethernet.

#define ARP_ETHER			1		// Ethernet hardware address.

typedef struct 
{ 
    uchar    icmp_type;
    uchar    icmp_op;
    ushort   icmp_chksum;
}ICMP_HEADER;

#define ARPOP_REQUEST			1		// Request to resolve address.
#define ARPOP_REPLY			2		// Response to previous request.
#define RARPOP_REQUEST			3		// Request to resolve address.
#define RARPOP_REPLY			4		// Response to previous request.

⌨️ 快捷键说明

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