yumapro  24.10-11
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 - 2025, 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
97typedef status_t
98 (*sm_yanglib_cbfn_t) (ncx_sm_rootcb_t *rootcb);
99
100
101
113typedef boolean
114 (*sm_rootcb_searchfn_t) (ncx_sm_rootcb_t *rootcb,
115 void *cookie);
116
117
118/********************************************************************
119* *
120* F U N C T I O N S *
121* *
122*********************************************************************/
123
136extern void sm_init (void);
137
138
143extern void
144 sm_cleanup (void);
145
146
155extern void
157
158
167extern void
169
170
175extern void
176 sm_dump_all_rootcb (void);
177
178
191extern ncx_module_t *
193 const xmlChar *modname,
194 const xmlChar *revision);
195
196
197/*
198* @brief Find an ncx_module_t in the rootcb->modQ by prefix
199*
200* rootcb->modQ These are the modules that are already loaded
201* into Mount Point
202*
203* @param rootcb control block to use
204* @param prefix name
205*
206* @return module pointer if found or NULL if not
207*/
208extern ncx_module_t *
209 sm_find_module_by_prefix (ncx_sm_rootcb_t *rootcb,
210 const xmlChar *prefix);
211
212
225extern ncx_module_t *
227 const xmlChar *deviname,
228 const xmlChar *revision);
229
230
242extern ncx_module_t *
243 sm_find_module_allroots (const xmlChar *modname,
244 const xmlChar *revision,
245 boolean withdev);
246
247
248/*
249* @brief Find an ncx_module_t in the any rootcb
250* CHECK submodules allowed
251* Will return the first match or NULL if no match
252* @param modname module name
253* @param revision module revision date
254* @param withdev TRUE to check deviation modules as well
255* @param withsubmod TRUE to check submodules and modules
256* @return module pointer if found or NULL if not
257*/
258extern ncx_module_t *
259 sm_find_module_allroots2 (const xmlChar *modname,
260 const xmlChar *revision,
261 boolean withdev,
262 boolean withsubmod);
263
264
274extern obj_template_t *
276 const xmlChar *objname);
277
278
290extern obj_template_t *
292 boolean augment_ok);
293
294
306extern obj_template_t *
308 boolean augment_ok);
309
310
321extern obj_template_t *
323 boolean augment_ok);
324
325
337extern obj_template_t *
339 boolean augment_ok);
340
341
364extern obj_template_t *
366 const xmlChar *modname,
367 const xmlChar *objname,
368 ncx_name_match_t match_names,
369 boolean alt_names,
370 boolean dataonly,
371 status_t *retres);
372
373
380extern void
382
383
390extern void
392
393
400extern void
402
403
409extern void
410 sm_register_yanglib_cbfn (sm_yanglib_cbfn_t cbfn);
411
412
419extern ncx_sm_mpid_t *
420 sm_new_mpid (void);
421
422
428extern void
430
431
442extern status_t
444 val_value_t *val,
445 obj_template_t *obj);
446
447
457extern void
458 sm_dump_mpid (const ncx_sm_mpid_t *mpid);
459
460
470extern ncx_sm_mpid_t *
471 sm_clone_mpid (const ncx_sm_mpid_t *mpid,
472 val_value_t *valroot);
473
474
486extern ncx_sm_mpid_t *
488
489
502extern status_t
504 val_value_t **mpidval);
505
506
507
516extern val_value_t *
518
519
520
530extern ncx_sm_mpid_t *
532
533
544extern status_t
546 dlq_hdr_t *keyQ);
547
548
555extern ncx_sm_mpid_t *
557
564extern ncx_sm_mpid_t *
566
567
578extern status_t
580 ncx_sm_mpid_t *mpid);
581
582
583
594extern ncx_sm_rootcb_t *
595 sm_search_rootcbs (dlq_hdr_t *searchQ,
596 sm_rootcb_searchfn_t searchfn,
597 void *cookie);
598
607extern ncx_sm_rootcb_t *
609 const xmlChar *label);
610
611
620extern ncx_sm_rootcb_t *
621 sm_find_rootcb (const xmlChar *label,
622 const xmlChar *modname);
623
624
630extern void
632
633
640extern ncx_module_t *
642
643
650extern ncx_module_t *
652
653
654/*
655* @brief Get the specific Mount Point Label
656*
657* @param mod module that is inside this Mount Point
658*/
659extern const xmlChar *
660 sm_get_current_mp_label (ncx_module_t *mod);
661
662
673extern void
674 sm_clear_all_rootcbs (dlq_hdr_t *saveQ);
675
676
697extern ncx_sm_mpid_t *
698 sm_val_to_mpid (val_value_t *mpidval,
699 boolean preserve,
700 status_t *res);
701
702
725extern val_value_t *
727 obj_template_t *mpidobj,
728 boolean preserve,
729 status_t *res);
730
731
738extern val_value_t *
740
741
742
749extern val_value_t *
750 sm_get_next_anckey (const val_value_t *curkey);
751
752
753
762extern ncx_sm_rootcb_t *
764
765
776extern uint32
778 ncx_sm_rootcb_t *rootcb,
779 const xmlChar *modname);
780
781
782
792extern uint32
794 const xmlChar *modname);
795
796
804extern status_t
806
807
810#ifdef __cplusplus
811} /* end extern 'C' */
812#endif
813
814#endif /* _H_sm */
815
816#else
817
818#define sm_dump_rootcb(R)
819
820#define sm_show_rootcb(R)
821
822#define sm_dump_all_rootcb()
823
824#define sm_find_module(A,B,C) NULL
825
826#define sm_find_deviation(A,B,C) NULL
827
828#define sm_find_module_allroots(A,B,C) NULL
829
830#define sm_find_any_object(A,B) NULL
831
832#define sm_first_mounted_obj(R,B) NULL
833
834#define sm_next_mounted_obj(C,B) NULL
835
836#define sm_last_mounted_obj(C,B) NULL
837
838#define sm_prev_mounted_obj(C,B) NULL
839
840#define sm_setup_cur_rootcb(P)
841
842#define sm_free_mpid(A)
843
844#define sm_dump_mpid(M)
845
846#define sm_clone_mpid(M,V) NULL
847
848#define sm_get_mpid_from_msg(M) NULL
849
850#define sm_get_mpi_valroot(P) NULL
851
852#define sm_get_ancestor_mpid(P) NULL
853
854#define sm_clear_all_rootcbs(P)
855
856#define sm_get_first_module(R) NULL
857
858#define sm_get_rootcb_for_mpid(P) NULL
859
860#define sm_setup_yanglib(R) ERR_NCX_OPERATION_NOT_SUPPORTED
861
862#define sm_get_first_anckey(M) NULL
863
864#define sm_get_next_anckey(M) NULL
865
866#endif // WITH_SCHEMA_MOUNT
status_t
global error return code
Definition: status_enum.h:219
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:2323
void sm_setup_cur_rootcb(ncx_sm_rootcb_t *rootcb)
setup NCX library to use the rootCB for schema mount
Definition: sm.c:971
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:1663
ncx_sm_mpid_t * sm_clone_mpid(const ncx_sm_mpid_t *mpid, val_value_t *valroot)
Clone an existing MPID.
Definition: sm.c:1260
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:2055
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:1613
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:721
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:1788
void sm_init_yanglib_cb(ncx_yanglib_cb_t *cb)
Init a YANG Library control block struct.
Definition: sm.c:1005
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:645
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:2294
ncx_sm_mpid_t * sm_get_first_mpid(ncx_sm_rootcb_t *rootcb)
Get the first MPID struct in the rootcb.
Definition: sm.c:1565
void sm_dump_mpid(const ncx_sm_mpid_t *mpid)
Dump the contents of a MPID struct if DEBUG.
Definition: sm.c:1200
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:2229
ncx_module_t * sm_get_first_module(ncx_sm_rootcb_t *rootcb)
Get first module from Root Control Block.
Definition: sm.c:1762
ncx_sm_mpid_t * sm_get_ancestor_mpid(val_value_t *val)
Get the MPID for the specified mounted node.
Definition: sm.c:1467
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:1695
void sm_free_mpid(ncx_sm_mpid_t *mpid)
free a malloced Mount Point ID control block
Definition: sm.c:1078
obj_template_t * sm_first_mounted_obj(ncx_sm_rootcb_t *rootcb, boolean augment_ok)
Find the first data node.
Definition: sm.c:756
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:1718
obj_template_t * sm_next_mounted_obj(obj_template_t *curobj, boolean augment_ok)
Find the next data node.
Definition: sm.c:788
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:2256
void sm_clean_yanglib_cb(ncx_yanglib_cb_t *cb)
Clean a YANG Library control block struct.
Definition: sm.c:1020
void sm_clear_all_rootcbs(dlq_hdr_t *saveQ)
Retrieve all the rootcb entries or clear the rootcbQ.
Definition: sm.c:1888
val_value_t * sm_get_next_anckey(const val_value_t *curkey)
Get next ancestor key from the MPID.
Definition: sm.c:2206
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:1358
ncx_module_t * sm_find_deviation(ncx_sm_rootcb_t *rootcb, const xmlChar *deviname, const xmlChar *revision)
Find an ncx_module_t in the rootcb->devQ;.
Definition: sm.c:606
val_value_t * sm_get_mpi_valroot(val_value_t *val)
Get the current value root value.
Definition: sm.c:1407
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:1329
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:1527
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:1120
void sm_register_yanglib_cbfn(sm_yanglib_cbfn_t cbfn)
register a yanglib_cb setup callback
Definition: sm.c:1040
val_value_t * sm_get_first_anckey(const ncx_sm_mpid_t *mpid)
Get first ancestor key from the MPID.
Definition: sm.c:2186
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:923
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:1961
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:872
obj_template_t * sm_last_mounted_obj(ncx_sm_rootcb_t *rootcb, boolean augment_ok)
Find the first data node.
Definition: sm.c:839
ncx_sm_mpid_t * sm_new_mpid(void)
Malloc and initialize an MPID struct.
Definition: sm.c:1053
ncx_sm_mpid_t * sm_get_next_mpid(ncx_sm_mpid_t *curmpid)
Get the next MPID struct in the rootcb.
Definition: sm.c:1586
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:1844
YANG module data structures Many internal representations of YANG module constructs.
Data Object Support.
global error status code enumerations
representation of one module or submodule during and after parsing
Definition: ncxtypes.h:1138
Moint Point Instance This struct lives in a val_value_t.val_extra struct.
Definition: ncxtypes.h:1815
Schema Mount Root Control Block used in the object template.
Definition: ncxtypes.h:1893
one context for a yang library.
Definition: ncxtypes.h:1863
One YANG data-def-stmt.
Definition: obj.h:1232
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:185
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:404