blob: f82682f363cfff3ae56bf4007225b4d730477e84 [file] [log] [blame]
/*
* agent_read_config.c
*/
#include <config.h>
#include <sys/types.h>
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#include <sys/time.h>
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
#include <netinet/ip.h>
#if HAVE_SYS_QUEUE_H
#include <sys/queue.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_SYS_STREAM_H
#include <sys/stream.h>
#endif
#if HAVE_NET_ROUTE_H
#include <net/route.h>
#endif
#if HAVE_NETINET_IN_PCB_H
#include <netinet/in_pcb.h>
#endif
#if HAVE_INET_MIB2_H
#include <inet/mib2.h>
#endif
#include "m2m.h"
#include "mibincl.h"
#include "snmpusm.h"
#include "mibgroup/struct.h"
#include "read_config.h"
#include "agent_read_config.h"
#include "mib_module_includes.h"
#include "mib_module_config.h"
#include "callback.h"
#include "snmp_agent.h"
#include "snmpd.h"
#include "../snmplib/system.h"
#include "snmp_debug.h"
char dontReadConfigFiles;
char *optconfigfile;
void init_agent_read_config (void)
{
register_config_handler("snmpd","authtrapenable",
snmpd_parse_config_authtrap, NULL,
"1 | 2\t\t(1 = enable, 2 = disable)");
register_config_handler("snmpd","trapsink",
snmpd_parse_config_trapsink, snmpd_free_trapsinks,
"host [community]");
register_config_handler("snmpd","trap2sink",
snmpd_parse_config_trap2sink, NULL,
"host [community]");
register_config_handler("snmpd","trapcommunity",
snmpd_parse_config_trapcommunity,
snmpd_free_trapcommunity,
"community-string");
#include "mibgroup/mib_module_dot_conf.h"
#ifdef TESTING
print_config_handlers();
#endif
}
RETSIGTYPE update_config(int a)
{
free_config();
if (!dontReadConfigFiles) { /* don't read if -C present on command line */
read_configs();
}
/* read all optional config files */
/* last is -c from command line */
/* always read this one even if -C is present (ie both -c and -C) */
if (optconfigfile != NULL) {
read_config_with_type (optconfigfile, "snmpd");
}
snmp_call_callbacks(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_POST_READ_CONFIG,
NULL);
#ifdef SIGHUP
signal(SIGHUP,update_config);
#endif
}
void
snmpd_register_config_handler(const char *token,
void (*parser) (char *, char *),
void (*releaser) (void),
const char *help)
{
DEBUGMSGTL(("snmpd_register_config_handler",
"registering .conf token for \"%s\"\n", token));
register_config_handler("snmpd", token, parser, releaser, help);
}
void
snmpd_unregister_config_handler(const char *token)
{
unregister_config_handler("snmpd", token);
}
/* this function is intended for use by mib-modules to store permenant
configuration information generated by sets or persistent counters */
void
snmpd_store_config(const char *line)
{
read_config_store("snmpd",line);
}