net-snmp 5.7
snmp_api.h
00001 /* Portions of this file are subject to the following copyright(s).  See
00002  * the Net-SNMP's COPYING file for more details and other copyrights
00003  * that may apply:
00004  */
00005 /*
00006  * Portions of this file are copyrighted by:
00007  * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
00008  * Use is subject to license terms specified in the COPYING file
00009  * distributed with the Net-SNMP package.
00010  */
00011 #ifndef SNMP_API_H
00012 #define SNMP_API_H
00013 
00014 /*
00015  * @file snmp_api.h - API for access to snmp.
00016  * 
00017  * @addtogroup library
00018  *
00019  * Caution: when using this library in a multi-threaded application,
00020  * the values of global variables "snmp_errno" and "snmp_detail"
00021  * cannot be reliably determined.  Suggest using snmp_error()
00022  * to obtain the library error codes.
00023  *
00024  * @{
00025  */
00026 
00027 #include <net-snmp/types.h>
00028 #include <net-snmp/varbind_api.h>
00029 #include <net-snmp/output_api.h>
00030 #include <net-snmp/pdu_api.h>
00031 #include <net-snmp/session_api.h>
00032 
00033 #include <net-snmp/net-snmp-features.h>
00034 
00035 #ifndef DONT_SHARE_ERROR_WITH_OTHER_THREADS
00036 #define SET_SNMP_ERROR(x) snmp_errno=(x)
00037 #else
00038 #define SET_SNMP_ERROR(x)
00039 #endif
00040 
00041 
00042 #ifdef __cplusplus
00043 extern          "C" {
00044 #endif
00045 
00046 /***********************************************************
00047         Copyright 1989 by Carnegie Mellon University
00048 
00049                       All Rights Reserved
00050 
00051 Permission to use, copy, modify, and distribute this software and its
00052 documentation for any purpose and without fee is hereby granted,
00053 provided that the above copyright notice appear in all copies and that
00054 both that copyright notice and this permission notice appear in
00055 supporting documentation, and that the name of CMU not be
00056 used in advertising or publicity pertaining to distribution of the
00057 software without specific, written prior permission.
00058 
00059 CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
00060 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
00061 CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
00062 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00063 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
00064 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00065 SOFTWARE.
00066 ******************************************************************/
00067 
00068 struct timeval;
00069 /*
00070  * A list of all the outstanding requests for a particular session.
00071  */
00072 #ifdef SNMP_NEED_REQUEST_LIST
00073 typedef struct request_list {
00074     struct request_list *next_request;
00075     long            request_id;     /* request id */
00076     long            message_id;     /* message id */
00077     netsnmp_callback callback;      /* user callback per request (NULL if unused) */
00078     void           *cb_data;        /* user callback data per request (NULL if unused) */
00079     int             retries;        /* Number of retries */
00080     u_long          timeout;        /* length to wait for timeout */
00081     struct timeval  time;   /* Time this request was made */
00082     struct timeval  expire; /* time this request is due to expire */
00083     struct snmp_session *session;
00084     netsnmp_pdu    *pdu;    /* The pdu for this request
00085                              * (saved so it can be retransmitted */
00086 } netsnmp_request_list;
00087 #endif                          /* SNMP_NEED_REQUEST_LIST */
00088 
00089     /*
00090      * Set fields in session and pdu to the following to get a default or unconfigured value.
00091      */
00092 #define SNMP_DEFAULT_COMMUNITY_LEN  0   /* to get a default community name */
00093 #define SNMP_DEFAULT_RETRIES        -1
00094 #define SNMP_DEFAULT_TIMEOUT        -1
00095 #define SNMP_DEFAULT_REMPORT        0
00096 #define SNMP_DEFAULT_REQID          -1
00097 #define SNMP_DEFAULT_MSGID          -1
00098 #define SNMP_DEFAULT_ERRSTAT        -1
00099 #define SNMP_DEFAULT_ERRINDEX       -1
00100 #define SNMP_DEFAULT_ADDRESS        0
00101 #define SNMP_DEFAULT_PEERNAME       NULL
00102 #define SNMP_DEFAULT_ENTERPRISE_LENGTH  0
00103 #define SNMP_DEFAULT_TIME           0
00104 #define SNMP_DEFAULT_VERSION        -1
00105 #define SNMP_DEFAULT_SECMODEL       -1
00106 #define SNMP_DEFAULT_CONTEXT        ""
00107 #ifndef NETSNMP_DISABLE_MD5
00108 #define SNMP_DEFAULT_AUTH_PROTO     usmHMACMD5AuthProtocol
00109 #else
00110 #define SNMP_DEFAULT_AUTH_PROTO     usmHMACSHA1AuthProtocol
00111 #endif
00112 #define SNMP_DEFAULT_AUTH_PROTOLEN  USM_LENGTH_OID_TRANSFORM
00113 #ifndef NETSNMP_DISABLE_DES
00114 #define SNMP_DEFAULT_PRIV_PROTO     usmDESPrivProtocol
00115 #else
00116 #define SNMP_DEFAULT_PRIV_PROTO     usmAESPrivProtocol
00117 #endif
00118 #define SNMP_DEFAULT_PRIV_PROTOLEN  USM_LENGTH_OID_TRANSFORM
00119 
00120     NETSNMP_IMPORT void     snmp_set_detail(const char *);
00121 
00122 #define SNMP_MAX_MSG_SIZE          1472 /* ethernet MTU minus IP/UDP header */
00123 #define SNMP_MAX_MSG_V3_HDRS       (4+3+4+7+7+3+7+16)   /* fudge factor=16 */
00124 #define SNMP_MAX_ENG_SIZE          32
00125 #define SNMP_MAX_SEC_NAME_SIZE     256
00126 #define SNMP_MAX_CONTEXT_SIZE      256
00127 #define SNMP_SEC_PARAM_BUF_SIZE    256
00128 
00129     /*
00130      * set to one to ignore unauthenticated Reports 
00131      */
00132 #define SNMPV3_IGNORE_UNAUTH_REPORTS 0
00133 
00134     /*
00135      * authoritative engine definitions 
00136      */
00137 #define SNMP_SESS_NONAUTHORITATIVE 0    /* should be 0 to default to this */
00138 #define SNMP_SESS_AUTHORITATIVE    1    /* don't learn engineIDs */
00139 #define SNMP_SESS_UNKNOWNAUTH      2    /* sometimes (like NRs) */
00140 
00141     /*
00142      * to determine type of Report from varbind_list 
00143      */
00144 #define REPORT_STATS_LEN  9     /* Length of prefix for MPD/USM report statistic objects */
00145 #define REPORT_STATS_LEN2 8     /* Length of prefix for Target report statistic objects */
00146 /* From SNMP-MPD-MIB */
00147 #define REPORT_snmpUnknownSecurityModels_NUM 1
00148 #define REPORT_snmpInvalidMsgs_NUM           2
00149 #define REPORT_snmpUnknownPDUHandlers_NUM    3
00150 /* From SNMP-USER-BASED-SM-MIB */
00151 #define REPORT_usmStatsUnsupportedSecLevels_NUM 1
00152 #define REPORT_usmStatsNotInTimeWindows_NUM 2
00153 #define REPORT_usmStatsUnknownUserNames_NUM 3
00154 #define REPORT_usmStatsUnknownEngineIDs_NUM 4
00155 #define REPORT_usmStatsWrongDigests_NUM     5
00156 #define REPORT_usmStatsDecryptionErrors_NUM 6
00157 /* From SNMP-TARGET-MIB */
00158 #define REPORT_snmpUnavailableContexts_NUM  4
00159 #define REPORT_snmpUnknownContexts_NUM      5
00160 
00161 #define SNMP_DETAIL_SIZE        512
00162 
00163 #define SNMP_FLAGS_UDP_BROADCAST   0x800
00164 #define SNMP_FLAGS_RESP_CALLBACK   0x400      /* Additional callback on response */
00165 #define SNMP_FLAGS_USER_CREATED    0x200      /* USM user has been created */
00166 #define SNMP_FLAGS_DONT_PROBE      0x100      /* don't probe for an engineID */
00167 #define SNMP_FLAGS_STREAM_SOCKET   0x80
00168 #define SNMP_FLAGS_LISTENING       0x40 /* Server stream sockets only */
00169 #define SNMP_FLAGS_SUBSESSION      0x20
00170 #define SNMP_FLAGS_STRIKE2         0x02
00171 #define SNMP_FLAGS_STRIKE1         0x01
00172 
00173 #define CLEAR_SNMP_STRIKE_FLAGS(x) \
00174         x &= ~(SNMP_FLAGS_STRIKE2|SNMP_FLAGS_STRIKE1)
00175 
00176     /*
00177      * returns '1' if the session is to be regarded as dead,
00178      * otherwise set the strike flags appropriately, and return 0
00179      */
00180 #define SET_SNMP_STRIKE_FLAGS(x) \
00181         ((   x & SNMP_FLAGS_STRIKE2 ) ? 1 :                             \
00182          ((( x & SNMP_FLAGS_STRIKE1 ) ? ( x |= SNMP_FLAGS_STRIKE2 ) :   \
00183                                         ( x |= SNMP_FLAGS_STRIKE1 )),   \
00184                                         0))
00185 
00186     /*
00187      * Error return values.
00188      *
00189      * SNMPERR_SUCCESS is the non-PDU "success" code.
00190      *
00191      * XXX  These should be merged with SNMP_ERR_* defines and confined
00192      *      to values < 0.  ???
00193      */
00194 #define SNMPERR_SUCCESS                 (0)     /* XXX  Non-PDU "success" code. */
00195 #define SNMPERR_GENERR                  (-1)
00196 #define SNMPERR_BAD_LOCPORT             (-2)
00197 #define SNMPERR_BAD_ADDRESS             (-3)
00198 #define SNMPERR_BAD_SESSION             (-4)
00199 #define SNMPERR_TOO_LONG                (-5)
00200 #define SNMPERR_NO_SOCKET               (-6)
00201 #define SNMPERR_V2_IN_V1                (-7)
00202 #define SNMPERR_V1_IN_V2                (-8)
00203 #define SNMPERR_BAD_REPEATERS           (-9)
00204 #define SNMPERR_BAD_REPETITIONS         (-10)
00205 #define SNMPERR_BAD_ASN1_BUILD          (-11)
00206 #define SNMPERR_BAD_SENDTO              (-12)
00207 #define SNMPERR_BAD_PARSE               (-13)
00208 #define SNMPERR_BAD_VERSION             (-14)
00209 #define SNMPERR_BAD_SRC_PARTY           (-15)
00210 #define SNMPERR_BAD_DST_PARTY           (-16)
00211 #define SNMPERR_BAD_CONTEXT             (-17)
00212 #define SNMPERR_BAD_COMMUNITY           (-18)
00213 #define SNMPERR_NOAUTH_DESPRIV          (-19)
00214 #define SNMPERR_BAD_ACL                 (-20)
00215 #define SNMPERR_BAD_PARTY               (-21)
00216 #define SNMPERR_ABORT                   (-22)
00217 #define SNMPERR_UNKNOWN_PDU             (-23)
00218 #define SNMPERR_TIMEOUT                 (-24)
00219 #define SNMPERR_BAD_RECVFROM            (-25)
00220 #define SNMPERR_BAD_ENG_ID              (-26)
00221 #define SNMPERR_BAD_SEC_NAME            (-27)
00222 #define SNMPERR_BAD_SEC_LEVEL           (-28)
00223 #define SNMPERR_ASN_PARSE_ERR           (-29)
00224 #define SNMPERR_UNKNOWN_SEC_MODEL       (-30)
00225 #define SNMPERR_INVALID_MSG             (-31)
00226 #define SNMPERR_UNKNOWN_ENG_ID          (-32)
00227 #define SNMPERR_UNKNOWN_USER_NAME       (-33)
00228 #define SNMPERR_UNSUPPORTED_SEC_LEVEL   (-34)
00229 #define SNMPERR_AUTHENTICATION_FAILURE  (-35)
00230 #define SNMPERR_NOT_IN_TIME_WINDOW      (-36)
00231 #define SNMPERR_DECRYPTION_ERR          (-37)
00232 #define SNMPERR_SC_GENERAL_FAILURE      (-38)
00233 #define SNMPERR_SC_NOT_CONFIGURED       (-39)
00234 #define SNMPERR_KT_NOT_AVAILABLE        (-40)
00235 #define SNMPERR_UNKNOWN_REPORT          (-41)
00236 #define SNMPERR_USM_GENERICERROR                (-42)
00237 #define SNMPERR_USM_UNKNOWNSECURITYNAME         (-43)
00238 #define SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL    (-44)
00239 #define SNMPERR_USM_ENCRYPTIONERROR             (-45)
00240 #define SNMPERR_USM_AUTHENTICATIONFAILURE       (-46)
00241 #define SNMPERR_USM_PARSEERROR                  (-47)
00242 #define SNMPERR_USM_UNKNOWNENGINEID             (-48)
00243 #define SNMPERR_USM_NOTINTIMEWINDOW             (-49)
00244 #define SNMPERR_USM_DECRYPTIONERROR             (-50)
00245 #define SNMPERR_NOMIB                   (-51)
00246 #define SNMPERR_RANGE                   (-52)
00247 #define SNMPERR_MAX_SUBID               (-53)
00248 #define SNMPERR_BAD_SUBID               (-54)
00249 #define SNMPERR_LONG_OID                (-55)
00250 #define SNMPERR_BAD_NAME                (-56)
00251 #define SNMPERR_VALUE                   (-57)
00252 #define SNMPERR_UNKNOWN_OBJID           (-58)
00253 #define SNMPERR_NULL_PDU                (-59)
00254 #define SNMPERR_NO_VARS                 (-60)
00255 #define SNMPERR_VAR_TYPE                (-61)
00256 #define SNMPERR_MALLOC                  (-62)
00257 #define SNMPERR_KRB5                    (-63)
00258 #define SNMPERR_PROTOCOL                (-64)
00259 #define SNMPERR_OID_NONINCREASING       (-65)
00260 #define SNMPERR_JUST_A_CONTEXT_PROBE    (-66)
00261 #define SNMPERR_TRANSPORT_NO_CONFIG     (-67)
00262 #define SNMPERR_TRANSPORT_CONFIG_ERROR  (-68)
00263 #define SNMPERR_TLS_NO_CERTIFICATE      (-69)
00264 
00265 #define SNMPERR_MAX                     (-69)
00266 
00267 
00268     /*
00269      * General purpose memory allocation functions. Use these functions to
00270      * allocate memory that may be reallocated or freed by the Net-SNMP
00271      * library or to reallocate or free memory that has been allocated by the
00272      * Net-SNMP library, and when working in a context where there is more than
00273      * one heap. Examples are:
00274      * - Perl XSUB's.
00275      * - MSVC or MinGW with the Net-SNMP library compiled as a DLL instead of
00276      *   a static library.
00277      */
00278     NETSNMP_IMPORT void *netsnmp_malloc(size_t size);
00279     NETSNMP_IMPORT void *netsnmp_calloc(size_t nelem, size_t elsize);
00280     NETSNMP_IMPORT void *netsnmp_realloc(void *ptr, size_t size);
00281     NETSNMP_IMPORT void netsnmp_free(void *ptr);
00282     NETSNMP_IMPORT char *netsnmp_strdup(const char *s1);
00283 
00284     /*
00285      * void
00286      * snmp_free_pdu(pdu)
00287      *     netsnmp_pdu *pdu;
00288      *
00289      * Frees the pdu and any malloc'd data associated with it.
00290      */
00291 
00292     NETSNMP_IMPORT void snmp_free_var_internals(netsnmp_variable_list *);     /* frees contents only */
00293 
00294 
00295     /*
00296      * This routine must be supplied by the application:
00297      *
00298      * u_char *authenticator(pdu, length, community, community_len)
00299      * u_char *pdu;         The rest of the PDU to be authenticated
00300      * int *length;         The length of the PDU (updated by the authenticator)
00301      * u_char *community;   The community name to authenticate under.
00302      * int  community_len   The length of the community name.
00303      *
00304      * Returns the authenticated pdu, or NULL if authentication failed.
00305      * If null authentication is used, the authenticator in snmp_session can be
00306      * set to NULL(0).
00307      */
00308 
00309 
00310 
00311     /*
00312      * This routine must be supplied by the application:
00313      *
00314      * int callback(operation, session, reqid, pdu, magic)
00315      * int operation;
00316      * netsnmp_session *session;    The session authenticated under.
00317      * int reqid;                       The request id of this pdu (0 for TRAP)
00318      * netsnmp_pdu *pdu;        The pdu information.
00319      * void *magic                      A link to the data for this routine.
00320      *
00321      * Returns 1 if request was successful, 0 if it should be kept pending.
00322      * Any data in the pdu must be copied because it will be freed elsewhere.
00323      * Operations are defined below:
00324      */
00325 
00326 #define NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE    1
00327 #define NETSNMP_CALLBACK_OP_TIMED_OUT           2
00328 #define NETSNMP_CALLBACK_OP_SEND_FAILED         3
00329 #define NETSNMP_CALLBACK_OP_CONNECT             4
00330 #define NETSNMP_CALLBACK_OP_DISCONNECT          5
00331 
00332     long            snmp_get_next_msgid(void);
00333     long            snmp_get_next_reqid(void);
00334     NETSNMP_IMPORT
00335     long            snmp_get_next_sessid(void);
00336     NETSNMP_IMPORT
00337     long            snmp_get_next_transid(void);
00338 
00339     NETSNMP_IMPORT
00340     int             snmp_oid_compare(const oid *, size_t, const oid *,
00341                                      size_t);
00342     int             snmp_oid_ncompare(const oid *, size_t, const oid *,
00343                                       size_t, size_t);
00344     NETSNMP_IMPORT
00345     int             snmp_oidtree_compare(const oid *, size_t, const oid *,
00346                                          size_t);
00347     NETSNMP_IMPORT
00348     int             snmp_oidsubtree_compare(const oid *, size_t, const oid *,
00349                                          size_t);
00350     NETSNMP_IMPORT
00351     int             netsnmp_oid_compare_ll(const oid * in_name1,
00352                                            size_t len1, const oid * in_name2,
00353                                            size_t len2, size_t *offpt);
00354     NETSNMP_IMPORT
00355     int             netsnmp_oid_equals(const oid *, size_t, const oid *,
00356                                        size_t);
00357     int             netsnmp_oid_tree_equals(const oid *, size_t, const oid *,
00358                                             size_t);
00359     NETSNMP_IMPORT
00360     int             netsnmp_oid_is_subtree(const oid *, size_t, const oid *,
00361                                            size_t);
00362     NETSNMP_IMPORT
00363     int             netsnmp_oid_find_prefix(const oid * in_name1, size_t len1,
00364                                             const oid * in_name2, size_t len2);
00365     NETSNMP_IMPORT
00366     void            init_snmp(const char *);
00367     u_char         *snmp_pdu_build(netsnmp_pdu *, u_char *, size_t *);
00368 #ifdef NETSNMP_USE_REVERSE_ASNENCODING
00369     u_char         *snmp_pdu_rbuild(netsnmp_pdu *, u_char *, size_t *);
00370 #endif
00371     int             snmpv3_parse(netsnmp_pdu *, u_char *, size_t *,
00372                                  u_char **, netsnmp_session *);
00373     int             snmpv3_packet_build(netsnmp_session *,
00374                                         netsnmp_pdu *pdu, u_char * packet,
00375                                         size_t * out_length,
00376                                         u_char * pdu_data,
00377                                         size_t pdu_data_len);
00378     int             snmpv3_packet_rbuild(netsnmp_session *,
00379                                          netsnmp_pdu *pdu, u_char * packet,
00380                                          size_t * out_length,
00381                                          u_char * pdu_data,
00382                                          size_t pdu_data_len);
00383     int             snmpv3_make_report(netsnmp_pdu *pdu, int error);
00384     int             snmpv3_get_report_type(netsnmp_pdu *pdu);
00385     int             snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data,
00386                                    size_t * length);
00387     u_char         *snmpv3_scopedPDU_parse(netsnmp_pdu *pdu, u_char * cp,
00388                                            size_t * length);
00389     NETSNMP_IMPORT
00390     void            snmp_store_needed(const char *type);
00391     NETSNMP_IMPORT
00392     void            snmp_store_if_needed(void);
00393     NETSNMP_IMPORT
00394     void            snmp_store(const char *type);
00395     NETSNMP_IMPORT
00396     void            snmp_shutdown(const char *type);
00397     NETSNMP_IMPORT
00398     int             snmp_add_var(netsnmp_pdu *, const oid *, size_t, char,
00399                                  const char *);
00400     NETSNMP_IMPORT
00401     oid            *snmp_duplicate_objid(const oid * objToCopy, size_t);
00402     NETSNMP_IMPORT
00403 
00404 #ifndef NETSNMP_FEATURE_REMOVE_STATISTICS
00405     u_int           snmp_increment_statistic(int which);
00406     NETSNMP_IMPORT
00407     u_int           snmp_increment_statistic_by(int which, int count);
00408     NETSNMP_IMPORT
00409     u_int           snmp_get_statistic(int which);
00410     void            snmp_init_statistics(void);
00411 #else /* NETSNMP_FEATURE_REMOVE_STATISTICS */
00412 
00413 /* allow code to continue referencing API even if statistics are removed */
00414 #define snmp_increment_statistic(X)
00415 #define snmp_increment_statistic_by(X,Y)
00416 #define snmp_init_statistics()
00417 
00418 #endif
00419 
00420     int             create_user_from_session(netsnmp_session * session);
00421     int snmp_get_fd_for_session(struct snmp_session *sessp);
00422     int snmpv3_probe_contextEngineID_rfc5343(void *slp,
00423                                              netsnmp_session *session);
00424 
00425     /*
00426      * New re-allocating reverse encoding functions.  
00427      */
00428 #ifdef NETSNMP_USE_REVERSE_ASNENCODING
00429 
00430     int        snmpv3_packet_realloc_rbuild(u_char ** pkt, size_t * pkt_len,
00431                                      size_t * offset,
00432                                      netsnmp_session * session,
00433                                      netsnmp_pdu *pdu, u_char * pdu_data,
00434                                      size_t pdu_data_len);
00435 
00436     int        snmp_pdu_realloc_rbuild(u_char ** pkt, size_t * pkt_len,
00437                                 size_t * offset, netsnmp_pdu *pdu);
00438 #endif
00439 
00440 
00441 
00442 struct netsnmp_transport_s;
00443 
00444     /*
00445      * Extended open; fpre_parse has changed.  
00446      */
00447 
00448     NETSNMP_IMPORT
00449     netsnmp_session *snmp_open_ex(netsnmp_session *,
00450                                   int (*fpre_parse) (netsnmp_session *,
00451                                                      struct
00452                                                      netsnmp_transport_s *,
00453                                                      void *, int),
00454                                   int (*fparse) (netsnmp_session *,
00455                                                  netsnmp_pdu *, u_char *,
00456                                                  size_t),
00457                                   int (*fpost_parse) (netsnmp_session *,
00458                                                       netsnmp_pdu *, int),
00459                                   int (*fbuild) (netsnmp_session *,
00460                                                  netsnmp_pdu *, u_char *,
00461                                                  size_t *),
00462                                   int (*frbuild) (netsnmp_session *,
00463                                                   netsnmp_pdu *, u_char **,
00464                                                   size_t *, size_t *),
00465                                   int (*fcheck) (u_char *, size_t));
00466 
00467     /*
00468      * provided for backwards compatability.  Don't use these functions.
00469      * See snmp_debug.h and snmp_debug.c instead.
00470      */
00471 
00472     NETSNMP_IMPORT
00473     void            snmp_set_do_debugging(int);
00474     NETSNMP_IMPORT
00475     int             snmp_get_do_debugging(void);
00476 
00477 
00478     NETSNMP_IMPORT
00479     void            netsnmp_sess_log_error(int priority,
00480                                            const char *prog_string,
00481                                            netsnmp_session * ss);
00482     const char *    snmp_pdu_type(int type);
00483 
00484     /*
00485      * Return the netsnmp_transport structure associated with the given opaque
00486      * pointer.  
00487      */
00488 
00489     NETSNMP_IMPORT
00490     struct netsnmp_transport_s *snmp_sess_transport(void *);
00491     void            snmp_sess_transport_set(void *,
00492                                             struct netsnmp_transport_s *);
00493 
00494     NETSNMP_IMPORT int
00495     netsnmp_sess_config_transport(struct netsnmp_container_s *transport_configuration,
00496                                   struct netsnmp_transport_s *transport);
00497 
00498     NETSNMP_IMPORT int
00499     netsnmp_sess_config_and_open_transport(netsnmp_session *in_session,
00500                                            struct netsnmp_transport_s *transport);
00501 
00502     /*
00503      * EXTENDED SESSION API ------------------------------------------ 
00504      * 
00505      * snmp_sess_add_ex, snmp_sess_add, snmp_add 
00506      * 
00507      * Analogous to snmp_open family of functions, but taking an
00508      * netsnmp_transport pointer as an extra argument.  Unlike snmp_open et
00509      * al. it doesn't attempt to interpret the in_session->peername as a
00510      * transport endpoint specifier, but instead uses the supplied transport.
00511      * JBPN
00512      * 
00513      */
00514 
00515     void           *snmp_sess_add_ex(netsnmp_session *,
00516                                      struct netsnmp_transport_s *,
00517                                      int (*fpre_parse) (netsnmp_session *,
00518                                                         struct
00519                                                         netsnmp_transport_s
00520                                                         *, void *, int),
00521                                      int (*fparse) (netsnmp_session *,
00522                                                     struct snmp_pdu *,
00523                                                     u_char *, size_t),
00524                                      int (*fpost_parse) (netsnmp_session *,
00525                                                          struct snmp_pdu *,
00526                                                          int),
00527                                      int (*fbuild) (netsnmp_session *,
00528                                                     struct snmp_pdu *,
00529                                                     u_char *, size_t *),
00530                                      int (*frbuild) (netsnmp_session *,
00531                                                      struct snmp_pdu *,
00532                                                      u_char **, size_t *,
00533                                                      size_t *),
00534                                      int (*fcheck) (u_char *, size_t),
00535                                      netsnmp_pdu *(*fcreate_pdu) (struct
00536                                                                   netsnmp_transport_s
00537                                                                   *,
00538                                                                   void *,
00539                                                                   size_t));
00540 
00541     void           *snmp_sess_add(netsnmp_session *,
00542                                   struct netsnmp_transport_s *,
00543                                   int (*fpre_parse) (netsnmp_session *,
00544                                                      struct
00545                                                      netsnmp_transport_s *,
00546                                                      void *, int),
00547                                   int (*fpost_parse) (netsnmp_session *,
00548                                                       netsnmp_pdu *, int));
00549 
00550     NETSNMP_IMPORT
00551     netsnmp_session *snmp_add(netsnmp_session *,
00552                               struct netsnmp_transport_s *,
00553                               int (*fpre_parse) (netsnmp_session *,
00554                                                  struct netsnmp_transport_s
00555                                                  *, void *, int),
00556                               int (*fpost_parse) (netsnmp_session *,
00557                                                   netsnmp_pdu *, int));
00558     NETSNMP_IMPORT
00559     netsnmp_session *snmp_add_full(netsnmp_session * in_session,
00560                                    struct netsnmp_transport_s *transport,
00561                                    int (*fpre_parse) (netsnmp_session *,
00562                                                       struct
00563                                                       netsnmp_transport_s
00564                                                       *, void *, int),
00565                                    int (*fparse) (netsnmp_session *,
00566                                                   netsnmp_pdu *, u_char *,
00567                                                   size_t),
00568                                    int (*fpost_parse) (netsnmp_session *,
00569                                                        netsnmp_pdu *, int),
00570                                    int (*fbuild) (netsnmp_session *,
00571                                                   netsnmp_pdu *, u_char *,
00572                                                   size_t *),
00573                                    int (*frbuild) (netsnmp_session *,
00574                                                    netsnmp_pdu *,
00575                                                    u_char **, size_t *,
00576                                                    size_t *),
00577                                    int (*fcheck) (u_char *, size_t),
00578                                    netsnmp_pdu *(*fcreate_pdu) (struct
00579                                                                 netsnmp_transport_s
00580                                                                 *, void *,
00581                                                                 size_t)
00582         );
00583     /*
00584      * end single session API 
00585      */
00586 
00587     /*
00588      * generic statistic counters 
00589      */
00590 
00591     /*
00592      * snmpv3 statistics 
00593      */
00594 
00595     /*
00596      * mpd stats 
00597      */
00598 #define   STAT_SNMPUNKNOWNSECURITYMODELS     0
00599 #define   STAT_SNMPINVALIDMSGS               1
00600 #define   STAT_SNMPUNKNOWNPDUHANDLERS        2
00601 #define   STAT_MPD_STATS_START               STAT_SNMPUNKNOWNSECURITYMODELS
00602 #define   STAT_MPD_STATS_END                 STAT_SNMPUNKNOWNPDUHANDLERS
00603 
00604     /*
00605      * usm stats 
00606      */
00607 #define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3
00608 #define   STAT_USMSTATSNOTINTIMEWINDOWS      4
00609 #define   STAT_USMSTATSUNKNOWNUSERNAMES      5
00610 #define   STAT_USMSTATSUNKNOWNENGINEIDS      6
00611 #define   STAT_USMSTATSWRONGDIGESTS          7
00612 #define   STAT_USMSTATSDECRYPTIONERRORS      8
00613 #define   STAT_USM_STATS_START               STAT_USMSTATSUNSUPPORTEDSECLEVELS
00614 #define   STAT_USM_STATS_END                 STAT_USMSTATSDECRYPTIONERRORS
00615 
00616     /*
00617      * snmp counters 
00618      */
00619 #define  STAT_SNMPINPKTS                     9
00620 #define  STAT_SNMPOUTPKTS                    10
00621 #define  STAT_SNMPINBADVERSIONS              11
00622 #define  STAT_SNMPINBADCOMMUNITYNAMES        12
00623 #define  STAT_SNMPINBADCOMMUNITYUSES         13
00624 #define  STAT_SNMPINASNPARSEERRS             14
00625     /*
00626      * #define  STAT_SNMPINBADTYPES              15 
00627      */
00628 #define  STAT_SNMPINTOOBIGS                  16
00629 #define  STAT_SNMPINNOSUCHNAMES              17
00630 #define  STAT_SNMPINBADVALUES                18
00631 #define  STAT_SNMPINREADONLYS                19
00632 #define  STAT_SNMPINGENERRS                  20
00633 #define  STAT_SNMPINTOTALREQVARS             21
00634 #define  STAT_SNMPINTOTALSETVARS             22
00635 #define  STAT_SNMPINGETREQUESTS              23
00636 #define  STAT_SNMPINGETNEXTS                 24
00637 #define  STAT_SNMPINSETREQUESTS              25
00638 #define  STAT_SNMPINGETRESPONSES             26
00639 #define  STAT_SNMPINTRAPS                    27
00640 #define  STAT_SNMPOUTTOOBIGS                 28
00641 #define  STAT_SNMPOUTNOSUCHNAMES             29
00642 #define  STAT_SNMPOUTBADVALUES               30
00643     /*
00644      * #define  STAT_SNMPOUTREADONLYS            31 
00645      */
00646 #define  STAT_SNMPOUTGENERRS                 32
00647 #define  STAT_SNMPOUTGETREQUESTS             33
00648 #define  STAT_SNMPOUTGETNEXTS                34
00649 #define  STAT_SNMPOUTSETREQUESTS             35
00650 #define  STAT_SNMPOUTGETRESPONSES            36
00651 #define  STAT_SNMPOUTTRAPS                   37
00652     /*
00653      * AUTHTRAPENABLE                            38 
00654      */
00655 #define  STAT_SNMPSILENTDROPS                39
00656 #define  STAT_SNMPPROXYDROPS                 40
00657 #define  STAT_SNMP_STATS_START               STAT_SNMPINPKTS
00658 #define  STAT_SNMP_STATS_END                 STAT_SNMPPROXYDROPS
00659 
00660     /*
00661      * target mib counters 
00662      */
00663 #define  STAT_SNMPUNAVAILABLECONTEXTS        41
00664 #define  STAT_SNMPUNKNOWNCONTEXTS            42
00665 #define  STAT_TARGET_STATS_START             STAT_SNMPUNAVAILABLECONTEXTS
00666 #define  STAT_TARGET_STATS_END               STAT_SNMPUNKNOWNCONTEXTS
00667 
00668     /*
00669      * TSM counters
00670      */
00671 #define  STAT_TSM_SNMPTSMINVALIDCACHES             43
00672 #define  STAT_TSM_SNMPTSMINADEQUATESECURITYLEVELS  44
00673 #define  STAT_TSM_SNMPTSMUNKNOWNPREFIXES           45
00674 #define  STAT_TSM_SNMPTSMINVALIDPREFIXES           46
00675 #define  STAT_TSM_STATS_START                 STAT_TSM_SNMPTSMINVALIDCACHES
00676 #define  STAT_TSM_STATS_END                   STAT_TSM_SNMPTSMINVALIDPREFIXES
00677 
00678     /*
00679      * TLSTM counters
00680      */
00681 #define  STAT_TLSTM_SNMPTLSTMSESSIONOPENS                      47
00682 #define  STAT_TLSTM_SNMPTLSTMSESSIONCLIENTCLOSES               48
00683 #define  STAT_TLSTM_SNMPTLSTMSESSIONOPENERRORS                 49
00684 #define  STAT_TLSTM_SNMPTLSTMSESSIONACCEPTS                    50
00685 #define  STAT_TLSTM_SNMPTLSTMSESSIONSERVERCLOSES               51
00686 #define  STAT_TLSTM_SNMPTLSTMSESSIONNOSESSIONS                 52
00687 #define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCLIENTCERTIFICATES  53
00688 #define  STAT_TLSTM_SNMPTLSTMSESSIONUNKNOWNSERVERCERTIFICATE   54
00689 #define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDSERVERCERTIFICATES  55
00690 #define  STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES              56
00691 
00692 #define  STAT_TLSTM_STATS_START                 STAT_TLSTM_SNMPTLSTMSESSIONOPENS
00693 #define  STAT_TLSTM_STATS_END          STAT_TLSTM_SNMPTLSTMSESSIONINVALIDCACHES
00694 
00695     /* this previously was end+1; don't know why the +1 is needed;
00696        XXX: check the code */
00697 #define  NETSNMP_STAT_MAX_STATS              (STAT_TLSTM_STATS_END+1)
00698 
00699 #define MAX_STATS NETSNMP_STAT_MAX_STATS
00700 
00701     /*
00702      * Internal: The list of active/open sessions.
00703      */
00704     struct session_list {
00705        struct session_list *next;
00706        netsnmp_session *session;
00707        netsnmp_transport *transport;
00708        struct snmp_internal_session *internal;
00709     };
00710 
00711 #ifdef __cplusplus
00712 }
00713 #endif
00714 #endif                          /* SNMP_API_H */