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/bulk_to_next.h>
18 /** @defgroup bulk_to_next bulk_to_next: convert GETBULK requests into GETNEXT requests for the handler.
19 * The only purpose of this handler is to convert a GETBULK request
20 * to a GETNEXT request. It is inserted into handler chains where
21 * the handler has not set the HANDLER_CAN_GETBULK flag.
26 /** returns a bulk_to_next handler that can be injected into a given
30 netsnmp_get_bulk_to_next_handler(void)
32 return netsnmp_create_handler("bulk_to_next",
33 netsnmp_bulk_to_next_helper);
36 /** takes answered requests and decrements the repeat count and
37 * updates the requests to the next to-do varbind in the list */
39 netsnmp_bulk_to_next_fix_requests(netsnmp_request_info *requests)
41 netsnmp_request_info *request;
43 * update the varbinds for the next request series
45 for (request = requests; request; request = request->next) {
46 if (request->repeat > 0 &&
47 request->requestvb->type != ASN_NULL &&
48 request->requestvb->type != ASN_PRIV_RETRY) {
50 snmp_set_var_objid(request->requestvb->next_variable,
51 request->requestvb->name,
52 request->requestvb->name_length);
53 request->requestvb = request->requestvb->next_variable;
54 request->requestvb->type = ASN_PRIV_RETRY;
59 /** @internal Implements the bulk_to_next handler */
61 netsnmp_bulk_to_next_helper(netsnmp_mib_handler *handler,
62 netsnmp_handler_registration *reginfo,
63 netsnmp_agent_request_info *reqinfo,
64 netsnmp_request_info *requests)
69 switch (reqinfo->mode) {
72 reqinfo->mode = MODE_GETNEXT;
74 netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
75 reqinfo->mode = MODE_GETBULK;
78 * update the varbinds for the next request series
80 netsnmp_bulk_to_next_fix_requests(requests);
84 return netsnmp_call_next_handler(handler, reginfo, reqinfo,
87 return SNMP_ERR_GENERR; /* should never get here */
90 /** initializes the bulk_to_next helper which then registers a bulk_to_next
91 * handler as a run-time injectable handler for configuration file
95 netsnmp_init_bulk_to_next_helper(void)
97 netsnmp_register_handler_by_name("bulk_to_next",
98 netsnmp_get_bulk_to_next_handler());