| 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 |
#ifndef SNMP_API_H |
| 17 |
#define SNMP_API_H |
| 18 |
|
| 19 |
/* |
| 20 |
* @file snmp_api.h - API for access to snmp. |
| 21 |
* |
| 22 |
* @addtogroup library |
| 23 |
* |
| 24 |
* Caution: when using this library in a multi-threaded application, |
| 25 |
* the values of global variables "snmp_errno" and "snmp_detail" |
| 26 |
* cannot be reliably determined. Suggest using snmp_error() |
| 27 |
* to obtain the library error codes. |
| 28 |
* |
| 29 |
* @{ |
| 30 |
*/ |
| 31 |
|
| 32 |
#include <net-snmp/types.h> |
| 33 |
#include <net-snmp/varbind_api.h> |
| 34 |
#include <net-snmp/output_api.h> |
| 35 |
#include <net-snmp/pdu_api.h> |
| 36 |
#include <net-snmp/session_api.h> |
| 37 |
|
| 38 |
#include <net-snmp/net-snmp-features.h> |
| 39 |
|
| 40 |
#ifndef DONT_SHARE_ERROR_WITH_OTHER_THREADS |
| 41 |
#define SET_SNMP_ERROR(x) snmp_errno=(x) |
| 42 |
#else |
| 43 |
#define SET_SNMP_ERROR(x) |
| 44 |
#endif |
| 45 |
|
| 46 |
|
| 47 |
#ifdef __cplusplus |
| 48 |
extern "C" { |
| 49 |
#endif |
| 50 |
|
| 51 |
/*********************************************************** |
| 52 |
Copyright 1989 by Carnegie Mellon University |
| 53 |
|
| 54 |
All Rights Reserved |
| 55 |
|
| 56 |
Permission to use, copy, modify, and distribute this software and its |
| 57 |
documentation for any purpose and without fee is hereby granted, |
| 58 |
provided that the above copyright notice appear in all copies and that |
| 59 |
both that copyright notice and this permission notice appear in |
| 60 |
supporting documentation, and that the name of CMU not be |
| 61 |
used in advertising or publicity pertaining to distribution of the |
| 62 |
software without specific, written prior permission. |
| 63 |
|
| 64 |
CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
| 65 |
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL |
| 66 |
CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR |
| 67 |
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 68 |
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 69 |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 70 |
SOFTWARE. |
| 71 |
******************************************************************/ |
| 72 |
|
| 73 |
struct timeval; |
| 74 |
/* |
| 75 |
* A list of all the outstanding requests for a particular session. |
| 76 |
*/ |
| 77 |
#ifdef SNMP_NEED_REQUEST_LIST |
| 78 |
typedef struct request_list { |
| 79 |
struct request_list *next_request; |
| 80 |
long request_id; /* request id */ |
| 81 |
long message_id; /* message id */ |
| 82 |
netsnmp_callback callback; /* user callback per request (NULL if unused) */ |
| 83 |
void *cb_data; /* user callback data per request (NULL if unused) */ |
| 84 |
int retries; /* Number of retries */ |
| 85 |
u_long timeout; /* length to wait for timeout */ |
| 86 |
struct timeval timeM; /* Time this request was made [monotonic clock] */ |
| 87 |
struct timeval expireM; /* Time this request is due to expire [monotonic clock]. */ |
| 88 |
struct snmp_session *session; |
| 89 |
netsnmp_pdu *pdu; /* The pdu for this request |
| 90 |
* (saved so it can be retransmitted */ |
| 91 |
} netsnmp_request_list; |
| 92 |
#endif /* SNMP_NEED_REQUEST_LIST */ |
| 93 |
|
| 94 |
/* |
| 95 |
* Set fields in session and pdu to the following to get a default or unconfigured value. |
| 96 |
*/ |
| 97 |
#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */ |
| 98 |
#define SNMP_DEFAULT_RETRIES -1 |
| 99 |
#define SNMP_DEFAULT_TIMEOUT -1 |
| 100 |
#define SNMP_DEFAULT_REMPORT 0 |
| 101 |
#define SNMP_DEFAULT_REQID -1 |
| 102 |
#define SNMP_DEFAULT_MSGID -1 |
| 103 |
#define SNMP_DEFAULT_ERRSTAT -1 |
| 104 |
#define SNMP_DEFAULT_ERRINDEX -1 |
| 105 |
#define SNMP_DEFAULT_ADDRESS 0 |
| 106 |
#define SNMP_DEFAULT_PEERNAME NULL |
| 107 |
#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0 |
| 108 |
#define SNMP_DEFAULT_TIME 0 |
| 109 |
#define SNMP_DEFAULT_VERSION -1 |
| 110 |
#define SNMP_DEFAULT_SECMODEL -1 |
| 111 |
#define SNMP_DEFAULT_CONTEXT "" |
| 112 |
#ifndef NETSNMP_DISABLE_MD5 |
| 113 |
#define SNMP_DEFAULT_AUTH_PROTO usmHMACMD5AuthProtocol |
| 114 |
#else |
| 115 |
#define SNMP_DEFAULT_AUTH_PROTO usmHMACSHA1AuthProtocol |
| 116 |
#endif |
| 117 |
#define SNMP_DEFAULT_AUTH_PROTOLEN OID_LENGTH(SNMP_DEFAULT_AUTH_PROTO) |
| 118 |
#ifndef NETSNMP_DISABLE_DES |
| 119 |
#define SNMP_DEFAULT_PRIV_PROTO usmDESPrivProtocol |
| 120 |
#else |
| 121 |
#define SNMP_DEFAULT_PRIV_PROTO usmAESPrivProtocol |
| 122 |
#endif |
| 123 |
#define SNMP_DEFAULT_PRIV_PROTOLEN OID_LENGTH(SNMP_DEFAULT_PRIV_PROTO) |
| 124 |
|
| 125 |
NETSNMP_IMPORT void snmp_set_detail(const char *); |
| 126 |
|
| 127 |
#define SNMP_MAX_RCV_MSG_SIZE 65536 |
| 128 |
#define SNMP_MAX_MSG_SIZE 1472 /* ethernet MTU minus IP/UDP header */ |
| 129 |
#define SNMP_MAX_MSG_V3_HDRS (4+3+4+7+7+3+7+16) /* fudge factor=16 */ |
| 130 |
#define SNMP_MAX_ENG_SIZE 32 |
| 131 |
#define SNMP_MAX_SEC_NAME_SIZE 256 |
| 132 |
#define SNMP_MAX_CONTEXT_SIZE 256 |
| 133 |
#define SNMP_SEC_PARAM_BUF_SIZE 256 |
| 134 |
|
| 135 |
/* |
| 136 |
* set to one to ignore unauthenticated Reports |
| 137 |
*/ |
| 138 |
#define SNMPV3_IGNORE_UNAUTH_REPORTS 0 |
| 139 |
|
| 140 |
/* |
| 141 |
* authoritative engine definitions |
| 142 |
*/ |
| 143 |
#define SNMP_SESS_NONAUTHORITATIVE 0 /* should be 0 to default to this */ |
| 144 |
#define SNMP_SESS_AUTHORITATIVE 1 /* don't learn engineIDs */ |
| 145 |
#define SNMP_SESS_UNKNOWNAUTH 2 /* sometimes (like NRs) */ |
| 146 |
|
| 147 |
/* |
| 148 |
* to determine type of Report from varbind_list |
| 149 |
*/ |
| 150 |
#define REPORT_STATS_LEN 9 /* Length of prefix for MPD/USM report statistic objects */ |
| 151 |
#define REPORT_STATS_LEN2 8 /* Length of prefix for Target report statistic objects */ |
| 152 |
/* From SNMP-MPD-MIB */ |
| 153 |
#define REPORT_snmpUnknownSecurityModels_NUM 1 |
| 154 |
#define REPORT_snmpInvalidMsgs_NUM 2 |
| 155 |
#define REPORT_snmpUnknownPDUHandlers_NUM 3 |
| 156 |
/* From SNMP-USER-BASED-SM-MIB */ |
| 157 |
#define REPORT_usmStatsUnsupportedSecLevels_NUM 1 |
| 158 |
#define REPORT_usmStatsNotInTimeWindows_NUM 2 |
| 159 |
#define REPORT_usmStatsUnknownUserNames_NUM 3 |
| 160 |
#define REPORT_usmStatsUnknownEngineIDs_NUM 4 |
| 161 |
#define REPORT_usmStatsWrongDigests_NUM 5 |
| 162 |
#define REPORT_usmStatsDecryptionErrors_NUM 6 |
| 163 |
/* From SNMP-TARGET-MIB */ |
| 164 |
#define REPORT_snmpUnavailableContexts_NUM 4 |
| 165 |
#define REPORT_snmpUnknownContexts_NUM 5 |
| 166 |
|
| 167 |
#define SNMP_DETAIL_SIZE 512 |
| 168 |
|
| 169 |
#define SNMP_FLAGS_SESSION_USER 0x1000 |
| 170 |
#define SNMP_FLAGS_UDP_BROADCAST 0x800 |
| 171 |
#define SNMP_FLAGS_RESP_CALLBACK 0x400 /* Additional callback on response */ |
| 172 |
#define SNMP_FLAGS_USER_CREATED 0x200 /* USM user has been created */ |
| 173 |
#define SNMP_FLAGS_DONT_PROBE 0x100 /* don't probe for an engineID */ |
| 174 |
#define SNMP_FLAGS_STREAM_SOCKET 0x80 |
| 175 |
#define SNMP_FLAGS_LISTENING 0x40 /* Server stream sockets only */ |
| 176 |
#define SNMP_FLAGS_SUBSESSION 0x20 |
| 177 |
#define SNMP_FLAGS_SHARED_SOCKET 0x10 /* subsession list=related sessions */ |
| 178 |
#define SNMP_FLAGS_STRIKE2 0x02 |
| 179 |
#define SNMP_FLAGS_STRIKE1 0x01 |
| 180 |
|
| 181 |
#define CLEAR_SNMP_STRIKE_FLAGS(x) \ |
| 182 |
x &= ~(SNMP_FLAGS_STRIKE2|SNMP_FLAGS_STRIKE1) |
| 183 |
|
| 184 |
/* |
| 185 |
* returns '1' if the session is to be regarded as dead, |
| 186 |
* otherwise set the strike flags appropriately, and return 0 |
| 187 |
*/ |
| 188 |
#define SET_SNMP_STRIKE_FLAGS(x) \ |
| 189 |
(( x & SNMP_FLAGS_STRIKE2 ) ? 1 : \ |
| 190 |
((( x & SNMP_FLAGS_STRIKE1 ) ? ( x |= SNMP_FLAGS_STRIKE2 ) : \ |
| 191 |
( x |= SNMP_FLAGS_STRIKE1 )), \ |
| 192 |
0)) |
| 193 |
|
| 194 |
/* |
| 195 |
* Error return values. |
| 196 |
* |
| 197 |
* SNMPERR_SUCCESS is the non-PDU "success" code. |
| 198 |
* |
| 199 |
* XXX These should be merged with SNMP_ERR_* defines and confined |
| 200 |
* to values < 0. ??? |
| 201 |
*/ |
| 202 |
#define SNMPERR_SUCCESS (0) /* XXX Non-PDU "success" code. */ |
| 203 |
#define SNMPERR_GENERR (-1) |
| 204 |
#define SNMPERR_BAD_LOCPORT (-2) |
| 205 |
#define SNMPERR_BAD_ADDRESS (-3) |
| 206 |
#define SNMPERR_BAD_SESSION (-4) |
| 207 |
#define SNMPERR_TOO_LONG (-5) |
| 208 |
#define SNMPERR_NO_SOCKET (-6) |
| 209 |
#define SNMPERR_V2_IN_V1 (-7) |
| 210 |
#define SNMPERR_V1_IN_V2 (-8) |
| 211 |
#define SNMPERR_BAD_REPEATERS (-9) |
| 212 |
#define SNMPERR_BAD_REPETITIONS (-10) |
| 213 |
#define SNMPERR_BAD_ASN1_BUILD (-11) |
| 214 |
#define SNMPERR_BAD_SENDTO (-12) |
| 215 |
#define SNMPERR_BAD_PARSE (-13) |
| 216 |
#define SNMPERR_BAD_VERSION (-14) |
| 217 |
#define SNMPERR_BAD_SRC_PARTY (-15) |
| 218 |
#define SNMPERR_BAD_DST_PARTY (-16) |
| 219 |
#define SNMPERR_BAD_CONTEXT (-17) |
| 220 |
#define SNMPERR_BAD_COMMUNITY (-18) |
| 221 |
#define SNMPERR_NOAUTH_DESPRIV (-19) |
| 222 |
#define SNMPERR_BAD_ACL (-20) |
| 223 |
#define SNMPERR_BAD_PARTY (-21) |
| 224 |
#define SNMPERR_ABORT (-22) |
| 225 |
#define SNMPERR_UNKNOWN_PDU (-23) |
| 226 |
#define SNMPERR_TIMEOUT (-24) |
| 227 |
#define SNMPERR_BAD_RECVFROM (-25) |
| 228 |
#define SNMPERR_BAD_ENG_ID (-26) |
| 229 |
#define SNMPERR_BAD_SEC_NAME (-27) |
| 230 |
#define SNMPERR_BAD_SEC_LEVEL (-28) |
| 231 |
#define SNMPERR_ASN_PARSE_ERR (-29) |
| 232 |
#define SNMPERR_UNKNOWN_SEC_MODEL (-30) |
| 233 |
#define SNMPERR_INVALID_MSG (-31) |
| 234 |
#define SNMPERR_UNKNOWN_ENG_ID (-32) |
| 235 |
#define SNMPERR_UNKNOWN_USER_NAME (-33) |
| 236 |
#define SNMPERR_UNSUPPORTED_SEC_LEVEL (-34) |
| 237 |
#define SNMPERR_AUTHENTICATION_FAILURE (-35) |
| 238 |
#define SNMPERR_NOT_IN_TIME_WINDOW (-36) |
| 239 |
#define SNMPERR_DECRYPTION_ERR (-37) |
| 240 |
#define SNMPERR_SC_GENERAL_FAILURE (-38) |
| 241 |
#define SNMPERR_SC_NOT_CONFIGURED (-39) |
| 242 |
#define SNMPERR_KT_NOT_AVAILABLE (-40) |
| 243 |
#define SNMPERR_UNKNOWN_REPORT (-41) |
| 244 |
#define SNMPERR_USM_GENERICERROR (-42) |
| 245 |
#define SNMPERR_USM_UNKNOWNSECURITYNAME (-43) |
| 246 |
#define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL (-44) |
| 247 |
#define SNMPERR_USM_ENCRYPTIONERROR (-45) |
| 248 |
#define SNMPERR_USM_AUTHENTICATIONFAILURE (-46) |
| 249 |
#define SNMPERR_USM_PARSEERROR (-47) |
| 250 |
#define SNMPERR_USM_UNKNOWNENGINEID (-48) |
| 251 |
#define SNMPERR_USM_NOTINTIMEWINDOW (-49) |
| 252 |
#define SNMPERR_USM_DECRYPTIONERROR (-50) |
| 253 |
#define SNMPERR_NOMIB (-51) |
| 254 |
#define SNMPERR_RANGE (-52) |
| 255 |
#define SNMPERR_MAX_SUBID (-53) |
| 256 |
#define SNMPERR_BAD_SUBID (-54) |
| 257 |
#define SNMPERR_LONG_OID (-55) |
| 258 |
#define SNMPERR_BAD_NAME (-56) |
| 259 |
#define SNMPERR_VALUE (-57) |
| 260 |
#define SNMPERR_UNKNOWN_OBJID (-58) |
| 261 |
#define SNMPERR_NULL_PDU (-59) |
| 262 |
#define SNMPERR_NO_VARS (-60) |
| 263 |
#define SNMPERR_VAR_TYPE (-61) |
| 264 |
#define SNMPERR_MALLOC (-62) |
| 265 |
#define SNMPERR_KRB5 (-63) |
| 266 |
#define SNMPERR_PROTOCOL (-64) |
| 267 |
#define SNMPERR_OID_NONINCREASING (-65) |
| 268 |
#define SNMPERR_JUST_A_CONTEXT_PROBE (-66) |
| 269 |
#define SNMPERR_TRANSPORT_NO_CONFIG (-67) |
| 270 |
#define SNMPERR_TRANSPORT_CONFIG_ERROR (-68) |
| 271 |
#define SNMPERR_TLS_NO_CERTIFICATE (-69) |
| 272 |
|
| 273 |
#define SNMPERR_MAX (-69) |
| 274 |
|
| 275 |
|
| 276 |
/* |
| 277 |
* General purpose memory allocation functions. Use these functions to |
| 278 |
* allocate memory that may be reallocated or freed by the Net-SNMP |
| 279 |
* library or to reallocate or free memory that has been allocated by the |
| 280 |
* Net-SNMP library, and when working in a context where there is more than |
| 281 |
* one heap. Examples are: |
| 282 |
* - Perl XSUB's. |
| 283 |
* - MSVC or MinGW with the Net-SNMP library compiled as a DLL instead of |
| 284 |
* a static library. |
| 285 |
*/ |
| 286 |
NETSNMP_IMPORT void *netsnmp_malloc(size_t size); |
| 287 |
NETSNMP_IMPORT void *netsnmp_calloc(size_t nelem, size_t elsize); |
| 288 |
NETSNMP_IMPORT void *netsnmp_realloc(void *ptr, size_t size); |
| 289 |
NETSNMP_IMPORT void netsnmp_free(void *ptr); |
| 290 |
NETSNMP_IMPORT char *netsnmp_strdup(const char *s1); |
| 291 |
|
| 292 |
NETSNMP_IMPORT long int netsnmp_random(void); |
| 293 |
NETSNMP_IMPORT void netsnmp_srandom(unsigned int seed); |
| 294 |
|
| 295 |
/* |
| 296 |
* void |
| 297 |
* snmp_free_pdu(pdu) |
| 298 |
* netsnmp_pdu *pdu; |
| 299 |
* |
| 300 |
* Frees the pdu and any malloc'd data associated with it. |
| 301 |
*/ |
| 302 |
|
| 303 |
NETSNMP_IMPORT void snmp_free_var_internals(netsnmp_variable_list *); /* frees contents only */ |
| 304 |
|
| 305 |
|
| 306 |
/* |
| 307 |
* This routine must be supplied by the application: |
| 308 |
* |
| 309 |
* u_char *authenticator(pdu, length, community, community_len) |
| 310 |
* u_char *pdu; The rest of the PDU to be authenticated |
| 311 |
* int *length; The length of the PDU (updated by the authenticator) |
| 312 |
* u_char *community; The community name to authenticate under. |
| 313 |
* int community_len The length of the community name. |
| 314 |
* |
| 315 |
* Returns the authenticated pdu, or NULL if authentication failed. |
| 316 |
* If null authentication is used, the authenticator in snmp_session can be |
| 317 |
* set to NULL(0). |
| 318 |
*/ |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
/* |
| 323 |
* This routine must be supplied by the application: |
| 324 |
* |
| 325 |
* int callback(operation, session, reqid, pdu, magic) |
| 326 |
* int operation; |
| 327 |
* netsnmp_session *session; The session authenticated under. |
| 328 |
* int reqid; The request id of this pdu (0 for TRAP) |
| 329 |
* netsnmp_pdu *pdu; The pdu information. |
| 330 |
* void *magic A link to the data for this routine. |
| 331 |
* |
| 332 |
* Returns 1 if request was successful, 0 if it should be kept pending. |
| 333 |
* Any data in the pdu must be copied because it will be freed elsewhere. |
| 334 |
* Operations are defined below: |
| 335 |
*/ |
| 336 |
|
| 337 |
#define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE 1 |
| 338 |
#define NETSNMP_CALLBACK_OP_TIMED_OUT 2 |
| 339 |
#define NETSNMP_CALLBACK_OP_SEND_FAILED 3 |
| 340 |
#define NETSNMP_CALLBACK_OP_CONNECT 4 |
| 341 |
#define NETSNMP_CALLBACK_OP_DISCONNECT 5 |
| 342 |
#define NETSNMP_CALLBACK_OP_RESEND 6 |
| 343 |
#define NETSNMP_CALLBACK_OP_SEC_ERROR 7 |
| 344 |
|
| 345 |
NETSNMP_IMPORT |
| 346 |
long snmp_get_next_msgid(void); |
| 347 |
NETSNMP_IMPORT |
| 348 |
long snmp_get_next_reqid(void); |
| 349 |
NETSNMP_IMPORT |
| 350 |
long snmp_get_next_sessid(void); |
| 351 |
NETSNMP_IMPORT |
| 352 |
long snmp_get_next_transid(void); |
| 353 |
|
| 354 |
NETSNMP_IMPORT |
| 355 |
int netsnmp_max_send_msg_size(void); |
| 356 |
|
| 357 |
NETSNMP_IMPORT |
| 358 |
int snmp_oid_compare(const oid *, size_t, const oid *, |
| 359 |
size_t); |
| 360 |
NETSNMP_IMPORT |
| 361 |
int snmp_oid_ncompare(const oid *, size_t, const oid *, |
| 362 |
size_t, size_t); |
| 363 |
NETSNMP_IMPORT |
| 364 |
int snmp_oidtree_compare(const oid *, size_t, const oid *, |
| 365 |
size_t); |
| 366 |
NETSNMP_IMPORT |
| 367 |
int snmp_oidsubtree_compare(const oid *, size_t, const oid *, |
| 368 |
size_t); |
| 369 |
NETSNMP_IMPORT |
| 370 |
int netsnmp_oid_compare_ll(const oid * in_name1, |
| 371 |
size_t len1, const oid * in_name2, |
| 372 |
size_t len2, size_t *offpt); |
| 373 |
NETSNMP_IMPORT |
| 374 |
int netsnmp_oid_equals(const oid *, size_t, const oid *, |
| 375 |
size_t); |
| 376 |
NETSNMP_IMPORT |
| 377 |
int netsnmp_oid_tree_equals(const oid *, size_t, const oid *, |
| 378 |
size_t); |
| 379 |
NETSNMP_IMPORT |
| 380 |
int netsnmp_oid_is_subtree(const oid *, size_t, const oid *, |
| 381 |
size_t); |
| 382 |
NETSNMP_IMPORT |
| 383 |
int netsnmp_oid_find_prefix(const oid * in_name1, size_t len1, |
| 384 |
const oid * in_name2, size_t len2); |
| 385 |
NETSNMP_IMPORT |
| 386 |
void init_snmp(const char *); |
| 387 |
|
| 388 |
NETSNMP_IMPORT |
| 389 |
int |
| 390 |
snmp_build(u_char ** pkt, size_t * pkt_len, size_t * offset, |
| 391 |
netsnmp_session * pss, netsnmp_pdu *pdu); |
| 392 |
|
| 393 |
NETSNMP_IMPORT |
| 394 |
int |
| 395 |
snmp_parse(struct session_list *sessp, netsnmp_session *pss, |
| 396 |
netsnmp_pdu *pdu, u_char *data, size_t length); |
| 397 |
|
| 398 |
NETSNMP_IMPORT |
| 399 |
u_char *snmp_pdu_build(netsnmp_pdu *, u_char *, size_t *); |
| 400 |
#ifdef NETSNMP_USE_REVERSE_ASNENCODING |
| 401 |
NETSNMP_IMPORT |
| 402 |
u_char *snmp_pdu_rbuild(netsnmp_pdu *, u_char *, size_t *); |
| 403 |
#endif |
| 404 |
NETSNMP_IMPORT |
| 405 |
int snmpv3_parse(netsnmp_pdu *, u_char *, size_t *, |
| 406 |
u_char **, netsnmp_session *); |
| 407 |
NETSNMP_IMPORT |
| 408 |
int snmpv3_packet_build(netsnmp_session *, |
| 409 |
netsnmp_pdu *pdu, u_char * packet, |
| 410 |
size_t * out_length, |
| 411 |
u_char * pdu_data, |
| 412 |
size_t pdu_data_len); |
| 413 |
NETSNMP_IMPORT |
| 414 |
int snmpv3_packet_rbuild(netsnmp_session *, |
| 415 |
netsnmp_pdu *pdu, u_char * packet, |
| 416 |
size_t * out_length, |
| 417 |
u_char * pdu_data, |
| 418 |
size_t pdu_data_len); |
| 419 |
NETSNMP_IMPORT |
| 420 |
int snmpv3_make_report(netsnmp_pdu *pdu, int error); |
| 421 |
NETSNMP_IMPORT |
| 422 |
int snmpv3_get_report_type(netsnmp_pdu *pdu); |
| 423 |
NETSNMP_IMPORT |
| 424 |
int snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, |
| 425 |
size_t * length); |
| 426 |
NETSNMP_IMPORT |
| 427 |
u_char *snmpv3_scopedPDU_parse(netsnmp_pdu *pdu, u_char * cp, |
| 428 |
size_t * length); |
| 429 |
NETSNMP_IMPORT |
| 430 |
void snmp_store_needed(const char *type); |
| 431 |
NETSNMP_IMPORT |
| 432 |
void snmp_store_if_needed(void); |
| 433 |
NETSNMP_IMPORT |
| 434 |
void snmp_store(const char *type); |
| 435 |
NETSNMP_IMPORT |
| 436 |
void snmp_shutdown(const char *type); |
| 437 |
NETSNMP_IMPORT |
| 438 |
int snmp_add_var(netsnmp_pdu *, const oid *, size_t, char, |
| 439 |
const char *); |
| 440 |
NETSNMP_IMPORT |
| 441 |
oid *snmp_duplicate_objid(const oid * objToCopy, size_t); |
| 442 |
|
| 443 |
#ifndef NETSNMP_FEATURE_REMOVE_STATISTICS |
| 444 |
NETSNMP_IMPORT |
| 445 |
u_int snmp_increment_statistic(int which); |
| 446 |
NETSNMP_IMPORT |
| 447 |
u_int snmp_increment_statistic_by(int which, int count); |
| 448 |
NETSNMP_IMPORT |
| 449 |
u_int snmp_get_statistic(int which); |
| 450 |
NETSNMP_IMPORT |
| 451 |
void snmp_init_statistics(void); |
| 452 |
#else /* NETSNMP_FEATURE_REMOVE_STATISTICS */ |
| 453 |
|
| 454 |
/* allow code to continue referencing API even if statistics are removed */ |
| 455 |
#define snmp_increment_statistic(X) |
| 456 |
#define snmp_increment_statistic_by(X,Y) |
| 457 |
#define snmp_init_statistics() |
| 458 |
|
| 459 |
#endif |
| 460 |
|
| 461 |
NETSNMP_IMPORT |
| 462 |
int create_user_from_session(netsnmp_session * session); |
| 463 |
NETSNMP_IMPORT |
| 464 |
int snmpv3_probe_contextEngineID_rfc5343(struct session_list *slp, |
| 465 |
netsnmp_session *session); |
| 466 |
|
| 467 |
/* |
| 468 |
* New re-allocating reverse encoding functions. |
| 469 |
*/ |
| 470 |
#ifdef NETSNMP_USE_REVERSE_ASNENCODING |
| 471 |
|
| 472 |
NETSNMP_IMPORT |
| 473 |
int snmpv3_packet_realloc_rbuild(u_char ** pkt, size_t * pkt_len, |
| 474 |
size_t * offset, |
| 475 |
netsnmp_session * session, |
| 476 |
netsnmp_pdu *pdu, u_char * pdu_data, |
| 477 |
size_t pdu_data_len); |
| 478 |
|
| 479 |
NETSNMP_IMPORT |
| 480 |
int snmp_pdu_realloc_rbuild(u_char ** pkt, size_t * pkt_len, |
| 481 |
size_t * offset, netsnmp_pdu *pdu); |
| 482 |
#endif |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
struct netsnmp_transport_s; |
| 487 |
|
| 488 |
/* |
| 489 |
* Extended open; fpre_parse has changed. |
| 490 |
*/ |
| 491 |
|
| 492 |
NETSNMP_IMPORT |
| 493 |
netsnmp_session *snmp_open_ex(netsnmp_session *, |
| 494 |
int (*fpre_parse) (netsnmp_session *, |
| 495 |
struct |
| 496 |
netsnmp_transport_s *, |
| 497 |
void *, int), |
| 498 |
int (*fparse) (netsnmp_session *, |
| 499 |
netsnmp_pdu *, u_char *, |
| 500 |
size_t), |
| 501 |
int (*fpost_parse) (netsnmp_session *, |
| 502 |
netsnmp_pdu *, int), |
| 503 |
int (*fbuild) (netsnmp_session *, |
| 504 |
netsnmp_pdu *, u_char *, |
| 505 |
size_t *), |
| 506 |
int (*frbuild) (netsnmp_session *, |
| 507 |
netsnmp_pdu *, u_char **, |
| 508 |
size_t *, size_t *), |
| 509 |
int (*fcheck) (u_char *, size_t)); |
| 510 |
|
| 511 |
NETSNMP_IMPORT |
| 512 |
void netsnmp_sess_log_error(int priority, |
| 513 |
const char *prog_string, |
| 514 |
netsnmp_session * ss); |
| 515 |
|
| 516 |
NETSNMP_IMPORT |
| 517 |
const char * snmp_pdu_type(int type); |
| 518 |
|
| 519 |
/* |
| 520 |
* Return the netsnmp_transport structure associated with the given opaque |
| 521 |
* pointer. |
| 522 |
*/ |
| 523 |
|
| 524 |
NETSNMP_IMPORT |
| 525 |
struct netsnmp_transport_s *snmp_sess_transport(void *); |
| 526 |
NETSNMP_IMPORT |
| 527 |
void snmp_sess_transport_set(void *, |
| 528 |
struct netsnmp_transport_s *); |
| 529 |
|
| 530 |
NETSNMP_IMPORT int |
| 531 |
netsnmp_sess_config_transport(struct netsnmp_container_s *transport_configuration, |
| 532 |
struct netsnmp_transport_s *transport); |
| 533 |
|
| 534 |
NETSNMP_IMPORT int |
| 535 |
netsnmp_sess_config_and_open_transport(netsnmp_session *in_session, |
| 536 |
struct netsnmp_transport_s *transport); |
| 537 |
|
| 538 |
/* |
| 539 |
* EXTENDED SESSION API ------------------------------------------ |
| 540 |
* |
| 541 |
* snmp_sess_add_ex, snmp_sess_add, snmp_add |
| 542 |
* |
| 543 |
* Analogous to snmp_open family of functions, but taking an |
| 544 |
* netsnmp_transport pointer as an extra argument. Unlike snmp_open et |
| 545 |
* al. it doesn't attempt to interpret the in_session->peername as a |
| 546 |
* transport endpoint specifier, but instead uses the supplied transport. |
| 547 |
* JBPN |
| 548 |
* |
| 549 |
*/ |
| 550 |
|
| 551 |
NETSNMP_IMPORT |
| 552 |
void netsnmp_cleanup_session(netsnmp_session *s); |
| 553 |
|
| 554 |
NETSNMP_IMPORT |
| 555 |
void *snmp_sess_add_ex(netsnmp_session *, |
| 556 |
struct netsnmp_transport_s *, |
| 557 |
int (*fpre_parse) (netsnmp_session *, |
| 558 |
struct |
| 559 |
netsnmp_transport_s |
| 560 |
*, void *, int), |
| 561 |
int (*fparse) (netsnmp_session *, |
| 562 |
struct snmp_pdu *, |
| 563 |
u_char *, size_t), |
| 564 |
int (*fpost_parse) (netsnmp_session *, |
| 565 |
struct snmp_pdu *, |
| 566 |
int), |
| 567 |
int (*fbuild) (netsnmp_session *, |
| 568 |
struct snmp_pdu *, |
| 569 |
u_char *, size_t *), |
| 570 |
int (*frbuild) (netsnmp_session *, |
| 571 |
struct snmp_pdu *, |
| 572 |
u_char **, size_t *, |
| 573 |
size_t *), |
| 574 |
int (*fcheck) (u_char *, size_t), |
| 575 |
netsnmp_pdu *(*fcreate_pdu) (struct |
| 576 |
netsnmp_transport_s |
| 577 |
*, |
| 578 |
void *, |
| 579 |
size_t)); |
| 580 |
|
| 581 |
NETSNMP_IMPORT |
| 582 |
void *snmp_sess_add(netsnmp_session *, |
| 583 |
struct netsnmp_transport_s *, |
| 584 |
int (*fpre_parse) (netsnmp_session *, |
| 585 |
struct |
| 586 |
netsnmp_transport_s *, |
| 587 |
void *, int), |
| 588 |
int (*fpost_parse) (netsnmp_session *, |
| 589 |
netsnmp_pdu *, int)); |
| 590 |
|
| 591 |
NETSNMP_IMPORT |
| 592 |
netsnmp_session *snmp_add(netsnmp_session *, |
| 593 |
struct netsnmp_transport_s *, |
| 594 |
int (*fpre_parse) (netsnmp_session *, |
| 595 |
struct netsnmp_transport_s |
| 596 |
*, void *, int), |
| 597 |
int (*fpost_parse) (netsnmp_session *, |
| 598 |
netsnmp_pdu *, int)); |
| 599 |
NETSNMP_IMPORT |
| 600 |
netsnmp_session *snmp_add_full(netsnmp_session * in_session, |
| 601 |
struct netsnmp_transport_s *transport, |
| 602 |
int (*fpre_parse) (netsnmp_session *, |
| 603 |
struct |
| 604 |
netsnmp_transport_s |
| 605 |
*, void *, int), |
| 606 |
int (*fparse) (netsnmp_session *, |
| 607 |
netsnmp_pdu *, u_char *, |
| 608 |
size_t), |
| 609 |
int (*fpost_parse) (netsnmp_session *, |
| 610 |
netsnmp_pdu *, int), |
| 611 |
int (*fbuild) (netsnmp_session *, |
| 612 |
netsnmp_pdu *, u_char *, |
| 613 |
size_t *), |
| 614 |
int (*frbuild) (netsnmp_session *, |
| 615 |
netsnmp_pdu *, |
| 616 |
u_char **, size_t *, |
| 617 |
size_t *), |
| 618 |
int (*fcheck) (u_char *, size_t), |
| 619 |
netsnmp_pdu *(*fcreate_pdu) (struct |
| 620 |
netsnmp_transport_s |
| 621 |
*, void *, |
| 622 |
size_t) |
| 623 |
); |
| 624 |
/* |
| 625 |
* end single session API |
| 626 |
*/ |
| 627 |
|
| 628 |
/* |
| 629 |
* generic statistic counters |
| 630 |
*/ |
| 631 |
|
| 632 |
/* |
| 633 |
* snmpv3 statistics |
| 634 |
*/ |
| 635 |
|
| 636 |
/* |
| 637 |
* mpd stats |
| 638 |
*/ |
| 639 |
#define STAT_SNMPUNKNOWNSECURITYMODELS 0 |
| 640 |
#define STAT_SNMPINVALIDMSGS 1 |
| 641 |
#define STAT_SNMPUNKNOWNPDUHANDLERS 2 |
| 642 |
#define STAT_MPD_STATS_START STAT_SNMPUNKNOWNSECURITYMODELS |
| 643 |
#define STAT_MPD_STATS_END STAT_SNMPUNKNOWNPDUHANDLERS |
| 644 |
|
| 645 |
/* |
| 646 |
* usm stats |
| 647 |
*/ |
| 648 |
#define STAT_USMSTATSUNSUPPORTEDSECLEVELS 3 |
| 649 |
#define STAT_USMSTATSNOTINTIMEWINDOWS 4 |
| 650 |
#define STAT_USMSTATSUNKNOWNUSERNAMES 5 |
| 651 |
#define STAT_USMSTATSUNKNOWNENGINEIDS 6 |
| 652 |
#define STAT_USMSTATSWRONGDIGESTS 7 |
| 653 |
#define STAT_USMSTATSDECRYPTIONERRORS 8 |
| 654 |
#define STAT_USM_STATS_START STAT_USMSTATSUNSUPPORTEDSECLEVELS |
| 655 |
#define STAT_USM_STATS_END STAT_USMSTATSDECRYPTIONERRORS |
| 656 |
|
| 657 |
/* |
| 658 |
* snmp counters |
| 659 |
*/ |
| 660 |
#define STAT_SNMPINPKTS 9 |
| 661 |
#define STAT_SNMPOUTPKTS 10 |
| 662 |
#define STAT_SNMPINBADVERSIONS 11 |
| 663 |
#define STAT_SNMPINBADCOMMUNITYNAMES 12 |
| 664 |
#define STAT_SNMPINBADCOMMUNITYUSES 13 |
| 665 |
#define STAT_SNMPINASNPARSEERRS 14 |
| 666 |
/* |
| 667 |
* #define STAT_SNMPINBADTYPES 15 |
| 668 |
*/ |
| 669 |
#define STAT_SNMPINTOOBIGS 16 |
| 670 |
#define STAT_SNMPINNOSUCHNAMES 17 |
| 671 |
#define STAT_SNMPINBADVALUES 18 |
| 672 |
#define STAT_SNMPINREADONLYS 19 |
| 673 |
#define STAT_SNMPINGENERRS 20 |
| 674 |
#define STAT_SNMPINTOTALREQVARS 21 |
| 675 |
#define STAT_SNMPINTOTALSETVARS 22 |
| 676 |
#define STAT_SNMPINGETREQUESTS 23 |
| 677 |
#define STAT_SNMPINGETNEXTS 24 |
| 678 |
#define STAT_SNMPINSETREQUESTS 25 |
| 679 |
#define STAT_SNMPINGETRESPONSES 26 |
| 680 |
#define STAT_SNMPINTRAPS 27 |
| 681 |
#define STAT_SNMPOUTTOOBIGS 28 |
| 682 |
#define STAT_SNMPOUTNOSUCHNAMES 29 |
| 683 |
#define STAT_SNMPOUTBADVALUES 30 |
| 684 |
/* |
| 685 |
* #define STAT_SNMPOUTREADONLYS 31 |
| 686 |
*/ |
| 687 |
#define STAT_SNMPOUTGENERRS 32 |
| 688 |
#define STAT_SNMPOUTGETREQUESTS 33 |
| 689 |
#define STAT_SNMPOUTGETNEXTS 34 |
| 690 |
#define STAT_SNMPOUTSETREQUESTS 35 |
| 691 |
#define STAT_SNMPOUTGETRESPONSES 36 |
| 692 |
#define STAT_SNMPOUTTRAPS 37 |
| 693 |
/* |
| 694 |
* AUTHTRAPENABLE 38 |
| 695 |
*/ |
| 696 |
#define STAT_SNMPSILENTDROPS 39 |
| 697 |
#define STAT_SNMPPROXYDROPS 40 |
| 698 |
#define STAT_SNMP_STATS_START STAT_SNMPINPKTS |
| 699 |
#define STAT_SNMP_STATS_END STAT_SNMPPROXYDROPS |
| 700 |
|
| 701 |
/* |
| 702 |
* target mib counters |
| 703 |
*/ |
| 704 |
#define STAT_SNMPUNAVAILABLECONTEXTS 41 |
| 705 |
#define STAT_SNMPUNKNOWNCONTEXTS 42 |
| 706 |
#define STAT_TARGET_STATS_START STAT_SNMPUNAVAILABLECONTEXTS |
| 707 |
#define STAT_TARGET_STATS_END STAT_SNMPUNKNOWNCONTEXTS |
| 708 |
|
| 709 |
/* |
| 710 |
* TSM counters |
| 711 |
*/ |
| 712 |
#define STAT_TSM_SNMPTSMINVALIDCACHES 43 |
| 713 |
#define STAT_TSM_SNMPTSMINADEQUATESECURITYLEVELS 44 |
| 714 |
#define STAT_TSM_SNMPTSMUNKNOWNPREFIXES 45 |
| 715 |
#define STAT_TSM_SNMPTSMINVALIDPREFIXES 46 |
| 716 |
#define STAT_TSM_STATS_START STAT_TSM_SNMPTSMINVALIDCACHES |
| 717 |
#define STAT_TSM_STATS_END STAT_TSM_SNMPTSMINVALIDPREFIXES |
| 718 |
|
| 719 |
/* |
| 720 |
* TLSTM counters |
| 721 |
*/ |
| 722 |
#define STAT_TLSTM_SNMPTLSTMSESSIONOPENS 47 |
| 723 |
#define STAT_TLSTM_SNMPTLSTMSESSIONCLIENTCLOSES 48 |
| 724 |
#define STAT_TLSTM_SNMPTLSTMSESSIONOPENERRORS 49 |
| 725 |
#define STAT_TLSTM_SNMPTLSTMSESSIONACCEPTS 50 |
| 726 |
#define STAT_TLSTM_SNMPTLSTMSESSIONSERVERCLOSES 51 |
| 727 |
#define STAT_TLSTM_SNMPTLSTMSESSIONNOSESSIONS 52 |
| 728 |
#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCLIENTCERTIFICATES 53 |
| 729 |
#define STAT_TLSTM_SNMPTLSTMSESSIONUNKNOWNSERVERCERTIFICATE 54 |
| 730 |
#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDSERVERCERTIFICATES 55 |
| 731 |
#define STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES 56 |
| 732 |
|
| 733 |
#define STAT_TLSTM_STATS_START STAT_TLSTM_SNMPTLSTMSESSIONOPENS |
| 734 |
#define STAT_TLSTM_STATS_END STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES |
| 735 |
|
| 736 |
/* this previously was end+1; don't know why the +1 is needed; |
| 737 |
XXX: check the code */ |
| 738 |
#define NETSNMP_STAT_MAX_STATS (STAT_TLSTM_STATS_END+1) |
| 739 |
/** backwards compatability */ |
| 740 |
#define MAX_STATS NETSNMP_STAT_MAX_STATS |
| 741 |
|
| 742 |
/* |
| 743 |
* Internal: The list of active/open sessions. |
| 744 |
*/ |
| 745 |
struct session_list { |
| 746 |
struct session_list *next; |
| 747 |
netsnmp_session *session; |
| 748 |
netsnmp_transport *transport; |
| 749 |
struct snmp_internal_session *internal; |
| 750 |
}; |
| 751 |
|
| 752 |
#ifdef __cplusplus |
| 753 |
} |
| 754 |
#endif |
| 755 |
#endif /* SNMP_API_H */ |