yumapro  20.10-12
YumaPro SDK
agt_util.h File Reference

Utility Functions for NCX Server method routines. More...

#include "agt.h"
#include "agt_cfg.h"
#include "cfg.h"
#include "dlq.h"
#include "getcb.h"
#include "ncxconst.h"
#include "ncxtypes.h"
#include "obj.h"
#include "rpc.h"
#include "ses.h"
#include "status.h"
#include "val.h"
#include "xml_msg.h"
#include "xml_util.h"
#include "xpath.h"
#include "yang_patch.h"
Include dependency graph for agt_util.h:

Go to the source code of this file.

Functions

status_t agt_get_cfg_from_parm (const xmlChar *parmname, rpc_msg_t *msg, xml_node_t *methnode, cfg_template_t **retcfg)
 FUNCTION agt_get_cfg_from_parm. More...
 
status_t agt_get_inline_cfg_from_parm (const xmlChar *parmname, rpc_msg_t *msg, xml_node_t *methnode, val_value_t **retval)
 Get the val_value_t node for the inline config element. More...
 
status_t agt_get_url_from_parm (const xmlChar *parmname, rpc_msg_t *msg, xml_node_t *methnode, const xmlChar **returl, val_value_t **retval)
 Get the URL string for the config in the target param. More...
 
xmlChar * agt_get_filespec_from_url (const xmlChar *urlstr, status_t *res)
 Check the URL and get the filespec part out of it. More...
 
const val_value_t * agt_get_parmval (const xmlChar *parmname, rpc_msg_t *msg)
 Get the identified val_value_t for a given parameter. More...
 
void agt_record_error (ses_cb_t *scb, xml_msg_hdr_t *msghdr, ncx_layer_t layer, status_t res, const xml_node_t *xmlnode, ncx_node_t parmtyp, const void *error_info, ncx_node_t nodetyp, void *error_path)
 Generate an rpc_err_rec_t and save it in the msg. More...
 
void agt_record_error_obj (ses_cb_t *scb, xml_msg_hdr_t *msghdr, status_t res, obj_template_t *errobj, const xmlChar *badval)
 Generate an rpc_err_rec_t and save it in the msg Use the provided object for <rpc-error> fields. More...
 
void agt_record_error_errinfo (ses_cb_t *scb, xml_msg_hdr_t *msghdr, ncx_layer_t layer, status_t res, const xml_node_t *xmlnode, ncx_node_t parmtyp, const void *error_info, ncx_node_t nodetyp, void *error_path, const ncx_errinfo_t *errinfo)
 Generate an rpc_err_rec_t and save it in the msg Use provided error fields. More...
 
void agt_record_warning (ses_cb_t *scb, xml_msg_hdr_t *msghdr, ncx_layer_t layer, status_t res, const xml_node_t *xmlnode, ncx_node_t parmtyp, const void *error_parm, ncx_node_t nodetyp, void *error_path, const ncx_errinfo_t *errinfo)
 Generate an rpc_err_rec_t and save it in the msg. More...
 
void agt_record_attr_error (ses_cb_t *scb, xml_msg_hdr_t *msghdr, ncx_layer_t layer, status_t res, const xml_attr_t *xmlattr, const xml_node_t *xmlnode, const xmlChar *badns, ncx_node_t nodetyp, void *errnode)
 Generate an rpc_err_rec_t and save it in the msg. More...
 
void agt_record_insert_error (ses_cb_t *scb, xml_msg_hdr_t *msghdr, status_t res, val_value_t *errval)
 Generate an rpc_err_rec_t and save it in the msg Called from the YANG edit validation code when an invalid insert operation is detected. More...
 
void agt_record_unique_error (ses_cb_t *scb, xml_msg_hdr_t *msghdr, val_value_t *errval, dlq_hdr_t *valuniqueQ)
 Generate an rpc_err_rec_t and save it in the msg. More...
 
status_t agt_validate_filter (ses_cb_t *scb, rpc_msg_t *msg)
 Validate the <filter> parameter if present. More...
 
status_t agt_validate_filter_ex (ses_cb_t *scb, rpc_msg_t *msg, val_value_t *filter)
 Validate the <filter> parameter if present (extended) More...
 
status_t agt_validate_filter_nmda (rpc_msg_t *msg, val_value_t *filter, boolean is_subtree)
 Validate the <filter> parameter; FOR NMDA ONLY. More...
 
