5 #include <net-snmp/net-snmp-config.h>
20 #if TIME_WITH_SYS_TIME
22 # include <sys/timeb.h>
24 # include <sys/time.h>
29 # include <sys/time.h>
35 #include <netinet/in.h>
37 #if HAVE_NETINET_IN_SYSTM_H
38 #include <netinet/in_systm.h>
41 #include <netinet/ip.h>
44 #if HAVE_NETINET_IP6_H
45 #include <netinet/ip6.h>
49 #include <sys/queue.h>
52 #include <sys/socket.h>
53 #if HAVE_SYS_SOCKETVAR_H
55 #include <sys/socketvar.h>
57 #include <sys/param.h>
64 #include <sys/stream.h>
67 #include <net/route.h>
69 #if HAVE_NETINET_IP_VAR_H
70 #include <netinet/ip_var.h>
73 #if HAVE_NETINET6_IP6_VAR_H
74 #include <netinet6/ip6_var.h>
77 #if HAVE_NETINET_IN_PCB_H
78 #include <netinet/in_pcb.h>
81 #include <inet/mib2.h>
98 #include <net-snmp/net-snmp-includes.h>
99 #include <net-snmp/agent/net-snmp-agent-includes.h>
101 #include "mibgroup/struct.h"
102 #include <net-snmp/agent/agent_trap.h>
104 #include <net-snmp/agent/agent_callbacks.h>
105 #include <net-snmp/agent/table.h>
106 #include <net-snmp/agent/table_iterator.h>
107 #include <net-snmp/agent/table_data.h>
108 #include <net-snmp/agent/table_dataset.h>
109 #include "mib_module_includes.h"
111 char dontReadConfigFiles;
114 #ifdef BRCM_SNMP_SUPPORT
117 snmpd_set_agent_user(const char *token, char *cptr)
119 #if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
123 if (cptr[0] == '#') {
126 uid = strtoul(cptr + 1, &ecp, 10);
128 config_perror("Bad number");
130 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
131 NETSNMP_DS_AGENT_USERID, uid);
134 #if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
135 else if ((info = getpwnam(cptr)) != NULL) {
136 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
137 NETSNMP_DS_AGENT_USERID, info->pw_uid);
139 config_perror("User not found in passwd database");
145 snmpd_set_agent_group(const char *token, char *cptr)
147 #if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
151 if (cptr[0] == '#') {
153 int gid = strtoul(cptr + 1, &ecp, 10);
155 config_perror("Bad number");
157 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
158 NETSNMP_DS_AGENT_GROUPID, gid);
161 #if defined(HAVE_GETGRNAM) && defined(HAVE_GRP_H)
162 else if ((info = getgrnam(cptr)) != NULL) {
163 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
164 NETSNMP_DS_AGENT_GROUPID, info->gr_gid);
166 config_perror("Group not found in group database");
173 snmpd_set_agent_address(const char *token, char *cptr)
175 char buf[SPRINT_MAX_LEN];
179 * has something been specified before?
181 ptr = netsnmp_ds_get_string(NETSNMP_DS_APPLICATION_ID,
182 NETSNMP_DS_AGENT_PORTS);
186 * append to the older specification string
188 sprintf(buf, "%s,%s", ptr, cptr);
193 DEBUGMSGTL(("snmpd_ports", "port spec: %s\n", buf));
194 netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
195 NETSNMP_DS_AGENT_PORTS, buf);
197 #endif /* BRCM_SNMP_SUPPORT */
200 init_agent_read_config(const char *app)
203 netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
204 NETSNMP_DS_LIB_APPTYPE, app);
206 app = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
207 NETSNMP_DS_LIB_APPTYPE);
210 #ifdef BRCM_SNMP_CONFIG_SUPPORT
211 register_app_config_handler("authtrapenable",
212 snmpd_parse_config_authtrap, NULL,
213 "1 | 2\t\t(1 = enable, 2 = disable)");
214 register_app_config_handler("pauthtrapenable",
215 snmpd_parse_config_authtrap, NULL, NULL);
218 if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
219 NETSNMP_DS_AGENT_ROLE) == MASTER_AGENT) {
220 register_app_config_handler("trapsink",
221 snmpd_parse_config_trapsink,
222 snmpd_free_trapsinks,
223 "host [community] [port]");
224 register_app_config_handler("trap2sink",
225 snmpd_parse_config_trap2sink, NULL,
226 "host [community] [port]");
228 #ifdef BRCM_SNMP_CONFIG_SUPPORT
229 register_app_config_handler("informsink",
230 snmpd_parse_config_informsink, NULL,
231 "host [community] [port]");
232 register_app_config_handler("trapsess",
233 snmpd_parse_config_trapsess, NULL,
234 "[snmpcmdargs] host");
237 register_app_config_handler("trapcommunity",
238 snmpd_parse_config_trapcommunity,
239 snmpd_free_trapcommunity,
241 #ifdef BRCM_SNMP_SUPPORT
243 register_app_config_handler("agentuser",
244 snmpd_set_agent_user, NULL, "userid");
245 register_app_config_handler("agentgroup",
246 snmpd_set_agent_group, NULL, "groupid");
248 register_app_config_handler("agentaddress",
249 snmpd_set_agent_address, NULL,
250 "SNMP bind address");
251 register_app_config_handler("table",
252 netsnmp_config_parse_table_set, NULL,
254 register_app_config_handler("add_row", netsnmp_config_parse_add_row,
255 NULL, "indexes... values...");
256 netsnmp_ds_register_config(ASN_BOOLEAN, app, "quit",
257 NETSNMP_DS_APPLICATION_ID,
258 NETSNMP_DS_AGENT_QUIT_IMMEDIATELY);
259 netsnmp_ds_register_config(ASN_BOOLEAN, app, "leave_pidfile",
260 NETSNMP_DS_APPLICATION_ID,
261 NETSNMP_DS_AGENT_LEAVE_PIDFILE);
262 netsnmp_init_handler_conf();
263 #endif /* BRCM_SNMP_SUPPORT */
265 #include "mib_module_dot_conf.h"
268 print_config_handlers();
275 snmp_call_callbacks(SNMP_CALLBACK_APPLICATION,
276 SNMPD_CALLBACK_PRE_UPDATE_CONFIG, NULL);
283 snmpd_register_config_handler(const char *token,
284 void (*parser) (const char *, char *),
285 void (*releaser) (void), const char *help)
287 DEBUGMSGTL(("snmpd_register_app_config_handler",
288 "registering .conf token for \"%s\"\n", token));
289 register_app_config_handler(token, parser, releaser, help);
293 snmpd_unregister_config_handler(const char *token)
295 unregister_app_config_handler(token);
299 * this function is intended for use by mib-modules to store permenant
300 * configuration information generated by sets or persistent counters
303 snmpd_store_config(const char *line)
305 read_app_config_store(line);