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/serialize.h>
18 /** @defgroup serialize serialize: Calls sub handlers one request at a time.
20 * This functionally passes in one request at a time
21 * into lower handlers rather than a whole bunch of requests at once.
22 * This is useful for handlers that don't want to iterate through the
23 * request lists themselves. Generally, this is probably less
24 * efficient so use with caution. The serialize handler might be
25 * useable to dynamically fix handlers with broken looping code,
30 /** returns a serialize handler that can be injected into a given
34 netsnmp_get_serialize_handler(void)
36 return netsnmp_create_handler("serialize",
37 netsnmp_serialize_helper_handler);
40 /** functionally the same as calling netsnmp_register_handler() but also
41 * injects a serialize handler at the same time for you. */
43 netsnmp_register_serialize(netsnmp_handler_registration *reginfo)
45 netsnmp_inject_handler(reginfo, netsnmp_get_serialize_handler());
46 return netsnmp_register_handler(reginfo);
49 /** Implements the serial handler */
51 netsnmp_serialize_helper_handler(netsnmp_mib_handler *handler,
52 netsnmp_handler_registration *reginfo,
53 netsnmp_agent_request_info *reqinfo,
54 netsnmp_request_info *requests)
57 netsnmp_request_info *request, *requesttmp;
59 DEBUGMSGTL(("helper:serialize", "Got request\n"));
61 * loop through requests
63 for (request = requests; request; request = request->next) {
67 * store next pointer and delete it
69 requesttmp = request->next;
73 * call the next handler
76 netsnmp_call_next_handler(handler, reginfo, reqinfo, request);
79 * restore original next pointer
81 request->next = requesttmp;
83 if (ret != SNMP_ERR_NOERROR)
87 return SNMP_ERR_NOERROR;
91 * initializes the serialize helper which then registers a serialize
92 * handler as a run-time injectable handler for configuration file
96 netsnmp_init_serialize(void)
98 netsnmp_register_handler_by_name("serialize",
99 netsnmp_get_serialize_handler());