net-snmp 5.7
|
00001 #include <net-snmp/net-snmp-config.h> 00002 00003 #include <net-snmp/net-snmp-includes.h> 00004 #include <net-snmp/agent/net-snmp-agent-includes.h> 00005 00006 #include <net-snmp/agent/serialize.h> 00007 00024 netsnmp_mib_handler * 00025 netsnmp_get_serialize_handler(void) 00026 { 00027 return netsnmp_create_handler("serialize", 00028 netsnmp_serialize_helper_handler); 00029 } 00030 00033 int 00034 netsnmp_register_serialize(netsnmp_handler_registration *reginfo) 00035 { 00036 netsnmp_inject_handler(reginfo, netsnmp_get_serialize_handler()); 00037 return netsnmp_register_handler(reginfo); 00038 } 00039 00041 int 00042 netsnmp_serialize_helper_handler(netsnmp_mib_handler *handler, 00043 netsnmp_handler_registration *reginfo, 00044 netsnmp_agent_request_info *reqinfo, 00045 netsnmp_request_info *requests) 00046 { 00047 00048 netsnmp_request_info *request, *requesttmp; 00049 00050 DEBUGMSGTL(("helper:serialize", "Got request\n")); 00051 /* 00052 * loop through requests 00053 */ 00054 for (request = requests; request; request = request->next) { 00055 int ret; 00056 00057 /* 00058 * store next pointer and delete it 00059 */ 00060 requesttmp = request->next; 00061 request->next = NULL; 00062 00063 /* 00064 * call the next handler 00065 */ 00066 ret = 00067 netsnmp_call_next_handler(handler, reginfo, reqinfo, request); 00068 00069 /* 00070 * restore original next pointer 00071 */ 00072 request->next = requesttmp; 00073 00074 if (ret != SNMP_ERR_NOERROR) 00075 return ret; 00076 } 00077 00078 return SNMP_ERR_NOERROR; 00079 } 00080 00086 void 00087 netsnmp_init_serialize(void) 00088 { 00089 netsnmp_register_handler_by_name("serialize", 00090 netsnmp_get_serialize_handler()); 00091 }