-/* $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 <reyk@openbsd.org>
#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 *);
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;
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;
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;
}
}
-/* $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 <reyk@openbsd.org>
#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__