/*
 *  Copyright (c) 1996-2007 Digi International Inc., All Rights Reserved
 *
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *
 *  Restricted Rights Legend
 *
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
*  File Description:
*                Definitions for SNMP (RFC 1067) agent variable finder.
**************************************************************************/

/***********************************************************
    Copyright 1988, 1989 by Carnegie Mellon University
    Copyright 1989  TGV, Incorporated

              All Rights Reserved

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of CMU and TGV not be used
in advertising or publicity pertaining to distribution of the software
without specific, written prior permission.

CMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
#ifndef _SNMPVARS_
#define _SNMPVARS_

#include <man_agnt.h>
#ifdef __cplusplus
extern "C"
{
#endif

    
/* prototypes for snmpvar.c                                             */
struct subtree * mibGroupRegister(oid * baseOid, int oidLen, struct variable * vars,
    int vCount, int vSize);
void removeAllMibGroups(void);
int mibGroupUnregister(oid * baseOid, int oidLen);

int getMibVal(struct varBind *getOp, int exact);

int compare(oid *name1, int len1, oid *name2, int len2);
int compare_tree(oid *name1, int len1, oid *name2, int len2);
int scalar_handler(struct variable *, oid *, int *, int, int *);
int isAscii(char * string);

extern char * nullString;
extern u_long nullLong;
extern oid nullOid[2];


/*
 * The subtree structure contains a subtree prefix which applies to
 * all variables in the associated variable list.
 * No subtree may be a subtree of another subtree in this list.  i.e.:
 * 1.2
 * 1.2.1.2
 */
struct subtree
{
    struct subtree * next;  /* pointer to next subtree in linked list   */
    struct variable *variables; /* pointer to MIB group variables array */
    int variables_len;      /* number of entries in above array         */
    int variables_width;    /* sizeof each variable entry               */
    oid *name;              /* objid prefix of subtree                  */
    u_char namelen;         /* number of subid's in name above          */
};

/* This is the general structure used in each MIB group array           */
/* Actual structures use something less than MAX_NAME_LEN for the size  */
/*  of the name oid array*/

/*ad*
 * Structure used in each MIB group array
 *
 * @category SNMP
 * @external
 * @since 6.0
 *
 * @param magic		passed to function as a hint
 * @param type 		type of variable
 * @param acl		access control list for variable
 * @param findVar	function that finds variable
 * @param namelen	length name of below
 * @param indexInfo	information about items indices
 * @param fieldCode	identifies which table field is being accessed
 * @param manInfo	info for management variable that represents the object
 * @param writeFn	write function for this object
 * @param name		object identifier of variable
 *
 * @see @link u_char
 * @see @link u_short
 * @see @link snmpVarAccess
*ad*/

struct variable
{
    u_char magic;           
    char type;             
    u_short acl;            
    snmpVarAccess findVar;  
    u_char namelen;         
#ifdef WANT_MIBMAN
    void *indexInfo;  
    int fieldCode;                      
    void *manInfo;                
    void *writeFn;          
#endif
    oid name[MAX_NAME_LEN]; 
};

/*
 * This is a new variable structure that doesn't have as much memory
 * tied up in the object identifier.  It's elements have also been re-arranged
 * so that the name field can be variable length.  Any number of these
 * structures can be created with lengths tailor made to a particular
 * application.  The first 5 elements of the structure must remain constant.
 */
struct variable2
{
    u_char  magic;          /* passed to function as a hint */
    char    type;           /* type of variable */
    u_short acl;            /* access control list for variable */
    snmpVarAccess findVar;  /* variable access method                   */
    u_char  namelen;        /* length of name below */
#ifdef WANT_MIBMAN
    void *indexInfo;  /* information about items indices*/
    int fieldCode;                      /* identifies which table field is being accessed*/
    void *manInfo;                /* info for management variable that represents the object*/
    void *writeFn;          /* write function for this object */
#endif
    oid     name[2];        /* object identifier of variable */
};

struct variable3
{
    u_char  magic;          /* passed to function as a hint */
    char    type;           /* type of variable */
    u_short acl;            /* access control list for variable */
    snmpVarAccess findVar;  /* variable access method                   */
    u_char  namelen;        /* length of name below */
#ifdef WANT_MIBMAN
    void *indexInfo;  /* information about items indices*/
    int fieldCode;                      /* identifies which table field is being accessed*/
    void *manInfo;                /* info for management variable that represents the object*/
    void *writeFn;          /* write function for this object */
#endif
    oid     name[3];        /* object identifier of variable */
};

