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

📄 p_tcpip.h

📁 一种操作系统源码核
💻 H
字号:


struct	ep{
        EADDR	dst;		/* destination host address		*/
	EADDR	src;		/* source host address			*/
	INT16U	type;/* Ethernet packet type (see below)	*/
	INT8U	data[1];
}
struct	arp_packet{
        EADDR	ep_dst;		/* destination host address		*/
	EADDR	ep_src;		/* source host address			*/
	INT8U	ep_type[2];           /* Ethernet packet type (see below)	*/
	INT8U	hw_type[2];	/* hardware type			*/
	INT16U	proto_type[2];	/* protocol type			*/
	INT8U	hw_addr_len;	/* hardware address length		*/
	INT8U	proto_len;	/* protocol address length		*/
	INT16U	arp_op;		/* ARP operation (see list above)	*/
	INT8U	arp_sha[EP_ALEN];	 - snder's physical hardware address	*/
	INT8U	arp_spa[IP_ALEN];	 - snder's protocol address (IP addr.)	*/
	INT8U	arp_tha[EP_ALEN];	 - target's physical hardware address	*/
	INT8U	arp_tpa[IP_ALEN];	 - target's protocol address (IP)	*/
	INT8U arp_data[ArpBufLength+3]
};
struct	arp{
       
	INT8U	hw_type[2];	/* hardware type			*/
	INT8U	proto_type[2];	/* protocol type			*/
	INT8U	hw_addr_len;	/* hardware address length		*/
	INT8U	proto_len;	/* protocol address length		*/
	INT16U	arp_op;		/* ARP operation (see list above)	*/
	INT8U	arp_sha[EP_ALEN];	 - snder's physical hardware address	*/
	INT8U	arp_spa[IP_ALEN];	 - snder's protocol address (IP addr.)	*/
	INT8U	arp_tha[EP_ALEN];	 - target's physical hardware address	*/
	INT8U	arp_tpa[IP_ALEN];	 - target's protocol address (IP)	*/
	INT8U arp_data[ArpBufLength+ARP_QSIZE]
};
struct	ip{
	INT8U	verlen;	/* IP version & header length (in INT32Us)*/
	INT8U	tos;		/* type of service			*/
	INT16U	len;		/* total packet length (in octets)	*/
	
	INT16U	id;		/* datagram id				*/
	INT16U 	fragoff;	/* fragment offset (in 8-octet's)	*/
	INT8U	ttl;		/* time to live, in gw hops	*/
	INT8U	proto;	/* IP protocol (see IPT_* above)	*/
	INT16U	cksum;	/* header cksum 			*/
	
	INT32U	src;		/* IP address of source			*/
	INT32U	dst;		/* IP address of destination		*/
	INT8U	data[1];	/* variable length data			*/
};
struct icmp_packet{
 INT8U  ep_src[4];
 INT8U  ep_dst[4];
 INT8U ep_type[2];
 INT8U  ip_version;
 INT8U  ip_tos;
 INT16U  ip_len;
 INT16U  ip_id;
 INT16U ip_fragoff;
 INT8U   ip_ttl;
 INT8U   ip_proto;
  INT16  ip_checksum;
  INT32U  ip_src;
  INT32U ip_dst;
  INT8U   ic_type;
  INT8U   ic_code;
  INT8U  ic_checksum[2];
   INT16U ic_data[24];
   
};

//Handler Tcp Udp

struct tcb{
  INT8U   state; //  (tcb  state) 2//
  INT8U  flag;//tcb flag 0   0=free,1=transmit,  5=stop  bit.4=1
  INT8U  code; //tcb state flags 1  bit.0=fin,bit.1=syn,bit.2=rst,bit.3=psh,bit.4=ack,bit.5=upg
  INT8U  id;
  INT8U  local_port[2];//local tcp port   04
  INT8U  peer_port[2]; //peer tcp port  6
  INT8U  peer_ip[2];//peer ip address 08
  INT8U  local_ip[2];//local ip address a
 
