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

📄 tcp.h

📁 基于TMS320F2812的网络编程例子.网卡芯片是RTL8019AS.这是开发板附带的例子程序
💻 H
字号:
#define		RTL8019BASE		0x4F00

#define		Reg00	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x00)))
#define		Reg01	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x04)))
#define		Reg02	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x08)))
#define		Reg03	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x0C)))
#define		Reg04	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x10)))
#define		Reg05	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x14)))
#define		Reg06	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x18)))
#define		Reg07	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x1C)))
#define		Reg08	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x20)))
#define		Reg09	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x24)))
#define		Reg0a	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x28)))
#define		Reg0b	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x2C)))
#define		Reg0c	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x30)))
#define		Reg0d	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x34)))
#define		Reg0e	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x38)))
#define		Reg0f	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x3C)))
#define		Reg10	(*((volatile	unsigned  int  *)(RTL8019BASE + 0x40)))

#define	  	SetData		GpioDataRegs.GPFDAT.bit.GPIOF12 = 1
#define	  	ClrData 	GpioDataRegs.GPFDAT.bit.GPIOF12 = 0
#define	  	SetClk		GpioDataRegs.GPFDAT.bit.GPIOF8 = 1
#define	  	ClrClk		GpioDataRegs.GPFDAT.bit.GPIOF8 = 0
#define	  	LedReg		(*((volatile  unsigned  int *)0x27FF))
#define	  	Led8Lock 	(*((volatile  unsigned  int *)0x2BFF)) 

#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 + -