From: martijn Date: Sun, 12 Nov 2023 20:14:39 +0000 (+0000) Subject: Move struct oid from snmpd.h into smi.c and trim a lot of the now unused X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9dc90119e20ee4fcccf3484b9b7a230388ce25d1;p=openbsd Move struct oid from snmpd.h into smi.c and trim a lot of the now unused fat. This includes all the o_flags member related defines. if it compiles ship it/OK tb@ --- diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c index 94f7df9e82b..ceeb8db6b6f 100644 --- a/usr.sbin/snmpd/smi.c +++ b/usr.sbin/snmpd/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.37 2023/11/12 20:12:01 martijn Exp $ */ +/* $OpenBSD: smi.c,v 1.38 2023/11/12 20:14:39 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter @@ -48,6 +48,17 @@ #include "mib.h" #include "application.h" +struct oid { + struct ber_oid o_id; +#define o_oid o_id.bo_id +#define o_oidlen o_id.bo_n + + char *o_name; + + RB_ENTRY(oid) o_element; + RB_ENTRY(oid) o_keyword; +}; + void smi_mibtree(struct oid *); struct oid *smi_findkey(char *); int smi_oid_cmp(struct oid *, struct oid *); @@ -89,7 +100,6 @@ smi_oid2string(struct ber_oid *o, char *buf, size_t len, size_t skip) bzero(buf, len); bzero(&key, sizeof(key)); bcopy(o, &key.o_id, sizeof(struct ber_oid)); - key.o_flags |= OID_KEY; /* do not match wildcards */ if (snmpd_env->sc_flags & SNMPD_F_NONAMES) lookup = 0; @@ -179,8 +189,6 @@ smi_mibtree(struct oid *oids) for (i = 0; oids[i].o_oid[0] != 0; i++) { oid = &oids[i]; if (oid->o_name != NULL) { - if ((oid->o_flags & OID_TABLE) && oid->o_get == NULL) - fatalx("smi_mibtree: invalid MIB table"); RB_INSERT(oidtree, &smi_oidtree, oid); RB_INSERT(keytree, &smi_keytree, oid); continue; @@ -188,11 +196,6 @@ smi_mibtree(struct oid *oids) decl = RB_FIND(oidtree, &smi_oidtree, oid); if (decl == NULL) fatalx("smi_mibtree: undeclared MIB"); - decl->o_flags = oid->o_flags; - decl->o_get = oid->o_get; - decl->o_table = oid->o_table; - 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 95ed7acef1d..b1ecd5cce0a 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.112 2023/11/12 20:12:01 martijn Exp $ */ +/* $OpenBSD: snmpd.h,v 1.113 2023/11/12 20:14:39 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter @@ -174,47 +174,6 @@ struct privsep_fd { #define DPRINTF(x...) do {} while(0) #endif -/* - * Message Processing Subsystem (mps) - */ - -struct oid { - struct ber_oid o_id; -#define o_oid o_id.bo_id -#define o_oidlen o_id.bo_n - - char *o_name; - - u_int o_flags; - - int (*o_get)(struct oid *, struct ber_oid *, - struct ber_element **); - struct ber_oid *(*o_table)(struct oid *, struct ber_oid *, - struct ber_oid *); - - long long o_val; - void *o_data; - - RB_ENTRY(oid) o_element; - RB_ENTRY(oid) o_keyword; -}; - -#define OID_RD 0x01 -#define OID_WR 0x02 -#define OID_IFSET 0x04 /* only if user-specified value */ -#define OID_DYNAMIC 0x08 /* free allocated data */ -#define OID_TABLE 0x10 /* dynamic sub-elements */ -#define OID_MIB 0x20 /* root-OID of a supported MIB */ -#define OID_KEY 0x40 /* lookup tables */ - -#define OID_RS (OID_RD|OID_IFSET) - -#define OID_TRD (OID_RD|OID_TABLE) - -#define OID_NOTSET(_oid) \ - (((_oid)->o_flags & OID_IFSET) && \ - ((_oid)->o_data == NULL) && ((_oid)->o_val == 0)) - #define OID(...) (struct ber_oid){ { __VA_ARGS__ }, \ (sizeof((uint32_t []) { __VA_ARGS__ }) / sizeof(uint32_t)) } #define MIBDECL(...) OID(MIB_##__VA_ARGS__), #__VA_ARGS__