yumapro  20.10-12
YumaPro SDK
agt_db_lock.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 - 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 #ifdef WITH_YCONTROL
12 #ifndef _H_agt_db_lock
13 #define _H_agt_db_lock
14 
15 /* FILE: agt_db_lock.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 29-jan-19 abb Begun
37 */
38 
39 #include <xmlstring.h>
40 
41 #ifndef _H_agt_cfg
42 #include "agt_cfg.h"
43 #endif
44 
45 #ifndef _H_status_enum
46 #include "status_enum.h"
47 #endif
48 
49 #ifndef _H_val
50 #include "val.h"
51 #endif
52 
53 #ifndef _H_ycontrol
54 #include "ycontrol.h"
55 #endif
56 
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 /********************************************************************
63 * *
64 * C O N S T A N T S *
65 * *
66 *********************************************************************/
67 
68 /********************************************************************
69 * *
70 * T Y P E S *
71 * *
72 *********************************************************************/
73 
74 
75 /********************************************************************
76 * *
77 * F U N C T I O N S *
78 * *
79 *********************************************************************/
80 
81 /* header in agt_db_api.h */
82 
83 
97 extern status_t
98  agt_db_lock_init (void);
99 
100 
106 extern void
107  agt_db_lock_cleanup (void);
108 
109 
117 extern status_t
118  agt_db_lock_set_owner (const xmlChar *subsys_id,
119  int subsys_fd);
120 
121 
127 extern boolean
128  agt_db_lock_needed (void);
129 
130 
137 extern status_t
138  agt_db_lock_request (agt_cfg_transaction_t *txcb);
139 
140 
146 extern status_t
147  agt_db_lock_release (void);
148 
149 
160 extern status_t
161  agt_db_lock_handle_response (uint32 msgid,
162  const xmlChar *subsys_id,
163  ycontrol_msgbody_t msgbody_type,
164  val_value_t *msgbody);
165 
166 
173 extern void
174  agt_db_lock_subsys_gone (const xmlChar *subsys_id);
175 
176 
183 extern boolean
185 
186 
190 #ifdef __cplusplus
191 } /* end extern 'C' */
192 #endif
193 
194 #endif /* _H_agt_db_lock */
195 #endif // WITH_YCONTROL
ses.h
NETCONF Session Common definitions module.
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
ERR_NCX_TIMEOUT
@ ERR_NCX_TIMEOUT
368
Definition: status_enum.h:411
cfg.h
YCONTROL_MSG_SERVER_REQUEST
@ YCONTROL_MSG_SERVER_REQUEST
server-request sent from server to subsystem
Definition: ycontrol_types.h:72
tstamp.h
Timestamp utilities.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
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
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
val.h
Value Node Basic Support.
agt_ncxserver_run_ycontrol
status_t agt_ncxserver_run_ycontrol(boolean ycontrol, const xmlChar *txid_str)
IO server loop for the ncxserver socket.
Definition: agt_ncxserver.c:3469
val_make_simval_obj
val_value_t * val_make_simval_obj(obj_template_t *obj, const xmlChar *valstr, status_t *res)
Create and set a val_value_t as a simple type from an object template instead of individual fields Ca...
Definition: val_util.c:4389
agt_db_lock_needed
boolean agt_db_lock_needed(void)
Check if lock is needed.
Definition: agt_db_lock.c:576
VAL_UINT32
#define VAL_UINT32(V)
Access the value as an uint32 ONLY if NCX_BT_UINT32.
Definition: val.h:497
status_enum.h
global error status code enumerations
YCONTROL_MSGBODY_ERROR
@ YCONTROL_MSGBODY_ERROR
error message
Definition: ycontrol_types.h:96
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
xml_wr.h
XML Write functions.
AGT_EXIT_MODE_TIMEOUT
@ AGT_EXIT_MODE_TIMEOUT
exit loop with timeout
Definition: agt.h:657
agt_ncxserver.h
NCX Server Transport and IO Library.
AGT_EXIT_MODE_DROPPED
@ AGT_EXIT_MODE_DROPPED
exit loop with session dropped
Definition: agt.h:658
YCONTROL_MSGBODY_OK
@ YCONTROL_MSGBODY_OK
OK message.
Definition: ycontrol_types.h:90
ncxconst.h
Contains NCX constants.
agt_db_lock_handle_response
status_t agt_db_lock_handle_response(uint32 msgid, const xmlChar *subsys_id, ycontrol_msgbody_t msgbody_type, val_value_t *msgbody)
Handle the db-lock response.
Definition: agt_db_lock.c:809
AGT_EXIT_MODE_ERROR
@ AGT_EXIT_MODE_ERROR
exit loop with error
Definition: agt.h:656
agt_db_lock_release
status_t agt_db_lock_release(void)
Release the DB-Edit-Lock.
Definition: agt_db_lock.c:746
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
val_remove_child
void val_remove_child(val_value_t *child)
Remove a child value node from its parent value node.
Definition: val.c:8316
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_ycontrol_get_scb
ses_cb_t * agt_ycontrol_get_scb(const xmlChar *subsys_id)
Get the session control block for the specified subsys ID.
Definition: agt_ycontrol.c:1944
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
ERR_NCX_SESSION_CLOSED
@ ERR_NCX_SESSION_CLOSED
1010
Definition: status_enum.h:499
agt_db_lock_set_owner
status_t agt_db_lock_set_owner(const xmlChar *subsys_id, int subsys_fd)
Set the subsystem that owns the DB-Edit-Lock.
Definition: agt_db_lock.c:519
agt_db_lock.h
Server DB-API DB-Edit-Lock support module.
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
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
AGT_DEF_DB_LOCK_TIMEOUT
#define AGT_DEF_DB_LOCK_TIMEOUT
db-lock default timeout (seconds )
Definition: agt.h:361
val_util.h
Value Node Utilities.
AGT_EXIT_MODE_OK
@ AGT_EXIT_MODE_OK
exit loop with OK
Definition: agt.h:655
agt_timer_restart
status_t agt_timer_restart(uint32 timer_id, uint32 seconds)
Restart a timer with a new timeout value.
Definition: agt_timer.c:390
rpc.h
NETCONF protocol remote procedure call common definitions.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
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
typ.h
Parameter Type Handler.
LOGINFO
#define LOGINFO
Check if at least log-level=info.
Definition: log.h:279
agt.h
Multi-Protocol Network Management Server.
ERR_NCX_RESOURCE_DENIED
@ ERR_NCX_RESOURCE_DENIED
269
Definition: status_enum.h:310
agt_db_lock_init_waiting
boolean agt_db_lock_init_waiting(void)
Check if db-lock is stuck in init-waiting state.
Definition: agt_db_lock.c:940
agt_db_lock_cleanup
void agt_db_lock_cleanup(void)
Cleanup the DB-Edit-Lock Module.
Definition: agt_db_lock.c:492
agt_db_lock_request
status_t agt_db_lock_request(agt_cfg_transaction_t *txcb)
Request the DB-Edit-Lock.
Definition: agt_db_lock.c:597
log_debug4_append
void void void void void void void void void void void void void void log_debug4_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG4 log entry.
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
YCONTROL_MSG_SERVER_EVENT
@ YCONTROL_MSG_SERVER_EVENT
server-event sent from server to subsystem
Definition: ycontrol_types.h:69
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
ycontrol_msg_cmn.h
YControl Message Utilities.
AGT_DB_API
#define AGT_DB_API
DB-API service name for YControl.
Definition: agt.h:415
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
agt_cli.h
NETCONF Server Command Line Interface handler.
agt_db_lock_init
status_t agt_db_lock_init(void)
Initialize the DB-Edit-Lock subsysystem handler.
Definition: agt_db_lock.c:425
rpc_err.h
NETCONF protocol standard error definitions.
agt_cfg.h
Manage Server configuration edit transactions.
agt_timer_delete
void agt_timer_delete(uint32 timer_id)
Remove and delete a timer control block.
Definition: agt_timer.c:426
agt_get_profile
agt_profile_t * agt_get_profile(void)
Get the server profile struct.
Definition: agt.c:4118
agt_timer_get_timenow
void agt_timer_get_timenow(time_t *tnow)
Get the current time using the system or monotonic clock.
Definition: agt_timer.c:457
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.
agt_ycontrol_send_payload
status_t agt_ycontrol_send_payload(ses_cb_t *scb, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, boolean with_ywattrs)
Send the subsystem <ycontrol> message to the sevice manager on the specified session,...
Definition: agt_ycontrol.c:1312
agt_db_lock_subsys_gone
void agt_db_lock_subsys_gone(const xmlChar *subsys_id)
Called when the subsystem is gone to cleanup any db-lock state in progress.
Definition: agt_db_lock.c:907
obj.h
Data Object Support.
ycontrol.h
YumaPro Subsystem Control Protocol.
agt_ycontrol.h
Handle the YumaPro Control Protocol <ycontrol> (top-level) element.
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.
YCONTROL_MSGBODY_PAYLOAD
@ YCONTROL_MSGBODY_PAYLOAD
payload message
Definition: ycontrol_types.h:93
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
AGT_DEF_DB_LOCK_RETRY
#define AGT_DEF_DB_LOCK_RETRY
db-lock default retry interval (milli-seconds)
Definition: agt.h:358
agt_timer.h
Handle timer services for the server.
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
ERR_NCX_SESSION_DROPPED
@ ERR_NCX_SESSION_DROPPED
400
Definition: status_enum.h:443
agt_ncxserver_exit_ycontrol_mode
void agt_ncxserver_exit_ycontrol_mode(const xmlChar *txid_str, agt_exit_mode_t exitmode)
Cause the ycontrol mode to terminate.
Definition: agt_ncxserver.c:3423
agt_ycontrol_get_obj
obj_template_t * agt_ycontrol_get_obj(void)
Get the ycontrol container object.
Definition: agt_ycontrol.c:1927
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.
log_debug3_append
void void void void void void void void void void void void log_debug3_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG3 log entry.
dlq.h
dlq provides general double-linked list and queue support:
agt_timer_create
status_t agt_timer_create(uint32 seconds, boolean is_periodic, agt_timer_fn_t timer_fn, void *cookie, uint32 *ret_timer_id)
Malloc and start a new timer control block.
Definition: agt_timer.c:327
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297