yumapro  20.10-12
YumaPro SDK
agt_yangpatch.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 #if defined(WITH_RESTCONF) || defined(WITH_YCONTROL) || defined(WITH_YANGAPI)
12 #ifndef _H_agt_yangpatch
13 #define _H_agt_yangpatch
14 /* FILE: agt_yangpatch.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
27 /*********************************************************************
28 * *
29 * C H A N G E H I S T O R Y *
30 * *
31 *********************************************************************
32 
33 date init comment
34 ---------------------------------------------------------------------
35 04apr16 am begun
36 
37 
38 */
39 
40 #ifndef _H_status_enum
41 #include "status_enum.h"
42 #endif
43 
44 #ifndef _H_status
45 #include "status.h"
46 #endif
47 
48 #ifndef _H_ses
49 #include "ses.h"
50 #endif
51 
52 #ifndef _H_rpc
53 #include "rpc.h"
54 #endif
55 
56 #ifndef _H_yang_patch
57 #include "yang_patch.h"
58 #endif
59 
60 #ifndef _H_yangapi
61 #include "yangapi.h"
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 
69 /********************************************************************
70 * *
71 * C O N S T A N T S *
72 * *
73 *********************************************************************/
74 
75 /********************************************************************
76 * *
77 * T Y P E S *
78 * *
79 *********************************************************************/
80 
81 /********************************************************************
82 * *
83 * F U N C T I O N S *
84 * *
85 *********************************************************************/
86 
142 extern status_t
143  agt_yangpatch_edit (ses_cb_t *scb,
144  yangapi_cb_t *rcb,
145  rpc_msg_t *msg);
146 
147 
148 #if defined(WITH_GNMI) && defined(WITH_RESTCONF) && defined(WITH_YCONTROL)
149 
173 extern status_t
174  agt_yangpatch_gnmi_edit (ses_cb_t *scb,
175  yangapi_cb_t *rcb,
176  yang_patch_cb_t *pcb,
177  rpc_msg_t *msg);
178 
179 #endif // WITH_GNMI
180 
181 
185 #ifdef __cplusplus
186 } /* end extern 'C' */
187 #endif
188 
189 #endif /* _H_agt_yangpatch */
190 #endif // defined(WITH_RESTCONF) || defined(WITH_YCONTROL) || defined(WITH_YANGAPI)
NCX_AGT_TARG_RUNNING
@ NCX_AGT_TARG_RUNNING
target=running
Definition: ncxtypes.h:355
ses.h
NETCONF Session Common definitions module.
ncx_get_empty_npcon_presence
boolean ncx_get_empty_npcon_presence(void)
Get the empty_npcon_presence value.
Definition: ncx.c:13615
DUMP_VAL_LOG
@ DUMP_VAL_LOG
dump val to main log
Definition: val.h:777
cfg.h
xpath_free_pcb
void xpath_free_pcb(xpath_pcb_t *pcb)
Free a malloced XPath parser control block.
Definition: xpath.c:2963
SES_YPMODE_NETCONF
@ SES_YPMODE_NETCONF
NETCONF mode.
Definition: ses.h:313
agt_restconf.h
IETF RESTCONF Protocol Message Handler.
SES_YPMODE_HA
@ SES_YPMODE_HA
YP-HA mode.
Definition: ses.h:311
agt_util.h
Utility Functions for NCX Server method routines.
YANG_PATCH_OP_CREATE
@ YANG_PATCH_OP_CREATE
create
Definition: yang_patch.h:89
OP_EDITOP_NONE
@ OP_EDITOP_NONE
not set
Definition: op.h:123
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
ERR_NCX_RESOURCE_UNKNOWN
@ ERR_NCX_RESOURCE_UNKNOWN
385
Definition: status_enum.h:428
val_find_child
val_value_t * val_find_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname)
Find the first instance of the specified child node.
Definition: val.c:8560
agt_yangapi_edit.h
Yuma REST API Edit Handler.
YANG_PATCH_WHERE_AFTER
@ YANG_PATCH_WHERE_AFTER
insert after foo
Definition: yang_patch.h:111
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
yang_patch_free_cb
void yang_patch_free_cb(yang_patch_cb_t *pcb)
Free a YANG Patch control block.
Definition: yang_patch.c:214
cfg_new_fake_candidate
cfg_template_t * cfg_new_fake_candidate(const xmlChar *name, ncx_cfg_t cfg_id)
Malloc and initialize a new fake Candidate cfg_template_t struct.
Definition: cfg.c:3391
val.h
Value Node Basic Support.
NCX_IFMT_RESTCONF
@ NCX_IFMT_RESTCONF
RESTCONF URI with list1=key1,key2.
Definition: ncxtypes.h:404
xml_util.h
XML Utilities.
xpath_new_pcb
xpath_pcb_t * xpath_new_pcb(const xmlChar *xpathstr, xpath_getvar_fn_t getvar_fn)
malloc a new XPath parser control block
Definition: xpath.c:2739
YANG_PATCH_OP_MERGE
@ YANG_PATCH_OP_MERGE
merge
Definition: yang_patch.h:92
YANG_PATCH_WHERE_NONE
@ YANG_PATCH_WHERE_NONE
not set
Definition: yang_patch.h:109
op_insertop_id
op_insertop_t op_insertop_id(const xmlChar *opstr)
Get the ID for the insert operation from its keyword.
Definition: op.c:234
status_enum.h
global error status code enumerations
val_swap_child
void val_swap_child(val_value_t *newchild, val_value_t *curchild)
Swap a child value node with a current value node.
Definition: val.c:8334
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
val_delete_children
void val_delete_children(val_value_t *val)
Check if the value is a complex type and if so then delete all child nodes.
Definition: val.c:13640
obj_npcon_has_defaults_slow
boolean obj_npcon_has_defaults_slow(obj_template_t *obj)
Check if the specified NP container has defaults within it Must be a config object!...
Definition: obj.c:11776
agt_restcmn_record_error
void agt_restcmn_record_error(ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, val_value_t *errnode, const xmlChar *badval)
Record an rpc-error for YANG-API/RESTCONF response translation.
Definition: agt_restcmn.c:7326
SES_GET_YPMODE
#define SES_GET_YPMODE(S)
get internal YP mode flag
Definition: ses.h:284
agt_yangpatch_gnmi_edit
status_t agt_yangpatch_gnmi_edit(ses_cb_t *scb, yangapi_cb_t *rcb, yang_patch_cb_t *pcb, rpc_msg_t *msg)
Handle a YP-GNMI edit.
Definition: agt_yangpatch.c:1536
SES_YPMODE_RESTCONF
@ SES_YPMODE_RESTCONF
RESTCONF mode.
Definition: ses.h:312
agt_sys_send_sysConfigChange
void agt_sys_send_sysConfigChange(const ses_cb_t *scb, dlq_hdr_t *auditrecQ)
Queue the Config Change notification.
Definition: agt_sys.c:1355
op.h
NETCONF protocol operations.
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxmod.h
NCX Module Load Manager.
xpath_yang_make_instanceid_val
val_value_t * xpath_yang_make_instanceid_val(xpath_pcb_t *pcb, status_t *retres, val_value_t **deepest)
Make a value subtree out of an instance-identifier Used by yangcli to send PDUs from CLI target param...
Definition: xpath_yang.c:2838
YANG_PATCH_OP_DELETE
@ YANG_PATCH_OP_DELETE
delete
Definition: yang_patch.h:90
cfg_get_root
val_value_t * cfg_get_root(ncx_cfg_t cfgid)
Get the config root for the specified config.
Definition: cfg.c:3240
OP_EDITOP_MERGE
@ OP_EDITOP_MERGE
edit op is merge
Definition: op.h:124
val_find_next_child
val_value_t * val_find_next_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname, const val_value_t *curchild)
Find the next instance of the specified child node.
Definition: val.c:8748
ERR_NCX_MISSING_PARM
@ ERR_NCX_MISSING_PARM
233
Definition: status_enum.h:272
xpath1.h
XPath 1.0 expression support.
agt_yangpatch_edit
status_t agt_yangpatch_edit(ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg)
Handle a YANG Patch edit.
Definition: agt_yangpatch.c:1309
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
agt_profile.h
NETCONF Server agt_profile data structure.
NCX_PROTO_RESTCONF
@ NCX_PROTO_RESTCONF
IETF RESTCONF.
Definition: ncxtypes.h:788
val_gen_instance_id_ex
status_t val_gen_instance_id_ex(xml_msg_hdr_t *mhdr, const val_value_t *val, ncx_instfmt_t format, boolean stop_at_root, xmlChar **buff)
Malloc and Generate the instance ID string for this value node,.
Definition: val_util.c:3462
ses_get_protocol
ncx_protocol_t ses_get_protocol(const ses_cb_t *scb)
Get the NETCONF protocol set (or unset) for this session.
Definition: ses.c:3854
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
xpath_free_result
void xpath_free_result(xpath_result_t *result)
Free a malloced XPath result struct.
Definition: xpath.c:3107
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
NCX_AGT_TARG_CANDIDATE
@ NCX_AGT_TARG_CANDIDATE
target=candidate
Definition: ncxtypes.h:354
yang_patch_value_to_edit
yang_patch_edit_t * yang_patch_value_to_edit(val_value_t *edit_val, boolean preserve_editval, status_t *res)
Convert a val_value_t tree to a YANG Patch edit.
Definition: yang_patch.c:934
val_child_add
status_t val_child_add(val_value_t *child, val_value_t *parent)
Add a child value node to a parent value node.
Definition: val_child.c:1542
val_util.h
Value Node Utilities.
xpath1_eval_expr
xpath_result_t * xpath1_eval_expr(xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, status_t *res)
Evaluate an XPath expression use if the prefixes are YANG: must/when.
Definition: xpath1.c:5293
ses_indent_count
int32 ses_indent_count(const ses_cb_t *scb)
Get the logging indent count for this session.
Definition: ses.c:2801
yang_patch_op_to_editop
op_editop_t yang_patch_op_to_editop(yang_patch_op_t op, boolean *is_insert)
Convert a YANG Patch operation enum to the corresponding edit operation.
Definition: yang_patch.c:1149
YANG_PATCH_OP_REMOVE
@ YANG_PATCH_OP_REMOVE
remove
Definition: yang_patch.h:95
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
NCX_CFGID_CANDIDATE
@ NCX_CFGID_CANDIDATE
candidate datastore
Definition: ncxtypes.h:385
agt_restcmn_decode_url
xmlChar * agt_restcmn_decode_url(const xmlChar *url, status_t *res)
Decode URL encoded string value into string.
Definition: agt_restcmn.c:7225
rpc.h
NETCONF protocol remote procedure call common definitions.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
val_clone
val_value_t * val_clone(const val_value_t *val)
Clone a specified val_value_t struct and sub-trees.
Definition: val.c:7836
val_child.h
Value Node Child Access Support.
OP_INSOP_NONE
@ OP_INSOP_NONE
not set
Definition: op.h:138
YANG_PATCH_OP_INSERT
@ YANG_PATCH_OP_INSERT
insert
Definition: yang_patch.h:91
val_match_child_count
val_value_t * val_match_child_count(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname, uint32 *matchcount)
Match the first instance of the specified child node Return the total number of matches.
Definition: val.c:8718
typ.h
Parameter Type Handler.
dlq_count
unsigned int dlq_count(const dlq_hdrT *listP)
get the number of queue entries in the listP queue list
Definition: dlq.c:994
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
yangconst.h
Contains YANG constants separated to prevent H file include loops.
yang_patch.h
YANG Patch Media Type.
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
YANG_PATCH_OP_MOVE
@ YANG_PATCH_OP_MOVE
move
Definition: yang_patch.h:93
val_new_editvars
status_t val_new_editvars(val_value_t *val)
Malloc and initialize the val->editvars field.
Definition: val.c:13350
val_dump_value_max
void val_dump_value_max(val_value_t *val, int32 startindent, int32 indent_amount, val_dumpvalue_mode_t dumpmode, ncx_display_mode_t display_mode, boolean with_meta, boolean configonly, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5859
OP_INSOP_LAST
@ OP_INSOP_LAST
insert last (default)
Definition: op.h:140
agt_restcmn.h
Common function for RESTCONF and YANG-API protocols.
obj_is_np_container
boolean obj_is_np_container(const obj_template_t *obj)
Check if the object is an Non-Presence-container.
Definition: obj.c:14487
xpath_yang.h
YANG-specific Xpath support.
yang_patch_new_cb
yang_patch_cb_t * yang_patch_new_cb(const xmlChar *patch_id, const xmlChar *the_comment, const xmlChar *target)
Malloc a new YANG Patch control block.
Definition: yang_patch.c:162
xml_msg.h
XML and JSON Message send and receive support.
agt_yangpatch.h
YumaPro YANG-PATCH Edit Handler for HA/RESTCONF/NETCONF.
YANG_PATCH_WHERE_BEFORE
@ YANG_PATCH_WHERE_BEFORE
insert before foo
Definition: yang_patch.h:110
agt_restcmn_val_error
void agt_restcmn_val_error(ses_cb_t *scb, xml_msg_hdr_t *mhdr, status_t res, val_value_t *errval, const xmlChar *badval)
Record an rpc-error for YANG-API/RESTCONF response translation.
Definition: agt_restcmn.c:7438
agt_cfg_free_transaction
void agt_cfg_free_transaction(agt_cfg_transaction_t *txcb)
Clean and free a agt_cfg_transaction_t struct.
Definition: agt_cfg.c:1278
agt_restcmn_make_uri
xmlChar * agt_restcmn_make_uri(ses_cb_t *scb, const xmlChar *target, const xmlChar *edit_target)
Make a URI string.
Definition: agt_restcmn.c:7167
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
val_get_next_child
val_value_t * val_get_next_child(const val_value_t *curchild)
Get the next child node.
Definition: val.c:8496
log.h
NCX System Logging Manager.
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ypgnmi.h
YP-GNMI requests support module.
agt_sys.h
NETCONF system.yang DM module support.
agt_yangapi_edit_request_ex
status_t agt_yangapi_edit_request_ex(ses_cb_t *scb, yangapi_cb_t *rcb, rpc_msg_t *msg, val_value_t *force_editval, op_editop_t force_editop, boolean skip_sil, boolean skip_save, const xmlChar *comment_str, yang_patch_edit_t *edit)
Perform an internal <edit-config> and <commit> if needed.
Definition: agt_yangapi_edit.c:1336
cfg_free_template
void cfg_free_template(cfg_template_t *cfg)
Clean and free the cfg_template_t struct.
Definition: cfg.c:1383
agt_cfg.h
Manage Server configuration edit transactions.
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
val_get_first_child
val_value_t * val_get_first_child(const val_value_t *parent)
Get the first child node.
Definition: val.c:8477
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
val_child_swap
status_t val_child_swap(val_value_t *newchild, val_value_t *curchild)
Swap a child value node with a current value node.
Definition: val_child.c:2253
YANGAPI_LAUNCHPT_DATASTORE
@ YANGAPI_LAUNCHPT_DATASTORE
/restconf/data launch point
Definition: yangapi.h:134
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
ERR_NCX_EXTRA_LISTSTR
@ ERR_NCX_EXTRA_LISTSTR
292
Definition: status_enum.h:335
ncx.h
YANG module utility functions.
VAL_INS_MODE_POINT
@ VAL_INS_MODE_POINT
YANG-API point param.
Definition: val.h:769
ypgnmi_set_edit_status
void ypgnmi_set_edit_status(rpc_msg_t *msg, const xmlChar *edit_id, status_t res)
Set the error status to the gNMI edit.
Definition: ypgnmi.c:342
obj.h
Data Object Support.
cfg_fill_candidate_from_running
status_t cfg_fill_candidate_from_running(ses_id_t sesid)
Fill the <candidate> config with the config contents of the <running> config.
Definition: cfg.c:1582
SES_MY_SID
#define SES_MY_SID(S)
get session-id
Definition: ses.h:105
NCX_DISPLAY_MODE_MODULE
@ NCX_DISPLAY_MODE_MODULE
plain CLI display mode with YANG module names added to nodes
Definition: ncxtypes.h:457
val_convert_anyxml_to_real
status_t val_convert_anyxml_to_real(val_value_t *anyxml_val, val_value_t *real_val, val_value_t **error_val)
Convert anydata nodes to match a real template.
Definition: val_util.c:7246
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
agt_get_first_result_val
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.
Definition: agt_util.c:5207
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
val_child_add_force
status_t val_child_add_force(val_value_t *child, val_value_t *parent)
Add a child value node to a parent value node Force add even if Tree Insersion fails.
Definition: val_child.c:1624
agt_restcmn_new_config_wrapper
val_value_t * agt_restcmn_new_config_wrapper(void)
Create a <config> wrapper val and return it.
Definition: agt_restcmn.c:7131
xmlns.h
XML namespace support.
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
status.h
Global error messages for status code enumerations.
yangapi.h
YANG-API definitions (pre-RESTCONF)
log_debug3_append
void void void void void void void void void void void void log_debug3_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG3 log entry.
xpath_convert_url_to_path
xmlChar * xpath_convert_url_to_path(const xmlChar *urlpath, ncx_name_match_t match_names, boolean alt_naming, boolean wildcards, boolean withkeys, boolean fullkeys, boolean withmod, ncx_protocol_t proto, status_t *res)
Convert a URL format path to XPath format path.
Definition: xpath.c:4374
YANG_PATCH_EDIT_TYPE_USER
@ YANG_PATCH_EDIT_TYPE_USER
edit by user
Definition: yang_patch.h:102
dlq.h
dlq provides general double-linked list and queue support:
yang_patch_where_to_str
const xmlChar * yang_patch_where_to_str(yang_patch_where_t wh)
Convert a YANG Patch where enum to the where string for the enumeration.
Definition: yang_patch.c:645
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297