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/read_only.h> 00007 00022 netsnmp_mib_handler * 00023 netsnmp_get_read_only_handler(void) 00024 { 00025 netsnmp_mib_handler *ret = NULL; 00026 00027 ret = netsnmp_create_handler("read_only", 00028 netsnmp_read_only_helper); 00029 if (ret) { 00030 ret->flags |= MIB_HANDLER_AUTO_NEXT; 00031 } 00032 return ret; 00033 } 00034 00036 int 00037 netsnmp_read_only_helper(netsnmp_mib_handler *handler, 00038 netsnmp_handler_registration *reginfo, 00039 netsnmp_agent_request_info *reqinfo, 00040 netsnmp_request_info *requests) 00041 { 00042 00043 DEBUGMSGTL(("helper:read_only", "Got request\n")); 00044 00045 switch (reqinfo->mode) { 00046 00047 #ifndef NETSNMP_NO_WRITE_SUPPORT 00048 case MODE_SET_RESERVE1: 00049 case MODE_SET_RESERVE2: 00050 case MODE_SET_ACTION: 00051 case MODE_SET_COMMIT: 00052 case MODE_SET_FREE: 00053 case MODE_SET_UNDO: 00054 netsnmp_request_set_error_all(requests, SNMP_ERR_NOTWRITABLE); 00055 return SNMP_ERR_NOTWRITABLE; 00056 #endif /* NETSNMP_NO_WRITE_SUPPORT */ 00057 00058 case MODE_GET: 00059 case MODE_GETNEXT: 00060 case MODE_GETBULK: 00061 /* next handler called automatically - 'AUTO_NEXT' */ 00062 return SNMP_ERR_NOERROR; 00063 } 00064 00065 netsnmp_request_set_error_all(requests, SNMP_ERR_GENERR); 00066 return SNMP_ERR_GENERR; 00067 } 00068 00073 void 00074 netsnmp_init_read_only_helper(void) 00075 { 00076 netsnmp_register_handler_by_name("read_only", 00077 netsnmp_get_read_only_handler()); 00078 }