#define READ 1
#define WRITE 0
-#define RESERVE1 0
-#define RESERVE2 1
-#define COMMIT 2
-#define ACTION 3
-#define FREE 4
+#define SNM_RESERVE1 0
+#define SNM_RESERVE2 1
+#define SNM_COMMIT 2
+#define SNM_ACTION 3
+#define SNM_FREE 4
#define RONLY 0xAAAA /* read access for everyone */
#define RWRITE 0xAABA /* add write access for community private */
/*
- * $Id: fqdncache.cc,v 1.72 1997/12/02 03:19:28 wessels Exp $
+ * $Id: fqdncache.cc,v 1.73 1997/12/02 17:59:33 kostas Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
fqdncache_low = (long) (((float) MAX_FQDN *
(float) FQDN_LOW_WATER) / (float) 100);
}
+
+#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 = compare(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);
+
+ switch (vp->magic) {
+ case NET_FQDN_ID:
+ long_return = (long) i;
+ return (u_char *) & long_return;
+ case NET_FQDN_NAME:
+ cp = fq->names[0];
+ *var_len = strlen(cp);
+ return (u_char *) cp;
+ case NET_FQDN_IP:
+ safe_inet_addr(fq->name, &fqaddr);
+ long_return = (long) fqaddr.s_addr;
+ return (u_char *) & long_return;
+ case NET_FQDN_LASTREF:
+ long_return = fq->lastref;
+ return (u_char *) & long_return;
+ case NET_FQDN_EXPIRES:
+ long_return = fq->expires;
+ return (u_char *) & long_return;
+ case NET_FQDN_STATE:
+ long_return = fq->status;
+ return (u_char *) & long_return;
+ default:
+ return NULL;
+ }
+}
+#endif
/*
- * $Id: ipcache.cc,v 1.149 1997/12/02 03:32:22 wessels Exp $
+ * $Id: ipcache.cc,v 1.150 1997/12/02 17:59:34 kostas Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
int release_locked;
} IpcacheStats;
-dlink_list lru_list;
+static dlink_list lru_list;
static int ipcache_testname(void);
static PF ipcache_dnsHandleRead;
ipcache_low = (long) (((float) Config.ipcache.size *
(float) Config.ipcache.low) / (float) 100);
}
+
+#ifdef SQUID_SNMP
+
+u_char *
+var_ipcache_entry(struct variable * vp, oid * name, int *length, int exact, int *var_len,
+ SNMPWM ** write_method)
+{
+ 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 = compare(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;
+ }
+ }
+
+ if (m == NULL)
+ return NULL;
+ if ((IPc = m->data) == NULL)
+ return NULL;
+
+ current++;
+ switch (vp->magic) {
+ case NET_IPC_ID:
+ long_return = (int) cnt;
+ return (u_char *) & long_return;
+ case NET_IPC_NAME:
+ cp = IPc->name;
+ *var_len = strlen(cp);
+ return (u_char *) cp;
+ case NET_IPC_IP:
+ long_return = IPc->addrs.in_addrs[0].s_addr; /* first one only */
+ return (u_char *) & long_return;
+ case NET_IPC_STATE:
+ long_return = IPc->status;
+ return (u_char *) & long_return;
+ default:
+ return NULL;
+ }
+}
+#endif
STATUS current
DESCRIPTION
" An entry in the NetDb"
- INDEX { netDbEntryNetwork }
+ INDEX { netDbEntryId }
::= { NetDbTable 1 }
NetDbEntry ::= SEQUENCE {
+ NetDbEntryId Integer,
NetDbEntryNetwork IpAddress,
NetDbEntryPingsSent Counter32,
NetDbEntryPingsRecv Counter32,
NetDbEntryPingTime TimeTicks,
NetDbEntryLastUse TimeTicks,
}
+
+ NetDbEntryId OBJECT-TYPE
+ SYNTAX Integer
+ ACCESS read-only
+ STATUS current
+ ::= { netDbEntry 1 }
NetDbEntryNetwork OBJECT-TYPE
SYNTAX IpAddress
ACCESS read-only
STATUS current
- ::= { netDbEntry 1 }
+ ::= { netDbEntry 2 }
NetDbEntryPingsSent OBJECT-TYPE
SYNTAX Counter32
ACCESS read-only
STATUS current
- ::= { netDbEntry 2 }
+ ::= { netDbEntry 3 }
NetDbEntryPingsRecv OBJECT-TYPE
SYNTAX Counter32
ACCESS read-only
STATUS current
- ::= { netDbEntry 3 }
+ ::= { netDbEntry 4 }
NetDbEntryHops OBJECT-TYPE
SYNTAX Integer
ACCESS read-only
STATUS current
- ::= { netDbEntry 4 }
+ ::= { netDbEntry 5 }
NetDbEntryRtt OBJECT-TYPE
SYNTAX TimeTicks
ACCESS read-only
STATUS current
- ::= { netDbEntry 5 }
+ ::= { netDbEntry 6 }
NetDbEntryPingTime OBJECT-TYPE
SYNTAX TimeTicks
ACCESS read-only
STATUS current
- ::= { netDbEntry 6 }
+ ::= { netDbEntry 7 }
NetDbEntryLastUse OBJECT-TYPE
SYNTAX TimeTicks
ACCESS read-only
STATUS current
- ::= { netDbEntry 7 }
+ ::= { netDbEntry 8 }
-- IP cache info
/*
- * $Id: net_db.cc,v 1.52 1997/12/01 22:45:53 wessels Exp $
+ * $Id: net_db.cc,v 1.53 1997/12/02 17:59:35 kostas Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
#if USE_ICMP
-hash_table *addr_table = NULL;
+static hash_table *addr_table = NULL;
static hash_table *host_table = NULL;
static struct in_addr networkFromInaddr(struct in_addr a);
return hptr ? (netdbEntry *) hptr->item : NULL;
}
-netdbEntry *
+static netdbEntry *
netdbGetFirst(hash_table * table)
{
return (netdbEntry *) hash_first(table);
}
-netdbEntry *
+static netdbEntry *
netdbGetNext(hash_table * table)
{
return (netdbEntry *) hash_next(table);
sortPeerByRtt);
#endif
}
+
+#ifdef SQUID_SNMP
+u_char *
+var_netdb_entry(struct variable * vp, oid * name, int *length, int exact, int *var_len, SNMPWM ** write_method)
+{
+ oid newname[MAX_NAME_LEN];
+ static char snbuf[256];
+ static netdbEntry *n = NULL;
+ static long long_return;
+ int cnt=1;
+
+ 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=netdbGetFirst(addr_table);
+
+ while (n != NULL) {
+ newname[vp->namelen] = cnt++;
+ result = compare(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=netdbGetNext(addr_table);
+ }
+#endif
+ if (n == 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_netdb_entry with peertable request for %s (%d)\n", snbuf, newname[10]);
+
+ switch (vp->magic) {
+ case NETDB_ID:
+ long_return= (long) cnt-1;
+ return (u_char *) & long_return;
+ case NETDB_NET:
+ long_return = (long) n->network;
+ return (u_char *) & long_return;
+ case NETDB_PING_S:
+ long_return = (long) n->pings_sent;
+ return (u_char *) & long_return;
+ case NETDB_PING_R:
+ long_return = (long) n->pings_recv;
+ return (u_char *) & long_return;
+ case NETDB_HOPS:
+ long_return = (long) n->hops;
+ return (u_char *) & long_return;
+ case NETDB_RTT:
+ long_return = (long) n->rtt;
+ return (u_char *) & long_return;
+ case NETDB_PINGTIME:
+ long_return = (long) n->next_ping_time;
+ return (u_char *) & long_return;
+ case NETDB_LASTUSE:
+ long_return = (long) n->last_use_time;
+ return (u_char *) & long_return;
+ default:
+ return NULL;
+ }
+}
+#endif
errstat, errindex, &errindex);
else
errstat = parse_var_op_list(sn_data, length, out_sn_data, *out_length,
- &errindex, msgtype, RESERVE1);
+ &errindex, msgtype, SNM_RESERVE1);
if (errstat == SNMP_ERR_NOSUCHNAME) {
/* see if we have forwarding turned on */
if (msgtype == SET_REQ_MSG) {
if (errstat == SNMP_ERR_NOERROR)
errstat = parse_var_op_list(sn_data, length, out_sn_data, *out_length,
- &errindex, msgtype, RESERVE2);
+ &errindex, msgtype, SNM_RESERVE2);
if (errstat == SNMP_ERR_NOERROR) {
/*
* SETS require 3-4 passes through the var_op_list. The first two
* pass is made so that any reserved resources can be freed.
*/
parse_var_op_list(sn_data, length, out_sn_data, *out_length,
- &dummyindex, msgtype, COMMIT);
+ &dummyindex, msgtype, SNM_COMMIT);
parse_var_op_list(sn_data, length, out_sn_data, *out_length,
- &dummyindex, msgtype, ACTION);
+ &dummyindex, msgtype, SNM_ACTION);
if (create_identical(startData, out_auth, startLength, 0L, 0L)) {
*out_length = packet_end - out_auth;
return 1;
return 0;
} else {
parse_var_op_list(sn_data, length, out_sn_data, *out_length,
- &dummyindex, msgtype, FREE);
+ &dummyindex, msgtype, SNM_FREE);
}
}
switch ((short) errstat) {
}
}
/* actually do the set if necessary */
- if (action == COMMIT)
+ if (action == SNM_COMMIT)
setVariable(var_val, var_val_type, var_val_len,
statP, statLen);
} else {
/*
- * $Id: squid.h,v 1.140 1997/12/02 05:06:43 wessels Exp $
+ * $Id: squid.h,v 1.141 1997/12/02 17:59:37 kostas Exp $
*
* AUTHOR: Duane Wessels
*
#ifdef SQUID_SNMP
#include "snmp.h"
+#include "snmp_impl.h"
+#include "snmp_vars.h"
#include "snmp_config.h"
+#include "cache_snmp.h"
#endif
/* Needed for poll() on Linux at least */