]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
*** empty log message ***
authorkostas <>
Sun, 22 Feb 1998 18:49:02 +0000 (18:49 +0000)
committerkostas <>
Sun, 22 Feb 1998 18:49:02 +0000 (18:49 +0000)
include/asn1.h
include/cache_snmp.h
include/parse.h
snmplib/CMU-SNMP-ReleaseNotes.txt [new file with mode: 0644]
src/fqdncache.cc
src/ipcache.cc
src/net_db.cc

index 1da07f8eaf3baca29f704bb634228a4c9c81b2a5..59bb0794e9d535fb1693b2bbbca5e231fb343cb6 100644 (file)
@@ -1,48 +1,46 @@
+#ifndef _SNMP_ASN1_H_
+#define _SNMP_ASN1_H_
+
 /*
  * Definitions for Abstract Syntax Notation One, ASN.1
  * As defined in ISO/IS 8824 and ISO/IS 8825
  *
- *
  */
-/***********************************************************
-       Copyright 1988, 1989 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.
-******************************************************************/
-
-#ifndef ASN1_H
-#define ASN1_H
-
-/* assume someone else includes "config.h" for us */
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
+/**********************************************************************
+ *
+ *           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: asn1.h,v 1.7 1998/02/22 11:51:06 kostas Exp $
+ * 
+ **********************************************************************/
 
 #ifndef EIGHTBIT_SUBIDS
-typedef u_long oid;
+typedef u_int  oid;
 #define MAX_SUBID   0xFFFFFFFF
 #else
-typedef u_char oid;
+typedef u_char oid;
 #define MAX_SUBID   0xFF
 #endif
 
-#define MAX_OID_LEN        64  /* max subid's in an oid */
+#define MAX_OID_LEN        128 /* max subid's in an oid, per SNMP spec. */
 
 #define ASN_BOOLEAN        (0x01)
 #define ASN_INTEGER        (0x02)
@@ -68,113 +66,34 @@ typedef u_char oid;
 #define IS_CONSTRUCTOR(byte)   ((byte) & ASN_CONSTRUCTOR)
 #define IS_EXTENSION_ID(byte)  (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
 
-/* 
- * internal 64 bit representation:
- */
-struct counter64 {
-    u_num32 high;
-    u_num32 low;
-};
-
-extern u_char *asn_parse_int(u_char * data,
-    int *datalength,
-    u_char * type,
-    long *intp,
-    int intsize);
-
-extern u_char *asn_build_int(u_char * data,
-    int *datalength,
-    u_char type,
-    long *intp,
-    int intsize);
-
-extern u_char *asn_parse_unsigned_int(u_char * data,
-    int *datalength,
-    u_char * type,
-    u_long * intp,
-    int intsize);
-
-extern u_char *asn_build_unsigned_int(u_char * data,
-    int *datalength,
-    u_char type,
-    u_long * intp,
-    int intsize);
-
-extern u_char *asn_parse_string(u_char * data,
-    int *datalength,
-    u_char * type,
-    u_char * string,
-    int *len);
-
-extern u_char *asn_build_string(u_char * data,
-    int *datalength,
-    u_char type,
-    u_char * str,
-    int len);
-
-extern u_char *asn_parse_header(u_char * data,
-    int *datalength,
-    u_char * type);
-
-extern u_char *asn_build_header(u_char * data,
-    int *datalength,
-    u_char type,
-    int len);
-
-extern u_char *asn_build_sequence(u_char * data,
-    int *datalength,
-    u_char type,
-    int len);
-
-extern u_char *asn_parse_length(u_char * data,
-    u_long * eln);
-
-extern u_char *asn_build_length(u_char * data,
-    int *datalength,
-    int len);
-
-extern u_char *asn_parse_objid(
-    u_char * data,
-    int *datalength,
-    u_char * type,
-    oid * objid,
-    int *objidlength);
-
-extern u_char *asn_build_objid(u_char * data,
-    int *datalength,
-    u_char type,
-    oid * objid,
-    int objidlength);
-
-extern u_char *asn_parse_null(u_char * data,
-    int *datalength,
-    u_char * type);
-
-extern u_char *asn_build_null(u_char * data,
-    int *datalength,
-    u_char type);
-extern u_char *asn_parse_bitstring(u_char * data,
-    int *datalength,
-    u_char * type,
-    u_char * str,
-    int *len);
-
-extern u_char *asn_build_bitstring(u_char * data,
-    int *datalength,
-    u_char type,
-    u_char * str,
-    int len);
-
-extern u_char *asn_parse_unsigned_int64(u_char * data,
-    int *datalength,
-    u_char * type,
-    struct counter64 *cp,
-    int cp_size);
-
-extern u_char *asn_build_unsigned_int64(u_char * data,
-    int *datalength,
-    u_char type,
-    struct counter64 *cp,
-    int cp_size);
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+u_char *asn_build_header(u_char *, int *, u_char, int);
+u_char *asn_parse_int(u_char *, int *, u_char *, int *, int);
+u_char *asn_parse_unsigned_int(u_char *, int *, u_char *, u_int *, int);
+u_char *asn_build_int(u_char *, int *, u_char, int *, int);
+u_char *asn_build_unsigned_int(u_char *, int *, u_char, u_int *, int);
+u_char *asn_parse_string(u_char *, int *, u_char *, u_char *, int *);
+u_char *asn_build_string(u_char *, int *, u_char, u_char *, int);
+u_char *asn_parse_header(u_char *, int *, u_char *);
+u_char *asn_build_header_with_truth(u_char *, int *, u_char, int, int);
+
+u_char *asn_parse_length(u_char *, u_int *);
+u_char *asn_build_length(u_char *, int *, int, int);
+u_char *asn_parse_objid(u_char *, int *, u_char *, oid *, int *);
+u_char *asn_build_objid(u_char *, int *, u_char, oid *, int);
+u_char *asn_parse_null(u_char *, int *, u_char *);
+u_char *asn_build_null(u_char *, int *, u_char);
+
+u_char *asn_parse_bitstring(u_char *, int *, u_char *, u_char *, int *);
+u_char *asn_build_bitstring(u_char *, int *, u_char, u_char *, int);
+
+u_char *asn_build_exception(u_char *, int *, u_char);
+
+#ifdef __cplusplus
+}
 #endif