  INT16 rcv_next; //receive seq  0c
  INT16 snd_next ;//send seq  0x10
  INT16 ack; //ack seq  0x12
  INT16 snd_unack;//send unacked  0x14
  //INT16 snd_seq; //send next seq 0x16
  INT8U  acked; //0x18   0=send unacked,  1=acked
  INT16 snd_bytes;//send data byte count //0x19
  INT8U  rexmt; //0x1a retranmit timeout value
  INT8U  retry;//0x1b
 };
 
 

struct tcp{
        INT8U	local_port[2];	/* source port			*/
	INT8U   local_port[2];
	INT8U	peer_port[2];	/* destination port		*/
	INT8U	peer_port[2];	/* destination port		*/
	INT32	tcp_seq;	/* sequence			*/
	INT32	tcp_ack;	/* acknowledged sequence	*/
	INT8U	tcp_offset;
	INT8U	tcp_code;	/* control flags		*/
	INT8U	tcp_window[2];	/* tcp_window advertisement		*/
	
	INT8U	tcp_cksum[2];	/* check sum			*/
	
	INT8U	tcp_urgptr[2];	/* urgent poINT16Uer		*/
	
      	
	INT8U	tcp_data[1];


}


struct	udp {				/* message format of DARPA UDP	*/
	INT8U	src[2];		/* source UDP port number	*/
	INT8U	dst[2];		/* destination UDP port number	*/
	INT8U	len[2];		/* length of UDP data		*/
	INT8U	cksum[2];	/* UDP cksum (0 => none)	*/
	
	INT8	data[1];	/* data in UDP message		*/
};
struct	tcp_packet{
        EADDR	ep_dst;		/* destination host address		*/
	EADDR	ep_src;		/* source host address			*/
	INT8U	ep_type[2];/* Ethernet packet type (see below)	*/
       
        INT8U	ip_verlen;	/* IP version & header length (in INT32Us)*/
	INT8U	ip_tos;		/* type of service			*/
	INT8U	ip_len[2];		/* total packet length (in octets)	*/
	INT16U	ip_id;		/* datagram id				*/
	INT16U 	ip_fragoff;	/* fragment offset (in 8-octet's)	*/
	INT8U	ip_ttl;		/* time to live, in gw hops	*/
	INT8U	ip_proto;	/* IP protocol (see IPT_* above)	*/
	INT16U	ip_cksum;	/* header cksum 			*/
	INT32U	ip_src;		/* IP address of source			*/
	INT32U	ip_dst;		/* IP address of destination		*/
        INT8U	local_port[2];	/* source port			*/
	INT8U   local_port[2];
	INT8U	peer_port[2];	/* destination port		*/
	INT8U	peer_port[2];	/* destination port		*/
	INT32	tcp_seq;	/* sequence			*/
	INT32	tcp_ack;	/* acknowledged sequence	*/
	INT8U	tcp_offset;
	INT8U	tcp_code;	/* control flags		*/
	INT8U	tcp_window[2];	/* tcp_window advertisement		*/
	
	INT8U	tcp_cksum[2];	/* check sum			*/
	
	INT8U	tcp_urgptr[2];	/* urgent poINT16Uer		*/
	INT8U	tcp_data[4];
      	
      	
};
struct	udp_packet{
        EADDR	ep_dst;		/* destination host address		*/
	EADDR	ep_src;		/* source host address			*/
	INT8U	ep_type[2];/* Ethernet packet type (see below)	*/
       
        INT8U	ip_verlen;	/* IP version & header length (in INT32Us)*/
	INT8U	ip_tos;		/* type of service			*/
	INT8U	ip_len[2];		/* total packet length (in octets)	*/
	INT16U	ip_id;		/* datagram id				*/
	INT16U 	ip_fragoff;	/* fragment offset (in 8-octet's)	*/
	INT8U	ip_ttl;		/* time to live, in gw hops	*/
	INT8U	ip_proto;	/* IP protocol (see IPT_* above)	*/
	INT16U	ip_cksum;	/* header cksum 			*/
	INT32U	ip_src;		/* IP address of source			*/
	INT32U	ip_dst;		/* IP address of destination		*/
        INT8U	udp_src[2];		/* source UDP port number	*/
	INT8U	udp_dst[2];		/* destination UDP port number	*/
	INT8U	udp_len[2];		/* length of UDP data		*/
	INT8U	udp_cksum[2];	/* UDP cksum (0 => none)	*/
	
