yumapro  20.10-12
YumaPro SDK
cfg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, 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 #ifndef _H_cfg
13 #define _H_cfg
14 /* FILE: cfg.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
85 /*********************************************************************
86 * *
87 * C H A N G E H I S T O R Y *
88 * *
89 *********************************************************************
90 
91 date init comment
92 ----------------------------------------------------------------------
93 15-apr-06 abb Begun.
94 29-may-08 abb Converted NCX database model to simplified
95  YANG object model
96 */
97 #include <xmlstring.h>
98 
99 #ifndef _H_dlq
100 #include "dlq.h"
101 #endif
102 
103 #ifndef _H_ncx
104 #include "ncx.h"
105 #endif
106 
107 #ifndef _H_ncxconst
108 #include "ncxconst.h"
109 #endif
110 
111 #ifndef _H_plock
112 #include "plock.h"
113 #endif
114 
115 #ifndef _H_ses
116 #include "ses.h"
117 #endif
118 
119 #ifndef _H_status
120 #include "status.h"
121 #endif
122 
123 #ifndef _H_val
124 #include "val.h"
125 #endif
126 
127 #ifndef _H_val_util
128 #include "val_util.h"
129 #endif
130 
131 #ifndef _H_thd
132 #include "thd.h"
133 #endif
134 
135 #ifdef __cplusplus
136 extern "C" {
137 #endif
138 
139 /********************************************************************
140 * *
141 * C O N S T A N T S *
142 * *
143 *********************************************************************/
144 
145 /* bit definitions for the cfg_template->flags field */
146 #define CFG_FL_TARGET bit0
147 #define CFG_FL_DIRTY bit1
148 #define CFG_FL_FORCE_DEADNODES bit2
149 #define CFG_FL_FORCE_TOP_DEFAULTS bit3
150 #define CFG_FL_EXTERN_NVSTORE bit4
151 
152 #define CFG_INITIAL_TXID (ncx_transaction_id_t)0
153 
154 /* this must match the number of enums in ncx_cfg_t (NCX_CFGID_CNT) */
155 #define CFG_NUM_STATIC 3
156 
157 #define CFG_GET_FORCE_DEADNODES(C) ((C)->flags & CFG_FL_FORCE_DEADNODES)
158 
159 #define CFG_SET_FORCE_DEADNODES(C) (C)->flags |= CFG_FL_FORCE_DEADNODES
160 
161 #define CFG_GET_FORCE_TOP_DEFAULTS(C) ((C)->flags & CFG_FL_FORCE_TOP_DEFAULTS)
162 
163 #define CFG_SET_FORCE_TOP_DEFAULTS(C) (C)->flags |= CFG_FL_FORCE_TOP_DEFAULTS
164 
165 
166 #define CFG_SET_EXTERN_NVSTORE(C) (C)->flags |= CFG_FL_EXTERN_NVSTORE
167 
168 #define CFG_IS_EXTERN_NVSTORE(C) ((C)->flags & CFG_FL_EXTERN_NVSTORE)
169 
170 /*
171  * Define constants for use with cfg_rwlock_acquire_xxx() functions
172  * and data structures:
173  */
174 
175 #define CFG_RWLOCK_READ_ACCESS FALSE
176 #define CFG_RWLOCK_WRITE_ACCESS TRUE
177 #define READ_ACCESS CFG_RWLOCK_READ_ACCESS
178 #define WRITE_ACCESS CFG_RWLOCK_WRITE_ACCESS
179 
180 #define CFG_GET_ROOT(C) ((C)->root)
181 
182 #define CFG_GET_ID(C) ((C)->cfg_id)
183 
184 
185 /********************************************************************
186 * *
187 * T Y P E S *
188 * *
189 *********************************************************************/
190 
191 
192 
194 typedef enum cfg_state_t_ {
195  CFG_ST_NONE,
196  CFG_ST_INIT,
197  CFG_ST_READY,
198  CFG_ST_PLOCK,
201 } cfg_state_t;
202 
203 
205 typedef enum cfg_source_t_ {
206  CFG_SRC_NONE,
207  CFG_SRC_INTERNAL,
208  CFG_SRC_NETCONF,
209  CFG_SRC_CLI,
210  CFG_SRC_SNMP,
211  CFG_SRC_HTTP,
212  CFG_SRC_OTHER
213 } cfg_source_t;
214 
215 
217 typedef enum cfg_location_t_ {
218  CFG_LOC_NONE,
219  CFG_LOC_FILE,
220  CFG_LOC_REMOTE_URL
221 } cfg_location_t;
222 
223 
225 typedef struct cfg_template_t_ {
227  ncx_cfg_t cfg_id;
228 
230  cfg_location_t cfg_loc;
231 
233  cfg_state_t cfg_state;
234 
237 
240 
243 
245  xmlChar *name;
246 
248  xmlChar *src_url;
249 
252 
254  xmlChar last_ch_time[TSTAMP_MIN_SIZE]; // TBD: remove!
255 
257  uint32 flags;
258 
261 
262  /* source of the config lock */
263  cfg_source_t lock_src;
264 
265  dlq_hdr_t load_errQ;
266  dlq_hdr_t plockQ;
274  pthread_rwlock_t rwlock;
281  boolean rw_wrlocked;
282  boolean rw_rdlocked;
285  boolean wrlock_pending;
286 
288  val_value_t *root;
291  boolean fake_candidate;
292 
293 } cfg_template_t;
294 
298 typedef void (*cfg_reload_candidate_cb_t) (void);
299 
300 
301 
302 /********************************************************************
303 * *
304 * V A R I A B L E S *
305 * *
306 *********************************************************************/
307 
308 #ifdef PTHREADS
309 extern boolean wrlock_pending;
310 #endif
311 
312 /********************************************************************
313 * *
314 * F U N C T I O N S *
315 * *
316 *********************************************************************/
317 
318 
326 extern void
327  cfg_ypinit (void);
328 
329 
334 extern void
335  cfg_clean_roots (void);
336 
337 
342 extern void
343  cfg_cleanup (void);
344 
345 
346 
347 #ifdef PTHREADS
348 
356 extern status_t cfg_rwlock_rdlock (thd_tcb_t *tcb, cfg_template_t *cfg);
357 
358 
368 extern status_t cfg_rwlock_wrlock (thd_tcb_t *tcb, cfg_template_t *cfg);
369 
370 
380 extern status_t cfg_rwlock_unlock (thd_tcb_t *tcb, cfg_template_t *cfg);
381 
382 
392 extern status_t cfg_rwlock_init_req_locks (thd_tcb_t *tcb);
393 
394 
402 extern status_t cfg_rwlock_release_all_locks (thd_tcb_t *tcb);
403 
404 
411 extern status_t cfg_rwlock_acquire_locks (thd_tcb_t *tcb);
412 
413 
426 extern status_t
427  cfg_rwlock_acquire_lock_pair (thd_tcb_t *tcb,
428  cfg_template_t *cfg1,
429  boolean wrlock1,
430  cfg_template_t *cfg2,
431  boolean wrlock2);
432 
433 
444 extern status_t cfg_rwlock_acquire_single_lock (thd_tcb_t *tcb,
445  cfg_template_t *cfg,
446  boolean wrlock);
447 
448 
458 extern status_t
459  cfg_rwlock_acquire_single_rdlock (thd_tcb_t *tcb, cfg_template_t *cfg);
460 
461 
462 
472 extern status_t
473  cfg_rwlock_acquire_single_wrlock (thd_tcb_t *tcb, cfg_template_t *cfg);
474 
475 #endif // PTHREADS
476 
477 
484 extern status_t
485  cfg_init_static_db (ncx_cfg_t cfg_id);
486 
487 
497 extern cfg_template_t *
498  cfg_new_template (const xmlChar *name,
499  ncx_cfg_t cfg_id);
500 
501 
508 extern void
509  cfg_free_template (cfg_template_t *cfg);
510 
511 
518 extern void
519  cfg_set_state (ncx_cfg_t cfg_id,
520  cfg_state_t new_state);
521 
522 
529 extern cfg_state_t
530  cfg_get_state (ncx_cfg_t cfg_id);
531 
532 
539 extern cfg_template_t *
540  cfg_get_config (const xmlChar *cfgname);
541 
542 
549 extern const xmlChar *
550  cfg_get_config_name (ncx_cfg_t cfgid);
551 
552 
559 extern cfg_template_t *
560  cfg_get_config_id (ncx_cfg_t cfgid);
561 
562 
568 extern void
569  cfg_set_target (ncx_cfg_t cfg_id);
570 
571 
579 extern status_t
581 
582 
591 extern status_t
593 
594 
604 extern status_t
606  val_value_t *newroot);
607 
608 
615 extern void
616  cfg_set_dirty_flag (cfg_template_t *cfg);
617 
618 
625 void cfg_clear_dirty_flag (cfg_template_t *cfg);
626 
627 
633 extern void
635 
636 
642 extern void
644 
645 
652 extern boolean
653  cfg_get_dirty_flag (const cfg_template_t *cfg);
654 
655 
663 extern status_t
664  cfg_ok_to_lock (const cfg_template_t *cfg);
665 
666 
675 extern status_t
676  cfg_ok_to_unlock (const cfg_template_t *cfg,
677  ses_id_t sesid);
678 
679 
686 extern status_t
687  cfg_ok_to_read (const cfg_template_t *cfg);
688 
689 
701 extern status_t
702  cfg_ok_to_write (const cfg_template_t *cfg,
703  ses_id_t sesid);
704 
705 
712 extern boolean
713  cfg_is_global_locked (const cfg_template_t *cfg);
714 
715 
722 extern boolean
723  cfg_is_partial_locked (const cfg_template_t *cfg);
724 
725 
736 extern status_t
737  cfg_get_global_lock_info (const cfg_template_t *cfg,
738  ses_id_t *sesid,
739  const xmlChar **locktime);
740 
741 
754 extern status_t
755  cfg_lock (cfg_template_t *cfg,
756  ses_id_t locked_by,
757  cfg_source_t lock_src);
758 
759 
768 extern status_t
769  cfg_unlock (cfg_template_t *cfg,
770  ses_id_t locked_by);
771 
772 
785 extern status_t
786  cfg_unlock_ex (cfg_template_t *cfg,
787  ses_id_t locked_by,
788  boolean skip_reload);
789 
790 
797 extern void
798  cfg_release_locks (ses_id_t sesid);
799 
800 
807 extern void
809 
810 
819 extern void
821  val_value_t *retval);
822 
823 
830 extern void
831  cfg_apply_load_root (cfg_template_t *cfg,
832  val_value_t *newroot);
833 
834 
841 extern void
842  cfg_update_last_ch_time (cfg_template_t *cfg,
843  time_t *timestamp);
844 
845 
852 extern void
853  cfg_update_last_txid (cfg_template_t *cfg,
854  ncx_transaction_id_t txid);
855 
856 
863 extern void
864  cfg_update_stamps (cfg_template_t *source,
865  cfg_template_t *dest);
866 
867 
874 extern const xmlChar *
875  cfg_get_last_ch_time (cfg_template_t *cfg);
876 
877 
885  cfg_get_last_txid (cfg_template_t *cfg);
886 
887 
897 extern status_t
898  cfg_sprintf_etag (cfg_template_t *cfg,
899  xmlChar *buff,
900  int32 buffsize);
901 
902 
913 extern status_t
915  xmlChar *buff,
916  int32 buffsize);
917 
918 
933 extern status_t
934  cfg_add_partial_lock (cfg_template_t *cfg,
935  plock_cb_t *plcb);
936 
937 
946 extern plock_cb_t *
947  cfg_find_partial_lock (cfg_template_t *cfg,
948  plock_id_t lockid);
949 
950 
958 extern plock_cb_t *
959  cfg_first_partial_lock (cfg_template_t *cfg);
960 
961 
969 extern plock_cb_t *
970  cfg_next_partial_lock (plock_cb_t *curplockcb);
971 
972 
979 extern void
980  cfg_delete_partial_lock (cfg_template_t *cfg,
981  plock_id_t lockid);
982 
983 
991 extern status_t
992  cfg_ok_to_partial_lock (const cfg_template_t *cfg);
993 
994 
1001 extern val_value_t *
1002  cfg_get_root (ncx_cfg_t cfgid);
1003 
1004 
1011 extern status_t
1012  cfg_setup_running (void);
1013 
1014 
1023 extern void
1025 
1026 
1032 extern const xmlChar *
1033  cfg_get_startup_filespec (void);
1034 
1035 
1036 #ifdef PTHREADS
1037 
1042 extern boolean
1043  cfg_running_is_wrlocked (void);
1044 
1045 
1051 extern boolean
1053 
1054 #endif // PTHREADS
1055 
1056 
1065 extern cfg_template_t *
1066  cfg_new_fake_candidate (const xmlChar *name,
1067  ncx_cfg_t cfg_id);
1068 
1069 
1070 
1073 #ifdef __cplusplus
1074 } /* end extern 'C' */
1075 #endif
1076 
1077 #endif /* _H_cfg */
CFG_ST_NONE
@ CFG_ST_NONE
not set
Definition: cfg.h:199
cfg_rwlock_acquire_single_rdlock
status_t cfg_rwlock_acquire_single_rdlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Acquire a single RWLOCK for read access.
Definition: cfg.c:957
ses.h
NETCONF Session Common definitions module.
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
cfg_unlock
status_t cfg_unlock(cfg_template_t *cfg, ses_id_t locked_by)
Unlock the specified config.
Definition: cfg.c:2565
cfg.h
cfg_get_lock_list
void cfg_get_lock_list(ses_id_t sesid, val_value_t *retval)
Get a list of all the locks held by a session.
Definition: cfg.c:2744
cfg_template_t_::cfg_loc
cfg_location_t cfg_loc
config location
Definition: cfg.h:230
plock_get_sid
uint32 plock_get_sid(plock_cb_t *plcb)
Get the session ID holding this partial lock.
Definition: plock.c:153
cfg_rwlock_acquire_lock_pair
status_t cfg_rwlock_acquire_lock_pair(thd_tcb_t *tcb, cfg_template_t *cfg1, boolean wrlock1, cfg_template_t *cfg2, boolean wrlock2)
Acquire multiple (2) locks in predetermined, repeatable in order to help prevent deadlock.
Definition: cfg.c:839
cfg_rwlock_rdlock
status_t cfg_rwlock_rdlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Take out the read lock associated with a cfg (datastore) RWLOCK structure May be called recursively.
Definition: cfg.c:256
cfg_ok_to_write
status_t cfg_ok_to_write(const cfg_template_t *cfg, ses_id_t sesid)
Check if the specified config can be written right now by the specified session ID.
Definition: cfg.c:2286
tstamp.h
Timestamp utilities.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
cfg_template_t_::rw_rdlocked
boolean rw_rdlocked
readlocked flag
Definition: cfg.h:282
cfg_template_t_::wrlock_pending
boolean wrlock_pending
TRUE if the wrlock is active and set.
Definition: cfg.h:285
cfg_template_t_::last_txid
ncx_transaction_id_t last_txid
last transaction ID
Definition: cfg.h:236
cfg_rwlock_acquire_single_wrlock
status_t cfg_rwlock_acquire_single_wrlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Acquire a single RWLOCK for write access.
Definition: cfg.c:978
cfg_ok_to_lock
status_t cfg_ok_to_lock(const cfg_template_t *cfg)
Check if the specified config can be locked right now for global lock only.
Definition: cfg.c:2097
cfg_candidate_is_wrlocked
boolean cfg_candidate_is_wrlocked(void)
Check if the candidate datastore is currently pthreads write-locked.
Definition: cfg.c:3363
cfg_update_last_ch_time
void cfg_update_last_ch_time(cfg_template_t *cfg, time_t *timestamp)
Update the last-modified timestamp.
Definition: cfg.c:2824
plock.h
RFC 57517 partial lock support.
cfg_template_t_::cur_txid
ncx_transaction_id_t cur_txid
current transaction ID
Definition: cfg.h:239
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
cfg_new_template
cfg_template_t * cfg_new_template(const xmlChar *name, ncx_cfg_t cfg_id)
Malloc and initialize a cfg_template_t struct.
Definition: cfg.c:1344
cfg_state_t_
cfg_state_t_
current configuration state
Definition: cfg.h:194
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.
val_clear_partial_lock
void val_clear_partial_lock(val_value_t *val, plock_cb_t *plcb)
Clear the partial lock throughout the value tree.
Definition: val_util.c:5710
xml_util.h
XML Utilities.
cfg_release_partial_locks
void cfg_release_partial_locks(ses_id_t sesid)
Release any configuration locks held by the specified session.
Definition: cfg.c:2690
cfg_apply_load_root
void cfg_apply_load_root(cfg_template_t *cfg, val_value_t *newroot)
Apply the AGT_CB_APPLY function for the OP_EDITOP_LOAD operation.
Definition: cfg.c:2794
cfg_template_t_
struct representing 1 configuration database
Definition: cfg.h:225
cfg_template_t_::rw_wrlocked
boolean rw_wrlocked
if the background thread locks the cfg for fill_candidate_from_running or other reason then the SID w...
Definition: cfg.h:281
cfg_rwlock_init_req_locks
status_t cfg_rwlock_init_req_locks(thd_tcb_t *tcb)
Initialize TCB multiple lock structure.
Definition: cfg.c:638
cfg_delete_partial_lock
void cfg_delete_partial_lock(cfg_template_t *cfg, plock_id_t lockid)
Remove a partial lock from the specified config.
Definition: cfg.c:3129
ncx_num.h
NCX Module Library Number Utility Functions.
cfg_location_t_
cfg_location_t_
classify the config location
Definition: cfg.h:217
cfg_release_locks
void cfg_release_locks(ses_id_t sesid)
Release any configuration locks held by the specified session.
Definition: cfg.c:2632
val_clone2
val_value_t * val_clone2(const val_value_t *val)
Clone a specified val_value_t struct and sub-trees but not the editvars.
Definition: val.c:7865
cfg_template_t_::name
xmlChar * name
config name string
Definition: cfg.h:245
cfg_template_t_::rwlock
pthread_rwlock_t rwlock
rwlock data
Definition: cfg.h:274
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
cfg_set_target
void cfg_set_target(ncx_cfg_t cfg_id)
Set the CFG_FL_TARGET flag in the specified config.
Definition: cfg.c:1551
cfg_get_dirty_flag
boolean cfg_get_dirty_flag(const cfg_template_t *cfg)
Get the config dirty flag value.
Definition: cfg.c:2066
cfg_template_t_::flags
uint32 flags
internal flags
Definition: cfg.h:257
cfg_get_state
cfg_state_t cfg_get_state(ncx_cfg_t cfg_id)
Get the state of the specified static config.
Definition: cfg.c:1439
plock_cb_free
void plock_cb_free(plock_cb_t *plcb)
Free a partial lock control block.
Definition: plock_cb.c:185
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
cfg_running_is_wrlocked
boolean cfg_running_is_wrlocked(void)
Check if the running datastore is currently pthreads write-locked.
Definition: cfg.c:3343
ses_id_t
uint32 ses_id_t
Session ID.
Definition: ses.h:306
cfg_template_t_::rwlock_initialized
boolean rwlock_initialized
RWLOCK for this config - used by multiple reader/writer threads according to RWLOCK rules: basically,...
Definition: cfg.h:273
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
cfg_get_last_ch_time
const xmlChar * cfg_get_last_ch_time(cfg_template_t *cfg)
Get the last-modified timestamp.
Definition: cfg.c:2896
cfg_get_startup_filespec
const xmlChar * cfg_get_startup_filespec(void)
Get the filespec string for the XML file to save the running database.
Definition: cfg.c:3322
cfg_init_static_db
status_t cfg_init_static_db(ncx_cfg_t cfg_id)
Initialize the specified static configuration slot.
Definition: cfg.c:1287
cfg_template_t_::fake_candidate
boolean fake_candidate
TRUE if this is YANG-PATCH request fake candidate template.
Definition: cfg.h:291
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
cfg_rwlock_release_all_locks
status_t cfg_rwlock_release_all_locks(thd_tcb_t *tcb)
Release all RWLOCKs recorded in TCB lock state structure.
Definition: cfg.c:675
ncx_find_object
obj_template_t * ncx_find_object(ncx_module_t *mod, const xmlChar *objname)
Find a top level module object.
Definition: ncx.c:4345
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
cfg_get_config
cfg_template_t * cfg_get_config(const xmlChar *cfgname)
Get the config struct from its name.
Definition: cfg.c:1468
cfg_sprintf_etag
status_t cfg_sprintf_etag(cfg_template_t *cfg, xmlChar *buff, int32 buffsize)
Write the Entity Tag for the datastore to the specified buffer.
Definition: cfg.c:2936
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
cfg_clear_running_dirty_flag
void cfg_clear_running_dirty_flag(void)
Clear the running dirty flag when it is saved to NV-storage or loaded into running from startup.
Definition: cfg.c:2024
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
heapchk.h
Internal Heap Checking Utilities.
ERR_NCX_CANDIDATE_DIRTY
@ ERR_NCX_CANDIDATE_DIRTY
367
Definition: status_enum.h:410
dlq_remove
void dlq_remove(void *nodeP)
remove the queue entry from its queue list entry MUST have been enqueued somehow before this function...
Definition: dlq.c:519
cfg_template_t_::plockQ
dlq_hdr_t plockQ
Q of plock_cb_t.
Definition: cfg.h:266
cfg_rwlock_wrlock
status_t cfg_rwlock_wrlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Take out a write lock associated with a cfg (datastore) RWLOCK structure.
Definition: cfg.c:375
val_util.h
Value Node Utilities.
cfg_template_t_::rw_rdlocked_by
ses_id_t rw_rdlocked_by
Note: Most recent read lock holder only ...
Definition: cfg.h:276
cfg_template_t_::rw_wrlocked_by
ses_id_t rw_wrlocked_by
Single write lock holder, if any.
Definition: cfg.h:275
NCX_CFGID_CANDIDATE
@ NCX_CFGID_CANDIDATE
candidate datastore
Definition: ncxtypes.h:385
cfg_template_t_::root
val_value_t * root
datastore root value
Definition: cfg.h:288
NCX_CFGID_STARTUP
@ NCX_CFGID_STARTUP
startup datastore
Definition: ncxtypes.h:386
cfg_is_global_locked
boolean cfg_is_global_locked(const cfg_template_t *cfg)
Check if the specified config has ab active global lock.
Definition: cfg.c:2403
cfg_next_partial_lock
plock_cb_t * cfg_next_partial_lock(plock_cb_t *curplockcb)
Get the next partial lock in the specified config.
Definition: cfg.c:3103
rpc.h
NETCONF protocol remote procedure call common definitions.
plock_get_id
plock_id_t plock_get_id(plock_cb_t *plcb)
Get the lock ID for this partial lock.
Definition: plock.c:127
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
cfg_source_t_
cfg_source_t_
classify the config source
Definition: cfg.h:205
cfg_sprintf_etag_id
status_t cfg_sprintf_etag_id(ncx_transaction_id_t id, xmlChar *buff, int32 buffsize)
Write the Entity Tag for the datastore to the specified buffer Use the last_id instead of the cfg tem...
Definition: cfg.c:2961
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
cfg_template_t_::locked_by
ses_id_t locked_by
session ID that has the datastore locked
Definition: cfg.h:260
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
tstamp_time2datetime
void tstamp_time2datetime(time_t *timerec, xmlChar *buff)
Convert the specified time_t to a YANG data-and-time format.
Definition: tstamp.c:457
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
cfg_find_partial_lock
plock_cb_t * cfg_find_partial_lock(cfg_template_t *cfg, plock_id_t lockid)
Find a partial lock in the specified config.
Definition: cfg.c:3038
rpc_err_free_record
void rpc_err_free_record(rpc_err_rec_t *err)
Clean and free an rpc_err_rec_t struct.
Definition: rpc_err.c:346
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
cfg_set_state
void cfg_set_state(ncx_cfg_t cfg_id, cfg_state_t new_state)
Change the state of the specified static config.
Definition: cfg.c:1409
cfg_unlock_ex
status_t cfg_unlock_ex(cfg_template_t *cfg, ses_id_t locked_by, boolean skip_reload)
Unlock the specified config.
Definition: cfg.c:2586
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
ncx_new_lmem
ncx_lmem_t * ncx_new_lmem(void)
Malloc and fill in a new ncx_lmem_t struct.
Definition: ncx_list.c:952
cfg_template_t_::src_url
xmlChar * src_url
source URL
Definition: cfg.h:248
cfg_ypinit
void cfg_ypinit(void)
Initialize the config manager.
Definition: cfg.c:1203
ERR_NCX_NOT_FOUND
@ ERR_NCX_NOT_FOUND
225
Definition: status_enum.h:264
cfg_get_last_txid
ncx_transaction_id_t cfg_get_last_txid(cfg_template_t *cfg)
Get the last good transaction ID.
Definition: cfg.c:2914
ERR_NCX_NO_ACCESS_LOCK
@ ERR_NCX_NO_ACCESS_LOCK
301
Definition: status_enum.h:344
cfg_rwlock_acquire_locks
status_t cfg_rwlock_acquire_locks(thd_tcb_t *tcb)
Acquire multiple locks in order to help prevent deadlock.
Definition: cfg.c:720
NCX_MAX_NUMLEN
#define NCX_MAX_NUMLEN
max number len to use for static buffer allocation only
Definition: ncxconst.h:136
cfg_clean_roots
void cfg_clean_roots(void)
Cleanup the cfg->root nodes before all the objects are freed.
Definition: cfg.c:1231
cfg_reload_candidate_cb_t
void(* cfg_reload_candidate_cb_t)(void)
support for server callback anytime the candidate config is reloaded from the running config <discard...
Definition: cfg.h:298
ERR_NCX_LOCK_DENIED
@ ERR_NCX_LOCK_DENIED
268
Definition: status_enum.h:309
cfg_template_t_::lock_time
xmlChar lock_time[TSTAMP_MIN_SIZE]
timestamp when last locked
Definition: cfg.h:251
cfg_update_stamps
void cfg_update_stamps(cfg_template_t *source, cfg_template_t *dest)
Update the last-modified and last-txid stamps.
Definition: cfg.c:2873
cfg_update_last_txid
void cfg_update_last_txid(cfg_template_t *cfg, ncx_transaction_id_t txid)
Update the last good transaction ID.
Definition: cfg.c:2852
cfg_get_global_lock_info
status_t cfg_get_global_lock_info(const cfg_template_t *cfg, ses_id_t *sesid, const xmlChar **locktime)
Get the current global lock info.
Definition: cfg.c:2470
tstamp_datetime
void tstamp_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:160
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
cfg_register_reload_candidate_cb
void cfg_register_reload_candidate_cb(cfg_reload_candidate_cb_t cbfn)
Register a callback function to be called anytime the.
Definition: cfg.c:3307
ncx_free_lmem
void ncx_free_lmem(ncx_lmem_t *lmem, ncx_btype_t btyp)
Free all the memory in a ncx_lmem_t struct.
Definition: ncx_list.c:1018
log.h
NCX System Logging Manager.
ERR_BUFF_OVFL
@ ERR_BUFF_OVFL
106
Definition: status_enum.h:218
CFG_ST_PLOCK
@ CFG_ST_PLOCK
partial lock active
Definition: cfg.h:202
cfg_ok_to_read
status_t cfg_ok_to_read(const cfg_template_t *cfg)
Check if the specified config can be read right now.
Definition: cfg.c:2226
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
NCX_MERGE_LAST
@ NCX_MERGE_LAST
merge last
Definition: ncxtypes.h:307
cfg_is_partial_locked
boolean cfg_is_partial_locked(const cfg_template_t *cfg)
Check if the specified config has any active partial locks.
Definition: cfg.c:2434
cfg_first_partial_lock
plock_cb_t * cfg_first_partial_lock(cfg_template_t *cfg)
Get the first partial lock in the specified config.
Definition: cfg.c:3076
rpc_err.h
NETCONF protocol standard error definitions.
cfg_ok_to_partial_lock
status_t cfg_ok_to_partial_lock(const cfg_template_t *cfg)
Check if the specified config can be locked right now for partial lock only.
Definition: cfg.c:3182
cfg_add_partial_lock
status_t cfg_add_partial_lock(cfg_template_t *cfg, plock_cb_t *plcb)
Add a partial lock the specified config.
Definition: cfg.c:3001
cfg_setup_running
status_t cfg_setup_running(void)
Setup the running config root if load_running_config did not add anything.
Definition: cfg.c:3265
cfg_fill_candidate_from_startup
status_t cfg_fill_candidate_from_startup(ses_id_t sesid)
Fill the <candidate> config with the config contents of the <startup> config.
Definition: cfg.c:1753
cfg_free_template
void cfg_free_template(cfg_template_t *cfg)
Clean and free the cfg_template_t struct.
Definition: cfg.c:1383
ncx_list.h
NCX Module Library List Utility Functions.
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
cfg_rwlock_unlock
status_t cfg_rwlock_unlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Release a lock associated with a cfg (datastore) RWLOCK structure.
Definition: cfg.c:535
cfg_cleanup
void cfg_cleanup(void)
Cleanup the config manager.
Definition: cfg.c:1257
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
CFG_ST_INIT
@ CFG_ST_INIT
init in progress
Definition: cfg.h:200
thd.h
Thread support (for now limited to netconfd)
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
cfg_lock
status_t cfg_lock(cfg_template_t *cfg, ses_id_t locked_by, cfg_source_t lock_src)
Lock the specified config.
Definition: cfg.c:2518
cfg_clear_dirty_flag
void cfg_clear_dirty_flag(cfg_template_t *cfg)
Clear the cfg dirty flag upon request.
Definition: cfg.c:2005
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
cfg_clear_candidate_dirty_flag
void cfg_clear_candidate_dirty_flag(void)
Clear the candidate dirty flag when it is saved to NV-storage or loaded into running from startup.
Definition: cfg.c:2044
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
ncx.h
YANG module utility functions.
TXID_T
#define TXID_T
For convenience.
Definition: ncxtypes.h:550
ERR_NCX_NOT_WRITABLE
@ ERR_NCX_NOT_WRITABLE
312
Definition: status_enum.h:355
ncx_is_db_lock_init_done
boolean ncx_is_db_lock_init_done(void)
Check if the <db-lock-init> message was processed by the server.
Definition: ncx.c:14750
cfg_get_config_id
cfg_template_t * cfg_get_config_id(ncx_cfg_t cfgid)
Get the config struct from its ID.
Definition: cfg.c:1530
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
ncx_insert_lmem
void ncx_insert_lmem(ncx_list_t *list, ncx_lmem_t *memval, ncx_merge_t mergetyp)
Insert a list entry into the specified list.
Definition: ncx_list.c:1123
TSTAMP_MIN_SIZE
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
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
plock_cb.h
RFC 57517 partial lock support Data structure definition.
plock_id_t
uint32 plock_id_t
matches lock-id-type in YANG module
Definition: plock_cb.h:78
SES_NULL_SID
#define SES_NULL_SID
session ID zero not used
Definition: ses.h:222
val_clone_config_data
val_value_t * val_clone_config_data(const val_value_t *val, status_t *res)
Clone a specified val_value_t struct and sub-trees with config=true only.
Definition: val.c:7903
cfg_template_t_::cfg_id
ncx_cfg_t cfg_id
config ID
Definition: cfg.h:227
cfg_fill_candidate_from_inline
status_t cfg_fill_candidate_from_inline(ses_id_t sesid, val_value_t *newroot)
Fill the <candidate> config with the config contents of the <config> inline XML node.
Definition: cfg.c:1892
cfg_rwlock_acquire_single_lock
status_t cfg_rwlock_acquire_single_lock(thd_tcb_t *tcb, cfg_template_t *cfg, boolean wrlock)
Acquire a single RWLOCK.
Definition: cfg.c:883
ncx_find_module
ncx_module_t * ncx_find_module(const xmlChar *modname, const xmlChar *revision)
Find a ncx_module_t in the ncx_sesmodQ.
Definition: ncx.c:3227
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
ERR_NCX_DATA_MISSING
@ ERR_NCX_DATA_MISSING
272
Definition: status_enum.h:313
cfg_get_config_name
const xmlChar * cfg_get_config_name(ncx_cfg_t cfgid)
Get the config name from its ID.
Definition: cfg.c:1493
NCX_CFG_RUNNING
#define NCX_CFG_RUNNING
NETCONF built-in config names.
Definition: ncxconst.h:579
ncx_is_with_dblock
boolean ncx_is_with_dblock(void)
Get the is_with_dblock value.
Definition: ncx.c:14714
thd_get_ids
void thd_get_ids(int *tid, ses_id_t *sid)
Return the TID and SID of the current running thread.
Definition: thd.c:1021
NCX_BT_STRING
@ NCX_BT_STRING
string
Definition: ncxtypes.h:217
cfg_template_t_::cfg_state
cfg_state_t cfg_state
config state
Definition: cfg.h:233
xmlns.h
XML namespace support.
cfg_template_t_::last_ch_time
xmlChar last_ch_time[TSTAMP_MIN_SIZE]
last change time
Definition: cfg.h:254
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
cfg_template_t_::last_modified
time_t last_modified
last modified timestamp
Definition: cfg.h:242
ncx_txid2etag
ncx_etag_t ncx_txid2etag(ncx_transaction_id_t txid)
Cast ncx_txid_t to ncx_etag_t.
Definition: ncx.c:15358
status.h
Global error messages for status code enumerations.
cfg_template_t_::load_errQ
dlq_hdr_t load_errQ
Q of rpc_err_rec_t.
Definition: cfg.h:265
dlq.h
dlq provides general double-linked list and queue support:
CFG_ST_READY
@ CFG_ST_READY
ready and no locks
Definition: cfg.h:201
cfg_set_dirty_flag
void cfg_set_dirty_flag(cfg_template_t *cfg)
Mark the config as 'changed'.
Definition: cfg.c:1979
CFG_ST_CLEANUP
@ CFG_ST_CLEANUP
cleanup in progress
Definition: cfg.h:204
cfg_ok_to_unlock
status_t cfg_ok_to_unlock(const cfg_template_t *cfg, ses_id_t sesid)
Check if the specified config can be unlocked right now by the specified session ID; for global lock ...
Definition: cfg.c:2165
ERR_NCX_NO_ACCESS_STATE
@ ERR_NCX_NO_ACCESS_STATE
302
Definition: status_enum.h:345
thd_find_tcb_by_sid
thd_tcb_t * thd_find_tcb_by_sid(ses_id_t sid, boolean strict)
Lookup TCB by session ID.
Definition: thd.c:704
ERR_RWLOCK_ERR
@ ERR_RWLOCK_ERR
014
Definition: status_enum.h:204
ncx_transaction_id_t
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:548
CFG_ST_FLOCK
@ CFG_ST_FLOCK
full lock active
Definition: cfg.h:203