Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

CentOS 3.1

netsnmp_handler(3)


Net-SNMP Agent handler and extensibility API

Net-SNMP Agent handler and extensibility API

NAME
DETAILED DESCRIPTION
FUNCTION DOCUMENTATION

NAME

Net-SNMP Agent handler and extensibility API − The basic theory goes something like this: In the past, with the original mib module api (which derived from the original CMU SNMP code) the underlying mib modules were passed very little information (only the truly most basic information about a request). More...

Modules

bulk_to_next: convert GETBULK requests into GETNEXT requests for the handler.
The only purpose of this handler is to convert a GETBULK request to a GETNEXT request.

debug: print out debugging information about the handler chain being called.
This is a useful module for run-time debugging of requests as the pass this handler in a calling chain.

instance: process scalars and other instances easily.
mode_end_call: at the end of a series of requests, call another handler hook.

Handlers that want to loop through a series of requests and then receive a callback at the end of a particular MODE can use this helper to make this possible.

multiplexer: splits mode requests into calls to different handlers.
The multiplexer helper lets you split the calling chain depending on the calling mode (get vs getnext vs set).

old_api: Calls mib module code written in the old style of code.
This is a backwards compatilibity module that allows code written in the old API to be run under the new handler based architecture.

read_only: make your handler read_only automatically
The only purpose of this handler is to return an appropriate error for any requests passed to it in a SET mode.

scalar: process scalars easily.
serialize: Calls sub handlers one request at a time.

This functionally passes in one request at a time into lower handlers rather than a whole bunch of requests at once.

table: Helps you implement a table.
This handler helps you implement a table by doing some of the processing for you.

watcher: watch a specified variable and process
it as an instance or scalar object

Functions

netsnmp_mib_handler * netsnmp_create_handler (const char *name, Netsnmp_Node_Handler *handler_access_method)
creates a netsnmp_mib_handler structure given a name and a access method.

netsnmp_handler_registration * netsnmp_create_handler_registration (const char *name, Netsnmp_Node_Handler *handler_access_method, oid *reg_oid, size_t reg_oid_len, int modes)
creates a handler registration structure given a name, a access_method function, a registration location oid and the modes the handler supports.

int netsnmp_register_handler (netsnmp_handler_registration *reginfo)
register a handler, as defined by the netsnmp_handler_registration pointer.

int netsnmp_register_handler_nocallback (netsnmp_handler_registration *reginfo)
register a handler, as defined by the netsnmp_handler_registration pointer.

int netsnmp_inject_handler (netsnmp_handler_registration *reginfo, netsnmp_mib_handler *handler)
inject a new handler into the calling chain of the handlers definedy by the netsnmp_handler_registration pointer.

