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

📄 tcp.h

📁 DSP2812资料,包括原理图,测试程序,使用说明,jjzhang166@163.com
💻 H
字号:
#define		RTL8019BASE		0x3700

#define		Reg00	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x00)))
#define		Reg01	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x01)))
#define		Reg02	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x02)))
#define		Reg03	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x03)))
#define		Reg04	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x04)))
#define		Reg05	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x05)))
#define		Reg06	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x06)))
#define		Reg07	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x07)))
#define		Reg08	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x08)))
#define		Reg09	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x09)))
#define		Reg0a	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0a)))
#define		Reg0b	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0b)))
#define		Reg0c	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0c)))
#define		Reg0d	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0d)))
#define		Reg0e	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0e)))
#define		Reg0f	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0f)))
#define		Reg10	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x10)))

#define	  	SetData			GpioDataRegs.GPFDAT.bit.GPIOF0 = 1
#define	  	ClrData   		GpioDataRegs.GPFDAT.bit.GPIOF0 = 0
#define	  	SetClk			GpioDataRegs.GPFDAT.bit.GPIOF2 = 1
#define	  	ClrClk			GpioDataRegs.GPFDAT.bit.GPIOF2 = 0
#define	  	LedReg		    (*((volatile  unsigned  int *)0x23FF))
#define	  	Led8Reg  		(*((volatile  unsigned  int *)0x25FF)) 

#define		SetFmq				0x40
#define		ClrFmq				0xBF
#define  	Set485OE		 	0x20
#define  	Clr485OE		 	0xDF
#define	 	Set8019RST		 	0x10
#define		Clr8019RST		 	0xEF
#define  	SetSPICS		 	0x08 
#define  	ClrSPICS		 	0xF7 
#define	 	SetAICCS		 	0x04  
#define  	ClrAICCS		 	0xFB 	
#define  	SetSIDIN		 	0x02  
#define	 	ClrSIDIN		 	0xFD  
#define  	SetSCLK		 		0x01  
#define  	ClrSCLK		 		0xFE  


#define 	BroadCast     1
#define 	RequestArp    2
#define		AnswerArp	  3
#define 	Nod           4
#define 	ARP	    	  1
#define 	UDP     	  2
#define 	IGMP    	  3
#define 	LSS           4
#define		TCP			  5
#define		ICMP		  6


/*tcp state define */

#define 	TCP_STATE_LISTEN        0
#define 	TCP_STATE_SYN_RCVD      1
#define 	TCP_STATE_SYN_SENT      2
#define 	TCP_STATE_ESTABLISHED   3
#define 	TCP_STATE_FIN_WAIT1     4
#define 	TCP_STATE_FIN_WAIT2     5
#define 	TCP_STATE_CLOSING       6
#define 	TCP_STATE_CLOSE_WAIT    7
#define 	TCP_STATE_LAST_ACK      8
#define 	TCP_STATE_CLOSED        9
#define 	TCP_STATE_TIME_WAIT     10
//tcp连接的标志位
#define 	TCP_FIN 0x01
#define 	TCP_SYN 0x02
#define 	TCP_RST 0x04
#define 	TCP_PSH 0x08
#define 	TCP_ACK 0x10
#define 	TCP_URG 0x20

#define		IP_FRAME	0X0800
#define		ARP_FRAME	0X0806
	
extern	void	SendFrame(Uint16	*buf,Uint16	len);
extern	Uint16	SwapByte(Uint16	value);

struct	ipaddr
		{
  			Uint16 	addr2_1;
  			Uint16	addr4_3;	
		};
struct 	mac
		{
  			Uint16	addr2_1;
  			Uint16	addr4_3;
  			Uint16 	addr6_5;
		};

struct 	iphdr
		{
  			Uint16  tos_version;
  			Uint16 	tol_len;
  			Uint16 	id;
  			Uint16	frag_off;
  			Uint16 	protocal_ttl;
  			Uint16	chksum;
  			struct 	ipaddr saddr;
  			struct 	ipaddr daddr;
		};
struct 	udphdr
		{
  			Uint16 	sport;
  			Uint16 	dport;
  			Uint16 	length;
  			Uint16 	chksum;
		};

struct 	igmphdr
		{
  			Uint16	type_mrt;
  			Uint16  chksum;
  			struct  ipaddr groupaddr;
		};
struct 	pre_udphdr
		{
  			struct 	ipaddr saddr;
  			struct 	ipaddr daddr;
  			Uint16	protocal_value;
  			Uint16  length;
};
struct 	arp
		{
  			Uint16	hard_type;				//硬件类型		
  			Uint16 	proto_type;				//协议类型
  			Uint16 	proto_hard_length;		//硬件及协议地址长度
  			Uint16 	op_code;				//操作字段
  			struct 	mac    send_macaddr;	//发送端以太网地址	
  			struct 	ipaddr send_ipaddr;		//发送断IP地址
  			struct 	mac    rec_macaddr;		//接收端以太网地址
  			struct 	ipaddr rec_ipaddr;		//接收端IP地址
};

struct Socket_Type{
                   	Uint16   	My_Port; 		 		//本机端口
		   			Uint16  	Dest_Port;		 		//对方端口
		   			Uint16  	Dest_Ip[2];	 			//对方ip
		   			Uint16  	Dest_Mac_Id[3]; 		//对方的以太网地址
		   			Uint32	 	IRS;			 		//初始化顺序号
                   	Uint32	 	ISS;			 		//我的初始化序列号
                   	Uint32	 	Rcv_Next;		 		//对方的顺序号
		   			Uint32	 	Send_Next;		 		//我的已经发送顺序号
                   	Uint32	 	Sent_UnAck;		 		//我的还没有确认顺序号
		   									 		//unsigned long dest_ack_number;
		   			Uint16	 	Rcv_Window;		 		//对方的window大小
                   	Uint16	 	Snd_Window; 		 	//我的window大小
        	   		Uint16	 	Dest_Max_Seg_Size;		//对方接受的最大的数据包大小MTU
                   	Uint16	 	My_Max_Seg_Size; 		//我能接受的最大的数据包大小
		   			Uint32	 	My_Wl1;		//seq
		   			Uint32	 	My_Wl2;		//ack
                   	Uint16	 	State;		//连接状态
		   			Uint16	 	Open;
                  };

//========================== end ==========================

⌨️ 快捷键说明

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