diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-01-18 18:38:36 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-01-18 18:38:36 +0000 |
commit | cfa9370f05bc318e69be746fd192260e3e08b36a (patch) | |
tree | 48fb03322abf0ad711499085c77ff20ad6907bf7 /usr.sbin/snmpd | |
parent | cb7708a4bab74e179e651c7968e54d0e1d8391f2 (diff) |
implement very basic support of the BRIDGE-MIB which is enough to get
recognized as a network device by some NMS.
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/mib.c | 63 | ||||
-rw-r--r-- | usr.sbin/snmpd/mib.h | 41 |
2 files changed, 100 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index 7c1efe3b533..6687184d06a 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.17 2008/01/16 09:51:15 reyk Exp $ */ +/* $OpenBSD: mib.c,v 1.18 2008/01/18 18:38:35 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -360,7 +360,7 @@ static struct oid if_mib[] = { { MIB(ifNumber), OID_RD, mib_ifnumber }, { MIB(ifIndex), OID_TRD, mib_iftable }, { MIB(ifDescr), OID_TRD, mib_iftable }, - { MIB(ifDescr), OID_TRD, mib_iftable }, + { MIB(ifType), OID_TRD, mib_iftable }, { MIB(ifMtu), OID_TRD, mib_iftable }, { MIB(ifSpeed), OID_TRD, mib_iftable }, { MIB(ifPhysAddress), OID_TRD, mib_iftable }, @@ -1269,6 +1269,62 @@ mib_ipaddr(struct oid *oid, struct ber_oid *o, struct ber_element **elm) } /* + * Defined in BRIDGE-MIB.txt (rfc1493) + * + * This MIB is required by some NMS to accept the device because + * the RFC says that mostly any network device has to provide this MIB... :( + */ + +int mib_dot1dtable(struct oid *, struct ber_oid *, struct ber_element **); + +static struct oid bridge_mib[] = { + { MIB(dot1dBridge), OID_MIB }, + { MIB(dot1dBaseBridgeAddress) }, + { MIB(dot1dBaseNumPorts), OID_RD, mib_ifnumber }, + { MIB(dot1dBaseType), OID_RD, mps_getint, NULL, + NULL, 4 /* srt (sourceroute + transparent) */ }, + { MIB(dot1dBasePort), OID_TRD, mib_dot1dtable }, + { MIB(dot1dBasePortIfIndex), OID_TRD, mib_dot1dtable }, + { MIB(dot1dBasePortCircuit), OID_TRD, mib_dot1dtable}, + { MIB(dot1dBasePortDelayExceededDiscards), OID_TRD, mib_dot1dtable }, + { MIB(dot1dBasePortMtuExceededDiscards), OID_TRD, mib_dot1dtable }, + { MIBEND } +}; + +int +mib_dot1dtable(struct oid *oid, struct ber_oid *o, struct ber_element **elm) +{ + struct ber_element *ber = *elm; + u_int32_t idx = 0; + struct kif *kif; + + /* Get and verify the current row index */ + idx = o->bo_id[OIDIDX_dot1dEntry]; + if ((kif = mib_ifget(idx)) == NULL) + return (1); + + /* Tables need to prepend the OID on their own */ + o->bo_id[OIDIDX_dot1dEntry] = kif->if_index; + ber = ber_add_oid(ber, o); + + switch (o->bo_id[OIDIDX_dot1d]) { + case 1: + case 2: + ber = ber_add_integer(ber, kif->if_index); + break; + case 3: + ber = ber_add_oid(ber, &zerodotzero); + break; + case 4: + case 5: + ber = ber_add_integer(ber, 0); + break; + } + + return (0); +} + +/* * Import all MIBs */ @@ -1293,6 +1349,9 @@ mib_init(void) /* IP-MIB */ smi_mibtree(ip_mib); + /* BRIDGE-MIB */ + smi_mibtree(bridge_mib); + /* OPENBSD-MIB */ smi_mibtree(openbsd_mib); } diff --git a/usr.sbin/snmpd/mib.h b/usr.sbin/snmpd/mib.h index 32e7143b2ed..9c1447a8a38 100644 --- a/usr.sbin/snmpd/mib.h +++ b/usr.sbin/snmpd/mib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.h,v 1.11 2008/01/16 09:51:15 reyk Exp $ */ +/* $OpenBSD: mib.h,v 1.12 2008/01/18 18:38:35 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -212,6 +212,26 @@ #define MIB_ipNetToMediaType MIB_ipNetToMediaEntry, 4 #define MIB_ipRoutingDiscards MIB_ipMIB, 23 +/* BRIDGE-MIB */ +#define MIB_dot1dBridge MIB_mib_2, 17 +#define MIB_dot1dBase MIB_dot1dBridge, 1 +#define MIB_dot1dBaseBridgeAddress MIB_dot1dBase, 1 +#define MIB_dot1dBaseNumPorts MIB_dot1dBase, 2 +#define MIB_dot1dBaseType MIB_dot1dBase, 3 +#define MIB_dot1dBasePortTable MIB_dot1dBase, 4 +#define OIDIDX_dot1d 10 +#define OIDIDX_dot1dEntry 11 +#define MIB_dot1dBasePortEntry MIB_dot1dBasePortTable, 1 +#define MIB_dot1dBasePort MIB_dot1dBasePortEntry, 1 +#define MIB_dot1dBasePortIfIndex MIB_dot1dBasePortEntry, 2 +#define MIB_dot1dBasePortCircuit MIB_dot1dBasePortEntry, 3 +#define MIB_dot1dBasePortDelayExceededDiscards MIB_dot1dBasePortEntry, 4 +#define MIB_dot1dBasePortMtuExceededDiscards MIB_dot1dBasePortEntry, 5 +#define MIB_dot1dStp MIB_dot1dBridge, 2 +#define MIB_dot1dSr MIB_dot1dBridge, 3 +#define MIB_dot1dTp MIB_dot1dBridge, 4 +#define MIB_dot1dStatic MIB_dot1dBridge, 5 + /* * PRIVATE ENTERPRISE NUMBERS from * http://www.iana.org/assignments/enterprise-numbers @@ -387,7 +407,7 @@ { MIBDECL(ifEntry) }, \ { MIBDECL(ifIndex) }, \ { MIBDECL(ifDescr) }, \ - { MIBDECL(ifDescr) }, \ + { MIBDECL(ifType) }, \ { MIBDECL(ifMtu) }, \ { MIBDECL(ifSpeed) }, \ { MIBDECL(ifPhysAddress) }, \ @@ -408,6 +428,23 @@ { MIBDECL(ifOutQLen) }, \ { MIBDECL(ifSpecific) }, \ \ + { MIBDECL(dot1dBridge) }, \ + { MIBDECL(dot1dBase) }, \ + { MIBDECL(dot1dBaseBridgeAddress) }, \ + { MIBDECL(dot1dBaseNumPorts) }, \ + { MIBDECL(dot1dBaseType) }, \ + { MIBDECL(dot1dBasePortTable) }, \ + { MIBDECL(dot1dBasePortEntry) }, \ + { MIBDECL(dot1dBasePort) }, \ + { MIBDECL(dot1dBasePortIfIndex) }, \ + { MIBDECL(dot1dBasePortCircuit) }, \ + { MIBDECL(dot1dBasePortDelayExceededDiscards) },\ + { MIBDECL(dot1dBasePortMtuExceededDiscards) }, \ + { MIBDECL(dot1dStp) }, \ + { MIBDECL(dot1dSr) }, \ + { MIBDECL(dot1dTp) }, \ + { MIBDECL(dot1dStatic) }, \ + \ { MIBDECL(ibm) }, \ { MIBDECL(cmu) }, \ { MIBDECL(unix) }, \ |