NETSNMP_INLINE int netsnmp_call_handler (netsnmp_mib_handler *next_handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
calls a handler with with appropriate NULL checking of arguments, etc.

NETSNMP_INLINE int netsnmp_call_next_handler (netsnmp_mib_handler *current, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
calls the next handler in the chain after the current one with with appropriate NULL checking, etc.

NETSNMP_INLINE int netsnmp_call_next_handler_one_request (netsnmp_mib_handler *current, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests)
calls the next handler in the chain after the current one with with appropriate NULL checking, etc.

void netsnmp_handler_free (netsnmp_mib_handler *handler)
free’s the resourceses associated with a given handler

netsnmp_mib_handler * netsnmp_handler_dup (netsnmp_mib_handler *handler)
dulpicates a handler

void netsnmp_handler_registration_free (netsnmp_handler_registration *reginfo)
free the resources associated with a handler registration object

netsnmp_handler_registration * netsnmp_handler_registration_dup (netsnmp_handler_registration *reginfo)
duplicates the handler registration object

NETSNMP_INLINE netsnmp_delegated_cache * netsnmp_create_delegated_cache (netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests, void *localinfo)
creates a cache of information which can be saved for future reference.

NETSNMP_INLINE netsnmp_delegated_cache * netsnmp_handler_check_cache (netsnmp_delegated_cache *dcache)
check’s a given cache and returns it if it is still valid (ie, the agent still considers it to be an outstanding request.

NETSNMP_INLINE void netsnmp_free_delegated_cache (netsnmp_delegated_cache *dcache)
frees a cache once you’re finished using it

void netsnmp_handler_mark_requests_as_delegated (netsnmp_request_info *requests, int isdelegated)
marks a list of requests as delegated (or not if isdelegaded = 0)

NETSNMP_INLINE void netsnmp_request_add_list_data (netsnmp_request_info *request, netsnmp_data_list *node)
add data to a request that can be extracted later by submodules

NETSNMP_INLINE void * netsnmp_request_get_list_data (netsnmp_request_info *request, const char *name)
extract data from a request that was added previously by a parent module

NETSNMP_INLINE void netsnmp_free_request_data_set (netsnmp_request_info *request)
Free the extra data stored in a request.

NETSNMP_INLINE void netsnmp_free_request_data_sets (netsnmp_request_info *request)
Free the extra data stored in a bunch of requests (all data in the chain).

netsnmp_mib_handler * netsnmp_find_handler_by_name (netsnmp_handler_registration *reginfo, const char *name)
Returns a handler from a chain based on the name.

void * netsnmp_find_handler_data_by_name (netsnmp_handler_registration *reginfo, const char *name)
Returns a handler’s void * pointer from a chain based on the name.

netsnmp_mib_handler * clone_handler (netsnmp_mib_handler *it)
clones a mib handler (it’s name and access methods onlys; not myvoid)

void netsnmp_register_handler_by_name (const char *name, netsnmp_mib_handler *handler)
registers a given handler by name so that it can be found easily later.

DETAILED DESCRIPTION

The basic theory goes something like this: In the past, with the original mib module api (which derived from the original CMU SNMP code) the underlying mib modules were passed very little information (only the truly most basic information about a request).

This worked well at the time but in todays world of subagents, device instrumentation, low resource consumption, etc, it just isn’t flexible enough. ’handlers’ are here to fix all that.

With the rewrite of the agent internals for the net-snmp 5.0 release, we introduce a modular calling scheme that allows agent modules to be written in a very flexible manner, and more importantly allows reuse of code in a decent way (and without the memory and speed overheads of OO languages like C++).

Functionally, the notion of what a handler does is the same as the older api: A handler is created and then registered with the main agent at a given OID in the OID tree and gets called any time a request is made that it should respond to. You probably should use one of the convenience helpers instead of doing anything else yourself though:

Most importantly, though, is that the handlers are built on the notion of modularity and reuse. Specifically, rather than do all the really hard work (like parsing table indexes out of an incoming oid request) in each module, the API is designed to make it easy to write ’helper’ handlers that merely process some aspect of the request before passing it along to the final handler that returns the real answer. Most people will want to make use of the instance, table, table_iterator, table_data, or table_dataset helpers to make their life easier. These ’helpers’ interpert important aspects of the request and pass them on to you.

For instance, the table helper is designed to hand you a list of extracted index values from an incoming request. THe table_iterator helper is built on top of the table helper, and is designed to help you iterate through data stored elsewhere (like in a kernel) that is not in OID lexographical order (ie, don’t write your own index/oid sorting routine, use this helper instead). The beauty of the

FUNCTION DOCUMENTATION

netsnmp_mib_handler* clone_handler (netsnmp_mib_handler * it)
clones a mib handler (it’s name and access methods onlys; not myvoid)

Definition at line 643 of file agent_handler.c.

References netsnmp_create_handler().

NETSNMP_INLINE int netsnmp_call_handler (netsnmp_mib_handler * next_handler, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests)
calls a handler with with appropriate NULL checking of arguments, etc.

Definition at line 305 of file agent_handler.c.

Referenced by netsnmp_call_next_handler(), netsnmp_call_next_handler_one_request(), and netsnmp_multiplexer_helper_handler().

NETSNMP_INLINE int netsnmp_call_next_handler (netsnmp_mib_handler * current, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests)
calls the next handler in the chain after the current one with with appropriate NULL checking, etc.

Definition at line 340 of file agent_handler.c.

References netsnmp_call_handler().

Referenced by netsnmp_serialize_helper_handler(), netsnmp_table_data_helper_handler(), netsnmp_table_data_set_helper_handler(), and table_helper_handler().

NETSNMP_INLINE int netsnmp_call_next_handler_one_request (netsnmp_mib_handler * current, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests)
calls the next handler in the chain after the current one with with appropriate NULL checking, etc.

Definition at line 358 of file agent_handler.c.

References netsnmp_call_handler().

NETSNMP_INLINE netsnmp_delegated_cache* netsnmp_create_delegated_cache (netsnmp_mib_handler * handler, netsnmp_handler_registration * reginfo, netsnmp_agent_request_info * reqinfo, netsnmp_request_info * requests, void * localinfo)
creates a cache of information which can be saved for future reference.

Use netsnmp_handler_check_cache() later to make sure it’s still valid before referencing it in the future.

Examples:

delayed_instance.c.

Definition at line 510 of file agent_handler.c.

netsnmp_mib_handler* netsnmp_create_handler (const char * name, Netsnmp_Node_Handler * handler_access_method)
creates a netsnmp_mib_handler structure given a name and a access method.

The returned handler should then be registered.

See also:

netsnmp_create_handler_registration() , netsnmp_register_handler()

Definition at line 80 of file agent_handler.c.

Referenced by clone_handler(), get_old_api_handler(), netsnmp_create_handler_registration(), netsnmp_get_bulk_to_next_handler(), netsnmp_get_debug_handler(), netsnmp_get_mode_end_call_handler(), netsnmp_get_multiplexer_handler(), netsnmp_get_read_only_handler(), netsnmp_get_serialize_handler(), netsnmp_get_table_data_handler(), netsnmp_get_table_data_set_handler(), and netsnmp_get_table_handler().

netsnmp_handler_registration* netsnmp_create_handler_registration (const char * name, Netsnmp_Node_Handler * handler_access_method, oid * reg_oid, size_t reg_oid_len, int modes)
creates a handler registration structure given a name, a access_method function, a registration location oid and the modes the handler supports.

If modes == 0, then modes will automatically be set to the default value of only HANDLER_CAN_DEFAULT, which is by default read-only GET and GETNEXT requests.

Note:

This ends up calling netsnmp_create_handler(name, handler_access_method)

See also:

netsnmp_create_handler() , netsnmp_register_handler()

Examples:

delayed_instance.c.

Definition at line 99 of file agent_handler.c.

References netsnmp_create_handler().

netsnmp_mib_handler* netsnmp_find_handler_by_name (netsnmp_handler_registration * reginfo, const char * name)
Returns a handler from a chain based on the name.

Definition at line 614 of file agent_handler.c.

Referenced by netsnmp_find_handler_data_by_name().

void* netsnmp_find_handler_data_by_name (netsnmp_handler_registration * reginfo, const char * name)
Returns a handler’s void * pointer from a chain based on the name.

This probably shouldn’t be used by the general public as the void * data may change as a handler evolves. Handlers should really advertise some function for you to use instead.

Definition at line 631 of file agent_handler.c.

References netsnmp_find_handler_by_name().

Referenced by netsnmp_find_table_registration_info().

NETSNMP_INLINE void netsnmp_free_delegated_cache (netsnmp_delegated_cache * dcache)
frees a cache once you’re finished using it

Examples:

delayed_instance.c.

Definition at line 548 of file agent_handler.c.

NETSNMP_INLINE void netsnmp_free_request_data_set (netsnmp_request_info * request)
Free the extra data stored in a request.

Definition at line 596 of file agent_handler.c.

NETSNMP_INLINE void netsnmp_free_request_data_sets (netsnmp_request_info * request)
Free the extra data stored in a bunch of requests (all data in the chain).

Definition at line 604 of file agent_handler.c.

NETSNMP_INLINE netsnmp_delegated_cache* netsnmp_handler_check_cache (netsnmp_delegated_cache * dcache)
check’s a given cache and returns it if it is still valid (ie, the agent still considers it to be an outstanding request.

Returns NULL if it’s no longer valid.

Examples:

delayed_instance.c.

Definition at line 534 of file agent_handler.c.

netsnmp_mib_handler* netsnmp_handler_dup (netsnmp_mib_handler * handler)
dulpicates a handler

Definition at line 394 of file agent_handler.c.

Referenced by netsnmp_handler_registration_dup().

void netsnmp_handler_free (netsnmp_mib_handler * handler)
free’s the resourceses associated with a given handler

Definition at line 380 of file agent_handler.c.

Referenced by netsnmp_handler_registration_free().

void netsnmp_handler_mark_requests_as_delegated (netsnmp_request_info * requests, int isdelegated)
marks a list of requests as delegated (or not if isdelegaded = 0)

Definition at line 562 of file agent_handler.c.

netsnmp_handler_registration* netsnmp_handler_registration_dup (netsnmp_handler_registration * reginfo)
duplicates the handler registration object

Definition at line 448 of file agent_handler.c.

References netsnmp_handler_dup(), and netsnmp_handler_registration_free().

void netsnmp_handler_registration_free (netsnmp_handler_registration * reginfo)
free the resources associated with a handler registration object

Definition at line 435 of file agent_handler.c.

References netsnmp_handler_free().

Referenced by netsnmp_handler_registration_dup(), netsnmp_register_mib_table_row(), and netsnmp_register_old_api().

int netsnmp_inject_handler (netsnmp_handler_registration * reginfo, netsnmp_mib_handler * handler)
inject a new handler into the calling chain of the handlers definedy by the netsnmp_handler_registration pointer.

The new handler is injected at the top of the list and hence will be the new handler to be called first.

Definition at line 221 of file agent_handler.c.

Referenced by netsnmp_register_handler(), netsnmp_register_read_only_table_data(), netsnmp_register_serialize(), netsnmp_register_table(), netsnmp_register_table_data(), and netsnmp_register_table_data_set().

int netsnmp_register_handler (netsnmp_handler_registration * reginfo)
register a handler, as defined by the netsnmp_handler_registration pointer.

Definition at line 125 of file agent_handler.c.

References netsnmp_get_bulk_to_next_handler(), and netsnmp_inject_handler().

Referenced by netsnmp_register_old_api(), netsnmp_register_serialize(), and netsnmp_register_table().

void netsnmp_register_handler_by_name (const char * name, netsnmp_mib_handler * handler)
registers a given handler by name so that it can be found easily later.

Definition at line 653 of file agent_handler.c.

Referenced by netsnmp_init_bulk_to_next_helper(), netsnmp_init_debug_helper(), netsnmp_init_read_only_helper(), and netsnmp_init_serialize().

int netsnmp_register_handler_nocallback (netsnmp_handler_registration * reginfo)
register a handler, as defined by the netsnmp_handler_registration pointer.

Definition at line 175 of file agent_handler.c.

Referenced by netsnmp_register_mib_table_row().

NETSNMP_INLINE void netsnmp_request_add_list_data (netsnmp_request_info * request, netsnmp_data_list * node)
add data to a request that can be extracted later by submodules

Examples:

delayed_instance.c.

Definition at line 573 of file agent_handler.c.

Referenced by netsnmp_old_api_helper(), netsnmp_table_data_helper_handler(), netsnmp_table_data_set_helper_handler(), and table_helper_handler().

NETSNMP_INLINE void* netsnmp_request_get_list_data (netsnmp_request_info * request, const char * name)
extract data from a request that was added previously by a parent module

Examples:

delayed_instance.c.

Definition at line 586 of file agent_handler.c.

Referenced by netsnmp_extract_array_context(), netsnmp_extract_table_data_set(), netsnmp_extract_table_info(), netsnmp_extract_table_row(), and netsnmp_old_api_helper().



netsnmp_handler(3)