Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / snmp / agent / mibgroup / agentx / agentx_config.c
blobd48f827bec29704ca4f4942e0c7e8235c090fba6
1 /*
2 * AgentX Configuration
3 */
4 #include <net-snmp/net-snmp-config.h>
6 #include <stdio.h>
7 #include <sys/types.h>
8 #ifdef HAVE_STDLIB_H
9 #include <stdlib.h>
10 #endif
11 #if HAVE_STRING_H
12 #include <string.h>
13 #else
14 #include <strings.h>
15 #endif
17 #include <net-snmp/net-snmp-includes.h>
18 #include <net-snmp/agent/net-snmp-agent-includes.h>
19 #include "snmpd.h"
20 #include "agentx/agentx_config.h"
22 #ifdef USING_AGENTX_MASTER_MODULE
23 void
24 agentx_parse_master(const char *token, char *cptr)
26 int i = -1;
27 char buf[BUFSIZ];
29 if (!strcmp(cptr, "agentx") ||
30 !strcmp(cptr, "all") ||
31 !strcmp(cptr, "yes") || !strcmp(cptr, "on")) {
32 i = 1;
33 snmp_log(LOG_INFO, "Turning on AgentX master support.\n");
34 } else if (!strcmp(cptr, "no") || !strcmp(cptr, "off"))
35 i = 0;
36 else
37 i = atoi(cptr);
39 if (i < 0 || i > 1) {
40 sprintf(buf, "master '%s' unrecognised", cptr);
41 config_perror(buf);
42 } else
43 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_AGENTX_MASTER, i);
45 #endif /* USING_AGENTX_MASTER_MODULE */
47 void
48 agentx_parse_agentx_socket(const char *token, char *cptr)
50 DEBUGMSGTL(("agentx/config", "port spec: %s\n", cptr));
51 netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, cptr);
54 void
55 agentx_parse_agentx_timeout(const char *token, char *cptr)
57 int x = atoi(cptr);
58 DEBUGMSGTL(("agentx/config/timeout", "%s\n", cptr));
59 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
60 NETSNMP_DS_AGENT_AGENTX_TIMEOUT, x * ONE_SEC);
63 void
64 agentx_parse_agentx_retries(const char *token, char *cptr)
66 int x = atoi(cptr);
67 DEBUGMSGTL(("agentx/config/retries", "%s\n", cptr));
68 netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
69 NETSNMP_DS_AGENT_AGENTX_RETRIES, x);
72 void
73 init_agentx_config(void)
76 * Don't set this up as part of the per-module initialisation.
77 * Delay this until the 'init_master_agent()' routine is called,
78 * so that the config settings have been processed.
79 * This means that we can use a config directive to determine
80 * whether or not to run as an AgentX master.
82 #ifdef USING_AGENTX_MASTER_MODULE
83 if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE) == MASTER_AGENT)
84 snmpd_register_config_handler("master",
85 agentx_parse_master, NULL,
86 "specify 'agentx' for AgentX support");
87 #endif /* USING_AGENTX_MASTER_MODULE */
88 snmpd_register_config_handler("agentxsocket",
89 agentx_parse_agentx_socket, NULL,
90 "AgentX bind address");
91 snmpd_register_config_handler("agentxRetries",
92 agentx_parse_agentx_retries, NULL,
93 "AgentX Retries");
94 snmpd_register_config_handler("agentxTimeout",
95 agentx_parse_agentx_timeout, NULL,
96 "AgentX Timeout (seconds)");