From: martijn Date: Wed, 8 Nov 2023 19:46:28 +0000 (+0000) Subject: export SNMP-TARGET-MIB::{snmpUnavailableContexts,snmpUnknownContexts} X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=92d4cb1db4d8ccf1997ea3b60530b782126e3c6c;p=openbsd export SNMP-TARGET-MIB::{snmpUnavailableContexts,snmpUnknownContexts} via application_internal. OK tb@ --- diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c index 1f96e9f678f..1c5b9b7dc50 100644 --- a/usr.sbin/snmpd/application.c +++ b/usr.sbin/snmpd/application.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application.c,v 1.30 2023/11/06 11:02:57 martijn Exp $ */ +/* $OpenBSD: application.c,v 1.31 2023/11/08 19:46:28 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -431,6 +431,23 @@ appl_sysortable_getnext(int8_t include, struct ber_oid *oid) return value; } +struct ber_element * +appl_targetmib(struct ber_oid *oid) +{ + struct ber_element *value = NULL; + + if (ober_oid_cmp(oid, &OID(MIB_snmpUnavailableContexts, 0)) == 0) + value = ober_add_integer(NULL, + snmp_target_mib.snmp_unavailablecontexts); + else if (ober_oid_cmp(oid, &OID(MIB_snmpUnknownContexts, 0)) == 0) + value = ober_add_integer(NULL, + snmp_target_mib.snmp_unknowncontexts); + + if (value != NULL) + ober_set_header(value, BER_CLASS_APPLICATION, SNMP_T_COUNTER32); + return value; +} + enum appl_error appl_region(struct appl_context *ctx, uint32_t timeout, uint8_t priority, struct ber_oid *oid, int instance, int subtree, diff --git a/usr.sbin/snmpd/application.h b/usr.sbin/snmpd/application.h index ecbc7dac1e0..30657c5b295 100644 --- a/usr.sbin/snmpd/application.h +++ b/usr.sbin/snmpd/application.h @@ -1,4 +1,4 @@ -/* $OpenBSD: application.h,v 1.9 2023/11/06 11:02:57 martijn Exp $ */ +/* $OpenBSD: application.h,v 1.10 2023/11/08 19:46:28 martijn Exp $ */ /* * Copyright (c) 2021 Martijn van Duren @@ -130,6 +130,7 @@ enum appl_error appl_removeagentcaps(const char *, struct ber_oid *, struct ber_element *appl_sysorlastchange(struct ber_oid *); struct ber_element *appl_sysortable(struct ber_oid *); struct ber_element *appl_sysortable_getnext(int8_t, struct ber_oid *); +struct ber_element *appl_targetmib(struct ber_oid *); enum appl_error appl_register(const char *, uint32_t, uint8_t, struct ber_oid *, int, int, uint8_t, uint32_t, struct appl_backend *); enum appl_error appl_unregister(const char *, uint8_t, struct ber_oid *, diff --git a/usr.sbin/snmpd/application_internal.c b/usr.sbin/snmpd/application_internal.c index 4221dcaabde..a59fe5a291b 100644 --- a/usr.sbin/snmpd/application_internal.c +++ b/usr.sbin/snmpd/application_internal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: application_internal.c,v 1.6 2023/11/06 11:02:57 martijn Exp $ */ +/* $OpenBSD: application_internal.c,v 1.7 2023/11/08 19:46:28 martijn Exp $ */ /* * Copyright (c) 2023 Martijn van Duren @@ -161,6 +161,11 @@ appl_internal_init(void) appl_internal_object(&OID(MIB_snmpEngineMaxMsgSize), appl_internal_engine, NULL); + appl_internal_object(&OID(MIB_snmpUnavailableContexts), + appl_targetmib, NULL); + appl_internal_object(&OID(MIB_snmpUnknownContexts), + appl_targetmib, NULL); + appl_internal_object(&OID(MIB_usmStatsUnsupportedSecLevels), appl_internal_usmstats, NULL); appl_internal_object(&OID(MIB_usmStatsNotInTimeWindow),