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

📄 net_stat.c

📁 从Luminary官方网站下载的LM3S6000系列的UCos+Tcp/IP的源码, 经本人稍微修改后可直接在IAR6.2下编译通过,里面包括了LM3S6000系列的所有外设UART, PWn....
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
*                                              uC/TCP-IP
*                                      The Embedded TCP/IP Suite
*
*                          (c) Copyright 2003-2007; 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 STATISTICS MANAGEMENT
*
* Filename      : net_stat.c
* Version       : V1.89
* Programmer(s) : ITJ
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                            INCLUDE FILES
*********************************************************************************************************
*/

#define    NET_STAT_MODULE
#include  <net.h>


/*$PAGE*/
/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                           LOCAL CONSTANTS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                          LOCAL DATA TYPES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                            LOCAL TABLES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                       LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                      LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                     LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/


/*$PAGE*/
/*
*********************************************************************************************************
*                                            NetStat_Init()
*
* Description : (1) Initialize Network Statistic Management Module :
*
*                   (a) Initialize statistics error counters
*
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : Net_Init().
*
*               This function is an INTERNAL network protocol suite function & MUST NOT be called by 
*               application function(s).
*
* Note(s)     : none.
*********************************************************************************************************
*/

void  NetStat_Init (void)
{
                                                                /* ---------------- INIT STAT ERR CTRS ---------------- */
#if (NET_CTR_CFG_ERR_EN         == DEF_ENABLED)
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
    NetStat_ErrNullPtrCtr       =  0;
    NetStat_ErrInvalidTypeCtr   =  0;
#endif
#endif
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                         NetStat_PoolInit()
*
* Description : Initialize a statistics pool.
*
* Argument(s) : pstat_pool  Pointer to a statistics pool.
*
*               nbr_avail   Total number of available statistics pool entries.
*
*               perr        Pointer to variable that will receive the return error code from this function :
*
*                               NET_STAT_ERR_NONE               Statistics pool successfully initialized.
*                               NET_STAT_ERR_NULL_PTR           Argument 'pstat_pool' passed a NULL pointer.
*
* Return(s)   : none.
*
* Caller(s)   : various.
*
*               This function is an INTERNAL network protocol suite function & SHOULD NOT be called by 
*               application function(s).
*
* Note(s)     : (1) Assumes pointer to statistics pool is valid (if non-NULL).
*********************************************************************************************************
*/

void  NetStat_PoolInit (NET_STAT_POOL      *pstat_pool,
                        NET_STAT_POOL_QTY   nbr_avail,
                        NET_ERR            *perr)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)                 /* ------------------- VALIDATE PTR ------------------- */
    if (pstat_pool == (NET_STAT_POOL *)0) {
        NET_CTR_ERR_INC(NetStat_ErrNullPtrCtr);
       *perr = NET_STAT_ERR_NULL_PTR;
        return;
    }
#endif


    CPU_CRITICAL_ENTER();
    pstat_pool->Type                  = NET_STAT_TYPE_POOL;     /* Init stat pool type--NEVER modify.                   */
    pstat_pool->EntriesInit           = nbr_avail;              /* Init nbr of pool  entries is also ...                */
    pstat_pool->EntriesTot            = nbr_avail;              /* Tot  nbr of pool  entries is also ...                */
    pstat_pool->EntriesAvail          = nbr_avail;              /* Init nbr of avail entries.                           */
    pstat_pool->EntriesUsed           = 0;
    pstat_pool->EntriesUsedMax        = 0;
    pstat_pool->EntriesLostCur        = 0;
    pstat_pool->EntriesLostTot        = 0;
    pstat_pool->EntriesAllocatedCtr   = 0;
    pstat_pool->EntriesDeallocatedCtr = 0;
    CPU_CRITICAL_EXIT();


   *perr = NET_STAT_ERR_NONE;
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                          NetStat_PoolClr()
*
* Description : Clear a statistics pool.
*
* Argument(s) : pstat_pool  Pointer to a statistics pool.
*
*               perr        Pointer to variable that will receive the return error code from this function :
*
*                               NET_STAT_ERR_NONE               Statistics pool successfully cleared.
*                               NET_STAT_ERR_NULL_PTR           Argument 'pstat_pool' passed a NULL pointer.
*
* Return(s)   : none.
*
* Caller(s)   : various.
*
*               This function is an INTERNAL network protocol suite function & SHOULD NOT be called by 
*               application function(s).
*
* Note(s)     : (1) Assumes pointer to statistics pool is valid (if non-NULL).
*********************************************************************************************************
*/

void  NetStat_PoolClr (NET_STAT_POOL  *pstat_pool,
                       NET_ERR        *perr)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)                 /* ------------------- VALIDATE PTR ------------------- */
    if (pstat_pool == (NET_STAT_POOL *)0) {
        NET_CTR_ERR_INC(NetStat_ErrNullPtrCtr);
       *perr = NET_STAT_ERR_NULL_PTR;
        return;
    }
#endif


    CPU_CRITICAL_ENTER();
    pstat_pool->Type                  = NET_STAT_TYPE_NONE;
    pstat_pool->EntriesInit           = 0;
    pstat_pool->EntriesTot            = 0;
    pstat_pool->EntriesAvail          = 0;
    pstat_pool->EntriesUsed           = 0;
    pstat_pool->EntriesUsedMax        = 0;
    pstat_pool->EntriesLostCur        = 0;
    pstat_pool->EntriesLostTot        = 0;
    pstat_pool->EntriesAllocatedCtr   = 0;
    pstat_pool->EntriesDeallocatedCtr = 0;
    CPU_CRITICAL_EXIT();


   *perr = NET_STAT_ERR_NONE;
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                         NetStat_PoolReset()
*
* Description : Reset a statistics pool.
*
*               (1) Assumes object pool is also reset; otherwise, statistics pool will NOT accurately
*                   reflect the state of the object pool.
*
*
* Argument(s) : pstat_pool  Pointer to a statistics pool.
*
*               perr        Pointer to variable that will receive the return error code from this function :
*
*                               NET_STAT_ERR_NONE                   Statistics pool successfully reset.
*                               NET_STAT_ERR_NULL_PTR               Argument 'pstat_pool' passed a NULL pointer.
*                               NET_STAT_ERR_POOL_INVALID_TYPE      Invalid statistics pool type.
*
* Return(s)   : none.
*
* Caller(s)   : various.
*
*               This function is an INTERNAL network protocol suite function & SHOULD NOT be called by 
*               application function(s).
*
* Note(s)     : none.
*********************************************************************************************************
*/

void  NetStat_PoolReset (NET_STAT_POOL  *pstat_pool,
                         NET_ERR        *perr)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
                                                                /* ------------------ VALIDATE PTR -------------------- */
    if (pstat_pool == (NET_STAT_POOL *)0) {
        NET_CTR_ERR_INC(NetStat_ErrNullPtrCtr);
       *perr = NET_STAT_ERR_NULL_PTR;
        return;
    }
                                                                /* ------------------ VALIDATE TYPE ------------------- */
    if (pstat_pool->Type != NET_STAT_TYPE_POOL) {

⌨️ 快捷键说明

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