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

📄 arp.h

📁 opentcp_mcf5282原代码
💻 H
字号:
/*********************************************************************************
File:			arp.h

Date:

Version:		0.1

Author:			Jari Lahti (jari.lahti@violasystems.com)

Description:	arp (address resolution protocol) functions

Version Info:

*********************************************************************************/

#ifndef __OPENTCP_INCLUDE_ARP_H__
#define __OPENTCP_INCLUDE_ARP_H__

#include "datatypes.h"

/* User Allowed to modify	*/


#define	MAXHWALEN		6		/* Maximum HW address Length (6=Eth)*/
#define MAXPRALEN		4		/* Maximum Protocol adr.len (4=IPv4)*/

#define ARP_TSIZE		13		/* ARP Cache size (# of entries)	*/

#define ARP_TIMEOUT		60		/* Refresh timeout in secs			*/
#define ARP_RESEND		2		/* Resend if no reply in x seconds	*/
#define ARP_MAXRETRY	5		/* Give up after x times			*/


/* System constants, don't modify	*/

#define AR_HARDWARE		0x0001	/* Ethernet hardware type code		*/
#define ARP_ETHCODE		0x0806	/* ARP over Ethernet				*/

#define ARP_REQUEST		1		/* ARP Request to resolve address	*/
#define ARP_REPLY		2		/* Reply to resolve request			*/

#define	ARP_MANG_TOUT	1		/* Interval between ARP cache mngmt. */

struct arpentry
{
	UINT8	state;				/* State of this entry (see below)	*/
	UINT8	type;				/* Type of this entry (see below)	*/
	UINT8	retries;			/* Number of retries so far			*/
	UINT8	ttl;				/* Time To Live						*/
	UINT8	hwadr[MAXHWALEN];	/* Hardware Address					*/
	UINT32	pradr;				/* Protocol Address					*/

};

/* Arp Entry States	*/

#define	ARP_FREE		0		/* Entry is Unused (initial value)	*/
#define ARP_RESERVED	1		/* Entry is reserved (allocated)	*/
#define ARP_PENDING		2		/* Entry is used but incomplete		*/
#define	ARP_RESOLVED	3		/* Entry has been resolved			*/
#define ARP_REFRESHING	4		/* Entry is being refreshed			*/


/* Arp Entry Types	*/

#define	ARP_FIXED_IP	0		/* For Fixed addresses like GW. 	*/
								/* Entry is refreshed after ttl		*/
#define	ARP_TEMP_IP		1		/* For Temporary addresses			*/
								/* Entry is removed after ttl		*/


/* ARP Variables	*/

extern struct arpentry	arptable[];

/* ARP Functions	*/
void arpinit(void);
struct arpentry* arpfind(LWORD, struct netif*, UINT8);
INT8 arpalloc(UINT8);
void arpsendreq(UINT8);
INT16 arp_keepcache(UINT32);
void arpmanage(void);
UINT8 IsSub(LWORD, struct netif*);
UINT8 Process_ARP(struct otcp_ethframe*);
void ARPSendResponse(void);
void ARPGetResponse(void);
void ARPSendRequest(void);
INT8 arpadd(UINT32, UINT8*, UINT8);

#endif	//guard

/*	EOF	*/

⌨️ 快捷键说明

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