yumapro  24.10-11
YumaPro SDK
Loading...
Searching...
No Matches
agt_ycontrol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3 * Copyright (c) 2012 - 2025, YumaWorks, Inc., All Rights Reserved.
4 *
5 * Unless required by applicable law or agreed to in writing,
6 * software distributed under the License is distributed on an
7 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the
9 * specific language governing permissions and limitations
10 * under the License.
11 */
12#ifdef WITH_YCONTROL
13#ifndef _H_agt_ycontrol
14#define _H_agt_ycontrol
15
16/* FILE: agt_ycontrol.h
17*********************************************************************
18* *
19* P U R P O S E *
20* *
21*********************************************************************/
22
29/*********************************************************************
30* *
31* C H A N G E H I S T O R Y *
32* *
33*********************************************************************
34
35date init comment
36----------------------------------------------------------------------
3710-apr-14 abb Begun
38
39*/
40
41#ifndef _H_agt_rpc
42#include "agt_rpc.h"
43#endif
44
45#ifndef _H_ses
46#include "ses.h"
47#endif
48
49#ifndef _H_status
50#include "status.h"
51#endif
52
53#ifndef _H_xml_util
54#include "xml_util.h"
55#endif
56
57#ifndef _H_xmlns
58#include "xmlns.h"
59#endif
60
61#ifndef _H_ycontrol_types
62#include "ycontrol_types.h"
63#endif
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69
83#define AGT_YCONTROL_MAX_SERVICES 4
84
85
86/********************************************************************
87* *
88* T Y P E S *
89* *
90*********************************************************************/
91
92
108typedef status_t
110 ycontrol_msgtype_t msgtype,
111 uint32 msgid,
112 const xmlChar *subsys_id,
113 ycontrol_msgbody_t msgbody_type,
114 val_value_t *msgbody,
115 boolean *scb_valid);
116
117
125typedef void
126 (*agt_ycontrol_subsys_gone_fn_t) (const xmlChar *subsys_id);
127
128
130typedef struct agt_ycontrol_cb_t_ {
132 dlq_hdr_t qhdr;
133
135 xmlChar *service_name;
136
139
143
144
148typedef struct agt_ycontrol_subsys_t_ {
150 dlq_hdr_t qhdr;
151
153 xmlChar *subsys_id;
154
156 xmlChar *service_id[AGT_YCONTROL_MAX_SERVICES];
157
160
163
167
168
169/********************************************************************
170* *
171* F U N C T I O N S *
172* *
173*********************************************************************/
174
175
184extern status_t
185 agt_ycontrol_init1 (void);
186
187
196extern status_t
197 agt_ycontrol_init2 (void);
198
199
205extern void
207
208
217extern boolean
219 xml_node_t *top);
220
221
243extern status_t
244 agt_ycontrol_send_payload (ses_cb_t *scb,
245 const xmlChar *service_id,
246 uint32 *msgid,
247 ycontrol_msgtype_t msgtype,
248 val_value_t *service_payload,
249 boolean with_ywattrs);
250
251
252
281extern status_t
283 const xmlChar *service_id,
284 uint32 *msgid,
285 ycontrol_msgtype_t msgtype,
286 boolean with_ywattrs,
287 obj_template_t *service_obj,
288 agt_rpc_data_cb_t data_cbfn,
289 rpc_msg_t *rpcmsg,
290 boolean need_filesave);
291
292
306extern status_t
307 agt_ycontrol_send_error (ses_cb_t *scb,
308 const xmlChar *service_id,
309 uint32 msgid,
310 status_t res,
311 const xmlChar *errstr);
312
313
325extern status_t
326 agt_ycontrol_send_ok (ses_cb_t *scb,
327 const xmlChar *service_id,
328 uint32 msgid);
329
330
340extern status_t
341 agt_ycontrol_send_event (const xmlChar *service_id,
342 val_value_t *service_payload,
343 boolean with_ywattrs);
344
345
346
358extern status_t
359 agt_ycontrol_send_event_subsys (const xmlChar *service_id,
360 val_value_t *service_payload,
361 boolean with_ywattrs,
362 const xmlChar *subsys_id);
363
364
365
375extern status_t
376 agt_ycontrol_register_service (const xmlChar *service_name,
377 agt_ycontrol_service_fn_t service_fn);
378
379
390extern status_t
391 agt_ycontrol_register_service_ex (const xmlChar *service_name,
392 agt_ycontrol_service_fn_t service_fn,
393 agt_ycontrol_subsys_gone_fn_t subsys_gone_fn);
394
395
401extern void
402 agt_ycontrol_unregister_service (const xmlChar *service_name);
403
404
412extern status_t
414 const xmlChar *subsys_id);
415
416
429extern void
431 const xmlChar *subsys_id);
432
433
439extern obj_template_t *
441
442
449extern ses_cb_t *
450 agt_ycontrol_get_scb (const xmlChar *subsys_id);
451
452
459extern void
461
462
468extern boolean
470
471
477extern status_t
479
480
487extern status_t
488 agt_ycontrol_send_shutdown_event_byservice (const xmlChar *service_id);
489
490
496extern boolean
498
499
506extern const xmlChar *
508
509
513#ifdef __cplusplus
514} /* end extern 'C' */
515#endif
516
517#endif /* _H_agt_ycontrol */
518#endif // WITH_YCONTROL
NETCONF protocol remote procedure call server-side definitions.
status_t(* agt_rpc_data_cb_t)(ses_cb_t *scb, rpc_msg_t *msg, uint32 indent)
Callback template for RPCs that use an inline callback function instead of generating a malloced val_...
Definition: agt_rpc.h:177
status_t agt_ycontrol_add_subsys(ses_id_t subsys_sid, const xmlChar *subsys_id)
Add a subsystem connection to the ycontrol manager.
Definition: agt_ycontrol.c:2003
status_t agt_ycontrol_send_callback(ses_cb_t *scb, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, boolean with_ywattrs, obj_template_t *service_obj, agt_rpc_data_cb_t data_cbfn, rpc_msg_t *rpcmsg, boolean need_filesave)
Send the subsystem <ycontrol> message to the sevice manager on the specified session,...
Definition: agt_ycontrol.c:1600
status_t agt_ycontrol_send_shutdown_event_byservice(const xmlChar *service_id)
Send a <shutdown-event> message to a specific subsystems.
Definition: agt_ycontrol.c:2241
status_t agt_ycontrol_register_service(const xmlChar *service_name, agt_ycontrol_service_fn_t service_fn)
Register a YControl service layer.
Definition: agt_ycontrol.c:1914
status_t agt_ycontrol_send_shutdown_event(void)
Send a <shutdown-event> message to all subsystems.
Definition: agt_ycontrol.c:2200
void agt_ycontrol_drop_session(ses_id_t sid)
Notify the agt_ycontrol module that a YControl session has been closed and needs to be cleaned up.
Definition: agt_ycontrol.c:2160
void agt_ycontrol_unregister_service(const xmlChar *service_name)
un-register a callback for 1 YControl service type
Definition: agt_ycontrol.c:1975
boolean agt_ycontrol_init_was_done(void)
Return TRUE if this module has been initialized.
Definition: agt_ycontrol.c:2281
boolean agt_ycontrol_dispatch(ses_cb_t *scb, xml_node_t *top)
Handle an incoming <ycontrol> message from a subsystem.
Definition: agt_ycontrol.c:1377
status_t agt_ycontrol_init2(void)
Initialize the agt_ycontrol module (phase 2)
Definition: agt_ycontrol.c:1309
void agt_ycontrol_remove_subsys(ses_id_t sid, const xmlChar *subsys_id)
Remove a subsystem connection to the ycontrol manager because the connection was closed or shutting d...
Definition: agt_ycontrol.c:2057
status_t agt_ycontrol_init1(void)
Initialize the agt_ycontrol module (phase 1)
Definition: agt_ycontrol.c:1243
boolean agt_ycontrol_any_subsys_active(void)
Check if there are any subsystems active.
Definition: agt_ycontrol.c:2183
void agt_ycontrol_cleanup(void)
Cleanup the agt_ycontrol module.
Definition: agt_ycontrol.c:1330
status_t agt_ycontrol_send_event(const xmlChar *service_id, val_value_t *service_payload, boolean with_ywattrs)
Send a server event to all the active subsystems.
Definition: agt_ycontrol.c:1765
status_t(* agt_ycontrol_service_fn_t)(ses_cb_t *scb, ycontrol_msgtype_t msgtype, uint32 msgid, const xmlChar *subsys_id, ycontrol_msgbody_t msgbody_type, val_value_t *msgbody, boolean *scb_valid)
Callback template for YControl services: message handler.
Definition: agt_ycontrol.h:109
status_t agt_ycontrol_send_event_subsys(const xmlChar *service_id, val_value_t *service_payload, boolean with_ywattrs, const xmlChar *subsys_id)
Send a server event to a specific subsystem or all subsystems.
Definition: agt_ycontrol.c:1794
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:2130
obj_template_t * agt_ycontrol_get_obj(void)
Get the ycontrol container object.
Definition: agt_ycontrol.c:2113
const xmlChar * agt_ycontrol_get_subsys_id(ses_id_t sid)
Get the subsystem-id for the session ID.
Definition: agt_ycontrol.c:2298
status_t agt_ycontrol_register_service_ex(const xmlChar *service_name, agt_ycontrol_service_fn_t service_fn, agt_ycontrol_subsys_gone_fn_t subsys_gone_fn)
Register a YControl service layer (extended)
Definition: agt_ycontrol.c:1938
#define AGT_YCONTROL_MAX_SERVICES
number of services hard-wired based on defined YumaPro features
Definition: agt_ycontrol.h:83
void(* agt_ycontrol_subsys_gone_fn_t)(const xmlChar *subsys_id)
brief Callback template for YControl services: subsys gone handler
Definition: agt_ycontrol.h:126
status_t
global error return code
Definition: status_enum.h:219
uint32 ses_id_t
Session ID.
Definition: ses.h:335
ycontrol_msgbody_t
YControl message body types.
Definition: ycontrol_types.h:85
ycontrol_msgtype_t
ycontrol message type
Definition: ycontrol_types.h:60
NETCONF Session Common definitions module.
Global error messages for status code enumerations.
control block for 1 registered service handler
Definition: agt_ycontrol.h:130
agt_ycontrol_service_fn_t service_fn
received message callback function
Definition: agt_ycontrol.h:138
dlq_hdr_t qhdr
queue header
Definition: agt_ycontrol.h:132
agt_ycontrol_subsys_gone_fn_t subsys_gone_fn
subsystem gone callback function
Definition: agt_ycontrol.h:141
xmlChar * service_name
service name
Definition: agt_ycontrol.h:135
control block for connected 1 subsystem; used to send event messages to the subsystem
Definition: agt_ycontrol.h:148
ses_id_t dropped_sid
internal ID of dropped session ID
Definition: agt_ycontrol.h:162
dlq_hdr_t qhdr
queue header
Definition: agt_ycontrol.h:150
boolean session_dropped
session dropped flag
Definition: agt_ycontrol.h:165
ses_id_t subsys_sid
session ID of YControl session with this subsystem
Definition: agt_ycontrol.h:159
xmlChar * subsys_id
subsystem ID from registration
Definition: agt_ycontrol.h:153
One YANG data-def-stmt.
Definition: obj.h:1232
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:185
Session Control Block.
Definition: ses.h:573
one value to match one type
Definition: val.h:912
gather node data into a simple struct.
Definition: xml_util.h:207
XML Utilities.
XML namespace support.
Some YControl data types.