1 .TH SNMP_AGENT_API 3 "27 Oct 1999"
4 default_store \- generic storage of global data.
7 #include <ucd-snmp/ucd-snmp-config.h>
8 #include <ucd-snmp/ucd-snmp-includes.h>
10 int ds_set_boolean(int storeid, int which, int value);
11 int ds_get_boolean(int storeid, int which);
12 int ds_set_int(int storeid, int which, int value);
13 int ds_get_int(int storeid, int which);
14 int ds_set_string(int storeid, int which, const char *value);
15 char *ds_get_string(int storeid, int which);
16 int ds_register_config(u_char type, const char *ftype, const char *token,
17 int storeid, int which);
18 int ds_register_premib(u_char type, const char *ftype, const char *token,
19 int storeid, int which);
20 void ds_shutdown(void);
23 The purpose of the default storage is three-fold:
25 To create a global storage space without creating a whole bunch of
26 globally accessible variables or a whole bunch of access functions to
27 work with more privately restricted variables.
29 To provide a single location where the thread locking needs to be
30 implemented. At the time of this writing, however, thread locking is not
33 To reduce the number of cross dependencies between code pieces that
34 may or may not be linked together in the long run. This provides for a
35 single location in which configuration data, for example, can be
36 stored for a separate section of code that may not be linked in to
37 the application in question.
39 The functions defined here implement these goals.
41 Currently, three data types are supported: boolean's, integers, and
42 strings. Each of based trade data types have separate storage
43 spaces. In addition, the storage space for each data type is divided
44 further by the application level. Currently, there are two storage
45 spaces. The first is reserved for the SNMP library itself. The second
46 is intended for use in applications and is not modified or checked by
47 the library, and, therefore, this is the space usable by you.
49 You can think of these storage spaces as being 3 arrays, something
50 like bool_storage[storeid][which], int_storage[storeid][which], and
51 string_storage[storeid][which]. The data is then accessed through the
52 functions defined below. For data you wish to store, you should use a
53 storeid of DS_APPLICATION_ID.
55 The storage space used by the library is defined in the
56 default_store.h file, which currently contains the following defines:
59 /* These definitions correspond with the "storid" argument to the API */
60 #define DS_LIBRARY_ID 0
61 #define DS_APPLICATION_ID 1
64 /* These definitions correspond with the "which" argument to the API,
65 when the storeid argument is DS_LIBRARY_ID */
66 /* library booleans */
67 #define DS_LIB_MIB_ERRORS 0
68 #define DS_LIB_SAVE_MIB_DESCRS 1
69 #define DS_LIB_MIB_COMMENT_TERM 2
70 #define DS_LIB_MIB_PARSE_LABEL 3
71 #define DS_LIB_DUMP_PACKET 4
72 #define DS_LIB_LOG_TIMESTAMP 5
73 #define DS_LIB_DONT_READ_CONFIGS 6
74 #define DS_LIB_MIB_REPLACE 7 /* replace objects from latest module */
75 #define DS_LIB_PRINT_NUMERIC_ENUM 8 /* print only numeric enum values */
76 #define DS_LIB_PRINT_NUMERIC_OIDS 9 /* print only numeric enum values */
77 #define DS_LIB_DONT_BREAKDOWN_OIDS 10 /* dont print oid indexes specially */
78 #define DS_LIB_ALARM_DONT_USE_SIG 11 /* don't use the alarm() signal */
79 #define DS_LIB_PRINT_FULL_OID 12 /* print fully qualified oids */
80 #define DS_LIB_QUICK_PRINT 13 /* print very brief output for parsing */
81 #define DS_LIB_RANDOM_ACCESS 14 /* random access to oid labels */
82 #define DS_LIB_REGEX_ACCESS 15 /* regex matching to oid labels */
83 #define DS_LIB_DONT_CHECK_RANGE 16 /* don't check values for ranges on send*/
84 #define DS_LIB_NO_TOKEN_WARNINGS 17 /* no warn about unknown config tokens */
85 #define DS_LIB_NUMERIC_TIMETICKS 18 /* print timeticks as a number */
86 #define DS_LIB_ESCAPE_QUOTES 19 /* shell escape quote marks in oids */
87 #define DS_LIB_REVERSE_ENCODE 20 /* encode packets from back to front */
88 #define DS_LIB_PRINT_BARE_VALUE 21 /* just print value (not OID = value) */
89 #define DS_LIB_EXTENDED_INDEX 22 /* print extended index format [x1][x2] */
90 #define DS_LIB_PRINT_HEX_TEXT 23 /* print ASCII text along with hex strings */
92 /* library integers */
93 #define DS_LIB_MIB_WARNINGS 0
94 #define DS_LIB_SECLEVEL 1
95 #define DS_LIB_SNMPVERSION 2
96 #define DS_LIB_DEFAULT_PORT 3
97 #define DS_LIB_PRINT_SUFFIX_ONLY 4 /* print out only a single oid node == 1.
98 like #1 but supply mib module too == 2. */
100 /* library strings */
101 #define DS_LIB_SECNAME 0
102 #define DS_LIB_CONTEXT 1
103 #define DS_LIB_PASSPHRASE 2
104 #define DS_LIB_AUTHPASSPHRASE 3
105 #define DS_LIB_PRIVPASSPHRASE 4
106 #define DS_LIB_OPTIONALCONFIG 5
107 #define DS_LIB_APPTYPE 6
108 #define DS_LIB_COMMUNITY 7
109 #define DS_LIB_PERSISTENT_DIR 8
110 #define DS_LIB_CONFIGURATION_DIR 9
114 .IP "ds_set_boolean(int storeid, int which, int value)"
119 != 0 or else false into the bool_storage[storeid][which] slot.
120 .IP "int ds_get_boolean(int storeid, int which)"
121 Returns 1 if storage[storeid][which] is true, or 0 if false.
122 .IP "int ds_set_string(int storeid, int which, const char *value)"
125 into the string_storage[storeid][which] slot.
126 .IP "char *ds_get_string(int storeid, int which)"
127 Returns the string which has been stored in the
128 string_storage[storeid][which] slot.
129 .IP "ds_set_int(int storeid, int which, int value)"
132 into the int_storage[storeid][which] slot.
133 .IP "int ds_get_int(int storeid, int which)"
134 Returns the integer which has been stored in the
135 int_storage[storeid][which] slot.
136 .IP "void ds_shutdown(void)"
137 Reclaims memory used to hold information gathered by
138 ds_register_config and ds_register_premib.
139 .IP "ds_register_config(u_char type, const char *ftype, const char *token, int storeid, int which)"
140 This token registers a configuration file directive and attaches it to
141 a default storage type and slot. Specifically,
145 indicate the storage slot in the data type indicated by
149 is either one of the following constants: ASN_BOOLEAN, ASN_INTEGER, or
152 variable indicates the file name base string searched for the
154 keyword. For example, the following call:
157 ds_register_config(ASN_INTEGER, "snmp", "testtoken", DS_APPLICATION_ID, 5)
160 would indicate that when the snmp.conf file(s) were found and parsed,
161 that any line beginning with the word "testtoken" should be read and
162 the value after "testtoken" should be stored into the
163 int_storage[DS_APPLICATION_ID][5] slot. For example the following
164 line in the configuration file:
170 would set int_storage[DS_APPLICATION_ID][5] = 42.
172 snmp_config(5), read_config(3)