+
+#endif /* _SNMP_ASN1_H_ */
index 6aae0147722c95d0595791be0133790be15710f1..6459a5b74511daf3586ec0723914a0552b4e04b8 100644 (file)
 #ifndef CACHE_SNMP_H
 #define CACHE_SNMP_H
 
-/* mib stuff here */
+#include "snmp.h"
+#include "snmp_impl.h"
+#include "asn1.h"
+#include "snmp_api.h"
+#include "snmp_client.h"
+#include "snmp_vars.h"
+#include "snmp_oidlist.h"
+#include "mib.h"
 
-struct subtree {
-    oid name[16];              /* objid prefix of subtree */
-    u_char namelen;            /* number of subid's in name above */
-    struct variable *variables;        /* pointer to variables array */
-    int variables_len;         /* number of entries in above array */
-    int variables_width;       /* sizeof each variable entry */
-    struct subtree *next;
-};
-
-#if 1
-#define variable2 variable
-#define variable4 variable
-#define variable5 variable
-#define variable7 variable
-#define variable13 variable
-#else
-/**
- * This is a new variable structure that doesn't have as much memory
- * tied up in the object identifier.  It's elements have also been re-arranged
- * so that the name field can be variable length.  Any number of these
- * structures can be created with lengths tailor made to a particular
- * application.  The first 5 elements of the structure must remain constant.
- */
-struct variable2 {
-    u_char magic;              /* passed to function as a hint */
-    char type;                 /* type of variable */
-    u_short acl;               /* access control list for variable */
-    u_char *(*findVar) ();     /* function that finds variable */
-    u_char namelen;            /* length of name below */
-    oid name[2];               /* object identifier of variable */
-};
-
-struct variable4 {
-    u_char magic;              /* passed to function as a hint */
-    char type;                 /* type of variable */
-    u_short acl;               /* access control list for variable */
-    u_char *(*findVar) ();     /* function that finds variable */
-    u_char namelen;            /* length of name below */
-    oid name[4];               /* object identifier of variable */
-};
-
-struct variable7 {
-    u_char magic;              /* passed to function as a hint */
-    char type;                 /* type of variable */
-    u_short acl;               /* access control list for variable */
-    u_char *(*findVar) ();     /* function that finds variable */
-    u_char namelen;            /* length of name below */
-    oid name[7];               /* object identifier of variable */
-};
-struct variable13 {
-    u_char magic;              /* passed to function as a hint */
-    char type;                 /* type of variable */
-    u_short acl;               /* access control list for variable */
-    u_char *(*findVar) ();     /* function that finds variable */
-    u_char namelen;            /* length of name below */
-    oid name[13];              /* object identifier of variable */
-};
+/* debugging redirected to squid (DW approach) */
 
+#ifdef __STDC__
+void (*snmplib_debug) (int,...); 
+#else
+void (*snmplib_debug) (va_alist));
 #endif
 
+/* mib stuff here */
 
 /* MIB definitions
  * We start from the SQUIDMIB as the root of the subtree
  *
  * we are under : iso.org.dod.internet.experimental.nsfnet.squid
- *
+ *                 1   3   6     1          3         25     17
  */
 
+#define SQUIDMIB 1, 3, 6, 1, 3, 25, 17     /* length is 7 */
+#define LEN_SQUIDMIB 7
 
-#define SQUIDMIB 1, 3, 6, 1, 3, 25, 17
-
+#define SYSMIB 1, 3, 6, 1, 2, 1, 1     /* basic system vars */
+#define LEN_SYSMIB 7
 
 /* basic groups under .squid */
 
-#define SQ_SYS SQUIDMIB, 1
+#define SQ_SYS  SQUIDMIB, 1            /* length is 8 */
+#define LEN_SQ_SYS LEN_SQUIDMIB+1
 #define SQ_CONF SQUIDMIB, 2
