yumapro  24.10-1
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 - 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#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
240extern status_t
242 const xmlChar *service_id,
243 uint32 *msgid,
244 ycontrol_msgtype_t msgtype,
245 val_value_t *service_payload,
246 boolean with_ywattrs);
247
248
249
278extern status_t
280 const xmlChar *service_id,
281 uint32 *msgid,
282 ycontrol_msgtype_t msgtype,
283 boolean with_ywattrs,
284 obj_template_t *service_obj,
285 agt_rpc_data_cb_t data_cbfn,
286 rpc_msg_t *rpcmsg,
287 boolean need_filesave);
288
289
300extern status_t
302 const xmlChar *service_id,
303 uint32 msgid,
304 status_t res,
305 const xmlChar *errstr);
306
307
316extern status_t
318 const xmlChar *service_id,
319 uint32 msgid);
320
321
331extern status_t
332 agt_ycontrol_send_event (const xmlChar *service_id,
333 val_value_t *service_payload,
334 boolean with_ywattrs);
335
336
337
349extern status_t
350 agt_ycontrol_send_event_subsys (const xmlChar *service_id,
351 val_value_t *service_payload,
352 boolean with_ywattrs,
353 const xmlChar *subsys_id);
354
355
356
366extern status_t
367 agt_ycontrol_register_service (const xmlChar *service_name,
368 agt_ycontrol_service_fn_t service_fn);
369
370
381extern status_t
382 agt_ycontrol_register_service_ex (const xmlChar *service_name,
383 agt_ycontrol_service_fn_t service_fn,
384 agt_ycontrol_subsys_gone_fn_t subsys_gone_fn);
385
386
392extern void
393 agt_ycontrol_unregister_service (const xmlChar *service_name);
394
395
403extern status_t
405 const xmlChar *subsys_id);
406
407
420extern void
422 const xmlChar *subsys_id);
423
424
430extern obj_template_t *
432
433
440extern ses_cb_t *
441 agt_ycontrol_get_scb (const xmlChar *subsys_id);
442
443
450extern void
452
453
459extern boolean
461
462
468extern status_t
470
471
478extern status_t
479 agt_ycontrol_send_shutdown_event_byservice (const xmlChar *service_id);
480
481
487extern boolean
489
490
497extern const xmlChar *
499
500
504#ifdef __cplusplus
505} /* end extern 'C' */
506#endif
507
508#endif /* _H_agt_ycontrol */
509#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
status_t agt_ycontrol_send_error(ses_cb_t *scb, const xmlChar *service_id, uint32 msgid, status_t res, const xmlChar *errstr)
Send a ycontrol error message.
Definition: agt_ycontrol.c:1649
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:1500
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_ok(ses_cb_t *scb, const xmlChar *service_id, uint32 msgid)
Send a ycontrol OK message.
Definition: agt_ycontrol.c:1711
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:210
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:1229
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
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.