summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2008-12-23 08:06:11 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2008-12-23 08:06:11 +0000
commit5231b3e8fcbd6c0cb69706739a553991ba10088c (patch)
treeda50e19cdad23fc1299ad0785bad3ea68a8e9670 /usr.sbin
parentad7486a76727a716358838ef553f134b62775ed5 (diff)
export the livelock counter in a private mib openBSD.5.
discussed with dlg@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/snmpd/mib.c41
-rw-r--r--usr.sbin/snmpd/mib.h17
-rw-r--r--usr.sbin/snmpd/snmpd.h3
3 files changed, 58 insertions, 3 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c
index cc4a3dda78c..0be3f9ce3d0 100644
--- a/usr.sbin/snmpd/mib.c
+++ b/usr.sbin/snmpd/mib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.c,v 1.29 2008/12/19 14:02:20 reyk Exp $ */
+/* $OpenBSD: mib.c,v 1.30 2008/12/23 08:06:10 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@@ -1217,6 +1217,7 @@ int mib_sensornum(struct oid *, struct ber_oid *, struct ber_element **);
int mib_sensors(struct oid *, struct ber_oid *, struct ber_element **);
const char *mib_sensorunit(struct sensor *);
char *mib_sensorvalue(struct sensor *);
+int mib_memiftable(struct oid *, struct ber_oid *, struct ber_element **);
static struct oid openbsd_mib[] = {
{ MIB(sensorMIBObjects), OID_MIB },
@@ -1228,6 +1229,11 @@ static struct oid openbsd_mib[] = {
{ MIB(sensorValue), OID_TRD, mib_sensors },
{ MIB(sensorUnits), OID_TRD, mib_sensors },
{ MIB(sensorStatus), OID_TRD, mib_sensors },
+ { MIB(memMIBObjects), OID_MIB },
+ { MIB(memMIBVersion), OID_RD, mps_getint, NULL, NULL,
+ OIDVER_OPENBSD_MEM },
+ { MIB(memIfName), OID_TRD, mib_memiftable },
+ { MIB(memIfLiveLocks), OID_TRD, mib_memiftable },
{ MIBEND }
};
@@ -1393,6 +1399,39 @@ mib_sensorvalue(struct sensor *s)
return (v);
}
+int
+mib_memiftable(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
+{
+ struct ber_element *ber = *elm;
+ u_int32_t idx = 0;
+ struct kif *kif;
+
+ idx = o->bo_id[OIDIDX_memIfEntry];
+ if ((kif = mib_ifget(idx)) == NULL)
+ return (1);
+
+ o->bo_id[OIDIDX_memIfEntry] = kif->if_index;
+ ber = ber_add_oid(ber, o);
+
+ switch (o->bo_id[OIDIDX_memIf]) {
+ case 1:
+ ber = ber_add_string(ber, kif->if_name);
+ break;
+ case 2:
+ ber = ber_add_integer(ber, kif->if_data.ifi_livelocks);
+ ber_set_header(ber, BER_CLASS_APPLICATION, SNMP_T_COUNTER64);
+ break;
+ default:
+ return (-1);
+ }
+
+ return (0);
+}
+
+/*
+ * Defined in IP-MIB.txt
+ */
+
int mib_getipstat(struct ipstat *);
int mib_ipstat(struct oid *, struct ber_oid *, struct ber_element **);
int mib_ipforwarding(struct oid *, struct ber_oid *, struct ber_element **);
diff --git a/usr.sbin/snmpd/mib.h b/usr.sbin/snmpd/mib.h
index 6f4ff2fc719..c324d632158 100644
--- a/usr.sbin/snmpd/mib.h
+++ b/usr.sbin/snmpd/mib.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.h,v 1.18 2008/12/19 14:02:20 reyk Exp $ */
+/* $OpenBSD: mib.h,v 1.19 2008/12/23 08:06:10 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@@ -389,6 +389,15 @@
#define MIB_sensorStatus MIB_sensorEntry, 7
#define MIB_carpMIBObjects MIB_openBSD, 3
#define MIB_ipsecMIBObjects MIB_openBSD, 4
+#define MIB_memMIBObjects MIB_openBSD, 5
+#define MIB_memMIBVersion MIB_memMIBObjects, 1
+#define OIDVER_OPENBSD_MEM 1
+#define MIB_memIfTable MIB_memMIBObjects, 2
+#define MIB_memIfEntry MIB_memIfTable, 1
+#define OIDIDX_memIf 10
+#define OIDIDX_memIfEntry 11
+#define MIB_memIfName MIB_memIfEntry, 1
+#define MIB_memIfLiveLocks MIB_memIfEntry, 2
#define MIB_localSystem MIB_openBSD, 23
#define MIB_SYSOID_DEFAULT MIB_openBSD, 23, 1
#define MIB_localTest MIB_openBSD, 42
@@ -661,6 +670,12 @@
{ MIBDECL(sensorValue) }, \
{ MIBDECL(sensorUnits) }, \
{ MIBDECL(sensorStatus) }, \
+ { MIBDECL(memMIBObjects) }, \
+ { MIBDECL(memMIBVersion) }, \
+ { MIBDECL(memIfTable) }, \
+ { MIBDECL(memIfEntry) }, \
+ { MIBDECL(memIfName) }, \
+ { MIBDECL(memIfLiveLocks) }, \
{ MIBDECL(localSystem) }, \
{ MIBDECL(localTest) }, \
\
diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h
index 6e2b7a8b4d8..b84d33299ac 100644
--- a/usr.sbin/snmpd/snmpd.h
+++ b/usr.sbin/snmpd/snmpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpd.h,v 1.22 2008/12/08 11:34:55 reyk Exp $ */
+/* $OpenBSD: snmpd.h,v 1.23 2008/12/23 08:06:10 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@@ -430,6 +430,7 @@ int mps_getts(struct oid *, struct ber_oid *,
struct ber_element **);
void mps_encodeinaddr(struct ber_oid *, struct in_addr *, int);
void mps_decodeinaddr(struct ber_oid *, struct in_addr *, int);
+struct ber_oid *mps_table(struct oid *, struct ber_oid *, struct ber_oid *);
/* smi.c */
int smi_init(void);