struct variable4
{
    u_char  magic;          /* passed to function as a hint */
    char    type;           /* type of variable */
    u_short acl;            /* access control list for variable */
    snmpVarAccess findVar;  /* variable access method                   */
    u_char  namelen;        /* length of name below */
#ifdef WANT_MIBMAN
    void *indexInfo;  /* information about items indices*/
    int fieldCode;                      /* identifies which table field is being accessed*/
    void *manInfo;                /* info for management variable that represents the object*/
    void *writeFn;          /* write function for this object */
#endif
    oid     name[4];        /* object identifier of variable */
};


/*
 * These are unit magic numbers for each variable.
 */
 /* TBD - move to <MIB group>_var.h */
#if 0
#define VERSION_DESCR       0
#define VERSION_ID          1
#define UPTIME              3
#define SYSCONTACT          4
#define SYSNAME             5
#define SYSLOCATION         6
#define SYSSERVICES         7

#define IFNUMBER            2
#define IFINDEX             1
#define IFDESCR             2
#define IFTYPE              3
#define IFMTU               4
#define IFSPEED             5
#define IFPHYSADDRESS       6
#define IFADMINSTATUS       7
#define IFOPERSTATUS        8
#define IFLASTCHANGE        9
#define IFINOCTETS          10
#define IFINUCASTPKTS       11
#define IFINNUCASTPKTS      12
#define IFINDISCARDS        13
#define IFINERRORS          14
#define IFINUNKNOWNPROTOS   15
#define IFOUTOCTETS         16
#define IFOUTUCASTPKTS      17
#define IFOUTNUCASTPKTS     18
#define IFOUTDISCARDS       19
#define IFOUTERRORS         20
#define IFOUTQLEN           21
#define IFSPECIFIC          22

#define ATIFINDEX           80
#define ATPHYSADDRESS       81
#define ATNETADDRESS        82

#define IPFORWARDING        0
#define IPDEFAULTTTL        1
#define IPINRECEIVES        2
#define IPINHDRERRORS       3
#define IPINADDRERRORS      4
#define IPFORWDATAGRAMS     5
#define IPINUNKNOWNPROTOS   6
#define IPINDISCARDS        7
#define IPINDELIVERS        8
#define IPOUTREQUESTS       9
#define IPOUTDISCARDS       10
#define IPOUTNOROUTES       11
#define IPREASMTIMEOUT      12
#define IPREASMREQDS        13
#define IPREASMOKS          14
#define IPREASMFAILS        15
#define IPFRAGOKS           16
#define IPFRAGFAILS         17
#define IPFRAGCREATES       18
#define IPROUTINGDISCARDS   19

#define IPADADDR            1
#define IPADIFINDEX         2
#define IPADNETMASK         3
#define IPADBCASTADDR       4
#define IPADREASMMAXSIZE    5

#define IPROUTEDEST     0
#define IPROUTEIFINDEX  1
#define IPROUTEMETRIC1  2
#define IPROUTEMETRIC2  3
#define IPROUTEMETRIC3  4
#define IPROUTEMETRIC4  5
#define IPROUTENEXTHOP  6
#define IPROUTETYPE     7
#define IPROUTEPROTO    8
#define IPROUTEAGE      9
#define IPROUTEMASK     10
#define IPROUTEMETRIC5  11
#define IPROUTEINFO     12

#define IPNETTOMEDIAIFINDEX     0
#define IPNETTOMEDIAPHYSADDRESS 4
#define IPNETTOMEDIAIPADDRESS   16
#define IPNETTOMEDIATYPE        20

#define ICMPINMSGS              0
#define ICMPINERRORS            1
#define ICMPINDESTUNREACHS      2
#define ICMPINTIMEEXCDS         3
#define ICMPINPARMPROBS         4
#define ICMPINSRCQUENCHS        5
#define ICMPINREDIRECTS         6
#define ICMPINECHOS             7
#define ICMPINECHOREPS          8
#define ICMPINTIMESTAMPS        9
#define ICMPINTIMESTAMPREPS     10
#define ICMPINADDRMASKS         11
#define ICMPINADDRMASKREPS      12
#define ICMPOUTMSGS             13
#define ICMPOUTERRORS           14
#define ICMPOUTDESTUNREACHS     15
#define ICMPOUTTIMEEXCDS        16
#define ICMPOUTPARMPROBS        17
#define ICMPOUTSRCQUENCHS       18
#define ICMPOUTREDIRECTS        19
#define ICMPOUTECHOS            20
#define ICMPOUTECHOREPS         21
#define ICMPOUTTIMESTAMPS       22
#define ICMPOUTTIMESTAMPREPS    23
#define ICMPOUTADDRMASKS        24
#define ICMPOUTADDRMASKREPS     25

