null.c

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/null.h>
00013 
00014 int
00015 netsnmp_register_null(oid * loc, size_t loc_len)
00016 {
00017     return netsnmp_register_null_context(loc, loc_len, NULL);
00018 }
00019 
00020 int
00021 netsnmp_register_null_context(oid * loc, size_t loc_len,
00022                               const char *contextName)
00023 {
00024     netsnmp_handler_registration *reginfo;
00025     reginfo = SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);
00026     reginfo->handlerName = strdup("");
00027     reginfo->rootoid = loc;
00028     reginfo->rootoid_len = loc_len;
00029     reginfo->handler =
00030         netsnmp_create_handler("null", netsnmp_null_handler);
00031     if (contextName)
00032         reginfo->contextName = strdup(contextName);
00033     reginfo->modes = HANDLER_CAN_DEFAULT;
00034     return netsnmp_register_handler(reginfo);
00035 }
00036 
00037 int
00038 netsnmp_null_handler(netsnmp_mib_handler *handler,
00039                      netsnmp_handler_registration *reginfo,
00040                      netsnmp_agent_request_info *reqinfo,
00041                      netsnmp_request_info *requests)
00042 {
00043     DEBUGMSGTL(("helper:null", "Got request\n"));
00044 
00045     DEBUGMSGTL(("helper:null", "  oid:"));
00046     DEBUGMSGOID(("helper:null", requests->requestvb->name,
00047                  requests->requestvb->name_length));
00048     DEBUGMSG(("helper:null", "\n"));
00049 
00050     switch (reqinfo->mode) {
00051     case MODE_GETNEXT:
00052     case MODE_GETBULK:
00053         return SNMP_ERR_NOERROR;
00054 
00055     case MODE_GET:
00056         netsnmp_request_set_error_all(requests, SNMP_NOSUCHOBJECT);
00057         return SNMP_ERR_NOERROR;
00058 
00059     default:
00060         netsnmp_request_set_error_all(requests, SNMP_ERR_NOSUCHNAME);
00061         return SNMP_ERR_NOERROR;
00062     }
00063 }

net-snmpに対してSat Sep 5 13:14:22 2009に生成されました。  doxygen 1.4.7