2 .\" Japanese Version Copyright (c) 2001 Yuichi SATO
3 .\" all rights reserved.
4 .\" Translated Mon Aug 20 07:04:42 JST 2001
5 .\" by Yuichi SATO <ysato@h4.dion.ne.jp>
7 .TH SNMP_AGENT_API 3 "27 Oct 1999"
11 .\"O default_store \- generic storage of global data.
12 default_store \- Âç°è¥Ç¡¼¥¿¤Î°ìÈÌŪ¤Ê³ÊǼ¾ì½ê
16 #include <ucd-snmp/ucd-snmp-config.h>
17 #include <ucd-snmp/ucd-snmp-includes.h>
19 int ds_set_boolean(int storeid, int which, int value);
20 int ds_get_boolean(int storeid, int which);
21 int ds_set_int(int storeid, int which, int value);
22 int ds_get_int(int storeid, int which);
23 int ds_set_string(int storeid, int which, const char *value);
24 char *ds_get_string(int storeid, int which);
25 int ds_register_config(u_char type, const char *ftype, const char *token,
26 int storeid, int which);
27 int ds_register_premib(u_char type, const char *ftype, const char *token,
28 int storeid, int which);
29 void ds_shutdown(void);
33 .\"O The purpose of the default storage is three-fold:
34 ¥Ç¥Õ¥©¥ë¥È¤Î¥Ç¡¼¥¿³ÊǼ¾ì½ê¤ÎÌÜŪ¤Ï¡¢¼¡¤Î 3 ¤Ä¤Ç¤¢¤ë:
36 .\"O To create a global storage space without creating a whole bunch of
37 .\"O globally accessible variables or a whole bunch of access functions to
38 .\"O work with more privately restricted variables.
39 Âç°èŪ¤Ë¥¢¥¯¥»¥¹¤Ç¤¤ëÊÑ¿ô¤ä
40 ¤â¤Ã¤È¸ø³«¤ÎÀ©¸Â¤µ¤ì¤¿ÊÑ¿ô¤Ë¥¢¥¯¥»¥¹¤¹¤ë´Ø¿ô·²¤òºîÀ®¤·¤¿¤ê¤»¤º¤Ë¡¢
41 Âç°èŪ¤Ê¥Ç¡¼¥¿³ÊǼ¾ì½ê¤òºîÀ®¤¹¤ë¡£
43 .\"O To provide a single location where the thread locking needs to be
44 .\"O implemented. At the time of this writing, however, thread locking is not
46 ¥¹¥ì¥Ã¥É (thread) ¥í¥Ã¥¯¤ò¼ÂÁõ¤¹¤ëɬÍפ¬¤¢¤ë³ÊǼ¾ì½ê¤òÄ󶡤¹¤ë¡£
47 ¤·¤«¤·¡¢¤³¤ì¤ò½ñ¤¤¤Æ¤¤¤ë»þÅÀ¤Ç¤Ï¡¢¥¹¥ì¥Ã¥É¥í¥Ã¥¯¤Ï¤Þ¤À¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
49 .\"O To reduce the number of cross dependencies between code pieces that
50 .\"O may or may not be linked together in the long run. This provides for a
51 .\"O single location in which configuration data, for example, can be
52 .\"O stored for a separate section of code that may not be linked in to
53 .\"O the application in question.
54 ¥³¡¼¥É´Ö¤ÎÁê¸ß°Í¸À¤Î¿ô¤ò¸º¤é¤¹
55 (¥³¡¼¥É¤ÏºÇ½ªÅª¤Ë¥ê¥ó¥¯¤·¤Æ¤â¤·¤Ê¤¯¤Æ¤âÎɤ¤)¡£
56 ÌäÂê¤È¤·¤Æ¤¤¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥óÆâ¤Ç¥ê¥ó¥¯¤µ¤ì¤Ê¤¤¡¢
57 ÊÌ¡¹¤Î¥»¥¯¥·¥ç¥ó¤Î¥³¡¼¥É¤Ç»È¤ï¤ì¤ëÀßÄê¥Ç¡¼¥¿¤Î¤è¤¦¤Ê
58 ¥Ç¡¼¥¿¤Î³ÊǼ¾ì½ê¤òÄ󶡤¹¤ë¡£
60 .\"O The functions defined here implement these goals.
61 ¤³¤³¤ÇÄêµÁ¤µ¤ì¤ë´Ø¿ô¤Ï¡¢°Ê²¼¤ÎÌÜŪ¤ò (¼Â¸½¤¹¤ëµ¡Ç½¤ò) ¼ÂÁõ¤·¤Æ¤¤¤ë¡£
63 .\"O Currently, three data types are supported: boolean's, integers, and
64 .\"O strings. Each of based trade data types have separate storage
65 .\"O spaces. In addition, the storage space for each data type is divided
66 .\"O further by the application level. Currently, there are two storage
67 .\"O spaces. The first is reserved for the SNMP library itself. The second
68 .\"O is intended for use in applications and is not modified or checked by
69 .\"O the library, and, therefore, this is the space usable by you.
70 ¸½ºß¤Î¤È¤³¤í¿¿µ¶ÃÍ (boolean)¡¦À°¿ôÃÍ (integer)¡¦
71 ʸ»úÎó (string) ¤È¤¤¤¦ 3 ¤Ä¤Î¥Ç¡¼¥¿·¿¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
72 ³Æ¥Ç¡¼¥¿·¿¤Î¥Ç¡¼¥¿¤Ï¡¢ÊÌ¡¹¤Î³ÊǼ¾ì½ê¤Ëʬ¤±¤é¤ì¤Æ¤¤¤ë¡£
73 ¤µ¤é¤Ë¡¢³Æ¥Ç¡¼¥¿·¿¤Î³ÊǼ¾ì½ê¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥ì¥Ù¥ë¤Ç¤âʬ³ä¤µ¤ì¤Æ¤¤¤ë¡£
74 ¸½ºß¤Î¤È¤³¤í 2 ¤Ä¤Î³ÊǼ¾ì½ê¤¬¤¢¤ë¡£
75 1 ¤ÄÌܤγÊǼ¾ì½ê¤Ï¡¢SNMP ¥é¥¤¥Ö¥é¥ê¼«¿È¤Ë¤è¤Ã¤ÆͽÌ󤵤ì¤Æ¤¤¤ë¡£
76 2 ¤ÄÌܤγÊǼ¾ì½ê¤Ï¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤Ã¤Æ»È¤ï¤ì¤ë¤³¤È¤ò°Õ¿Þ¤·¤Æ¤ª¤ê¡¢
77 ¥é¥¤¥Ö¥é¥ê¤Ë¤è¤ëÊѹ¹¤ä¥Á¥§¥Ã¥¯¤¬¹Ô¤ï¤ì¤Ê¤¤¤Î¤Ç¡¢
78 ¥æ¡¼¥¶¡¼¤¬»È¤¤¤ä¤¹¤¤¤â¤Î¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
80 .\"O You can think of these storage spaces as being 3 arrays, something
81 .\"O like bool_storage[storeid][which], int_storage[storeid][which], and
82 .\"O string_storage[storeid][which]. The data is then accessed through the
83 .\"O functions defined below. For data you wish to store, you should use a
84 .\"O storeid of DS_APPLICATION_ID.
86 bool_storage[storeid][which], int_storage[storeid][which],
87 string_storage[storeid][which]
88 ¤È¤¤¤¦ 3 ¤Ä¤ÎÇÛÎó¤È¹Í¤¨¤ë¤³¤È¤¬¤Ç¤¤ë¡£
89 ¥Ç¡¼¥¿¤Ï°Ê²¼¤ÇÄêµÁ¤µ¤ì¤ë´Ø¿ô¤Ç¥¢¥¯¥»¥¹¤Ç¤¤ë¡£
90 ³ÊǼ¤·¤¿¤¤¥Ç¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ï¡¢
91 DS_APPLICATION_ID ¤È¤¤¤¦ storeid ¤ò»È¤¨¤ÐÎɤ¤¡£
93 .\"O The storage space used by the library is defined in the
94 .\"O default_store.h file, which currently contains the following defines:
95 ¥é¥¤¥Ö¥é¥ê¤¬»È¤¦³ÊǼ¾ì½ê¤Ï¡¢default_store.h ¤ÇÄêµÁ¤µ¤ì¤Æ¤ª¤ê¡¢
96 ¸½ºß¤Î¤È¤³¤í°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
99 .\"O /* These definitions correspond with the "storid" argument to the API */
100 /* °Ê²¼¤ÎÄêµÁ¤Ï API ¤Î "storeid" °ú¤¿ô¤È¤·¤Æ»È¤ï¤ì¤ë¡£ */
101 #define DS_LIBRARY_ID 0
102 #define DS_APPLICATION_ID 1
103 #define DS_TOKEN_ID 2
105 .\"O /* These definitions correspond with the "which" argument to the API,
106 .\"O when the storeid argument is DS_LIBRARY_ID */
107 /* storeid ¤¬ DS_LIBRARY_ID ¤Î¾ì¹ç¡¢
108 °Ê²¼¤ÎÄêµÁ¤Ï API ¤Î "which" °ú¤¿ô¤È¤·¤Æ»È¤ï¤ì¤ë¡£*/
109 .\"O /* library booleans */
110 /* ¿¿µ¶ÃͤòÁàºî¤¹¤ë¥é¥¤¥Ö¥é¥ê¤Ç»È¤ï¤ì¤ë¤â¤Î */
111 #define DS_LIB_MIB_ERRORS 0
112 #define DS_LIB_SAVE_MIB_DESCRS 1
113 #define DS_LIB_MIB_COMMENT_TERM 2
114 #define DS_LIB_MIB_PARSE_LABEL 3
115 #define DS_LIB_DUMP_PACKET 4
116 #define DS_LIB_LOG_TIMESTAMP 5
117 #define DS_LIB_DONT_READ_CONFIGS 6
118 .\"O #define DS_LIB_MIB_REPLACE 7 /* replace objects from latest module */
119 #define DS_LIB_MIB_REPLACE 7 /* ¥ª¥Ö¥¸¥§¥¯¥È¤òºÇ¿·¤Î¥â¥¸¥å¡¼¥ë¤ÇÃÖ¤´¹¤¨¤ë */
120 .\"O #define DS_LIB_PRINT_NUMERIC_ENUM 8 /* print only numeric enum values */
121 #define DS_LIB_PRINT_NUMERIC_ENUM 8 /* ¿ôÃͤÎÎóµó·¿ (enum) ÃͤΤߤòɽ¼¨¤¹¤ë */
122 .\"O #define DS_LIB_PRINT_NUMERIC_OIDS 9 /* print only numeric enum values */
123 #define DS_LIB_PRINT_NUMERIC_OIDS 9 /* ¿ôÃͤΠoid ¤Î¤ß¤òɽ¼¨¤¹¤ë */
124 .\"O #define DS_LIB_DONT_BREAKDOWN_OIDS 10 /* dont print oid indexes specially */
125 #define DS_LIB_DONT_BREAKDOWN_OIDS 10 /* oid ¥¤¥ó¥Ç¥Ã¥¯¥¹¤òÆäËɽ¼¨¤·¤Ê¤¤ */
126 .\"O #define DS_LIB_ALARM_DONT_USE_SIG 11 /* don't use the alarm() signal */
127 #define DS_LIB_ALARM_DONT_USE_SIG 11 /* alarm() ¥·¥°¥Ê¥ë¤ò»È¤ï¤Ê¤¤ */
128 .\"O #define DS_LIB_PRINT_FULL_OID 12 /* print fully qualified oids */
129 #define DS_LIB_PRINT_FULL_OID 12 /* ´°Á´¤Ê oid ¤òɽ¼¨¤¹¤ë */
130 .\"O #define DS_LIB_QUICK_PRINT 13 /* print very brief output for parsing */
131 #define DS_LIB_QUICK_PRINT 13 /* ¥Ñ¡¼¥¹¤ÎºÝ¤ËÈó¾ï¤Ë´Êñ¤Ê½ÐÎϤò¤¹¤ë */
132 .\"O #define DS_LIB_RANDOM_ACCESS 14 /* random access to oid labels */
133 #define DS_LIB_RANDOM_ACCESS 14 /* oid ¥é¥Ù¥ë¤Ë¥é¥ó¥À¥à¤Ë¥¢¥¯¥»¥¹¤¹¤ë */
134 .\"O #define DS_LIB_REGEX_ACCESS 15 /* regex matching to oid labels */
135 #define DS_LIB_REGEX_ACCESS 15 /* oid ¥é¥Ù¥ë¤Ë regex ¤Ë¤è¤ë¥Þ¥Ã¥Á¥ó¥°¤ò¹Ô¤¦ */
136 .\"O #define DS_LIB_DONT_CHECK_RANGE 16 /* don't check values for ranges on send*/
137 #define DS_LIB_DONT_CHECK_RANGE 16 /* send ¤ÎÃͤÎÈϰϤΥÁ¥§¥Ã¥¯¤ò¹Ô¤ï¤Ê¤¤ */
138 .\"O #define DS_LIB_NO_TOKEN_WARNINGS 17 /* no warn about unknown config tokens */
139 #define DS_LIB_NO_TOKEN_WARNINGS 17 /* config ´Ø¿ô¤Î token ¤¬ÉÔÌÀ¤Ê¾ì¹ç¤Ç¤â·Ù¹ð¤ò½Ð¤µ¤Ê¤¤ */
140 .\"O #define DS_LIB_NUMERIC_TIMETICKS 18 /* print timeticks as a number */
141 #define DS_LIB_NUMERIC_TIMETICKS 18 /* timeticks ¤ò¿ôÃͤÇɽ¼¨¤¹¤ë */
142 .\"O #define DS_LIB_ESCAPE_QUOTES 19 /* shell escape quote marks in oids */
143 #define DS_LIB_ESCAPE_QUOTES 19 /* oid ¤Î°úÍÑÉä¤ò¥·¥§¥ë¤Ë¥¨¥¹¥±¡¼¥×¤µ¤»¤ë */
144 .\"O #define DS_LIB_REVERSE_ENCODE 20 /* encode packets from back to front */
145 #define DS_LIB_REVERSE_ENCODE 20 /* ¥Ð¥Ã¥¯¤«¤é¥Õ¥í¥ó¥È¤Ø¤Î¥Ñ¥±¥Ã¥È¤ò¥¨¥ó¥³¡¼¥É¤¹¤ë */
146 .\"O #define DS_LIB_PRINT_BARE_VALUE 21 /* just print value (not OID = value) */
147 #define DS_LIB_PRINT_BARE_VALUE 21 /* (OID = value ¤Ç¤Ê¤¤¾ì¹ç¤Î) value ¤À¤±¤òɽ¼¨¤¹¤ë */
148 .\"O #define DS_LIB_EXTENDED_INDEX 22 /* print extended index format [x1][x2] */
149 #define DS_LIB_EXTENDED_INDEX 22 /* [x1][x2] ¤È¤¤¤¦³ÈÄ¥·Á¼°¤Ç¥¤¥ó¥Ç¥Ã¥¯¥¹¤òɽ¼¨¤¹¤ë */
151 .\"O /* library integers */
152 /* À°¿ôÃͤòÁàºî¤¹¤ë¥é¥¤¥Ö¥é¥ê¤Ç»È¤ï¤ì¤ë¤â¤Î */
153 #define DS_LIB_MIB_WARNINGS 0
154 #define DS_LIB_SECLEVEL 1
155 #define DS_LIB_SNMPVERSION 2
156 #define DS_LIB_DEFAULT_PORT 3
157 .\"O #define DS_LIB_PRINT_SUFFIX_ONLY 4 /* print out only a single oid node == 1.
158 .\"O like #1 but supply mib module too == 2. */
159 #define DS_LIB_PRINT_SUFFIX_ONLY 4 /* oid node == 1 ¤Î¤â¤Î¤òɽ¼¨¤¹¤ë¡£
160 1 ÈÖÌܤȻ÷¤Æ¤¤¤ë¤¬¡¢mib ¥â¥¸¥å¡¼¥ë
161 too == 2 ¤Î¤â¤Î¤òÍ¿¤¨¤ë¡£ */
164 .\"O /* library strings */
165 /* ʸ»úÎó¤òÁàºî¤¹¤ë¥é¥¤¥Ö¥é¥ê¤Ç»È¤ï¤ì¤ë¤â¤Î */
166 #define DS_LIB_SECNAME 0
167 #define DS_LIB_CONTEXT 1
168 #define DS_LIB_PASSPHRASE 2
169 #define DS_LIB_AUTHPASSPHRASE 3
170 #define DS_LIB_PRIVPASSPHRASE 4
171 #define DS_LIB_OPTIONALCONFIG 5
172 #define DS_LIB_APPTYPE 6
173 #define DS_LIB_COMMUNITY 7
174 #define DS_LIB_PERSISTENT_DIR 8
175 #define DS_LIB_CONFIGURATION_DIR 9
180 .IP "ds_set_boolean(int storeid, int which, int value)"
185 .\"O != 0 or else false into the bool_storage[storeid][which] slot.
188 ¤Î¾ì¹ç¤Ï¡¢bool_storage[storeid][which] ¤Î¥¹¥í¥Ã¥È¤Ë
194 .IP "int ds_get_boolean(int storeid, int which)"
195 .\"O Returns 1 if storage[storeid][which] is true, or 0 if false.
196 storage[storeid][which] ¤¬ true ¤Î¾ì¹ç¤Ï¡¢1 ¤òÊÖ¤¹¡£
197 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢0 ¤òÊÖ¤¹¡£
198 .IP "int ds_set_string(int storeid, int which, const char *value)"
201 .\"O into the string_storage[storeid][which] slot.
203 ¤ò¥¹¥í¥Ã¥È string_storage[storeid][which] ¤ËÆþ¤ì¤ë¡£
204 .IP "char *ds_get_string(int storeid, int which)"
205 .\"O Returns the string which has been stored in the
206 .\"O string_storage[storeid][which] slot.
207 ¥¹¥í¥Ã¥È string_storage[storeid][which] ¤ËÆþ¤Ã¤Æ¤¤¤ëʸ»úÎó¤òÊÖ¤¹¡£
208 .IP "ds_set_int(int storeid, int which, int value)"
211 .\"O into the int_storage[storeid][which] slot.
214 ¥¹¥í¥Ã¥È int_storage[storeid][which] ¤ËÆþ¤ì¤ë¡£
215 .IP "int ds_get_int(int storeid, int which)"
216 .\"O Returns the integer which has been stored in the
217 .\"O int_storage[storeid][which] slot.
218 ¥¹¥í¥Ã¥È int_storage[storeid][which] ¤ËÆþ¤Ã¤Æ¤¤¤ëÀ°¿ôÃͤòÊÖ¤¹¡£
219 .IP "void ds_shutdown(void)"
220 .\"O Reclaims memory used to hold information gathered by
221 .\"O ds_register_config and ds_register_premib.
222 ds_register_config ¤È ds_register_premib ¤Ç½¸¤á¤¿¾ðÊó¤ò
223 ÊÝ»ý¤·¤Æ¤ª¤¯¤¿¤á¤Ë»È¤ï¤ì¤Æ¤¤¤ë¥á¥â¥ê¤ò²ó¼ý¤¹¤ë¡£
224 .IP "ds_register_config(u_char type, const char *ftype, const char *token, int storeid, int which)"
225 .\"O This token registers a configuration file directive and attaches it to
226 .\"O a default storage type and slot. Specifically,
230 .\"O indicate the storage slot in the data type indicated by
234 .\"O is either one of the following constants: ASN_BOOLEAN, ASN_INTEGER, or
236 token ¤ÏÀßÄê¥Õ¥¡¥¤¥ë¤Î¥Ç¥£¥ì¥¯¥Æ¥£¥Ö¤òÅÐÏ¿¤·¡¢
237 ¥Ç¥Õ¥©¥ë¥È¤Î³ÊǼ¥¿¥¤¥×¤È¥¹¥í¥Ã¥È¤Ë´ØÏ¢¤Å¤±¤ë¡£
244 ¥Ç¡¼¥¿·¿¤Î³ÊǼ¥¹¥í¥Ã¥È¤ò»Ø¤¹¡£
246 ¤ÏÄê¿ô ASN_BOOLEAN, ASN_INTEGER, ASN_OCTET_STR ¤Î¤¤¤º¤ì¤« 1 ¤Ä¤Ç¤¢¤ë¡£
249 .\"O variable indicates the file name base string searched for the
251 .\"O keyword. For example, the following call:
255 ¥¡¼¥ï¡¼¥É¤òõ¤¹¤¿¤á¤Î¥Õ¥¡¥¤¥ë̾¤Î¥Ù¡¼¥¹Ê¸»úÎó¤Ç¤¢¤ë¡£
259 ds_register_config(ASN_INTEGER, "snmp", "testtoken", DS_APPLICATION_ID, 5)
262 .\"O would indicate that when the snmp.conf file(s) were found and parsed,
263 .\"O that any line beginning with the word "testtoken" should be read and
264 .\"O the value after "testtoken" should be stored into the
265 .\"O int_storage[DS_APPLICATION_ID][5] slot. For example the following
266 .\"O line in the configuration file:
267 ¤È¤¤¤¦¸Æ¤Ó½Ð¤·¤Ç¤Ï¡¢snmp.conf ¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤Ã¤Æ¥Ñ¡¼¥¹¤µ¤ì¤ë¤È¤¤Ë¡¢
268 "testtoken" ¤È¤¤¤¦¸ì¤Ç»Ï¤Þ¤ë¹Ô¤¬Æɤޤ졢
269 "testtoken" ¤Î¸å¤Ë¤¢¤ëÃͤ¬
270 ¥¹¥í¥Ã¥È int_storage[DS_APPLICATION_ID][5] ¤Ë³ÊǼ¤µ¤ì¤ë¡£
271 Î㤨¤Ð¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤Î
277 ¤È¤¤¤¦¹Ô¤Ç¤Ï¡¢int_storage[DS_APPLICATION_ID][5] = 42 ¤ËÀßÄꤵ¤ì¤ë¡£
280 snmp_config(5), read_config(3)