LEAF MIB
"yogesh marathe" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
i gave command
snmpget -v 2c -c public localhost leaf.leafNetwork.leafNetworkHostsIp.0
and my leaf.c leaf mib look like
LEAF-MIB DEFINITIONS ::= BEGIN
IMPORTS
mgmt, experimental, NetworkAddress, IpAddress, Counter, Gauge,
TimeTicks
FROM RFC1155-SMI
OBJECT-TYPE
FROM RFC-1212;
DisplayString ::=
OCTET STRING
PhysAddress ::=
OCTET STRING
--internet OBJECT IDENTIFIER ::= { iso org(3) dod(6) 1 }
leaf OBJECT IDENTIFIER ::= { iso org(3) dod(6) internet(1) experimental(3) 100 }
leafNetwork OBJECT IDENTIFIER ::= { leaf 1 }
--leafSystem OBJECT IDENTIFIER ::= { leaf 2 }
leafNetworkInterfaces OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"/etc/network/interfaces"
::= { leafNetwork 1 }
leafNetworkOptions OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"/etc/network/options"
::= { leafNetwork 2 }
leafNetworkHostsIP OBJECT-TYPE
SYNTAX IpAddress
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/hosts"
::= { leafNetwork 3 }
leafNetworkHostName OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/hostname"
::= { leafNetwork 4 }
leafNetworkResolv OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/resolv.conf"
::= { leafNetwork 5 }
leafNetworkSSD OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/inetd.conf"
::= { leafNetwork 6 }
leafNetworkHostsAllowed OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/hosts.allow"
::= { leafNetwork 7 }
leafNetworkHostsDenied OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/hosts.deny"
::= { leafNetwork 8 }
leafNetworkNet OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
ACCESS read-write
STATUS mandatory
DESCRIPTION
"/etc/network"
::= { leafNetwork 9 }
END
(WE DONT KNOW WHAT EXACTLY WE SHOULD WRITE IN THIS .C FILE PLEASE HELP US.)
LEAF.c looks like
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "leaf.h"
/** Initializes the leaf module */
void
init_leaf(void)
{
static oid leafNetworkInterfaces_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 1 };
static oid leafNetworkOptions_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 2 };
static oid leafNetworkHostsIP_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 3 };
static oid leafNetworkHostName_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 4 };
static oid leafNetworkResolv_oid[] = { 1, 3, 6, 1, 3, 100, 1, 5 };
static oid leafNetworkSSD_oid[] = { 1, 3, 6, 1, 3, 100, 1, 6 };
static oid leafNetworkHostsAllowed_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 7 };
static oid leafNetworkHostsDenied_oid[] =
{ 1, 3, 6, 1, 3, 100, 1, 8 };
static oid leafNetworkNet_oid[] = { 1, 3, 6, 1, 3, 100, 1, 9 };
DEBUGMSGTL(("leaf", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkInterfaces",
handle_leafNetworkInterfaces,
leafNetworkInterfaces_oid,
OID_LENGTH(leafNetworkInterfaces_oid),
HANDLER_CAN_RONLY));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkOptions",
handle_leafNetworkOptions,
leafNetworkOptions_oid,
OID_LENGTH(leafNetworkOptions_oid),
HANDLER_CAN_RONLY));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkHostsIP",
handle_leafNetworkHostsIP,
leafNetworkHostsIP_oid,
OID_LENGTH(leafNetworkHostsIP_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkHostName",
handle_leafNetworkHostName,
leafNetworkHostName_oid,
OID_LENGTH(leafNetworkHostName_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkResolv", handle_leafNetworkResolv,
leafNetworkResolv_oid,
OID_LENGTH(leafNetworkResolv_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkSSD", handle_leafNetworkSSD,
leafNetworkSSD_oid,
OID_LENGTH(leafNetworkSSD_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkHostsAllowed",
handle_leafNetworkHostsAllowed,
leafNetworkHostsAllowed_oid,
OID_LENGTH(leafNetworkHostsAllowed_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkHostsDenied",
handle_leafNetworkHostsDenied,
leafNetworkHostsDenied_oid,
OID_LENGTH(leafNetworkHostsDenied_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_scalar(netsnmp_create_handler_registration
("leafNetworkNet", handle_leafNetworkNet,
leafNetworkNet_oid,
OID_LENGTH(leafNetworkNet_oid),
HANDLER_CAN_RWRITE));
}
int
handle_leafNetworkInterfaces(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkInterfaces\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkOptions(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkOptions\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkHostsIP(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_IPADDRESS,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_IPADDRESS);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkHostsIP\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkHostName(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkHostName\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkResolv(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkResolv\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkSSD(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR, "unknown mode (%d) in handle_leafNetworkSSD\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkHostsAllowed(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkHostsAllowed\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkHostsDenied(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR,
"unknown mode (%d) in handle_leafNetworkHostsDenied\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_leafNetworkNet(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
/*
* We are never called for a GETNEXT if it's registered as a
* "instance", as it's "magically" handled for us.
*/
/*
* a instance handler also only hands us one request at a time, so
* we don't need to loop over a list of requests; we'll only get one.
*/
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_OCTET_STR,
(u_char *)
/* XXX: a pointer to the scalar's data */
,
/*
* XXX: the length of the data in bytes
*/ );
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
/*
* or you could use netsnmp_check_vb_type_and_size instead
*/
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
/*
* XXX malloc "undo" storage buffer
*/
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
/*
* XXX: free resources allocated in RESERVE1 and/or
* RESERVE2. Something failed somewhere, and the states
* below won't be called.
*/
break;
case MODE_SET_ACTION:
/*
* XXX: perform the value change here
*/
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
if ( /* XXX: error? */ ) {
/*
* try _really_really_ hard to never get to this point
*/
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR, "unknown mode (%d) in handle_leafNetworkNet\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
LEAF.h
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
*/
#ifndef LEAF_H
#define LEAF_H
/*
* function declarations
*/
void init_leaf(void);
Netsnmp_Node_Handler handle_leafNetworkInterfaces;
Netsnmp_Node_Handler handle_leafNetworkOptions;
Netsnmp_Node_Handler handle_leafNetworkHostsIP;
Netsnmp_Node_Handler handle_leafNetworkHostName;
Netsnmp_Node_Handler handle_leafNetworkResolv;
Netsnmp_Node_Handler handle_leafNetworkSSD;
Netsnmp_Node_Handler handle_leafNetworkHostsAllowed;
Netsnmp_Node_Handler handle_leafNetworkHostsDenied;
Netsnmp_Node_Handler handle_leafNetworkNet;
#endif /* LEAF_H */
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users