net-snmp
5.4.1
|
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/read_only.h> 00013 00028 netsnmp_mib_handler * 00029 netsnmp_get_read_only_handler(void) 00030 { 00031 netsnmp_mib_handler *ret = NULL; 00032 00033 ret = netsnmp_create_handler("read_only", 00034 netsnmp_read_only_helper); 00035 if (ret) { 00036 ret->flags |= MIB_HANDLER_AUTO_NEXT; 00037 } 00038 return ret; 00039 } 00040 00042 int 00043 netsnmp_read_only_helper(netsnmp_mib_handler *handler, 00044 netsnmp_handler_registration *reginfo, 00045 netsnmp_agent_request_info *reqinfo, 00046 netsnmp_request_info *requests) 00047 { 00048 00049 DEBUGMSGTL(("helper:read_only", "Got request\n")); 00050 00051 switch (reqinfo->mode) { 00052 00053 case MODE_SET_RESERVE1: 00054 case MODE_SET_RESERVE2: 00055 case MODE_SET_ACTION: 00056 case MODE_SET_COMMIT: 00057 case MODE_SET_FREE: 00058 case MODE_SET_UNDO: 00059 netsnmp_request_set_error_all(requests, SNMP_ERR_NOTWRITABLE); 00060 return SNMP_ERR_NOTWRITABLE; 00061 00062 case MODE_GET: 00063 case MODE_GETNEXT: 00064 case MODE_GETBULK: 00065 /* next handler called automatically - 'AUTO_NEXT' */ 00066 return SNMP_ERR_NOERROR; 00067 00068 default: 00069 netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR); 00070 return SNMP_ERR_GENERR; 00071 } 00072 netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR); 00073 return SNMP_ERR_GENERR; /* should never get here */ 00074 } 00075 00080 void 00081 netsnmp_init_read_only_helper(void) 00082 { 00083 netsnmp_register_handler_by_name("read_only", 00084 netsnmp_get_read_only_handler()); 00085 }