yumapro  23.10T-9
YumaPro SDK
Loading...
Searching...
No Matches
sm.h
Go to the documentation of this file.
1#ifdef WITH_SCHEMA_MOUNT
2/*
3 * Copyright (c) 2022 - 2023, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12
13#ifndef _H_sm
14#define _H_sm
15
16/* FILE: sm.h
17*********************************************************************
18* *
19* P U R P O S E *
20* *
21*********************************************************************/
22
28/*********************************************************************
29* *
30* C H A N G E H I S T O R Y *
31* *
32*********************************************************************
33
34date init comment
35----------------------------------------------------------------------
3604-apr-22 am Begun
37*/
38
39/* used by the agent for the xmlTextReader interface */
40#include <xmlreader.h>
41
42#ifndef _H_ncxtypes
43#include "ncxtypes.h"
44#endif
45
46#ifndef _H_obj
47#include "obj.h"
48#endif
49
50#ifndef _H_status_enum
51#include "status_enum.h"
52#endif
53
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59
60/* Header only */
61
70/********************************************************************
71* *
72* C O N S T A N T S *
73* *
74*********************************************************************/
75
76
77/********************************************************************
78* *
79* T Y P E S *
80* *
81*********************************************************************/
82
83
84
96typedef status_t
98
99
100
111typedef boolean
113 void *cookie);
114
115
116/********************************************************************
117* *
118* F U N C T I O N S *
119* *
120*********************************************************************/
121
134extern void sm_init (void);
135
136
141extern void
142 sm_cleanup (void);
143
144
153extern void
155
156
165extern void
167
168
173extern void
174 sm_dump_all_rootcb (void);
175
176
189extern ncx_module_t *
191 const xmlChar *modname,
192 const xmlChar *revision);
193
194
195/*
196* @brief Find an ncx_module_t in the rootcb->modQ by prefix
197*
198* rootcb->modQ These are the modules that are already loaded
199* into Mount Point
200*
201* @param rootcb control block to use
202* @param prefix name
203*
204* @return module pointer if found or NULL if not
205*/
206extern ncx_module_t *
207 sm_find_module_by_prefix (ncx_sm_rootcb_t *rootcb,
208 const xmlChar *prefix);
209
210
223extern ncx_module_t *
225 const xmlChar *modname,
226 const xmlChar *revision);
227
228
240extern ncx_module_t *
241 sm_find_module_allroots (const xmlChar *modname,
242 const xmlChar *revision,
243 boolean withdev);
244
245
246/*
247* @brief Find an ncx_module_t in the any rootcb
248* CHECK submodules allowed
249* Will return the first match or NULL if no match
250* @param modname module name
251* @param revision module revision date
252* @param withdev TRUE to check deviation modules as well
253* @param withsubmod TRUE to check submodules and modules
254* @return module pointer if found or NULL if not
255*/
256extern ncx_module_t *
257 sm_find_module_allroots2 (const xmlChar *modname,
258 const xmlChar *revision,
259 boolean withdev,
260 boolean withsubmod);
261
262
272extern obj_template_t *
274 const xmlChar *objname);
275
276
288extern obj_template_t *
290 boolean augment_ok);
291
292
304extern obj_template_t *
306 boolean augment_ok);
307
308
319extern obj_template_t *
321 boolean augment_ok);
322
323
335extern obj_template_t *
337 boolean augment_ok);
338
339
362extern obj_template_t *
364 const xmlChar *modname,
365 const xmlChar *objname,
366 ncx_name_match_t match_names,
367 boolean alt_names,
368 boolean dataonly,
369 status_t *retres);
370
371
378extern void
380
381
388extern void
390
391
398extern void
400
401
407extern void
409
410
417extern ncx_sm_mpid_t *
418 sm_new_mpid (void);
419
420
426extern void
428
429
440extern status_t
442 val_value_t *val,
443 obj_template_t *obj);
444
445
455extern void
456 sm_dump_mpid (const ncx_sm_mpid_t *mpid);
457
458
468extern ncx_sm_mpid_t *
469 sm_clone_mpid (const ncx_sm_mpid_t *mpid,
470 val_value_t *valroot);
471
472
484extern ncx_sm_mpid_t *
486
487
500extern status_t
502 val_value_t **mpidval);
503
504
505
514extern val_value_t *
516
517
518
528extern ncx_sm_mpid_t *
530
531
542extern status_t
544 dlq_hdr_t *keyQ);
545
546
553extern ncx_sm_mpid_t *
555
562extern ncx_sm_mpid_t *
564
565
576extern status_t
578 ncx_sm_mpid_t *mpid);
579
580
581
592extern ncx_sm_rootcb_t *
593 sm_search_rootcbs (dlq_hdr_t *searchQ,
594 sm_rootcb_searchfn_t searchfn,
595 void *cookie);
596
605extern ncx_sm_rootcb_t *
607 const xmlChar *label);
608
609
618extern ncx_sm_rootcb_t *
619 sm_find_rootcb (const xmlChar *label,
620 const xmlChar *modname);
621
622
628extern void
630
631
638extern ncx_module_t *
640
641
648extern ncx_module_t *
650
651
652/*
653* @brief Get the specific Mount Point Label
654*
655* @param mod module that is inside this Mount Point
656*/
657extern const xmlChar *
658 sm_get_current_mp_label (ncx_module_t *mod);
659
660
671extern void
672 sm_clear_all_rootcbs (dlq_hdr_t *saveQ);
673
674
695extern ncx_sm_mpid_t *
696 sm_val_to_mpid (val_value_t *mpidval,
697 boolean preserve,
698 status_t *res);
699
700
723extern val_value_t *
725 obj_template_t *mpidobj,
726 boolean preserve,
727 status_t *res);
728
729
736extern val_value_t *
738
739
740
747extern val_value_t *
748 sm_get_next_anckey (const val_value_t *curkey);
749
750
751
760extern ncx_sm_rootcb_t *
762
763
774extern uint32
776 ncx_sm_rootcb_t *rootcb,
777 const xmlChar *modname);
778
779
780
790extern uint32
792 const xmlChar *modname);
793
794
802extern status_t
804
805
808#ifdef __cplusplus
809} /* end extern 'C' */
810#endif
811
812#endif /* _H_sm */
813
814#else
815
816#define sm_dump_rootcb(R)
817
818#define sm_show_rootcb(R)
819
820#define sm_dump_all_rootcb()
821
822#define sm_find_module(A,B,C) NULL
823
824#define sm_find_deviation(A,B,C) NULL
825
826#define sm_find_module_allroots(A,B,C) NULL
827
828#define sm_find_any_object(A,B) NULL
829
830#define sm_first_mounted_obj(R,B) NULL
831
832#define sm_next_mounted_obj(C,B) NULL
833
834#define sm_last_mounted_obj(C,B) NULL
835
836#define sm_prev_mounted_obj(C,B) NULL
837
838#define sm_setup_cur_rootcb(P)
839
840#define sm_free_mpid(A)
841
842#define sm_dump_mpid(M)
843
844#define sm_clone_mpid(M,V) NULL
845
846#define sm_get_mpid_from_msg(M) NULL
847
848#define sm_get_mpi_valroot(P) NULL
849
850#define sm_get_ancestor_mpid(P) NULL
851
852#define sm_clear_all_rootcbs(P)
853
854#define sm_get_first_module(R) NULL
855
856#define sm_get_rootcb_for_mpid(P) NULL
857
858#define sm_setup_yanglib(R) ERR_NCX_OPERATION_NOT_SUPPORTED
859
860#define sm_get_first_anckey(M) NULL
861
862#define sm_get_next_anckey(M) NULL
863
864#endif // WITH_SCHEMA_MOUNT
status_t
global error return code
Definition: status_enum.h:210
ncx_name_match_t
Node name match modes.
Definition: ncxtypes.h:695
status_t sm_setup_yanglib(ncx_sm_rootcb_t *rootcb)
Setup the YANG library early because the get-sm-yanglib operation is enabled.
Definition: sm.c:2300
void sm_setup_cur_rootcb(ncx_sm_rootcb_t *rootcb)
setup NCX library to use the rootCB for schema mount
Definition: sm.c:959
void sm_cleanup(void)
Cleanup Schema Mount handler.
Definition: sm.c:393
ncx_sm_rootcb_t * sm_save_rootcb(obj_template_t *obj, const xmlChar *label)
Set the with_schema_mount value.
Definition: sm.c:1651
ncx_sm_mpid_t * sm_clone_mpid(const ncx_sm_mpid_t *mpid, val_value_t *valroot)
Clone an existing MPID.
Definition: sm.c:1248
val_value_t * sm_mpid_to_val(ncx_sm_mpid_t *mpid, obj_template_t *mpidobj, boolean preserve, status_t *res)
Convert a "mpid" struct to a YANG container.
Definition: sm.c:2043
ncx_module_t * sm_find_module(ncx_sm_rootcb_t *rootcb, const xmlChar *modname, const xmlChar *revision)
Find an ncx_module_t in the rootcb->modQ.
Definition: sm.c:553
status_t sm_activate_mpid(ncx_sm_rootcb_t *rootcb, ncx_sm_mpid_t *mpid)
Setup a new MPID.
Definition: sm.c:1601
obj_template_t * sm_find_any_object(ncx_sm_rootcb_t *rootcb, const xmlChar *objname)
Check if an obj_template_t is in any module that matches the object name string.
Definition: sm.c:709
void sm_dump_all_rootcb(void)
Print the interesting fields in all rootcbs.
Definition: sm.c:513
ncx_module_t * sm_get_last_module(ncx_sm_rootcb_t *rootcb)
Get the last module from Root Control Block.
Definition: sm.c:1776
void sm_init_yanglib_cb(ncx_yanglib_cb_t *cb)
Init a YANG Library control block struct.
Definition: sm.c:993
ncx_module_t * sm_find_module_allroots(const xmlChar *modname, const xmlChar *revision, boolean withdev)
Find an ncx_module_t in the any rootcb.
Definition: sm.c:633
uint32 sm_mod_revision_count_allroots(xml_msg_hdr_t *msg, const xmlChar *modname)
get the module revision count for all rootcbs
Definition: sm.c:2271
ncx_sm_mpid_t * sm_get_first_mpid(ncx_sm_rootcb_t *rootcb)
Get the first MPID struct in the rootcb.
Definition: sm.c:1553
void sm_dump_mpid(const ncx_sm_mpid_t *mpid)
Dump the contents of a MPID struct if DEBUG.
Definition: sm.c:1188
void sm_init(void)
Initialize Schema Mount handler.
Definition: sm.c:378
ncx_sm_rootcb_t * sm_get_rootcb_for_mpid(ncx_sm_mpid_t *mpid)
Get the rootcb for an MPID.
Definition: sm.c:2217
ncx_module_t * sm_get_first_module(ncx_sm_rootcb_t *rootcb)
Get first module from Root Control Block.
Definition: sm.c:1750
ncx_sm_mpid_t * sm_get_ancestor_mpid(val_value_t *val)
Get the MPID for the specified mounted node.
Definition: sm.c:1455
ncx_sm_rootcb_t * sm_find_rootcb(const xmlChar *label, const xmlChar *modname)
Find a Mount Point Control Block Entry in the rootcbQ.
Definition: sm.c:1683
void sm_free_mpid(ncx_sm_mpid_t *mpid)
free a malloced Mount Point ID control block
Definition: sm.c:1066
obj_template_t * sm_first_mounted_obj(ncx_sm_rootcb_t *rootcb, boolean augment_ok)
Find the first data node.
Definition: sm.c:744
void sm_show_rootcb(ncx_sm_rootcb_t *rootcb)
Print the interesting fields in Root Control block for yangcli report capabilities.
Definition: sm.c:494
void sm_free_rootcb(ncx_sm_rootcb_t *rootcb)
Free a ncx_sm_rootcb_t Control Block record.
Definition: sm.c:1706
obj_template_t * sm_next_mounted_obj(obj_template_t *curobj, boolean augment_ok)
Find the next data node.
Definition: sm.c:776
uint32 sm_mod_revision_count(xml_msg_hdr_t *msg, ncx_sm_rootcb_t *rootcb, const xmlChar *modname)
get the module revision count for one rootcb
Definition: sm.c:2244
void sm_clean_yanglib_cb(ncx_yanglib_cb_t *cb)
Clean a YANG Library control block struct.
Definition: sm.c:1008
void sm_clear_all_rootcbs(dlq_hdr_t *saveQ)
Retrieve all the rootcb entries or clear the rootcbQ.
Definition: sm.c:1876
ncx_module_t * sm_find_deviation(ncx_sm_rootcb_t *rootcb, const xmlChar *modname, const xmlChar *revision)
Find an ncx_module_t in the rootcb->devQ;.
Definition: sm.c:606
val_value_t * sm_get_next_anckey(const val_value_t *curkey)
Get next ancestor key from the MPID.
Definition: sm.c:2194
status_t sm_find_mpidval_from_input(val_value_t *chval, val_value_t **mpidval)
Get the MPID value node from the parsed val_value_t tree prepresenting the ancestors of the action or...
Definition: sm.c:1346
val_value_t * sm_get_mpi_valroot(val_value_t *val)
Get the current value root value.
Definition: sm.c:1395
ncx_sm_mpid_t * sm_get_mpid_from_msg(rpc_msg_t *msg)
Get the MPID struct from the message header if set.
Definition: sm.c:1317
status_t sm_patch_notif_keyQ(const ncx_sm_mpid_t *mpid, dlq_hdr_t *keyQ)
Patch the keyQ for a notification to prepend the SM ancestor keys to the queue.
Definition: sm.c:1515
status_t sm_setup_mpid(xml_msg_hdr_t *msg, val_value_t *val, obj_template_t *obj)
Set Up ancestor keys and yanglib for the current MPI.
Definition: sm.c:1108
void sm_register_yanglib_cbfn(sm_yanglib_cbfn_t cbfn)
register a yanglib_cb setup callback
Definition: sm.c:1028
val_value_t * sm_get_first_anckey(const ncx_sm_mpid_t *mpid)
Get first ancestor key from the MPID.
Definition: sm.c:2174
obj_template_t * sm_find_child_obj(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname, ncx_name_match_t match_names, boolean alt_names, boolean dataonly, status_t *retres)
Find the previous data node.
Definition: sm.c:911
ncx_sm_mpid_t * sm_val_to_mpid(val_value_t *mpidval, boolean preserve, status_t *res)
Convert a "mpid" YANG container to an MPID value.
Definition: sm.c:1949
void sm_dump_rootcb(ncx_sm_rootcb_t *rootcb)
Print the interesting fields in Root Control block Must be debug for some info, debug4 for full info.
Definition: sm.c:473
obj_template_t * sm_prev_mounted_obj(obj_template_t *curobj, boolean augment_ok)
Find the previous data node.
Definition: sm.c:860
obj_template_t * sm_last_mounted_obj(ncx_sm_rootcb_t *rootcb, boolean augment_ok)
Find the first data node.
Definition: sm.c:827
ncx_sm_mpid_t * sm_new_mpid(void)
Malloc and initialize an MPID struct.
Definition: sm.c:1041
ncx_sm_mpid_t * sm_get_next_mpid(ncx_sm_mpid_t *curmpid)
Get the next MPID struct in the rootcb.
Definition: sm.c:1574
ncx_sm_rootcb_t * sm_search_rootcbs(dlq_hdr_t *searchQ, sm_rootcb_searchfn_t searchfn, void *cookie)
search all the rootcbs in the specified queue
Definition: sm.c:1832
YANG module data structures Many internal representations of YANG module constructs.
Data Object Support.
status_t(* sm_yanglib_cbfn_t)(ncx_sm_rootcb_t *rootcb)
yang library SIL code callback to setup a yanglib_cb
Definition: sm.h:97
boolean(* sm_rootcb_searchfn_t)(ncx_sm_rootcb_t *rootcb, void *cookie)
ROOTCB Search Callback Function.
Definition: sm.h:112
global error status code enumerations
representation of one module or submodule during and after parsing
Definition: ncxtypes.h:1134
Moint Point Instance This struct lives in a val_value_t.val_extra struct.
Definition: ncxtypes.h:1811
Schema Mount Root Control Block used in the object template.
Definition: ncxtypes.h:1889
one context for a yang library.
Definition: ncxtypes.h:1859
One YANG data-def-stmt.
Definition: obj.h:1220
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
one value to match one type
Definition: val.h:912
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:397