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 #if HAVE_STRING_H 00014 #include <string.h> 00015 #else 00016 #include <strings.h> 00017 #endif 00018 00019 #include <net-snmp/net-snmp-includes.h> 00020 #include <net-snmp/agent/net-snmp-agent-includes.h> 00021 00022 #include <net-snmp/agent/debug_handler.h> 00023 00049 netsnmp_mib_handler * 00050 netsnmp_get_debug_handler(void) 00051 { 00052 return netsnmp_create_handler("debug", netsnmp_debug_helper); 00053 } 00054 00056 void 00057 debug_print_requests(netsnmp_request_info *requests) 00058 { 00059 netsnmp_request_info *request; 00060 00061 for (request = requests; request; request = request->next) { 00062 DEBUGMSGTL(("helper:debug", " #%2d: ", request->index)); 00063 DEBUGMSGVAR(("helper:debug", request->requestvb)); 00064 DEBUGMSG(("helper:debug", "\n")); 00065 00066 if (request->processed) 00067 DEBUGMSGTL(("helper:debug", " [processed]\n")); 00068 if (request->delegated) 00069 DEBUGMSGTL(("helper:debug", " [delegated]\n")); 00070 if (request->status) 00071 DEBUGMSGTL(("helper:debug", " [status = %d]\n", 00072 request->status)); 00073 if (request->parent_data) { 00074 netsnmp_data_list *lst; 00075 DEBUGMSGTL(("helper:debug", " [parent data =")); 00076 for (lst = request->parent_data; lst; lst = lst->next) { 00077 DEBUGMSG(("helper:debug", " %s", lst->name)); 00078 } 00079 DEBUGMSG(("helper:debug", "]\n")); 00080 } 00081 } 00082 } 00083 00084 00086 int 00087 netsnmp_debug_helper(netsnmp_mib_handler *handler, 00088 netsnmp_handler_registration *reginfo, 00089 netsnmp_agent_request_info *reqinfo, 00090 netsnmp_request_info *requests) 00091 { 00092 00093 netsnmp_mib_handler *hptr; 00094 int i, ret, count; 00095 00096 DEBUGMSGTL(("helper:debug", "Entering Debugging Helper:\n")); 00097 DEBUGMSGTL(("helper:debug", " Handler Registration Info:\n")); 00098 DEBUGMSGTL(("helper:debug", " Name: %s\n", 00099 reginfo->handlerName)); 00100 DEBUGMSGTL(("helper:debug", " Context: %s\n", 00101 (NULL == reginfo->contextName) 00102 ? "NULL" : reginfo->contextName)); 00103 DEBUGMSGTL(("helper:debug", " Base OID: ")); 00104 DEBUGMSGOID(("helper:debug", reginfo->rootoid, reginfo->rootoid_len)); 00105 DEBUGMSG(("helper:debug", "\n")); 00106 00107 DEBUGMSGTL(("helper:debug", " Modes: 0x%x = ", 00108 reginfo->modes)); 00109 for (count = 0, i = reginfo->modes; i; i = i >> 1, count++) { 00110 if (i & 0x01) { 00111 DEBUGMSG(("helper:debug", "%s | ", 00112 se_find_label_in_slist("handler_can_mode", 00113 0x01 << count))); 00114 } 00115 } 00116 DEBUGMSG(("helper:debug", "\n")); 00117 00118 DEBUGMSGTL(("helper:debug", " Priority: %d\n", 00119 reginfo->priority)); 00120 00121 DEBUGMSGTL(("helper:debug", " Handler Calling Chain:\n")); 00122 DEBUGMSGTL(("helper:debug", " ")); 00123 for (hptr = reginfo->handler; hptr; hptr = hptr->next) { 00124 DEBUGMSG(("helper:debug", " -> %s", hptr->handler_name)); 00125 if (hptr->myvoid) 00126 DEBUGMSG(("helper:debug", " [myvoid = %x]", hptr->myvoid)); 00127 } 00128 DEBUGMSG(("helper:debug", "\n")); 00129 00130 DEBUGMSGTL(("helper:debug", " Request information:\n")); 00131 DEBUGMSGTL(("helper:debug", " Mode: %s (%d = 0x%x)\n", 00132 se_find_label_in_slist("agent_mode", reqinfo->mode), 00133 reqinfo->mode, reqinfo->mode)); 00134 DEBUGMSGTL(("helper:debug", " Request Variables:\n")); 00135 debug_print_requests(requests); 00136 00137 DEBUGMSGTL(("helper:debug", " --- calling next handler --- \n")); 00138 ret = netsnmp_call_next_handler(handler, reginfo, reqinfo, requests); 00139 00140 DEBUGMSGTL(("helper:debug", " Results:\n")); 00141 DEBUGMSGTL(("helper:debug", " Returned code: %d\n", ret)); 00142 DEBUGMSGTL(("helper:debug", " Returned Variables:\n")); 00143 debug_print_requests(requests); 00144 00145 DEBUGMSGTL(("helper:debug", "Exiting Debugging Helper:\n")); 00146 return ret; 00147 } 00148 00153 void 00154 netsnmp_init_debug_helper(void) 00155 { 00156 netsnmp_register_handler_by_name("debug", netsnmp_get_debug_handler()); 00157 }
1.3.9.1
Last modified: Thursday, 01-Mar-2007 16:20:12 PST
For questions regarding web content and site functionality, please write to the net-snmp-users mail list.