mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-07 05:30:14 +00:00
SNMP doxygen updates
This commit is contained in:
parent
75c5829a57
commit
1af40e7de2
@ -89,6 +89,19 @@ snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs)
|
||||
snmp_num_mibs = num_mibs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 'device enterprise oid' is used for 'device OID' field in trap PDU's (for identification of generating device)
|
||||
* as well as for value returned by MIB-2 'sysObjectID' field (if internal MIB2 implementation is used).
|
||||
* The 'device enterprise oid' shall point to an OID located under 'private-enterprises' branch (1.3.6.1.4.1.XXX). If a vendor
|
||||
* wants to provide a custom object there, he has to get its own enterprise oid from IANA (http://www.iana.org). It
|
||||
* is not allowed to use LWIP enterprise ID!
|
||||
* In order to identify a specific device it is recommended to create a dedicated OID for each device type under its own
|
||||
* enterprise oid.
|
||||
* e.g.
|
||||
* device a > 1.3.6.1.4.1.XXX(ent-oid).1(devices).1(device a)
|
||||
* device b > 1.3.6.1.4.1.XXX(ent-oid).1(devices).2(device b)
|
||||
* for more details see description of 'sysObjectID' field in RFC1213-MIB
|
||||
*/
|
||||
void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid)
|
||||
{
|
||||
if (device_enterprise_oid == NULL) {
|
||||
@ -98,6 +111,7 @@ void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_
|
||||
}
|
||||
}
|
||||
|
||||
/** Get 'device enterprise oid' */
|
||||
const struct snmp_obj_id* snmp_get_device_enterprise_oid(void)
|
||||
{
|
||||
return snmp_device_enterprise_oid;
|
||||
@ -365,6 +379,12 @@ snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port)
|
||||
|
||||
#endif /* LWIP_IPV4 || LWIP_IPV6 */
|
||||
|
||||
/**
|
||||
* Assign an OID to \struct snmp_obj_id
|
||||
* @param target
|
||||
* @param oid
|
||||
* @param oid_len
|
||||
*/
|
||||
void
|
||||
snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
{
|
||||
@ -377,6 +397,12 @@ snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix an OID to OID in \struct snmp_obj_id
|
||||
* @param target
|
||||
* @param oid
|
||||
* @param oid_len
|
||||
*/
|
||||
void
|
||||
snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
{
|
||||
@ -394,6 +420,14 @@ snmp_oid_prefix(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine two OIDs into \struct snmp_obj_id
|
||||
* @param target
|
||||
* @param oid1
|
||||
* @param oid1_len
|
||||
* @param oid2
|
||||
* @param oid2_len
|
||||
*/
|
||||
void
|
||||
snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
|
||||
{
|
||||
@ -401,6 +435,12 @@ snmp_oid_combine(struct snmp_obj_id* target, const u32_t *oid1, u8_t oid1_len, c
|
||||
snmp_oid_append(target, oid2, oid2_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append OIDs to \struct snmp_obj_id
|
||||
* @param target
|
||||
* @param oid
|
||||
* @param oid_len
|
||||
*/
|
||||
void
|
||||
snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
{
|
||||
@ -412,6 +452,14 @@ snmp_oid_append(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two OIDs
|
||||
* @param oid1
|
||||
* @param oid1_len
|
||||
* @param oid2
|
||||
* @param oid2_len
|
||||
* @return
|
||||
*/
|
||||
s8_t
|
||||
snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
|
||||
{
|
||||
@ -444,12 +492,26 @@ snmp_oid_compare(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check of two OIDs are equal
|
||||
* @param oid1
|
||||
* @param oid1_len
|
||||
* @param oid2
|
||||
* @param oid2_len
|
||||
* @return
|
||||
*/
|
||||
u8_t
|
||||
snmp_oid_equal(const u32_t *oid1, u8_t oid1_len, const u32_t *oid2, u8_t oid2_len)
|
||||
{
|
||||
return (snmp_oid_compare(oid1, oid1_len, oid2, oid2_len) == 0)? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert netif to interface index
|
||||
* @param netif
|
||||
* @return index
|
||||
*/
|
||||
u8_t
|
||||
netif_to_num(const struct netif *netif)
|
||||
{
|
||||
@ -901,6 +963,7 @@ snmp_mib_tree_resolve_next(const struct snmp_mib *mib, const u32_t *oid, u8_t oi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** initialize struct next_oid_state using this function before passing it to next_oid_check */
|
||||
void
|
||||
snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
const u32_t *start_oid, u8_t start_oid_len,
|
||||
@ -914,6 +977,9 @@ snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
state->status = SNMP_NEXT_OID_STATUS_NO_MATCH;
|
||||
}
|
||||
|
||||
/** checks if the passed incomplete OID may be a possible candidate for snmp_next_oid_check();
|
||||
this methid is intended if the complete OID is not yet known but it is very expensive to build it up,
|
||||
so it is possible to test the starting part before building up the complete oid and pass it to snmp_next_oid_check()*/
|
||||
u8_t
|
||||
snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len)
|
||||
{
|
||||
@ -933,6 +999,7 @@ snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, cons
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** checks the passed OID if it is a candidate to be the next one (get_next); returns !=0 if passed oid is currently closest, otherwise 0 */
|
||||
u8_t
|
||||
snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference)
|
||||
{
|
||||
|
@ -101,10 +101,9 @@ snmp_mib2_set_sysdescr(const u8_t *str, const u16_t *len)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes sysContact pointers,
|
||||
* e.g. ptrs to non-volatile memory external to lwIP.
|
||||
* Initializes sysContact pointers
|
||||
*
|
||||
* @param ocstr if non-NULL then copy str pointer
|
||||
* * @param ocstr if non-NULL then copy str pointer
|
||||
* @param ocstrlen points to string length, excluding zero terminator.
|
||||
* if set to NULL it is assumed that ocstr is NULL-terminated.
|
||||
* @param bufsize size of the buffer in bytes.
|
||||
@ -125,6 +124,7 @@ snmp_mib2_set_syscontact(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize)
|
||||
}
|
||||
}
|
||||
|
||||
/** see \ref snmp_mib2_set_syscontact but set pointer to readonly memory */
|
||||
void
|
||||
snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen)
|
||||
{
|
||||
@ -139,8 +139,7 @@ snmp_mib2_set_syscontact_readonly(const u8_t *ocstr, const u16_t *ocstrlen)
|
||||
|
||||
|
||||
/**
|
||||
* Initializes sysName pointers,
|
||||
* e.g. ptrs to non-volatile memory external to lwIP.
|
||||
* Initializes sysName pointers
|
||||
*
|
||||
* @param ocstr if non-NULL then copy str pointer
|
||||
* @param ocstrlen points to string length, excluding zero terminator.
|
||||
@ -163,6 +162,7 @@ snmp_mib2_set_sysname(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize)
|
||||
}
|
||||
}
|
||||
|
||||
/** see \ref snmp_mib2_set_sysname but set pointer to readonly memory */
|
||||
void
|
||||
snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen)
|
||||
{
|
||||
@ -176,8 +176,7 @@ snmp_mib2_set_sysname_readonly(const u8_t *ocstr, const u16_t *ocstrlen)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes sysLocation pointers,
|
||||
* e.g. ptrs to non-volatile memory external to lwIP.
|
||||
* Initializes sysLocation pointers
|
||||
*
|
||||
* @param ocstr if non-NULL then copy str pointer
|
||||
* @param ocstrlen points to string length, excluding zero terminator.
|
||||
@ -200,6 +199,7 @@ snmp_mib2_set_syslocation(u8_t *ocstr, u16_t *ocstrlen, u16_t bufsize)
|
||||
}
|
||||
}
|
||||
|
||||
/** see \ref snmp_mib2_set_syslocation but set pointer to readonly memory */
|
||||
void
|
||||
snmp_mib2_set_syslocation_readonly(const u8_t *ocstr, const u16_t *ocstrlen)
|
||||
{
|
||||
|
@ -54,32 +54,27 @@ extern "C" {
|
||||
void snmp_init(void);
|
||||
void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs);
|
||||
|
||||
/**
|
||||
* 'device enterprise oid' is used for 'device OID' field in trap PDU's (for identification of generating device)
|
||||
* as well as for value returned by MIB-2 'sysObjectID' field (if internal MIB2 implementation is used).
|
||||
* The 'device enterprise oid' shall point to an OID located under 'private-enterprises' branch (1.3.6.1.4.1.XXX). If a vendor
|
||||
* wants to provide a custom object there, he has to get its own enterprise oid from IANA (http://www.iana.org). It
|
||||
* is not allowed to use LWIP enterprise ID!
|
||||
* In order to identify a specific device it is recommended to create a dedicated OID for each device type under its own
|
||||
* enterprise oid.
|
||||
* e.g.
|
||||
* device a > 1.3.6.1.4.1.XXX(ent-oid).1(devices).1(device a)
|
||||
* device b > 1.3.6.1.4.1.XXX(ent-oid).1(devices).2(device b)
|
||||
* for more details see description of 'sysObjectID' field in RFC1213-MIB
|
||||
*/
|
||||
void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_oid);
|
||||
const struct snmp_obj_id* snmp_get_device_enterprise_oid(void);
|
||||
|
||||
void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable);
|
||||
void snmp_trap_dst_ip_set(u8_t dst_idx, const ip_addr_t *dst);
|
||||
|
||||
/** Generic trap: cold start */
|
||||
#define SNMP_GENTRAP_COLDSTART 0
|
||||
/** Generic trap: warm start */
|
||||
#define SNMP_GENTRAP_WARMSTART 1
|
||||
/** Generic trap: link down */
|
||||
#define SNMP_GENTRAP_LINKDOWN 2
|
||||
/** Generic trap: link up */
|
||||
#define SNMP_GENTRAP_LINKUP 3
|
||||
/** Generic trap: authentication failure */
|
||||
#define SNMP_GENTRAP_AUTH_FAILURE 4
|
||||
/** Generic trap: EGP neighbor lost */
|
||||
#define SNMP_GENTRAP_EGP_NEIGHBOR_LOSS 5
|
||||
/** Generic trap: enterprise specific */
|
||||
#define SNMP_GENTRAP_ENTERPRISE_SPECIFIC 6
|
||||
|
||||
err_t snmp_send_trap_generic(s32_t generic_trap);
|
||||
err_t snmp_send_trap_specific(s32_t specific_trap);
|
||||
|
||||
|
@ -96,7 +96,7 @@ extern "C" {
|
||||
#define SNMP_VARBIND_EXCEPTION_OFFSET 0xF0
|
||||
#define SNMP_VARBIND_EXCEPTION_MASK 0x0F
|
||||
|
||||
/* error codes predefined by SNMP prot. */
|
||||
/** error codes predefined by SNMP prot. */
|
||||
typedef enum {
|
||||
SNMP_ERR_NOERROR = 0,
|
||||
/*
|
||||
@ -137,6 +137,7 @@ struct snmp_obj_id_const_ref
|
||||
|
||||
extern const struct snmp_obj_id_const_ref snmp_zero_dot_zero; /* administrative identifier from SNMPv2-SMI */
|
||||
|
||||
/** SNMP variant value, used as reference in struct snmp_node_instance and table implementation */
|
||||
union snmp_variant_value
|
||||
{
|
||||
void* ptr;
|
||||
@ -168,7 +169,7 @@ struct snmp_node
|
||||
u32_t oid;
|
||||
};
|
||||
|
||||
/* SNMP node instance access types */
|
||||
/** SNMP node instance access types */
|
||||
typedef enum {
|
||||
SNMP_NODE_INSTANCE_ACCESS_READ = 1,
|
||||
SNMP_NODE_INSTANCE_ACCESS_WRITE = 2,
|
||||
@ -187,6 +188,7 @@ typedef void (*node_instance_release_method)(struct snmp_node_instance*);
|
||||
|
||||
#define SNMP_GET_VALUE_RAW_DATA 0x8000
|
||||
|
||||
/** SNMP node instance */
|
||||
struct snmp_node_instance
|
||||
{
|
||||
/** prefilled with the node, get_instance() is called on; may be changed by user to any value to pass an arbitrary node between calls to get_instance() and get_value/test_value/set_value */
|
||||
@ -215,9 +217,10 @@ struct snmp_node_instance
|
||||
};
|
||||
|
||||
|
||||
/** SNMP tree node */
|
||||
struct snmp_tree_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
u16_t subnode_count;
|
||||
const struct snmp_node* const *subnodes;
|
||||
@ -231,15 +234,16 @@ struct snmp_tree_node
|
||||
{{ SNMP_NODE_TREE, (oid) }, \
|
||||
0, NULL }
|
||||
|
||||
/** SNMP leaf node */
|
||||
struct snmp_leaf_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
/** inherited "base class" members */
|
||||
struct snmp_node node;
|
||||
snmp_err_t (*get_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t (*get_next_instance)(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
};
|
||||
|
||||
/* represents a single mib with its base oid and root node */
|
||||
/** represents a single mib with its base oid and root node */
|
||||
struct snmp_mib
|
||||
{
|
||||
const u32_t *base_oid;
|
||||
@ -279,15 +283,10 @@ struct snmp_next_oid_state
|
||||
void* reference;
|
||||
};
|
||||
|
||||
/** initialize struct next_oid_state using this function before passing it to next_oid_check */
|
||||
void snmp_next_oid_init(struct snmp_next_oid_state *state,
|
||||
const u32_t *start_oid, u8_t start_oid_len,
|
||||
u32_t *next_oid_buf, u8_t next_oid_max_len);
|
||||
/** checks if the passed incomplete OID may be a possible candidate for snmp_next_oid_check();
|
||||
this methid is intended if the complete OID is not yet known but it is very expensive to build it up,
|
||||
so it is possible to test the starting part before building up the complete oid and pass it to snmp_next_oid_check()*/
|
||||
u8_t snmp_next_oid_precheck(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len);
|
||||
/** checks the passed OID if it is a candidate to be the next one (get_next); returns !=0 if passed oid is currently closest, otherwise 0 */
|
||||
u8_t snmp_next_oid_check(struct snmp_next_oid_state *state, const u32_t *oid, const u8_t oid_len, void* reference);
|
||||
|
||||
void snmp_oid_assign(struct snmp_obj_id* target, const u32_t *oid, u8_t oid_len);
|
||||
|
@ -47,11 +47,10 @@ extern "C" {
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/* basic scalar node */
|
||||
|
||||
/** basic scalar node */
|
||||
struct snmp_scalar_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u8_t asn1_type;
|
||||
snmp_access_t access;
|
||||
@ -72,7 +71,7 @@ snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_le
|
||||
|
||||
#define SNMP_SCALAR_CREATE_NODE_READONLY(oid, asn1_type, get_value_method) SNMP_SCALAR_CREATE_NODE(oid, SNMP_NODE_INSTANCE_READ_ONLY, asn1_type, get_value_method, NULL, NULL)
|
||||
|
||||
/* scalar array node - a tree node which contains scalars only as children */
|
||||
/** scalar array node - a tree node which contains scalars only as children */
|
||||
struct snmp_scalar_array_node_def
|
||||
{
|
||||
u32_t oid;
|
||||
@ -84,9 +83,10 @@ typedef u16_t (*snmp_scalar_array_get_value_method)(const struct snmp_scalar_arr
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_test_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
typedef snmp_err_t (*snmp_scalar_array_set_value_method)(const struct snmp_scalar_array_node_def*, u16_t, void*);
|
||||
|
||||
/** basic scalar array node */
|
||||
struct snmp_scalar_array_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t array_node_count;
|
||||
const struct snmp_scalar_array_node_def* array_nodes;
|
||||
|
@ -47,8 +47,7 @@ extern "C" {
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
/* default (customizable) read/write table */
|
||||
|
||||
/** default (customizable) read/write table */
|
||||
struct snmp_table_col_def
|
||||
{
|
||||
u32_t index;
|
||||
@ -56,9 +55,10 @@ struct snmp_table_col_def
|
||||
snmp_access_t access;
|
||||
};
|
||||
|
||||
/** table node */
|
||||
struct snmp_table_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
/** inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
u16_t column_count;
|
||||
const struct snmp_table_col_def* columns;
|
||||
@ -86,8 +86,7 @@ snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len
|
||||
#define SNMP_TABLE_GET_COLUMN_FROM_OID(oid) ((oid)[1]) /* first array value is (fixed) row entry (fixed to 1) and 2nd value is column, follow3ed by instance */
|
||||
|
||||
|
||||
/* simple read-only table */
|
||||
|
||||
/** simple read-only table */
|
||||
typedef enum {
|
||||
SNMP_VARIANT_VALUE_TYPE_U32,
|
||||
SNMP_VARIANT_VALUE_TYPE_S32,
|
||||
@ -102,6 +101,7 @@ struct snmp_table_simple_col_def
|
||||
snmp_table_column_data_type_t data_type; /* depending of what union member is used to store the value*/
|
||||
};
|
||||
|
||||
/** simple read-only table node */
|
||||
struct snmp_table_simple_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
|
@ -94,6 +94,7 @@ struct snmp_threadsync_node
|
||||
snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
|
||||
/** Create thread sync proxy node */
|
||||
#define SNMP_CREATE_THREAD_SYNC_NODE(oid, target_leaf_node, threadsync_instance) \
|
||||
{{{ SNMP_NODE_THREADSYNC, (oid) }, \
|
||||
snmp_threadsync_get_instance, \
|
||||
@ -101,6 +102,7 @@ snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oi
|
||||
(target_leaf_node), \
|
||||
(threadsync_instance) }
|
||||
|
||||
/** Create thread sync instance data */
|
||||
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
Loading…
Reference in New Issue
Block a user