yumapro  20.10-12
YumaPro SDK
ycontrol.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_ycontrol
13 #define _H_ycontrol
14 
15 /* FILE: ycontrol.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 15-mar-14 abb Begun
37 */
38 
39 #include <time.h>
40 #include <sys/time.h>
41 
42 // TBD: remove dependency on xmlstring.h for xmlChar */
43 #include <xmlstring.h>
44 
45 #ifndef _H_ncxtypes
46 #include "ncxtypes.h"
47 #endif
48 
49 #ifndef _H_obj
50 #include "obj.h"
51 #endif
52 
53 #ifndef _H_ses
54 #include "ses.h"
55 #endif
56 
57 #ifndef _H_status_enum
58 #include "status_enum.h"
59 #endif
60 
61 #ifndef _H_val
62 #include "val.h"
63 #endif
64 
65 #ifndef _H_tstamp
66 #include "tstamp.h"
67 #endif
68 
69 #ifndef _H_ycontrol_types
70 #include "ycontrol_types.h"
71 #endif
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 
78 
79 
106 /********************************************************************
107 * *
108 * C O N S T A N T S *
109 * *
110 *********************************************************************/
111 
112 
114 #define YCONTROL_DEF_RETRY_INTERVAL 5000
115 
116 
117 #define YCONTROL_DEF_MAX_RETRIES 5000
118 
120 #define SHUTDOWN_STATE(ST) \
121  (ST == YCONTROL_ST_SHUTDOWN_REQ || \
122  ST == YCONTROL_ST_DISCONNECTING || \
123  ST == YCONTROL_ST_SHUTDOWN)
124 
128 #define YCONTROL_MAX_SERVICES 2
129 
131 #define YCONTROL_MOD (const xmlChar *)"yumaworks-ycontrol"
132 
134 #define YCONTROL_OBJ (const xmlChar *)"ycontrol"
135 
136 
137 /********************************************************************
138 * *
139 * T Y P E S *
140 * *
141 *********************************************************************/
142 
143 
152 typedef status_t
154 
155 
165 typedef status_t
166  (*ycontrol_service_stop_t) (ses_cb_t *scb);
167 
168 
186 typedef status_t
188  (ses_cb_t *scb,
189  ycontrol_msgtype_t msgtype,
190  uint32 msgid,
191  const xmlChar *server_id,
192  ycontrol_msgbody_t msgbody_type,
193  val_value_t *msgbody,
194  boolean *response_sent);
195 
196 
207 typedef void
209 
210 
211 
217 typedef void
219 
220 
222 typedef enum ycontrol_state_t_ {
225 
228 
231 
234 
237 
240 
243 
246 
249 
252 } ycontrol_state_t;
253 
254 
256 typedef struct ycontrol_service_t_ {
258  xmlChar *service_name;
259 
262 
265 
268 
271 } ycontrol_service_t;
272 
273 
275 typedef struct ycontrol_profile_t_ {
276 
278  xmlChar *subsys_id;
279 
281  xmlChar *server_id;
282 
284  ycontrol_state_t ycontrol_state;
285 
287  status_t ycontrol_res;
288 
291 
294 
297 
300 
304  boolean is_standby;
305 
308 
310  struct timeval retry_timestamp;
311 
313  ses_cb_t *ycontrol_scb;
314 
317 
319  fd_set read_fd_set;
320 
322  fd_set write_fd_set;
323 
325  ncx_module_t *ycontrol_mod;
326 
328  obj_template_t *ycontrol_obj;
329 
331  val_value_t *ycontrol_msg;
332 
334  val_value_t *ycontrol_txid;
335 
337  val_value_t *ycontrol_payload;
338 
340  val_value_t *ycontrol_ok;
341 
343  val_value_t *ycontrol_error;
344 
348  uint32 next_msgid;
349 
352 
354  ycontrol_service_t service[YCONTROL_MAX_SERVICES];
355 
356 } ycontrol_profile_t;
357 
358 
359 
363 /********************************************************************
364 * *
365 * F U N C T I O N S *
366 * *
367 *********************************************************************/
368 
369 
370 
397 extern status_t
398  ycontrol_init (int argc,
399  char *argv[],
400  const xmlChar *subsys_id);
401 
402 
418 extern status_t
419  ycontrol_init_ex (int argc,
420  char *argv[],
421  const xmlChar *subsys_id,
422  boolean is_standby);
423 
424 
442 extern status_t
443  ycontrol_init_ex2 (int argc,
444  char *argv[],
445  const xmlChar *subsys_id,
446  boolean is_standby,
447  boolean quiet_mode);
448 
449 
457 extern status_t
458  ycontrol_init2 (void);
459 
460 
474 extern status_t
475  ycontrol_init2_ha (const char *server_id,
476  const char *server_addr,
477  uint16 server_port);
478 
479 #ifdef PTHREADS
480 
487 extern void
488  ycontrol_init2_ha_thd (thd_tcb_t *tcb);
489 #endif // PTHREADS
490 
491 
498 extern void
499  ycontrol_cleanup (void);
500 
501 
513 extern void
514  ycontrol_cleanup_ex (boolean do_ncx_cleanup);
515 
516 
524 extern status_t
525  ycontrol_check_io (void);
526 
527 
533 extern boolean
534  ycontrol_is_ready (void);
535 
536 
543 extern void
545 
546 
552 extern boolean
554 
555 
573 extern status_t
574  ycontrol_register_service (const xmlChar *service_name,
575  ycontrol_service_start_t service_start,
576  ycontrol_service_stop_t service_stop,
577  ycontrol_service_msg_rcvr_t service_rcvr,
578  ycontrol_service_shutdown_t service_shut);
579 
580 
581 
587 extern void
588  ycontrol_unregister_service (const xmlChar *service_name);
589 
590 
596 extern void
597  ycontrol_service_start (void);
598 
599 
605 extern void
606  ycontrol_service_stop (void);
607 
608 
615 extern obj_template_t *
616  ycontrol_get_service_object (const xmlChar *service_name);
617 
618 
633 extern status_t
634  ycontrol_send (const xmlChar *service_id,
635  uint32 *msgid,
636  ycontrol_msgtype_t msgtype,
637  val_value_t *service_payload,
638  status_t msg_status);
639 
640 
656 extern status_t
657  ycontrol_send_ex (const xmlChar *service_id,
658  uint32 *msgid,
659  ycontrol_msgtype_t msgtype,
660  val_value_t *service_payload,
661  status_t msg_status,
662  const xmlChar *txid_str);
663 
664 
681 extern status_t
682  ycontrol_send_ex2 (const xmlChar *service_id,
683  uint32 *msgid,
684  ycontrol_msgtype_t msgtype,
685  val_value_t *service_payload,
686  status_t msg_status,
687  boolean with_origin,
688  const xmlChar *txid_str);
689 
690 
704 extern status_t
705  ycontrol_send_error (const xmlChar *service_id,
706  uint32 *msgid,
707  status_t msg_status,
708  uint32 error_index,
709  const xmlChar *error_message,
710  const xmlChar *txid_str);
711 
712 
722 extern status_t
723  ycontrol_send_ok (const xmlChar *service_id,
724  uint32 *msgid,
725  const xmlChar *txid_str);
726 
727 
737 extern boolean
738  ycontrol_dispatch_msg (ses_cb_t *scb);
739 
740 
747 extern void
749 
750 
758 extern boolean
759  ycontrol_shutdown_now (void);
760 
761 
769 extern void
771 
772 
779 extern void
780  ycontrol_set_retry_interval (int retry_int);
781 
782 
788 extern const xmlChar *
789  ycontrol_get_subsys_id (void);
790 
791 
792 
798 extern void
799  ycontrol_set_retry_limit (uint16 retry_limit);
800 
801 
806 #ifdef __cplusplus
807 } /* end extern 'C' */
808 #endif
809 
810 #endif /* _H_ycontrol */
ses.h
NETCONF Session Common definitions module.
YCONTROL_ST_WAIT_CONNECT_RETRY
@ YCONTROL_ST_WAIT_CONNECT_RETRY
connect failed and waiting for a retry
Definition: ycontrol.h:236
ycontrol_set_retry_interval
void ycontrol_set_retry_interval(int retry_int)
Set the re-connect retry interval.
Definition: ycontrol.c:1441
ycontrol_ses_cleanup
void ycontrol_ses_cleanup(ycontrol_profile_t *profile)
Cleanup ycontrol session handler.
Definition: ycontrol_ses.c:269
YCONTROL_OBJ
#define YCONTROL_OBJ
container name for YControl protocol
Definition: ycontrol.h:134
ycontrol_get_service_object
obj_template_t * ycontrol_get_service_object(const xmlChar *service_name)
Get the service object from the payload container.
Definition: ycontrol.c:1088
ycontrol_service_t_
callback functions for a service that registers with ycontrol
Definition: ycontrol.h:256
YCONTROL_ST_CONNECTED
@ YCONTROL_ST_CONNECTED
active state, ready to receive requests and start service layers
Definition: ycontrol.h:239
ycontrol_service_t_::service_msg_rcvr
ycontrol_service_msg_rcvr_t service_msg_rcvr
service message receiver callback
Definition: ycontrol.h:267
ycontrol_profile_t_::ycontrol_error
val_value_t * ycontrol_error
cached error message ready to reload and send
Definition: ycontrol.h:343
ycontrol_msg_get_service_object
obj_template_t * ycontrol_msg_get_service_object(ycontrol_profile_t *profile, const xmlChar *service_name)
Get the service object from the payload container.
Definition: ycontrol_msg.c:655
YCONTROL_MSG_SERVER_REQUEST
@ YCONTROL_MSG_SERVER_REQUEST
server-request sent from server to subsystem
Definition: ycontrol_types.h:72
ycontrol_profile_t_::boot_timestamp
time_t boot_timestamp
timestamp of the connection attempt
Definition: ycontrol.h:307
tstamp.h
Timestamp utilities.
ycontrol_profile_t_::retry_timestamp
struct timeval retry_timestamp
retry timestamp
Definition: ycontrol.h:310
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
xml_clean_node
void xml_clean_node(xml_node_t *node)
Clean an xml_node_t struct.
Definition: xml_util.c:266
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
ycontrol_profile_t_::write_fd_set
fd_set write_fd_set
socket write FD set
Definition: ycontrol.h:322
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
ycontrol_signal.h
Handle interrupt signals for the YControl.
ycontrol_signal_init
void ycontrol_signal_init(void)
Initialize the ycontrol_signal module.
Definition: ycontrol_signal.c:74
ycontrol_send_error
status_t ycontrol_send_error(const xmlChar *service_id, uint32 *msgid, status_t msg_status, uint32 error_index, const xmlChar *error_message, const xmlChar *txid_str)
Send a YControl <error> message.
Definition: ycontrol.c:1238
val.h
Value Node Basic Support.
ncx_cleanup
void ncx_cleanup(void)
cleanup NCX module
Definition: ncx.c:3009
YCONTROL_DEF_RETRY_INTERVAL
#define YCONTROL_DEF_RETRY_INTERVAL
number of milli-seconds to wait between re-connect retries
Definition: ycontrol.h:114
ycontrol_send_ex
status_t ycontrol_send_ex(const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status, const xmlChar *txid_str)
Send a YControl message (extended)
Definition: ycontrol.c:1153
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.
ERR_TOO_MANY_ENTRIES
@ ERR_TOO_MANY_ENTRIES
012
Definition: status_enum.h:202
ycontrol_io_init
void ycontrol_io_init(ycontrol_profile_t *profile)
Setup ycontrol session handler.
Definition: ycontrol_io.c:153
YCONTROL_MSGBODY_OK
@ YCONTROL_MSGBODY_OK
OK message.
Definition: ycontrol_types.h:90
cleanup_subsystem_ycontrol
void cleanup_subsystem_ycontrol(status_t res)
Cleanup the subsystem variables.
Definition: subsystem.c:1295
ERR_NCX_DUP_ENTRY
@ ERR_NCX_DUP_ENTRY
224
Definition: status_enum.h:263
ycontrol_init_ex2
status_t ycontrol_init_ex2(int argc, char *argv[], const xmlChar *subsys_id, boolean is_standby, boolean quiet_mode)
Setup global vars before accepting any requests; extended 2.
Definition: ycontrol.c:545
ycontrol_profile_t_::next_msgid
uint32 next_msgid
next message ID, incremented when subsystem initiates the message
Definition: ycontrol.h:348
ycontrol_io_check
status_t ycontrol_io_check(ycontrol_profile_t *profile)
IO server loop for the ycontrol manager.
Definition: ycontrol_io.c:172
ncxconst.h
Contains NCX constants.
ncxmod.h
NCX Module Load Manager.
ycontrol_register_service
status_t ycontrol_register_service(const xmlChar *service_name, ycontrol_service_start_t service_start, ycontrol_service_stop_t service_stop, ycontrol_service_msg_rcvr_t service_rcvr, ycontrol_service_shutdown_t service_shut)
Register a specific service with the YumaPro control message manager.
Definition: ycontrol.c:951
ycontrol_profile_t_::ycontrol_ok
val_value_t * ycontrol_ok
cached OK message ready to reload and send
Definition: ycontrol.h:340
YCONTROL_MSGBODY_NONE
@ YCONTROL_MSGBODY_NONE
not set
Definition: ycontrol_types.h:87
subsys_util.h
Thin client IO handler for YumaPro server (utility functions)
ycontrol_profile_t_::shutdown_requested
boolean shutdown_requested
flag shutdown requested by the application
Definition: ycontrol.h:299
ycontrol_service_msg_rcvr_t
status_t(* ycontrol_service_msg_rcvr_t)(ses_cb_t *scb, ycontrol_msgtype_t msgtype, uint32 msgid, const xmlChar *server_id, ycontrol_msgbody_t msgbody_type, val_value_t *msgbody, boolean *response_sent)
YControl Service Layer Message Receiver Callback Function.
Definition: ycontrol.h:188
ycontrol_profile_t_::ycontrol_state
ycontrol_state_t ycontrol_state
current YControl protocol state
Definition: ycontrol.h:284
ycontrol_profile_t_::ycontrol_txid
val_value_t * ycontrol_txid
cached transaction ID
Definition: ycontrol.h:334
ycontrol_profile_t_::timer_handler
ycontrol_timer_handler_t timer_handler
timer callback for periodic checks like reconnect
Definition: ycontrol.h:351
ycontrol_init
status_t ycontrol_init(int argc, char *argv[], const xmlChar *subsys_id)
Initialize the YControl library.
Definition: ycontrol.c:485
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
ERR_NCX_MISSING_PARM
@ ERR_NCX_MISSING_PARM
233
Definition: status_enum.h:272
YCONTROL_ST_CONNECTING
@ YCONTROL_ST_CONNECTING
connecting to the server
Definition: ycontrol.h:233
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.
ycontrol_dispatch_msg
boolean ycontrol_dispatch_msg(ses_cb_t *scb)
Find the appropriate service handler and call it with the incoming message from the server.
Definition: ycontrol.c:1306
YCONTROL_ST_SHUTDOWN_REQ
@ YCONTROL_ST_SHUTDOWN_REQ
got an application shutdown request
Definition: ycontrol.h:242
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
ycontrol_service_shutdown_t
void(* ycontrol_service_shutdown_t)(void)
YControl Service Layer Shutdown Callback Function.
Definition: ycontrol.h:208
init_subsystem_ycontrol
status_t init_subsystem_ycontrol(int trace_level, const char *subsys_id)
@
Definition: subsystem.c:1175
ycontrol_profile_t_::service
ycontrol_service_t service[YCONTROL_MAX_SERVICES]
service layers registered callbacks stored here
Definition: ycontrol.h:354
ycontrol_cleanup_ex
void ycontrol_cleanup_ex(boolean do_ncx_cleanup)
Cleanup ycontrol layer (extended)
Definition: ycontrol.c:766
YCONTROL_MOD
#define YCONTROL_MOD
YANG module for YControl protocol.
Definition: ycontrol.h:131
ycontrol_cleanup
void ycontrol_cleanup(void)
Cleanup ycontrol layer.
Definition: ycontrol.c:753
ycontrol_profile_t_::is_standby
boolean is_standby
internal flag to identify special subsystem that is a server connecting to another server
Definition: ycontrol.h:304
ycontrol_xml_consume_node
status_t ycontrol_xml_consume_node(xmlTextReaderPtr reader, xml_node_t *node)
Consume an XML node from the XmlTextReader.
Definition: ycontrol_xml.c:130
ycontrol_init2
status_t ycontrol_init2(void)
Phase 2 initialization.
Definition: ycontrol.c:648
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
ALL_SERVICES
#define ALL_SERVICES
YControl string for event to the YControl layer itself.
Definition: ncxconst.h:589
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
ycontrol_msg_send_ex2
status_t ycontrol_msg_send_ex2(ycontrol_profile_t *profile, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status, uint32 error_index, const xmlChar *error_msg, boolean with_ywattrs, boolean with_origin, const xmlChar *txid_str)
Send a YControl message (extended2)
Definition: ycontrol_msg.c:449
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
ycontrol_service_t_::service_shutdown
ycontrol_service_shutdown_t service_shutdown
service shutdown callback
Definition: ycontrol.h:270
ycontrol_xml.h
YControl XML parser APIs.
ycontrol_is_ready
boolean ycontrol_is_ready(void)
Check if the ycontrol ready is up and ready to be used.
Definition: ycontrol.c:884
ycontrol_init2_ha_thd
void ycontrol_init2_ha_thd(thd_tcb_t *tcb)
Setup scb->tcb for ycontrol session.
Definition: ycontrol.c:734
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ycontrol_service_start
void ycontrol_service_start(void)
Start the registered services.
Definition: ycontrol.c:1021
ycontrol_set_timer_handler
void ycontrol_set_timer_handler(ycontrol_timer_handler_t timer_handler)
Set the timer callback handler.
Definition: ycontrol.c:1424
ycontrol_val_parse
status_t ycontrol_val_parse(ses_cb_t *scb, obj_template_t *obj, xml_node_t *startnode, val_value_t *retval)
parse a value for a YANG type from a NETCONF PDU XML stream
Definition: ycontrol_val_parse.c:2289
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
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
init_subsystem_ycontrol_ha
status_t init_subsystem_ycontrol_ha(int trace_level, const char *subsys_id, const char *server_id, const char *server_addr, uint16 server_port)
@
Definition: subsystem.c:1203
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.
ycontrol_profile_t_::ycontrol_msg
val_value_t * ycontrol_msg
cached message subtree to save time
Definition: ycontrol.h:331
ycontrol_profile_t_::ycontrol_mod
ncx_module_t * ycontrol_mod
parsed and saved YANG module for YControl messages
Definition: ycontrol.h:325
ycontrol_msg_cmn_get_msgtype_enum
ycontrol_msgtype_t ycontrol_msg_cmn_get_msgtype_enum(val_value_t *msgval, status_t *res)
Get the message type enumeration from the message.
Definition: ycontrol_msg_cmn.c:114
ycontrol_ses_init
status_t ycontrol_ses_init(ycontrol_profile_t *profile)
Setup the YControl session handler.
Definition: ycontrol_ses.c:244
YCONTROL_MAX_SERVICES
#define YCONTROL_MAX_SERVICES
this constant needs to be updated as more service types are implemented; currently only sil-sa,...
Definition: ycontrol.h:128
ycontrol_profile_t_::active_fd_set
fd_set active_fd_set
socket active FD set
Definition: ycontrol.h:316
ERR_NCX_NOT_FOUND
@ ERR_NCX_NOT_FOUND
225
Definition: status_enum.h:264
ycontrol_service_stop_t
status_t(* ycontrol_service_stop_t)(ses_cb_t *scb)
YControl Service Layer Stop Callback Function.
Definition: ycontrol.h:166
ycontrol_send_ok
status_t ycontrol_send_ok(const xmlChar *service_id, uint32 *msgid, const xmlChar *txid_str)
Send a YControl <ok> message.
Definition: ycontrol.c:1273
ycontrol_msg_send
status_t ycontrol_msg_send(ycontrol_profile_t *profile, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status)
Send a YControl message.
Definition: ycontrol_msg.c:358
ncx_set_message_indent
void ncx_set_message_indent(int8 msg_indent)
Set the protocol output message indent amount.
Definition: ncx.c:10791
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
subsystem.h
Thin client IO handler for YumaPro server.
ycontrol_profile_t_::connect_retries
int connect_retries
connect retries done
Definition: ycontrol.h:290
YCONTROL_MSG_SERVER_RESPONSE
@ YCONTROL_MSG_SERVER_RESPONSE
server-response sent from server to subsystem
Definition: ycontrol_types.h:75
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.
ycontrol_init2_ha
status_t ycontrol_init2_ha(const char *server_id, const char *server_addr, uint16 server_port)
Phase 2 initialization for HA.
Definition: ycontrol.c:669
ycontrol_send
status_t ycontrol_send(const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status)
Send a YControl message.
Definition: ycontrol.c:1116
ycontrol_profile_t_::read_fd_set
fd_set read_fd_set
socket read FD set
Definition: ycontrol.h:319
ycontrol_profile_t_
control block for 1 ycontrol manager (only 1 used)
Definition: ycontrol.h:275
ycontrol_ses.h
YControl session handler.
YCONTROL_MSG_SERVER_EVENT
@ YCONTROL_MSG_SERVER_EVENT
server-event sent from server to subsystem
Definition: ycontrol_types.h:69
SES_ST_SHUTDOWN_REQ
@ SES_ST_SHUTDOWN_REQ
session shutdown requested
Definition: ses.h:360
ycontrol_unregister_service
void ycontrol_unregister_service(const xmlChar *service_name)
Unregister a specific service.
Definition: ycontrol.c:997
ycontrol_get_subsys_id
const xmlChar * ycontrol_get_subsys_id(void)
Get the subsystem ID string.
Definition: ycontrol.c:1459
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.
ycontrol_msg_send_ex
status_t ycontrol_msg_send_ex(ycontrol_profile_t *profile, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status, uint32 error_index, const xmlChar *error_msg, boolean with_ywattrs, const xmlChar *txid_str)
Send a YControl message (extended)
Definition: ycontrol_msg.c:400
ycontrol_timer_handler_t
void(* ycontrol_timer_handler_t)(void)
YControl Service Layer Timer Handler Function.
Definition: ycontrol.h:218
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
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
ycontrol_profile_t_::connect_retry_interval
int connect_retry_interval
number of milliseconds to wait before connect retry
Definition: ycontrol.h:296
ycontrol_val_parse.h
XML Parameter Value Parser Module.
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
ycontrol_service_start_t
status_t(* ycontrol_service_start_t)(void)
YControl Service Layer Start Callback Function.
Definition: ycontrol.h:153
ycontrol_check_io
status_t ycontrol_check_io(void)
Check for input/output.
Definition: ycontrol.c:820
ycontrol_signal_cleanup
void ycontrol_signal_cleanup(void)
Cleanup the ycontrol_signal module.
Definition: ycontrol_signal.c:99
ncx_set_ycontrol_running
void ncx_set_ycontrol_running(void)
Set the ycontrol_running flag to TRUE.
Definition: ncx.c:12530
ycontrol_profile_t_::ycontrol_obj
obj_template_t * ycontrol_obj
YControl message YANG object.
Definition: ycontrol.h:328
ycontrol_send_ex2
status_t ycontrol_send_ex2(const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, status_t msg_status, boolean with_origin, const xmlChar *txid_str)
Send a YControl message (extended2)
Definition: ycontrol.c:1197
YCONTROL_ST_CONNECT
@ YCONTROL_ST_CONNECT
need a socket connection to server
Definition: ycontrol.h:230
ycontrol_profile_t_::subsys_id
xmlChar * subsys_id
malloced subsystem ID to use
Definition: ycontrol.h:278
YCONTROL_ST_SHUTDOWN
@ YCONTROL_ST_SHUTDOWN
in the process of shutting down
Definition: ycontrol.h:248
ycontrol_state_t_
ycontrol_state_t_
ycontrol manager connection state enumerations
Definition: ycontrol.h:222
ycontrol_ses_attempt_connect
status_t ycontrol_ses_attempt_connect(ycontrol_profile_t *profile)
Attempt to connect to the server.
Definition: ycontrol_ses.c:189
ycontrol_request_shutdown
void ycontrol_request_shutdown(void)
Request a control message handler shutdown.
Definition: ycontrol.c:914
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.
YCONTROL_ST_NONE
@ YCONTROL_ST_NONE
not set
Definition: ycontrol.h:224
obj.h
Data Object Support.
ycontrol.h
YumaPro Subsystem Control Protocol.
ycontrol_types.h
Some YControl data types.
ycontrol_service_t_::service_start
ycontrol_service_start_t service_start
service start callback
Definition: ycontrol.h:261
LOG_DEBUG_INFO
@ LOG_DEBUG_INFO
all previous + user info trace
Definition: log.h:392
ycontrol_profile_t_::ycontrol_res
status_t ycontrol_res
last operation result
Definition: ycontrol.h:287
ncx_get_subsys_id
const xmlChar * ncx_get_subsys_id(void)
Get the subsys_id value; NULL if not set.
Definition: ncx.c:12585
ycontrol_io.h
YControl protocol Input Output Handler.
ycontrol_profile_t_::ycontrol_scb
ses_cb_t * ycontrol_scb
session control block for connection to server
Definition: ycontrol.h:313
ycontrol_msg.h
YControl protocol message send APIs.
YCONTROL_MSG_SUBSYS_RESPONSE
@ YCONTROL_MSG_SUBSYS_RESPONSE
subsystem-response sent from subsystem to server
Definition: ycontrol_types.h:84
ncx_init
status_t ncx_init(boolean netconfd, boolean savestr, log_debug_t dlevel, boolean logtstamps, boolean collapse_submods, boolean xpath_backptrs, const char *startmsg, int argc, char *argv[])
Initialize the NCX library.
Definition: ncx.c:2616
ycontrol_service_t_::service_name
xmlChar * service_name
service name (list key)
Definition: ycontrol.h:258
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
ycontrol_init_ex
status_t ycontrol_init_ex(int argc, char *argv[], const xmlChar *subsys_id, boolean is_standby)
Initialize the YControl library.
Definition: ycontrol.c:513
ycontrol_service_t_::service_stop
ycontrol_service_stop_t service_stop
service stop callback
Definition: ycontrol.h:264
YCONTROL_ST_INIT
@ YCONTROL_ST_INIT
YControl initializing.
Definition: ycontrol.h:227
YCONTROL_ST_SHUTDOWN_DONE
@ YCONTROL_ST_SHUTDOWN_DONE
shutdown complete
Definition: ycontrol.h:251
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
xml_init_node
void xml_init_node(xml_node_t *node)
Init an xml_node_t struct.
Definition: xml_util.c:229
ycontrol_set_retry_limit
void ycontrol_set_retry_limit(uint16 retry_limit)
Set the re-connect retry limit.
Definition: ycontrol.c:1474
ycontrol_profile_t_::connect_max_retries
int connect_max_retries
connect retries allowed
Definition: ycontrol.h:293
ycontrol_shutdown_requested
boolean ycontrol_shutdown_requested(void)
Check if a control message handler shutdown is in progress.
Definition: ycontrol.c:933
YCONTROL_ST_DISCONNECTING
@ YCONTROL_ST_DISCONNECTING
disconnecting from the server
Definition: ycontrol.h:245
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
ycontrol_profile_t_::ycontrol_payload
val_value_t * ycontrol_payload
cached payload to reload and save time
Definition: ycontrol.h:337
status.h
Global error messages for status code enumerations.
ycontrol_shutdown_now
boolean ycontrol_shutdown_now(void)
Check if the YControl subsystem has shut down because a <shutdown-event> was received from the server...
Definition: ycontrol.c:1408
ycontrol_setup_reconnect
void ycontrol_setup_reconnect(void)
Setup the YControl profile to reconnect after the retry interval with the incoming message from the s...
Definition: ycontrol.c:1383
xml_dump_node
void xml_dump_node(const xml_node_t *node, log_debug_t lvl)
Debug function to printf xml_node_t contents.
Definition: xml_util.c:661
ycontrol_profile_t_::server_id
xmlChar * server_id
server ID that this subsystem connected to
Definition: ycontrol.h:281
tstamp_diff
long int tstamp_diff(struct timeval *start_time, struct timeval *end_time, long int *usec)
Get the elapsed time between two timeval structs.
Definition: tstamp.c:612
ycontrol_service_stop
void ycontrol_service_stop(void)
Stop the registered services.
Definition: ycontrol.c:1052
YCONTROL_DEF_MAX_RETRIES
#define YCONTROL_DEF_MAX_RETRIES
max number of reconnect retries before giving up
Definition: ycontrol.h:117