yumapro  20.10-12
YumaPro SDK
agt_sys.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_agt_sys
13 #define _H_agt_sys
14 /* FILE: agt_sys.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 04-jun-09 abb Begun.
36 */
37 
38 #include <xmlstring.h>
39 
40 #ifndef _H_dlq
41 #include "dlq.h"
42 #endif
43 
44 #ifndef _H_ncxtypes
45 #include "ncxtypes.h"
46 #endif
47 
48 #ifndef _H_obj
49 #include "obj.h"
50 #endif
51 
52 #ifndef _H_ses
53 #include "ses.h"
54 #endif
55 
56 #ifndef _H_status
57 #include "status.h"
58 #endif
59 
60 #ifndef _H_tstamp
61 #include "tstamp.h"
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
89 /********************************************************************
90 * *
91 * C O N S T A N T S *
92 * *
93 *********************************************************************/
94 
96 #define AGT_SYS_MODULE (const xmlChar *)"yuma-system"
97 
99 #define AGT_YWSYS_MODULE (const xmlChar *)"yumaworks-system"
100 
101 
102 /********************************************************************
103 * *
104 * T Y P E S *
105 * *
106 *********************************************************************/
107 
108 
109 /********************************************************************
110 * *
111 * F U N C T I O N S *
112 * *
113 *********************************************************************/
114 
115 
122 extern status_t
123  agt_sys_init (void);
124 
125 
133 extern status_t
134  agt_sys_init2 (void);
135 
136 
142 extern void
143  agt_sys_cleanup (void);
144 
145 
155 extern void
156  agt_sys_send_sysSessionStart (const ses_cb_t *scb);
157 
158 
171 extern void
172  agt_sys_send_sysSessionEnd (const ses_cb_t *scb,
173  ses_term_reason_t termreason,
174  ses_id_t killedby);
175 
176 
188 extern void
189  agt_sys_send_sysConfigChange (const ses_cb_t *scb,
190  dlq_hdr_t *auditrecQ);
191 
192 
210 extern void
211  agt_sys_send_sysCapabilityChange (ses_cb_t *changed_by,
212  boolean is_add,
213  const xmlChar *capstr);
214 
215 
228 extern void
229  agt_sys_send_sysConfirmedCommit (const ses_cb_t *scb,
230  ncx_confirm_event_t event,
231  uint32 timeout);
232 
233 
239 extern uint32
241 
242 
250 extern val_value_t *
252 
253 
278 extern status_t
279  agt_sys_fill_ha_status (val_value_t *ha_status_val);
280 
281 
285 #ifdef __cplusplus
286 } /* end extern 'C' */
287 #endif
288 
289 
290 #endif /* _H_agt_sys */
ses.h
NETCONF Session Common definitions module.
agt_sys_send_sysCapabilityChange
void agt_sys_send_sysCapabilityChange(ses_cb_t *changed_by, boolean is_add, const xmlChar *capstr)
Send a Capability Change notification.
Definition: agt_sys.c:1477
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
agt_rpc_fill_rpc_error
status_t agt_rpc_fill_rpc_error(const rpc_err_rec_t *err, val_value_t *rpcerror)
Fill one <rpc-error> like element using the specified namespace and name, which may be different than...
Definition: agt_rpc.c:3501
ERR_NCX_NOT_IN_RANGE
@ ERR_NCX_NOT_IN_RANGE
288
Definition: status_enum.h:331
agt_cap.h
NETCONF Server capabilities handler.
cfg.h
log_set_syslog_log_level
void log_set_syslog_log_level(log_debug_t dlevel)
Set the syslog log level.
Definition: log.c:3438
val_move_children
void val_move_children(val_value_t *srcval, val_value_t *destval)
Move all the child nodes from src to dest Source and dest must both be containers!
Definition: val.c:12651
val_set_simval_obj
status_t val_set_simval_obj(val_value_t *val, obj_template_t *obj, const xmlChar *valstr)
Set an initialized val_value_t as a simple type.
Definition: val_util.c:4444
agt_ses.h
Server Session Management.
agt_util.h
Utility Functions for NCX Server method routines.
agt_rpc_register_method
status_t agt_rpc_register_method(const xmlChar *module, const xmlChar *method_name, agt_rpc_phase_t phase, agt_rpc_method_t method)
add callback for 1 phase of RPC processing
Definition: agt_rpc.c:2557
agt_use_notifications
boolean agt_use_notifications(void)
Check if notifications currently enabled.
Definition: agt.c:4867
tstamp.h
Timestamp utilities.
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_state.h
NETCONF State Monitoring Data Model Module support.
val_change_nsid
void val_change_nsid(val_value_t *val, xmlns_id_t nsid)
Change the namespace ID for a value node and all its descendants.
Definition: val.c:12303
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
LOG_DEBUG_NONE
@ LOG_DEBUG_NONE
value not set or error
Definition: log.h:386
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
ncx_get_modname
const xmlChar * ncx_get_modname(const ncx_module_t *mod)
Get the main module name.
Definition: ncx.c:4834
val.h
Value Node Basic Support.
xml_util.h
XML Utilities.
getcb.h
GET1 and GET2 Callback Support.
agt_rpc.h
NETCONF protocol remote procedure call server-side definitions.
val_child_find
val_value_t * val_child_find(const val_value_t *parent, const xmlChar *child_modname, const xmlChar *child_name)
Find the child node for the specified child name and modname.
Definition: val_child.c:1707
xml_wr.h
XML Write functions.
agt_make_virtual_leaf
val_value_t * agt_make_virtual_leaf(obj_template_t *parentobj, const xmlChar *leafname, getcb_fn_t callbackfn, status_t *res)
make a val_value_t struct for a specified virtual leaf or leaf-list
Definition: agt_util.c:3872
AGT_CLI_STARTUP
#define AGT_CLI_STARTUP
name of startup case
Definition: agt.h:490
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
agt_rpc_add_return_val
void agt_rpc_add_return_val(val_value_t *return_val, rpc_msg_t *msg)
Add a return value to the msg.
Definition: agt_rpc.c:4350
ncxmod.h
NCX Module Load Manager.
agt_not.h
NETCONF Notifications DM module support.
NCX_PROTO_YUMA_YANGAPI
@ NCX_PROTO_YUMA_YANGAPI
YumaPro YANG-API 1.0.
Definition: ncxtypes.h:785
agt_sys_send_sysSessionEnd
void agt_sys_send_sysSessionEnd(const ses_cb_t *scb, ses_term_reason_t termreason, ses_id_t killedby)
Queue the Session End notification.
Definition: agt_sys.c:1260
log_set_log_level
void log_set_log_level(log_debug_t dlevel)
Set the main log level.
Definition: log.c:3395
ses_msg.h
NETCONF Session Message Common definitions module.
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
ses_id_t
uint32 ses_id_t
Session ID.
Definition: ses.h:306
agt_cb.h
NETCONF Server Data Model callback handler.
VAL_ENUM_NAME
#define VAL_ENUM_NAME(V)
Access the enum name in the value ONLY if BCX_NT_ENUM This is the macro used to check values in SIL c...
Definition: val.h:434
agt_rpc_unregister_method
void agt_rpc_unregister_method(const xmlChar *module, const xmlChar *method_name)
remove the callback functions for all phases of RPC or Action processing for the specified RPC method...
Definition: agt_rpc.c:2759
ERR_NCX_MISSING_PARM
@ ERR_NCX_MISSING_PARM
233
Definition: status_enum.h:272
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.
agt_ietf_notif.h
ietf-netconf-notifications YANG module support
agt_sys_get_system_node
val_value_t * agt_sys_get_system_node(void)
Get the /yuma-system:system container.
Definition: agt_sys.c:1737
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
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
agt_get_server_key
const xmlChar * agt_get_server_key(void)
Get the ha-server-key string.
Definition: agt.c:4717
NCX_PROTO_RESTCONF
@ NCX_PROTO_RESTCONF
IETF RESTCONF.
Definition: ncxtypes.h:788
agt_sys_get_capability_changes
uint32 agt_sys_get_capability_changes(void)
Get the capability-changes counter.
Definition: agt_sys.c:1721
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
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
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
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.
agt_get_savedevQ
dlq_hdr_t * agt_get_savedevQ(void)
Get the agt_savedevQ pointer.
Definition: agt.c:4747
y_ietf_netconf_notifications_netconf_confirmed_commit_send
void y_ietf_netconf_notifications_netconf_confirmed_commit_send(const xmlChar *username, uint32 session_id, const xmlChar *source_host, const xmlChar *confirm_event, ncx_confirm_event_t event, uint32 timeout)
Send a y_ietf_netconf_notifications_netconf_confirmed_commit notification.
Definition: agt_ietf_notif.c:693
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
log_get_log_level
log_debug_t log_get_log_level(void)
Get the main log level.
Definition: log.c:3508
agt_sil_lib.h
Server Instrumentation Library Support.
agt_add_uint_leafy
status_t agt_add_uint_leafy(val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, uint32 leafval)
make a child node from a uint32 and add to parent.
Definition: agt_util.c:7373
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.
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
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.
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
agt_sys_send_sysConfirmedCommit
void agt_sys_send_sysConfirmedCommit(const ses_cb_t *scb, ncx_confirm_event_t event, uint32 timeout)
Queue the Confirmed Commit notification.
Definition: agt_sys.c:1648
yangconst.h
Contains YANG constants separated to prevent H file include loops.
AGT_CLI_FACTORY_STARTUP
#define AGT_CLI_FACTORY_STARTUP
name of factory-startup case
Definition: agt.h:493
agt_state_refresh_backup_dir
status_t agt_state_refresh_backup_dir(ses_cb_t *scb)
Check the backup directory and re-generate the YANG operational data for the netconf-state/backups co...
Definition: agt_state.c:2814
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
agt.h
Multi-Protocol Network Management Server.
agt_make_leaf
val_value_t * agt_make_leaf(obj_template_t *parentobj, const xmlChar *leafname, const xmlChar *leafstrval, status_t *res)
make a string val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:3683
agt_not_add_to_payload
void agt_not_add_to_payload(agt_not_msg_t *notif, val_value_t *val)
Queue the specified value node into the payloadQ for the specified notification.
Definition: agt_not.c:6000
agt_add_leafy
status_t agt_add_leafy(val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, const xmlChar *leafstrval)
make a child node from a string and add to parent.
Definition: agt_util.c:7319
GETCB_GET_VALUE
@ GETCB_GET_VALUE
GET request.
Definition: getcb.h:247
SES_TR_KILLED
@ SES_TR_KILLED
kill-session
Definition: ses.h:390
op_editop_name
const xmlChar * op_editop_name(op_editop_t ed_id)
Get the keyword for the specified op_editop_t enumeration.
Definition: op.c:106
agt_add_boolean_leafy
status_t agt_add_boolean_leafy(val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, boolean boolval)
make a child node from a boolean and add to parent.
Definition: agt_util.c:7590
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
y_ietf_netconf_notifications_netconf_session_end_send
void y_ietf_netconf_notifications_netconf_session_end_send(const xmlChar *username, uint32 session_id, const xmlChar *source_host, uint32 killed_by, const xmlChar *termination_reason)
Send a y_ietf_netconf_notifications_netconf_session_end notification.
Definition: agt_ietf_notif.c:617
agt_make_uint_leaf
val_value_t * agt_make_uint_leaf(obj_template_t *parentobj, const xmlChar *leafname, uint32 leafval, status_t *res)
make a uint32 val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:3702
agt_sys_send_sysSessionStart
void agt_sys_send_sysSessionStart(const ses_cb_t *scb)
Queue the Session Start notification.
Definition: agt_sys.c:1192
AGT_CLI_NOSTARTUP
#define AGT_CLI_NOSTARTUP
name of no-startup case
Definition: agt.h:487
y_ietf_netconf_notifications_netconf_session_start_send
void y_ietf_netconf_notifications_netconf_session_start_send(const xmlChar *username, uint32 session_id, const xmlChar *source_host)
Send a y_ietf_netconf_notifications_netconf_session_start notification.
Definition: agt_ietf_notif.c:580
agt_sys_cleanup
void agt_sys_cleanup(void)
Cleanup the module data structures.
Definition: agt_sys.c:1158
y_ietf_netconf_notifications_netconf_config_change_send
void y_ietf_netconf_notifications_netconf_config_change_send(const xmlChar *username, uint32 session_id, const xmlChar *source_host, const xmlChar *datastore, dlq_hdr_t *auditrecQ)
Send a y_ietf_netconf_notifications_netconf_config_change notification Called by your code when notif...
Definition: agt_ietf_notif.c:369
EMPTY_STRING
#define EMPTY_STRING
empty string used to get const xmlChar * cast
Definition: ncxconst.h:289
agt_make_object
val_value_t * agt_make_object(obj_template_t *parentobj, const xmlChar *objname, status_t *res)
make a val_value_t struct for a specified node
Definition: agt_util.c:3841
obj_find_child
obj_template_t * obj_find_child(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname)
Find a child object with the specified Qname.
Definition: obj.c:6116
agt_sys_init2
status_t agt_sys_init2(void)
INIT 2: Initialize the monitoring data structures This must be done after the <running> config is loa...
Definition: agt_sys.c:851
tstamp_datetime
void tstamp_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:160
agt_add_uint64_leafy
status_t agt_add_uint64_leafy(val_value_t *parentval, const xmlChar *modname, const xmlChar *leafname, uint64 leafval)
make a child node from a uint64 and add to parent.
Definition: agt_util.c:7481
agt_not_new_notification
agt_not_msg_t * agt_not_new_notification(obj_template_t *eventType)
Malloc and initialize the fields in an agt_not_msg_t.
Definition: agt_not.c:5910
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
ncxmod_load_module
status_t ncxmod_load_module(const xmlChar *modname, const xmlChar *revision, dlq_hdr_t *savedevQ, ncx_module_t **retmod)
Determine the location of the specified module and then load it into the system, if not already loade...
Definition: ncxmod.c:4342
log.h
NCX System Logging Manager.
AGT_RPC_PH_INVOKE
@ AGT_RPC_PH_INVOKE
(3) cb to invoke the requested method
Definition: agt_rpc.h:118
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
agt_sys.h
NETCONF system.yang DM module support.
agt_cli.h
NETCONF Server Command Line Interface handler.
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
rpc_err.h
NETCONF protocol standard error definitions.
agt_getTermReasonStr
const xmlChar * agt_getTermReasonStr(ses_term_reason_t termreason)
Convert the termination reason enum to a string.
Definition: agt_util.c:6516
y_ietf_netconf_notifications_netconf_capability_change_send
void y_ietf_netconf_notifications_netconf_capability_change_send(const xmlChar *username, uint32 session_id, const xmlChar *source_host, cap_change_t cap_change, const xmlChar *capstr)
Send a y_ietf_netconf_notifications_netconf_capability_change notification.
Definition: agt_ietf_notif.c:498
agt_yp_ha_get_config_info
status_t agt_yp_ha_get_config_info(uint64 *config_id, const xmlChar **config_stamp)
Get the config ID and timestamp info.
Definition: agt_yp_ha.c:1294
agt_cfg.h
Manage Server configuration edit transactions.
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
AGT_SYS_MODULE
#define AGT_SYS_MODULE
older yuma-system module
Definition: agt_sys.h:96
AGT_YWSYS_MODULE
#define AGT_YWSYS_MODULE
newerr yumaworks-system module mostly replaces yuma-system
Definition: agt_sys.h:99
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
agt_sys_init
status_t agt_sys_init(void)
INIT 1: Initialize the server notification module data structures.
Definition: agt_sys.c:727
agt_get_server_id
const xmlChar * agt_get_server_id(void)
Get the server-id string.
Definition: agt.c:4700
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
agt_yp_ha.h
YumaPro High Availability module (YP-HA)
obj.h
Data Object Support.
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
agt_yp_ha_get_role_state
const xmlChar * agt_yp_ha_get_role_state(void)
Get the YP-HA server role for this server as a string.
Definition: agt_yp_ha.c:961
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.
SES_TR_BAD_START
@ SES_TR_BAD_START
bad session start
Definition: ses.h:394
val_child_next_same
val_value_t * val_child_next_same(val_value_t *curnode)
Get the next node of the same type.
Definition: val_child.c:2359
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
agt_not_free_notification
void agt_not_free_notification(agt_not_msg_t *notif)
Scrub the memory in an agt_not_template_t by freeing all the sub-fields and then freeing the entire s...
Definition: agt_not.c:5953
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
agt_cli_get_valset
val_value_t * agt_cli_get_valset(void)
Retrieve the command line parameter set from boot time.
Definition: agt_cli.c:3427
status.h
Global error messages for status code enumerations.
ncx_get_confirm_event_str
const xmlChar * ncx_get_confirm_event_str(ncx_confirm_event_t event)
Get the string for the specified enum value.
Definition: ncx.c:9836
agt_not_queue_notification
void agt_not_queue_notification(agt_not_msg_t *notif)
Queue the specified notification in the replay log.
Definition: agt_not.c:6034
dlq.h
dlq provides general double-linked list and queue support:
agt_sys_fill_ha_status
status_t agt_sys_fill_ha_status(val_value_t *ha_status_val)
Fill the HA status container.
Definition: agt_sys.c:1786
ncx_get_version
status_t ncx_get_version(xmlChar *buffer, uint32 buffsize)
Get the the Yuma version ID string.
Definition: ncx.c:9577