yumapro  21.10T-8
YumaPro SDK
yang_patch.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 #ifndef _H_yang_patch
12 #define _H_yang_patch
13 
14 /* FILE: yang_patch.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
29 /*********************************************************************
30 * *
31 * C H A N G E H I S T O R Y *
32 * *
33 *********************************************************************
34 
35 date init comment
36 ----------------------------------------------------------------------
37 16-nov-14 abb Begun
38 
39 */
40 
41 #include <xmlstring.h>
42 
43 #ifndef _H_dlq
44 #include "dlq.h"
45 #endif
46 
47 #ifndef _H_obj
48 #include "obj.h"
49 #endif
50 
51 #ifndef _H_op
52 #include "op.h"
53 #endif
54 
55 #ifndef _H_status
56 #include "status.h"
57 #endif
58 
59 #ifndef _H_val
60 #include "val.h"
61 #endif
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 
68 #define YANG_PATCH_DEF_SKIP_SIL TRUE
69 
70 
71 /********************************************************************
72 * *
73 * T Y P E S *
74 * *
75 *********************************************************************/
76 
87 typedef enum yang_patch_op_t_ {
97 
98 
100 typedef enum yang_patch_edit_type_t_ {
105 
106 
108 typedef enum yang_patch_where_t_ {
115 
116 
118 typedef struct yang_patch_edit_t_ {
120  dlq_hdr_t qhdr;
121 
123  xmlChar *edit_id;
124 
126  yang_patch_op_t operation;
127 
129  xmlChar *target;
130 
132  xmlChar *point;
133 
135  yang_patch_where_t insert_where;
136 
139 
144 
147 
149  boolean lastedit;
150 
152 
153 
155 typedef struct yang_patch_cb_t_ {
157  dlq_hdr_t qhdr;
158 
160  xmlChar *patch_id;
161 
163  yang_patch_edit_type_t edit_type;
164 
166  boolean skip_sil;
167 
169  xmlChar *comment;
170 
178  xmlChar *target;
179 
181  dlq_hdr_t editQ;
183 
184 
185 
186 /********************************************************************
187 * *
188 * F U N C T I O N S *
189 * *
190 *********************************************************************/
191 
192 
198 extern status_t
199  yang_patch_init (void);
200 
201 
206 extern void
207  yang_patch_cleanup (void);
208 
209 
219 extern yang_patch_cb_t *
220  yang_patch_new_cb (const xmlChar *patch_id,
221  const xmlChar *the_comment,
222  const xmlChar *target);
223 
224 
230 extern void
232 
233 
239 extern void
241 
242 
256 extern yang_patch_edit_t *
257  yang_patch_new_edit (const xmlChar *edit_id,
258  yang_patch_op_t operation,
259  const xmlChar *target,
260  const xmlChar *point,
261  yang_patch_where_t insert_where,
262  val_value_t *value);
263 
264 
280 extern yang_patch_edit_t *
281  yang_patch_new_edit2 (const xmlChar *edit_id,
282  yang_patch_op_t operation,
283  const xmlChar *target,
284  const xmlChar *point,
285  yang_patch_where_t insert_where,
286  val_value_t *value,
287  boolean plain_clone);
288 
289 
296 extern void
298  yang_patch_edit_t *edit);
299 
300 
308 extern yang_patch_edit_t *
310  const xmlChar *edit_id);
311 
312 
319 extern uint32
321 
322 
330 extern yang_patch_op_t
331  yang_patch_str_to_op (const xmlChar *opstr);
332 
333 
341 extern const xmlChar *
342  yang_patch_op_to_str (yang_patch_op_t op);
343 
344 
352 extern yang_patch_edit_type_t
353  yang_patch_str_to_edit_type (const xmlChar *str);
354 
355 
363 extern const xmlChar *
364  yang_patch_edit_type_to_str (yang_patch_edit_type_t typ);
365 
366 
374 extern yang_patch_where_t
375  yang_patch_str_to_where (const xmlChar *wherestr);
376 
377 
385 extern const xmlChar *
386  yang_patch_where_to_str (yang_patch_where_t wh);
387 
388 
399 extern val_value_t *
401  yang_patch_edit_t *edit,
402  status_t *res);
403 
404 
415 extern val_value_t *
417  yang_patch_cb_t *pcb,
418  status_t *res);
419 
420 
434 extern yang_patch_edit_t *
436  boolean preserve_editval,
437  status_t *res);
438 
439 
454 extern yang_patch_cb_t *
456  const xmlChar *target,
457  boolean preserve_patchval,
458  status_t *res);
459 
460 
471 extern op_editop_t
472  yang_patch_op_to_editop (yang_patch_op_t op,
473  boolean *is_insert);
474 
475 
485 extern yang_patch_op_t
487 
488 
496 extern void
498 
499 
503 #ifdef __cplusplus
504 } /* end extern 'C' */
505 #endif
506 
507 #endif /* _H_yang_patch */
Data Object Support.
dlq provides general double-linked list and queue support:
void yang_patch_cleanup(void)
Cleanup the yang_patch module.
Definition: yang_patch.c:141
val_value_t * targval
REAL target value for the current EDIT.
Definition: yang_patch.h:146
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_where_t
YANG Patch insert location.
Definition: yang_patch.h:108
yang_patch_op_t operation
edit operation from request
Definition: yang_patch.h:126
yang_patch_where_t yang_patch_str_to_where(const xmlChar *wherestr)
Convert a YANG Patch where string to the where enumeration for the string.
Definition: yang_patch.c:611
insert first
Definition: yang_patch.h:112
Represents one YANG Patch edit entry.
Definition: yang_patch.h:118
remove
Definition: yang_patch.h:95
replace
Definition: yang_patch.h:94
yang_patch_op_t
YANG Patch operation type.
Definition: yang_patch.h:87
insert
Definition: yang_patch.h:91
One YANG data-def-stmt.
Definition: obj.h:1140
xmlChar * point
point parameter for insert from request
Definition: yang_patch.h:132
edit by system
Definition: yang_patch.h:103
yang_patch_op_t yang_patch_editop_to_op(op_editop_t edit_op)
Convert an edit operation enum to a YANG Patch operation enum.
Definition: yang_patch.c:1195
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
yang_patch_edit_t * yang_patch_new_edit(const xmlChar *edit_id, yang_patch_op_t operation, const xmlChar *target, const xmlChar *point, yang_patch_where_t insert_where, val_value_t *value)
Malloc a new YANG Patch edit control block Any of the fields can be NULL to add later or not use...
Definition: yang_patch.c:255
xmlChar * target
data path target from request
Definition: yang_patch.h:129
create
Definition: yang_patch.h:89
not set
Definition: yang_patch.h:109
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
uint32 yang_patch_edit_count(yang_patch_cb_t *pcb)
Get the number of edits in the PCB.
Definition: yang_patch.c:443
Value Node Basic Support.
yang_patch_edit_t * yang_patch_find_edit(yang_patch_cb_t *pcb, const xmlChar *edit_id)
Find an edit by its edit_id in the YANG Patch.
Definition: yang_patch.c:414
val_value_t * configval
the &#39;root&#39; value struct that represents the tree of changes to apply to the target ...
Definition: yang_patch.h:143
yang_patch_cb_t * yang_patch_value_to_patch(val_value_t *patch_val, const xmlChar *target, boolean preserve_patchval, status_t *res)
Convert a val_value tree to a YANG Patch control block.
Definition: yang_patch.c:1055
One YANG Patch Request.
Definition: yang_patch.h:155
yang_patch_edit_type_t
Internal edit type for access control and DB-API support.
Definition: yang_patch.h:100
void yang_patch_dump_pcb(yang_patch_cb_t *pcb)
Dump the current Patch Control block with all the edits.
Definition: yang_patch.c:1240
void yang_patch_free_cb(yang_patch_cb_t *pcb)
Free a YANG Patch control block.
Definition: yang_patch.c:214
insert before foo
Definition: yang_patch.h:110
xmlChar * patch_id
patch ID is usually the transaction-id
Definition: yang_patch.h:160
op_editop_t
NETCONF edit-config operation types.
Definition: op.h:122
val_value_t * value
edit value from request (not provided for delete)
Definition: yang_patch.h:138
boolean lastedit
flag for last edit
Definition: yang_patch.h:149
move
Definition: yang_patch.h:93
insert after foo
Definition: yang_patch.h:111
yang_patch_where_t insert_where
insert where parameter for insert from request
Definition: yang_patch.h:135
one value to match one type
Definition: val.h:870
status_t yang_patch_init(void)
Load the ietf-yang-patch module.
Definition: yang_patch.c:120
insert lsat (default)
Definition: yang_patch.h:113
yang_patch_edit_type_t yang_patch_str_to_edit_type(const xmlChar *str)
Convert a YANG Patch edit-type string to the edit_type enumeration for the string.
Definition: yang_patch.c:553
status_t
global error return code
Definition: status_enum.h:186
boolean skip_sil
skip SIL callback; used by DB-API to control edit in main server
Definition: yang_patch.h:166
val_value_t * yang_patch_edit_to_value(obj_template_t *edit_obj, yang_patch_edit_t *edit, status_t *res)
Convert a YANG Patch edit to a val_value_t tree.
Definition: yang_patch.c:680
const xmlChar * yang_patch_op_to_str(yang_patch_op_t op)
Convert a YANG Patch operation enum to the operation string for the enumeration.
Definition: yang_patch.c:515
Global error messages for status code enumerations.
xmlChar * comment
comment provided for this patch
Definition: yang_patch.h:169
xmlChar * edit_id
edit identifier string from request
Definition: yang_patch.h:123
xmlChar * target
In case of HA and NETCONF this &#39;target&#39; uses the datastore root &#39;/&#39; as the target resource and use th...
Definition: yang_patch.h:178
void yang_patch_add_edit(yang_patch_cb_t *pcb, yang_patch_edit_t *edit)
Malloc and add new YANG Patch edit control block.
Definition: yang_patch.c:393
const xmlChar * yang_patch_edit_type_to_str(yang_patch_edit_type_t typ)
Convert a YANG Patch edit type enum to the string for the enumeration.
Definition: yang_patch.c:583
NETCONF protocol operations.
delete
Definition: yang_patch.h:90
not set
Definition: yang_patch.h:101
edit by user
Definition: yang_patch.h:102
yang_patch_edit_t * yang_patch_new_edit2(const xmlChar *edit_id, yang_patch_op_t operation, const xmlChar *target, const xmlChar *point, yang_patch_where_t insert_where, val_value_t *value, boolean plain_clone)
Malloc a new YANG Patch edit control block Any of the fields can be NULL to add later or not use...
Definition: yang_patch.c:293
merge
Definition: yang_patch.h:92
yang_patch_op_t yang_patch_str_to_op(const xmlChar *opstr)
Convert a YANG Patch operation string to the operation enumeration for the string.
Definition: yang_patch.c:465
val_value_t * yang_patch_to_value(obj_template_t *patch_obj, yang_patch_cb_t *pcb, status_t *res)
Convert a YANG Patch control block to a val_value_t tree.
Definition: yang_patch.c:846
yang_patch_edit_type_t edit_type
edit type (user or system)
Definition: yang_patch.h:163
not set
Definition: yang_patch.h:88
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
void yang_patch_free_edit(yang_patch_edit_t *edit)
Free a YANG Patch edit control block.
Definition: yang_patch.c:367