📄 net_arp.h
字号:
/*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Suite
*
* (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/TCP-IP is provided in source form for FREE evaluation, for educational
* use or peaceful research. If you plan on using uC/TCP-IP in a commercial
* product you need to contact Micrium to properly license its use in your
* product. We provide ALL the source code for your convenience and to help
* you experience uC/TCP-IP. The fact that the source code is provided does
* NOT mean that you can use it without paying a licensing fee.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* NETWORK ARP LAYER
* (ADDRESS RESOLUTION PROTOCOL)
*
* Filename : net_arp.h
* Version : V1.87
* Programmer(s) : ITJ
*********************************************************************************************************
* Note(s) : (1) Address Resolution Protocol ONLY required for network interfaces that require
* network-address-to-hardware-address bindings (see RFC #826 'Abstract').
*
* (2) Supports Address Resolution Protocol as described in RFC #826 with the following
* restrictions/constraints :
*
* (a) ONLY supports the following hardware types :
* (1) 48-bit Ethernet
*
* (b) ONLY supports the following protocol types :
* (1) 32-bit IP
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MODULE
*
* Note(s) : (1) ARP Layer is required for some network interfaces (see 'net_arp.h Note #1).
*
* (2) The following ARP-module-present configuration value MUST be pre-#define'd in 'net_cfg_net.h'
* PRIOR to all other network modules that require ARP Layer Configuration (see 'net_cfg_net.h
* ARP LAYER CONFIGURATION Note #2b' & 'net_cfg_net.h NETWORK INTERFACE LAYER CONFIGURATION
* Note #4') :
*
* NET_ARP_MODULE_PRESENT
*********************************************************************************************************
*/
#ifdef NET_ARP_MODULE_PRESENT /* See Note #2. */
/*
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*/
#ifdef NET_ARP_MODULE
#define NET_ARP_EXT
#else
#define NET_ARP_EXT extern
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ARP CACHE DEFINES
*********************************************************************************************************
*/
#define NET_ARP_CACHE_TIMEOUT_MIN_SEC ( 1L * 60L) /* Cache timeout min = 60 seconds */
#define NET_ARP_CACHE_TIMEOUT_MAX_SEC (10L * 60L) /* Cache timeout max = 600 seconds */
#define NET_ARP_CACHE_TIMEOUT_DFLT_SEC (10L * 60L) /* Cache timeout dflt = 600 seconds */
#define NET_ARP_CACHE_ACCESSED_TH_MIN 10u
#define NET_ARP_CACHE_ACCESSED_TH_MAX 65000u
#define NET_ARP_CACHE_ACCESSED_TH_DFLT 100u
/*
*********************************************************************************************************
* ARP REQUEST DEFINES
*
* Note(s) : (1) RFC #1122, Section 2.3.2.1 states that "a mechanism to prevent ARP flooding (repeatedly
* sending an ARP Request for the same IP address, at a high rate) MUST be included. The
* recommended maximum rate is 1 per second per destination".
*********************************************************************************************************
*/
#define NET_ARP_REQ_RETRY_MIN 0
#define NET_ARP_REQ_RETRY_MAX 5
#define NET_ARP_REQ_RETRY_DFLT 3
/* ARP req retry timeouts (see Note #1). */
#define NET_ARP_REQ_RETRY_TIMEOUT_MIN_SEC 1L /* ARP req retry timeout min = 1 seconds */
#define NET_ARP_REQ_RETRY_TIMEOUT_MAX_SEC 10L /* ARP req retry timeout max = 10 seconds */
#define NET_ARP_REQ_RETRY_TIMEOUT_DFLT_SEC 5L /* ARP req retry timeout dflt = 5 seconds */
/*$PAGE*/
/*
*********************************************************************************************************
* ARP FLAG DEFINES
*********************************************************************************************************
*/
/* ------------------ NET ARP FLAGS ------------------- */
#define NET_ARP_FLAG_NONE DEF_BIT_NONE
#define NET_ARP_FLAG_USED DEF_BIT_00 /* ARP cache cur used; i.e. NOT in free cache pool. */
/*
*********************************************************************************************************
* ARP TYPE DEFINES
*
* Note(s) : (1) NET_ARP_TYPE_??? #define values specifically chosen as ASCII representations of the ARP
* types. Memory dumps of ARP types will display the ARP TYPE with the chosen ASCII name.
*********************************************************************************************************
*/
/* ------------------ NET ARP TYPES ------------------- */
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
#define NET_ARP_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define NET_ARP_TYPE_CACHE 0x41525020 /* "ARP " in ASCII. */
#else
#if (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_32)
#define NET_ARP_TYPE_NONE 0x454E4F4E /* "NONE" in ASCII. */
#define NET_ARP_TYPE_CACHE 0x20505241 /* "ARP " in ASCII. */
#elif (CPU_CFG_DATA_SIZE == CPU_WORD_SIZE_16)
#define NET_ARP_TYPE_NONE 0x4F4E454E /* "NONE" in ASCII. */
#define NET_ARP_TYPE_CACHE 0x52412050 /* "ARP " in ASCII. */
#else /* Dflt CPU_WORD_SIZE_08. */
#define NET_ARP_TYPE_NONE 0x4E4F4E45 /* "NONE" in ASCII. */
#define NET_ARP_TYPE_CACHE 0x41525020 /* "ARP " in ASCII. */
#endif
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* ARP HARDWARE & PROTOCOL DEFINES
*
* Note(s) : (1) The following ARP values MUST be pre-#define'd in 'net_def.h' PRIOR to 'net_cfg.h' so
* that the developer can configure ARP for the correct network interface link layer &
* network protocol layer (see 'net_def.h ARP LAYER DEFINES' & 'net_cfg_net.h ARP LAYER
* CONFIGURATION') :
*
* ---- SUPPORTED ARP HW TYPES ----
* NET_ARP_HW_TYPE_NONE 0x0000
*
* NET_ARP_HW_TYPE_ETHER 0x0001
* NET_ARP_HW_ADDR_LEN_ETHER 6
*
*
* - SUPPORTED ARP PROTOCOL TYPES -
* NET_ARP_PROTOCOL_TYPE_NONE 0x0000
*
* NET_ARP_PROTOCOL_TYPE_IP_V4 0x0800
* NET_ARP_PROTOCOL_ADDR_LEN_IP_V4 4
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* ARP HEADER / MESSAGE DEFINES
*
* Note(s) : (1) See RFC #826, Section 'Packet Format' for ARP packet header format.
*
* (a) ARP header includes two pairs of hardware & protocol type addresses--one each for the
* sender & the target.
*********************************************************************************************************
*/
#define NET_ARP_HDR_SIZE_MIN 12
#define NET_ARP_HDR_SIZE_MAX 68
#define NET_ARP_HDR_SIZE_OVRHD 8
/* See Note #1a. */
#define NET_ARP_HDR_SIZE (NET_ARP_HDR_SIZE_OVRHD + \
(NET_ARP_CFG_HW_ADDR_LEN * 2) + \
(NET_ARP_CFG_PROTOCOL_ADDR_LEN * 2))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -