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

mode_end_call.c

00001 /* Portions of this file are subject to the following copyright(s).  See
00002  * the Net-SNMP's COPYING file for more details and other copyrights
00003  * that may apply:
00004  */
00005 /*
00006  * Portions of this file are copyrighted by:
00007  * Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
00008  * Use is subject to license terms specified in the COPYING file
00009  * distributed with the Net-SNMP package.
00010  */
00011 #include <net-snmp/net-snmp-config.h>
00012 
00013 #include <net-snmp/net-snmp-includes.h>
00014 #include <net-snmp/agent/net-snmp-agent-includes.h>
00015 
00016 #include <net-snmp/agent/mode_end_call.h>
00017 
00043 netsnmp_mib_handler *
00044 netsnmp_get_mode_end_call_handler(netsnmp_mode_handler_list *endlist)
00045 {
00046     netsnmp_mib_handler *me =
00047         netsnmp_create_handler("mode_end_call",
00048                                netsnmp_mode_end_call_helper);
00049 
00050     if (!me)
00051         return NULL;
00052 
00053     me->myvoid = endlist;
00054     return me;
00055 }
00056 
00063 netsnmp_mode_handler_list *
00064 netsnmp_mode_end_call_add_mode_callback(netsnmp_mode_handler_list *endlist,
00065                                         int mode,
00066                                         netsnmp_mib_handler *callbackh) {
00067     netsnmp_mode_handler_list *ptr, *ptr2;
00068     ptr = SNMP_MALLOC_TYPEDEF(netsnmp_mode_handler_list);
00069     if (!ptr)
00070         return NULL;
00071     
00072     ptr->mode = mode;
00073     ptr->callback_handler = callbackh;
00074     ptr->next = NULL;
00075 
00076     if (!endlist)
00077         return ptr;
00078 
00079     /* get to end */
00080     for(ptr2 = endlist; ptr2->next != NULL; ptr2 = ptr2->next);
00081 
00082     ptr2->next = ptr;
00083     return endlist;
00084 }
00085     
00087 int
00088 netsnmp_mode_end_call_helper(netsnmp_mib_handler *handler,
00089                             netsnmp_handler_registration *reginfo,
00090                             netsnmp_agent_request_info *reqinfo,
00091                             netsnmp_request_info *requests)
00092 {
00093 
00094     int             ret;
00095     int             ret2 = SNMP_ERR_NOERROR;
00096     netsnmp_mode_handler_list *ptr;
00097 
00098     /* always call the real handlers first */
00099     ret = netsnmp_call_next_handler(handler, reginfo, reqinfo,
00100                                     requests);
00101 
00102     /* then call the callback handlers */
00103     for(ptr = handler->myvoid; ptr; ptr = ptr->next) {
00104         if (ptr->mode == NETSNMP_MODE_END_ALL_MODES ||
00105             reqinfo->mode == ptr->mode) {
00106             ret2 = netsnmp_call_handler(ptr->callback_handler, reginfo,
00107                                              reqinfo, requests);
00108             if (ret != SNMP_ERR_NOERROR)
00109                 ret = ret2;
00110         }
00111     }
00112     
00113     return ret2;
00114 }

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

Valid CSS!


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