From 46c28d35e9011a656e7f7fc6bae4d7ebeede5ec4 Mon Sep 17 00:00:00 2001 From: martijn Date: Sun, 12 Nov 2023 20:12:01 +0000 Subject: [PATCH] Remove a bunch of unused smi_ functions and move a couple of definitions out of snmpd.h, which aren't used outside of smi.c OK tb@ --- usr.sbin/snmpd/smi.c | 88 +++--------------------------------------- usr.sbin/snmpd/snmpd.h | 13 +------ 2 files changed, 7 insertions(+), 94 deletions(-) diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c index f895f41e6ee..94f7df9e82b 100644 --- a/usr.sbin/snmpd/smi.c +++ b/usr.sbin/snmpd/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.36 2023/11/12 20:10:13 martijn Exp $ */ +/* $OpenBSD: smi.c,v 1.37 2023/11/12 20:12:01 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -48,6 +48,11 @@ #include "mib.h" #include "application.h" +void smi_mibtree(struct oid *); +struct oid *smi_findkey(char *); +int smi_oid_cmp(struct oid *, struct oid *); +int smi_key_cmp(struct oid *, struct oid *); + RB_HEAD(oidtree, oid); RB_PROTOTYPE(oidtree, oid, o_element, smi_oid_cmp); struct oidtree smi_oidtree; @@ -74,26 +79,6 @@ smi_getticks(void) return (ticks); } -void -smi_oidlen(struct ber_oid *o) -{ - size_t i; - - for (i = 0; i < BER_MAX_OID_LEN && o->bo_id[i] != 0; i++) - ; - o->bo_n = i; -} - -void -smi_scalar_oidlen(struct ber_oid *o) -{ - smi_oidlen(o); - - /* Append .0. */ - if (o->bo_n < BER_MAX_OID_LEN) - o->bo_n++; -} - char * smi_oid2string(struct ber_oid *o, char *buf, size_t len, size_t skip) { @@ -162,24 +147,6 @@ smi_string2oid(const char *oidstr, struct ber_oid *o) return (0); } -void -smi_delete(struct oid *oid) -{ - struct oid key, *value; - - bzero(&key, sizeof(key)); - bcopy(&oid->o_id, &key.o_id, sizeof(struct ber_oid)); - if ((value = RB_FIND(oidtree, &smi_oidtree, &key)) != NULL && - value == oid) - RB_REMOVE(oidtree, &smi_oidtree, value); - - free(oid->o_data); - if (oid->o_flags & OID_DYNAMIC) { - free(oid->o_name); - free(oid); - } -} - const char * smi_insert(struct ber_oid *oid, const char *name) { @@ -238,18 +205,6 @@ smi_init(void) return (0); } -struct oid * -smi_find(struct oid *oid) -{ - return (RB_FIND(oidtree, &smi_oidtree, oid)); -} - -struct oid * -smi_nfind(struct oid *oid) -{ - return (RB_NFIND(oidtree, &smi_oidtree, oid)); -} - struct oid * smi_findkey(char *name) { @@ -260,37 +215,6 @@ smi_findkey(char *name) return (RB_FIND(keytree, &smi_keytree, &oid)); } -struct oid * -smi_next(struct oid *oid) -{ - return (RB_NEXT(oidtree, &smi_oidtree, oid)); -} - -struct oid * -smi_foreach(struct oid *oid, u_int flags) -{ - /* - * Traverse the tree of MIBs with the option to check - * for specific OID flags. - */ - if (oid == NULL) { - oid = RB_MIN(oidtree, &smi_oidtree); - if (oid == NULL) - return (NULL); - if (flags == 0 || (oid->o_flags & flags)) - return (oid); - } - for (;;) { - oid = RB_NEXT(oidtree, &smi_oidtree, oid); - if (oid == NULL) - break; - if (flags == 0 || (oid->o_flags & flags)) - return (oid); - } - - return (oid); -} - #ifdef DEBUG void smi_debug_elements(struct ber_element *root) diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h index 6b03e7c9694..95ed7acef1d 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.111 2023/11/12 20:06:53 martijn Exp $ */ +/* $OpenBSD: snmpd.h,v 1.112 2023/11/12 20:12:01 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -505,19 +505,8 @@ int trap_send(struct ber_oid *, struct ber_element *); /* smi.c */ int smi_init(void); -void smi_mibtree(struct oid *); -struct oid *smi_find(struct oid *); -struct oid *smi_nfind(struct oid *); -struct oid *smi_findkey(char *); -struct oid *smi_next(struct oid *); -struct oid *smi_foreach(struct oid *, u_int); -void smi_oidlen(struct ber_oid *); -void smi_scalar_oidlen(struct ber_oid *); int smi_string2oid(const char *, struct ber_oid *); -void smi_delete(struct oid *); const char *smi_insert(struct ber_oid *, const char *); -int smi_oid_cmp(struct oid *, struct oid *); -int smi_key_cmp(struct oid *, struct oid *); unsigned int smi_application(struct ber_element *); void smi_debug_elements(struct ber_element *); -- 2.20.1