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

📄 m2pppipcpgroup.c

📁 这是全套的PPP协议的源码
💻 C
字号:
/* m2pppIpcpGroup.c - SNMP pppIpTable and pppIpConfigTable implementation *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01g,18dec02,qhu  rollback the change made previously.01f,18dec02,qhu delete m2pppIpcpGroupInterfacesTable in                 m2pppIpcpGroupUnregister, SPR 85198.  01e,16sep02,rp  fix for SPR 8206901d,28may02,rvr fixed build warnings (teamf1)01c,17mar00,adb HTML Manual fixes01b,22feb00,sj  documenation01a,06jan00,sj  created.*//*DESCRIPTIONThis library implements the SNMP pppIpTable and pppIpConfigTable which are partof the PPP IP MIB Group which is specified in RFC 1473.INCLUDE FILES: m2pppIpcpGroup.h m2pppLib.h ipcpInterfaces.h pfwStack.h pfwTable.hSEE ALSO: m2pppLib*//* includes */#include "vxWorks.h"#include "stdio.h"#include "stdlib.h"#include "string.h"#include "logLib.h"#include "tickLib.h"#include "pfw/pfw.h"#include "pfw/pfwStack.h"#include "pfw/pfwTable.h"#include "pfw/pfwMemory.h"#include "ppp/m2pppLib.h"#include "ppp/m2pppIpcpGroup.h"#include "ppp/interfaces/ipcpInterfaces.h"/* defines *//* typedefs */typedef struct m2pppIpcpGroupInterfacesEntry    {    PFW_OBJ *                         pfwObj;            /*framework for which*/                                                         /*these interfaces */							 /* exist */    int                               key;               /* tableItem number */    PPP_IPCP_MIB_INTERFACE          * pppIpcpEntry;    }M2_PPP_IPCP_GROUP_INTERFACES_ENTRY;/* globals *//* locals */LOCAL PFW_TABLE_OBJ * m2pppIpcpGroupInterfacesTable = NULL;/* forwards */LOCAL M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * ipcpGroupInterfacesGet (PFW_OBJ *);LOCAL BOOL compareIpcpGroupEntry (UINT32 key, void * pItem, void * arg);/******************************************************************************** m2pppIpcpGroupRegister - register/initialize PPP IP MIB Group interfaces** This routine allows the PPP framework component that supports the PPP* IP MIB Group to publish its support. Typically the IPCP* framework component supports this MIB. * * RETURNS: OK on successful registration and ERROR otherwise** SEE ALSO: m2pppLib*/STATUS m2pppIpcpGroupRegister    (    PFW_OBJ * pfwObj    /* PPP Framework context */    )    {    M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * ipcpGroupInterfaces;    int id;    if (m2pppIpcpGroupInterfacesTable == NULL)	{	if ((m2pppIpcpGroupInterfacesTable = pfwTableCreate(NULL,2,-1)) == NULL)	    {	    printf ("m2pppIpcpGroupInit: Failed to create m2pppIpcpGroupInterfacesTable \n");	    return ERROR;	    }	}    if ((ipcpGroupInterfaces = pfwMalloc(pfwObj,	    sizeof(M2_PPP_IPCP_GROUP_INTERFACES_ENTRY))) == NULL)	{	return ERROR;	}    /* get the interface pointers */    ipcpGroupInterfaces->pfwObj  = pfwObj;    if ((id = pfwInterfaceIdGet(pfwObj, 		"PPP_IPCP_MIB_INTERFACE")) == 0)	 {	 logMsg("m2IpcpGroup: Could not get ipcpEntry MIB interface ID\n",							     1,2,3,4,5,6);	 return ERROR;	 }    if ((ipcpGroupInterfaces->pppIpcpEntry = (PPP_IPCP_MIB_INTERFACE *)		    pfwInterfaceObjGetViaPfwObj (pfwObj,id)) == NULL)	    {	    pfwPrintError (__FILE__, "m2pppIpcpGroupInit", __LINE__, pfwObj,		0,"No PPP_IPCP_MIB_INTERFACE!");	    return ERROR;	    }    /* save interfaces information in table */    ipcpGroupInterfaces->key =	pfwTableItemAdd(m2pppIpcpGroupInterfacesTable,ipcpGroupInterfaces);    return OK;    }/******************************************************************************** m2pppIpcpGroupUnregister - withdraw PPP IP MIB Group support** This routine allows the PPP framework component that supports the PPP* IP MIB Group to withdraw its support.** RETURNS: OK on success and ERROR otherwise** SEE ALSO: m2pppLib*/STATUS m2pppIpcpGroupUnregister    (    PFW_OBJ * pfwObj    /* PPP Framework context */    )    {    M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * ipcpGroupInterfaces;    if (m2pppIpcpGroupInterfacesTable == NULL)	return ERROR;    if ((ipcpGroupInterfaces = ipcpGroupInterfacesGet(pfwObj)) == NULL)	return ERROR;    pfwInterfaceReferenceDelete(	&ipcpGroupInterfaces->pppIpcpEntry->interfaceObj);    /* delete interfaces information from table */    pfwTableItemDelete(m2pppIpcpGroupInterfacesTable,ipcpGroupInterfaces->key);    pfwFree(ipcpGroupInterfaces);    return OK;    }/******************************************************************************** m2pppIpcpGroupEntryLookup - access of PPP IP MIB group data keyed by link ID** This routine retrieves the PPP IPCP Status and Config data based on* PPP link ID. ** The first and only entry of the array argument <oid> specifies the link ID* which is the key to the composite pppIpEntry and pppIpConfigEntry. * The argument <oidLen> that specifies* the number of elements in the <oid> array should be set to 1.** If <M2_PPP_ENTRY_MATCH_TYPE> is set to M2_PPP_ENTRY_EXACT_MATCH * the data that correspond to the input key will be retrieved.* If <M2_PPP_ENTRY_MATCH_TYPE> is set to M2_PPP_ENTRY_NEXT_MATCH, * the data corresponding to the key that is minimum superior to the* input key will be retrieved, provided that an entry exists with * key superior to the input key. ** The input key may be 0 only in the M2_PPP_ENTRY_NEXT_MATCH case call.** This routine must be called before a set operation can be performed for any* of the leaf objects in this entry in order to retrieve the necessary * references and contexts which are stored in the corresponding* PPP_IPCP_ENTRY_DATA structure.** RETURNS: OK or ERROR** SEE ALSO: m2pppLib*/STATUS m2pppIpcpEntryLookup    (    UINT32                  oidLen, /* should be set to 1 */    UINT32 *                oid,    /* should point to link ID */    PPP_IPCP_ENTRY_DATA *   data,   /* placeholder for retrieved data */    M2_PPP_ENTRY_MATCH_TYPE match   /* EXACT or NEXT */    )    {    int ifIndex = (oid != NULL && oidLen == 1) ? *oid : 0;    int nextIfIndex = 0;    M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * ipcpGroupInterfaces;    if (match == M2_PPP_ENTRY_EXACT_MATCH && ifIndex <= 0)	return ERROR;    else if (match == M2_PPP_ENTRY_NEXT_MATCH && ifIndex < 0)	return ERROR;    if ((match == M2_PPP_ENTRY_EXACT_MATCH)  && 	(m2pppInterfaceStackObjGet(ifIndex,&data->stackObj) != OK))	return ERROR;    if ((match == M2_PPP_ENTRY_NEXT_MATCH)  && 	(m2pppNextInterfaceStackObjGet((UINT32)ifIndex,(UINT32 *)&nextIfIndex,&data->stackObj)	!= OK))	return ERROR;    if (data->stackObj == NULL)	return ERROR;    if ((ipcpGroupInterfaces =	    ipcpGroupInterfacesGet(pfwStackObjPfwGet(data->stackObj))) == NULL)	return ERROR;    data->interface = ipcpGroupInterfaces->pppIpcpEntry;    if ((data->state = pfwPluginObjStateGet (data->stackObj,			    data->interface->interfaceObj.pluginObj)) == NULL)	return ERROR;    return OK;    }/******************************************************************************** ipcpGroupInterfacesGet -*/LOCAL M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * ipcpGroupInterfacesGet    (    PFW_OBJ * pfwObj    )    {    int key;    key = pfwTableTraverse(m2pppIpcpGroupInterfacesTable,						compareIpcpGroupEntry,pfwObj);    if (key == 0)	return NULL;    else	return (pfwTableItemGet(m2pppIpcpGroupInterfacesTable,key));    }/******************************************************************************** compareIpcpGroupEntry -*/LOCAL BOOL compareIpcpGroupEntry    (    UINT32 key,    void * pItem,    void * arg    )    {    M2_PPP_IPCP_GROUP_INTERFACES_ENTRY * tableEntry = pItem;    PFW_OBJ * thisPfw = arg;    if (tableEntry->pfwObj == thisPfw)	return TRUE;    return FALSE;    }

⌨️ 快捷键说明

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