ether.c

来自「完整的TCP/IP源代码,绝对好用」· C语言 代码 · 共 42 行

C
42
字号
#include "C:\wql\tcpipsocket\IP51_MAC.h"
#include "C:\wql\tcpipsocket\ether.h"
#include "C:\wql\tcpipsocket\IP51_sfr.h"
#include "C:\wql\tcpipsocket\arp.h"
#include "C:\wql\tcpipsocket\ip.h"
//#include "uart.h"

UINT8 xdata	mrbuf[ETH_MTU];

void
Ether_Input()
{
	UINT16	len;
	struct	ether_hdr * eth_hdr;

	len	=	Rd_pkt_len();
	len	-=	18;  //reduce rdma_hdr,and reduce MAC header,MAC CRC
	Rd_pkt(&mrbuf[0]);
	eth_hdr	=	(struct ether_hdr*)(&mrbuf[4]);

	switch(eth_hdr->type)
	{
		case	ETH_ARP:
				ARP_Interpret((ARP_LAYER *)&mrbuf[18]);
				break;
		case	ETH_IP :
				IP_Interpret((IPLAYER *)&mrbuf[18], (UINT8 *)&mrbuf[18], len);
				break;
		default	:
				break;
	
	}

}

void Ether_output(UINT8 * eth_addr,UINT16 len,UINT8 * tptr,UINT16 flag)
{
	 while(Wr_pkt(eth_addr,len,tptr,flag)!=0);
}


⌨️ 快捷键说明

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