libnsh
0.3
Net-SNMP helper C-library
|
#include "table.h"
#include "private.h"
#include "deprecated.h"
Go to the source code of this file.
Macros | |
#define | nsh_register_scalar_ro(name) _nsh_register_scalar(name, HANDLER_CAN_RONLY) |
#define | nsh_register_scalar_rw(name) _nsh_register_scalar(name, HANDLER_CAN_RWRITE) |
#define | nsh_scalar_handler_const(name, type, value) _nsh_scalar_handler(name, type, 0, NULL, sizeof(long), value, NULL) |
#define | nsh_scalar_handler_ro(name, type, callback, size) _nsh_scalar_handler(name, type, 0, callback, size, 0, NULL) |
#define | nsh_scalar_str_handler_ro(name, callback, max_length) _nsh_scalar_handler(name, ASN_OCTET_STR, 0, callback, max_length, 1, NULL) |
#define | nsh_scalar_group_handler_ro(name, type, id, callback, size, isstring) _nsh_scalar_handler(name, type, id, callback, size, isstring, NULL) |
#define | nsh_scalar_handler_rw(name, type, nsh_get_cb, size, nsh_set_cb) _nsh_scalar_handler(name, type, 0, nsh_get_cb, size, 0, nsh_set_cb) |
#define | nsh_scalar_str_handler_rw(name, nsh_get_cb, max_length, nsh_set_cb) _nsh_scalar_handler(name, ASN_OCTET_STR, 0, nsh_get_cb, max_length, 1, nsh_set_cb) |
#define | nsh_scalar_group_handler_rw(name, type, id, nsh_get_cb, size, isstring, nsh_set_cb) _nsh_scalar_handler(name, type, id, nsh_get_cb, size, isstring, nsh_set_cb) |
#define | nsh_table(name, get_first_cb, get_next_cb, free_cb, table_data, head, num_table, index_list, num_indexes) |
Typedefs | |
typedef int(* | nsh_get_cb) (void *value, int len, int id) |
typedef int(* | nsh_set_cb) (void *value, int id) |
#define nsh_register_scalar_ro | ( | name | ) | _nsh_register_scalar(name, HANDLER_CAN_RONLY) |
Register a read-only scalar OID.
name | OID define, without the oid_ prefix. |
This function will register a read-only scalar handler callback for the defined OID. The name of the callback function is based on the input parameter name, which means that name shall also be the input to the scalar create function which will handle the OID.
#define nsh_register_scalar_rw | ( | name | ) | _nsh_register_scalar(name, HANDLER_CAN_RWRITE) |
Register a writable scalar OID.
name | OID define without the oid_ prefix. |
This function will register a read-write scalar handler callback for the defined OID. The name of the callback function is based on the input parameter name, which means that name shall also be the input to the scalar create function which will handle the OID.
#define nsh_scalar_group_handler_ro | ( | name, | |
type, | |||
id, | |||
callback, | |||
size, | |||
isstring | |||
) | _nsh_scalar_handler(name, type, id, callback, size, isstring, NULL) |
Create a grouped read-only scalar OID handler.
name | OID define, without the oid_ prefix. |
type | OID type. ASN_COUNTER, ASN_INTEGER, ASN_TIMETICKS, ASN_UNSIGNED, ASN_IPADDRESS, ASN_OCTET_STR or ASN_OBJECT_ID. |
id | Group identifier for this request. |
callback | Callback function to get return value by a request. |
size | Data length of handled value. |
isstring | Set if value is a string. |
This function will create a grouped read-only scalar handler callback function. This function will behave in the same maner as nsh_scalar_handler_ro() except that a id is used to distinguish different OID requests. A common callback can therefore be shared between several created handlers. If the isstring parameter is set, the function behaves as nsh_scalar_str_handler_ro(), i.e. with repect to the string length. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_ro().
#define nsh_scalar_group_handler_rw | ( | name, | |
type, | |||
id, | |||
nsh_get_cb, | |||
size, | |||
isstring, | |||
nsh_set_cb | |||
) | _nsh_scalar_handler(name, type, id, nsh_get_cb, size, isstring, nsh_set_cb) |
Create a grouped read-write scalar OID handler.
name | OID define, without the oid_ prefix. |
type | OID type. ASN_COUNTER, ASN_INTEGER, ASN_TIMETICKS, ASN_UNSIGNED, ASN_IPADDRESS, ASN_OCTET_STR or ASN_OBJECT_ID. |
id | Group identifier for this request. |
nsh_get_cb | Callback function to get return value by a request. |
size | Data length of handled value. |
isstring | Set if value is a string. |
nsh_set_cb | Callback function to set value by a request. |
This function will create a grouped read-write scalar handler callback function. This function will behave in the same maner as nsh_scalar_handler_rw() except that a id is used to distinguish different OID requests. A common read callback, nsh_get_cb, and a common write callback, nsh_set_cb, can therefore be shared between several created handlers. If the isstring parameter is set, the function behaves as nsh_scalar_str_handler_rw(), i.e. with repect to the string length. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_rw().
#define nsh_scalar_handler_const | ( | name, | |
type, | |||
value | |||
) | _nsh_scalar_handler(name, type, 0, NULL, sizeof(long), value, NULL) |
Create a constant scalar OID handler.
name | OID define, without the oid_ prefix. |
type | OID type. ASN_COUNTER, ASN_INTEGER, ASN_TIMETICKS, ASN_UNSIGNED or ASN_IPADDRESS. |
value | Value to be returned by a request. |
This function will create a scalar handler callback function which will return a constant value. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_ro().
#define nsh_scalar_handler_ro | ( | name, | |
type, | |||
callback, | |||
size | |||
) | _nsh_scalar_handler(name, type, 0, callback, size, 0, NULL) |
Create a read-only scalar OID handler.
name | OID define, without the oid_ prefix. |
type | OID type. ASN_COUNTER, ASN_INTEGER, ASN_TIMETICKS, ASN_UNSIGNED, ASN_IPADDRESS, ASN_OCTET_STR or ASN_OBJECT_ID. |
callback | Callback function to get return value by a request. |
size | Data length of handled value. |
This function will create a read-only scalar handler callback function which will return the value from the callback function. If a string value is to be returned, consider using nsh_scalar_str_handler_ro() instead, else the string returned will always be size long. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_ro().
#define nsh_scalar_handler_rw | ( | name, | |
type, | |||
nsh_get_cb, | |||
size, | |||
nsh_set_cb | |||
) | _nsh_scalar_handler(name, type, 0, nsh_get_cb, size, 0, nsh_set_cb) |
Create a read-write scalar OID handler.
name | OID define, without the oid_ prefix. |
type | OID type. ASN_COUNTER, ASN_INTEGER, ASN_TIMETICKS, ASN_UNSIGNED, ASN_IPADDRESS, ASN_OCTET_STR or ASN_OBJECT_ID. |
nsh_get_cb | Callback function to get return value by a request. |
size | Data length of handled value. |
nsh_set_cb | Callback function to set value by a request. |
This function will create a read-write scalar handler callback function. A read request to the OID object will return the value from the nsh_get_cb callback function. A write request will pass the value to the nsh_set_cb callback function. If a string value is to be handled, consider using nsh_scalar_str_handler_rw() instead, else the string returned will always be size long. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_rw().
#define nsh_scalar_str_handler_ro | ( | name, | |
callback, | |||
max_length | |||
) | _nsh_scalar_handler(name, ASN_OCTET_STR, 0, callback, max_length, 1, NULL) |
Create a read-only string OID handler.
name | OID define, without the oid_ prefix. |
callback | Callback function to get string value by a request. |
max_length | Maximum length of returned string. |
This function will create a read-only string handler callback function which will return the string from the callback function. The function is similar to nsh_scalar_handler_ro() except it will return a string with the correct length, i.e. the actual string length instead of the maximum length of the string. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_ro().
#define nsh_scalar_str_handler_rw | ( | name, | |
nsh_get_cb, | |||
max_length, | |||
nsh_set_cb | |||
) | _nsh_scalar_handler(name, ASN_OCTET_STR, 0, nsh_get_cb, max_length, 1, nsh_set_cb) |
Create a read-write string OID handler.
name | OID define, without the oid_ prefix. |
nsh_get_cb | Callback function to get string value by a request. |
max_length | Maximum length of returned string. |
nsh_set_cb | Callback function to set value by a request. |
This function will create a read-write string handler callback function. The function is similar to nsh_scalar_handler_rw() except it will return a string with the correct length, i.e. the actual string length instead of the maximum length of the string. The callback function name will be based on the input parameter name, which should be the same parameter used when registering the OID, i.e with nsh_register_scalar_rw().
#define nsh_table | ( | name, | |
get_first_cb, | |||
get_next_cb, | |||
free_cb, | |||
table_data, | |||
head, | |||
num_table, | |||
index_list, | |||
num_indexes | |||
) |
Create table handlers.
name | Name of table registration object. |
get_first_cb | Name of table get first handler. |
get_next_cb | Name of table get next handler. |
free_cb | Name of table free handler. |
table_data | Table data struct. |
head | Head of table data. |
num_table | Number of entries in table data struct. |
index_list | Table index struct. |
num_indexes | Number of indexes in table index struct. |
This function will create table handlers to get first table element, get next table element and to empty all table elements.
typedef int(* nsh_get_cb) (void *value, int len, int id) |
Callback to get (read) value for a get request.
value | Pointer to variable which should be set to the value that is to be returned by a get request. |
len | Data size (or maximum data size) of value. |
id | ID for the requested OID. |
This callback shall set value to the value which should be returned by a get request. len specifies the data size (or maximum data size) for the requested object. id is used to distinguish the requested OID from others OIDs if the callback is shared between several OID handlers. If the callback is only used for one OID, id can be ignored.
typedef int(* nsh_set_cb) (void *value, int id) |
Callback to set (write) value for a set request.
value | Pointer to variable which holds the value from a set request. |
id | ID for the requested OID. |
This callback shall use value to update the value which should be set by a set request. id is used to distinguish the requested OID from others OIDs if the callback is shared between several OID handlers. If the callback is only used for one OID, id can be ignored.