yumapro  24.10-11
YumaPro SDK
Loading...
Searching...
No Matches
agt_rpc.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#ifndef _H_agt_rpc
13#define _H_agt_rpc
14/* FILE: agt_rpc.h
15*********************************************************************
16* *
17* P U R P O S E *
18* *
19*********************************************************************/
20
27/*********************************************************************
28* *
29* C H A N G E H I S T O R Y *
30* *
31*********************************************************************
32
33date init comment
34----------------------------------------------------------------------
3530-apr-05 abb Begun.
36*/
37
38#ifndef _H_cfg
39#include "cfg.h"
40#endif
41
42#ifndef _H_rpc
43#include "rpc.h"
44#endif
45
46#ifndef _H_rpc_err
47#include "rpc_err.h"
48#endif
49
50#ifndef _H_ses
51#include "ses.h"
52#endif
53
54#ifndef _H_status_enum
55#include "status_enum.h"
56#endif
57
58#ifndef _H_xml_util
59#include "xml_util.h"
60#endif
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
77/********************************************************************
78* *
79* C O N S T A N T S *
80* *
81*********************************************************************/
82
89#define AGT_RPC_NUM_CALLBACK_PHASES 3
90
91/********************************************************************
92* *
93* T Y P E S *
94* *
95*********************************************************************/
96
109typedef enum agt_rpc_phase_t_ {
112
115
118
121
125
126
146typedef status_t
147 (*agt_rpc_method_t) (ses_cb_t *scb,
148 rpc_msg_t *msg,
149 xml_node_t *methnode);
150
151
153typedef struct agt_rpc_cbset_t_ {
156
158 boolean regdone;
159
161 dlq_hdr_t subsysQ;
164
165
176typedef status_t
178 rpc_msg_t *msg,
179 uint32 indent);
180
181
186typedef struct agt_rpc_subsys_t_ {
188 dlq_hdr_t qhdr;
189
191 const xmlChar *subsys_id;
192
196
197
198/********************************************************************
199* *
200* F U N C T I O N S *
201* *
202*********************************************************************/
203
204
214extern status_t
215 agt_rpc_init (void);
216
217
224extern void
225 agt_rpc_cleanup (void);
226
227
243extern status_t
244 agt_rpc_register_method (const xmlChar *module,
245 const xmlChar *method_name,
246 agt_rpc_phase_t phase,
247 agt_rpc_method_t method);
248
249
258extern void
259 agt_rpc_support_method (const xmlChar *module,
260 const xmlChar *method_name);
261
262
271extern void
272 agt_rpc_unsupport_method (const xmlChar *module,
273 const xmlChar *method_name);
274
275
286extern void
287 agt_rpc_unregister_method (const xmlChar *module,
288 const xmlChar *method_name);
289
290
303extern boolean
305 xml_node_t *top);
306
307
336extern status_t
337 agt_rpc_load_config_file (const xmlChar *filespec,
338 cfg_template_t *cfg,
339 boolean isload,
340 ses_id_t use_sid,
341 dlq_hdr_t *errQ,
342 boolean do_config_change,
343 const rpc_msg_t *reqmsg);
344
345
370extern val_value_t *
371 agt_rpc_get_config_file (const xmlChar *filespec,
372 cfg_template_t *targetcfg,
373 ses_id_t use_sid,
374 dlq_hdr_t *errorQ,
375 status_t *res);
376
377
398extern status_t
399 agt_rpc_load_config_file_val (const xmlChar *filespec,
400 ses_id_t use_sid,
401 val_value_t **configval,
402 dlq_hdr_t *errorQ);
403
404
422extern status_t
424
425
438extern status_t
440 val_value_t *rpcerror);
441
442
451extern void
453 status_t retres);
454
455
467extern status_t
469 xml_msg_hdr_t *msg,
470 const rpc_err_rec_t *err,
471 int32 indent,
472 boolean isfirst,
473 boolean islast);
474
475
482extern ncx_backptr_t *
484
485
493extern ncx_backptr_t *
495
496
505extern status_t
507 rpc_msg_t *msg,
508 obj_template_t *rpcobj);
509
510
520extern status_t
522 rpc_msg_t *msg,
523 obj_template_t *rpcobj,
524 xml_node_t *method);
525
526
537extern status_t
539 rpc_msg_t *msg,
540 status_t psdres);
541
542
555extern status_t
557 rpc_msg_t *msg,
558 xml_node_t *method_node);
559
560
575extern status_t
577 rpc_msg_t *msg,
578 xml_node_t *method_node,
579 val_value_t *action_val);
580
581
587extern rpc_msg_t *
589
590
598extern boolean
600
601
607extern void
609
610
617extern boolean
619
620
621#ifdef WITH_YCONTROL
632extern status_t
633 agt_rpc_register_subsys_callback (const xmlChar *subsys_id,
634 const xmlChar *modname,
635 const xmlChar *revision,
636 const xmlChar *rpcname);
637
638
648extern void
649 agt_rpc_unregister_subsys_callback (const xmlChar *subsys_id,
650 const xmlChar *modname,
651 const xmlChar *revision,
652 const xmlChar *rpcname);
653
654#endif // WITH_YCONTROL
655
656
663extern void
665 rpc_msg_t *msg);
666
667
674extern void
675 agt_rpc_add_return_vals (dlq_hdr_t *return_valQ,
676 rpc_msg_t *msg);
677
678
684extern void
686
687
688#ifdef WITH_YCONTROL
705extern status_t
706 agt_rpc_handle_subsys_request (void *sil_sa_cb,
707 ses_cb_t *scb,
708 const xmlChar *modname,
709 const xmlChar *rpcname,
710 val_value_t *rpc_input_val,
711 val_value_t *mpid_val,
712 dlq_hdr_t *return_dataQ);
713
714
729extern status_t
730 agt_rpc_handle_subsys_action (void *sil_sa_cb,
731 ses_cb_t *scb,
732 const xmlChar *path,
733 val_value_t *action_input_val,
734 val_value_t *mpid_val,
735 dlq_hdr_t *return_dataQ);
736#endif // WITH_YCONTROL
737
738
747extern void
748 agt_rpc_finish_reply (uint32 sid,
749 void *msg);
750
751
765extern void
767
768
769#ifdef WITH_YCONTROL
775extern void
777
778
785extern agt_rpc_subsys_t *
786 agt_rpc_new_subsys (const xmlChar *subsys_id);
787
788
796extern agt_rpc_subsys_t *
797 agt_rpc_find_subsys (dlq_hdr_t *subsysQ,
798 const xmlChar *subsys_id);
799
800
817extern status_t
819 rpc_msg_t *msg,
820 const xmlChar *rpc_module,
821 const xmlChar *rpc_name,
822 val_value_t *rpc_method,
823 const xmlChar *out_filespec);
824
825#endif // WITH_YCONTROL
826
827
835extern void
837
838
850extern status_t
852 rpc_msg_t *msg,
853 val_value_t *action_val,
854 xml_node_t *method,
855 obj_template_t *rpcobj);
856
857
858
869extern status_t
871
872
875#ifdef __cplusplus
876} /* end extern 'C' */
877#endif
878
879#endif /* _H_agt_rpc */
NCX configuration database manager.
status_t agt_rpc_parse_rpc_input(ses_cb_t *scb, rpc_msg_t *msg, obj_template_t *rpcobj, xml_node_t *method)
RPC received, parse parameters against rpcio for 'input'.
Definition: agt_rpc.c:4262
status_t agt_rpc_register_subsys_callback(const xmlChar *subsys_id, const xmlChar *modname, const xmlChar *revision, const xmlChar *rpcname)
Register an object specific RPC callback function.
Definition: agt_rpc.c:4652
status_t agt_rpc_replay_config(void)
Dispatch an internal <replay-config> request used for OP_EDITOP_LOAD to load the running from startup...
Definition: agt_rpc.c:3772
boolean agt_rpc_callback_set(obj_template_t *obj)
Check if an RPC callback is registered for this object for SIL-SA usage.
Definition: agt_rpc.c:4480
void agt_rpc_support_method(const xmlChar *module, const xmlChar *method_name)
mark an RPC method or action as supported within the server
Definition: agt_rpc.c:3013
void agt_rpc_unregister_subsys_callback(const xmlChar *subsys_id, const xmlChar *modname, const xmlChar *revision, const xmlChar *rpcname)
Unregister an object specific RPC callback function.
Definition: agt_rpc.c:4814
status_t agt_rpc_handle_subsys_request(void *sil_sa_cb, ses_cb_t *scb, const xmlChar *modname, const xmlChar *rpcname, val_value_t *rpc_input_val, val_value_t *mpid_val, dlq_hdr_t *return_dataQ)
Handles incoming <rpc-request> server request messages from a subsystem.
Definition: agt_rpc.c:4953
rpc_msg_t * agt_rpc_new_dummy_msg(void)
Create a dummy rpc_msg_t.
Definition: agt_rpc.c:4447
void agt_rpc_unload_module(ncx_module_t *mod)
Check all the rpc objects from this module and clean any callbacks because the module is being unload...
Definition: agt_rpc.c:5731
status_t agt_rpc_subrpc_dispatch(ses_cb_t *scb, rpc_msg_t *msg, const xmlChar *rpc_module, const xmlChar *rpc_name, val_value_t *rpc_method, const xmlChar *out_filespec)
Dispatch an incoming <subrpc-request> request.
Definition: agt_rpc.c:5504
status_t agt_rpc_send_malformed_error(ses_cb_t *scb)
send a malformed-message error
Definition: agt_rpc.c:6092
boolean agt_rpc_callback_is_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4541
status_t agt_rpc_check_rpc_invoke(ses_cb_t *scb, rpc_msg_t *msg, obj_template_t *rpcobj)
Some RPC node parsed, check if it can be invoked or not.
Definition: agt_rpc.c:4209
status_t agt_rpc_post_psd_state(ses_cb_t *scb, rpc_msg_t *msg, status_t psdres)
Fixup parmset after parse phase.
Definition: agt_rpc.c:4340
status_t agt_rpc_handle_subsys_action(void *sil_sa_cb, ses_cb_t *scb, const xmlChar *path, val_value_t *action_input_val, val_value_t *mpid_val, dlq_hdr_t *return_dataQ)
Handles incoming <action-request> server request messages.
Definition: agt_rpc.c:5129
agt_rpc_subsys_t * agt_rpc_new_subsys(const xmlChar *subsys_id)
Malloc and Initialize a subsys record.
Definition: agt_rpc.c:5442
void agt_rpc_cleanup(void)
Cleanup the agt_rpc module.
Definition: agt_rpc.c:2907
void agt_rpc_send_error_reply(ses_cb_t *scb, status_t retres)
Operation failed or was never attempted.
Definition: agt_rpc.c:4017
agt_rpc_subsys_t * agt_rpc_find_subsys(dlq_hdr_t *subsysQ, const xmlChar *subsys_id)
Find a subsystem control block.
Definition: agt_rpc.c:5464
#define AGT_RPC_NUM_CALLBACK_PHASES
this constant is for the number of callback slots allocated in a 'cbset', and only includes the RPC p...
Definition: agt_rpc.h:89
status_t agt_rpc_invoke_action(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *method_node, val_value_t *action_val)
Invoke an Action – need to call following functions first:
Definition: agt_rpc.c:4414
status_t agt_rpc_fill_rpc_error(const rpc_err_rec_t *err, val_value_t *rpcerror)
Fill one <rpc-error> like element using the specified namespace and name, which may be different than...
Definition: agt_rpc.c:3887
status_t(* agt_rpc_method_t)(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *methnode)
Template for RPC server callbacks.
Definition: agt_rpc.h:147
status_t agt_rpc_send_rpc_error(ses_cb_t *scb, xml_msg_hdr_t *msg, const rpc_err_rec_t *err, int32 indent, boolean isfirst, boolean islast)
Send one <rpc-error> element on the specified session.
Definition: agt_rpc.c:4131
status_t agt_rpc_invoke_rpc(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *method_node)
Invoke an RPC – need to call following functions first:
Definition: agt_rpc.c:4372
boolean agt_rpc_dispatch(ses_cb_t *scb, xml_node_t *top)
Dispatch an incoming <rpc> request.
Definition: agt_rpc.c:3183
void agt_rpc_add_return_vals(dlq_hdr_t *return_valQ, rpc_msg_t *msg)
Add a Q of return values to the msg.
Definition: agt_rpc.c:4903
void agt_rpc_reorder_dataQ(rpc_msg_t *msg)
Reorder the dataQ.
Definition: agt_rpc.c:5356
ncx_backptr_t * agt_rpc_get_next_backptr(ncx_backptr_t *curptr)
Get the next backptr to the registered and supported RPC methods on the server.
Definition: agt_rpc.c:4189
status_t agt_rpc_load_config_file_val(const xmlChar *filespec, ses_id_t use_sid, val_value_t **configval, dlq_hdr_t *errorQ)
Dispatch an internal <load-config> request used for COPY-CONFIG for URL to Candidate.
Definition: agt_rpc.c:5788
void agt_rpc_free_subsys(agt_rpc_subsys_t *cb)
Clean and free a subsys record.
Definition: agt_rpc.c:5424
status_t agt_rpc_init(void)
Initialize the agt_rpc module.
Definition: agt_rpc.c:2872
void agt_rpc_callback_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4512
status_t agt_rpc_process_rpc_request(ses_cb_t *scb, rpc_msg_t *msg, val_value_t *action_val, xml_node_t *method, obj_template_t *rpcobj)
Setup Action Parent nodes for when/must processing.
Definition: agt_rpc.c:5972
void agt_rpc_unsupport_method(const xmlChar *module, const xmlChar *method_name)
mark an RPC method or action as unsupported within the server
Definition: agt_rpc.c:3057
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
void agt_rpc_finish_reply(uint32 sid, void *msg)
Finish the rpc-reply for a remote operation.
Definition: agt_rpc.c:5317
status_t agt_rpc_load_config_file(const xmlChar *filespec, cfg_template_t *cfg, boolean isload, ses_id_t use_sid, dlq_hdr_t *errQ, boolean do_config_change, const rpc_msg_t *reqmsg)
Dispatch an internal <load-config> request.
Definition: agt_rpc.c:3657
val_value_t * agt_rpc_get_config_file(const xmlChar *filespec, cfg_template_t *targetcfg, ses_id_t use_sid, dlq_hdr_t *errorQ, status_t *res)
Dispatch an internal <load-config> request except skip the INVOKE phase and just remove the 'config' ...
Definition: agt_rpc.c:3725
ncx_backptr_t * agt_rpc_get_first_backptr(void)
Get the first backptr to the registered and supported RPC methods on the server.
Definition: agt_rpc.c:4172
void agt_rpc_add_return_val(val_value_t *return_val, rpc_msg_t *msg)
Add a return value to the msg.
Definition: agt_rpc.c:4881
agt_rpc_phase_t
There are 3 different callbacks possible in the server processing chain.
Definition: agt_rpc.h:109
void agt_rpc_clear_return_data(rpc_msg_t *msg)
Clear the return data Q.
Definition: agt_rpc.c:4924
@ AGT_RPC_PH_INVOKE
(3) cb to invoke the requested method
Definition: agt_rpc.h:114
@ AGT_RPC_PH_VALIDATE
(2) cb after the input is parsed
Definition: agt_rpc.h:111
@ AGT_RPC_PH_REPLY
(4) NO CB FOR THIS STATE
Definition: agt_rpc.h:123
@ AGT_RPC_PH_PARSE
(1) NO CB FOR THIS STATE
Definition: agt_rpc.h:120
@ AGT_RPC_PH_POST_REPLY
(5) cb after the reply is generated
Definition: agt_rpc.h:117
status_t
global error return code
Definition: status_enum.h:219
uint32 ses_id_t
Session ID.
Definition: ses.h:335
NETCONF protocol remote procedure call common definitions.
NETCONF protocol standard error definitions.
NETCONF Session Common definitions module.
global error status code enumerations
the agt_rpc module stores a set of callbacks for each RPC
Definition: agt_rpc.h:153
boolean regdone
registration done flag
Definition: agt_rpc.h:158
dlq_hdr_t subsysQ
only used if WITH_YCONTROL set
Definition: agt_rpc.h:161
header for 1 subsystem that has a SIL-SA callback function registered for the RPC method in the agt_r...
Definition: agt_rpc.h:186
dlq_hdr_t qhdr
queue header
Definition: agt_rpc.h:188
status_t res
subsystem status
Definition: agt_rpc.h:194
const xmlChar * subsys_id
backptr to agt_sil_state->subsys_id
Definition: agt_rpc.h:191
struct representing 1 configuration database
Definition: cfg.h:229
used with various structs to cache back-ptrs the 'node' pointer may or may not be malloced!...
Definition: ncxtypes.h:1530
representation of one module or submodule during and after parsing
Definition: ncxtypes.h:1138
One YANG data-def-stmt.
Definition: obj.h:1232
One RPC error record built by the server before an <rpc-error> element is generated.
Definition: rpc_err.h:484
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
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:404
gather node data into a simple struct.
Definition: xml_util.h:207
XML Utilities.