#define TCPRTOALGORITHM      0
#define TCPRTOMIN            4
#define TCPRTOMAX            8
#define TCPMAXCONN           12
#define TCPACTIVEOPENS       16
#define TCPPASSIVEOPENS      20
#define TCPATTEMPTFAILS      24
#define TCPESTABRESETS       28
#define TCPCURRESTAB         32
#define TCPINSEGS            36
#define TCPOUTSEGS           40
#define TCPRETRANSSEGS       44
#define TCPINERRS            48
#define TCPOUTRSTS           52

#define TCPCONNSTATE        13
#define TCPCONNLOCALADDRESS 14
#define TCPCONNLOCALPORT    15
#define TCPCONNREMADDRESS   16
#define TCPCONNREMPORT      17

#define UDPINDATAGRAMS      0
#define UDPNOPORTS          4
#define UDPINERRORS         8
#define UDPOUTDATAGRAMS     12


#define UDPLOCALADDRESS     0
#define UDPLOCALPORT        1

#define SNMPINPKTS              0
#define SNMPOUTPKTS             4
#define SNMPINBADVERSIONS       8
#define SNMPINBADCOMMUNITYNAMES 12
#define SNMPINBADCOMMUNITYUSES  16
#define SNMPINASNPARSEERRS      20
#define SNMPINTOOBIGS           24
#define SNMPINNOSUCHNAMES       28
#define SNMPINBADVALUES         32
#define SNMPINREADONLYS         36
#define SNMPINGENERRS           40
#define SNMPINTOTALREQVARS      44
#define SNMPINTOTALSETVARS      48
#define SNMPINGETREQUESTS       52
#define SNMPINGETNEXTS          56
#define SNMPINSETREQUESTS       60
#define SNMPINGETRESPONSES      64
#define SNMPINTRAPS             68
#define SNMPOUTTOOBIGS          72
#define SNMPOUTNOSUCHNAMES      76
#define SNMPOUTBADVALUES        80
#define SNMPOUTGENERRS          84
#define SNMPOUTGETREQUESTS      88
#define SNMPOUTGETNEXTS         92
#define SNMPOUTSETREQUESTS      96
#define SNMPOUTGETRESPONSES     100
#define SNMPOUTTRAPS            104
#define SNMPENABLEAUTHTRAPS     108

/* RN added rip support */

#define RIP2GLOBALROUTECHANGES  0
#define RIP2GLOBALQUERIES       1


#define RIP2IFSTATADDRESS       0
#define RIP2IFSTATRCVBADPACKETS 1
#define RIP2IFSTATRCVBADROUTES  2
#define RIP2IFSTATSENTUPDATES   3
#define RIP2IFSTATSTATUS        4


#define RIP2IFCONFADDRESS       0
#define RIP2IFCONFDOMAIN        1
#define RIP2IFCONFAUTHTYPE      2
#define RIP2IFCONFAUTHKEY       3
#define RIP2IFCONFSEND          4
#define RIP2IFCONFRECEIVE       5
#define RIP2IFCONFDEFAULTMETRIC 6
#define RIP2IFCONFSTATUS        7
#define RIP2IFCONFSOURCE        8


#define RIP2PEERADDRESS         0
#define RIP2PEERDOMAIN          1
#define RIP2PEERLASTUPDATE      2
#define RIP2PEERVERSION         3
#define RIP2PEERRCVBADPACKETS   4
#define RIP2PEERRCVBADROUTES    5
#endif /* 0 */

/* RN added ospf support */

