diff --git a/usr.sbin/bsnmpd/Makefile b/usr.sbin/bsnmpd/Makefile new file mode 100644 index 000000000000..4fed3e5d0c97 --- /dev/null +++ b/usr.sbin/bsnmpd/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +SUBDIR= gensnmptree \ + bsnmpd + +.include diff --git a/usr.sbin/bsnmpd/Makefile.inc b/usr.sbin/bsnmpd/Makefile.inc new file mode 100644 index 000000000000..265f86d1ed55 --- /dev/null +++ b/usr.sbin/bsnmpd/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile new file mode 100644 index 000000000000..a1856ebeb795 --- /dev/null +++ b/usr.sbin/bsnmpd/bsnmpd/Makefile @@ -0,0 +1,28 @@ +# $FreeBSD$ +# +# Author: Harti Brandt + +.PATH: ${.CURDIR}/../../../contrib/bsnmp/snmpd + +PROG= bsnmpd +SRCS= oid.h tree.h tree.c main.c action.c config.c export.c trap.c +MAN= bsnmpd.1 snmpmod.3 +WARNS= 6 + +FILESGROUPS += MIBS DEFS + +MIBS= FOKUS-MIB.txt BEGEMOT-MIB.txt BEGEMOT-SNMPD.txt +MIBSDIR= ${SHAREDIR}/bsnmp/mibs +DEFS= tree.def +DEFSDIR= ${SHAREDIR}/bsnmp/defs +INCSDIR= ${INCLUDEDIR}/bsnmp +# snmpdmod is installed in lib/libbsnmp/modules +# INCS= snmpmod.h + +CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/../lib -I${.OBJDIR} -I${INCLUDEDIR}/bsnmp +DPADD+= ${LIBISC} ${LIBBSNMP} +LDADD= -lisc -lbsnmp + +LDFLAGS+= -export-dynamic + +.include diff --git a/usr.sbin/bsnmpd/bsnmpd/genfiles b/usr.sbin/bsnmpd/bsnmpd/genfiles new file mode 100644 index 000000000000..7f09b89755cb --- /dev/null +++ b/usr.sbin/bsnmpd/bsnmpd/genfiles @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD$ + +XSYM="snmpMIB begemotSnmpdModuleTable begemotSnmpd begemotTrapSinkTable \ + sysUpTime snmpTrapOID coldStart authenticationFailure" +SRC=../../../contrib/bsnmp/snmpd + +gensnmptree -l <${SRC}/tree.def +gensnmptree <${SRC}/tree.def -e ${XSYM} >oid.h + +for i in tree.h tree.c oid.h ; do + ex $i <<'EOF' +0a +/* $FreeBSD$ */ +/* generated file, don't edit - use ./genfiles */ +. +wq +EOF +done diff --git a/usr.sbin/bsnmpd/bsnmpd/oid.h b/usr.sbin/bsnmpd/bsnmpd/oid.h new file mode 100644 index 000000000000..f7e86f65dafe --- /dev/null +++ b/usr.sbin/bsnmpd/bsnmpd/oid.h @@ -0,0 +1,26 @@ +/* $FreeBSD$ */ +/* generated file, don't edit - use ./genfiles */ +#define OID_snmpMIB 1 +#define OIDLEN_snmpMIB 7 +#define OIDX_snmpMIB { 7, { 1, 3, 6, 1, 6, 3, 1, } } +#define OID_begemotSnmpdModuleTable 6 +#define OIDLEN_begemotSnmpdModuleTable 11 +#define OIDX_begemotSnmpdModuleTable { 11, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 6, } } +#define OID_begemotSnmpd 1 +#define OIDLEN_begemotSnmpd 9 +#define OIDX_begemotSnmpd { 9, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, } } +#define OID_begemotTrapSinkTable 2 +#define OIDLEN_begemotTrapSinkTable 11 +#define OIDX_begemotTrapSinkTable { 11, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 2, } } +#define OID_sysUpTime 3 +#define OIDLEN_sysUpTime 8 +#define OIDX_sysUpTime { 8, { 1, 3, 6, 1, 2, 1, 1, 3, } } +#define OID_snmpTrapOID 1 +#define OIDLEN_snmpTrapOID 10 +#define OIDX_snmpTrapOID { 10, { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, } } +#define OID_coldStart 1 +#define OIDLEN_coldStart 10 +#define OIDX_coldStart { 10, { 1, 3, 6, 1, 6, 3, 1, 1, 5, 1, } } +#define OID_authenticationFailure 5 +#define OIDLEN_authenticationFailure 10 +#define OIDX_authenticationFailure { 10, { 1, 3, 6, 1, 6, 3, 1, 1, 5, 5, } } diff --git a/usr.sbin/bsnmpd/bsnmpd/tree.c b/usr.sbin/bsnmpd/bsnmpd/tree.c new file mode 100644 index 000000000000..25f5e7421bf2 --- /dev/null +++ b/usr.sbin/bsnmpd/bsnmpd/tree.c @@ -0,0 +1,52 @@ +/* $FreeBSD$ */ +/* generated file, don't edit - use ./genfiles */ +#include +#include +#include "asn1.h" +#include "snmp.h" +#include "snmpagent.h" +#include "tree.h" + +const struct snmp_node ctree[] = { + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 1, }}, "sysDescr", SNMP_NODE_LEAF, SNMP_SYNTAX_OCTETSTRING, op_system_group, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 2, }}, "sysObjectId", SNMP_NODE_LEAF, SNMP_SYNTAX_OID, op_system_group, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 3, }}, "sysUpTime", SNMP_NODE_LEAF, SNMP_SYNTAX_TIMETICKS, op_system_group, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 4, }}, "sysContact", SNMP_NODE_LEAF, SNMP_SYNTAX_OCTETSTRING, op_system_group, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 5, }}, "sysName", SNMP_NODE_LEAF, SNMP_SYNTAX_OCTETSTRING, op_system_group, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 6, }}, "sysLocation", SNMP_NODE_LEAF, SNMP_SYNTAX_OCTETSTRING, op_system_group, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 7, }}, "sysServices", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_system_group, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 1, 8, }}, "sysORLastChange", SNMP_NODE_LEAF, SNMP_SYNTAX_TIMETICKS, op_system_group, 0, 0, NULL }, + {{ 10, { 1, 3, 6, 1, 2, 1, 1, 9, 1, 2, }}, "sysORID", SNMP_NODE_COLUMN, SNMP_SYNTAX_OID, op_or_table, 0, 0x11, NULL }, + {{ 10, { 1, 3, 6, 1, 2, 1, 1, 9, 1, 3, }}, "sysORDescr", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_or_table, 0, 0x11, NULL }, + {{ 10, { 1, 3, 6, 1, 2, 1, 1, 9, 1, 4, }}, "sysORUpTime", SNMP_NODE_COLUMN, SNMP_SYNTAX_TIMETICKS, op_or_table, 0, 0x11, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 1, }}, "snmpInPkts", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 3, }}, "snmpInBadVersions", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 4, }}, "snmpInBadCommunityNames", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 5, }}, "snmpInBadCommunityUses", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 6, }}, "snmpInASNParseErrs", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 30, }}, "snmpEnableAuthenTraps", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_snmp, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 31, }}, "snmpSilentDrops", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 8, { 1, 3, 6, 1, 2, 1, 11, 32, }}, "snmpProxyDrops", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmp, 0, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 1, 1, }}, "begemotSnmpdTransmitBuffer", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_snmpd_config, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 1, 2, }}, "begemotSnmpdReceiveBuffer", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_snmpd_config, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 1, 3, }}, "begemotSnmpdCommunityDisable", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_snmpd_config, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 1, 4, }}, "begemotSnmpdTrap1Addr", SNMP_NODE_LEAF, SNMP_SYNTAX_IPADDRESS, op_snmpd_config, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 2, 1, 3, }}, "begemotTrapSinkStatus", SNMP_NODE_COLUMN, SNMP_SYNTAX_INTEGER, op_trapsink, 0|SNMP_NODE_CANSET, 0x142, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 2, 1, 4, }}, "begemotTrapSinkComm", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_trapsink, 0|SNMP_NODE_CANSET, 0x142, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 2, 1, 5, }}, "begemotTrapSinkVersion", SNMP_NODE_COLUMN, SNMP_SYNTAX_INTEGER, op_trapsink, 0|SNMP_NODE_CANSET, 0x142, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 4, 1, 3, }}, "begemotSnmpdPortStatus", SNMP_NODE_COLUMN, SNMP_SYNTAX_INTEGER, op_snmp_port, 0|SNMP_NODE_CANSET, 0x142, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 5, 1, 3, }}, "begemotSnmpdCommunityString", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_community, 0|SNMP_NODE_CANSET, 0x622, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 5, 1, 4, }}, "begemotSnmpdCommunityDescr", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_community, 0, 0x622, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 6, 1, 2, }}, "begemotSnmpdModulePath", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_modules, 0|SNMP_NODE_CANSET, 0x21, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 6, 1, 3, }}, "begemotSnmpdModuleComment", SNMP_NODE_COLUMN, SNMP_SYNTAX_OCTETSTRING, op_modules, 0, 0x21, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 7, 1, }}, "begemotSnmpdStatsNoRxBufs", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmpd_stats, 0, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 7, 2, }}, "begemotSnmpdStatsNoTxBufs", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmpd_stats, 0, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 7, 3, }}, "begemotSnmpdStatsInTooLongPkts", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmpd_stats, 0, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 7, 4, }}, "begemotSnmpdStatsInBadPduTypes", SNMP_NODE_LEAF, SNMP_SYNTAX_COUNTER, op_snmpd_stats, 0, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 8, 1, }}, "begemotSnmpdDebugDumpPdus", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_debug, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 8, 2, }}, "begemotSnmpdDebugSnmpTrace", SNMP_NODE_LEAF, SNMP_SYNTAX_GAUGE, op_debug, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 12, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 8, 3, }}, "begemotSnmpdDebugSyslogPri", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_debug, 0|SNMP_NODE_CANSET, 0, NULL }, + {{ 13, { 1, 3, 6, 1, 4, 1, 12325, 1, 1, 1, 9, 1, 2, }}, "begemotSnmpdLocalPortStatus", SNMP_NODE_COLUMN, SNMP_SYNTAX_INTEGER, op_local_port, 0|SNMP_NODE_CANSET, 0x21, NULL }, + {{ 10, { 1, 3, 6, 1, 6, 3, 1, 1, 6, 1, }}, "snmpSetSerialNo", SNMP_NODE_LEAF, SNMP_SYNTAX_INTEGER, op_snmp_set, 0|SNMP_NODE_CANSET, 0, NULL }, +}; + diff --git a/usr.sbin/bsnmpd/bsnmpd/tree.h b/usr.sbin/bsnmpd/bsnmpd/tree.h new file mode 100644 index 000000000000..95cf26cf47b8 --- /dev/null +++ b/usr.sbin/bsnmpd/bsnmpd/tree.h @@ -0,0 +1,56 @@ +/* $FreeBSD$ */ +/* generated file, don't edit - use ./genfiles */ +int op_system_group(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_sysDescr 1 +# define LEAF_sysObjectId 2 +# define LEAF_sysUpTime 3 +# define LEAF_sysContact 4 +# define LEAF_sysName 5 +# define LEAF_sysLocation 6 +# define LEAF_sysServices 7 +# define LEAF_sysORLastChange 8 +int op_or_table(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_sysORID 2 +# define LEAF_sysORDescr 3 +# define LEAF_sysORUpTime 4 +int op_snmp(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_snmpInPkts 1 +# define LEAF_snmpInBadVersions 3 +# define LEAF_snmpInBadCommunityNames 4 +# define LEAF_snmpInBadCommunityUses 5 +# define LEAF_snmpInASNParseErrs 6 +# define LEAF_snmpEnableAuthenTraps 30 +# define LEAF_snmpSilentDrops 31 +# define LEAF_snmpProxyDrops 32 +int op_snmpd_config(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdTransmitBuffer 1 +# define LEAF_begemotSnmpdReceiveBuffer 2 +# define LEAF_begemotSnmpdCommunityDisable 3 +# define LEAF_begemotSnmpdTrap1Addr 4 +int op_trapsink(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotTrapSinkStatus 3 +# define LEAF_begemotTrapSinkComm 4 +# define LEAF_begemotTrapSinkVersion 5 +int op_snmp_port(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdPortStatus 3 +int op_community(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdCommunityString 3 +# define LEAF_begemotSnmpdCommunityDescr 4 +int op_modules(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdModulePath 2 +# define LEAF_begemotSnmpdModuleComment 3 +int op_snmpd_stats(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdStatsNoRxBufs 1 +# define LEAF_begemotSnmpdStatsNoTxBufs 2 +# define LEAF_begemotSnmpdStatsInTooLongPkts 3 +# define LEAF_begemotSnmpdStatsInBadPduTypes 4 +int op_debug(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdDebugDumpPdus 1 +# define LEAF_begemotSnmpdDebugSnmpTrace 2 +# define LEAF_begemotSnmpdDebugSyslogPri 3 +int op_local_port(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_begemotSnmpdLocalPortStatus 2 +int op_snmp_set(struct snmp_context *, struct snmp_value *, u_int, u_int, enum snmp_op); +# define LEAF_snmpSetSerialNo 1 +#define CTREE_SIZE 40 +extern const struct snmp_node ctree[]; diff --git a/usr.sbin/bsnmpd/gensnmptree/Makefile b/usr.sbin/bsnmpd/gensnmptree/Makefile new file mode 100644 index 000000000000..5efa31aa377d --- /dev/null +++ b/usr.sbin/bsnmpd/gensnmptree/Makefile @@ -0,0 +1,12 @@ +# $FreeBSD$ +# +# Author: Harti Brandt + +CONTRIB=${.CURDIR}/../../../contrib/bsnmp/gensnmptree +.PATH: ${CONTRIB} + +PROG= gensnmptree +MAN= gensnmptree.1 +CFLAGS+= -I${INCLUDEDIR}/bsnmp + +.include