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

📄 snmpudp.c

📁 wm PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
字号:
/* snmpUdp.c - snmp v1 method routines *//* *  Copyright 2000-2005 Wind River Systems, Inc. *  All rights reserved.  Provided under license only. *  Distribution or other use of this software is only *  permitted pursuant to the terms of a license agreement *  from Wind River Systems (and is otherwise prohibited). *  Refer to that license agreement for terms of use. */#include "copyright_wrs.h"/*modification history-------------------01c,19apr05,job  update copyright notices01b,01dec03,job  update copyright information01a,10mar96,rjc  written*//* * $Log: snmpudp.c,v $ * Revision 1.5  2002/06/20 15:21:05  meister * Fixed some function storage class compiler warnings * (static/non-static inconsistencies) * * Revision 1.4  2001/11/09 17:30:26  tneale * Another adjustment for generated header files * * Revision 1.3  2001/11/09 14:54:09  tneale * Fixed paths for generated files mibhand.h and mibleaf.h * * Revision 1.2  2001/11/08 22:18:36  meister * rework pathnames * * Revision 1.1.1.1  2001/11/05 17:47:50  tneale * Tornado shuffle * * Revision 1.7  2001/04/24 17:44:11  josh * updating vxWorks agent with modifications carried over * from Windnet/SNMP agent * * Revision 1.6  2001/04/16 19:38:44  josh * merging the kingfisher branch onto the trunk * * Revision 1.5  2001/01/19 22:25:07  paul * Update copyright. * * Revision 1.4.2.2  2001/03/12 22:11:36  tneale * Updated copyright * * Revision 1.4.2.1  2000/10/17 21:24:53  josh * fixing a bug in udpEntryGet() -- UDP port number was always being * assigned a value of 1 * * Revision 1.4  2000/03/09 17:42:28  josh * setting up prototypes and includes where appropriate to eliminate * build warnings * * Revision 1.3  2000/03/07 21:17:31  josh * fixing log comments * * Revision 1.2  2000/03/07 20:58:37  josh * putting CVS headers and logs into files that were lacking * *//* includes */#include <wrn/wm/snmp/vxagent/snmpdLib.h>#include "m2Lib.h"#include <wrn/wm/snmp/vxagent/mibleaf.h>#include <wrn/wm/snmp/vxagent/mibhand.h>#include <wrn/wm/snmp/engine/auxfuncs.h>/* defines */#define IP_ADDR_LEN               4               /* Num of oid components in ip address */#define UDP_PORT_LEN              1               /* Num of oid components in udp port */#define MAX_UDP_PORT              0xffff          /* Max value for tcp port */#define UDP_TBL_INDEX_LEN         (IP_ADDR_LEN + UDP_PORT_LEN)/* locals *//* max possible values for udp table index*/LOCAL  const OIDC_T maxUdpIndex []        = { 0xff, 0xff, 0xff, 0xff, 0xffff };/* forward declarations */LOCAL void udpEntryInfoGet (OIDC_T, SNMP_PKT_T*, VB_T*, M2_UDPTBL*);    /*******************************************************************************  udpGet**  Get method routine for udp group scalars*  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.**  RETURNS : N/A*/    void udpGet    (    OIDC_T              lastmatch,    int	                compc,    OIDC_T*             compl,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {    M2_UDP      udpVars;    /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);    if ((compc != 1) || (*compl != 0))        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            getproc_nosuchins (pktp, vbp);            }        return;        }    if (m2UdpGroupInfoGet (&udpVars) != OK)         {         for ( ; vbp != NULL; vbp = vbp->vb_link)             {             getproc_error (pktp, vbp, GEN_ERR);             }            return;        }            for ( ; vbp; vbp = vbp->vb_link)        {        switch (vbp->vb_ml.ml_last_match)            {            case LEAF_udpInDatagrams:                getproc_got_uint32 (pktp, vbp, udpVars.udpInDatagrams,                                     VT_COUNTER);                break;            case LEAF_udpNoPorts:                getproc_got_uint32 (pktp, vbp, udpVars.udpNoPorts, VT_COUNTER);                break;            case LEAF_udpInErrors:                getproc_got_uint32 (pktp, vbp, udpVars.udpInErrors, VT_COUNTER);                break;            case LEAF_udpOutDatagrams:                getproc_got_uint32 (pktp, vbp, udpVars.udpOutDatagrams,                                     VT_COUNTER);                break;            default:                getproc_error (pktp, vbp, GEN_ERR);                break;             }        }    }/*******************************************************************************  udpEntryGet **  Get method routine for udp Table.*  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.**  RETURNS : N/A**/void udpEntryGet    (    OIDC_T              lastmatch,    int	                compc,    OIDC_T*             compl,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    )    {    M2_UDPTBL  udpEntry;    /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance(pktp, vbp, compc, compl);    if ((compc != UDP_TBL_INDEX_LEN) ||        ((snmpOidToIpHostOrder (IP_ADDR_LEN, compl,                                &udpEntry.udpLocalAddress),          (udpEntry.udpLocalPort = compl [IP_ADDR_LEN])) > MAX_UDP_PORT) ||        (m2UdpTblEntryGet (M2_EXACT_VALUE, &udpEntry) != OK))       {       for ( ; vbp != NULL; vbp = vbp->vb_link)           {           getproc_nosuchins (pktp, vbp);           }       return;       }    /* mark getproc for this varbind as started to avoid  repetition */    for (  ; vbp; vbp = vbp->vb_link)       {       udpEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &udpEntry);       }   }/*******************************************************************************  udpEntryInfoGet**  Routine  for extracting udptable info from the appropriate*  m2 udp structure.**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.*  <pUdpEntry> - ptr to udp entry.**  RETURNS : N/A*/LOCAL void udpEntryInfoGet    (    OIDC_T              lastmatch,    SNMP_PKT_T*	        pktp,    VB_T*               vbp,    M2_UDPTBL *         pUdpEntry    )    {    switch (lastmatch)        {        case LEAF_udpLocalAddress:            getproc_got_ip_address (pktp, vbp,                                    htonl (pUdpEntry->udpLocalAddress));            return;        case LEAF_udpLocalPort:            getproc_got_int32 (pktp, vbp, (INT_32_T)pUdpEntry->udpLocalPort);            break;        default:            getproc_error (pktp, vbp, GEN_ERR);            return;        }    }/*******************************************************************************  udpEntryNext**  Next method routine for udpTable**  Parameters to this routine are *  *  <lastmatch> - the last oid component that was matched to get to this leaf.*  <compc>     - count of components remaining in the unmatched portion i.e.*                the length of the instance portion.*  <compl>     - ptr to the oid sequence remaining, i.e. the instance portion.*  <pktp>      - ptr to internal representation of the snmp pkt.*  <vbp>       - ptr to var bind being processed.**  RETURNS : N/A**/void udpEntryNext    (    OIDC_T              lastmatch,    int	                compc,    OIDC_T*             compl,    SNMP_PKT_T*	        pktp,    VB_T*               vbp    ){    M2_UDPTBL           udpEntry;    OIDC_T              udpIndex [UDP_TBL_INDEX_LEN];    /* Group together all varbinds which have the same getproc and instance */    snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl);    if (snmpNextIndex (compc, compl, udpIndex, maxUdpIndex, UDP_TBL_INDEX_LEN))           {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            nextproc_no_next (pktp, vbp);            }        return;        }    snmpOidToIpHostOrder (IP_ADDR_LEN, udpIndex, &udpEntry.udpLocalAddress);     udpEntry.udpLocalPort = udpIndex [IP_ADDR_LEN];    if (m2UdpTblEntryGet (M2_NEXT_VALUE, & udpEntry) != OK)        {        for ( ; vbp != NULL; vbp = vbp->vb_link)            {            snmpNextError (pktp, vbp);            }        return;        }    (void) ip_to_rlist(htonl (udpEntry.udpLocalAddress), udpIndex);    *(udpIndex + IP_ADDR_LEN) = udpEntry.udpLocalPort;    for ( ; vbp; vbp = vbp->vb_link)       {       /* install instance part of next instance found */        nextproc_next_instance (pktp, vbp, UDP_TBL_INDEX_LEN, udpIndex);       udpEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &udpEntry);       }    }

⌨️ 快捷键说明

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