1DEFAULT_STORE(3)                   Net-SNMP                   DEFAULT_STORE(3)
2
3
4

NAME

6       default_store - generic storage of global data.
7

SYNOPSIS

9       #include <net-snmp/net-snmp-config.h>
10       #include <net-snmp/config_api.h>
11
12       int netsnmp_ds_set_boolean(int store, int which, int val);
13       int netsnmp_ds_get_boolean(int store, int which);
14       int netsnmp_ds_set_int(int store, int which, int val);
15       int netsnmp_ds_get_int(int store, int which);
16       int netsnmp_ds_set_string(int store, int which,
17                                 const char *val);
18       char *netsnmp_ds_get_string(int store, int which);
19       int netsnmp_ds_register_config(u_char type,
20                                      const char *ftype,
21                                      const char *token,
22                                      int store, int which);
23       int netsnmp_ds_register_premib(u_char type,
24                                      const char *ftype,
25                                      const char *token,
26                                      int store, int which);
27       void netsnmp_ds_shutdown(void);
28

DESCRIPTION

30       The purpose of the default storage is three-fold:
31
32       1)     To  create a global storage space without creating a whole bunch
33              of globally accessible variables or  a  whole  bunch  of  access
34              functions to work with more privately restricted variables.
35
36       2)     To  provide  a single location where the thread locking needs to
37              be implemented. At the time of  this  writing,  however,  thread
38              locking is not yet in place.
39
40       3)     To  reduce  the number of cross dependencies between code pieces
41              that may or may not be linked together in  the  long  run.  This
42              provides  for a single location in which configuration data, for
43              example, can be stored for a separate section of code  that  may
44              not be linked in to the application in question.
45
46       The functions defined here implement these goals.
47
48       Currently,  three  data  types  are  supported: booleans, integers, and
49       strings. Each of these data types have separate storage spaces. In  ad‐
50       dition,  the storage space for each data type is divided further by the
51       application level.   Currently, there are two storage spaces. The first
52       is reserved for the SNMP library itself. The second is intended for use
53       in applications and is not modified or checked  by  the  library,  and,
54       therefore, this is the space usable by you.
55
56       You can think of these storage spaces as being 3 arrays, something like
57       bool_storage[storeid][which],     int_storage[storeid][which],      and
58       string_storage[storeid][which].   The data is then accessed through the
59       functions defined below.  For data you wish to store, you should use  a
60       store parameter of NETSNMP_DS_APPLICATION_ID.
61
62       The storage space used by the library (for which the store parameter is
63       NETSNMP_DS_LIBRARY_ID) is defined in the  default_store.h  file,  which
64       currently contains the following defines:
65
66            */
67       /**
68        * @def NETSNMP_DS_LIBRARY_ID
69        * These definitions correspond with the "storid" argument to the API.
70        */
71       #define NETSNMP_DS_LIBRARY_ID     0
72       #define NETSNMP_DS_APPLICATION_ID 1
73       #define NETSNMP_DS_TOKEN_ID       2
74
75           /*
76            * These definitions correspond with the "which" argument to the API,
77            * when the storeid argument is NETSNMP_DS_LIBRARY_ID
78            */
79           /*
80            * library booleans
81            */
82       #define NETSNMP_DS_LIB_MIB_ERRORS          0
83       #define NETSNMP_DS_LIB_SAVE_MIB_DESCRS     1
84       #define NETSNMP_DS_LIB_MIB_COMMENT_TERM    2
85       #define NETSNMP_DS_LIB_MIB_PARSE_LABEL     3
86       #define NETSNMP_DS_LIB_DUMP_PACKET         4
87       #define NETSNMP_DS_LIB_LOG_TIMESTAMP       5
88       #define NETSNMP_DS_LIB_DONT_READ_CONFIGS   6    /* don't read normal config files */
89       #define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD      NETSNMP_DS_LIB_DONT_READ_CONFIGS
90       #define NETSNMP_DS_LIB_MIB_REPLACE         7    /* replace objects from latest module */
91       #define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM  8    /* print only numeric enum values */
92       #define NETSNMP_DS_LIB_PRINT_NUMERIC_OIDS  9    /* print only numeric enum values */
93       #define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10   /* dont print oid indexes specially */
94       #define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG  11   /* don't use the alarm() signal */
95       #define NETSNMP_DS_LIB_PRINT_FULL_OID      12   /* print fully qualified oids */
96       #define NETSNMP_DS_LIB_QUICK_PRINT         13   /* print very brief output for parsing */
97       #define NETSNMP_DS_LIB_RANDOM_ACCESS       14   /* random access to oid labels */
98       #define NETSNMP_DS_LIB_REGEX_ACCESS        15   /* regex matching to oid labels */
99       #define NETSNMP_DS_LIB_DONT_CHECK_RANGE    16   /* don't check values for ranges on send */
100       #define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS   17   /* no warn about unknown config tokens */
101       #define NETSNMP_DS_LIB_NUMERIC_TIMETICKS   18   /* print timeticks as a number */
102       #define NETSNMP_DS_LIB_ESCAPE_QUOTES       19   /* shell escape quote marks in oids */
103       #define NETSNMP_DS_LIB_REVERSE_ENCODE      20   /* encode packets from back to front */
104       #define NETSNMP_DS_LIB_PRINT_BARE_VALUE    21   /* just print value (not OID = value) */
105       #define NETSNMP_DS_LIB_EXTENDED_INDEX      22   /* print extended index format [x1][x2] */
106       #define NETSNMP_DS_LIB_PRINT_HEX_TEXT      23   /* print ASCII text along with hex strings */
107       #define NETSNMP_DS_LIB_PRINT_UCD_STYLE_OID 24   /* print OID's using the UCD-style prefix suppression */
108       #define NETSNMP_DS_LIB_READ_UCD_STYLE_OID  25   /* require top-level OIDs to be prefixed with a dot */
109       #define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26       /* have the pre-mib parsing config tokens been processed */
110       #define NETSNMP_DS_LIB_HAVE_READ_CONFIG    27   /* have the config tokens been processed */
111       #define NETSNMP_DS_LIB_QUICKE_PRINT        28
112       #define NETSNMP_DS_LIB_DONT_PRINT_UNITS    29 /* don't print UNITS suffix */
113       #define NETSNMP_DS_LIB_NO_DISPLAY_HINT     30 /* don't apply DISPLAY-HINTs */
114       #define NETSNMP_DS_LIB_16BIT_IDS           31   /* restrict requestIDs, etc to 16-bit values */
115       #define NETSNMP_DS_LIB_DONT_PERSIST_STATE  32     /* don't load config and don't load/save persistent file */
116       #define NETSNMP_DS_LIB_2DIGIT_HEX_OUTPUT   33     /* print a leading 0 on hex values <= 'f' */
117       #define NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY 34     /* don't complain if no community is specified in the command arguments */
118       #define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD  35 /* don't load persistent file */
119       #define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE  36 /* don't save persistent file */
120       #define NETSNMP_DS_LIB_APPEND_LOGFILES     37 /* append, don't overwrite, log files */
121       #define NETSNMP_DS_LIB_NO_DISCOVERY        38 /* don't support RFC5343 contextEngineID discovery */
122       #define NETSNMP_DS_LIB_TSM_USE_PREFIX      39 /* TSM's simple security name mapping */
123       #define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */
124       #define NETSNMP_DS_LIB_DNSSEC_WARN_ONLY     41 /* tread DNSSEC errors as warnings */
125       #define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */
126       #define NETSNMP_DS_LIB_DISABLE_V1          43 /* disable SNMPv1 */
127       #define NETSNMP_DS_LIB_DISABLE_V2c         44 /* disable SNMPv2c */
128       #define NETSNMP_DS_LIB_DISABLE_V3          45 /* disable SNMPv3 */
129       #define NETSNMP_DS_LIB_FILTER_SOURCE       46 /* filter pkt by source IP */
130       #define NETSNMP_DS_LIB_ADD_FORWARDER_INFO  47 /* add info about forwarder to SNMP packets */
131       #define NETSNMP_DS_LIB_MAX_BOOL_ID         48 /* match NETSNMP_DS_MAX_SUBIDS */
132
133           /*
134            * library integers
135            */
136       #define NETSNMP_DS_LIB_MIB_WARNINGS         0
137       #define NETSNMP_DS_LIB_SECLEVEL             1
138       #define NETSNMP_DS_LIB_SNMPVERSION          2
139       #define NETSNMP_DS_LIB_DEFAULT_PORT         3
140       #define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT    4
141       #define NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY    NETSNMP_DS_LIB_OID_OUTPUT_FORMAT
142       #define NETSNMP_DS_LIB_STRING_OUTPUT_FORMAT 5
143       #define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH    6
144       #define NETSNMP_DS_LIB_SERVERSENDBUF        7 /* send buffer (server) */
145       #define NETSNMP_DS_LIB_SERVERRECVBUF        8 /* receive buffer (server) */
146       #define NETSNMP_DS_LIB_CLIENTSENDBUF        9 /* send buffer (client) */
147       #define NETSNMP_DS_LIB_CLIENTRECVBUF       10 /* receive buffer (client) */
148       #define NETSNMP_DS_SSHDOMAIN_SOCK_PERM     11
149       #define NETSNMP_DS_SSHDOMAIN_DIR_PERM      12
150       #define NETSNMP_DS_SSHDOMAIN_SOCK_USER     12
151       #define NETSNMP_DS_SSHDOMAIN_SOCK_GROUP    13
152       #define NETSNMP_DS_LIB_TIMEOUT             14
153       #define NETSNMP_DS_LIB_RETRIES             15
154       #define NETSNMP_DS_LIB_MSG_SEND_MAX        16 /* global max response size */
155       #define NETSNMP_DS_LIB_FILTER_TYPE         17 /* 0=NONE, 1=acceptlist, -1=blocklist */
156       #define NETSNMP_DS_LIB_MAX_INT_ID          48 /* match NETSNMP_DS_MAX_SUBIDS */
157
158           /*
159            * special meanings for the default SNMP version slot (NETSNMP_DS_LIB_SNMPVERSION)
160            */
161       #ifndef NETSNMP_DISABLE_SNMPV1
162       #define NETSNMP_DS_SNMP_VERSION_1    128        /* bogus */
163       #endif
164       #ifndef NETSNMP_DISABLE_SNMPV2C
165       #define NETSNMP_DS_SNMP_VERSION_2c   1  /* real */
166       #endif
167       #define NETSNMP_DS_SNMP_VERSION_3    3  /* real */
168
169
170           /*
171            * library strings
172            */
173       #define NETSNMP_DS_LIB_SECNAME           0
174       #define NETSNMP_DS_LIB_CONTEXT           1
175       #define NETSNMP_DS_LIB_PASSPHRASE        2
176       #define NETSNMP_DS_LIB_AUTHPASSPHRASE    3
177       #define NETSNMP_DS_LIB_PRIVPASSPHRASE    4
178       #define NETSNMP_DS_LIB_OPTIONALCONFIG    5
179       #define NETSNMP_DS_LIB_APPTYPE           6
180       #define NETSNMP_DS_LIB_COMMUNITY         7
181       #define NETSNMP_DS_LIB_PERSISTENT_DIR    8
182       #define NETSNMP_DS_LIB_CONFIGURATION_DIR 9
183       #define NETSNMP_DS_LIB_SECMODEL          10
184       #define NETSNMP_DS_LIB_MIBDIRS           11
185       #define NETSNMP_DS_LIB_OIDSUFFIX         12
186       #define NETSNMP_DS_LIB_OIDPREFIX         13
187       #define NETSNMP_DS_LIB_CLIENT_ADDR       14
188       #define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15
189       #define NETSNMP_DS_LIB_AUTHMASTERKEY     16
190       #define NETSNMP_DS_LIB_PRIVMASTERKEY     17
191       #define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY  18
192       #define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY  19
193       #define NETSNMP_DS_LIB_APPTYPES          20
194       #define NETSNMP_DS_LIB_KSM_KEYTAB        21
195       #define NETSNMP_DS_LIB_KSM_SERVICE_NAME  22
196       #define NETSNMP_DS_LIB_X509_CLIENT_PUB   23
197       #define NETSNMP_DS_LIB_X509_SERVER_PUB   24
198       #define NETSNMP_DS_LIB_SSHTOSNMP_SOCKET  25
199       #define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26
200       #define NETSNMP_DS_LIB_HOSTNAME          27
201       #define NETSNMP_DS_LIB_X509_CRL_FILE     28
202       #define NETSNMP_DS_LIB_TLS_ALGORITMS     29
203       #define NETSNMP_DS_LIB_TLS_LOCAL_CERT    30
204       #define NETSNMP_DS_LIB_TLS_PEER_CERT     31
205       #define NETSNMP_DS_LIB_SSH_USERNAME      32
206       #define NETSNMP_DS_LIB_SSH_PUBKEY        33
207       #define NETSNMP_DS_LIB_SSH_PRIVKEY       34
208       #define NETSNMP_DS_LIB_OUTPUT_PRECISION  35
209       #define NETSNMP_DS_LIB_MAX_STR_ID        48 /* match NETSNMP_DS_MAX_SUBIDS */
210
211           /*
212

FUNCTIONS

214       int netsnmp_ds_set_boolean(int store, int which, int val);
215              Stores  TRUE  if  val  !=  0  or  else FALSE into the bool_stor‐
216              age[store][which] slot.  Returns SNMPERR_GENERR if the store and
217              which  parameters  do  not  correspond  to a valid slot, or SNM‐
218              PERR_SUCCESS otherwise.
219
220       int netsnmp_ds_get_boolean(int store, int which);
221              Returns 1 if bool_storage[store][which] is TRUE  or  0  if  not.
222              May also return SNMPERR_GENERR if the store and which parameters
223              do not correspond to a valid slot.
224
225       int netsnmp_ds_set_string(int store, int which, const char *val);
226              Stores val into the string_storage[store][which] slot.   Returns
227              SNMPERR_SUCCESS  normally,  or  SNMPERR_GENERR  if the store and
228              which parameters do not correspond to a valid slot.
229
230       char *netsnmp_ds_get_string(int store, int which);
231              Returns the string which has been  stored  in  the  string_stor‐
232              age[store][which]  slot,  or NULL if the store and which parame‐
233              ters do not correspond to a valid slot.
234
235       netsnmp_ds_set_int(int store, int which, int val);
236              Stores val into the int_storage[store][which] slot.  Returns SN‐
237              MPERR_GENERR if the store and which parameters do not correspond
238              to a valid slot, or SNMPERR_SUCCESS otherwise.
239
240       int netsnmp_ds_get_int(int store, int which);
241              Returns the integer which  has  been  stored  in  the  int_stor‐
242              age[store][which] slot, or SNMPERR_GENERR if the store and which
243              parameters do not correspond to a valid slot.
244
245       void netsnmp_ds_shutdown(void);
246              Reclaims memory  used  to  hold  information  gathered  by  net‐
247              snmp_ds_register_config and netsnmp_ds_register_premib.
248
249       int  netsnmp_ds_register_config(u_char  type,  const char *ftype, const
250       char *token, int store, int which);
251              Registers a configuration file directive token and  attaches  it
252              to  a  default  storage  type and slot.  Specifically, store and
253              which indicate the storage slot in the data  type  indicated  by
254              type, where type is one of the following constants: ASN_BOOLEAN,
255              ASN_INTEGER, or ASN_OCTET_STR.  The ftype variable indicates the
256              file name base string searched for the token keyword.  For exam‐
257              ple, the following call:
258
259                     netsnmp_ds_register_config(ASN_INTEGER, "snmp",  "testto‐
260                     ken", DS_APPLICATION_ID, 5)
261
262              would  indicate  that  when the snmp.conf file(s) were found and
263              parsed, that any line beginning with the word "testtoken" should
264              be  read  and  the value after "testtoken" should be stored into
265              the int_storage[DS_APPLICATION_ID][5]  slot.   For  example  the
266              following line in the configuration file:
267
268                     testtoken 502
269
270              would  set  int_storage[DS_APPLICATION_ID][5] = 502.  This func‐
271              tion returns SNMPERR_SUCCESS if the registration was  made  suc‐
272              cessfully,  or  SNMPERR_GENERR  if the registration was not made
273              (perhaps because the store and which parameters  do  not  corre‐
274              spond  to  a valid slot, or because of a memory allocation fail‐
275              ure).
276
277       int netsnmp_ds_register_premib(u_char type, const  char  *ftype,  const
278       char *token, int store, int which);
279              Analogous  to the preceding function, but the token is processed
280              before MIBs are read (this is therefore useful  for  controlling
281              MIB processing options).
282

SEE ALSO

284       snmp_config(5), netsnmp_config_api(3)
285
286
287
288
289V5.9.3                            25 Jun 2002                 DEFAULT_STORE(3)
Impressum