	INT8	udp_data[1];	/* data in UDP message		*/
      	
      	
};

 
 



OS_EXT INT8U   *Adapter_pRcvPacket;//指向接收到的经过解包后该协议层需要的数据包的开始
	
OS_EXT INT8U    *Adapter_pRcvTcpData;
OS_EXT INT8U    *Adapter_pRcvUdpData; 
OS_EXT INT8U    *pPeerMacAddress; 
OS_EXT INT8U    *pPeerIPAddress ;  //68c9


OS_EXT	INT8U	Local_pMacAddress[HW_ALEN];  //0x6b43
OS_EXT	INT8U	Local_pIPAddress[IP_ALEN];  //0x6b49
OS_EXT	INT8U	Local_pSubnetMask[IP_ALEN]; //0x6b4d
OS_EXT	INT8U	Local_pRouteIP[IP_ALEN]; //0x6b51

//OS_EXT BOOLEAN bDhcpUnFinished;
//BOOLEAN	Dhcp_bEnable;
//OS_EXT DCHAR UdpPort_HIGH,UdpPort_LOW;


BOOLEAN	Ne2000Initialize();													// Ne2000.c
void	Ne2000Send(UCHAR iLength, INT8U * pData);
void	Ne2000SendLargePacket(USHORT iLength);
 void	Ne2000Run();     

void	Ne2000HandleInterrupt();
void	Ne2000WaitPacket();	

void	ArpInitialize();													// Arp.c
void	ArpRun();
void	ArpHandleTimer();
void	ArpSend(PXCHAR pPeerIP);
void	ArpResolvedRun();
void TaskAfterArpResolved();

void	IcmpInitialize();													// Icmp.c
void	IcmpRun();
void	IcmpRunLargePacket();

ULONG	IpPrepareData(UCHAR iProtocol, PXCHAR pData);						// Ip.c
void	IpCheckSum(ULONG lHeaderSum, PXCHAR pData);
void	IpCheckSumLargePacket(ULONG lHeaderSum, PUCHAR pData);
ULONG	IpModifyCheckSum(ULONG lHeaderSum, PXCHAR pDstIP);
USHORT  CheckSum(UCHAR len,PXCHAR pDATA);

void	UdpInitialize();													// Udp.c
void	UdpOpen(INT8U * pUdpData, UCHAR iDstPortHi, UCHAR iDstPortLo);
void	UdpRun();
void	UdpSend(INT8U * pUdpData, UCHAR iLength);
void	UdpSendLarge(INT8U * pUdpData, USHORT iLength);




void	TcpInitialize();													// Tcp.c
void	TcpOpen(INT8U * pTcbData, UCHAR iDstPortHi, UCHAR iDstPortLo);
void	TcpClose(INT8U * pDataBuf);
void	TcpRun();
UCHAR  TcpSend(UCHAR iCurMsgPos);

void	TcpHandleTimer();



BOOLEAN	TcbInit(INT8U * pTcbData, UCHAR iListenPortHi, UCHAR iListenPortLo);
void	TcbRun(PXCHAR pTcbData);
BOOLEAN	TcbHandleTimer(INT8U * pSendPacket);
BOOLEAN	TcbCheckData(PXCHAR pTcbData);	



UCHAR	TcbGetLocalPortHi(INT8U * pTcbData);	
UCHAR	TcbGetLocalPortLo(INT8U * pTcbData);	
UCHAR	TcbGetRemotePortHi(INT8U * pTcbData);	
UCHAR	TcbGetRemotePortLo(INT8U * pTcbData);	
INT8U *	TcbGetRemoteIP(INT8U * pTcbData);




⌨️ 快捷键说明

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