drop more dead code

This commit is contained in:
Wolfgang Hottgenroth 2025-02-14 18:27:54 +01:00
parent dc21a0d16b
commit 565ea0992d
4 changed files with 46 additions and 112 deletions

View File

@ -1,5 +1,5 @@
PROG= snmpd_ntpd PROG= snmpd_ntpd
SRCS= mib.c log.c timer.c util.c SRCS= mib.c log.c util.c
MAN= MAN=
CFLAGS+= -Wall -I${.CURDIR} CFLAGS+= -Wall -I${.CURDIR}

52
mib.c
View File

@ -19,50 +19,22 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
//#include <sys/types.h>
#include <sys/signal.h> #include <sys/signal.h>
//#include <sys/queue.h>
#include <sys/proc.h> #include <sys/proc.h>
//#include <sys/stat.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
//#include <sys/time.h>
//#include <sys/tree.h>
//#include <sys/utsname.h>
//#include <sys/sysctl.h>
//#include <sys/sensors.h>
//#include <sys/sched.h>
//#include <sys/mount.h>
//#include <sys/ioctl.h>
//#include <sys/disk.h>
//#include <netinet/in.h>
//#include <netinet/ip.h>
//#include <netinet/ip_carp.h>
//#include <netinet/ip_var.h>
//#include <arpa/inet.h>
//#include <net/if.h>
//#include <net/if_types.h>
//#include <net/pfvar.h>
//#include <netinet/ip_ipsp.h>
//#include <net/if_pfsync.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <event.h> #include <event.h>
//#include <fcntl.h>
#include <grp.h> #include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <syslog.h> #include <syslog.h>
//#include <time.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include <limits.h> #include <limits.h>
//#include <kvm.h>
//
//#include "log.h"
#include "snmpd.h" #include "snmpd.h"
#include "mib.h" #include "mib.h"
@ -70,10 +42,6 @@ struct event connev;
const char *agentxsocket = NULL; const char *agentxsocket = NULL;
int agentxfd = -1; int agentxfd = -1;
//int pageshift;
//#define pagetok(size) ((size) << pageshift)
//void pageshift_init(void);
void snmp_connect(struct agentx *, void *, int); void snmp_connect(struct agentx *, void *, int);
void snmp_tryconnect(int, short, void *); void snmp_tryconnect(int, short, void *);
void snmp_read(int, short, void *); void snmp_read(int, short, void *);
@ -172,8 +140,6 @@ main(int argc, char *argv[])
if ((sac = agentx_context(sas, context)) == NULL) if ((sac = agentx_context(sas, context)) == NULL)
fatal("agentx_context"); fatal("agentx_context");
/* kr_init requires sac */
//pageshift_init();
if (agentxsocket != NULL) { if (agentxsocket != NULL) {
if (strlcpy(agentxsocketdir, agentxsocket, if (strlcpy(agentxsocketdir, agentxsocket,
@ -211,24 +177,6 @@ main(int argc, char *argv[])
event_dispatch(); event_dispatch();
} }
#if 0
#define LOG1024 10
void
pageshift_init(void)
{
long pagesize;
if ((pagesize = sysconf(_SC_PAGESIZE)) == -1)
fatal("sysconf(_SC_PAGESIZE)");
while (pagesize > 1) {
pageshift++;
pagesize >>= 1;
}
/* we only need the amount of log(2)1024 for our conversion */
pageshift -= LOG1024;
}
#endif
void void
snmp_connect(struct agentx *sa, void *cookie, int close) snmp_connect(struct agentx *sa, void *cookie, int close)
{ {

98
snmpd.h
View File

@ -1,6 +1,6 @@
/* $OpenBSD: snmpd.h,v 1.1.1.1 2022/09/01 14:20:33 martijn Exp $ */
/* /*
* Copyright (c) 2025 Wolfgang Hottgenroth <woho@hottis.de>
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org> * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
* *
@ -20,80 +20,66 @@
#ifndef SNMPD_H #ifndef SNMPD_H
#define SNMPD_H #define SNMPD_H
#include <sys/tree.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <net/pfvar.h>
#include <net/route.h>
#include <ber.h>
#include <stdio.h>
#include <imsg.h>
#include "log.h" #include "log.h"
#ifndef nitems //#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) //#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif //#endif
/* /*
* common definitions for snmpd * common definitions for snmpd
*/ */
#define CONF_FILE "/etc/snmpd.conf" //#define CONF_FILE "/etc/snmpd.conf"
#define SNMPD_SOCKET "/var/run/snmpd.sock" //#define SNMPD_SOCKET "/var/run/snmpd.sock"
#define SNMPD_USER "_snmpd" //#define SNMPD_USER "_snmpd"
#define SNMP_PORT "161" //#define SNMP_PORT "161"
#define SNMPTRAP_PORT "162" //#define SNMPTRAP_PORT "162"
#define SNMPD_MAXSTRLEN 484 //#define SNMPD_MAXSTRLEN 484
#define SNMPD_MAXCOMMUNITYLEN SNMPD_MAXSTRLEN //#define SNMPD_MAXCOMMUNITYLEN SNMPD_MAXSTRLEN
#define SNMPD_MAXVARBIND 0x7fffffff //#define SNMPD_MAXVARBIND 0x7fffffff
#define SNMPD_MAXVARBINDLEN 1210 //#define SNMPD_MAXVARBINDLEN 1210
#define SNMPD_MAXENGINEIDLEN 32 //#define SNMPD_MAXENGINEIDLEN 32
#define SNMPD_MAXUSERNAMELEN 32 //#define SNMPD_MAXUSERNAMELEN 32
#define SNMPD_MAXCONTEXNAMELEN 32 //#define SNMPD_MAXCONTEXNAMELEN 32
#define SNMP_USM_MAXDIGESTLEN 48 //#define SNMP_USM_MAXDIGESTLEN 48
#define SNMP_USM_SALTLEN 8 //#define SNMP_USM_SALTLEN 8
#define SNMP_USM_KEYLEN 64 //#define SNMP_USM_KEYLEN 64
#define SNMP_CIPHER_KEYLEN 16 //#define SNMP_CIPHER_KEYLEN 16
//
//#define SMALL_READ_BUF_SIZE 1024
//#define READ_BUF_SIZE 65535
//#define RT_BUF_SIZE 16384
//#define MAX_RTSOCK_BUF (2 * 1024 * 1024)
#define SMALL_READ_BUF_SIZE 1024 //#define SNMP_ENGINEID_OLD 0x00
#define READ_BUF_SIZE 65535 //#define SNMP_ENGINEID_NEW 0x80 /* RFC3411 */
#define RT_BUF_SIZE 16384
#define MAX_RTSOCK_BUF (2 * 1024 * 1024)
#define SNMP_ENGINEID_OLD 0x00 //#define SNMP_ENGINEID_FMT_IPv4 1
#define SNMP_ENGINEID_NEW 0x80 /* RFC3411 */ //#define SNMP_ENGINEID_FMT_IPv6 2
//#define SNMP_ENGINEID_FMT_MAC 3
//#define SNMP_ENGINEID_FMT_TEXT 4
//#define SNMP_ENGINEID_FMT_OCT 5
//#define SNMP_ENGINEID_FMT_HH 129
#define SNMP_ENGINEID_FMT_IPv4 1 //#define PEN_OPENBSD 30155
#define SNMP_ENGINEID_FMT_IPv6 2
#define SNMP_ENGINEID_FMT_MAC 3
#define SNMP_ENGINEID_FMT_TEXT 4
#define SNMP_ENGINEID_FMT_OCT 5
#define SNMP_ENGINEID_FMT_HH 129
#define PEN_OPENBSD 30155 //#if DEBUG
//#define DPRINTF log_debug
#if DEBUG //#else
#define DPRINTF log_debug //#define DPRINTF(x...) do {} while(0)
#else //#endif
#define DPRINTF(x...) do {} while(0)
#endif
/* /*
* daemon structures * daemon structures
*/ */
struct snmpd { struct snmpd {
int sc_ncpu; // int sc_ncpu;
int64_t *sc_cpustates; // int64_t *sc_cpustates;
}; };
extern struct snmpd *snmpd_env; extern struct snmpd *snmpd_env;
@ -103,7 +89,7 @@ u_long smi_getticks(void);
/* timer.c */ /* timer.c */
void timer_init(void); //void timer_init(void);
/* util.c */ /* util.c */
ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *, ssize_t sendtofrom(int, void *, size_t, int, struct sockaddr *,