null.c

来自「开发snmp的开发包有两个开放的SNMP开发库」· C语言 代码 · 共 64 行

C
64
字号
#include <net-snmp/net-snmp-config.h>#if HAVE_STRING_H#include <string.h>#else#include <strings.h>#endif#include <net-snmp/net-snmp-includes.h>#include <net-snmp/agent/net-snmp-agent-includes.h>#include <net-snmp/agent/null.h>intnetsnmp_register_null(oid * loc, size_t loc_len){    return netsnmp_register_null_context(loc, loc_len, NULL);}intnetsnmp_register_null_context(oid * loc, size_t loc_len,                              const char *contextName){    netsnmp_handler_registration *reginfo;    reginfo = SNMP_MALLOC_TYPEDEF(netsnmp_handler_registration);    reginfo->handlerName = strdup("");    reginfo->rootoid = loc;    reginfo->rootoid_len = loc_len;    reginfo->handler =        netsnmp_create_handler("null", netsnmp_null_handler);    if (contextName)        reginfo->contextName = strdup(contextName);    reginfo->modes = HANDLER_CAN_DEFAULT;    return netsnmp_register_handler(reginfo);}intnetsnmp_null_handler(netsnmp_mib_handler *handler,                     netsnmp_handler_registration *reginfo,                     netsnmp_agent_request_info *reqinfo,                     netsnmp_request_info *requests){    DEBUGMSGTL(("helper:null", "Got request\n"));    DEBUGMSGTL(("helper:null", "  oid:"));    DEBUGMSGOID(("helper:null", requests->requestvb->name,                 requests->requestvb->name_length));    DEBUGMSG(("helper:null", "\n"));    switch (reqinfo->mode) {    case MODE_GETNEXT:    case MODE_GETBULK:        return SNMP_ERR_NOERROR;    case MODE_GET:        netsnmp_request_set_error_all(requests, SNMP_NOSUCHOBJECT);        return SNMP_ERR_NOERROR;    default:        netsnmp_request_set_error_all(requests, SNMP_ERR_NOSUCHNAME);        return SNMP_ERR_NOERROR;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?