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

📄 endlib.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* endLib.c - support library for END-based drivers *//* Copyright 1984 - 2002 Wind River Systems, Inc.  *//*modification history--------------------01z,21jun02,wap  avoid bcopy() in endEtherAddressForm()01y,21may02,vvv  updated mib2ErrorAdd doc (SPR #75064)01x,17may02,rcs  added endMibIfInit() for initializing the MIB-II callback                 pointers. SPR# 77478	01w,26oct01,brk  added cast to stop compile warnings (SPR #65332)01v,27jun01,rcs  Merg tor2.0.2 to Tornado-Comp-Drv01u,06feb01,spm  fixed detection of 802.3 Ethernet packets (SPR #27844)01t,16oct00,spm  merged version 01u from tor3_0_x branch (base version 01r):		 adds support for link-level broadcasts and multiple snarf		 protocols, and code cleanup; removes etherLib.h dependency01s,29apr99,pul  Upgraded NPT phase3 code to tor2.0.001r,16mar99,spm  recovered orphaned code from tor2_0_x branch (SPR #25770)01q,09dec98,n_s  fixed endEtherPacketDataGet to handle M_BLK chains. spr 2389501p,18nov98,n_s  fixed end8023AddressForm. spr 22976.01o,10dec97,gnn  made minor man page fixes01n,08dec97,gnn  END code review fixes.01m,17oct97,vin  changed prototypes, fixed endEtherPacketDataGet.01k,25sep97,gnn  SENS beta feedback fixes01j,27aug97,gnn  doc fixes and clean up.01i,25aug97,vin  added netMblkDup in endEtherPacketDataGet().01h,22aug97,gnn  cleaned up and improved endEtherAddrGet.01g,19aug97,gnn  changes due to new buffering scheme.		 added routine to get addresses from a packet.01f,12aug97,gnn  changes necessitated by MUX/END update.01e,jul3197,kbw  fixed man page problems found in beta review01d,26feb97,gnn  Set the type of a returned M_BLK_ID correctly.01c,05feb97,gnn  Added a check for NULL on allocation.01b,03feb97,gnn  Added default memory management routines.01a,26dec96,gnn  written.*/  /*DESCRIPTIONThis library contains support routines for Enhanced Network Drivers.These routines are common to ALL ENDs.  Specialized routines should onlyappear in the drivers themselves.INCLUDE FILES:*//* includes */#include "vxWorks.h"#include "memLib.h"#include "netBufLib.h"#include "endLib.h"#include "end.h"#include "etherMultiLib.h"#include "bufLib.h"#include "netinet/if_ether.h"#include "memLib.h"#include "stdlib.h"/* defints *//* typedefs *//* globals */MIB_ROUTINES * 	pMibRtn;    /* structure to hold MIB-II callback pointers */ /* locals *//* forward declarations */void endRcvRtnCall    (    END_OBJ* pEnd,    M_BLK_ID pData    )    {    if (pEnd->receiveRtn) 	{ 	pEnd->receiveRtn ((pEnd), pData);	}    }void tkRcvRtnCall    (    END_OBJ* pEnd,    M_BLK_ID pData,    long netSvcOffset,    long netSvcType,    BOOL wrongDstInt,    void* pAsyncData    )    {    if (pEnd->receiveRtn)	{	pEnd->receiveRtn ((pEnd), pData, netSvcOffset , netSvcType, 			  wrongDstInt, pAsyncData);	}    }void endTxSemTake    (    END_OBJ* pEnd,    int tmout    )     {    semTake(pEnd->txSem,tmout);    }void endTxSemGive    (    END_OBJ* pEnd    )    {    semGive (pEnd->txSem);    }void endFlagsClr    (    END_OBJ* pEnd,    int clrBits    )     {    pEnd->flags &= ~clrBits;    }void endFlagsSet    (    END_OBJ* pEnd,    int setBits    )    {    pEnd->flags |= (setBits);    }int endFlagsGet    (    END_OBJ* pEnd    )     {    return(pEnd->flags);    }int endMultiLstCnt    (    END_OBJ* pEnd    )    {    return (lstCount(&pEnd->multiList));    }ETHER_MULTI* endMultiLstFirst    (    END_OBJ *pEnd    )     {    return ((ETHER_MULTI *)(lstFirst(&pEnd->multiList)));    }ETHER_MULTI* endMultiLstNext    (    ETHER_MULTI* pCurrent    )     {    return ((ETHER_MULTI *)(lstNext(&pCurrent->node)));    }char* endDevName    (    END_OBJ* pEnd    )     {    return(pEnd->devObject.name);    }void endObjectUnload    (    END_OBJ* pEnd    )    {     lstFree (&pEnd->multiList);     lstFree (&pEnd->protocols);     }/******************************************************************************** endMibIfInit - Initialize the MIB-II callback pointers** This routine initializes the MIB-II pointers used by the callback macros.** RETURNS: OK or ERROR.** NOMANUAL*/STATUS endMibIfInit    (    FUNCPTR pMibAllocRtn,    FUNCPTR pMibFreeRtn,    FUNCPTR pMibCtrUpdate,    FUNCPTR pMibVarUpdate    )    {    if ((pMibAllocRtn != NULL) && (pMibFreeRtn != NULL) &&         (pMibCtrUpdate != NULL) && (pMibVarUpdate != NULL))        {        if (pMibRtn == NULL)            {            if ((pMibRtn = (MIB_ROUTINES *)malloc (sizeof (MIB_ROUTINES))) ==                  NULL)                {                return(ERROR);                }            }        pMibRtn->mibAlloc = (FUNCPTR)pMibAllocRtn;        pMibRtn->mibFree = (FUNCPTR)pMibFreeRtn;        pMibRtn->mibCntUpdate = (FUNCPTR)pMibCtrUpdate;        pMibRtn->mibVarUpdate = (FUNCPTR)pMibVarUpdate;        return(OK);        }    else        {        return(ERROR);        }    }/******************************************************************************** mib2Init - initialize a MIB-II structure** Initialize a MIB-II structure.  Set all error counts to zero.  Assume* a 10Mbps Ethernet device.** RETURNS: OK or ERROR.*/STATUS mib2Init    (    M2_INTERFACETBL *pMib,      /* struct to be initialized */    long ifType,                /* ifType from m2Lib.h */    UCHAR * phyAddr,            /* MAC/PHY address */    int addrLength,             /* MAC/PHY address length */    int mtuSize,                /* MTU size */    int speed                   /* interface speed */    )    {    /* Clear out our statistics. */    bzero ((char *)pMib, sizeof (*pMib));    pMib->ifPhysAddress.addrLength = addrLength;        /* Obtain our Ethernet address and save it */    bcopy ((char *) phyAddr, (char *)pMib->ifPhysAddress.phyAddress,	    pMib->ifPhysAddress.addrLength);    /* Set static statistics. assume ethernet */    pMib->ifType = ifType;    pMib->ifMtu =  mtuSize;    pMib->ifSpeed = speed;    return OK;    }/******************************************************************************** mib2ErrorAdd - change a MIB-II error count** This function adds a specified value to one of the MIB-II error counters in a * MIB-II interface table.  The counter to be altered is specified by the * errCode argument. errCode can be MIB2_IN_ERRS, MIB2_IN_UCAST, MIB2_OUT_ERRS * or MIB2_OUT_UCAST. Specifying a negative value reduces the error count, a * positive value increases the error count.** RETURNS: OK or ERROR.*/STATUS mib2ErrorAdd    (    M2_INTERFACETBL * pMib,    int errCode,    int value    )    {    switch (errCode)	{	default:	case MIB2_IN_ERRS:	    pMib->ifInErrors += value;	    break;	case MIB2_IN_UCAST:	    pMib->ifInUcastPkts += value;	    break;	case MIB2_OUT_ERRS:	    pMib->ifOutErrors += value;	    break;	case MIB2_OUT_UCAST:	    pMib->ifOutUcastPkts += value;	    break;	}        return OK;    }/********************************************************************************* endObjInit - initialize an END_OBJ structure** This routine initializes an END_OBJ structure and fills it with data from * the argument list.  It also creates and initializes semaphores and * protocol list.** RETURNS: OK or ERROR.*/STATUS endObjInit    (    END_OBJ *   pEndObj,        /* object to be initialized */    DEV_OBJ*    pDevice,        /* ptr to device struct */    char *      pBaseName,      /* device base name, for example, "ln" */    int         unit,           /* unit number */    NET_FUNCS * pFuncTable,     /* END device functions */    char*       pDescription    )    {    pEndObj->devObject.pDevice = pDevice;    /* Create the transmit semaphore. */    pEndObj->txSem = semMCreate ( SEM_Q_PRIORITY |				  SEM_DELETE_SAFE |				  SEM_INVERSION_SAFE);    if (pEndObj->txSem == NULL)	{	return (ERROR);	}    /* Install data and functions into the network node. */    pEndObj->flags = 0;    lstInit (&pEndObj->protocols);      /* Head of protocol list, */

⌨️ 快捷键说明

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