-#define SQ_PRF SQUIDMIB, 3
-#define SQ_ACC SQUIDMIB, 6
-#define SQ_SEC SQUIDMIB, 5
-#define SQ_NET SQUIDMIB, 4
+#define LEN_SQ_CONF LEN_SQUIDMIB+1
+#define SQ_PRF  SQUIDMIB, 3
+#define LEN_SQ_PRF LEN_SQUIDMIB+1
+#define SQ_NET  SQUIDMIB, 4
+#define LEN_SQ_NET LEN_SQUIDMIB+1
+#define SQ_SEC  SQUIDMIB, 5
+#define LEN_SQ_SEC LEN_SQUIDMIB+1
+#define SQ_ACC  SQUIDMIB, 6
+#define LEN_SQ_ACC LEN_SQUIDMIB+1
+
+enum { /* basic system mib info group */
+SYSMIB_START,
+VERSION_DESCR,
+VERSION_ID,
+UPTIME,
+SYSCONTACT,
+SYSYSNAME,
+SYSLOCATION,
+SYSSERVICES,
+SYSORLASTCHANGE,
+SYSMIB_END
+};
 
 /* cacheSystem group */
 
 enum {
+    SYS_START,
     SYSVMSIZ,
-    SYSSTOR
+    SYSSTOR,
+    SYSFDTBL,
+    SYS_END
 };
 
 /* cacheConfig group */
 
 enum {
+    CONF_START,
     CONF_ADMIN,
     CONF_UPTIME,
+    CONF_WAIS_RHOST,
+    CONF_WAIS_RPORT,
+    CONF_LOG_LVL,
+    CONF_PTBL,
+    CONF_STORAGE,
+    CONF_TIO,
+    CONF_END
+};
+
+enum {
+    CONF_ST_START,
     CONF_ST_MMAXSZ,
     CONF_ST_MHIWM,
     CONF_ST_MLOWM,
     CONF_ST_SWMAXSZ,
     CONF_ST_SWHIWM,
     CONF_ST_SWLOWM,
-    CONF_WAIS_RHOST,
-    CONF_WAIS_RPORT,
+    CONF_ST_END
+};
+
+enum {
+    CONF_TIO_START,
     CONF_TIO_RD,
     CONF_TIO_CON,
     CONF_TIO_REQ,
-    CONF_LOG_LVL,
+    CONF_TIO_END
+};
+
+enum {
+    CONF_PTBL_START,
     CONF_PTBL_ID,
     CONF_PTBL_NAME,
     CONF_PTBL_IP,
     CONF_PTBL_HTTP,
     CONF_PTBL_ICP,
     CONF_PTBL_TYPE,
-    CONF_PTBL_STATE
+    CONF_PTBL_STATE,
+    CONF_PTBL_END
 };
 
 /* cacheNetwork group */
 
 enum {
+    NETDB_START,
     NETDB_ID,
     NETDB_NET,
     NETDB_PING_S,
@@ -129,45 +130,85 @@ enum {
     NETDB_RTT,
     NETDB_PINGTIME,
     NETDB_LASTUSE,
-    NETDB_LINKCOUNT,
+    NETDB_END
+};
+
+enum {
+    NET_IPC_START,
     NET_IPC_ID,
     NET_IPC_NAME,
     NET_IPC_IP,
     NET_IPC_STATE,
+    NET_IPC_END
+};
+
+enum {
+    NET_DNS_START,
+    NET_DNS_IPCACHE,
+    NET_DNS_FQDNCACHE,
+    NET_DNS_END
+};
+
+
+enum {
+    NET_FQDN_START,
     NET_FQDN_ID,
     NET_FQDN_NAME,
     NET_FQDN_IP,
     NET_FQDN_LASTREF,
     NET_FQDN_EXPIRES,
     NET_FQDN_STATE,
-    NET_TCPCONNS,
-    NET_UDPCONNS,
-    NET_INTHRPUT,
-    NET_OUTHRPUT
+    NET_FQDN_END
+};
+
+enum {
+    NET_START,
+    NET_NETDBTBL,
+    NET_DNS,
+    NET_NETSTAT,
+    NET_END
 };
 
 enum {
+    NETSTAT_START,
+    NETSTAT_TCPCONNS,
+    NETSTAT_UDPCONNS,
+    NETSTAT_INTHRPUT,
+    NETSTAT_OUTHRPUT
+};
+
+enum { 
+    PERF_START,
+    PERF_SYS,
+    PERF_PROTO,
+    PERF_PEER,
+    PERF_END
+};
+
+enum {
+    PERF_SYS_START,
     PERF_SYS_PF,
     PERF_SYS_NUMR,
     PERF_SYS_DEFR,
     PERF_SYS_MEMUSAGE,
     PERF_SYS_CPUUSAGE,
     PERF_SYS_MAXRESSZ,
-    PERF_SYS_CURMEMSZ,
+    PERF_SYS_NUMOBJCNT,
     PERF_SYS_CURLRUEXP,
     PERF_SYS_CURUNLREQ,
     PERF_SYS_CURUNUSED_FD,
     PERF_SYS_CURRESERVED_FD,
-    PERF_SYS_NUMOBJCNT,
-    PERF_PROTOSTAT_ID,
-    PERF_PROTOSTAT_KBMAX,
-    PERF_PROTOSTAT_KBMIN,
-    PERF_PROTOSTAT_KBAVG,
-    PERF_PROTOSTAT_KBNOW,
-    PERF_PROTOSTAT_HIT,
-    PERF_PROTOSTAT_MISS,
-    PERF_PROTOSTAT_REFCOUNT,
-    PERF_PROTOSTAT_TRNFRB,
+    PERF_SYS_END
+};
+
+enum {
+    PERF_PROTOSTAT_START,
+    PERF_PROTOSTAT_AGGR,
+    PERF_PROTOSTAT_END
+};
+
+enum {
+    PERF_PROTOSTAT_AGGR_START,
     PERF_PROTOSTAT_AGGR_HTTP_REQ,
     PERF_PROTOSTAT_AGGR_HTTP_HITS,
     PERF_PROTOSTAT_AGGR_HTTP_ERRORS,
@@ -178,13 +219,29 @@ enum {
     PERF_PROTOSTAT_AGGR_KBYTES_IN,
     PERF_PROTOSTAT_AGGR_KBYTES_OUT,
     PERF_PROTOSTAT_AGGR_CURSWAP,
-    PERF_SYS_FD_NUMBER,
-    PERF_SYS_FD_TYPE,
-    PERF_SYS_FD_TOUT,
-    PERF_SYS_FD_NREAD,
-    PERF_SYS_FD_NWRITE,
-    PERF_SYS_FD_ADDR,
-    PERF_SYS_FD_NAME,
+    PERF_PROTOSTAT_AGGR_HTTP_SVC_5,
+    PERF_PROTOSTAT_AGGR_HTTP_SVC_60,
+    PERF_PROTOSTAT_AGGR_ICP_SVC_5,
+    PERF_PROTOSTAT_AGGR_ICP_SVC_60,
+    PERF_PROTOSTAT_AGGR_DNS_SVC_5,
+    PERF_PROTOSTAT_AGGR_DNS_SVC_60,
+    PERF_PROTOSTAT_AGGR_END
+};
+
+enum {
+    SYS_FD_START,
+    SYS_FD_NUMBER,
+    SYS_FD_TYPE,
+    SYS_FD_TOUT,
+    SYS_FD_NREAD,
+    SYS_FD_NWRITE,
+    SYS_FD_ADDR,
+    SYS_FD_NAME,
+    SYS_FD_END
+};
+
+enum {
+    PERF_PEERSTAT_START,
     PERF_PEERSTAT_ID,
     PERF_PEERSTAT_SENT,
     PERF_PEERSTAT_PACKED,
@@ -192,8 +249,30 @@ enum {
     PERF_PEERSTAT_RTT,
     PERF_PEERSTAT_IGN,
     PERF_PEERSTAT_KEEPAL_S,
-    PERF_PEERSTAT_KEEPAL_R
+    PERF_PEERSTAT_KEEPAL_R,
+    PERF_PEERSTAT_END
 };
 
+/* First, we have a huge array of MIBs this agent knows about */
+struct MIBListEntry {
+  oid            Name[9]; /* Change as appropriate */
+  long           NameLen;
+  oid_GetFn     *GetFn;
+  oid_GetNextFn *GetNextFn;
+};
+
+variable_list *snmp_basicFn(variable_list *, long *);
+variable_list *snmp_confPtblFn(variable_list *, long *);
+variable_list *snmp_confFn(variable_list *, long *);
+variable_list *snmp_sysFn(variable_list *, long *);
+variable_list *snmp_prfSysFn(variable_list *, long *);
+variable_list *snmp_prfProtoFn(variable_list *, long *);
+variable_list *snmp_prfPeerFn(variable_list *, long *);
+variable_list *snmp_netdbFn(variable_list *, long *);
+variable_list *snmp_dnsFn(variable_list *, long *);
+variable_list *snmp_ipcacheFn(variable_list *, long *);
+variable_list *snmp_fqdncacheFn(variable_list *, long *);
+
 #endif
 #endif
index 4b08f9b67eb6129bfe0e5fa20da5bca7e4db7177..04b94b8cfc63e7c423a050da2b7acba43ab6d45b 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _HAVE_PARSE_H_
+#define _HAVE_PARSE_H_
+
 /***********************************************************
        Copyright 1989 by Carnegie Mellon University
 
@@ -19,55 +22,31 @@ 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.
 ******************************************************************/
-
 /*
  * parse.h
  */
 
-#ifndef _PARSE_H
-#define _PARSE_H
-
-#define MAXLABEL       64      /* maximum characters in a label */
-#define MAXTOKEN       64      /* maximum characters in a token */
-#define MAXQUOTESTR    512     /* maximum characters in a quoted string */
-
 /*
  * A linked list of tag-value pairs for enumerated integers.
  */
 struct enum_list {
     struct enum_list *next;
-    int value;
+    int        value;
     char *label;
 };
 
-/*
- * A linked list of nodes.
- */
-struct node {
-    struct node *next;
-    char label[MAXLABEL];      /* This node's (unique) textual name */
-    u_long subid;              /* This node's integer subidentifier */
-    char parent[MAXLABEL];     /* The parent's textual name */
-    int type;                  /* The type of object this represents */
-    struct enum_list *enums;   /* (optional) list of enumerated integers
-                                * (otherwise NULL) */
-    char *description;         /* description (a quoted string) */
-};
-
 /*
  * 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 *parent;
-    char label[MAXLABEL];      /* This node's textual name */
-    u_long subid;              /* This node's integer subidentifier */
+struct snmp_mib_tree {
+    struct snmp_mib_tree *child_list;  /* list of children of this node */
+    struct snmp_mib_tree *next_peer;   /* Next node in list of peers */
+    struct snmp_mib_tree *parent;
+    char label[64];            /* This node's textual name */
+    u_int subid;               /* This node's integer subidentifier */
     int type;                  /* This node's object type */
-    struct enum_list *enums;   /* (optional) list of enumerated integers
-                                * (otherwise NULL) */
-    void (*printer) ();                /* Value printing function */
-    char *description;         /* description (a quoted string) */
+    struct enum_list *enums;   /* (optional) list of enumerated integers (otherwise NULL) */
+    void (*printer)();     /* Value printing function */
 };
 
 /* non-aggregate types for tree end nodes */
@@ -80,14 +59,42 @@ struct tree {
 #define TYPE_COUNTER       6
 #define TYPE_GAUGE         7
 #define TYPE_TIMETICKS     8
-#define TYPE_OPAQUE        9
+#define TYPE_OPAQUE                9
 #define TYPE_NULL          10
-#define TYPE_COUNTER64      11
-#define TYPE_BITSTRING      12
-#define TYPE_NSAPADDRESS    13
-#define TYPE_UINTEGER      14
 
-struct tree *read_mib(const char *fname);
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+void init_mib(char *);
+int read_objid(char *, oid *, int *);
+void  print_objid(oid *, int);
+void sprint_objid(char *, oid *, int);
+void print_variable(oid *, int, struct variable_list *);
+void sprint_variable(char *, oid *, int, struct variable_list *);
+void sprint_value(char *, oid *, int, struct variable_list *);
+void print_value(oid *, int, struct variable_list *);
 
+/*void print_variable_list(struct variable_list *);*/
+/*void print_variable_list_value(struct variable_list *);*/
+/*void print_type(struct variable_list *);*/
+void print_oid_nums(oid *, int);
+
+struct snmp_mib_tree *read_mib();
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef _SNMP_H
+#ifndef SQUID_H
+#ifdef __STDC__
+void (*snmplib_debug) (int,char *,...); 
+#else
+void (*snmplib_debug) (va_alist));
 #endif
+#endif
+
+#endif
+
+#endif /* _HAVE_PARSE_H_ */
diff --git a/snmplib/CMU-SNMP-ReleaseNotes.txt b/snmplib/CMU-SNMP-ReleaseNotes.txt
new file mode 100644 (file)
index 0000000..f9aa8ab
--- /dev/null
@@ -0,0 +1,230 @@
+Release Notes, Version 1.8
+
+Ryan Troll <ryan@andrew.cmu.edu>
+
+Major Changes:
+
+Portability / Bug Fixes
+#######################
+
+Incorporated patches from Par Westesson <pw@cbc.chalmers.se>.  Par's
+description of the patches sent to me:
+
+- The SNMPv2 error code definitions in asn1.c have been fixed.  [ They
+  were previously listed as Hex values, instead of decimal. ]
+
+- The function snmp_var_EncodeVarBind in snmp_vars.c has been modified
+  to be able to encode the exception values noSuchObject,
+  noSuchInstance and endOfMibView. It does so using the definitions
+  added in snmp_vars.h and the function asn_build_exception added in
+  asn1.c.
+
+  Note that we haven't included support for decoding these exceptions
+  (since we're using the library in an agent rather than a manager).
+  Including support for this would however only require some small
+  changes to the function snmp_var_DecodeVarBind and the addition of
+  an asn_parse_exception function.
+
+  We also haven't made any changes to the print_type function in
+  mib.c, so these values can't be printed. Otherwise, no other changes
+  to the library should be necessary because of the inclusion of the
+  support for the exceptions.
+
+- All calls to the macro ASN_PARSE_ERROR which increments the counter
+  snmpInASNParseErrs have been removed from the functions that encode
+  SNMP packets since it should only be used when decoding. This
+  affects the files snmp_vars.c, snmp_msg.c and snmp_pdu.c.
+
+Incorporated patches from Sebastien Rosset
+(sebastien.rosset@cstelecom.cie-signaux.fr):
+
+- Patches that augment Par's changes for noSuchObject, etc.
+
+- Fixed a bug when trying to deal with Bulk requests
+
+
+
+MAX_OID_LEN is now correctly set to 128 subids.
+
+Removed bcmp, bzero calls, for Solaris 2.4.
+
+Parser now handles description fields that begin with a quote
+immediately followed by a word, instead of failing.  (Thanks to Simon
+Burr <simonb@uk.uu.net>)
+
+
+----------------------------------------------------------------------
+
+Release Notes, Version 1.7
+October 14, 1997
+Ryan Troll <ryan@andrew.cmu.edu>
+
+Major changes:
+
+Portability / Bug Fixes
+#######################
+
+Incorporated patches for compilation under Visual C++ 4.0 / WinNT.
+(Thanks to Steven Chew <smchew@ibm.net>)
+
+It is now possible to compile the Irix version with '-n32', '-32', or
+'-o32' and have it installed into the appropriate place with the
+"--with-mips-abi=[n32,o32,32]" flag to configure.  (Thanks to Rob
+Earhart <earhart+@cmu.edu>)
+
+Incorporated patch for socket options under Linux.  Now sending UDP
+packets to remote hosts that are unavailable should not hurt anything
+else.  (Thanks to Chaskiel Grundman <cg2v+@andrew.cmu.edu>)
+
+Other
+#####
+
+The included MIB is now correct, and expanded.
+
+----------------------------------------------------------------------
+
+Release Notes, Version 1.6
+May 27, 1997
+Ryan Troll <ryan@andrew.cmu.edu>
+
+Major changes:
+
+Portability / Bug Fixes
+#######################
+
+Correct use of int/long, so that machines using 64bit longs may use
+the library.
+
+Miniclient function declarations (and others) are now wrapped within
+the appropriate c++ wrappers.
+
+Added timer defines, to allow the library to compile with the Cygnus
+Win32 compiler.
+
+Now handles returns strings that are (supposedly) allocated yet
+contain no information.
+
+Fixed a few calls to asn functions that were passing sizeof(Pointer)
+rather than sizeof(what pointer points to), which weren't caught when
+these were the same.  (But, on 64 bit machines...)
+
+
+Informs
+#######
+
+The built-in snmp PDU/Session management now correctly handles SNMP
+Informs.  
+
+
+Parser
+######
+
+The parser now accepts two additional pieces of information in a mib:
+DESCRIPTION and INDEX.  It also handles "ACCESS" and "MAX-ACCESS".
+With these additions, SNMPv2 SMI MIBs can be parsed with minimal
+changes.  (Specificly, with the removal of text conventions, etc.)
+
+The included CMU MIB should be a good example.
+
+
+Other
+#####
+
+Changed some symbol names to static, to help reduce symbol name
+conflict with applications.
+
+Corrected incorrect backwards-compatibility defines.
+
+----------------------------------------------------------------------
+
+Release Notes, Version 1.5
+March 31, 1997
+Ryan Troll <ryan@andrew.cmu.edu>
+
+
+
+This SNMP library is based on the SNMP1.1b library that has been
+available via ftp.net.cmu.edu since September of 1991.  Many changes
+have been made to increase it's performance, clean up memory leaks,
+and prepare it for use with SNMPv2 managers and agents.
+
+
+This is the last release of the CMU SNMP Library, aside from bug fixes
+and portability patches. Future SNMP development will be in a new
+direction. The new CMU SNMP library will be fully object oriented;
+compatible with SNMPv1, SNMPv2 Classic, and possibly others; and
+handle SMIv2 MIBs with the use of a MIB Compiler (IE: SMICng). 
+
+The major changes since CMU SNMP 1.1b are:
+
+Autoconf
+########
+
+The SNMP Library now uses GNU Autoconf to determine system specific
+information. 
+
+Trap and PDU Type Definitions
+#############################
+
+All well-known traps and PDUs are now defined snmp_pdu.h, and are of
+the format SNMP_TRAP_${TrapType} and SNMP_PDU_${PDUType}.  All defines
+previously used to specify trap and pdu type should still work. 
+
+Installation Directories
+########################
+
+The library is now installed in $(exec_prefix)/lib, and the include
+files are installed in $(exec_prefix)/include.
+
+Includes
+########
+
+Applications now only need to include <snmp/snmp.h>, instead of
+all the separate headers required previously.
+
+MiniClient
+##########
+
+This library now contains a mini-client.  The miniclient only
+implements the Get, GetNext, and Set functions.  By using the
+miniclient, SNMP capable applications may be quickly generated.  (We
+use the miniclient for most of our internal monitoring stuff.)
+
+Optimizations
+#############
+
+Various parts of the library have been optimized.  The most
+significant optimization adds 6 bytes to every outgoing packet the
+length identifiers for the Message, PDU, and Variable List SEQUENCEs
+are now all encoded in three bytes instead of 1.  However, this
+reduces the number of iterations over the variable list during
+encoding from 4 to 1.  There is also no delayed range shifting of the
+entire encoded stream to insert a better length.
+
+Purify
+######
+
+All of the SNMP Applications we've compiled using this library have
+been purified, and all errors / complaints / warnings have been taken
+care of.  Based on this, we believe the library is free of memory
+leaks
+
+Trap Generation
+###############
+
+There are no longer routines for trap generation within this library.
+This may be done by the application.
+
+V1 - V2 Coexistance
+###################
+
+There are two functions (snmp_coexist_V2toV1 and snmp_coexist_V1toV2)
+that should provide V1-V2 coexistance per RFC 1908.  However, these
+have not been tested.
+
+Version
+#######
+
+The snmp_session structure now contains a variable called "Version".
+This variable specifies the default version of all incoming / outgoing
+data for this session.
index 0542fafabb5ff26e5ab69fe632f4e633c2cf6ec8..4c7e102bf09d8e6a83e0e4411d9e7123b92fd46c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.82 1998/02/19 23:09:50 wessels Exp $
+ * $Id: fqdncache.cc,v 1.83 1998/02/22 11:59:00 kostas Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -895,77 +895,85 @@ fqdncache_restart(void)
 }
 
 #ifdef SQUID_SNMP
-u_char *
-var_fqdn_entry(struct variable *vp, oid * name, int *length, int exact, int
-    *var_len,
-    SNMPWM ** write_method)
-{
-    static int current = 0;
-    static long long_return;
-    static char *cp = NULL;
-    static fqdncache_entry *fq;
-    static struct in_addr fqaddr;
-    int i;
-    oid newname[MAX_NAME_LEN];
-    int result;
-    static char snbuf[256];
-
-    debug(49, 3) ("snmp: var_fqdn_entry called with magic=%d \n", vp->magic);
-    debug(49, 3) ("snmp: var_fqdn_entry with (%d,%d)\n", *length, *var_len);
-    sprint_objid(snbuf, name, *length);
-    debug(49, 3) ("snmp: var_fqdn_entry oid: %s\n", snbuf);
-
-    memcpy((char *) newname, (char *) vp->name, (int) vp->namelen * sizeof(oid));
-    newname[vp->namelen] = (oid) 1;
-
-    debug(49, 5) ("snmp var_fqdn_entry: hey, here we are.\n");
-
-    fq = NULL;
-    i = 0;
-    while (fq != NULL) {
-       newname[vp->namelen] = i + 1;
-       result = snmpCompare(name, *length, newname, (int) vp->namelen + 1);
-       if ((exact && (result == 0)) || (!exact && (result < 0))) {
-           debug(49, 5) ("snmp var_fqdn_entry: yup, a match.\n");
-           break;
-       }
-       i++;
-       fq = NULL;
-    }
-    if (fq == NULL)
-       return NULL;
 
-    debug(49, 5) ("hey, matched.\n");
-    memcpy((char *) name, (char *) newname, ((int) vp->namelen + 1) * sizeof(oid));
-    *length = vp->namelen + 1;
-    *write_method = 0;
-    *var_len = sizeof(long);   /* default length */
-    sprint_objid(snbuf, newname, *length);
-    debug(49, 5) ("snmp var_fqdn_entry  request for %s (%d)\n", snbuf, current);
+int
+fqdn_getMax()
+{
+       int i=0;
+       fqdncache_entry *fq=NULL;
+
+       fq=(fqdncache_entry *) hash_first(fqdn_table);
+       if (fq!=NULL) {
+               i=1;
+               while ((fq=(fqdncache_entry *)hash_next(fqdn_table))) i++;
+       }
+       return i;
+} 
+
+variable_list *snmp_fqdncacheFn(variable_list *Var, long *ErrP)
+{
+  variable_list *Answer;
+  static fqdncache_entry *fq=NULL;
+  static struct in_addr fqaddr;
+  int cnt=0;
+
+  debug(49,5)("snmp_fqdncacheFn: Processing request with %d.%d!\n",Var->name[11],Var->name[12]);
 
-    switch (vp->magic) {
+  cnt=Var->name[12];
+
+  fq=(fqdncache_entry *) hash_first(fqdn_table);
+  while (fq && --cnt) 
+       fq = (fqdncache_entry *) hash_next(fqdn_table);
+  if (fq==NULL || cnt!=0) {
+       *ErrP = SNMP_ERR_NOSUCHNAME;
+       return NULL;
+  }    
+  Answer = snmp_var_new(Var->name, Var->name_length);
+  *ErrP = SNMP_ERR_NOERROR;
+
+  switch(Var->name[11]) {
     case NET_FQDN_ID:
-       long_return = (long) i;
-       return (u_char *) & long_return;
+       Answer->type = ASN_INTEGER;
+       Answer->val.integer = xmalloc(Answer->val_len);
+       Answer->val_len = sizeof(long);
+        *(Answer->val.integer)= Var->name[12];
+       break;
     case NET_FQDN_NAME:
-       cp = fq->names[0];
-       *var_len = strlen(cp);
-       return (u_char *) cp;
+        Answer->type = SMI_STRING;
+       Answer->val_len=strlen(fq->names[0]);
+       Answer->val.string=xstrdup((char *)fq->names[0]);
+       break;
     case NET_FQDN_IP:
-       safe_inet_addr(fq->name, &fqaddr);
-       long_return = (long) fqaddr.s_addr;
-       return (u_char *) & long_return;
+       Answer->type = SMI_IPADDRESS;
+       Answer->val.integer = xmalloc(Answer->val_len);
+       Answer->val_len = sizeof(long);
+        safe_inet_addr(fq->name, &fqaddr);
+        *(Answer->val.integer)= (long) fqaddr.s_addr;
+       break;
     case NET_FQDN_LASTREF:
-       long_return = fq->lastref;
-       return (u_char *) & long_return;
+       Answer->type = SMI_TIMETICKS;
+       Answer->val.integer = xmalloc(Answer->val_len);
+       Answer->val_len = sizeof(long);
+        *(Answer->val.integer)= fq->lastref;
+       break;
     case NET_FQDN_EXPIRES:
-       long_return = fq->expires;
-       return (u_char *) & long_return;
+       Answer->type = SMI_TIMETICKS;
+       Answer->val.integer = xmalloc(Answer->val_len);
+       Answer->val_len = sizeof(long);
+        *(Answer->val.integer)= fq->expires;
+       break;
     case NET_FQDN_STATE:
-       long_return = fq->status;
-       return (u_char *) & long_return;
+       Answer->type = ASN_INTEGER;
+       Answer->val.integer = xmalloc(Answer->val_len);
+       Answer->val_len = sizeof(long);
+        *(Answer->val.integer)= fq->status;
+       break;
     default:
-       return NULL;
-    }
+        *ErrP = SNMP_ERR_NOSUCHNAME;
+        snmp_var_free(Answer);
+        xfree(Answer->val.integer);
+        return(NULL);
+  }
+  return Answer;
 }
 #endif
index 817d1d57fb4390b2acc04f68bd83a6319a897ef0..0eab4cdec18bc6dd243366475b5ca63a6a102154 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.157 1998/02/19 23:09:52 wessels Exp $
+ * $Id: ipcache.cc,v 1.158 1998/02/22 11:58:35 kostas Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -1059,61 +1059,60 @@ ipcache_restart(void)
 
 #ifdef SQUID_SNMP
 
-u_char *
-var_ipcache_entry(struct variable *vp, oid * name, int *length, int exact, int *var_len,
-    SNMPWM ** write_method)
+int ipcache_getMax()
 {
-    static char snbuf[256], *cp;
-    static long long_return;
-    static int current = 0;
-    oid newname[MAX_NAME_LEN];
-    int result;
-    dlink_node *m = NULL;
-    ipcache_entry *IPc;
-    int cnt = 1;
-
-    debug(49, 3) ("snmp: var_ipcache_entry called with magic=%d\n", vp->magic);
-    debug(49, 3) ("snmp: var_ipcache_entry with (%d,%d)\n", *length, *var_len);
-    sprint_objid(snbuf, name, *length);
-    debug(49, 3) ("snmp: var_ipcache_entry oid: %s\n", snbuf);
-
-    memcpy((char *) newname, (char *) vp->name, (int) vp->namelen * sizeof(oid));
-    newname[vp->namelen] = (oid) 1;
-
-    debug(49, 5) ("snmp var_ipcache_entry: hey, here we are.\n");
-
-
-    for (m = lru_list.head; m; m = m->next, cnt++) {
-       newname[vp->namelen] = cnt;
-       result = snmpCompare(name, *length, newname, (int) vp->namelen + 1);
-       if ((exact && (result == 0)) || (!exact && (result < 0))) {
-           debug(49, 5) ("snmp var_ipcache_entry: yup, a match.\n");
-           break;
-       }
-    }
+       int i=0;
+       dlink_node *m = NULL;
+       for (m=lru_list.head; m &&m->data ; m=m->next) i++;
+       return i;
+}
 
-    if (m == NULL)
-       return NULL;
-    if ((IPc = m->data) == NULL)
+variable_list *snmp_ipcacheFn(variable_list *Var, long *ErrP)
+{
+  variable_list *Answer;
+  ipcache_entry *IPc= NULL;
+  dlink_node *m = NULL;
+  int cnt = 1;
+  debug(49,5)("snmp_ipcacheFn: Processing request with %d.%d!\n",Var->name[11],Var->name[12]);
+
+  cnt=Var->name[12];
+
+  for (m = lru_list.head; --cnt && m; m = m->next);
+  debug(49,5)("snmp_ipcacheFn: cnt now=%d m=%x, data=%x\n",cnt,m->data);
+  if (!m || !(IPc = m->data)) {
+        *ErrP = SNMP_ERR_NOSUCHNAME;
        return NULL;
-
-    current++;
-    switch (vp->magic) {
+  }
+  Answer = snmp_var_new(Var->name, Var->name_length);
+  *ErrP = SNMP_ERR_NOERROR;
+  Answer->val.integer = xmalloc(Answer->val_len);
+  Answer->val_len = sizeof(long);
+  switch(Var->name[11]) {
     case NET_IPC_ID:
-       long_return = (int) cnt;
-       return (u_char *) & long_return;
+        Answer->type = SMI_INTEGER;
+        *(Answer->val.integer)= Var->name[12];
+       break;
     case NET_IPC_NAME:
-       cp = IPc->name;
-       *var_len = strlen(cp);
-       return (u_char *) cp;
+       xfree(Answer->val.integer);
+       Answer->type = SMI_STRING;
+       Answer->val_len = strlen(IPc->name);
+       Answer->val.string = xstrdup(IPc->name);
+       break;
     case NET_IPC_IP:
-       long_return = IPc->addrs.in_addrs[0].s_addr;    /* first one only */
-       return (u_char *) & long_return;
+       Answer->type = SMI_IPADDRESS;
+        *(Answer->val.integer)=IPc->addrs.in_addrs[0].s_addr;    /* first one only */
+       break;
     case NET_IPC_STATE:
-       long_return = IPc->status;
-       return (u_char *) & long_return;
+        Answer->type = SMI_INTEGER;
+        *(Answer->val.integer)= IPc->status;
+       break;
     default:
-       return NULL;
-    }
+        *ErrP = SNMP_ERR_NOSUCHNAME;
+        snmp_var_free(Answer);
+        xfree(Answer->val.integer);
+        return(NULL);
+  }
+  return Answer;
 }
 #endif
+
index e5a98a02f5d4beda24bd9ec3d4f5cc3c298c7e9a..159cf58858836c0b44e1db6aaae9541fc2e2efe9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.66 1998/02/19 23:09:56 wessels Exp $
+ * $Id: net_db.cc,v 1.67 1998/02/22 11:59:33 kostas Exp $
  *
  * DEBUG: section 37    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -699,76 +699,97 @@ netdbUpdatePeer(request_t * r, peer * e, int irtt, int ihops)
 }
 
 #ifdef SQUID_SNMP
-u_char *
-var_netdb_entry(struct variable *vp, oid * name, int *length, int exact, int *var_len, SNMPWM ** write_method)
+int netdb_getMax()
 {
-    oid newname[MAX_NAME_LEN];
-    static char snbuf[256];
-    static netdbEntry *n = NULL;
-    static long long_return;
-    int cnt = 1;
-    int result;
-
-    debug(49, 3) ("snmp: var_netdb_entry called with magic=%d\n", vp->magic);
-    debug(49, 3) ("snmp: var_netdb_entry with (%d,%d)\n", *length, *var_len);
-    sprint_objid(snbuf, name, *length);
-    debug(49, 3) ("snmp: var_netdb_entry oid: %s\n", snbuf);
-
-    memcpy((char *) newname, (char *) vp->name, (int) vp->namelen * sizeof(oid));
-    newname[vp->namelen] = (oid) 1;
-
-    debug(49, 5) ("snmp var_netdb_entry: hey, here we are.\n");
-#ifdef USE_ICMP
-    n = (netdbEntry *) hash_first(addr_table);
-    while (n != NULL) {
-       newname[vp->namelen] = cnt++;
-       result = snmpCompare(name, *length, newname, (int) vp->namelen + 1);
-       if ((exact && (result == 0)) || (!exact && (result < 0))) {
-           debug(49, 5) ("snmp var_netdb_entry: yup, a match.\n");
-           break;
-       }
-       n = (netdbEntry *) hash_next(addr_table);
-    }
+  int i=0;
+#if USE_ICMP
+  static netdbEntry *n=NULL;
+
+  n = (netdbEntry *) hash_first(addr_table);
+  if (n!=NULL) {
+       i=1;
+       while ((n=(netdbEntry *)hash_next(addr_table))) i++;
+  }
 #endif
-    if (n == NULL)
-       return NULL;
+  return i;
+}
 
-    debug(49, 5) ("hey, matched.\n");
-    memcpy((char *) name, (char *) newname, ((int) vp->namelen + 1) * sizeof(oid));
-    *length = vp->namelen + 1;
-    *write_method = 0;
-    *var_len = sizeof(long);   /* default length */
-    sprint_objid(snbuf, newname, *length);
-    debug(49, 5) ("snmp var_netdb_entry with peertable request for %s (%d)\n", snbuf, newname[10]);
+variable_list *snmp_netdbFn(variable_list *Var, long *ErrP)
+{
+  variable_list *Answer;
+  int cnt;
+  static netdbEntry *n = NULL;
+#if USE_ICMP
+  struct in_addr addr;
+#endif
+  debug(49,5)("snmp_netdbFn: Processing request with %d.%d!\n",Var->name[10],Var->name[11]);
 
-    switch (vp->magic) {
+  Answer = snmp_var_new(Var->name, Var->name_length);
+  *ErrP = SNMP_ERR_NOERROR;
+
+  cnt=Var->name[11];
+#if USE_ICMP
+  n = (netdbEntry *) hash_first(addr_table);
+  if (n==NULL) debug(49,6)("NO FUCKING ENTRIES HERE :((( - cnt=%d\n",cnt);
+  while (n != NULL)  
+       if (--cnt!=0){ 
+                debug(49,6)("hmmmmm... getting another one while cnt=%d\n",
+                               cnt);
+                n = (netdbEntry *) hash_next(addr_table); 
+       }
+       else break;
+#endif
+  if (n==NULL) {
+       debug(49,6)("snmp_netdbFn: No more entries.\n");
+       *ErrP = SNMP_ERR_NOSUCHNAME;
+        snmp_var_free(Answer);
+        return(NULL);
+  }
+#if USE_ICMP
+  Answer->val.integer = xmalloc(Answer->val_len);
+  Answer->val_len = sizeof(long);
+  switch(Var->name[10]) {
     case NETDB_ID:
-       long_return = (long) cnt - 1;
-       return (u_char *) & long_return;
+       Answer->type = SMI_INTEGER;
+        *(Answer->val.integer)= (long) cnt - 1;
+       break;
     case NETDB_NET:
-       long_return = (long) n->network;
-       return (u_char *) & long_return;
+       Answer->type = SMI_IPADDRESS;
+       safe_inet_addr(n->network, &addr);
+        *(Answer->val.integer)= addr.s_addr;
+       break;
     case NETDB_PING_S:
-       long_return = (long) n->pings_sent;
-       return (u_char *) & long_return;
+       Answer->type = SMI_COUNTER32;
+        *(Answer->val.integer) = (long) n->pings_sent;
+       break;
     case NETDB_PING_R:
-       long_return = (long) n->pings_recv;
-       return (u_char *) & long_return;
+       Answer->type = SMI_COUNTER32;
+        *(Answer->val.integer) = (long) n->pings_recv;
+       break;
     case NETDB_HOPS:
-       long_return = (long) n->hops;
-       return (u_char *) & long_return;
+       Answer->type = SMI_COUNTER32;
+        *(Answer->val.integer) = (long) n->hops;
+       break;
     case NETDB_RTT:
-       long_return = (long) n->rtt;
-       return (u_char *) & long_return;
+       Answer->type = SMI_TIMETICKS;
+        *(Answer->val.integer) = (long) n->rtt;
+       break;
     case NETDB_PINGTIME:
-       long_return = (long) n->next_ping_time;
-       return (u_char *) & long_return;
+       Answer->type = SMI_TIMETICKS;
+        *(Answer->val.integer) = (long) n->next_ping_time;
+       break;
     case NETDB_LASTUSE:
-       long_return = (long) n->last_use_time;
-       return (u_char *) & long_return;
+       Answer->type = SMI_TIMETICKS;
+        *(Answer->val.integer) = (long) n->last_use_time;
+       break;
     default:
-       return NULL;
-    }
+        *ErrP = SNMP_ERR_NOSUCHNAME;
+        snmp_var_free(Answer);
+       xfree(Answer->val.integer);
+        return(NULL);
+  }
+#endif
+  return Answer;
 }
 #endif