Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / agent / helpers / null.c
1 #include <net-snmp/net-snmp-config.h>
2
3 #if HAVE_STRING_H
4 #include <string.h>
5 #else
6 #include <strings.h>
7 #endif
8
9 #include <net-snmp/net-snmp-includes.h>
10 #include <net-snmp/agent/net-snmp-agent-includes.h>
11
12 #include <net-snmp/agent/null.h>
13
14 #if HAVE_DMALLOC_H
15 #include <dmalloc.h>
16 #endif
17
18 int
19 netsnmp_register_null(oid * loc, size_t loc_len)
20 {
21     netsnmp_handler_registration *reginfo;
22     reginfo = SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);
23     reginfo->handlerName = strdup("");
24     reginfo->rootoid = loc;
25     reginfo->rootoid_len = loc_len;
26     reginfo->handler =
27         netsnmp_create_handler("null", netsnmp_null_handler);
28     return netsnmp_register_handler(reginfo);
29 }
30
31 int
32 netsnmp_null_handler(netsnmp_mib_handler *handler,
33                      netsnmp_handler_registration *reginfo,
34                      netsnmp_agent_request_info *reqinfo,
35                      netsnmp_request_info *requests)
36 {
37     DEBUGMSGTL(("helper:null", "Got request\n"));
38
39     DEBUGMSGTL(("helper:null", "  oid:"));
40     DEBUGMSGOID(("helper:null", requests->requestvb->name,
41                  requests->requestvb->name_length));
42     DEBUGMSG(("helper:null", "\n"));
43
44     switch (reqinfo->mode) {
45     case MODE_GETNEXT:
46     case MODE_GETBULK:
47         return SNMP_ERR_NOERROR;
48
49     case MODE_GET:
50         netsnmp_set_all_requests_error(reqinfo, requests,
51                                        SNMP_NOSUCHOBJECT);
52         return SNMP_ERR_NOERROR;
53
54     default:
55         netsnmp_set_all_requests_error(reqinfo, requests,
56                                        SNMP_ERR_NOSUCHNAME);
57         return SNMP_ERR_NOERROR;
58     }
59 }