diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/snmpd/mib.c | 76 | ||||
-rw-r--r-- | usr.sbin/snmpd/mib.h | 40 |
2 files changed, 113 insertions, 3 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index 968768f0652..ee185137bed 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.3 2007/12/06 09:08:05 reyk Exp $ */ +/* $OpenBSD: mib.c,v 1.4 2007/12/10 23:23:21 gilles Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -1036,6 +1036,77 @@ mib_sensorvalue(struct sensor *s) return (v); } +int mib_ipforwarding(struct oid *, struct ber_oid *, struct ber_element **); +int mib_ipdefaultttl(struct oid *, struct ber_oid *, struct ber_element **); + +static struct oid ip_mib[] = { + { MIB(IPMIB), "ipMIB", OID_MIB }, + { MIB(IPFORWARDING), "ipForwarding", OID_RD, mib_ipforwarding }, + { MIB(IPDEFAULTTTL), "ipDefaultTTL", OID_RD, mib_ipdefaultttl }, + { MIB(IPINRECEIVES), "ipInReceives" }, + { MIB(IPINHDRERRORS), "ipInHdrErrors" }, + { MIB(IPINADDRERRORS), "ipInAddrErrors" }, + { MIB(IPFORWDATAGRAMS), "ipForwDatagrams" }, + { MIB(IPINUNKNOWNPROTOS), "ipInUnknownProtos" }, + { MIB(IPINDISCARDS), "ipInDiscards" }, + { MIB(IPINDELIVERS), "ipInDelivers" }, + { MIB(IPOUTREQUESTS), "ipOutRequests" }, + { MIB(IPOUTDISCARDS), "ipOutDiscards" }, + { MIB(IPOUTNOROUTES), "ipOutNoRoutes" }, + { MIB(IPREASMTIMEOUT), "ipReasmTimeout" }, + { MIB(IPREASMREQDS), "ipReasmReqds" }, + { MIB(IPREASMOKS), "ipReasmOKs" }, + { MIB(IPREASMFAILS), "ipReasmFails" }, + { MIB(IPFRAGOKS), "ipFragOKs" }, + { MIB(IPFRAGFAILS), "ipFragFails" }, + { MIB(IPFRAGCREATES), "ipFragCreate" }, + { MIBEND } +}; + +int +mib_ipforwarding(struct oid *oid, struct ber_oid *o, struct ber_element **elm) +{ + int mib[4]; + int v; + size_t len; + + mib[0] = CTL_NET; + mib[1] = AF_INET; + mib[2] = IPPROTO_IP; + mib[3] = IPCTL_FORWARDING; + + len = sizeof(v); + + if (sysctl(mib, 4, &v, &len, NULL, 0) == -1) + return(-1); + + *elm = ber_add_integer(*elm, v); + + return (0); +} + +int +mib_ipdefaultttl(struct oid *oid, struct ber_oid *o, struct ber_element **elm) +{ + int mib[4]; + int v; + size_t len; + + mib[0] = CTL_NET; + mib[1] = AF_INET; + mib[2] = IPPROTO_IP; + mib[3] = IPCTL_DEFTTL; + + len = sizeof(v); + + if (sysctl(mib, 4, &v, &len, NULL, 0) == -1) + return(-1); + + *elm = ber_add_integer(*elm, v); + + return (0); +} + /* * Import all MIBs */ @@ -1049,6 +1120,9 @@ mib_init(void) /* IF-MIB */ mps_mibtree(if_mib); + /* IP-MIB */ + mps_mibtree(ip_mib); + /* some http://www.iana.org/assignments/enterprise-numbers */ mps_mibtree(enterprise_mib); diff --git a/usr.sbin/snmpd/mib.h b/usr.sbin/snmpd/mib.h index c5c82388213..5dbefc04bad 100644 --- a/usr.sbin/snmpd/mib.h +++ b/usr.sbin/snmpd/mib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.h,v 1.3 2007/12/05 22:52:50 reyk Exp $ */ +/* $OpenBSD: mib.h,v 1.4 2007/12/10 23:23:21 gilles Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -166,7 +166,43 @@ #define MIB_IFOUTQLEN MIB_IFENTRY, 21 #define MIB_IFSPECIFIC MIB_IFENTRY, 22 -/* Some enterprise-sepcific OIDs */ +/* IP-MIB */ +#define MIB_IPMIB MIB_MIB_2, 4 +#define MIB_IPFORWARDING MIB_IPMIB, 1 +#define MIB_IPDEFAULTTTL MIB_IPMIB, 2 +#define MIB_IPINRECEIVES MIB_IPMIB, 3 +#define MIB_IPINHDRERRORS MIB_IPMIB, 4 +#define MIB_IPINADDRERRORS MIB_IPMIB, 5 +#define MIB_IPFORWDATAGRAMS MIB_IPMIB, 6 +#define MIB_IPINUNKNOWNPROTOS MIB_IPMIB, 7 +#define MIB_IPINDISCARDS MIB_IPMIB, 8 +#define MIB_IPINDELIVERS MIB_IPMIB, 9 +#define MIB_IPOUTREQUESTS MIB_IPMIB, 10 +#define MIB_IPOUTDISCARDS MIB_IPMIB, 11 +#define MIB_IPOUTNOROUTES MIB_IPMIB, 12 +#define MIB_IPREASMTIMEOUT MIB_IPMIB, 13 +#define MIB_IPREASMREQDS MIB_IPMIB, 14 +#define MIB_IPREASMOKS MIB_IPMIB, 15 +#define MIB_IPREASMFAILS MIB_IPMIB, 16 +#define MIB_IPFRAGOKS MIB_IPMIB, 17 +#define MIB_IPFRAGFAILS MIB_IPMIB, 18 +#define MIB_IPFRAGCREATES MIB_IPMIB, 19 +#define MIB_IPADDRTABLE MIB_IPMIB, 20 +#define MIB_IPADDRENTRY MIB_IPADDRTABLE, 1 +#define MIB_IPADENTADDR MIB_IPADDRENTRY, 2 +#define MIB_IPADENTIFINDEX MIB_IPADDRENTRY, 3 +#define MIB_IPADENTNETMASK MIB_IPADDRENTRY, 4 +#define MIB_IPADENTBCASTADDR MIB_IPADDRENTRY, 5 +#define MIB_IPADENTREASMMAXSIZE MIB_IPADDRENTRY, 6 +#define MIB_IPNETTOMEDIATABLE MIB_IPMIB, 22 +#define MIB_IPNETTOMEDIAENTRY MIB_IPNETTOMEDIATABLE, 1 +#define MIB_IPNETTOMEDIAIFINDEX MIB_IPNETTOMEDIAENTRY, 1 +#define MIB_IPNETTOMEDIAPHYSADDRESS MIB_IPNETTOMEDIAENTRY, 2 +#define MIB_IPNETTOMEDIANETADDRESS MIB_IPNETTOMEDIAENTRY, 3 +#define MIB_IPNETTOMEDIATYPE MIB_IPNETTOMEDIAENTRY, 4 +#define MIB_IPROUTINGDISCARDS MIB_IPMIB, 23 + +/* Some enterprise-specific OIDs */ #define MIB_IBM MIB_ENTERPRISES, 2 #define MIB_CMU MIB_ENTERPRISES, 3 #define MIB_UNIX MIB_ENTERPRISES, 4 |