/* #include */ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef struct FILE FILE; typedef unsigned long fd_set; typedef unsigned long size_t; #include /* #if TIME_WITH_SYS_TIME */ /* # include */ /* # include */ /* #else */ /* # if HAVE_SYS_TIME_H */ /* # include */ /* # else */ /* # include */ /* # endif */ /* #endif */ typedef struct timeval timeval; typedef struct netsnmp_large_fd_set_s { unsigned lfs_setsize; fd_set *lfs_setptr; fd_set lfs_set; } netsnmp_large_fd_set; typedef u_long oid; typedef union { long *integer; u_char *string; oid *objid; u_char *bitstring; struct counter64 *counter64; #ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES float *floatVal; double *doubleVal; /* * t_union *unionVal; */ #endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */ } netsnmp_vardata; #define MAX_OID_LEN 128 /* max subid's in an oid */ /** @typedef struct variable_list netsnmp_variable_list * Typedefs the variable_list struct into netsnmp_variable_list */ /** @struct variable_list * The netsnmp variable list binding structure, it's typedef'd to * netsnmp_variable_list. */ typedef struct variable_list { /** NULL for last variable */ struct variable_list *next_variable; /** Object identifier of variable */ oid *name; /** number of subid's in name */ size_t name_length; /** ASN type of variable */ u_char type; /** value of variable */ netsnmp_vardata val; /** the length of the value to be copied into buf */ size_t val_len; /** buffer to hold the OID */ oid name_loc[MAX_OID_LEN]; /** 90 percentile < 40. */ u_char buf[40]; /** (Opaque) hook for additional data */ void *data; /** callback to free above */ void (*dataFreeHook)(void *); int index; } netsnmp_variable_list; /** @typedef struct snmp_pdu to netsnmp_pdu * Typedefs the snmp_pdu struct into netsnmp_pdu */ /** @struct snmp_pdu * The snmp protocol data unit. */ typedef struct snmp_pdu { #define non_repeaters errstat #define max_repetitions errindex /* * Protocol-version independent fields */ /** snmp version */ long version; /** Type of this PDU */ int command; /** Request id - note: not incremented on retries */ long reqid; /** Message id for V3 messages note: incremented for each retry */ long msgid; /** Unique ID for incoming transactions */ long transid; /** Session id for AgentX messages */ long sessid; /** Error status (non_repeaters in GetBulk) */ long errstat; /** Error index (max_repetitions in GetBulk) */ long errindex; /** Uptime */ u_long time; u_long flags; int securityModel; /** noAuthNoPriv, authNoPriv, authPriv */ int securityLevel; int msgParseModel; /** * Transport-specific opaque data. This replaces the IP-centric address * field. */ void *transport_data; int transport_data_length; /** * The actual transport domain. This SHOULD NOT BE FREE()D. */ const oid *tDomain; size_t tDomainLen; netsnmp_variable_list *variables; /* * SNMPv1 & SNMPv2c fields */ /** community for outgoing requests. */ u_char *community; /** length of community name. */ size_t community_len; /* * Trap information */ /** System OID */ oid *enterprise; size_t enterprise_length; /** trap type */ long trap_type; /** specific type */ long specific_type; /** This is ONLY used for v1 TRAPs */ unsigned char agent_addr[4]; /* * SNMPv3 fields */ /** context snmpEngineID */ u_char *contextEngineID; /** Length of contextEngineID */ size_t contextEngineIDLen; /** authoritative contextName */ char *contextName; /** Length of contextName */ size_t contextNameLen; /** authoritative snmpEngineID for security */ u_char *securityEngineID; /** Length of securityEngineID */ size_t securityEngineIDLen; /** on behalf of this principal */ char *securityName; /** Length of securityName. */ size_t securityNameLen; /* * AgentX fields * (also uses SNMPv1 community field) */ int priority; int range_subid; void *securityStateRef; } netsnmp_pdu; /* #include */ /** @typedef struct snmp_session netsnmp_session * Typedefs the snmp_session struct intonetsnmp_session */ struct snmp_session; typedef struct snmp_session netsnmp_session; #define USM_AUTH_KU_LEN 32 #define USM_PRIV_KU_LEN 32 typedef int (*snmp_callback) (int, netsnmp_session *, int, netsnmp_pdu *, void *); typedef int (*netsnmp_callback) (int, netsnmp_session *, int, netsnmp_pdu *, void *); struct netsnmp_container_s; /** @struct snmp_session * The snmp session structure. */ struct snmp_session { /* * Protocol-version independent fields */ /** snmp version */ long version; /** Number of retries before timeout. */ int retries; /** Number of uS until first timeout, then exponential backoff */ long timeout; u_long flags; struct snmp_session *subsession; struct snmp_session *next; /** name or address of default peer (may include transport specifier and/or port number) */ char *peername; /** UDP port number of peer. (NO LONGER USED - USE peername INSTEAD) */ u_short remote_port; /** My Domain name or dotted IP address, 0 for default */ char *localname; /** My UDP port number, 0 for default, picked randomly */ u_short local_port; /** * Authentication function or NULL if null authentication is used */ u_char *(*authenticator) (u_char *, size_t *, u_char *, size_t); /** Function to interpret incoming data */ netsnmp_callback callback; /** * Pointer to data that the callback function may consider important */ void *callback_magic; /** copy of system errno */ int s_errno; /** copy of library errno */ int s_snmp_errno; /** Session id - AgentX only */ long sessid; /* * SNMPv1 & SNMPv2c fields */ /** community for outgoing requests. */ u_char *community; /** Length of community name. */ size_t community_len; /** Largest message to try to receive. */ size_t rcvMsgMaxSize; /** Largest message to try to send. */ size_t sndMsgMaxSize; /* * SNMPv3 fields */ /** are we the authoritative engine? */ u_char isAuthoritative; /** authoritative snmpEngineID */ u_char *contextEngineID; /** Length of contextEngineID */ size_t contextEngineIDLen; /** initial engineBoots for remote engine */ u_int engineBoots; /** initial engineTime for remote engine */ u_int engineTime; /** authoritative contextName */ char *contextName; /** Length of contextName */ size_t contextNameLen; /** authoritative snmpEngineID */ u_char *securityEngineID; /** Length of contextEngineID */ size_t securityEngineIDLen; /** on behalf of this principal */ char *securityName; /** Length of securityName. */ size_t securityNameLen; /** auth protocol oid */ oid *securityAuthProto; /** Length of auth protocol oid */ size_t securityAuthProtoLen; /** Ku for auth protocol XXX */ u_char securityAuthKey[USM_AUTH_KU_LEN]; /** Length of Ku for auth protocol */ size_t securityAuthKeyLen; /** Kul for auth protocol */ u_char *securityAuthLocalKey; /** Length of Kul for auth protocol XXX */ size_t securityAuthLocalKeyLen; /** priv protocol oid */ oid *securityPrivProto; /** Length of priv protocol oid */ size_t securityPrivProtoLen; /** Ku for privacy protocol XXX */ u_char securityPrivKey[USM_PRIV_KU_LEN]; /** Length of Ku for priv protocol */ size_t securityPrivKeyLen; /** Kul for priv protocol */ u_char *securityPrivLocalKey; /** Length of Kul for priv protocol XXX */ size_t securityPrivLocalKeyLen; /** snmp security model, v1, v2c, usm */ int securityModel; /** noAuthNoPriv, authNoPriv, authPriv */ int securityLevel; /** target param name */ char *paramName; /** * security module specific */ void *securityInfo; /** * transport specific configuration */ struct netsnmp_container_s *transport_configuration; /** * use as you want data * * used by 'SNMP_FLAGS_RESP_CALLBACK' handling in the agent * XXX: or should we add a new field into this structure? */ void *myvoid; }; // snmp sess NETSNMP_IMPORT void snmp_sess_init(netsnmp_session *); /* * netsnmp_session *snmp_open(session) * netsnmp_session *session; * * Sets up the session with the snmp_session information provided * by the user. Then opens and binds the necessary UDP port. * A handle to the created session is returned (this is different than * the pointer passed to snmp_open()). On any error, NULL is returned * and snmp_errno is set to the appropriate error code. */ NETSNMP_IMPORT netsnmp_session *snmp_open(netsnmp_session *); /* * int snmp_close(session) * netsnmp_session *session; * * Close the input session. Frees all data allocated for the session, * dequeues any pending requests, and closes any sockets allocated for * the session. Returns 0 on error, 1 otherwise. * * snmp_close_sessions() does the same thing for all open sessions */ NETSNMP_IMPORT int snmp_close(netsnmp_session *); NETSNMP_IMPORT int snmp_close_sessions(void); /* * int snmp_send(session, pdu) * netsnmp_session *session; * netsnmp_pdu *pdu; * * Sends the input pdu on the session after calling snmp_build to create * a serialized packet. If necessary, set some of the pdu data from the * session defaults. Add a request corresponding to this pdu to the list * of outstanding requests on this session, then send the pdu. * Returns the request id of the generated packet if applicable, otherwise 1. * On any error, 0 is returned. * The pdu is freed by snmp_send() unless a failure occured. */ NETSNMP_IMPORT int snmp_send(netsnmp_session *, netsnmp_pdu *); /* * int snmp_async_send(session, pdu, callback, cb_data) * netsnmp_session *session; * netsnmp_pdu *pdu; * netsnmp_callback callback; * void *cb_data; * * Sends the input pdu on the session after calling snmp_build to create * a serialized packet. If necessary, set some of the pdu data from the * session defaults. Add a request corresponding to this pdu to the list * of outstanding requests on this session and store callback and data, * then send the pdu. * Returns the request id of the generated packet if applicable, otherwise 1. * On any error, 0 is returned. * The pdu is freed by snmp_send() unless a failure occured. */ NETSNMP_IMPORT int snmp_async_send(netsnmp_session *, netsnmp_pdu *, netsnmp_callback, void *); /* * void snmp_read(fdset) * fd_set *fdset; * * Checks to see if any of the fd's set in the fdset belong to * snmp. Each socket with it's fd set has a packet read from it * and snmp_parse is called on the packet received. The resulting pdu * is passed to the callback routine for that session. If the callback * routine returns successfully, the pdu and it's request are deleted. */ NETSNMP_IMPORT void snmp_read(fd_set *); /* * snmp_read2() is similar to snmp_read(), but accepts a pointer to a * large file descriptor set instead of a pointer to a regular file * descriptor set. */ NETSNMP_IMPORT void snmp_read2(netsnmp_large_fd_set *); NETSNMP_IMPORT int snmp_synch_response(netsnmp_session *, netsnmp_pdu *, netsnmp_pdu **); /* * int snmp_select_info(numfds, fdset, timeout, block) * int *numfds; * fd_set *fdset; * struct timeval *timeout; * int *block; * * Returns info about what snmp requires from a select statement. * numfds is the number of fds in the list that are significant. * All file descriptors opened for SNMP are OR'd into the fdset. * If activity occurs on any of these file descriptors, snmp_read * should be called with that file descriptor set. * * The timeout is the latest time that SNMP can wait for a timeout. The * select should be done with the minimum time between timeout and any other * timeouts necessary. This should be checked upon each invocation of select. * If a timeout is received, snmp_timeout should be called to check if the * timeout was for SNMP. (snmp_timeout is idempotent) * * Block is 1 if the select is requested to block indefinitely, rather than * time out. If block is input as 1, the timeout value will be treated as * undefined, but it must be available for setting in snmp_select_info. On * return, if block is true, the value of timeout will be undefined. * * snmp_select_info returns the number of open sockets. (i.e. The number * of sessions open) */ NETSNMP_IMPORT int snmp_select_info(int *, fd_set *, struct timeval *, int *); /* * snmp_select_info2() is similar to snmp_select_info(), but accepts a * pointer to a large file descriptor set instead of a pointer to a * regular file descriptor set. */ NETSNMP_IMPORT int snmp_select_info2(int *, netsnmp_large_fd_set *, struct timeval *, int *); #define NETSNMP_SELECT_NOFLAGS 0x00 #define NETSNMP_SELECT_NOALARMS 0x01 NETSNMP_IMPORT int snmp_sess_select_info_flags(void *, int *, fd_set *, struct timeval *, int *, int); int snmp_sess_select_info2_flags(void *, int *, netsnmp_large_fd_set *, struct timeval *, int *, int); /* * void snmp_timeout(); * * snmp_timeout should be called whenever the timeout from snmp_select_info * expires, but it is idempotent, so snmp_timeout can be polled (probably a * cpu expensive proposition). snmp_timeout checks to see if any of the * sessions have an outstanding request that has timed out. If it finds one * (or more), and that pdu has more retries available, a new packet is formed * from the pdu and is resent. If there are no more retries available, the * callback for the session is used to alert the user of the timeout. */ NETSNMP_IMPORT void snmp_timeout(void); /* * single session API. * * These functions perform similar actions as snmp_XX functions, * but operate on a single session only. * * Synopsis: void * sessp; netsnmp_session session, *ss; netsnmp_pdu *pdu, *response; snmp_sess_init(&session); session.retries = ... session.remote_port = ... sessp = snmp_sess_open(&session); ss = snmp_sess_session(sessp); if (ss == NULL) exit(1); ... if (ss->community) free(ss->community); ss->community = strdup(gateway); ss->community_len = strlen(gateway); ... snmp_sess_synch_response(sessp, pdu, &response); ... snmp_sess_close(sessp); * See also: * snmp_sess_synch_response, in snmp_client.h. * Notes: * 1. Invoke snmp_sess_session after snmp_sess_open. * 2. snmp_sess_session return value is an opaque pointer. * 3. Do NOT free memory returned by snmp_sess_session. * 4. Replace snmp_send(ss,pdu) with snmp_sess_send(sessp,pdu) */ NETSNMP_IMPORT void *snmp_sess_open(netsnmp_session *); NETSNMP_IMPORT void *snmp_sess_pointer(netsnmp_session *); NETSNMP_IMPORT netsnmp_session *snmp_sess_session(void *); NETSNMP_IMPORT netsnmp_session *snmp_sess_session_lookup(void *); /* * use return value from snmp_sess_open as void * parameter */ NETSNMP_IMPORT int snmp_sess_send(void *, netsnmp_pdu *); NETSNMP_IMPORT int snmp_sess_async_send(void *, netsnmp_pdu *, netsnmp_callback, void *); NETSNMP_IMPORT int snmp_sess_select_info(void *, int *, fd_set *, struct timeval *, int *); NETSNMP_IMPORT int snmp_sess_select_info2(void *, int *, netsnmp_large_fd_set *, struct timeval *, int *); /* * Returns 0 if success, -1 if fail. */ NETSNMP_IMPORT int snmp_sess_read(void *, fd_set *); /* * Similar to snmp_sess_read(), but accepts a pointer to a large file * descriptor set instead of a pointer to a file descriptor set. */ NETSNMP_IMPORT int snmp_sess_read2(void *, netsnmp_large_fd_set *); NETSNMP_IMPORT void snmp_sess_timeout(void *); NETSNMP_IMPORT int snmp_sess_close(void *); NETSNMP_IMPORT int snmp_sess_synch_response(void *, netsnmp_pdu *, netsnmp_pdu **); /* #include */ NETSNMP_IMPORT netsnmp_pdu *snmp_pdu_create(int type); NETSNMP_IMPORT netsnmp_pdu *snmp_clone_pdu(netsnmp_pdu *pdu); NETSNMP_IMPORT netsnmp_pdu *snmp_fix_pdu( netsnmp_pdu *pdu, int idx); NETSNMP_IMPORT void snmp_free_pdu( netsnmp_pdu *pdu); /* #include */ /* Initialisation and Shutdown */ NETSNMP_IMPORT int add_mibdir(const char *); NETSNMP_IMPORT void netsnmp_init_mib(void); #ifndef NETSNMP_NO_LEGACY_DEFINITIONS NETSNMP_IMPORT void init_mib(void); NETSNMP_IMPORT void init_mib_internals(void); #endif NETSNMP_IMPORT void shutdown_mib(void); /* Reading and Parsing MIBs */ NETSNMP_IMPORT struct tree *netsnmp_read_module(const char *); #ifndef NETSNMP_NO_LEGACY_DEFINITIONS NETSNMP_IMPORT struct tree *read_module(const char *); #endif NETSNMP_IMPORT struct tree *read_mib(const char *); NETSNMP_IMPORT struct tree *read_all_mibs(void); NETSNMP_IMPORT void add_module_replacement(const char *, const char *, const char *, int); /* from ucd-compat.h */ NETSNMP_IMPORT void snmp_set_mib_warnings(int); NETSNMP_IMPORT void snmp_set_mib_errors(int); NETSNMP_IMPORT void snmp_set_save_descriptions(int); /* Searching the MIB Tree */ NETSNMP_IMPORT int read_objid(const char *, oid *, size_t *); NETSNMP_IMPORT oid *snmp_parse_oid(const char *, oid *, size_t *); NETSNMP_IMPORT int get_module_node(const char *, const char *, oid *, size_t *); /* Output */ NETSNMP_IMPORT void print_mib(FILE * fp); NETSNMP_IMPORT void print_objid(const oid * objid, size_t objidlen); NETSNMP_IMPORT void fprint_objid(FILE * fp, const oid * objid, size_t objidlen); NETSNMP_IMPORT int snprint_objid(char *buf, size_t buf_len, const oid * objid, size_t objidlen); NETSNMP_IMPORT void print_description(oid * objid, size_t objidlen, int width); NETSNMP_IMPORT void fprint_description(FILE * fp, oid * objid, size_t objidlen, int width); NETSNMP_IMPORT int snprint_description(char *buf, size_t buf_len, oid * objid, size_t objidlen, int width); /* #include */ /* Creation */ NETSNMP_IMPORT netsnmp_variable_list * snmp_pdu_add_variable(netsnmp_pdu *pdu, const oid * name, size_t name_length, u_char type, const void * value, size_t len); NETSNMP_IMPORT netsnmp_variable_list * snmp_varlist_add_variable(netsnmp_variable_list ** varlist, const oid * name, size_t name_length, u_char type, const void * value, size_t len); NETSNMP_IMPORT netsnmp_variable_list * snmp_add_null_var(netsnmp_pdu *pdu, const oid * name, size_t name_length); NETSNMP_IMPORT netsnmp_variable_list * snmp_clone_varbind(netsnmp_variable_list * varlist); /* Setting Values */ NETSNMP_IMPORT int snmp_set_var_objid(netsnmp_variable_list * var, const oid * name, size_t name_length); NETSNMP_IMPORT int snmp_set_var_value(netsnmp_variable_list * var, const void * value, size_t len); NETSNMP_IMPORT int snmp_set_var_typed_value(netsnmp_variable_list * var, u_char type, const void * value, size_t len); NETSNMP_IMPORT int snmp_set_var_typed_integer(netsnmp_variable_list * var, u_char type, long val); /* Output */ NETSNMP_IMPORT void print_variable(const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); NETSNMP_IMPORT void fprint_variable(FILE * fp, const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); NETSNMP_IMPORT int snprint_variable(char *buf, size_t buf_len, const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); NETSNMP_IMPORT void print_value(const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); NETSNMP_IMPORT void fprint_value(FILE * fp, const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); NETSNMP_IMPORT int snprint_value(char *buf, size_t buf_len, const oid * objid, size_t objidlen, const netsnmp_variable_list * variable); /* See mib_api.h for {,f,sn}print_objid */ /* Deletion */ NETSNMP_IMPORT void snmp_free_var( netsnmp_variable_list *var); /* frees just this one */ NETSNMP_IMPORT void snmp_free_varbind(netsnmp_variable_list *varlist); /* frees all in list */ /* #include */ /* Config Handlers */ NETSNMP_IMPORT struct config_line *register_config_handler(const char *filePrefix, const char *token, void (*parser) (const char *, char *), void (*releaser) (void), const char *usageLine); NETSNMP_IMPORT struct config_line *register_const_config_handler(const char *filePrefix, const char *token, void (*parser) (const char *, const char *), void (*releaser) (void), const char *usageLine); NETSNMP_IMPORT struct config_line *register_prenetsnmp_mib_handler(const char *filePrefix, const char *token, void (*parser) (const char *, char *), void (*releaser) (void), const char *usageLine); NETSNMP_IMPORT void unregister_config_handler(const char *filePrefix, const char *token); /* Defined in mib.c, rather than read_config.c */ void register_mib_handlers(void); void unregister_all_config_handlers(void); /* Application Handlers */ NETSNMP_IMPORT struct config_line *register_app_config_handler( const char *token, void (*parser) (const char *, char *), void (*releaser) (void), const char *usageLine); NETSNMP_IMPORT struct config_line *register_app_prenetsnmp_mib_handler( const char *token, void (*parser) (const char *, char *), void (*releaser) (void), const char *usageLine); NETSNMP_IMPORT void unregister_app_config_handler( const char *token); /* Reading Config Files */ NETSNMP_IMPORT void read_configs(void); NETSNMP_IMPORT void read_premib_configs(void); /* Help Strings and Errors */ NETSNMP_IMPORT void read_config_print_usage(const char *lead); NETSNMP_IMPORT void config_perror(const char *); NETSNMP_IMPORT void config_pwarn(const char *); /* #include */ /* Error reporting */ NETSNMP_IMPORT void snmp_error(netsnmp_session *sess, int *clib_errorno, int *snmp_errorno, char **errstring); NETSNMP_IMPORT void snmp_sess_error( void *sess, int *clib_errorno, int *snmp_errorno, char **errstring); NETSNMP_IMPORT const char *snmp_api_errstring(int snmp_errorno); /* library errors */ NETSNMP_IMPORT const char *snmp_errstring(int snmp_errorno); /* protocol errors */ NETSNMP_IMPORT void snmp_perror(const char *msg); /* for parsing errors only */ NETSNMP_IMPORT void snmp_sess_perror(const char *msg, netsnmp_session *sess); /* for all other SNMP library errors */ NETSNMP_IMPORT void snmp_log_perror(const char *msg); /* for system library errors */ #define _LOG_ATTR __attribute__ ((__format__ (__printf__, 2, 3))) NETSNMP_IMPORT int snmp_log( int priority, const char *format, ...) _LOG_ATTR; NETSNMP_IMPORT int snmp_get_do_logging( void); NETSNMP_IMPORT void netsnmp_logging_restart(void); NETSNMP_IMPORT void snmp_disable_log( void); NETSNMP_IMPORT void shutdown_snmp_logging( void); /* #include */ /* #include */ /* * General purpose memory allocation functions. Use these functions to * allocate memory that may be reallocated or freed by the Net-SNMP * library or to reallocate or free memory that has been allocated by the * Net-SNMP library, and when working in a context where there is more than * one heap. Examples are: * - Perl XSUB's. * - MSVC or MinGW with the Net-SNMP library compiled as a DLL instead of * a static library. */ NETSNMP_IMPORT void *netsnmp_malloc(size_t size); NETSNMP_IMPORT void *netsnmp_calloc(size_t nelem, size_t elsize); NETSNMP_IMPORT void *netsnmp_realloc(void *ptr, size_t size); NETSNMP_IMPORT void netsnmp_free(void *ptr); NETSNMP_IMPORT char *netsnmp_strdup(const char *s1); /* * void * snmp_free_pdu(pdu) * netsnmp_pdu *pdu; * * Frees the pdu and any malloc'd data associated with it. */ NETSNMP_IMPORT void snmp_free_var_internals(netsnmp_variable_list *); /* frees contents only */ NETSNMP_IMPORT long snmp_get_next_msgid(void); NETSNMP_IMPORT long snmp_get_next_reqid(void); NETSNMP_IMPORT long snmp_get_next_sessid(void); NETSNMP_IMPORT long snmp_get_next_transid(void); NETSNMP_IMPORT int snmp_oid_compare(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int snmp_oid_ncompare(const oid *, size_t, const oid *, size_t, size_t); NETSNMP_IMPORT int snmp_oidtree_compare(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int snmp_oidsubtree_compare(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int netsnmp_oid_compare_ll(const oid * in_name1, size_t len1, const oid * in_name2, size_t len2, size_t *offpt); NETSNMP_IMPORT int netsnmp_oid_equals(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int netsnmp_oid_tree_equals(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int netsnmp_oid_is_subtree(const oid *, size_t, const oid *, size_t); NETSNMP_IMPORT int netsnmp_oid_find_prefix(const oid * in_name1, size_t len1, const oid * in_name2, size_t len2); NETSNMP_IMPORT void init_snmp(const char *); NETSNMP_IMPORT u_char *snmp_pdu_build(netsnmp_pdu *, u_char *, size_t *); #ifdef NETSNMP_USE_REVERSE_ASNENCODING NETSNMP_IMPORT u_char *snmp_pdu_rbuild(netsnmp_pdu *, u_char *, size_t *); #endif NETSNMP_IMPORT int snmpv3_parse(netsnmp_pdu *, u_char *, size_t *, u_char **, netsnmp_session *); NETSNMP_IMPORT int snmpv3_packet_build(netsnmp_session *, netsnmp_pdu *pdu, u_char * packet, size_t * out_length, u_char * pdu_data, size_t pdu_data_len); NETSNMP_IMPORT int snmpv3_packet_rbuild(netsnmp_session *, netsnmp_pdu *pdu, u_char * packet, size_t * out_length, u_char * pdu_data, size_t pdu_data_len); NETSNMP_IMPORT int snmpv3_make_report(netsnmp_pdu *pdu, int error); NETSNMP_IMPORT int snmpv3_get_report_type(netsnmp_pdu *pdu); NETSNMP_IMPORT int snmp_pdu_parse(netsnmp_pdu *pdu, u_char * data, size_t * length); NETSNMP_IMPORT u_char *snmpv3_scopedPDU_parse(netsnmp_pdu *pdu, u_char * cp, size_t * length); NETSNMP_IMPORT void snmp_store_needed(const char *type); NETSNMP_IMPORT void snmp_store_if_needed(void); NETSNMP_IMPORT void snmp_store(const char *type); NETSNMP_IMPORT void snmp_shutdown(const char *type); NETSNMP_IMPORT int snmp_add_var(netsnmp_pdu *, const oid *, size_t, char, const char *); NETSNMP_IMPORT oid *snmp_duplicate_objid(const oid * objToCopy, size_t); NETSNMP_IMPORT int create_user_from_session(netsnmp_session * session); NETSNMP_IMPORT int snmpv3_probe_contextEngineID_rfc5343(void *slp, netsnmp_session *session); NETSNMP_IMPORT int snmpv3_packet_realloc_rbuild(u_char ** pkt, size_t * pkt_len, size_t * offset, netsnmp_session * session, netsnmp_pdu *pdu, u_char * pdu_data, size_t pdu_data_len); NETSNMP_IMPORT int snmp_pdu_realloc_rbuild(u_char ** pkt, size_t * pkt_len, size_t * offset, netsnmp_pdu *pdu); NETSNMP_IMPORT netsnmp_session *snmp_open_ex(netsnmp_session *, int (*fpre_parse) (netsnmp_session *, struct netsnmp_transport_s *, void *, int), int (*fparse) (netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int (*fpost_parse) (netsnmp_session *, netsnmp_pdu *, int), int (*fbuild) (netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int (*frbuild) (netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int (*fcheck) (u_char *, size_t)); /* * provided for backwards compatability. Don't use these functions. * See snmp_debug.h and snmp_debug.c instead. */ NETSNMP_IMPORT void snmp_set_do_debugging(int); NETSNMP_IMPORT int snmp_get_do_debugging(void); NETSNMP_IMPORT void netsnmp_sess_log_error(int priority, const char *prog_string, netsnmp_session * ss); NETSNMP_IMPORT const char * snmp_pdu_type(int type); /* * Return the netsnmp_transport structure associated with the given opaque * pointer. */ NETSNMP_IMPORT struct netsnmp_transport_s *snmp_sess_transport(void *); NETSNMP_IMPORT void snmp_sess_transport_set(void *, struct netsnmp_transport_s *); NETSNMP_IMPORT int netsnmp_sess_config_transport(struct netsnmp_container_s *transport_configuration, struct netsnmp_transport_s *transport); NETSNMP_IMPORT int netsnmp_sess_config_and_open_transport(netsnmp_session *in_session, struct netsnmp_transport_s *transport); /* * EXTENDED SESSION API ------------------------------------------ * * snmp_sess_add_ex, snmp_sess_add, snmp_add * * Analogous to snmp_open family of functions, but taking an * netsnmp_transport pointer as an extra argument. Unlike snmp_open et * al. it doesn't attempt to interpret the in_session->peername as a * transport endpoint specifier, but instead uses the supplied transport. * JBPN * */ NETSNMP_IMPORT void *snmp_sess_add_ex(netsnmp_session *, struct netsnmp_transport_s *, int (*fpre_parse) (netsnmp_session *, struct netsnmp_transport_s *, void *, int), int (*fparse) (netsnmp_session *, struct snmp_pdu *, u_char *, size_t), int (*fpost_parse) (netsnmp_session *, struct snmp_pdu *, int), int (*fbuild) (netsnmp_session *, struct snmp_pdu *, u_char *, size_t *), int (*frbuild) (netsnmp_session *, struct snmp_pdu *, u_char **, size_t *, size_t *), int (*fcheck) (u_char *, size_t), netsnmp_pdu *(*fcreate_pdu) (struct netsnmp_transport_s *, void *, size_t)); NETSNMP_IMPORT void *snmp_sess_add(netsnmp_session *, struct netsnmp_transport_s *, int (*fpre_parse) (netsnmp_session *, struct netsnmp_transport_s *, void *, int), int (*fpost_parse) (netsnmp_session *, netsnmp_pdu *, int)); NETSNMP_IMPORT netsnmp_session *snmp_add(netsnmp_session *, struct netsnmp_transport_s *, int (*fpre_parse) (netsnmp_session *, struct netsnmp_transport_s *, void *, int), int (*fpost_parse) (netsnmp_session *, netsnmp_pdu *, int)); NETSNMP_IMPORT netsnmp_session *snmp_add_full(netsnmp_session * in_session, struct netsnmp_transport_s *transport, int (*fpre_parse) (netsnmp_session *, struct netsnmp_transport_s *, void *, int), int (*fparse) (netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int (*fpost_parse) (netsnmp_session *, netsnmp_pdu *, int), int (*fbuild) (netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int (*frbuild) (netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int (*fcheck) (u_char *, size_t), netsnmp_pdu *(*fcreate_pdu) (struct netsnmp_transport_s *, void *, size_t) ); /* #include */ typedef int (SNMPCallback) (int majorID, int minorID, void *serverarg, void *clientarg); struct snmp_gen_callback { SNMPCallback *sc_callback; void *sc_client_arg; int priority; struct snmp_gen_callback *next; }; /* * function prototypes */ NETSNMP_IMPORT void init_callbacks(void); NETSNMP_IMPORT int netsnmp_register_callback(int major, int minor, SNMPCallback * new_callback, void *arg, int priority); NETSNMP_IMPORT int snmp_register_callback(int major, int minor, SNMPCallback * new_callback, void *arg); NETSNMP_IMPORT int snmp_call_callbacks(int major, int minor, void *caller_arg); NETSNMP_IMPORT int snmp_callback_available(int major, int minor); /* is >1 available */ NETSNMP_IMPORT int snmp_count_callbacks(int major, int minor); /* ret the number registered */ NETSNMP_IMPORT int snmp_unregister_callback(int major, int minor, SNMPCallback * new_callback, void *arg, int matchargs); NETSNMP_IMPORT void clear_callback (void); int netsnmp_callback_clear_client_arg(void *, int i, int j); struct snmp_gen_callback *snmp_callback_list(int major, int minor); /* #include */ NETSNMP_IMPORT int setup_engineID(u_char ** eidp, const char *text); void engineID_conf(const char *word, char *cptr); void engineBoots_conf(const char *, char *); void engineIDType_conf(const char *, char *); void engineIDNic_conf(const char *, char *); NETSNMP_IMPORT void init_snmpv3(const char *); int init_snmpv3_post_config(int majorid, int minorid, void *serverarg, void *clientarg); int init_snmpv3_post_premib_config(int majorid, int minorid, void *serverarg, void *clientarg); void shutdown_snmpv3(const char *type); int snmpv3_store(int majorID, int minorID, void *serverarg, void *clientarg); NETSNMP_IMPORT u_long snmpv3_local_snmpEngineBoots(void); int snmpv3_clone_engineID(u_char **, size_t *, u_char *, size_t); NETSNMP_IMPORT size_t snmpv3_get_engineID(u_char * buf, size_t buflen); NETSNMP_IMPORT u_char *snmpv3_generate_engineID(size_t *); NETSNMP_IMPORT u_long snmpv3_local_snmpEngineTime(void); int get_default_secLevel(void); void snmpv3_set_engineBootsAndTime(int boots, int ttime); int free_engineID(int majorid, int minorid, void *serverarg, void *clientarg); NETSNMP_IMPORT int parse_secLevel_conf(const char* word, char *cptr); /* #include */ NETSNMP_IMPORT oid usmNoAuthProtocol[10]; /* == { 1,3,6,1,6,3,10,1,1,1 }; */ #ifndef NETSNMP_DISABLE_MD5 NETSNMP_IMPORT oid usmHMACMD5AuthProtocol[10]; /* == { 1,3,6,1,6,3,10,1,1,2 }; */ #endif NETSNMP_IMPORT oid usmHMACSHA1AuthProtocol[10]; /* == { 1,3,6,1,6,3,10,1,1,3 }; */ NETSNMP_IMPORT oid usmNoPrivProtocol[10]; /* == { 1,3,6,1,6,3,10,1,2,1 }; */ #ifndef NETSNMP_DISABLE_DES NETSNMP_IMPORT oid usmDESPrivProtocol[10]; /* == { 1,3,6,1,6,3,10,1,2,2 }; */ #endif /* XXX: OIDs not defined yet */ NETSNMP_IMPORT oid usmAESPrivProtocol[10]; /* == { 1,3,6,1,6,3,10,1,2,4 }; */ NETSNMP_IMPORT oid *usmAES128PrivProtocol; /* backwards compat */ /* #include */ NETSNMP_IMPORT int generate_Ku(const oid * hashtype, u_int hashtype_len, const u_char * P, size_t pplen, u_char * Ku, size_t * kulen); NETSNMP_IMPORT int generate_kul(const oid * hashtype, u_int hashtype_len, const u_char * engineID, size_t engineID_len, const u_char * Ku, size_t ku_len, u_char * Kul, size_t * kul_len); NETSNMP_IMPORT int encode_keychange(const oid * hashtype, u_int hashtype_len, u_char * oldkey, size_t oldkey_len, u_char * newkey, size_t newkey_len, u_char * kcstring, size_t * kcstring_len); NETSNMP_IMPORT int decode_keychange(const oid * hashtype, u_int hashtype_len, u_char * oldkey, size_t oldkey_len, u_char * kcstring, size_t kcstring_len, u_char * newkey, size_t * newkey_len); /* #include */ /* * A linked list of tag-value pairs for enumerated integers. */ struct enum_list { struct enum_list *next; int value; char *label; }; /* * A linked list of ranges */ struct range_list { struct range_list *next; int low, high; }; /* * A linked list of indexes */ struct index_list { struct index_list *next; char *ilabel; char isimplied; }; /* * A linked list of varbinds */ struct varbind_list { struct varbind_list *next; char *vblabel; }; /* * A tree in the format of the tree structure of the MIB. */ struct tree { struct tree *child_list; /* list of children of this node */ struct tree *next_peer; /* Next node in list of peers */ struct tree *next; /* Next node in hashed list of names */ struct tree *parent; char *label; /* This node's textual name */ u_long subid; /* This node's integer subidentifier */ int modid; /* The module containing this node */ int number_modules; int *module_list; /* To handle multiple modules */ int tc_index; /* index into tclist (-1 if NA) */ int type; /* This node's object type */ int access; /* This nodes access */ int status; /* This nodes status */ struct enum_list *enums; /* (optional) list of enumerated integers */ struct range_list *ranges; struct index_list *indexes; char *augments; struct varbind_list *varbinds; char *hint; char *units; int (*printomat) (u_char **, size_t *, size_t *, int, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); void (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); /* Value printing function */ char *description; /* description (a quoted string) */ char *reference; /* references (a quoted string) */ int reported; /* 1=report started in print_subtree... */ char *defaultValue; }; /* * Information held about each MIB module */ struct module_import { char *label; /* The descriptor being imported */ int modid; /* The module imported from */ }; struct module { char *name; /* This module's name */ char *file; /* The file containing the module */ struct module_import *imports; /* List of descriptors being imported */ int no_imports; /* The number of such import descriptors */ /* * -1 implies the module hasn't been read in yet */ int modid; /* The index number of this module */ struct module *next; /* Linked list pointer */ }; struct module_compatability { const char *old_module; const char *new_module; const char *tag; /* NULL implies unconditional replacement, * otherwise node identifier or prefix */ size_t tag_len; /* 0 implies exact match (or unconditional) */ struct module_compatability *next; /* linked list */ }; /* * non-aggregate types for tree end nodes */ #define TYPE_OTHER 0 #define TYPE_OBJID 1 #define TYPE_OCTETSTR 2 #define TYPE_INTEGER 3 #define TYPE_NETADDR 4 #define TYPE_IPADDR 5 #define TYPE_COUNTER 6 #define TYPE_GAUGE 7 #define TYPE_TIMETICKS 8 #define TYPE_OPAQUE 9 #define TYPE_NULL 10 #define TYPE_COUNTER64 11 #define TYPE_BITSTRING 12 #define TYPE_NSAPADDRESS 13 #define TYPE_UINTEGER 14 #define TYPE_UNSIGNED32 15 #define TYPE_INTEGER32 16 #define TYPE_SIMPLE_LAST 16 #define TYPE_TRAPTYPE 20 #define TYPE_NOTIFTYPE 21 #define TYPE_OBJGROUP 22 #define TYPE_NOTIFGROUP 23 #define TYPE_MODID 24 #define TYPE_AGENTCAP 25 #define TYPE_MODCOMP 26 #define TYPE_OBJIDENTITY 27 #define MIB_ACCESS_READONLY 18 #define MIB_ACCESS_READWRITE 19 #define MIB_ACCESS_WRITEONLY 20 #define MIB_ACCESS_NOACCESS 21 #define MIB_ACCESS_NOTIFY 67 #define MIB_ACCESS_CREATE 48 #define MIB_STATUS_MANDATORY 23 #define MIB_STATUS_OPTIONAL 24 #define MIB_STATUS_OBSOLETE 25 #define MIB_STATUS_DEPRECATED 39 #define MIB_STATUS_CURRENT 57 #define ANON "anonymous#" #define ANON_LEN strlen(ANON) int netsnmp_unload_module(const char *name); #ifndef NETSNMP_NO_LEGACY_DEFINITIONS int unload_module(const char *name); #endif void netsnmp_init_mib_internals(void); void unload_all_mibs(void); int add_mibfile(const char*, const char*, FILE *); int which_module(const char *); NETSNMP_IMPORT char *module_name(int, char *); NETSNMP_IMPORT void print_subtree(FILE *, struct tree *, int); NETSNMP_IMPORT void print_ascii_dump_tree(FILE *, struct tree *, int); NETSNMP_IMPORT struct tree *find_tree_node(const char *, int); NETSNMP_IMPORT const char *get_tc_descriptor(int); NETSNMP_IMPORT const char *get_tc_description(int); NETSNMP_IMPORT struct tree *find_best_tree_node(const char *, struct tree *, u_int *); /* * backwards compatability */ NETSNMP_IMPORT struct tree *find_node(const char *, struct tree *); struct tree *find_node2(const char *, const char *); NETSNMP_IMPORT struct module *find_module(int); void adopt_orphans(void); NETSNMP_IMPORT char *snmp_mib_toggle_options(char *options); NETSNMP_IMPORT void snmp_mib_toggle_options_usage(const char *lead, FILE * outf); NETSNMP_IMPORT void print_mib(FILE *); NETSNMP_IMPORT void print_mib_tree(FILE *, struct tree *, int); int get_mib_parse_error_count(void); NETSNMP_IMPORT int snmp_get_token(FILE * fp, char *token, int maxtlen); NETSNMP_IMPORT struct tree *find_best_tree_node(const char *name, struct tree *tree_top, u_int * match); /* #include */ /* #include */ /* #include */ /* #include */