/**********************************
#define OSPFROUTERID            0
#define OSPFADMINSTAT           1
#define OSPFVERSIONNUMBER       2
#define OSPFAREABDRRTRSTATUS    3
#define OSPFASBDRRTRSTATUS      4
#define OSPFEXTERNLSACOUNT      5
#define OSPFEXTERNLSACKSUMSUM   6
#define OSPFTOSSUPPORT          7
#define OSPFORIGINATENEWLSAS    8
#define OSPFRXNEWLSAS           9


#define OSPFAREAID              0
#define OSPFAUTHTYPE            1
#define OSPFIMPORTASEXTERN      2
#define OSPFSPFRUNS             3
#define OSPFAREABDRRTRCOUNT     4
#define OSPFASBDRRTRCOUNT       5
#define OSPFAREALSACOUNT        6
#define OSPFAREALSACKSUMSUM     7


#define OSPFSTUBAREAID          0
#define OSPFSTUBTOS             1
#define OSPFSTUBMETRIC          2
#define OSPFSTUBSTATUS          3


#define OSPFLSDBAREAID          0
#define OSPFLSDBTYPE            1
#define OSPFLSDBLSID            2
#define OSPFLSDBROUTERID        3
#define OSPFLSDBSEQUENCE        4
#define OSPFLSDBAGE             5
#define OSPFLSDBCHECKSUM        6
#define OSPFLSDBADVERTISEMENT   7


#define OSPFAREARANGEAREAID     0
#define OSPFAREARANGENET        1
#define OSPFAREARANGEMASK       2
#define OSPFAREARANGESTATUS     3


#define OSPFHOSTIPADDRESS       0
#define OSPFHOSTTOS             1
#define OSPFHOSTMETRIC          2
#define OSPFHOSTSTATUS          3


#define OSPFIFIPADDRESS         0
#define OSPFADDRESSLESSIF       1
#define OSPFIFAREAID            2
#define OSPFIFTYPE              3
#define OSPFIFADMINSTAT         4
#define OSPFIFRTRPRIORITY       5
#define OSPFIFTRANSITDELAY      6
#define OSPFIFRETRANSINTERVAL   7
#define OSPFIFHELLOINTERVAL     8
#define OSPFIFRTRDEADINTERVAL   9
#define OSPFIFPOLLINTERVAL      10
#define OSPFIFSTATE             11
#define OSPFIFDESIGNATEDROUTER  12
#define OSPFIFBACKUPDESIGNATEDROUTER 13
#define OSPFIFEVENTS            14
#define OSPFIFAUTHKEY           15


#define OSPFIFMETRICIPADDRESS       0
#define OSPFIFMETRICADDRESSLESSIF   1
#define OSPFIFMETRICTOS             2
#define OSPFIFMETRICMETRIC          3
#define OSPFIFMETRICSTATUS          4


#define OSPFVIRTIFAREAID            0
#define OSPFVIRTIFNEIGHBOR          1
#define OSPFVIRTIFTRANSITDELAY      2
#define OSPFVIRTIFRETRANSINTERVAL   3
#define OSPFVIRTIFHELLOINTERVAL     4
#define OSPFVIRTIFRTRDEADINTERVAL   5
#define OSPFVIRTIFSTATE             6
#define OSPFVIRTIFEVENTS            7
#define OSPFVIRTIFAUTHKEY           8
#define OSPFVIRTIFSTATUS            9


#define OSPFNBRIPADDR           0
#define OSPFNBRADDRESSLESSINDEX 1
#define OSPFNBRRTRID            2
#define OSPFNBROPTIONS          3
#define OSPFNBRPRIORITY         4
#define OSPFNBRSTATE            5
#define OSPFNBREVENTS           6
#define OSPFNBRLSRETRANSQLEN    7
#define OSPFNBMANBRSTATUS       8


#define OSPFVIRTNBRAREA         0
#define OSPFVIRTNBRRTRID        1
#define OSPFVIRTNBRIPADDR       2
#define OSPFVIRTNBROPTIONS      3
#define OSPFVIRTNBRSTATE        4
#define OSPFVIRTNBREVENTS       5
#define OSPFVIRTNBRLSRETRANSQLEN 6
**************************************/

#if 0
#define SNMPENGINEID            1
#define SNMPENGINEBOOTS         2
#define SNMPENGINETIME          3
#define SNMPENGINEMAXMSGSIZE    4

#define USMUNSUPPORTEDSECLEVELS 1
#define USMNOTINTIMEWINDOWS     2
#define USMUNKNOWNUSERNAMES     3
#define USMUNKNOWNENGINEIDS     4
#define USMWRONGDIGESTS         5
#define USMDECRYPTIONERRORS     6

#define USMUSERSPINLOCK         7

#define USERENGINEID            1
#define USERNAME                2
#define USERSECURITYNAME        3
#define USERCLONEFROM           4
#define USERAUTHPROTOCOL        5
#define USERAUTHKEYCHANGE       6
#define USEROWNAUTHKEYCHANGE    7
#define USERPRIVPROTOCOL        8
#define USERPRIVKEYCHANGE       9
#define USEROWNPRIVKEYCHANGE    10
#define USERPUBLIC              11
#define USERSTORAGETYPE         12
#define USERSTATUS              13

#define VACMCONTEXTNAME     1

#define VACMS2GGROUPNAME        1
#define VACMS2GSTORAGETYPE      2
#define VACMS2GSTATUS           3

#define VACMACCCONTEXTMATCH     1
#define VACMACCREADVIEWNAME     2
#define VACMACCWRITEVIEWNAME        3
#define VACMACCNOTFVIEWNAME     4
#define VACMACCSTORAGETYPE      5
#define VACMACCSTATUS           6

#define VACMVIEWSPINLOCK        1

#define VACMVIEWFAMILYMASK      1
#define VACMVIEWFAMILYTYPE      2
#define VACMVFSTORAGETYPE       3
#define VACMVFSTATUS            4
#endif /* 0 */
#ifdef __cplusplus
}
#endif

#endif /* _SNMPVARS_ */


