yumapro
24.10-1
YumaPro SDK
|
Utility functions for net-snmp agent for SNMP support. More...
Functions | |
val_value_t * | agt_ypsnmp_bestmatch_next_index (yangapi_cb_t *rcb) |
Find the next best matching list entry in the Queue. More... | |
val_value_t * | agt_ypsnmp_get_first_getnextlist (yangapi_cb_t *rcb) |
Get the first list val_value structure in getnext_listQ. More... | |
val_value_t * | agt_ypsnmp_get_next_getnextlist (val_value_t *list) |
Get the next list val_value structure in getnext_listQ. More... | |
boolean | agt_ypsnmp_match_obj (obj_template_t *targetobj, obj_template_t *curobj) |
Checks if the current object in the walker is the target object for the request. More... | |
boolean | agt_ypsnmp_match_index (yangapi_cb_t *rcb, val_value_t *keyval) |
Checks if the current index in the walker is the target index for the request. More... | |
obj_template_t * | agt_ypsnmp_get_table_obj (obj_template_t *obj) |
Find the Table object of the current object. More... | |
obj_template_t * | agt_ypsnmp_get_parent_obj (obj_template_t *obj) |
Find the complex parent of the current leaf object. More... | |
boolean | agt_ypsnmp_is_scalar_obj (obj_template_t *curobj) |
Check if the object is a scalar object. More... | |
boolean | agt_ypsnmp_is_augmented_obj (obj_template_t *curobj) |
Check if the object is an augmented object. More... | |
xmlChar * | agt_ypsnmp_convert_physaddr (val_value_t *val) |
Converts the value of ifPhysAddress leaf element from yang syntax to SMI syntax expected by snmp client. More... | |
netsnmp_variable_list * | agt_ypsnmp_create_snmp_varbind_object (const oid *name, size_t name_length, u_char type, const void *value, size_t len) |
Allocates and creates a new netsnmp variable binding object. More... | |
void | agt_ypsnmp_append_varbind_to_list (netsnmp_variable_list **list, netsnmp_variable_list *var) |
Adds the given netsnmp variable binding object to the end of the list of given pdu. More... | |
obj_oid_t * | agt_ypsnmp_convert_varbind_to_oid (netsnmp_variable_list *var_ptr) |
Converts an SNMP OID string into an internal object. More... | |
status_t | agt_ypsnmp_set_varbind (ses_cb_t *scb, netsnmp_pdu *pdu, val_value_t *val, const obj_oid_t *oid_obj) |
Set the return Varbind based on the found value. More... | |
status_t | agt_ypsnmp_setup_peeraddr (ses_cb_t *scb, netsnmp_pdu *pdu) |
Setup the scb->peeraddr for debugging and auditing. More... | |
yangapi_method_t | agt_ypsnmp_get_yangapi_method (uint8 msg_code) |
Get the YANGAPI method from the SNMP method. More... | |
xmlChar * | agt_ypsnmp_make_restconf_uri (obj_template_t *obj) |
Make a RESTCONF URI string from the specified OID string. More... | |
void | agt_ypsnmp_log_pdu (netsnmp_pdu *pdu) |
logs the received SNMP PDU packet contents More... | |
const void * | agt_ypsnmp_get_varbind_value (netsnmp_variable_list *var) |
Get the Varbind value. More... | |
const xmlChar * | agt_ypsnmp_get_getnext_modename (ypsnmp_getnext_mode_t getnextmode) |
Get the getnext mode name from its enum. More... | |
obj_oid_t * | agt_ypsnmp_get_index_oid (obj_oid_t *full_oid, uint32 index_length) |
parse requested OID and strip out index OID More... | |
status_t | agt_ypsnmp_convert_oid2chars (xmlChar *str, uint32 len, const oid_t *useoid) |
Converts an OID to its character form. More... | |
status_t | agt_ypsnmp_convert_str_oid2str (xmlChar *str, uint32 len, oid_t *useoid) |
Converts a string OID to its string form. More... | |
status_t | agt_ypsnmp_convert_str2oid (const xmlChar *str, oid_t *useoid, uint32 len) |
Converts a string to its OID form. More... | |
status_t | agt_ypsnmp_indexoid_to_value (yangapi_cb_t *rcb, obj_template_t *obj, uint32 index_length) |
Parse requested OID and strip out index OID. More... | |
status_t | agt_ypsnmp_value_to_indexoid (yangapi_cb_t *rcb, val_value_t *list) |
Converts val_value list with keys into index OID. More... | |
ypsnmp_agent_session_t * | agt_ypsnmp_init_agent_session (netsnmp_session *session, netsnmp_pdu *pdu) |
Allocate new ypsnmp session context. More... | |
void | agt_ypsnmp_free_agent_session (ypsnmp_agent_session_t *asp) |
free the ypsnmp session and deallocate any associated memory More... | |
void | free_varbind (netsnmp_variable_list *var) |
Frees the variable and any malloc'd data associated with it. More... | |
void | free_varbind_yp (netsnmp_variable_list *var) |
Frees the variable and any malloc'd data associated with it. More... | |
Utility functions for net-snmp agent for SNMP support.
Requires WITH_SNMP=1 in build and –with-snmp=true CLI parameter at runtime.
void agt_ypsnmp_append_varbind_to_list | ( | netsnmp_variable_list ** | list, |
netsnmp_variable_list * | var | ||
) |
Adds the given netsnmp variable binding object to the end of the list of given pdu.
Only present if WITH_SNMP=1.
list | address of varbind list to add to |
var | variable binding object |
val_value_t * agt_ypsnmp_bestmatch_next_index | ( | yangapi_cb_t * | rcb | ) |
Find the next best matching list entry in the Queue.
Only present if WITH_SNMP=1.
rcb | restapi request control block to use |
Converts an OID to its character form.
in example 5 . 1 . 2 . 3 . 4 . 5 = 12345
Only present if WITH_SNMP=1.
[out] | str | buffer to fill in |
len | length of the buffer. | |
useoid | the oid. |
xmlChar * agt_ypsnmp_convert_physaddr | ( | val_value_t * | val | ) |
Converts the value of ifPhysAddress leaf element from yang syntax to SMI syntax expected by snmp client.
Only present if WITH_SNMP=1.
val | val node |
Converts a string to its OID form.
in example "hello" = 5 . 'h' . 'e' . 'l' . 'l' . 'o'
Only present if WITH_SNMP=1.
[out] | str | buffer to fill in |
useoid | the oid. | |
len | the length of the oid. |
Converts a string OID to its string form.
in example 5 . 'h' . 'e' . 'l' . 'l' . 'o' = "hello\0" (null terminated)
Only present if WITH_SNMP=1.
[out] | str | buffer to fill in |
len | the length of the buffer. | |
useoid | the oid. |
obj_oid_t * agt_ypsnmp_convert_varbind_to_oid | ( | netsnmp_variable_list * | var_ptr | ) |
Converts an SNMP OID string into an internal object.
Only present if WITH_SNMP=1.
var_ptr | pointer to the varbind |
netsnmp_variable_list * agt_ypsnmp_create_snmp_varbind_object | ( | const oid * | name, |
size_t | name_length, | ||
u_char | type, | ||
const void * | value, | ||
size_t | len | ||
) |
Allocates and creates a new netsnmp variable binding object.
Add a variable with the requested name to the end of the list of variables for this pdu.
Only present if WITH_SNMP=1.
name | oid value |
name_length | length of above oid |
type | ASN type |
value | value to be set |
len | length of the value |
void agt_ypsnmp_free_agent_session | ( | ypsnmp_agent_session_t * | asp | ) |
free the ypsnmp session and deallocate any associated memory
Only present if WITH_SNMP=1.
asp | handle to ypsnmp session to free |
val_value_t * agt_ypsnmp_get_first_getnextlist | ( | yangapi_cb_t * | rcb | ) |
Get the first list val_value structure in getnext_listQ.
Only present if WITH_SNMP=1.
rcb | restapi request control block to use |
const xmlChar * agt_ypsnmp_get_getnext_modename | ( | ypsnmp_getnext_mode_t | getnextmode | ) |
Get the getnext mode name from its enum.
Only present if WITH_SNMP=1.
getnextmode | getnext mode name enumeration |
parse requested OID and strip out index OID
Only present if WITH_SNMP=1.
full_oid | complete requested OID |
index_length | length of the index, how mane .x.y.z... |
val_value_t * agt_ypsnmp_get_next_getnextlist | ( | val_value_t * | list | ) |
Get the next list val_value structure in getnext_listQ.
Only present if WITH_SNMP=1.
list | current list entry |
obj_template_t * agt_ypsnmp_get_parent_obj | ( | obj_template_t * | obj | ) |
Find the complex parent of the current leaf object.
Skips:
Only present if WITH_SNMP=1.
obj | leaf obj_template to use |
obj_template_t * agt_ypsnmp_get_table_obj | ( | obj_template_t * | obj | ) |
Find the Table object of the current object.
Skips:
Only present if WITH_SNMP=1.
obj | current obj_template to use |
const void * agt_ypsnmp_get_varbind_value | ( | netsnmp_variable_list * | var | ) |
Get the Varbind value.
Only present if WITH_SNMP=1.
var | varbind variable |
yangapi_method_t agt_ypsnmp_get_yangapi_method | ( | uint8 | msg_code | ) |
Get the YANGAPI method from the SNMP method.
Only present if WITH_SNMP=1.
msg_code | uint8 SNMP pdu command code |
status_t agt_ypsnmp_indexoid_to_value | ( | yangapi_cb_t * | rcb, |
obj_template_t * | obj, | ||
uint32 | index_length | ||
) |
Parse requested OID and strip out index OID.
For tabular objects ONLY. Converts index OID into val_value, saves all key values into Q of val_values
Only present if WITH_SNMP=1.
RFC 1902 7.7. Mapping of the INDEX clause The INDEX clause, which must be present if that object corresponds to a conceptual row (unless an AUGMENTS clause is present instead), and must be absent otherwise, defines instance identification information for the columnar objects subordinate to that object. The instance identification information in an INDEX clause must specify object(s) such that value(s) of those object(s) will unambiguously distinguish a conceptual row. The syntax of those objects indicate how to form the instance-identifier: *(1) integer-valued: a single sub-identifier taking the integer value (this works only for non-negative integers); *(2) string-valued, fixed-length strings (or variable-length preceded by the IMPLIED keyword): `n' sub-identifiers, where `n' is the length of the string (each octet of the string is encoded in a separate sub-identifier); *(3) string-valued, variable-length strings (not preceded by the IMPLIED keyword): `n+1' sub-identifiers, where `n' is the length of the string (the first sub-identifier is `n' itself, following this, each octet of the string is encoded in a separate sub-identifier); *(4) object identifier-valued (when preceded by the IMPLIED keyword): `n' sub-identifiers, where `n' is the number of sub-identifiers in the value (each sub-identifier of the value is copied into a separate sub-identifier); *(5) object identifier-valued (when not preceded by the IMPLIED keyword): `n+1' sub-identifiers, where `n' is the number of sub- identifiers in the value (the first sub-identifier is `n' itself, following this, each sub-identifier in the value is copied); *(6) IpAddress-valued: 4 sub-identifiers, in the familiar a.b.c.d notation.
[in,out] | rcb | rest control block
|
obj | object to use | |
index_length | length of the index |
ypsnmp_agent_session_t * agt_ypsnmp_init_agent_session | ( | netsnmp_session * | session, |
netsnmp_pdu * | pdu | ||
) |
Allocate new ypsnmp session context.
Only present if WITH_SNMP=1.
session | net-snmp session to use |
pdu | PDU for context |
boolean agt_ypsnmp_is_augmented_obj | ( | obj_template_t * | curobj | ) |
Check if the object is an augmented object.
That's, if the object is inside augment statement
Only present if WITH_SNMP=1.
curobj | leaf obj_template to use |
boolean agt_ypsnmp_is_scalar_obj | ( | obj_template_t * | curobj | ) |
Check if the object is a scalar object.
Only present if WITH_SNMP=1.
curobj | leaf obj_template to use |
void agt_ypsnmp_log_pdu | ( | netsnmp_pdu * | pdu | ) |
logs the received SNMP PDU packet contents
Only present if WITH_SNMP=1.
pdu | received SNMP protocol data unit (PDU) |
xmlChar * agt_ypsnmp_make_restconf_uri | ( | obj_template_t * | obj | ) |
Make a RESTCONF URI string from the specified OID string.
Only present if WITH_SNMP=1.
obj | object to make the URI string for |
boolean agt_ypsnmp_match_index | ( | yangapi_cb_t * | rcb, |
val_value_t * | keyval | ||
) |
Checks if the current index in the walker is the target index for the request.
Only present if WITH_SNMP=1.
rcb | restapi control block to use |
keyval | key value to match |
boolean agt_ypsnmp_match_obj | ( | obj_template_t * | targetobj, |
obj_template_t * | curobj | ||
) |
Checks if the current object in the walker is the target object for the request.
Only present if WITH_SNMP=1.
targetobj | first obj_template to use |
curobj | another obj_template to use for compar |
status_t agt_ypsnmp_set_varbind | ( | ses_cb_t * | scb, |
netsnmp_pdu * | pdu, | ||
val_value_t * | val, | ||
const obj_oid_t * | oid_obj | ||
) |
Set the return Varbind based on the found value.
The mapping between YANG and SMIv2 data types is defined in RFC6643
rcb->variables is updated with the final return Varbinds. Or pdu->variables is updated in case of Traps responce Only present if WITH_SNMP=1.
scb | session control block |
pdu | SNMP PDU->varbinds to use instead of SCB->varbinds |
val | found value to use |
oid_obj | corresponding OID value for the val |
Setup the scb->peeraddr for debugging and auditing.
Only present if WITH_SNMP=1.
scb | session control block to use |
pdu | SNMP PDU to use |
status_t agt_ypsnmp_value_to_indexoid | ( | yangapi_cb_t * | rcb, |
val_value_t * | list | ||
) |
Converts val_value list with keys into index OID.
Only present if WITH_SNMP=1.
[in,out] | rcb | yangapi control block to use.
|
list | list val_value node with only keys in it |
void free_varbind | ( | netsnmp_variable_list * | var | ) |
Frees the variable and any malloc'd data associated with it.
Only present if WITH_SNMP=1.
var | variable binding object |
void free_varbind_yp | ( | netsnmp_variable_list * | var | ) |
Frees the variable and any malloc'd data associated with it.
Using m__free API
Only present if WITH_SNMP=1.
var | variable binding object |