MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
DEFAULTSTORE(3)                   Net-SNMP                   DEFAULTSTORE(3)



NAME
       defaultstore - generic storage of global data.

SYNOPSIS
       ##include <>
       ##include <>

       int netsnmpdssetboolean(int store,, int which,, int val);;
       int netsnmpdsgetboolean(int store,, int which);;
       int netsnmpdssetint(int store,, int which,, int val);;
       int netsnmpdsgetint(int store,, int which);;
       int netsnmpdssetstring(int store,, int which,,
                                 const char **val);;
       char **netsnmpdsgetstring(int store,, int which);;
       int netsnmpdsregisterconfig(uchar type,,
                                      const char **ftype,,
                                      const char **token,,
                                      int store,, int which);;
       int netsnmpdsregisterpremib(uchar type,,
                                      const char **ftype,,
                                      const char **token,,
                                      int store,, int which);;
       void netsnmpdsshutdown(void);;

DESCRIPTION
       The purpose of the default storage is three-fold:

       1)     To  create a global storage space without creating a whole bunch
              of globally accessible variables or  a  whole  bunch  of  access
              functions to work with more privately restricted variables.

       2)     To  provide  a single location where the thread locking needs to
              be implemented. At the time of  this  writing,  however,  thread
              locking is not yet in place.

       3)     To  reduce  the number of cross dependencies between code pieces
              that may or may not be linked together in  the  long  run.  This
              provides  for a single location in which configuration data, for
              example, can be stored for a separate section of code  that  may
              not be linked in to the application in question.

       The functions defined here implement these goals.

       Currently,  three  data  types  are  supported: booleans, integers, and
       strings. Each of these data types  have  separate  storage  spaces.  In
       addition,  the  storage  space for each data type is divided further by
       the application level.   Currently, there are two storage  spaces.  The
       first  is  reserved for the SNMP library itself. The second is intended
       for use in applications and is not modified or checked by the  library,
       and, therefore, this is the space usable by you.

       You can think of these storage spaces as being 3 arrays, something like
       boolstorage[storeid][which],     intstorage[storeid][which],      and
       stringstorage[storeid][which].   The data is then accessed through the
       functions defined below.  For data you wish to store, you should use  a
       store parameter of NETSNMPDSAPLICATIONID.

       The storage space used by the library (for which the store parameter is
       NETSNMPDSLIBRARYID) is defined in the  defaultstore.h  file,  which
       currently contains the following defines:

            */
       /**
        * @def NETSNMPDSLIBRARYID These definitions correspond with the "storid" argument to the API
        */
       #define NETSNMPDSLIBRARYID     0
       #define NETSNMPDSAPLICATIONID 1
       #define NETSNMPDSTOKENID       2

           /*
            * These definitions correspond with the "which" argument to the API,
            * when the storeid argument is NETSNMPDSLIBRARYID
            */
           /*
            * library booleans
            */
       #define NETSNMPDSLIBMIBERORS          0
       #define NETSNMPDSLIBSAVEMIBDESCRS     1
       #define NETSNMPDSLIBMIBCOMENTERM    2
       #define NETSNMPDSLIBMIBPARSELABEL     3
       #define NETSNMPDSLIBDUMPACKET         4
       #define NETSNMPDSLIBLOGTIMESTAMP       5
       #define NETSNMPDSLIBDONTREADCONFIGS   6
       #define NETSNMPDSLIBMIBREPLACE         7    /* replace objects from latest module */
       #define NETSNMPDSLIBPRINTNUMERICENUM  8    /* print only numeric enum values */
       #define NETSNMPDSLIBPRINTNUMERICOIDS  9    /* print only numeric enum values */
       #define NETSNMPDSLIBDONTBREAKDOWNOIDS 10   /* dont print oid indexes specially */
       #define NETSNMPDSLIBALARMDONTUSESIG  11   /* don't use the alarm() signal */
       #define NETSNMPDSLIBPRINTFULOID      12   /* print fully qualified oids */
       #define NETSNMPDSLIBQUICKPRINT         13   /* print very brief output for parsing */
       #define NETSNMPDSLIBRANDOMACES       14   /* random access to oid labels */
       #define NETSNMPDSLIBREGEXACES        15   /* regex matching to oid labels */
       #define NETSNMPDSLIBDONTCHECKRANGE    16   /* don't check values for ranges on send */
       #define NETSNMPDSLIBNOTOKENWARNINGS   17   /* no warn about unknown config tokens */
       #define NETSNMPDSLIBNUMERICTIMETICKS   18   /* print timeticks as a number */
       #define NETSNMPDSLIBESCAPEQUOTES       19   /* shell escape quote marks in oids */
       #define NETSNMPDSLIBREVERSENCODE      20   /* encode packets from back to front */
       #define NETSNMPDSLIBPRINTBAREVALUE    21   /* just print value (not OID = value) */
       #define NETSNMPDSLIBEXTENDEDINDEX      22   /* print extended index format [x1][x2] */
       #define NETSNMPDSLIBPRINTHEXTEXT      23   /* print ASCI text along with hex strings */
       #define NETSNMPDSLIBPRINTUCDSTYLEOID 24   /* print OID's using the UCD-style prefix suppression */
       #define NETSNMPDSLIBREADUCDSTYLEOID  25   /* require top-level OIDs to be prefixed with a dot */
       #define NETSNMPDSLIBHAVEREADPREMIBCONFIG 26       /* have the pre-mib parsing config tokens been processed */
       #define NETSNMPDSLIBHAVEREADCONFIG    27   /* have the config tokens been processed */
       #define NETSNMPDSLIBQUICKEPRINT        28
       #define NETSNMPDSLIBDONTPRINTUNITS    29 /* don't print UNITS suffix */
       #define NETSNMPDSLIBNODISPLAYHINT     30 /* don't apply DISPLAY-HINTs */
       #define NETSNMPDSLIB16BITIDS           31   /* restrict requestIDs, etc to 16-bit values */
       #define NETSNMPDSLIBDONTPERSISTSTATE  32     /* don't save/load any persistant state */
       #define NETSNMPDSLIB2DIGITHEXOUTPUT   33     /* print a leading 0 on hex values <= 'f' */
       #define NETSNMPDSLIBIGNORENOCOMUNITY 34     /* don't complain if not community is specified in the command arguments */

           /*
            * library integers
            */
       #define NETSNMPDSLIBMIBWARNINGS  0
       #define NETSNMPDSLIBSECLEVEL      1
       #define NETSNMPDSLIBSNMPVERSION   2
       #define NETSNMPDSLIBDEFAULTPORT  3
       #define NETSNMPDSLIBOIDOUTPUTFORMAT  4
       #define NETSNMPDSLIBPRINTSUFIXONLY  NETSNMPDSLIBOIDOUTPUTFORMAT
       #define NETSNMPDSLIBSTRINGOUTPUTFORMAT 5
       #define NETSNMPDSLIBHEXOUTPUTLENGTH 6
       #define NETSNMPDSLIBSERVERSENDBUF   7 /* send buffer (server) */
       #define NETSNMPDSLIBSERVERECVBUF   8 /* receive buffer (server) */
       #define NETSNMPDSLIBCLIENTSENDBUF   9 /* send buffer (client) */
       #define NETSNMPDSLIBCLIENTRECVBUF  10 /* receive buffer (client) */

           /*
            * special meanings for the default SNMP version slot (NETSNMPDSLIBSNMPVERSION)
            */
       #ifndef DISABLESNMPV1
       #define NETSNMPDSNMPVERSION1    128        /* bogus */
       #endif
       #ifndef DISABLESNMPV2C
       #define NETSNMPDSNMPVERSION2c   1  /* real */
       #endif
       #define NETSNMPDSNMPVERSION3    3  /* real */


           /*
            * library strings
            */
       #define NETSNMPDSLIBSECNAME           0
       #define NETSNMPDSLIBCONTEXT           1
       #define NETSNMPDSLIBPASPHRASE        2
       #define NETSNMPDSLIBAUTHPASPHRASE    3
       #define NETSNMPDSLIBPRIVPASPHRASE    4
       #define NETSNMPDSLIBOPTIONALCONFIG    5
       #define NETSNMPDSLIBAPTYPE           6
       #define NETSNMPDSLIBCOMUNITY         7
       #define NETSNMPDSLIBPERSISTENTDIR    8
       #define NETSNMPDSLIBCONFIGURATIONDIR 9
       #define NETSNMPDSLIBSECMODEL          10
       #define NETSNMPDSLIBMIBDIRS           11
       #define NETSNMPDSLIBOIDSUFIX         12
       #define NETSNMPDSLIBOIDPREFIX         13
       #define NETSNMPDSLIBCLIENTADR       14
       #define NETSNMPDSLIBTEMPFILEPATERN 15
       #define NETSNMPDSLIBAUTHMASTERKEY     16
       #define NETSNMPDSLIBPRIVMASTERKEY     17
       #define NETSNMPDSLIBAUTHLOCALIZEDKEY  18
       #define NETSNMPDSLIBPRIVLOCALIZEDKEY  19
       #define NETSNMPDSLIBAPTYPES          20
       #define NETSNMPDSLIBKSMKEYTAB        21
       #define NETSNMPDSLIBKSMSERVICENAME  22

           /*

FUNCTIONS
       int netsnmpdssetboolean(int store,, int which,, int val);;
              Stores  TRUE  if  val  !=  0  or  else FALSE into the boolstor-
              age[store][which] slot.  Returns SNMPERGENER if the store and
              which  parameters  do  not  correspond  to a valid slot, or SN-
              PERSUCES otherwise.

       int netsnmpdsgetboolean(int store,, int which);;
              Returns 1 if boolstorage[store][which] is TRUE  or  0  if  not.
              May also return SNMPERGENER if the store and which parameters
              do not correspond to a valid slot.

       int netsnmpdssetstring(int store,, int which,, const char **val);;
              Stores val into the stringstorage[store][which] slot.   Returns
              SNMPERSUCES  normally,  or  SNMPERGENER  if the store and
              which parameters do not correspond to a valid slot.

       char **netsnmpdsgetstring(int store,, int which);;
              Returns the string which has been  stored  in  the  stringstor-
              age[store][which]  slot,  or NUL if the store and which parame-
              ters do not correspond to a valid slot.

       netsnmpdssetint(int store,, int which,, int val);;
              Stores val into  the  intstorage[store][which]  slot.   Returns
              SNMPERGENER  if  the store and which parameters do not corre-
              spond to a valid slot, or SNMPERSUCES otherwise.

       int netsnmpdsgetint(int store,, int which);;
              Returns the integer which  has  been  stored  in  the  intstor-
              age[store][which] slot, or SNMPERGENER if the store and which
              parameters do not correspond to a valid slot.

       void netsnmpdsshutdown(void);;
              Reclaims memory  used  to  hold  information  gathered  by  net-
              snmpdsregisterconfig and netsnmpdsregisterpremib.

       int  netsnmpdsregisterconfig(uchar  type,,  const char **ftype,, const
       char **token,, int store,, int which);;
              Registers  a  configuration file directive token and attaches it
              to a default storage type and  slot.   Specifically,  store  and
              which  indicate  the  storage slot in the data type indicated by
              type, where type is one of the following constants: ASNBOLEAN,
              ASNINTEGER, or ASNOCTETSTR.  The ftype variable indicates the
              file name base string searched for the token keyword.  For exam-
              ple, the following call:

                     netsnmpdsregisterconfig(ASNINTEGER,  "snmp", "testto-
                     ken", DSAPLICATIONID, 5)

              would indicate that when the snmp.conf file(s)  were  found  and
              parsed, that any line beginning with the word "testtoken" should
              be read and the value after "testtoken" should  be  stored  into
              the  intstorage[DSAPLICATIONID][5]  slot.   For  example the
              following line in the configuration file:

                     testtoken 502

              would set intstorage[DSAPLICATIONID][5] = 502.   This  func-
              tion  returns  SNMPERSUCES if the registration was made suc-
              cessfully, or SNMPERGENER if the registration  was  not  made
              (perhaps  because  the  store and which parameters do not corre-
              spond to a valid slot, or because of a memory  allocation  fail-
              ure).

       int  netsnmpdsregisterpremib(uchar  type,,  const char **ftype,, const
       char **token,, int store,, int which);;
              Analogous to the preceeding function, but the token is processed
              before MIBs are read (this is therefore useful  for  controlling
              MIB processing options).

SEE ALSO
       snmpconfig(5), readconfig(3)




4.2 Berkeley Distribution         25 Jun 2002                 DEFAULTSTORE(3)
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™