--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_INTERNAL_H_
+#define _SNMP_INTERNAL_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * $Id: snmp-internal.h,v 1.1 1998/02/22 11:48:41 kostas Exp $
+ *
+ **********************************************************************/
+
+#define SNMP_PORT 161
+#define SNMP_TRAP_PORT 162
+#define SNMP_MAX_LEN 484
+
+#ifdef DEBUG
+#define ERROR(string) printf("%s(%d): %s\n",__FILE__, __LINE__, string);
+#else
+#define ERROR(string)
+#endif
+
+#endif /* _SNMP_INTERNAL_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_MIB_H_
+#define _SNMP_MIB_H_
+
+/***************************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp-mib.h,v 1.1 1998/02/22 11:48:42 kostas Exp $
+ *
+ ***************************************************************************/
+
+#include <asn1.h> /* Need OID Definition */
+#include <snmp_vars.h> /* Need variable_list */
+#include <mib.h> /* Then the function definitions */
+
+#endif /* _SNMP_MIB_H_ */
+#ifndef _SNMP_H_
+#define _SNMP_H_
+
/*
* Definitions for the Simple Network Management Protocol (RFC 1067).
*
- *
*/
-/*
- * Copyright 1988, 1989 by Carnegie Mellon University
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
*
- * All Rights Reserved
+ * All Rights Reserved
*
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted,
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
- * both that copyright notice and this permission notice appear in
+ * both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of CMU not be
* used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
+ * software without specific, written prior permission.
*
* CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
- */
-
-#ifndef SNMP_H
-#define SNMP_H
-
-#include "snmp_api.h"
-
-
-#define SNMP_PORT 161
-#define SNMP_TRAP_PORT 162
-
-#define SNMP_MAX_LEN 1450
-
-#define SNMP_MESSAGE_LIFETIME 150
-
-#define SNMP_VERSION_1 0
-#define SNMP_VERSION_2C 1
-#define SNMP_VERSION_2 2
-
-#define SNMP_USEC_MODEL 1
-
-#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
-#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
-#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
-#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
-#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
-
-#define GETBULK_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
-#define INFORM_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
-#define TRP2_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
-#define REPORT_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
-
-#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
-#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
-#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
-
-#define SNMP_ERR_NOERROR (0)
-#define SNMP_ERR_TOOBIG (1)
-#define SNMP_ERR_NOSUCHNAME (2)
-#define SNMP_ERR_BADVALUE (3)
-#define SNMP_ERR_READONLY (4)
-#define SNMP_ERR_GENERR (5)
-
-#define SNMP_ERR_NOACCESS (6)
-#define SNMP_ERR_WRONGTYPE (7)
-#define SNMP_ERR_WRONGLENGTH (8)
-#define SNMP_ERR_WRONGENCODING (9)
-#define SNMP_ERR_WRONGVALUE (10)
-#define SNMP_ERR_NOCREATION (11)
-#define SNMP_ERR_INCONSISTENTVALUE (12)
-#define SNMP_ERR_RESOURCEUNAVAILABLE (13)
-#define SNMP_ERR_COMMITFAILED (14)
-#define SNMP_ERR_UNDOFAILED (15)
-#define SNMP_ERR_AUTHORIZATIONERROR (16)
-#define SNMP_ERR_NOTWRITABLE (17)
-#define SNMP_ERR_INCONSISTENTNAME (18)
-
-#define SNMP_TRAP_COLDSTART (0x0)
-#define SNMP_TRAP_WARMSTART (0x1)
-#define SNMP_TRAP_LINKDOWN (0x2)
-#define SNMP_TRAP_LINKUP (0x3)
-#define SNMP_TRAP_AUTHFAIL (0x4)
-#define SNMP_TRAP_EGPNEIGHBORLOSS (0x5)
-#define SNMP_TRAP_ENTERPRISESPECIFIC (0x6)
-
-#define USEC_QOS_AUTH (0x01)
-#define USEC_QOS_PRIV (0x02)
-#define USEC_QOS_AUTHPRIV (0x03)
-#define USEC_QOS_GENREPORT (0x04)
-#define USEC_QOS_NOAUTH_NOPRIV (0)
-
-#define SNMP_STAT_PACKETS 0
-#define SNMP_STAT_ENCODING_ERRORS 1
-#define USEC_STAT_UNSUPPORTED_QOS 2
-#define USEC_STAT_NOT_IN_WINDOWS 3
-#define USEC_STAT_UNKNOWN_USERNAMES 4
-#define USEC_STAT_WRONG_DIGEST_VALUES 5
-#define USEC_STAT_UNKNOWN_CONTEXT_SELECTORS 6
-#define USEC_STAT_BAD_PARAMETERS 7
-#define USEC_STAT_UNAUTHORIZED_OPERATIONS 8
-#define SNMP_STAT_BAD_OPERATIONS 9
-#define SNMP_STAT_PROXY_DROPS 10
-#define SNMP_STAT_SILENT_DROPS 11
-#define SNMP_STAT_V1_BAD_COMMUNITY_NAMES 12
-#define SNMP_STAT_V1_BAD_COMMUNITY_USES 13
-
-#define SNMP_LAST_STAT SNMP_STAT_V1_BAD_COMMUNITY_USES
-
-
-typedef struct _conf_if_list {
- char *name;
- int type;
- int speed;
- struct _conf_if_list *next;
-} conf_if_list;
-
-extern conf_if_list *if_list;
-extern void init_mib(const char *);
-extern int read_objid(char *input, oid * output, int *out_len);
-extern void snmp_add_null_var(struct snmp_pdu *, oid *, int);
-extern void sprint_objid(char *buf, oid * id, int idlen);
-extern void print_objid(oid * id, int idlen);
-extern void xdump(u_char * cp, int length, char *prefix);
-extern void snmp_synch_setup(struct snmp_session *session);
-extern int snmp_synch_response(struct snmp_session *ss,
- struct snmp_pdu *pdu,
- struct snmp_pdu **response);
+ *
+ * $Id: snmp.h,v 1.9 1998/02/22 11:48:42 kostas Exp $
+ *
+ **********************************************************************/
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
#endif
-/*
- * usec.c
- */
-extern void md5Digest(u_char * msg, int length, u_char * key, u_char * digest);
-extern int parse_app_community_string(struct snmp_session *session);
+/* These come first */
+#include "asn1.h"
+#include "snmp_error.h"
+#include "mibii.h"
+#include "snmp_extra.h"
+#include "snmp_dump.h"
+
+/* I didn't touch this */
+#include "snmp_session.h"
+
+/* The various modules */
+#include <snmp_vars.h>
+#include <snmp_pdu.h>
+#include <snmp_msg.h>
+
+/* Other functions */
+#include <snmp_coexist.h>
+#include <version.h>
+#include <snmp_error.h>
+#include <snmp_api_error.h>
+#include <mini-client.h>
+
+/* Other stuff I didn't touch */
+#include <snmp_impl.h>
+#include <snmp_api.h>
+#include <snmp_client.h>
+#include <snmp-internal.h>
+#include <mib.h>
+#include <parse.h>
+#include <snmp_compat.h>
+
+#ifndef SQUID_H
+#ifdef __STDC__
+void (*snmplib_debug) (int,char *, ...);
+#else
+void (*snmplib_debug) (va_alist));
+#endif
+#endif
+#endif /* _SNMP_H_ */
+#ifndef _SNMP_API_H_
+#define _SNMP_API_H_
+
+#include "config.h"
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
/***********************************************************
Copyright 1989 by Carnegie Mellon University
* snmp_api.h - API for access to snmp.
*/
-#ifndef _SNMP_API_H
-#define _SNMP_API_H
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#if defined(sun) && !defined(__svr4__)
-typedef int ssize_t;
-#endif
-
-#include "asn1.h"
-
-
-typedef struct sockaddr_in ipaddr;
-
-typedef struct {
- u_char securityModel;
- u_char qoS;
- u_char agentID[12];
- u_long agentBoots;
- int agentTime;
- int MMS;
- int userLen;
- u_char userName[16];
- int authLen;
- u_char authDigest[16];
- u_char *authDigestPtr;
- int contextLen;
- u_char contextSelector[40];
-} Parameters;
-
-struct snmp_session {
- int retries; /* Number of retries before timeout. */
- long timeout; /* Number of uS until first timeout, then exponential backoff */
- char *peername; /* Domain name or dotted IP address of default peer */
- u_short remote_port; /* UDP port number of peer. */
- u_short local_port; /* My UDP port number, 0 for default, picked randomly */
- /* Authentication function or NULL if null authentication is used */
- int (*authenticator) ();
- int (*callback) (); /* Function to interpret incoming data */
-
- /* Pointer to data that the callback function may consider important */
- void *callback_magic;
-
- int version; /* SNMP version number */
-
- /* fields to support SNMPv1 community model */
- int community_len;
- u_char *community;
-
- /* the private keys to use for user-based security */
- u_char authKey[16];
- u_char privKey[16];
-
- /* fields to support user-based security model in SNMPv2 */
- Parameters params;
-
- u_char qoS;
- u_char agentID[16];
- u_long agentBoots;
- int agentTime; /* the agentTime value */
- int agentClock; /* the running agentClock */
- int userLen;
- u_char userName[32];
- int MMS;
- int contextLen;
- u_char contextSelector[64];
-
- /* misc stuff */
- int readView;
- int writeView;
-};
/*
* Set fields in session and pdu to the following to get a default or unconfigured value.
*/
#define SNMP_DEFAULT_COMMUNITY_LEN 0 /* to get a default community name */
-#define SNMP_DEFAULT_RETRIES -1
-#define SNMP_DEFAULT_TIMEOUT -1
+#define SNMP_DEFAULT_RETRIES 3
+#define SNMP_DEFAULT_TIMEOUT 1
#define SNMP_DEFAULT_REMPORT 0
-#define SNMP_DEFAULT_REQID 0
-#define SNMP_DEFAULT_ERRSTAT -1
-#define SNMP_DEFAULT_ERRINDEX -1
-#define SNMP_DEFAULT_ADDRESS 0
#define SNMP_DEFAULT_PEERNAME NULL
#define SNMP_DEFAULT_ENTERPRISE_LENGTH 0
#define SNMP_DEFAULT_TIME 0
+#define SNMP_DEFAULT_MAXREPETITIONS 5
+#define SNMP_DEFAULT_MACREPEATERS 0
-/*
- * default initial timeout ans default retries;
- * the timeout is doubled for every retry:
- * 0.3 + 0.6 + 1.2 + 2.4 + 4.8 = 9.3
- */
-#define SNMP_API_DEFAULT_RETRIES 6
-#define SNMP_API_DEFAULT_TIMEOUT 300000L
-
-extern int snmp_errno;
-/* Error return values */
-#define SNMPERR_GENERR -1
-#define SNMPERR_BAD_LOCPORT -2 /* local port was already in use */
-#define SNMPERR_BAD_ADDRESS -3
-#define SNMPERR_BAD_SESSION -4
-#define SNMPERR_TOO_LONG -5
-
-
-struct snmp_pdu {
- ipaddr address; /* Address of peer */
-
- int command; /* Type of this PDU */
-
- Parameters params;
-
- u_long reqid; /* Request id */
- u_long errstat; /* Error status */
- u_long errindex; /* Error index */
-
- /* Trap information */
- oid *enterprise; /* System OID */
- int enterprise_length;
- ipaddr agent_addr; /* address of object generating trap */
- int trap_type; /* trap type */
- int specific_type; /* specific type */
- u_long time; /* Uptime */
-
- struct variable_list *variables;
-};
-
+#ifdef __cplusplus
+extern "C" {
+#endif
-struct variable_list {
- struct variable_list *next_variable; /* NULL for last variable */
- oid *name; /* Object identifier of variable */
- int name_length; /* number of subid's in name */
- u_char type; /* ASN type of variable */
- union { /* value of variable */
- long *integer;
- u_char *string;
- oid *objid;
- u_char *bitstring;
- struct counter64 *counter64;
+ /* Parse the buffer pointed to by arg3, of length arg4, into pdu arg2.
+ *
+ * Returns the community of the incoming PDU, or NULL
+ */
+u_char *snmp_parse(struct snmp_session *, struct snmp_pdu *,
+ u_char *, int);
- } val;
- int val_len;
-};
+/* Encode pdu arg2 into buffer arg3. arg4 contains the size of
+ * the buffer.
+ */
+int snmp_build(struct snmp_session *, struct snmp_pdu *,
+ u_char *, int *);
/*
* struct snmp_session *snmp_open(session)
- * struct snmp_session *session;
+ * struct snmp_session *session;
*
* Sets up the session with the snmp_session information provided
* by the user. Then opens and binds the necessary UDP port.
* the pointer passed to snmp_open()). On any error, NULL is returned
* and snmp_errno is set to the appropriate error code.
*/
-struct snmp_session *snmp_open(struct snmp_session *session);
+struct snmp_session *snmp_open(struct snmp_session *);
/*
* int snmp_close(session)
* dequeues any pending requests, and closes any sockets allocated for
* the session. Returns 0 on error, 1 otherwise.
*/
-int snmp_close(struct snmp_session *session);
+int snmp_close(struct snmp_session *);
/*
* int snmp_send(session, pdu)
* struct snmp_session *session;
- * struct snmp_pdu *pdu;
+ * struct snmp_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
* On any error, 0 is returned.
* The pdu is freed by snmp_send() unless a failure occured.
*/
-int snmp_send(struct snmp_session *session,
- struct snmp_pdu *pdu);
+int snmp_send(struct snmp_session *, struct snmp_pdu *);
/*
* is passed to the callback routine for that session. If the callback
* routine returns successfully, the pdu and it's request are deleted.
*/
-void snmp_read(fd_set * fdset);
+void snmp_read(fd_set *);
-/*
- * void
- * snmp_free_pdu(pdu)
- * struct snmp_pdu *pdu;
- *
- * Frees the pdu and any malloc'd data associated with it.
- */
-void snmp_free_pdu(struct snmp_pdu *pdu);
-
/*
* int snmp_select_info(numfds, fdset, timeout, block)
* int *numfds;
*
* snmp_select_info returns the number of open sockets. (i.e. The number of sessions open)
*/
-int snmp_select_info(int *numfds,
- fd_set * fdset,
- struct timeval *timeout,
- int *block);
+int snmp_select_info(int *, fd_set *, struct timeval *, int *);
/*
* void snmp_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.
+ * 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:
*/
-extern int snmp_build(struct snmp_session *, struct snmp_pdu *, u_char *, int *, int);
-#define RECEIVED_MESSAGE 1
-#define TIMED_OUT 2
-extern int snmp_dump_packet;
+
+void snmp_api_stats(void *);
+
+#ifdef __cplusplus
+}
#endif
+
+
+#endif /* _SNMP_API_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_API_ERROR_H_
+#define _SNMP_API_ERROR_H_
+
+/***************************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp_api_error.h,v 1.1 1998/02/22 11:48:43 kostas Exp $
+ *
+ ***************************************************************************/
+
+/* Error return values */
+#define SNMPERR_GENERR -1
+#define SNMPERR_BAD_LOCPORT -2 /* local port was already in use */
+#define SNMPERR_BAD_ADDRESS -3
+#define SNMPERR_BAD_SESSION -4
+#define SNMPERR_TOO_LONG -5 /* data too long for provided buffer */
+
+#define SNMPERR_ASN_ENCODE -6
+#define SNMPERR_ASN_DECODE -7
+#define SNMPERR_PDU_TRANSLATION -8
+#define SNMPERR_OS_ERR -9
+#define SNMPERR_INVALID_TXTOID -10
+
+#define SNMPERR_UNABLE_TO_FIX -11
+#define SNMPERR_UNSUPPORTED_TYPE -12
+#define SNMPERR_PDU_PARSE -13
+#define SNMPERR_PACKET_ERR -14
+#define SNMPERR_NO_RESPONSE -15
+
+#define SNMPERR_LAST -16 /* Last error message */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* extern int snmp_errno */
+
+char *snmp_api_error(int);
+int snmp_api_errno(void);
+
+char *api_errstring(int); /* Backwards compatibility */
+void snmp_set_api_error(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNMP_API_ERROR_H_ */
--- /dev/null
+#ifndef _SNMP_API_UTIL_H_
+#define _SNMP_API_UTIL_H_
+
+/***********************************************************
+ Copyright 1997 by Carnegie Mellon University
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+******************************************************************/
+
+/*
+ * snmp_api_util.h - API management.
+ * Didier DESIDERIO (SINFOR) - November 26th, 1997
+ */
+
+#define PACKET_LENGTH 4500
+
+/*
+ * A list of all the outstanding requests for a particular session.
+ */
+struct request_list {
+ struct request_list *next_request;
+ int request_id; /* request id */
+ int retries; /* Number of retries */
+ u_int timeout; /* length to wait for timeout */
+ struct timeval time; /* Time this request was made */
+ struct timeval expire; /* time this request is due to expire */
+ struct snmp_pdu *pdu; /* The pdu for this request (saved so it can be retransmitted */
+};
+
+/*
+ * The list of active/open sessions.
+ */
+struct session_list {
+ struct session_list *next;
+ struct snmp_session *session;
+ struct snmp_internal_session *internal;
+};
+
+struct snmp_internal_session {
+ int sd; /* socket descriptor for this connection */
+ ipaddr addr; /* address of connected peer */
+ struct request_list *requests;/* Info about outstanding requests */
+};
+
+/* Define these here, as they aren't defined normall under
+ * cygnus Win32 stuff.
+ */
+#undef timercmp
+#define timercmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec) cmp ((uvp)->tv_sec)) || \
+ ((((tvp)->tv_sec) == ((uvp)->tv_sec)) && \
+ (((tvp)->tv_usec) cmp ((uvp)->tv_usec)))
+
+#undef timerclear
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+
+#undef timerisset
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+
+#ifdef HAVE_SRAND
+#define random rand
+#define srandom srand
+#endif /* HAVE_SRAND */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ int snmp_get_socket_session(struct snmp_session *session_);
+ int snmp_select_info_session(struct snmp_session *session_, struct timeval* timeout);
+ int snmp_timeout_session(struct snmp_session *sp_);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNMP_API_UTIL_H_ */
+#ifndef _SNMP_CLIENT_H_
+#define _SNMP_CLIENT_H_
+
/*
* snmp_client.h
*/
-
/***********************************************************
Copyright 1988, 1989 by Carnegie Mellon University
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
-
-#ifndef SNMP_CLIENT_H
-#define SNMP_CLIENT_H
-
struct synch_state {
- int waiting;
+ int waiting;
int status;
/* status codes */
#define STAT_SUCCESS 0
struct snmp_pdu *pdu;
};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern struct synch_state snmp_synch_state;
-extern struct snmp_pdu *snmp_pdu_create(int cmd);
+/* Synchronize Input with Agent */
+int snmp_synch_input(int, struct snmp_session *, int,
+ struct snmp_pdu *, void *);
+
+/* Synchronize Response with Agent */
+int snmp_synch_response(struct snmp_session *, struct snmp_pdu *,
+ struct snmp_pdu **);
-extern struct snmp_pdu *snmp_fix_pdu(struct snmp_pdu *pdu,
- int cmd);
-extern char *snmp_errstring(int errstat);
+/* Synchronize Setup */
+void snmp_synch_setup(struct snmp_session *);
+#ifdef __cplusplus
+}
#endif
+
+#endif /* _SNMP_CLIENT_H_ */
+
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_COEXISTANCE_H_
+#define _SNMP_COEXISTANCE_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp_coexist.h,v 1.1 1998/02/22 11:48:45 kostas Exp $
+ *
+ **********************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int snmp_coexist_V2toV1(struct snmp_pdu *);
+int snmp_coexist_V1toV2(struct snmp_pdu *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNMP_COEXISTANCE_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_ERROR_H_
+#define _SNMP_ERROR_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * $Id: snmp_error.h,v 1.1 1998/02/22 11:48:46 kostas Exp $
+ *
+ **********************************************************************/
+
+/*
+ * RFC 1905: Protocol Operations for SNMPv2
+ *
+ * PDU : Error Status Values
+ */
+
+#define SNMP_ERR_NOERROR (0x0)
+#define SNMP_ERR_TOOBIG (0x1)
+#define SNMP_ERR_NOSUCHNAME (0x2)
+#define SNMP_ERR_BADVALUE (0x3)
+#define SNMP_ERR_READONLY (0x4)
+#define SNMP_ERR_GENERR (0x5)
+#define SNMP_ERR_NOACCESS (0x6)
+#define SNMP_ERR_WRONGTYPE (0x7)
+#define SNMP_ERR_WRONGLENGTH (0x8)
+#define SNMP_ERR_WRONGENCODING (0x9)
+#define SNMP_ERR_WRONGVALUE (0x10)
+#define SNMP_ERR_NOCREATION (0x11)
+#define SNMP_ERR_INCONSISTENTVALUE (0x12)
+#define SNMP_ERR_RESOURCEUNAVAILABLE (0x13)
+#define SNMP_ERR_COMMITFAILED (0x14)
+#define SNMP_ERR_UNDOFAILED (0x15)
+#define SNMP_ERR_AUTHORIZATIONERROR (0x16)
+#define SNMP_ERR_NOTWRITABLE (0x17)
+#define SNMP_ERR_INCONSISTENTNAME (0x18)
+
+#ifdef __cplusplus
+
+extern "C" {
+#endif
+
+ char *snmp_errstring(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNMP_ERROR_H_ */
+#ifndef _SNMP_IMPL_H_
+#define _SNMP_IMPL_H_
+
/*
* Definitions for SNMP (RFC 1067) implementation.
*
SOFTWARE.
******************************************************************/
-#ifndef SNMP_IMPL_H
-#define SNMP_IMPL_H
+#if 0
+#if (defined vax) || (defined (mips))
+/*
+ * This is a fairly bogus thing to do, but there seems to be no better way for
+ * compilers that don't understand void pointers.
+ */
+#ifndef void
+#define void char
+#endif
+#endif
+#endif
/*
* Error codes:
#define PARSE_ERROR -1
#define BUILD_ERROR -2
-#define SID_MAX_LEN 200
-#define MAX_NAME_LEN 64 /* number of subid's in a objid */
+#define SID_MAX_LEN 64
#ifndef NULL
#define NULL 0
#define READ 1
#define WRITE 0
-#define SNM_RESERVE1 0
-#define SNM_RESERVE2 1
-#define SNM_COMMIT 2
-#define SNM_ACTION 3
-#define SNM_FREE 4
+#define SNMP_RESERVE1 0
+#define SNMP_RESERVE2 1
+#define SNMP_COMMIT 2
+#define SNMP_FREE 3
-#define RONLY 0xAAAA /* read access for everyone */
-#define RWRITE 0xAABA /* add write access for community private */
-#define NOACCESS 0x0000 /* no access for anybody */
+#define RONLY 0xAAAA /* read access for everyone */
+#define RWRITE 0xAABA /* add write access for community private */
+#define NOACCESS 0x0000 /* no access for anybody */
#define INTEGER ASN_INTEGER
#define STRING ASN_OCTET_STR
#define OBJID ASN_OBJECT_ID
#define NULLOBJ ASN_NULL
-/* defined types (from the SMI, RFC 1065) */
-#define IPADDRESS (ASN_APPLICATION | 0)
-#define COUNTER (ASN_APPLICATION | 1)
-#define GAUGE (ASN_APPLICATION | 2)
-#define TIMETICKS (ASN_APPLICATION | 3)
-#define OPAQUE (ASN_APPLICATION | 4)
-
-#define NSAP (ASN_APPLICATION | 5)
-#define COUNTER64 (ASN_APPLICATION | 6)
-#define UINTEGER (ASN_APPLICATION | 7)
-
-#undef DEBUG
-#ifdef DEBUG
-#define ERROR(string) fprintf(stderr,"%s(%d): ERROR %s\n",__FILE__, __LINE__, string);
-#else
-#define ERROR(string)
-#endif
-/* from snmp.c */
-extern u_char sid[]; /* size SID_MAX_LEN */
-
-extern u_char *snmp_parse_var_op(u_char * data,
- oid * var_name,
- int *var_name_len,
- u_char * var_val_type,
- int *var_val_len,
- u_char ** var_val,
- int *listlength);
-
-extern u_char *snmp_build_var_op(u_char * data,
- oid * var_name,
- int *var_name_len,
- u_char var_val_type,
- int var_val_len,
- u_char * var_val,
- int *listlength);
-
-extern u_char *snmp_auth_parse(u_char * data,
- int *length,
- u_char * sid,
- int *slen,
- long *version);
-
-extern u_char *snmp_auth_build(u_char * data,
- int *length,
- struct snmp_session *session,
- int is_agent,
- int messagelen);
+struct trapVar {
+ oid *varName;
+ int varNameLen;
+ u_char varType;
+ int varLen;
+ u_char *varVal;
+ struct trapVar *next;
+};
-#endif
+/* from snmp.c*/
+extern u_char sid[]; /* size SID_MAX_LEN */
+
+#endif /* _SNMP_IMPL_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_MSG_H_
+#define _SNMP_MSG_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp_msg.h,v 1.1 1998/02/22 11:48:47 kostas Exp $
+ *
+ **********************************************************************/
+
+#define SNMP_VERSION_1 0 /* RFC 1157 */
+#define SNMP_VERSION_2 1 /* RFC 1901 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+u_char *snmp_msg_Encode(u_char *, int *, u_char *,
+ int, int, struct snmp_pdu *);
+u_char *snmp_msg_Decode(u_char *, int *, u_char *,
+ int *, int *, struct snmp_pdu *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SNMP_MSG_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_PDU_H_
+#define _SNMP_PDU_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp_pdu.h,v 1.1 1998/02/22 11:48:48 kostas Exp $
+ *
+ **********************************************************************/
+
+typedef struct sockaddr_in ipaddr;
+
+/* An SNMP PDU */
+struct snmp_pdu {
+ int command; /* Type of this PDU */
+ ipaddr address; /* Address of peer */
+
+ int reqid; /* Integer32: Request id */
+ int errstat; /* INTEGER: Error status */
+ int errindex; /* INTEGER: Error index */
+
+ /* SNMPv2 Bulk Request */
+ int non_repeaters; /* INTEGER: */
+ int max_repetitions; /* INTEGER: */
+
+ struct variable_list *variables; /* Variable Bindings */
+
+ /* Trap information */
+ oid *enterprise; /* System OID */
+ int enterprise_length;
+ ipaddr agent_addr; /* address of object generating trap */
+ int trap_type; /* generic trap type */
+ int specific_type; /* specific type */
+ u_int time; /* Uptime */
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ struct snmp_pdu *snmp_pdu_create(int);
+ struct snmp_pdu *snmp_pdu_clone(struct snmp_pdu *);
+ struct snmp_pdu *snmp_pdu_fix(struct snmp_pdu *, int);
+ struct snmp_pdu *snmp_fix_pdu(struct snmp_pdu *, int);
+ void snmp_free_pdu(struct snmp_pdu *);
+ void snmp_pdu_free(struct snmp_pdu *);
+
+ u_char *snmp_pdu_encode(u_char *, int *, struct snmp_pdu *);
+ u_char *snmp_pdu_decode(u_char *, int *, struct snmp_pdu *);
+ char *snmp_pdu_type(struct snmp_pdu *);
+
+ /* Add a NULL Variable to a PDU */
+ void snmp_add_null_var(struct snmp_pdu *, oid *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * RFC 1905: Protocol Operations for SNMPv2
+ *
+ * RFC 1157: A Simple Network Management Protocol (SNMP)
+ *
+ * PDU Types
+ */
+
+#define SNMP_PDU_GET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
+#define SNMP_PDU_GETNEXT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
+#define SNMP_PDU_RESPONSE (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
+#define SNMP_PDU_SET (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
+#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) /*Obsolete*/
+#define SNMP_PDU_GETBULK (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
+#define SNMP_PDU_INFORM (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
+#define SNMP_PDU_V2TRAP (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
+#define SNMP_PDU_REPORT (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
+
+#define MAX_BINDINGS 2147483647
+
+/* PDU Defaults */
+#define SNMP_DEFAULT_ERRSTAT -1
+#define SNMP_DEFAULT_ERRINDEX -1
+#define SNMP_DEFAULT_ADDRESS 0
+#define SNMP_DEFAULT_REQID 0
+
+/*
+ * RFC 1907: Management Information Base for SNMPv2
+ *
+ * RFC 1157: A Simple Network Management Protocol (SNMP)
+ *
+ * Trap Types
+ */
+
+#define SNMP_TRAP_COLDSTART (0x0)
+#define SNMP_TRAP_WARMSTART (0x1)
+#define SNMP_TRAP_LINKDOWN (0x2)
+#define SNMP_TRAP_LINKUP (0x3)
+#define SNMP_TRAP_AUTHENTICATIONFAILURE (0x4)
+#define SNMP_TRAP_EGPNEIGHBORLOSS (0x5)
+#define SNMP_TRAP_ENTERPRISESPECIFIC (0x6)
+
+#endif /* _SNMP_PDU_H_ */
--- /dev/null
+/* -*- c++ -*- */
+#ifndef _SNMP_SESSION_H_
+#define _SNMP_SESSION_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * $Id: snmp_session.h,v 1.1 1998/02/22 11:48:49 kostas Exp $
+ *
+ **********************************************************************/
+
+struct snmp_session {
+ int Version; /* SNMP Version for this session */
+
+
+ u_char *community; /* community for outgoing requests. */
+ int community_len; /* Length of community name. */
+ int retries; /* Number of retries before timeout. */
+ int timeout; /* Number of uS until first timeout, then exponential backoff */
+ char *peername; /* Domain name or dotted IP address of default peer */
+ u_short remote_port;/* UDP port number of peer. */
+ u_short local_port; /* My UDP port number, 0 for default, picked randomly */
+ /* This isn't used, but is here so that libraries compiled with this
+ * in place still work.
+ */
+ u_char *(*authenticator)();
+ int (*callback)(); /* Function to interpret incoming data */
+ /* Pointer to data that the callback function may consider important */
+ void *callback_magic;
+};
+
+#define RECEIVED_MESSAGE 1
+#define TIMED_OUT 2
+
+#endif /* _SNMP_SESSION_H_ */
-/*
- * Definitions for SNMP (RFC 1067) agent variable finder.
- * and more.
- */
-/***********************************************************
- Copyright 1988, 1989 by Carnegie Mellon University
- Copyright 1989 TGV, Incorporated
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of CMU and TGV not be used
-in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission.
-
-CMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-EVENT SHALL CMU OR TGV BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
-USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THIS SOFTWARE.
-******************************************************************/
-
-#ifndef SNMPLIB_H
-#define SNMPLIB_H
+/* -*- c++ -*- */
+#ifndef _SNMP_VARS_H_
+#define _SNMP_VARS_H_
+
+/**********************************************************************
+ *
+ * Copyright 1997 by Carnegie Mellon University
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of CMU not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ryan Troll <ryan+@andrew.cmu.edu>
+ *
+ * $Id: snmp_vars.h,v 1.6 1998/02/22 11:48:49 kostas Exp $
+ *
+ **********************************************************************/
+
+struct variable_list {
+ struct variable_list *next_variable; /* NULL for last variable */
+ oid *name; /* Object identifier of variable */
+ int name_length; /* number of subid's in name */
+ u_char type; /* ASN type of variable */
+ union { /* value of variable */
+ int *integer;
+ u_char *string;
+ oid *objid;
+ } val;
+ int val_len;
+};
-u_char *var_system();
-u_char *var_ifEntry();
-u_char *var_atEntry();
-u_char *var_ip();
-u_char *var_ipAddrEntry();
-u_char *var_ipRouteEntry();
-u_char *var_icmp();
-u_char *var_tcp();
-u_char *var_udp();
-#ifdef linux
-u_char *var_snmp();
-u_char *var_id();
+#ifdef __cplusplus
+extern "C" {
#endif
-u_char *var_process();
-u_char *var_event();
-u_char *var_capture();
-u_char *var_demo();
-u_char *var_snmpStats();
-u_char *var_usecStats();
-u_char *var_usecAgent();
-u_char *var_orEntry();
-u_char *var_rwstats();
-u_char *getStatPtr();
-
-extern long long_return;
-extern u_char return_buf[];
-
-#define INST 0xFFFFFFFF /* used to fill out the instance field of the variables table */
-
-/*
- * These are unit magic numbers for each variable.
- */
-
-#define VERSION_DESCR 0
-#define VERSION_ID 1
-#define IFNUMBER 2
-#define UPTIME 3
-#define SYSCONTACT 4
-#define SYSYSNAME 5
-#define SYSLOCATION 6
-#define SYSSERVICES 7
-#define SYSORLASTCHANGE 8
-
-#define IFINDEX 1
-#define IFDESCR 2
-#define IFTYPE 3
-#define IFMTU 4
-#define IFSPEED 5
-#define IFPHYSADDRESS 6
-#define IFADMINSTATUS 7
-#define IFOPERSTATUS 8
-#define IFLASTCHANGE 9
-#define IFINOCTETS 10
-#define IFINUCASTPKTS 11
-#define IFINNUCASTPKTS 12
-#define IFINDISCARDS 13
-#define IFINERRORS 14
-#define IFINUNKNOWNPROTOS 15
-#define IFOUTOCTETS 16
-#define IFOUTUCASTPKTS 17
-#define IFOUTNUCASTPKTS 18
-#define IFOUTDISCARDS 19
-#define IFOUTERRORS 20
-#define IFOUTQLEN 21
-#define IFSPECIFIC 22
-#define ATIFINDEX 0
-#define ATPHYSADDRESS 1
-#define ATNETADDRESS 2
+ struct variable_list *snmp_var_new(oid *, int);
+ struct variable_list *snmp_var_clone(struct variable_list *);
+ void snmp_var_free(struct variable_list *);
-#define IPFORWARDING 0
-#define IPDEFAULTTTL 1
-#define IPINRECEIVES 2
-#define IPINHDRERRORS 3
-#define IPINADDRERRORS 4
-#define IPFORWDATAGRAMS 5
-#define IPINUNKNOWNPROTOS 6
-#define IPINDISCARDS 7
-#define IPINDELIVERS 8
-#define IPOUTREQUESTS 9
-#define IPOUTDISCARDS 10
-#define IPOUTNOROUTES 11
-#define IPREASMTIMEOUT 12
-#define IPREASMREQDS 13
-#define IPREASMOKS 14
-#define IPREASMFAILS 15
-#define IPFRAGOKS 16
-#define IPFRAGFAILS 17
-#define IPFRAGCREATES 18
+ u_char *snmp_var_EncodeVarBind(u_char *, int *, struct variable_list *, int);
+ u_char *snmp_var_DecodeVarBind(u_char *, int *, struct variable_list **, int);
-#define IPADADDR 1
-#define IPADIFINDEX 2
-#define IPADNETMASK 3
-#define IPADBCASTADDR 4
-#define IPADENTREASMMAXSIZE 5
-
-#ifndef linux
-#define IPROUTEDEST 0
-#define IPROUTEIFINDEX 1
-#define IPROUTEMETRIC1 2
-#define IPROUTEMETRIC2 3
-#define IPROUTEMETRIC3 4
-#define IPROUTEMETRIC4 5
-#define IPROUTENEXTHOP 6
-#define IPROUTETYPE 7
-#define IPROUTEPROTO 8
-#define IPROUTEAGE 9
-#else
-/* XXX */
-#define IPROUTEDEST 1
-#define IPROUTEIFINDEX 2
-#define IPROUTEMETRIC1 3
-#define IPROUTEMETRIC2 4
-#define IPROUTEMETRIC3 5
-#define IPROUTEMETRIC4 6
-#define IPROUTENEXTHOP 7
-#define IPROUTETYPE 8
-#define IPROUTEPROTO 9
-#define IPROUTEAGE 10
-#define IPROUTEMASK 11
-#define IPROUTEMETRIC5 12
-#define IPROUTEINFO 13
+#ifdef __cplusplus
+}
#endif
-#define IPNETTOMEDIAIFINDEX 1
-#define IPNETTOMEDIAPHYSADDR 2
-#define IPNETTOMEDIANETADDR 3
-#define IPNETTOMEDIATYPE 4
-
-#define ICMPINMSGS 0
-#define ICMPINERRORS 1
-#define ICMPINDESTUNREACHS 2
-#define ICMPINTIMEEXCDS 3
-#define ICMPINPARMPROBS 4
-#define ICMPINSRCQUENCHS 5
-#define ICMPINREDIRECTS 6
-#define ICMPINECHOS 7
-#define ICMPINECHOREPS 8
-#define ICMPINTIMESTAMPS 9
-#define ICMPINTIMESTAMPREPS 10
-#define ICMPINADDRMASKS 11
-#define ICMPINADDRMASKREPS 12
-#define ICMPOUTMSGS 13
-#define ICMPOUTERRORS 14
-#define ICMPOUTDESTUNREACHS 15
-#define ICMPOUTTIMEEXCDS 16
-#define ICMPOUTPARMPROBS 17
-#define ICMPOUTSRCQUENCHS 18
-#define ICMPOUTREDIRECTS 19
-#define ICMPOUTECHOS 20
-#define ICMPOUTECHOREPS 21
-#define ICMPOUTTIMESTAMPS 22
-#define ICMPOUTTIMESTAMPREPS 23
-#define ICMPOUTADDRMASKS 24
-#define ICMPOUTADDRMASKREPS 25
-
-#define TCPRTOALGORITHM 1
-#define TCPRTOMIN 2
-#define TCPRTOMAX 3
-#define TCPMAXCONN 4
-#define TCPACTIVEOPENS 5
-#define TCPPASSIVEOPENS 6
-#define TCPATTEMPTFAILS 7
-#define TCPESTABRESETS 8
-#define TCPCURRESTAB 9
-#define TCPINSEGS 10
-#define TCPOUTSEGS 11
-#define TCPRETRANSSEGS 12
-#define TCPCONNSTATE 13
-#define TCPCONNLOCALADDRESS 14
-#define TCPCONNLOCALPORT 15
-#define TCPCONNREMADDRESS 16
-#define TCPCONNREMPORT 17
-
-#define UDPINDATAGRAMS 0
-#define UDPNOPORTS 1
-#define UDPINERRORS 2
-#define UDPOUTDATAGRAMS 3
-#ifdef linux
-#define UDPLOCALADDRESS 4
-#define UDPLOCALPORT 5
-#endif /* linux */
-
-#define SNMPINPKTS 1
-#define SNMPOUTPKTS 2
-#define SNMPINBADVERSIONS 3
-#define SNMPINBADCOMMUNITYNAMES 4
-#define SNMPINBADCOMMUNITYUSES 5
-#define SNMPINASNPARSEERRORS 6
-#define SNMPINTOOBIGS 8
-#define SNMPINNOSUCHNAMES 9
-#define SNMPINBADVALUES 10
-#define SNMPINREADONLYS 11
-#define SNMPINGENERRS 12
-#define SNMPINTOTALREQVARS 13
-#define SNMPINTOTALSETVARS 14
-#define SNMPINGETREQUESTS 15
-#define SNMPINGETNEXTS 16
-#define SNMPINSETREQUESTS 17
-#define SNMPINGETRESPONSES 18
-#define SNMPINTRAPS 19
-#define SNMPOUTTOOBIGS 20
-#define SNMPOUTNOSUCHNAMES 21
-#define SNMPOUTBADVALUES 22
-#define SNMPOUTGENERRS 24
-#define SNMPOUTGETREQUESTS 25
-#define SNMPOUTGETNEXTS 26
-#define SNMPOUTSETREQUESTS 27
-#define SNMPOUTGETRESPONSES 28
-#define SNMPOUTTRAPS 29
-#define SNMPENABLEAUTHENTRAPS 30
-
+#define MAX_NAME_LEN 64 /* number of subid's in a objid */
/*
- * for tcp-connection list access:
+ * RFC 1902: Structure of Management Information for SNMPv2
+ *
+ * Defined Types
+ *
*/
-#include <netinet/in.h>
-#ifdef linux
-struct inpcb {
- struct inpcb *inp_next; /* pointers to other pcb's */
- struct in_addr inp_faddr; /* foreign host table entry */
- u_short inp_fport; /* foreign port */
- struct in_addr inp_laddr; /* local host table entry */
- u_short inp_lport; /* local port */
- int inp_state;
- int uid; /* owner of the connection */
-};
+#define SMI_INTEGER ASN_INTEGER
+#define SMI_STRING ASN_OCTET_STR
+#define SMI_OBJID ASN_OBJECT_ID
+#define SMI_NULLOBJ ASN_NULL
+#define SMI_IPADDRESS (ASN_APPLICATION | 0) /* OCTET STRING, net byte order */
+#define SMI_COUNTER32 (ASN_APPLICATION | 1) /* INTEGER */
+#define SMI_GAUGE32 (ASN_APPLICATION | 2) /* INTEGER */
+# define SMI_UNSIGNED32 SMI_GAUGE32
+#define SMI_TIMETICKS (ASN_APPLICATION | 3) /* INTEGER */
+#define SMI_OPAQUE (ASN_APPLICATION | 4) /* OCTET STRING */
-#endif
+#define SMI_COUNTER64 (ASN_APPLICATION | 6) /* INTEGER */
-extern void TCP_Scan_Init();
-extern int TCP_Scan_Next();
+#define SMI_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
+#define SMI_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
+#define SMI_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
typedef struct variable variable;
+typedef struct variable_list variable_list;
+
typedef int SNMPWM(int, u_char *, u_char, int, u_char *, oid *, int);
typedef u_char *SNMPFV(variable *, oid *, int *, int, int *, SNMPWM **);
-struct variable {
- u_char magic; /* passed to function as a hint */
- char type; /* type of variable */
-/* See important comment in snmp_vars.c relating to acl */
- u_short acl; /* access control list for variable */
- SNMPFV *findVar; /* function that finds variable */
- u_char namelen; /* length of above */
- oid name[32]; /* object identifier of variable */
-};
-
-extern void Interface_Scan_Init();
-extern int Interface_Scan_Next();
-
-#endif
+#endif /* _SNMP_VARS_H_ */