1 #include <net-snmp/net-snmp-config.h>
9 #include <net-snmp/net-snmp-includes.h>
10 #include <net-snmp/agent/net-snmp-agent-includes.h>
12 #include <net-snmp/agent/read_only.h>
18 /** @defgroup read_only read_only: make your handler read_only automatically
19 * The only purpose of this handler is to return an
20 * appropriate error for any requests passed to it in a SET mode.
21 * Inserting it into your handler chain will ensure you're never
22 * asked to perform a SET request so you can ignore those error
28 /** returns a read_only handler that can be injected into a given
32 netsnmp_get_read_only_handler(void)
34 return netsnmp_create_handler("read_only", netsnmp_read_only_helper);
37 /** @internal Implements the read_only handler */
39 netsnmp_read_only_helper(netsnmp_mib_handler *handler,
40 netsnmp_handler_registration *reginfo,
41 netsnmp_agent_request_info *reqinfo,
42 netsnmp_request_info *requests)
45 DEBUGMSGTL(("helper:read_only", "Got request\n"));
47 switch (reqinfo->mode) {
49 case MODE_SET_RESERVE1:
50 case MODE_SET_RESERVE2:
55 netsnmp_set_all_requests_error(reqinfo, requests,
56 SNMP_ERR_NOTWRITABLE);
57 return SNMP_ERR_NOERROR;
60 return netsnmp_call_next_handler(handler, reginfo, reqinfo,
63 return SNMP_ERR_GENERR; /* should never get here */
66 /** initializes the read_only helper which then registers a read_only
67 * handler as a run-time injectable handler for configuration file
71 netsnmp_init_read_only_helper(void)
73 netsnmp_register_handler_by_name("read_only",
74 netsnmp_get_read_only_handler());