boolean agt_check_config (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get-config> operation to return any type of configuration data. More...
 
boolean agt_check_default (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get*> operation to return only values not set to the default. More...
 
boolean agt_check_config_false (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get*> operation to return only config=false nodes and the ID ancestor nodes. More...
 
boolean agt_check_config_false_default (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get> operation to return only content=nonconfig nodes and the ID ancestor node and only values not set to the default except if it is a container with counters. More...
 
boolean agt_check_save (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by agt_ncx_cfg_save function to filter just what is supposed to be saved in the <startup> config file. More...
 
boolean agt_check_modtags (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get> and <get-config> operation to return report-all module-tags filtered data. More...
 
boolean agt_check_basic (xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
 Used by the <get-data> operation to return basic filtering NMDA, module-tags, tstamps filtered data. More...
 
status_t agt_output_filter (ses_cb_t *scb, rpc_msg_t *msg, int32 indent)
 output the proper data for the get or get-config operation generate the data that matched the subtree or XPath filter More...
 
status_t agt_output_schema (ses_cb_t *scb, rpc_msg_t *msg, int32 indent)
 generate the YANG file contents for the get-schema operation More...
 
status_t agt_output_empty (ses_cb_t *scb, rpc_msg_t *msg, int32 indent)
 output no data for the get or get-config operation because the if-modified-since fileter did not pass More...
 
status_t agt_check_max_access (val_value_t *newval, boolean cur_exists)
 Check if the max-access for a parameter is exceeded. More...
 
status_t agt_check_editop (op_editop_t pop, op_editop_t *cop, val_value_t *newnode, val_value_t *curnode, ncx_iqual_t iqual, ncx_protocol_t proto, boolean is_commit, boolean *delete_default)
 Check if the edit operation is okay. More...
 
status_t agt_enable_feature (const xmlChar *modname, const xmlChar *featurename)
 Enable a YANG feature in the server. More...
 
status_t agt_disable_feature (const xmlChar *modname, const xmlChar *featurename)
 Disable a YANG feature in the server. More...
 
val_value_t * agt_make_leaf (obj_template_t *parentobj, const xmlChar *leafname, const xmlChar *leafstrval, status_t *res)
 make a string val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_uint_leaf (obj_template_t *parentobj, const xmlChar *leafname, uint32 leafval, status_t *res)
 make a uint32 val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_int_leaf (obj_template_t *parentobj, const xmlChar *leafname, int32 leafval, status_t *res)
 make an int32 val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_uint64_leaf (obj_template_t *parentobj, const xmlChar *leafname, uint64 leafval, status_t *res)
 make a uint64 val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_int64_leaf (obj_template_t *parentobj, const xmlChar *leafname, int64 leafval, status_t *res)
 make an int64 val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_idref_leaf (obj_template_t *parentobj, const xmlChar *leafname, const val_idref_t *leafval, status_t *res)
 make an identityref val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_list (obj_template_t *parentobj, const xmlChar *listname, status_t *res)
 make a val_value_t struct for a specified list More...
 
val_value_t * agt_make_object (obj_template_t *parentobj, const xmlChar *objname, status_t *res)
 make a val_value_t struct for a specified node More...
 
val_value_t * agt_make_virtual_leaf (obj_template_t *parentobj, const xmlChar *leafname, getcb_fn_t callbackfn, status_t *res)
 make a val_value_t struct for a specified virtual leaf or leaf-list More...
 
status_t agt_add_top_virtual (obj_template_t *obj, getcb_fn_t callbackfn)
 make a val_value_t struct for a specified virtual top-level data node More...
 
status_t agt_add_top_container (obj_template_t *obj, val_value_t **val)
 make a val_value_t struct for a specified top-level container data node. More...
 
status_t agt_add_container (const xmlChar *modname, const xmlChar *objname, val_value_t *parentval, val_value_t **val)
 make a val_value_t struct for a specified nested container data node. More...
 
val_value_t * agt_init_cache (const xmlChar *modname, const xmlChar *objname, status_t *res)
 init a cache pointer during the init2 callback More...
 
status_t agt_check_cache (val_value_t **cacheptr, val_value_t *newval, val_value_t *curval, op_editop_t editop)
 check if a cache pointer needs to be changed or NULLed out More...
 
xpath_pcb_t * agt_new_xpath_pcb (ses_cb_t *scb, const xmlChar *expr, status_t *res)
 Get a new XPath parser control block and set up the server variable bindings. More...
 
xmlChar * agt_get_startup_filespec (status_t *res)
 Figure out where to store the startup file. More...
 
xmlChar * agt_get_target_filespec (const xmlChar *target_url, status_t *res)
 Figure out where to store the URL target file. More...
 
status_t agt_set_mod_defaults (ncx_module_t *mod, val_value_t *valroot, boolean set_candidate, boolean set_augment, boolean force)
 Check for any top-level config leafs that have a default value, and add them to the running configuration. More...
 
status_t agt_set_val_defaults (val_value_t *val)
 Check for any node-level config leafs that have a default value, and add them to the running configuration. More...
 
status_t agt_set_with_defaults (rpc_msg_t *msg, const xmlChar *modname, val_value_t **errval)
 Check if the <with-defaults> parameter is set in the request message, and if so, it is one of the server's supported values. More...
 
void agt_set_with_owners (rpc_msg_t *msg)
 Check if the <with-owners> parameter is set in the request message. More...
 
void agt_set_depth (rpc_msg_t *msg)
 Check if the <depth> parameter is set in the request message. More...
 
void agt_set_depth_nmda (rpc_msg_t *msg)
 Check if the <depth> parameter is set NMDA max-depth parameter in the request message If so, then set the msg->mhdr.max_depth and cur_depth will be set. More...
 
val_value_t * agt_get_key_value (val_value_t *startval, val_value_t **lastkey)
 Get the next expected key value in the ancestor chain. More...
 
val_value_t * agt_add_top_node_if_missing (ncx_module_t *mod, const xmlChar *objname, boolean *added, status_t *res)
 Add a top config node if it is missing. More...
 
boolean agt_any_operations_set (val_value_t *val)
 Check the new node and all descendants for any operation attibutes prsent. More...
 
boolean agt_apply_this_node (op_editop_t editop, const val_value_t *newnode, const val_value_t *curnode)
 Check if the write operation applies to the current node. More...
 
boolean agt_apply_this_node_ex (op_editop_t editop, const val_value_t *newnode, const val_value_t *curnode, boolean ignore_defaults, boolean childonly, boolean top_replace)
 Check if the write operation applies to the current node. More...
 
boolean agt_backups_enabled (void)
 Check if the backup commands are enabled. More...
 
xpath_result_t * agt_get_result_from_xpath (xpath_pcb_t *pcb, val_value_t *rootval, status_t *retres)
 Get the result from evaluating an XPath expression. More...
 
val_value_t * agt_get_first_result_val (xpath_result_t *result)
 Get the first XPath result node or NULL if not node-set or empty node-set or not value node. More...
 
void agt_output_start_container (ses_cb_t *scb, xml_msg_hdr_t *mhdr, xmlns_id_t parent_nsid, xmlns_id_t node_nsid, const xmlChar *node_name, int32 indent)
 Output a start container node. More...
 
void agt_output_start_node (ses_cb_t *scb, xml_msg_hdr_t *mhdr, xmlns_id_t parent_nsid, xmlns_id_t node_nsid, const xmlChar *node_name, int32 indent, boolean try_modname)
 Output a start node and try to use modname infront if needed. More...
 
void agt_output_start_errors_container (ses_cb_t *scb, xml_msg_hdr_t *mhdr, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent, boolean empty)
 Output a start <errors> element on the specified session for RESTCONF error handling. More...
 
void agt_output_end_container (ses_cb_t *scb, xml_msg_hdr_t *mhdr, xmlns_id_t node_nsid, const xmlChar *node_name, int32 indent)
 Output an end container node. More...
 
boolean agt_match_etag (val_value_t *val, const xmlChar *etag)
 Check if the etag matches the specified value string. More...
 
boolean agt_match_etag_binary (val_value_t *val, ncx_etag_t etag)
 Check if the etag matches the specified value string. More...
 
boolean agt_modified_since (val_value_t *val, time_t *timerec)
 Check if the timestamp for the object is later then the specified timestamp. More...
 
boolean agt_notifications_enabled (void)
 Check if notifications are enabled. More...
 
val_value_t * agt_make_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, const xmlChar *leafstrval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_union_leaf (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, const val_value_t *leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list use a val_value_t for a union More...
 
val_value_t * agt_make_uint_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, uint32 leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_int_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, int32 leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_uint64_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, uint64 leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_int64_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, int64 leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_idref_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, const val_idref_t *leafval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list More...
 
val_value_t * agt_make_bits_leaf (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, const ncx_list_t *listval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list (NCX_BT_BITS or NCX_BT_SLIST) More...
 
val_value_t * agt_make_boolean_leaf (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, boolean boolval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list (NCX_BT_BOOL) More...
 
val_value_t * agt_make_empty_leaf (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, boolean boolval, status_t *res)
 make a val_value_t struct for a specified leaf or leaf-list (NCX_BT_EMPTY) More...
 
val_value_t * agt_make_object2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *objname, status_t *res)
 make a val_value_t struct for a specified node More...
 
val_value_t * agt_make_virtual_leaf2 (obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, getcb_fn_t callbackfn, status_t *res)
 make a val_value_t struct for a specified virtual leaf or leaf-list More...
 
ncx_cfg_t agt_get_edit_config_id (rpc_msg_t *rpcmsg)
 Get the enum ID of the configuration that is being edited. More...
 
boolean agt_module_in_cli_valset (const xmlChar *modname)
 Check if there is a module=foo parameter in the CLI parameter set. More...
 
void agt_set_basic_withdef_enabled (void)
 Force the basic mode to be enabled in the agt_withdef_enabled bitmask. More...
 
boolean agt_check_delete_all_allowed (obj_template_t *testobj)
 Check if the delete-all or remove-all operation is enabled for for specified object. More...
 
op_editop_t agt_cvt_editop (op_editop_t editop, const val_value_t *newval, const val_value_t *curval)
 Determine the effective edit (if OP_EDITOP_COMMIT) More...
 
op_editop_t agt_cvt_editop_ex (op_editop_t editop, const val_value_t *newval, const val_value_t *curval)
 Determine the effective edit (if OP_EDITOP_COMMIT) Do not convert COMMIT to REPLACE same as cvt_editop. More...
 
int agt_connect_client (const xmlChar *hostname, uint16_t port)
 Start a TCP connection to a client. More...
 
status_t agt_find_in_datastore (ncx_cfg_t cfg_id, val_value_t *err_value, val_value_t **retval)
 Find the node (should be from an <edit-config> content node) in the specified datastore. More...
 
uint32 agt_get_error_count (rpc_msg_t *msg)
 Get the current number of errors in the rpc msg Q. More...
 
val_value_t * agt_get_rpc_input (rpc_msg_t *msg)
 Get the rpc input value node. More...
 
const xmlChar * agt_getTermReasonStr (ses_term_reason_t termreason)
 Convert the termination reason enum to a string. More...
 
boolean agt_get_ok_for_nolock (rpc_msg_t *msg)
 Check if the get has filters and if they are OK for a <get> without waiting for a pthreads filter. More...
 
boolean agt_getbulk_ok_for_nolock (const xmlChar *pathstr)
 Check if the get-bulk target is OK for a nolock get without waiting for a pthreads filter. More...
 
boolean agt_op_ok_for_maintenance_mode (const obj_template_t *rpcobj)
 Check if the operation is OK for maintenance mode. More...
 
const xmlChar * agt_crl_mode_str (agt_crl_mode_t crl_mode)
 Get the string for the CRL mode enum. More...
 
agt_crl_mode_t agt_crl_mode_enum (const xmlChar *crl_mode)
 Get the enum for the CRL mode string. More...
 
val_nodetest_fn_t agt_util_get_testfn (xml_msg_hdr_t *msg, boolean getop)
 Get the test function that should be used for a specific get operation based on with-default parameter and get operation. More...
 
status_t agt_fill_dummy_method (const xmlChar *modname, const xmlChar *rpcname, xml_node_t *node, obj_template_t **rpcobj)
 Fill the xml_node with the proper data to fake an XML node for the start of the rpc-method element. More...
 
yang_patch_cb_t * agt_make_yang_patch_cb (const xmlChar *patch_id, const xmlChar *the_comment, const xmlChar *patch_root, agt_cfg_transaction_t *txcb, uint32 included_changes)
 Make a yang_patch_cb for a YANG Patch conventional datastore on-change update. More...
 
yang_patch_cb_t * agt_make_yang_patch_cb_targobj (const xmlChar *patch_id, const xmlChar *the_comment, const xmlChar *patch_root, agt_cfg_transaction_t *txcb, uint32 included_changes, obj_template_t *targobj)
 Make a yang_patch_cb for a YANG Patch conventional datastore on-change update for a target object. More...
 
yang_patch_cb_t * agt_make_yang_patch_cb_file (const xmlChar *patch_id, const xmlChar *the_comment, const xmlChar *patch_root, const xmlChar *filespec)
 Make a yang_patch_cb for a Simulated Operational On-Change subscription update from a data file. More...
 
boolean agt_check_included_changes (agt_cfg_transaction_t *txcb, uint32 included_changes, obj_template_t *targobj)
 Check an edit transaction to see if it has any edits that match the included_changes bitmask parameter. More...
 
status_t agt_add_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, const xmlChar *leafstrval)
 make a child node from a string and add to parent. More...
 
status_t agt_add_uint_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, uint32 leafval)
 make a child node from a uint32 and add to parent. More...
 
status_t agt_add_int_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, int32 leafval)
 make a child node from a int32 and add to parent. More...
 
status_t agt_add_uint64_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, uint64 leafval)
 make a child node from a uint64 and add to parent. More...
 
status_t agt_add_int64_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, int64 leafval)
 make a child node from a int64 and add to parent. More...
 
status_t agt_add_boolean_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, boolean boolval)
 make a child node from a boolean and add to parent. More...
 
status_t agt_add_idref_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, const val_idref_t *leafval)
 make a child node from a val_idref_t struct and add to parent. More...
 
status_t agt_add_bits_leafy (val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, const ncx_list_t *leafval)
 make a child node from a ncx_list_t struct (bits) and add to parent. More...
 

Detailed Description

Utility Functions for NCX Server method routines.