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

📄 arp.c

📁 MC9S12NE64串口与网络通信源代码
💻 C
字号:
 /*****************************************************************************
 *
 * File Name     : arp.c
 *
 * DESCRIPTION   : Used for ARP Protocol  
 *
 * Written by houlei  @2004.10.10 Tsinghua University 
 * Recently Modified by houlei @2004.12.10
 *****************************************************************************/

#include "ethernet.h"
#include "ne64api.h"
#include "MOTTYPES.h"
#include "etherinit.h"
#include "IO_MAP.h"



extern tU08 sed_Send( tU16 );
extern void Move( tU08 *, tU08 *, tU16 );
extern tU08 *sed_FormatPacket( tU08 *, tU08 *, tU16 );
extern void putb_ser(tU08);
extern eth_HwAddress sed_lclEthAddr;
extern in_HwAddress  sin_lclINAddr;
extern tU08 *EtherPtr;

tU08 sar_CheckPacket(arp_Header *ap)
{
	arp_Header *op;

	if ( ap->hwType != arp_TypeEther || /* have ethernet hardware, */
		ap->protType != 0x800 ||       /* and internet software, */
		ap->opcode != ARP_REQUEST ||   /* and be a resolution req. */
		ap->dstIPAddr != sin_lclINAddr ) /* for my addr. */ 
		{
			return ( 0 );                  /* .... or we ignore it. */
		}
	
	/* format response. */
	op = (arp_Header *)sed_FormatPacket(EtherPtr,ap->srcEthAddr, 0x806);
	op->hwType = arp_TypeEther;
	op->protType = 0x0800;
	op->hwProtAddrLen = (sizeof(eth_HwAddress) << 8) + sizeof(in_HwAddress);
	op->opcode = ARP_REPLY;
	op->dstIPAddr = ap->srcIPAddr;
	op->srcIPAddr = sin_lclINAddr;
	Move(op->dstEthAddr, ap->srcEthAddr, sizeof(eth_HwAddress));
	Move(op->srcEthAddr, sed_lclEthAddr, sizeof(eth_HwAddress));

	sed_Send(sizeof(arp_Header));

	return ( 1 );
}

⌨️ 快捷键说明

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