yumapro  21.10T-8
YumaPro SDK
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 
35 date init comment
36 ----------------------------------------------------------------------
37 10-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
66 extern "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 
108 typedef 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 
125 typedef void
126  (*agt_ycontrol_subsys_gone_fn_t) (const xmlChar *subsys_id);
127 
128 
130 typedef struct agt_ycontrol_cb_t_ {
132  dlq_hdr_t qhdr;
133 
135  xmlChar *service_name;
136 
139 
143 
144 
148 typedef 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 
184 extern status_t
185  agt_ycontrol_init1 (void);
186 
187 
196 extern status_t
197  agt_ycontrol_init2 (void);
198 
199 
205 extern void
206  agt_ycontrol_cleanup (void);
207 
208 
217 extern boolean
219  xml_node_t *top);
220 
221 
240 extern 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 
272 extern status_t
274  const xmlChar *service_id,
275  uint32 *msgid,
276  ycontrol_msgtype_t msgtype,
277  boolean with_ywattrs,
278  obj_template_t *service_obj,
279  agt_rpc_data_cb_t data_cbfn,
280  rpc_msg_t *rpcmsg);
281 
282 
293 extern status_t
295  const xmlChar *service_id,
296  uint32 msgid,
297  status_t res,
298  const xmlChar *errstr);
299 
300 
309 extern status_t
311  const xmlChar *service_id,
312  uint32 msgid);
313 
314 
324 extern status_t
325  agt_ycontrol_send_event (const xmlChar *service_id,
326  val_value_t *service_payload,
327  boolean with_ywattrs);
328 
329 
330 
342 extern status_t
343  agt_ycontrol_send_event_subsys (const xmlChar *service_id,
344  val_value_t *service_payload,
345  boolean with_ywattrs,
346  const xmlChar *subsys_id);
347 
348 
349 
359 extern status_t
360  agt_ycontrol_register_service (const xmlChar *service_name,
361  agt_ycontrol_service_fn_t service_fn);
362 
363 
374 extern status_t
375  agt_ycontrol_register_service_ex (const xmlChar *service_name,
376  agt_ycontrol_service_fn_t service_fn,
377  agt_ycontrol_subsys_gone_fn_t subsys_gone_fn);
378 
379 
385 extern void
386  agt_ycontrol_unregister_service (const xmlChar *service_name);
387 
388 
396 extern status_t
397  agt_ycontrol_add_subsys (ses_id_t subsys_sid,
398  const xmlChar *subsys_id);
399 
400 
413 extern void
415  const xmlChar *subsys_id);
416 
417 
423 extern obj_template_t *
424  agt_ycontrol_get_obj (void);
425 
426 
433 extern ses_cb_t *
434  agt_ycontrol_get_scb (const xmlChar *subsys_id);
435 
436 
443 extern void
445 
446 
452 extern boolean
454 
455 
461 extern status_t
463 
464 
471 extern status_t
472  agt_ycontrol_send_shutdown_event_byservice (const xmlChar *service_id);
473 
474 
480 extern boolean
482 
483 
490 extern const xmlChar *
492 
493 
497 #ifdef __cplusplus
498 } /* end extern 'C' */
499 #endif
500 
501 #endif /* _H_agt_ycontrol */
502 #endif // WITH_YCONTROL
NETCONF protocol remote procedure call server-side definitions.
gather node data into a simple struct.
Definition: xml_util.h:204
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
void agt_ycontrol_cleanup(void)
Cleanup the agt_ycontrol module.
Definition: agt_ycontrol.c:1234
status_t agt_ycontrol_init2(void)
Initialize the agt_ycontrol module (phase 2)
Definition: agt_ycontrol.c:1213
boolean agt_ycontrol_any_subsys_active(void)
Check if there are any subsystems active.
Definition: agt_ycontrol.c:2085
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:178
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:1813
obj_template_t * agt_ycontrol_get_obj(void)
Get the ycontrol container object.
Definition: agt_ycontrol.c:2018
boolean agt_ycontrol_init_was_done(void)
Return TRUE if this module has been initialized.
Definition: agt_ycontrol.c:2183
One YANG data-def-stmt.
Definition: obj.h:1140
#define AGT_YCONTROL_MAX_SERVICES
number of services hard-wired based on defined YumaPro features
Definition: agt_ycontrol.h:83
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:1906
NETCONF Session Common definitions module.
const xmlChar * agt_ycontrol_get_subsys_id(ses_id_t sid)
Get the subsystem-id for the session ID.
Definition: agt_ycontrol.c:2200
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:1546
control block for connected 1 subsystem; used to send event messages to the subsystem ...
Definition: agt_ycontrol.h:148
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:2035
uint32 ses_id_t
Session ID.
Definition: ses.h:306
agt_ycontrol_subsys_gone_fn_t subsys_gone_fn
subsystem gone callback function
Definition: agt_ycontrol.h:141
ses_id_t dropped_sid
internal ID of dropped session ID
Definition: agt_ycontrol.h:162
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:2143
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:1609
void agt_ycontrol_unregister_service(const xmlChar *service_name)
un-register a callback for 1 YControl service type
Definition: agt_ycontrol.c:1876
status_t agt_ycontrol_send_shutdown_event(void)
Send a <shutdown-event> message to all subsystems.
Definition: agt_ycontrol.c:2102
XML Utilities.
ses_id_t subsys_sid
session ID of YControl session with this subsystem
Definition: agt_ycontrol.h:159
one value to match one type
Definition: val.h:870
xmlChar * subsys_id
subsystem ID from registration
Definition: agt_ycontrol.h:153
agt_ycontrol_service_fn_t service_fn
received message callback function
Definition: agt_ycontrol.h:138
Session Control Block.
Definition: ses.h:542
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
global error return code
Definition: status_enum.h:186
xmlChar * service_name
service name
Definition: agt_ycontrol.h:135
ycontrol_msgbody_t
YControl message body types.
Definition: ycontrol_types.h:85
control block for 1 registered service handler
Definition: agt_ycontrol.h:130
status_t agt_ycontrol_init1(void)
Initialize the agt_ycontrol module (phase 1)
Definition: agt_ycontrol.c:1147
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, using the <payload> variant.
Definition: agt_ycontrol.c:1403
Global error messages for status code enumerations.
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:2062
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)
Send the subsystem <ycontrol> message to the sevice manager on the specified session, using the <payload> variant.
Definition: agt_ycontrol.c:1496
boolean agt_ycontrol_dispatch(ses_cb_t *scb, xml_node_t *top)
Handle an incoming <ycontrol> message from a subsystem.
Definition: agt_ycontrol.c:1281
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:1837
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 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:1693
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:1962
XML namespace support.
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:1664
ycontrol_msgtype_t
ycontrol message type
Definition: ycontrol_types.h:60
boolean session_dropped
session dropped flag
Definition: agt_ycontrol.h:165
Some YControl data types.