1 /* Portions of this file are subject to the following copyright(s). See 2 * the Net-SNMP's COPYING file for more details and other copyrights 3 * that may apply: 4 */ 5 /* 6 * Portions of this file are copyrighted by: 7 * Copyright � 2003 Sun Microsystems, Inc. All rights reserved. 8 * Use is subject to license terms specified in the COPYING file 9 * distributed with the Net-SNMP package. 10 * 11 * Portions of this file are copyrighted by: 12 * Copyright (c) 2016 VMware, Inc. All rights reserved. 13 * Use is subject to license terms specified in the COPYING file 14 * distributed with the Net-SNMP package. 15 */ 16 /* 17 * Note: 18 * If new default_store entries are added to this header file, 19 * then remember to run 'perl/default_store/gen' to update the 20 * corresponding perl interface. 21 */ 22 /* 23 * @file default_store.h: storage space for defaults 24 * 25 * @addtogroup default_store 26 * 27 * @{ 28 */ 29 #ifndef DEFAULT_STORE_H 30 #define DEFAULT_STORE_H 31 32 #include <net-snmp/net-snmp-config.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #define NETSNMP_DS_MAX_IDS 3 39 #define NETSNMP_DS_MAX_SUBIDS 48 /* needs to be a multiple of 8 */ 40 41 /* 42 * begin storage definitions 43 */ 44 /** 45 * @def NETSNMP_DS_LIBRARY_ID 46 * These definitions correspond with the "storid" argument to the API. 47 */ 48 #define NETSNMP_DS_LIBRARY_ID 0 49 #define NETSNMP_DS_APPLICATION_ID 1 50 #define NETSNMP_DS_TOKEN_ID 2 51 52 /* 53 * These definitions correspond with the "which" argument to the API, 54 * when the storeid argument is NETSNMP_DS_LIBRARY_ID 55 */ 56 /* 57 * library booleans 58 */ 59 #define NETSNMP_DS_LIB_MIB_ERRORS 0 60 #define NETSNMP_DS_LIB_SAVE_MIB_DESCRS 1 61 #define NETSNMP_DS_LIB_MIB_COMMENT_TERM 2 62 #define NETSNMP_DS_LIB_MIB_PARSE_LABEL 3 63 #define NETSNMP_DS_LIB_DUMP_PACKET 4 64 #define NETSNMP_DS_LIB_LOG_TIMESTAMP 5 65 #define NETSNMP_DS_LIB_DONT_READ_CONFIGS 6 /* don't read normal config files */ 66 #define NETSNMP_DS_LIB_DISABLE_CONFIG_LOAD NETSNMP_DS_LIB_DONT_READ_CONFIGS 67 #define NETSNMP_DS_LIB_MIB_REPLACE 7 /* replace objects from latest module */ 68 #define NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM 8 /* print only numeric enum values */ 69 #define NETSNMP_DS_LIB_PRINT_NUMERIC_OIDS 9 /* print only numeric enum values */ 70 #define NETSNMP_DS_LIB_DONT_BREAKDOWN_OIDS 10 /* dont print oid indexes specially */ 71 #define NETSNMP_DS_LIB_ALARM_DONT_USE_SIG 11 /* don't use the alarm() signal */ 72 #define NETSNMP_DS_LIB_PRINT_FULL_OID 12 /* print fully qualified oids */ 73 #define NETSNMP_DS_LIB_QUICK_PRINT 13 /* print very brief output for parsing */ 74 #define NETSNMP_DS_LIB_RANDOM_ACCESS 14 /* random access to oid labels */ 75 #define NETSNMP_DS_LIB_REGEX_ACCESS 15 /* regex matching to oid labels */ 76 #define NETSNMP_DS_LIB_DONT_CHECK_RANGE 16 /* don't check values for ranges on send */ 77 #define NETSNMP_DS_LIB_NO_TOKEN_WARNINGS 17 /* no warn about unknown config tokens */ 78 #define NETSNMP_DS_LIB_NUMERIC_TIMETICKS 18 /* print timeticks as a number */ 79 #define NETSNMP_DS_LIB_ESCAPE_QUOTES 19 /* shell escape quote marks in oids */ 80 #define NETSNMP_DS_LIB_REVERSE_ENCODE 20 /* encode packets from back to front */ 81 #define NETSNMP_DS_LIB_PRINT_BARE_VALUE 21 /* just print value (not OID = value) */ 82 #define NETSNMP_DS_LIB_EXTENDED_INDEX 22 /* print extended index format [x1][x2] */ 83 #define NETSNMP_DS_LIB_PRINT_HEX_TEXT 23 /* print ASCII text along with hex strings */ 84 #define NETSNMP_DS_LIB_PRINT_UCD_STYLE_OID 24 /* print OID's using the UCD-style prefix suppression */ 85 #define NETSNMP_DS_LIB_READ_UCD_STYLE_OID 25 /* require top-level OIDs to be prefixed with a dot */ 86 #define NETSNMP_DS_LIB_HAVE_READ_PREMIB_CONFIG 26 /* have the pre-mib parsing config tokens been processed */ 87 #define NETSNMP_DS_LIB_HAVE_READ_CONFIG 27 /* have the config tokens been processed */ 88 #define NETSNMP_DS_LIB_QUICKE_PRINT 28 89 #define NETSNMP_DS_LIB_DONT_PRINT_UNITS 29 /* don't print UNITS suffix */ 90 #define NETSNMP_DS_LIB_NO_DISPLAY_HINT 30 /* don't apply DISPLAY-HINTs */ 91 #define NETSNMP_DS_LIB_16BIT_IDS 31 /* restrict requestIDs, etc to 16-bit values */ 92 #define NETSNMP_DS_LIB_DONT_PERSIST_STATE 32 /* don't load config and don't load/save persistent file */ 93 #define NETSNMP_DS_LIB_2DIGIT_HEX_OUTPUT 33 /* print a leading 0 on hex values <= 'f' */ 94 #define NETSNMP_DS_LIB_IGNORE_NO_COMMUNITY 34 /* don't complain if no community is specified in the command arguments */ 95 #define NETSNMP_DS_LIB_DISABLE_PERSISTENT_LOAD 35 /* don't load persistent file */ 96 #define NETSNMP_DS_LIB_DISABLE_PERSISTENT_SAVE 36 /* don't save persistent file */ 97 #define NETSNMP_DS_LIB_APPEND_LOGFILES 37 /* append, don't overwrite, log files */ 98 #define NETSNMP_DS_LIB_NO_DISCOVERY 38 /* don't support RFC5343 contextEngineID discovery */ 99 #define NETSNMP_DS_LIB_TSM_USE_PREFIX 39 /* TSM's simple security name mapping */ 100 #define NETSNMP_DS_LIB_DONT_LOAD_HOST_FILES 40 /* don't read host.conf files */ 101 #define NETSNMP_DS_LIB_DNSSEC_WARN_ONLY 41 /* tread DNSSEC errors as warnings */ 102 #define NETSNMP_DS_LIB_CLIENT_ADDR_USES_PORT 42 /* NETSNMP_DS_LIB_CLIENT_ADDR includes address and also port */ 103 #define NETSNMP_DS_LIB_DISABLE_V1 43 /* disable SNMPv1 */ 104 #define NETSNMP_DS_LIB_DISABLE_V2c 44 /* disable SNMPv2c */ 105 #define NETSNMP_DS_LIB_DISABLE_V3 45 /* disable SNMPv3 */ 106 #define NETSNMP_DS_LIB_FILTER_SOURCE 46 /* filter pkt by source IP */ 107 #define NETSNMP_DS_LIB_ADD_FORWARDER_INFO 47 /* add info about forwarder to SNMP packets */ 108 #define NETSNMP_DS_LIB_MAX_BOOL_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ 109 110 /* 111 * library integers 112 */ 113 #define NETSNMP_DS_LIB_MIB_WARNINGS 0 114 #define NETSNMP_DS_LIB_SECLEVEL 1 115 #define NETSNMP_DS_LIB_SNMPVERSION 2 116 #define NETSNMP_DS_LIB_DEFAULT_PORT 3 117 #define NETSNMP_DS_LIB_OID_OUTPUT_FORMAT 4 118 #define NETSNMP_DS_LIB_PRINT_SUFFIX_ONLY NETSNMP_DS_LIB_OID_OUTPUT_FORMAT 119 #define NETSNMP_DS_LIB_STRING_OUTPUT_FORMAT 5 120 #define NETSNMP_DS_LIB_HEX_OUTPUT_LENGTH 6 121 #define NETSNMP_DS_LIB_SERVERSENDBUF 7 /* send buffer (server) */ 122 #define NETSNMP_DS_LIB_SERVERRECVBUF 8 /* receive buffer (server) */ 123 #define NETSNMP_DS_LIB_CLIENTSENDBUF 9 /* send buffer (client) */ 124 #define NETSNMP_DS_LIB_CLIENTRECVBUF 10 /* receive buffer (client) */ 125 #define NETSNMP_DS_SSHDOMAIN_SOCK_PERM 11 126 #define NETSNMP_DS_SSHDOMAIN_DIR_PERM 12 127 #define NETSNMP_DS_SSHDOMAIN_SOCK_USER 12 128 #define NETSNMP_DS_SSHDOMAIN_SOCK_GROUP 13 129 #define NETSNMP_DS_LIB_TIMEOUT 14 130 #define NETSNMP_DS_LIB_RETRIES 15 131 #define NETSNMP_DS_LIB_MSG_SEND_MAX 16 /* global max response size */ 132 #define NETSNMP_DS_LIB_FILTER_TYPE 17 /* 0=NONE, 1=acceptlist, -1=blocklist */ 133 #define NETSNMP_DS_LIB_MAX_INT_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ 134 135 /* 136 * special meanings for the default SNMP version slot (NETSNMP_DS_LIB_SNMPVERSION) 137 */ 138 #ifndef NETSNMP_DISABLE_SNMPV1 139 #define NETSNMP_DS_SNMP_VERSION_1 128 /* bogus */ 140 #endif 141 #ifndef NETSNMP_DISABLE_SNMPV2C 142 #define NETSNMP_DS_SNMP_VERSION_2c 1 /* real */ 143 #endif 144 #define NETSNMP_DS_SNMP_VERSION_3 3 /* real */ 145 146 147 /* 148 * library strings 149 */ 150 #define NETSNMP_DS_LIB_SECNAME 0 151 #define NETSNMP_DS_LIB_CONTEXT 1 152 #define NETSNMP_DS_LIB_PASSPHRASE 2 153 #define NETSNMP_DS_LIB_AUTHPASSPHRASE 3 154 #define NETSNMP_DS_LIB_PRIVPASSPHRASE 4 155 #define NETSNMP_DS_LIB_OPTIONALCONFIG 5 156 #define NETSNMP_DS_LIB_APPTYPE 6 157 #define NETSNMP_DS_LIB_COMMUNITY 7 158 #define NETSNMP_DS_LIB_PERSISTENT_DIR 8 159 #define NETSNMP_DS_LIB_CONFIGURATION_DIR 9 160 #define NETSNMP_DS_LIB_SECMODEL 10 161 #define NETSNMP_DS_LIB_MIBDIRS 11 162 #define NETSNMP_DS_LIB_OIDSUFFIX 12 163 #define NETSNMP_DS_LIB_OIDPREFIX 13 164 #define NETSNMP_DS_LIB_CLIENT_ADDR 14 165 #define NETSNMP_DS_LIB_TEMP_FILE_PATTERN 15 166 #define NETSNMP_DS_LIB_AUTHMASTERKEY 16 167 #define NETSNMP_DS_LIB_PRIVMASTERKEY 17 168 #define NETSNMP_DS_LIB_AUTHLOCALIZEDKEY 18 169 #define NETSNMP_DS_LIB_PRIVLOCALIZEDKEY 19 170 #define NETSNMP_DS_LIB_APPTYPES 20 171 #define NETSNMP_DS_LIB_KSM_KEYTAB 21 172 #define NETSNMP_DS_LIB_KSM_SERVICE_NAME 22 173 #define NETSNMP_DS_LIB_X509_CLIENT_PUB 23 174 #define NETSNMP_DS_LIB_X509_SERVER_PUB 24 175 #define NETSNMP_DS_LIB_SSHTOSNMP_SOCKET 25 176 #define NETSNMP_DS_LIB_CERT_EXTRA_SUBDIR 26 177 #define NETSNMP_DS_LIB_HOSTNAME 27 178 #define NETSNMP_DS_LIB_X509_CRL_FILE 28 179 #define NETSNMP_DS_LIB_TLS_ALGORITMS 29 180 #define NETSNMP_DS_LIB_TLS_LOCAL_CERT 30 181 #define NETSNMP_DS_LIB_TLS_PEER_CERT 31 182 #define NETSNMP_DS_LIB_SSH_USERNAME 32 183 #define NETSNMP_DS_LIB_SSH_PUBKEY 33 184 #define NETSNMP_DS_LIB_SSH_PRIVKEY 34 185 #define NETSNMP_DS_LIB_OUTPUT_PRECISION 35 186 #define NETSNMP_DS_LIB_MAX_STR_ID 48 /* match NETSNMP_DS_MAX_SUBIDS */ 187 188 /* 189 * end storage definitions 190 */ 191 192 /* 193 * macros for dynamic protocol switches 194 */ 195 #ifndef NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION 196 197 #if defined(NETSNMP_DISABLE_SNMPV1) 198 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) \ 199 ((pc_ver) == 0/*SNMP_VERSION_1*/) 200 #else 201 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) \ 202 ((pc_ver) == SNMP_VERSION_1 && \ 203 netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ 204 NETSNMP_DS_LIB_DISABLE_V1)) 205 #endif 206 207 #if defined(NETSNMP_DISABLE_SNMPV2C) 208 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) \ 209 ((pc_ver) == 1/*SNMP_VERSION_2c*/) 210 #else 211 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) \ 212 ((pc_ver) == SNMP_VERSION_2c && \ 213 netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ 214 NETSNMP_DS_LIB_DISABLE_V2c)) 215 #endif 216 217 #define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target) do { \ 218 if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) || \ 219 NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver)) { \ 220 DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n")); \ 221 goto pc_target; \ 222 } \ 223 } while(0) 224 225 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver) \ 226 ((pc_ver == SNMP_VERSION_3) && \ 227 netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, \ 228 NETSNMP_DS_LIB_DISABLE_V3)) 229 230 #define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target) do { \ 231 if (NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) { \ 232 DEBUGMSGTL(("snmp:protocol:disabled", "enforced\n")); \ 233 goto pc_target; \ 234 } \ 235 } while(0) 236 237 #define NETSNMP_RUNTIME_PROTOCOL_CHECK(pc_ver, pc_target) do { \ 238 NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(pc_ver, pc_target); \ 239 NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(pc_ver, pc_target); \ 240 } while(0) 241 242 #define NETSNMP_RUNTIME_PROTOCOL_SKIP(pc_ver) \ 243 (NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) || \ 244 NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) || \ 245 NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver)) 246 247 #else /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */ 248 #define NETSNMP_RUNTIME_PROTOCOL_SKIP(pc_ver) (0) 249 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V1(pc_ver) (0) 250 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V2(pc_ver) (0) 251 #define NETSNMP_RUNTIME_PROTOCOL_SKIP_V3(pc_ver) (0) 252 #define NETSNMP_RUNTIME_PROTOCOL_CHECK(ver, gt) do { ; } while(0) 253 #define NETSNMP_RUNTIME_PROTOCOL_CHECK_V1V2(ver, gt) do { ; } while(0) 254 #define NETSNMP_RUNTIME_PROTOCOL_CHECK_V3(ver, gt) do { ; } while(0) 255 #endif /* NETSNMP_FEATURE_REMOVE_RUNTIME_DISABLE_VERSION */ 256 257 258 NETSNMP_IMPORT 259 int netsnmp_ds_set_boolean(int storeid, int which, int value); 260 NETSNMP_IMPORT 261 int netsnmp_ds_get_boolean(int storeid, int which); 262 NETSNMP_IMPORT 263 int netsnmp_ds_toggle_boolean(int storeid, int which); 264 NETSNMP_IMPORT 265 int netsnmp_ds_set_int(int storeid, int which, int value); 266 NETSNMP_IMPORT 267 int netsnmp_ds_get_int(int storeid, int which); 268 NETSNMP_IMPORT 269 int netsnmp_ds_set_string(int storeid, int which, 270 const char *value); 271 NETSNMP_IMPORT 272 char *netsnmp_ds_get_string(int storeid, int which); 273 NETSNMP_IMPORT 274 int netsnmp_ds_set_void(int storeid, int which, void *value); 275 NETSNMP_IMPORT 276 void *netsnmp_ds_get_void(int storeid, int which); 277 NETSNMP_IMPORT 278 int netsnmp_ds_register_config(u_char type, const char *ftype, 279 const char *token, int storeid, 280 int which); 281 NETSNMP_IMPORT 282 int netsnmp_ds_register_premib(u_char type, const char *ftype, 283 const char *token, int storeid, 284 int which); 285 NETSNMP_IMPORT 286 int netsnmp_ds_parse_boolean(char *line); 287 NETSNMP_IMPORT 288 void netsnmp_ds_shutdown(void); 289 290 #ifdef __cplusplus 291 } 292 #endif 293 #endif /* DEFAULT_STORE_H */ 294 /** @} */ 295