Logo
Home page Net-SNMP

Archive Search:

Require all words?

Site Search:
Google
Main Page | Modules | Data Structures | File List | Data Fields | Related Pages | Examples

bulk_to_next.c

00001 #include <net-snmp/net-snmp-config.h>
00002 
00003 #if HAVE_STRING_H
00004 #include <string.h>
00005 #else
00006 #include <strings.h>
00007 #endif
00008 
00009 #include <net-snmp/net-snmp-includes.h>
00010 #include <net-snmp/agent/net-snmp-agent-includes.h>
00011 
00012 #include <net-snmp/agent/bulk_to_next.h>
00013 
00025 netsnmp_mib_handler *
00026 netsnmp_get_bulk_to_next_handler(void)
00027 {
00028     netsnmp_mib_handler *handler =
00029         netsnmp_create_handler("bulk_to_next",
00030                                netsnmp_bulk_to_next_helper);
00031 
00032     if (NULL != handler)
00033         handler->flags |= MIB_HANDLER_AUTO_NEXT;
00034 
00035     return handler;
00036 }
00037 
00040 void
00041 netsnmp_bulk_to_next_fix_requests(netsnmp_request_info *requests)
00042 {
00043     netsnmp_request_info *request;
00044     /*
00045      * update the varbinds for the next request series 
00046      */
00047     for (request = requests; request; request = request->next) {
00048         if (request->repeat > 0 &&
00049             request->requestvb->type != ASN_NULL &&
00050             request->requestvb->type != ASN_PRIV_RETRY &&
00051             request->requestvb->next_variable ) {
00052             request->repeat--;
00053             snmp_set_var_objid(request->requestvb->next_variable,
00054                                request->requestvb->name,
00055                                request->requestvb->name_length);
00056             request->requestvb = request->requestvb->next_variable;
00057             request->requestvb->type = ASN_PRIV_RETRY;
00058         }
00059     }
00060 }
00061 
00063 int
00064 netsnmp_bulk_to_next_helper(netsnmp_mib_handler *handler,
00065                             netsnmp_handler_registration *reginfo,
00066                             netsnmp_agent_request_info *reqinfo,
00067                             netsnmp_request_info *requests)
00068 {
00069 
00070     int             ret = SNMP_ERR_NOERROR;
00071 
00072     /*
00073      * this code depends on AUTO_NEXT being set
00074      */
00075     netsnmp_assert(handler->flags & MIB_HANDLER_AUTO_NEXT);
00076 
00077     /*
00078      * don't do anything for any modes besides GETBULK. Just return, and
00079      * the agent will call the next handler (AUTO_NEXT).
00080      *
00081      * for GETBULK, we munge the mode, call the next handler ourselves
00082      * (setting AUTO_NEXT_OVERRRIDE so the agent knows what we did),
00083      * restore the mode and fix up the requests.
00084      */
00085     if(MODE_GETBULK == reqinfo->mode) {
00086 
00087         DEBUGIF("bulk_to_next") {
00088             netsnmp_request_info *req = requests;
00089             while(req) {
00090                 DEBUGMSGTL(("bulk_to_next", "Got request: "));
00091                 DEBUGMSGOID(("bulk_to_next", req->requestvb->name,
00092                              req->requestvb->name_length));
00093                 DEBUGMSG(("bulk_to_next", "\n"));
00094                 req = req->next;
00095             }
00096         }
00097 
00098         reqinfo->mode = MODE_GETNEXT;
00099         ret =
00100             netsnmp_call_next_handler(handler, reginfo, reqinfo, requests);
00101         reqinfo->mode = MODE_GETBULK;
00102 
00103         /*
00104          * update the varbinds for the next request series 
00105          */
00106         netsnmp_bulk_to_next_fix_requests(requests);
00107 
00108         /*
00109          * let agent handler know that we've already called next handler
00110          */
00111         handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
00112     }
00113 
00114     return ret;
00115 }
00116 
00121 void
00122 netsnmp_init_bulk_to_next_helper(void)
00123 {
00124     netsnmp_register_handler_by_name("bulk_to_next",
00125                                      netsnmp_get_bulk_to_next_handler());
00126 }

Generated on Fri Dec 30 13:47:44 2005 for net-snmp by  doxygen 1.3.9.1

Valid CSS!


Last modified: Thursday, 01-Mar-2007 16:20:07 PST
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.