?? net_icmp.c
字號:
/*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Suite
*
* (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may not be used to write a similar
* product. This file may only be used in accordance with a license
* and should not be redistributed in any way.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* NETWORK ICMP LAYER
* (INTERNET CONTROL MESSAGE PROTOCOL)
*
* Filename : net_icmp.c
* Version : V1.86
* Programmer(s) : ITJ
*********************************************************************************************************
* Note(s) : (1) Supports Internet Control Message Protocol as described in RFC #792 with the following
* restrictions/constraints :
*
* (a) Does NOT support IP forwarding/routing RFC #1122, Section 3.3.1
*
* (b) Does NOT support IP multicasting RFC #1122, Section 3.3.7
*
* (c) Does NOT support ICMP Address Mask Agent/Server RFC #1122, Section 3.2.2.9
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#define NET_ICMP_MODULE
#include <net.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/* ------------------- RX FNCTS ------------------- */
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
static void NetICMP_RxPktValidateBuf (NET_BUF_HDR *pbuf_hdr,
NET_ERR *perr);
#endif
static void NetICMP_RxPktValidate (NET_BUF *pbuf,
NET_BUF_HDR *pbuf_hdr,
NET_ICMP_HDR *picmp_hdr,
NET_ERR *perr);
static void NetICMP_RxPktFree (NET_BUF *pbuf);
static void NetICMP_RxPktDiscard (NET_BUF *pbuf,
NET_ERR *perr);
/* ------------------- TX FNCTS ------------------- */
static void NetICMP_TxMsgErrValidate (NET_BUF *pbuf,
NET_BUF_HDR *pbuf_hdr,
NET_IP_HDR *pip_hdr,
CPU_INT08U type,
CPU_INT08U code,
CPU_INT08U ptr,
NET_ERR *perr);
static void NetICMP_TxMsgReqValidate (CPU_INT08U type,
CPU_INT08U code,
NET_ERR *perr);
static void NetICMP_TxMsgReply (NET_BUF *pbuf,
NET_BUF_HDR *pbuf_hdr,
NET_ICMP_HDR *picmp_hdr,
NET_ERR *perr);
static void NetICMP_TxPktFree (NET_BUF *pbuf);
static void NetICMP_TxPktDiscard (NET_BUF *pbuf,
NET_ERR *perr);
/* ---------------- HANDLER FNCTS ----------------- */
#if (NET_ICMP_CFG_TX_SRC_QUENCH_EN == DEF_ENABLED)
static void NetICMP_HandlerTxSrcQuench (NET_BUF *pbuf);
static void NetICMP_HandlerTxSrcQuenchClrList(void);
static void NetICMP_HandlerTxSrcQuenchClr (NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
static NET_ICMP_TX_SRC_QUENCH *NetICMP_HandlerTxSrcQuenchGet (NET_ERR *perr);
static void NetICMP_HandlerTxSrcQuenchFree (NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
static void NetICMP_HandlerTxSrcQuenchRemove (NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
static void NetICMP_HandlerTxSrcQuenchInsert (NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
static void NetICMP_HandlerTxSrcQuenchUnlink (NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
static void NetICMP_HandlerTxSrcQuenchDiscard(NET_ICMP_TX_SRC_QUENCH *ptx_src_quench);
#endif
#endif
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*$PAGE*/
/*
*********************************************************************************************************
* NetICMP_Init()
*
* Description : (1) Initialize Internet Control Message Protocol Layer :
*
* (a) Initialize ICMP transmit source quench :
* (1) Initialize ICMP transmit source quench pool
* (A) Pool MUST be initialized PRIOR to initializing the pool with pointers to
* ICMP transmit source quench entries.
* (2) Initialize ICMP transmit source quench table
* (3) Initialize ICMP transmit source quench list pointers
* (c) Initialize ICMP statistics & error counters
*
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Net_Init().
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetICMP_Init (void)
{
#if (NET_ICMP_CFG_TX_SRC_QUENCH_EN == DEF_ENABLED)
NET_ICMP_TX_SRC_QUENCH *ptx_src_quench_tbl;
NET_ICMP_SRC_QUENCH_QTY i;
NET_ERR err;
/* -------- INIT ICMP TX SRC QUENCH POOL/STATS -------- */
NetICMP_TxSrcQuenchPoolPtr = (NET_ICMP_TX_SRC_QUENCH *)0; /* See Note #1a1A. */
NetStat_PoolInit((NET_STAT_POOL *)&NetICMP_TxSrcQuenchPoolStat,
(NET_STAT_POOL_QTY) NET_ICMP_CFG_TX_SRC_QUENCH_SIZE,
(NET_ERR *)&err);
/* ----------- INIT ICMP TX SRC QUENCH TBL ------------ */
ptx_src_quench_tbl = &NetICMP_TxSrcQuenchTbl[0];
for (i = 0; i < NET_ICMP_CFG_TX_SRC_QUENCH_SIZE; i++) {
/* Init each ICMP tx src quench type--NEVER modify. */
ptx_src_quench_tbl->Type = NET_ICMP_TYPE_TX_SRC_QUENCH;
ptx_src_quench_tbl->Flags = NET_ICMP_FLAG_NONE; /* Init each ICMP tx src quench as NOT used. */
#if (NET_DBG_CFG_MEM_CLR_EN == DEF_ENABLED)
NetICMP_HandlerTxSrcQuenchClr(ptx_src_quench_tbl);
#endif
/* Free each entry to pool (see Note #1a1A). */
ptx_src_quench_tbl->NextPtr = (void *)NetICMP_TxSrcQuenchPoolPtr;
NetICMP_TxSrcQuenchPoolPtr = ptx_src_quench_tbl;
ptx_src_quench_tbl++;
}
/* -------- INIT ICMP TX SRC QUENCH LIST PTRS --------- */
NetICMP_TxSrcQuenchListHead = (NET_ICMP_TX_SRC_QUENCH *)0;
NetICMP_TxSrcQuenchListTail = (NET_ICMP_TX_SRC_QUENCH *)0;
#endif
/*$PAGE*/
/* ------------ INIT ICMP STAT & ERR CTRS ------------- */
NetICMP_TxSeqNbrCtr = 0;
#if (NET_CTR_CFG_STAT_EN == DEF_ENABLED)
NetICMP_StatRxMsgCtr = 0;
NetICMP_StatRxMsgProcessedCtr = 0;
NetICMP_StatRxMsgErrProcessedCtr = 0;
NetICMP_StatRxMsgReqProcessedCtr = 0;
NetICMP_StatRxMsgReplyProcessedCtr = 0;
NetICMP_StatTxMsgCtr = 0;
NetICMP_StatTxMsgErrCtr = 0;
NetICMP_StatTxMsgReqCtr = 0;
NetICMP_StatTxMsgReplyCtr = 0;
#endif
#if (NET_CTR_CFG_ERR_EN == DEF_ENABLED)
NetICMP_ErrRxHdrTypeCtr = 0;
NetICMP_ErrRxHdrCodeCtr = 0;
NetICMP_ErrRxHdrMsgLenCtr = 0;
NetICMP_ErrRxHdrPtrCtr = 0;
NetICMP_ErrRxHdrChkSumCtr = 0;
NetICMP_ErrRxBroadcastCtr = 0;
NetICMP_ErrRxPktDiscardedCtr = 0;
NetICMP_ErrTxInvalidLenCtr = 0;
NetICMP_ErrTxHdrTypeCtr = 0;
NetICMP_ErrTxHdrCodeCtr = 0;
NetICMP_ErrTxPktDiscardedCtr = 0;
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
NetICMP_ErrNullPtrCtr = 0;
NetICMP_ErrNotUsedCtr = 0;
NetICMP_ErrInvalidTypeCtr = 0;
NetICMP_ErrRxInvalidBufIxCtr = 0;
NetICMP_ErrRxHdrDataLenCtr = 0;
NetICMP_ErrTxInvalidBufIxCtr = 0;
NetICMP_ErrTxHdrPtrCtr = 0;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -