summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-12-28 16:27:52 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-12-28 16:27:52 +0000
commit1c4205276f2aaa838d09b45bb7b9588157d73e23 (patch)
treeb8e436bd3bfb08e2026f4d864ba7c81a32084559 /usr.sbin
parent1b13a61c1674815943b907f246443a2f77322491 (diff)
split the MIB declarations (names) from the definitions (implementation).
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/snmpd/mib.c119
-rw-r--r--usr.sbin/snmpd/mib.h243
-rw-r--r--usr.sbin/snmpd/mps.c23
-rw-r--r--usr.sbin/snmpd/snmpd.h5
4 files changed, 277 insertions, 113 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c
index f9662e6a6b2..d911268ca3b 100644
--- a/usr.sbin/snmpd/mib.c
+++ b/usr.sbin/snmpd/mib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.c,v 1.13 2007/12/28 15:32:02 reyk Exp $ */
+/* $OpenBSD: mib.c,v 1.14 2007/12/28 16:27:51 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -58,16 +58,11 @@ int mib_getsnmp(struct oid *, struct ber_oid *, struct ber_element **);
int mib_sysor(struct oid *, struct ber_oid *, struct ber_element **);
int mib_setsnmp(struct oid *, struct ber_oid *, struct ber_element **);
+static struct oid mib_tree[] = MIB_TREE;
+
/* base MIB tree */
static struct oid base_mib[] = {
- { MIB(iso) },
- { MIB(org) },
- { MIB(dod) },
- { MIB(internet) },
- { MIB(directory) },
- { MIB(mgmt) },
{ MIB(mib_2), OID_MIB },
- { MIB(system) },
{ MIB(sysDescr), OID_RD, mib_getsys },
{ MIB(sysOID), OID_RD, mib_getsys },
{ MIB(sysUpTime), OID_RD, mib_getsys },
@@ -76,13 +71,10 @@ static struct oid base_mib[] = {
{ MIB(sysLocation), OID_RW, mib_getsys, mps_setstr },
{ MIB(sysServices), OID_RS, mib_getsys },
{ MIB(sysORLastChange), OID_RD, mps_getts },
- { MIB(sysORTable) },
- { MIB(sysOREntry) },
{ MIB(sysORIndex), OID_TRD, mib_sysor },
{ MIB(sysORID), OID_TRD, mib_sysor },
{ MIB(sysORDescr), OID_TRD, mib_sysor },
{ MIB(sysORUpTime), OID_TRD, mib_sysor },
- { MIB(transmission) },
{ MIB(snmp), OID_MIB },
{ MIB(snmpInPkts), OID_RD, mib_getsnmp },
{ MIB(snmpOutPkts), OID_RD, mib_getsnmp },
@@ -114,26 +106,6 @@ static struct oid base_mib[] = {
{ MIB(snmpEnableAuthenTraps), OID_RW, mib_getsnmp, mib_setsnmp },
{ MIB(snmpSilentDrops), OID_RD, mib_getsnmp },
{ MIB(snmpProxyDrops), OID_RD, mib_getsnmp },
- { MIB(experimental) },
- { MIB(private) },
- { MIB(enterprises) },
- { MIB(security) },
- { MIB(snmpV2) },
- { MIB(snmpDomains) },
- { MIB(snmpProxies) },
- { MIB(snmpModules) },
- { MIB(snmpMIB) },
- { MIB(snmpMIBObjects) },
- { MIB(snmpTrap) },
- { MIB(snmpTrapOID) },
- { MIB(snmpTrapEnterprise) },
- { MIB(snmpTraps) },
- { MIB(coldStart) },
- { MIB(warmStart) },
- { MIB(linkDown) },
- { MIB(linkUp) },
- { MIB(authenticationFailure) },
- { MIB(egpNeighborLoss) },
{ MIBEND }
};
@@ -363,9 +335,6 @@ static struct ber_oid zerodotzero = { { 0, 0 }, 2 };
static struct oid if_mib[] = {
{ MIB(ifMIB), OID_MIB },
- { MIB(ifMIBObjects) },
- { MIB(ifXTable) },
- { MIB(ifXEntry) },
{ MIB(ifName), OID_TRD, mib_ifxtable },
{ MIB(ifInMulticastPkts), OID_TRD, mib_ifxtable },
{ MIB(ifInBroadcastPkts), OID_TRD, mib_ifxtable },
@@ -385,17 +354,10 @@ static struct oid if_mib[] = {
{ MIB(ifConnectorPresent), OID_TRD, mib_ifxtable },
{ MIB(ifAlias), OID_TRD, mib_ifxtable },
{ MIB(ifCounterDiscontinuityTime), OID_TRD, mib_ifxtable },
- { MIB(ifStackTable) },
- { MIB(ifStackEntry) },
- { MIB(ifRcvAddressTable) },
- { MIB(ifRcvAddressEntry) },
{ MIB(ifRcvAddressStatus), OID_TRD, mib_ifrcvtable },
{ MIB(ifRcvAddressType), OID_TRD, mib_ifrcvtable },
{ MIB(ifStackLastChange), OID_RD, mib_ifstacklast },
- { MIB(interfaces) },
{ MIB(ifNumber), OID_RD, mib_ifnumber },
- { MIB(ifTable) },
- { MIB(ifEntry) },
{ MIB(ifIndex), OID_TRD, mib_iftable },
{ MIB(ifDescr), OID_TRD, mib_iftable },
{ MIB(ifDescr), OID_TRD, mib_iftable },
@@ -787,55 +749,6 @@ mib_ifrcvtable(struct oid *oid, struct ber_oid *o, struct ber_element **elm)
}
/*
- * PRIVATE ENTERPRISE NUMBERS from
- * http://www.iana.org/assignments/enterprise-numbers
- *
- * This is not the complete list of private enterprise numbers, it only
- * includes some well-known companies and especially network companies
- * that are very common in the datacenters around the world. It would
- * be an overkill to include ~30.000 entries for all the organizations
- * from the official list.
- */
-static struct oid enterprise_mib[] = {
- { MIB(ibm) },
- { MIB(cmu) },
- { MIB(unix) },
- { MIB(ciscoSystems) },
- { MIB(hp) },
- { MIB(mit) },
- { MIB(nortelNetworks) },
- { MIB(sun) },
- { MIB(3com) },
- { MIB(synOptics) },
- { MIB(enterasys) },
- { MIB(sgi) },
- { MIB(apple) },
- { MIB(att) },
- { MIB(nokia) },
- { MIB(cern) },
- { MIB(fsc) },
- { MIB(compaq) },
- { MIB(dell) },
- { MIB(alteon) },
- { MIB(extremeNetworks) },
- { MIB(foundryNetworks) },
- { MIB(huawaiTechnology) },
- { MIB(ucDavis) },
- { MIB(checkPoint) },
- { MIB(juniper) },
- { MIB(force10Networks) },
- { MIB(alcatelLucent) },
- { MIB(snom) },
- { MIB(google) },
- { MIB(f5Networks) },
- { MIB(sFlow) },
- { MIB(microSystems) },
- { MIB(vantronix) },
- { MIB(openBSD) },
- { MIBEND }
-};
-
-/*
* Defined in OPENBSD-SENSORS-MIB.txt
* (http://packetmischief.ca/openbsd/snmp/)
*/
@@ -847,10 +760,7 @@ char *mib_sensorvalue(struct sensor *);
static struct oid openbsd_mib[] = {
{ MIB(sensorMIBObjects), OID_MIB },
- { MIB(sensors) },
{ MIB(sensorNumber), OID_RD, mib_sensornum },
- { MIB(sensorTable) },
- { MIB(sensorEntry) },
{ MIB(sensorIndex), OID_TRD, mib_sensors },
{ MIB(sensorDescr), OID_TRD, mib_sensors },
{ MIB(sensorType), OID_TRD, mib_sensors },
@@ -1056,7 +966,9 @@ static struct oid ip_mib[] = {
{ MIB(ipInAddrErrors), OID_RD, mib_ipinaddrerrs },
{ MIB(ipForwDatagrams), OID_RD, mib_ipforwdgrams },
{ MIB(ipInUnknownProtos), OID_RD, mib_ipstat },
+#ifdef notyet
{ MIB(ipInDiscards) },
+#endif
{ MIB(ipInDelivers), OID_RD, mib_ipstat },
{ MIB(ipOutRequests), OID_RD, mib_ipstat },
{ MIB(ipOutDiscards), OID_RD, mib_ipstat },
@@ -1068,21 +980,18 @@ static struct oid ip_mib[] = {
{ MIB(ipFragOKs), OID_RD, mib_ipstat },
{ MIB(ipFragFails), OID_RD, mib_ipfragfails },
{ MIB(ipFragCreates), OID_RD, mib_ipstat },
- { MIB(ipRoutingDiscards) },
- { MIB(ipAddrTable) },
- { MIB(ipAddrEntry) },
+#ifdef notyet
{ MIB(ipAdEntAddr) },
{ MIB(ipAdEntIfIndex) },
{ MIB(ipAdEntNetMask) },
{ MIB(ipAdEntBcastAddr) },
{ MIB(ipAdEntReasmMaxSize) },
- { MIB(ipNetToMediaTable) },
- { MIB(ipNetToMediaEntry) },
{ MIB(ipNetToMediaIfIndex) },
{ MIB(ipNetToMediaPhysAddress) },
{ MIB(ipNetToMediaNetAddress) },
{ MIB(ipNetToMediaType) },
- { MIB(ipNetToMediaType) },
+ { MIB(ipRoutingDiscards) },
+#endif
{ MIBEND }
};
@@ -1273,6 +1182,15 @@ mib_iproutingdiscards(struct oid *oid, struct ber_oid *o,
void
mib_init(void)
{
+ /*
+ * MIB declarations (to register the OID names)
+ */
+ mps_mibtree(mib_tree);
+
+ /*
+ * MIB definitions (the implementation)
+ */
+
/* SNMPv2-MIB */
mps_mibtree(base_mib);
@@ -1282,9 +1200,6 @@ mib_init(void)
/* IP-MIB */
mps_mibtree(ip_mib);
- /* some http://www.iana.org/assignments/enterprise-numbers */
- mps_mibtree(enterprise_mib);
-
/* OPENBSD-MIB */
mps_mibtree(openbsd_mib);
}
diff --git a/usr.sbin/snmpd/mib.h b/usr.sbin/snmpd/mib.h
index 054d348a3a5..2f32741fdbb 100644
--- a/usr.sbin/snmpd/mib.h
+++ b/usr.sbin/snmpd/mib.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mib.h,v 1.8 2007/12/28 15:32:02 reyk Exp $ */
+/* $OpenBSD: mib.h,v 1.9 2007/12/28 16:27:51 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -19,6 +19,13 @@
#ifndef _SNMPD_MIB_H
#define _SNMPD_MIB_H
+/*
+ * Adding new MIBs:
+ * - add the OID definitions below
+ * - add the OIDs to the MIB_TREE table at the end of this file
+ * - optional: write the implementation in mib.c
+ */
+
/* From the SNMPv2-SMI MIB */
#define MIB_iso 1
#define MIB_org MIB_iso, 3
@@ -203,7 +210,16 @@
#define MIB_ipNetToMediaType MIB_ipNetToMediaEntry, 4
#define MIB_ipRoutingDiscards MIB_ipMIB, 23
-/* Some enterprise-specific OIDs */
+/*
+ * PRIVATE ENTERPRISE NUMBERS from
+ * http://www.iana.org/assignments/enterprise-numbers
+ *
+ * This is not the complete list of private enterprise numbers, it only
+ * includes some well-known companies and especially network companies
+ * that are very common in the datacenters around the world. It would
+ * be an overkill to include ~30.000 entries for all the organizations
+ * from the official list.
+ */
#define MIB_ibm MIB_enterprises, 2
#define MIB_cmu MIB_enterprises, 3
#define MIB_unix MIB_enterprises, 4
@@ -257,6 +273,227 @@
#define MIB_sensorUnits MIB_sensorEntry, 6
#define MIB_sensorStatus MIB_sensorEntry, 7
-void mib_init(void);
+#define MIB_TREE { \
+ { MIBDECL(iso) }, \
+ { MIBDECL(org) }, \
+ { MIBDECL(dod) }, \
+ { MIBDECL(internet) }, \
+ { MIBDECL(directory) }, \
+ { MIBDECL(mgmt) }, \
+ { MIBDECL(mib_2) }, \
+ { MIBDECL(system) }, \
+ { MIBDECL(sysDescr) }, \
+ { MIBDECL(sysOID) }, \
+ { MIBDECL(sysUpTime) }, \
+ { MIBDECL(sysContact) }, \
+ { MIBDECL(sysName) }, \
+ { MIBDECL(sysLocation) }, \
+ { MIBDECL(sysServices) }, \
+ { MIBDECL(sysORLastChange) }, \
+ { MIBDECL(sysORTable) }, \
+ { MIBDECL(sysOREntry) }, \
+ { MIBDECL(sysORIndex) }, \
+ { MIBDECL(sysORID) }, \
+ { MIBDECL(sysORDescr) }, \
+ { MIBDECL(sysORUpTime) }, \
+ { MIBDECL(transmission) }, \
+ { MIBDECL(snmp) }, \
+ { MIBDECL(snmpInPkts) }, \
+ { MIBDECL(snmpOutPkts) }, \
+ { MIBDECL(snmpInBadVersions) }, \
+ { MIBDECL(snmpInBadCommunityNames) }, \
+ { MIBDECL(snmpInBadCommunityUses) }, \
+ { MIBDECL(snmpInASNParseErrs) }, \
+ { MIBDECL(snmpInTooBigs) }, \
+ { MIBDECL(snmpInNoSuchNames) }, \
+ { MIBDECL(snmpInBadValues) }, \
+ { MIBDECL(snmpInReadOnlys) }, \
+ { MIBDECL(snmpInGenErrs) }, \
+ { MIBDECL(snmpInTotalReqVars) }, \
+ { MIBDECL(snmpInTotalSetVars) }, \
+ { MIBDECL(snmpInGetRequests) }, \
+ { MIBDECL(snmpInGetNexts) }, \
+ { MIBDECL(snmpInSetRequests) }, \
+ { MIBDECL(snmpInGetResponses) }, \
+ { MIBDECL(snmpInTraps) }, \
+ { MIBDECL(snmpOutTooBigs) }, \
+ { MIBDECL(snmpOutNoSuchNames) }, \
+ { MIBDECL(snmpOutBadValues) }, \
+ { MIBDECL(snmpOutGenErrs) }, \
+ { MIBDECL(snmpOutGetRequests) }, \
+ { MIBDECL(snmpOutGetNexts) }, \
+ { MIBDECL(snmpOutSetRequests) }, \
+ { MIBDECL(snmpOutGetResponses) }, \
+ { MIBDECL(snmpOutTraps) }, \
+ { MIBDECL(snmpEnableAuthenTraps) }, \
+ { MIBDECL(snmpSilentDrops) }, \
+ { MIBDECL(snmpProxyDrops) }, \
+ { MIBDECL(experimental) }, \
+ { MIBDECL(private) }, \
+ { MIBDECL(enterprises) }, \
+ { MIBDECL(security) }, \
+ { MIBDECL(snmpV2) }, \
+ { MIBDECL(snmpDomains) }, \
+ { MIBDECL(snmpProxies) }, \
+ { MIBDECL(snmpModules) }, \
+ { MIBDECL(snmpMIB) }, \
+ { MIBDECL(snmpMIBObjects) }, \
+ { MIBDECL(snmpTrap) }, \
+ { MIBDECL(snmpTrapOID) }, \
+ { MIBDECL(snmpTrapEnterprise) }, \
+ { MIBDECL(snmpTraps) }, \
+ { MIBDECL(coldStart) }, \
+ { MIBDECL(warmStart) }, \
+ { MIBDECL(linkDown) }, \
+ { MIBDECL(linkUp) }, \
+ { MIBDECL(authenticationFailure) }, \
+ { MIBDECL(egpNeighborLoss) }, \
+ \
+ { MIBDECL(ifMIB) }, \
+ { MIBDECL(ifMIBObjects) }, \
+ { MIBDECL(ifXTable) }, \
+ { MIBDECL(ifXEntry) }, \
+ { MIBDECL(ifName) }, \
+ { MIBDECL(ifInMulticastPkts) }, \
+ { MIBDECL(ifInBroadcastPkts) }, \
+ { MIBDECL(ifOutMulticastPkts) }, \
+ { MIBDECL(ifOutBroadcastPkts) }, \
+ { MIBDECL(ifHCInOctets) }, \
+ { MIBDECL(ifHCInUcastPkts) }, \
+ { MIBDECL(ifHCInMulticastPkts) }, \
+ { MIBDECL(ifHCInBroadcastPkts) }, \
+ { MIBDECL(ifHCOutOctets) }, \
+ { MIBDECL(ifHCOutUcastPkts) }, \
+ { MIBDECL(ifHCOutMulticastPkts) }, \
+ { MIBDECL(ifHCOutBroadcastPkts) }, \
+ { MIBDECL(ifLinkUpDownTrapEnable) }, \
+ { MIBDECL(ifHighSpeed) }, \
+ { MIBDECL(ifPromiscuousMode) }, \
+ { MIBDECL(ifConnectorPresent) }, \
+ { MIBDECL(ifAlias) }, \
+ { MIBDECL(ifCounterDiscontinuityTime) }, \
+ { MIBDECL(ifStackTable) }, \
+ { MIBDECL(ifStackEntry) }, \
+ { MIBDECL(ifRcvAddressTable) }, \
+ { MIBDECL(ifRcvAddressEntry) }, \
+ { MIBDECL(ifRcvAddressStatus) }, \
+ { MIBDECL(ifRcvAddressType) }, \
+ { MIBDECL(ifStackLastChange) }, \
+ { MIBDECL(interfaces) }, \
+ { MIBDECL(ifNumber) }, \
+ { MIBDECL(ifTable) }, \
+ { MIBDECL(ifEntry) }, \
+ { MIBDECL(ifIndex) }, \
+ { MIBDECL(ifDescr) }, \
+ { MIBDECL(ifDescr) }, \
+ { MIBDECL(ifMtu) }, \
+ { MIBDECL(ifSpeed) }, \
+ { MIBDECL(ifPhysAddress) }, \
+ { MIBDECL(ifAdminStatus) }, \
+ { MIBDECL(ifOperStatus) }, \
+ { MIBDECL(ifLastChange) }, \
+ { MIBDECL(ifInOctets) }, \
+ { MIBDECL(ifInUcastPkts) }, \
+ { MIBDECL(ifInNUcastPkts) }, \
+ { MIBDECL(ifInDiscards) }, \
+ { MIBDECL(ifInErrors) }, \
+ { MIBDECL(ifInUnknownErrors) }, \
+ { MIBDECL(ifOutOctets) }, \
+ { MIBDECL(ifOutUcastPkts) }, \
+ { MIBDECL(ifOutNUcastPkts) }, \
+ { MIBDECL(ifOutDiscards) }, \
+ { MIBDECL(ifOutErrors) }, \
+ { MIBDECL(ifOutQLen) }, \
+ { MIBDECL(ifSpecific) }, \
+ \
+ { MIBDECL(ibm) }, \
+ { MIBDECL(cmu) }, \
+ { MIBDECL(unix) }, \
+ { MIBDECL(ciscoSystems) }, \
+ { MIBDECL(hp) }, \
+ { MIBDECL(mit) }, \
+ { MIBDECL(nortelNetworks) }, \
+ { MIBDECL(sun) }, \
+ { MIBDECL(3com) }, \
+ { MIBDECL(synOptics) }, \
+ { MIBDECL(enterasys) }, \
+ { MIBDECL(sgi) }, \
+ { MIBDECL(apple) }, \
+ { MIBDECL(att) }, \
+ { MIBDECL(nokia) }, \
+ { MIBDECL(cern) }, \
+ { MIBDECL(fsc) }, \
+ { MIBDECL(compaq) }, \
+ { MIBDECL(dell) }, \
+ { MIBDECL(alteon) }, \
+ { MIBDECL(extremeNetworks) }, \
+ { MIBDECL(foundryNetworks) }, \
+ { MIBDECL(huawaiTechnology) }, \
+ { MIBDECL(ucDavis) }, \
+ { MIBDECL(checkPoint) }, \
+ { MIBDECL(juniper) }, \
+ { MIBDECL(force10Networks) }, \
+ { MIBDECL(alcatelLucent) }, \
+ { MIBDECL(snom) }, \
+ { MIBDECL(google) }, \
+ { MIBDECL(f5Networks) }, \
+ { MIBDECL(sFlow) }, \
+ { MIBDECL(microSystems) }, \
+ { MIBDECL(vantronix) }, \
+ { MIBDECL(openBSD) }, \
+ \
+ { MIBDECL(sensorMIBObjects) }, \
+ { MIBDECL(sensors) }, \
+ { MIBDECL(sensorNumber) }, \
+ { MIBDECL(sensorTable) }, \
+ { MIBDECL(sensorEntry) }, \
+ { MIBDECL(sensorIndex) }, \
+ { MIBDECL(sensorDescr) }, \
+ { MIBDECL(sensorType) }, \
+ { MIBDECL(sensorDevice) }, \
+ { MIBDECL(sensorValue) }, \
+ { MIBDECL(sensorUnits) }, \
+ { MIBDECL(sensorStatus) }, \
+ \
+ { MIBDECL(ipMIB) }, \
+ { MIBDECL(ipForwarding) }, \
+ { MIBDECL(ipDefaultTTL) }, \
+ { MIBDECL(ipInReceives) }, \
+ { MIBDECL(ipInHdrErrors) }, \
+ { MIBDECL(ipInAddrErrors) }, \
+ { MIBDECL(ipForwDatagrams) }, \
+ { MIBDECL(ipInUnknownProtos) }, \
+ { MIBDECL(ipInDiscards) }, \
+ { MIBDECL(ipInDelivers) }, \
+ { MIBDECL(ipOutRequests) }, \
+ { MIBDECL(ipOutDiscards) }, \
+ { MIBDECL(ipOutNoRoutes) }, \
+ { MIBDECL(ipReasmTimeout) }, \
+ { MIBDECL(ipReasmReqds) }, \
+ { MIBDECL(ipReasmOKs) }, \
+ { MIBDECL(ipReasmFails) }, \
+ { MIBDECL(ipFragOKs) }, \
+ { MIBDECL(ipFragFails) }, \
+ { MIBDECL(ipFragCreates) }, \
+ { MIBDECL(ipRoutingDiscards) }, \
+ { MIBDECL(ipAddrTable) }, \
+ { MIBDECL(ipAddrEntry) }, \
+ { MIBDECL(ipAdEntAddr) }, \
+ { MIBDECL(ipAdEntIfIndex) }, \
+ { MIBDECL(ipAdEntNetMask) }, \
+ { MIBDECL(ipAdEntBcastAddr) }, \
+ { MIBDECL(ipAdEntReasmMaxSize) }, \
+ { MIBDECL(ipNetToMediaTable) }, \
+ { MIBDECL(ipNetToMediaEntry) }, \
+ { MIBDECL(ipNetToMediaIfIndex) }, \
+ { MIBDECL(ipNetToMediaPhysAddress) }, \
+ { MIBDECL(ipNetToMediaNetAddress) }, \
+ { MIBDECL(ipNetToMediaType) }, \
+ { MIBDECL(ipNetToMediaType) }, \
+ \
+ { MIBEND } \
+}
+
+ void mib_init(void);
#endif /* _SNMPD_MIB_H */
diff --git a/usr.sbin/snmpd/mps.c b/usr.sbin/snmpd/mps.c
index 5a02bb7f601..7dcf0f197a2 100644
--- a/usr.sbin/snmpd/mps.c
+++ b/usr.sbin/snmpd/mps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mps.c,v 1.5 2007/12/07 10:14:27 reyk Exp $ */
+/* $OpenBSD: mps.c,v 1.6 2007/12/28 16:27:51 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -378,15 +378,26 @@ mps_insert(struct oid *oid)
void
mps_mibtree(struct oid *oids)
{
- struct oid *oid;
+ struct oid *oid, *decl;
size_t i;
- for (i = 0; oids[i].o_name != NULL; i++) {
+ for (i = 0; oids[i].o_oid[0] != 0; i++) {
oid = &oids[i];
mps_oidlen(&oid->o_id);
- if ((oid->o_flags & OID_TABLE) && oid->o_get == NULL)
- fatalx("mps_mibtree: invalid MIB table");
- RB_INSERT(oidtree, &mps_oidtree, oid);
+ if (oid->o_name != NULL) {
+ if ((oid->o_flags & OID_TABLE) && oid->o_get == NULL)
+ fatalx("mps_mibtree: invalid MIB table");
+ RB_INSERT(oidtree, &mps_oidtree, oid);
+ continue;
+ }
+ decl = RB_FIND(oidtree, &mps_oidtree, oid);
+ if (decl == NULL)
+ fatalx("mps_mibtree: undeclared MIB");
+ decl->o_flags = oid->o_flags;
+ decl->o_get = oid->o_get;
+ decl->o_set = oid->o_set;
+ decl->o_val = oid->o_val;
+ decl->o_data = oid->o_data;
}
}
diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h
index 362887f58f1..fda99a27ef2 100644
--- a/usr.sbin/snmpd/snmpd.h
+++ b/usr.sbin/snmpd/snmpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpd.h,v 1.5 2007/12/28 15:32:02 reyk Exp $ */
+/* $OpenBSD: snmpd.h,v 1.6 2007/12/28 16:27:51 reyk Exp $ */
/*
* Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net>
@@ -235,7 +235,8 @@ struct oid {
((_oid)->o_data == NULL) && ((_oid)->o_val == 0))
#define OID(_mib...) { { _mib } }
-#define MIB(_mib...) { { MIB_##_mib } }, #_mib
+#define MIBDECL(_mib...) { { MIB_##_mib } }, #_mib
+#define MIB(_mib...) { { MIB_##_mib } }, NULL
#define MIBEND { { 0 } }, NULL
/*