snmp_api.h

来自「eCos操作系统源码」· C头文件 代码 · 共 857 行 · 第 1/3 页

H
857
字号
void snmp_free_pdu (struct snmp_pdu *);void snmp_free_var (struct variable_list *);void snmp_free_varbind(struct variable_list *var);/* * 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) */int snmp_select_info (int *, fd_set *, struct timeval *, 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. */void snmp_timeout (void);/* * This routine must be supplied by the application: * * u_char *authenticator(pdu, length, community, community_len) * u_char *pdu;		The rest of the PDU to be authenticated * int *length;		The length of the PDU (updated by the authenticator) * u_char *community;	The community name to authenticate under. * int	community_len	The length of the community name. * * Returns the authenticated pdu, or NULL if authentication failed. * If null authentication is used, the authenticator in snmp_session can be * set to NULL(0). *//* * This routine must be supplied by the application: * * int callback(operation, session, reqid, pdu, magic) * int operation; * struct snmp_session *session;    The session authenticated under. * int reqid;			    The request id of this pdu (0 for TRAP) * struct snmp_pdu *pdu;	    The pdu information. * void *magic			    A link to the data for this routine. * * Returns 1 if request was successful, 0 if it should be kept pending. * Any data in the pdu must be copied because it will be freed elsewhere. * Operations are defined below: */#define RECEIVED_MESSAGE   1#define TIMED_OUT	   2long snmp_get_next_msgid(void);long snmp_get_next_reqid(void);long snmp_get_next_sessid(void);long snmp_get_next_transid(void);/* provide for backwards compatibility */void snmp_set_dump_packet(int);int snmp_get_dump_packet(void);void snmp_set_quick_print(int);int snmp_get_quick_print(void);void snmp_set_suffix_only(int);int snmp_get_suffix_only(void);void snmp_set_full_objid(int);int snmp_get_full_objid(void);void snmp_set_random_access(int);int snmp_get_random_access(void);int snmp_oid_compare (const oid *, size_t, const oid *, size_t);void init_snmp (const char *);u_char *snmp_pdu_build (struct snmp_pdu *, u_char *, size_t *);int snmpv3_parse(struct snmp_pdu *, u_char *, size_t *, u_char  **);int snmpv3_dparse(struct snmp_pdu *, u_char *, size_t *, u_char  **, int);int snmpv3_packet_build(struct snmp_pdu *pdu, u_char *packet, size_t *out_length, u_char *pdu_data, size_t pdu_data_len);int snmpv3_make_report(struct snmp_pdu *pdu, int error);int snmpv3_get_report_type(struct snmp_pdu *pdu);int snmp_pdu_parse(struct snmp_pdu *pdu, u_char *data, size_t *length);int snmp_pdu_dparse(struct snmp_pdu *pdu, u_char *data, size_t *length, int);u_char* snmpv3_scopedPDU_parse(struct snmp_pdu *pdu, u_char *cp, size_t *length);u_char* snmpv3_scopedPDU_dparse(struct snmp_pdu *pdu, u_char *cp, size_t *length, int);void snmp_shutdown(const char *type);struct variable_list *snmp_pdu_add_variable (struct snmp_pdu *, oid *, size_t, u_char, u_char *, size_t);struct variable_list *snmp_varlist_add_variable(struct variable_list **varlist,	oid *name, size_t name_length, u_char type, u_char *value, size_t len);int hex_to_binary (const char *, u_char *);int ascii_to_binary (const char *, u_char *);int snmp_add_var (struct snmp_pdu *, oid*, size_t, char, const char *);oid  *snmp_duplicate_objid(oid *objToCopy, size_t);u_int snmp_increment_statistic(int which);u_int snmp_increment_statistic_by(int which, int count);u_int snmp_get_statistic(int which);void  snmp_init_statistics(void);int create_user_from_session(struct snmp_session *session);/* extended open */struct snmp_session *snmp_open_ex (struct snmp_session *,  int (*fpre_parse) (struct snmp_session *, snmp_ipaddr),  int (*fparse) (struct snmp_session *, struct snmp_pdu *, u_char *, size_t),  int (*fpost_parse) (struct snmp_session *, struct snmp_pdu *, int),  int (*fbuild) (struct snmp_session *, struct snmp_pdu *, u_char *, 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.*/#if HAVE_STDARG_Hvoid DEBUGP (const char *, ...);#elsevoid DEBUGP (va_alist);#endifvoid DEBUGPOID(oid *, size_t);void snmp_set_do_debugging (int);int snmp_get_do_debugging (void);#ifdef CMU_COMPATIBLEextern int snmp_dump_packet;extern int quick_print;#endifsize_t snmp_socket_length   (int family);/* * snmp_error - return error data * Inputs :  address of errno, address of snmp_errno, address of string * Caller must free the string returned after use. */void snmp_error (struct snmp_session *, int *, int *, char **);/* * single session API. * * These functions perform similar actions as snmp_XX functions, * but operate on a single session only. * * Synopsis:	void * sessp;	struct snmp_session session, *ss;	struct snmp_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) */void   snmp_sess_init       (struct snmp_session *);void * snmp_sess_open       (struct snmp_session *);struct snmp_session * snmp_sess_session    (void *);/* use return value from snmp_sess_open as void * parameter */int    snmp_sess_send       (void *, struct snmp_pdu *);int    snmp_sess_async_send (void *, struct snmp_pdu *,                                         snmp_callback, void *);int    snmp_sess_select_info (void *, int *, fd_set *,                                         struct timeval *, int *);int    snmp_sess_read       (void *, fd_set *);void   snmp_sess_timeout    (void *);int    snmp_sess_close      (void *);void   snmp_sess_error      (void *, int *, int *, char **);void   snmp_sess_perror     (const char *prog_string, struct snmp_session *ss);/* end single session API *//* generic statistic counters *//* snmpv3 statistics *//* mpd stats */#define   STAT_SNMPUNKNOWNSECURITYMODELS     0#define   STAT_SNMPINVALIDMSGS               1#define   STAT_SNMPUNKNOWNPDUHANDLERS        2#define   STAT_MPD_STATS_START               STAT_SNMPUNKNOWNSECURITYMODELS#define   STAT_MPD_STATS_END                 STAT_SNMPUNKNOWNPDUHANDLERS/* usm stats */#define   STAT_USMSTATSUNSUPPORTEDSECLEVELS  3#define   STAT_USMSTATSNOTINTIMEWINDOWS      4#define   STAT_USMSTATSUNKNOWNUSERNAMES      5#define   STAT_USMSTATSUNKNOWNENGINEIDS      6#define   STAT_USMSTATSWRONGDIGESTS          7#define   STAT_USMSTATSDECRYPTIONERRORS      8#define   STAT_USM_STATS_START               STAT_USMSTATSUNSUPPORTEDSECLEVELS#define   STAT_USM_STATS_END                 STAT_USMSTATSDECRYPTIONERRORS/* snmp counters */#define  STAT_SNMPINPKTS                     9#define  STAT_SNMPOUTPKTS                    10#define  STAT_SNMPINBADVERSIONS              11#define  STAT_SNMPINBADCOMMUNITYNAMES        12#define  STAT_SNMPINBADCOMMUNITYUSES         13#define  STAT_SNMPINASNPARSEERRS             14/* #define  STAT_SNMPINBADTYPES		     15 */#define  STAT_SNMPINTOOBIGS                  16#define  STAT_SNMPINNOSUCHNAMES              17#define  STAT_SNMPINBADVALUES                18#define  STAT_SNMPINREADONLYS                19#define  STAT_SNMPINGENERRS                  20#define  STAT_SNMPINTOTALREQVARS             21#define  STAT_SNMPINTOTALSETVARS             22#define  STAT_SNMPINGETREQUESTS              23#define  STAT_SNMPINGETNEXTS                 24#define  STAT_SNMPINSETREQUESTS              25#define  STAT_SNMPINGETRESPONSES             26#define  STAT_SNMPINTRAPS                    27#define  STAT_SNMPOUTTOOBIGS                 28#define  STAT_SNMPOUTNOSUCHNAMES             29#define  STAT_SNMPOUTBADVALUES               30/* #define  STAT_SNMPOUTREADONLYS	     31 */#define  STAT_SNMPOUTGENERRS                 32#define  STAT_SNMPOUTGETREQUESTS             33#define  STAT_SNMPOUTGETNEXTS                34#define  STAT_SNMPOUTSETREQUESTS             35#define  STAT_SNMPOUTGETRESPONSES            36#define  STAT_SNMPOUTTRAPS                   37/* AUTHTRAPENABLE			     38 */#define  STAT_SNMPSILENTDROPS		     39#define  STAT_SNMPPROXYDROPS		     40#define  STAT_SNMP_STATS_START               STAT_SNMPINPKTS#define  STAT_SNMP_STATS_END                 STAT_SNMPOUTTRAPS#define  MAX_STATS                           41#ifdef __cplusplus}#endif#endif /* SNMP_API_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?