yumapro  24.10-2
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 - 2023, 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
240extern status_t
241 agt_rpc_register_method (const xmlChar *module,
242 const xmlChar *method_name,
243 agt_rpc_phase_t phase,
244 agt_rpc_method_t method);
245
246
255extern void
256 agt_rpc_support_method (const xmlChar *module,
257 const xmlChar *method_name);
258
259
268extern void
269 agt_rpc_unsupport_method (const xmlChar *module,
270 const xmlChar *method_name);
271
272
280extern void
281 agt_rpc_unregister_method (const xmlChar *module,
282 const xmlChar *method_name);
283
284
297extern boolean
299 xml_node_t *top);
300
301
330extern status_t
331 agt_rpc_load_config_file (const xmlChar *filespec,
332 cfg_template_t *cfg,
333 boolean isload,
334 ses_id_t use_sid,
335 dlq_hdr_t *errQ,
336 boolean do_config_change,
337 const rpc_msg_t *reqmsg);
338
339
364extern val_value_t *
365 agt_rpc_get_config_file (const xmlChar *filespec,
366 cfg_template_t *targetcfg,
367 ses_id_t use_sid,
368 dlq_hdr_t *errorQ,
369 status_t *res);
370
371
392extern status_t
393 agt_rpc_load_config_file_val (const xmlChar *filespec,
394 ses_id_t use_sid,
395 val_value_t **configval,
396 dlq_hdr_t *errorQ);
397
398
416extern status_t
418
419
432extern status_t
434 val_value_t *rpcerror);
435
436
445extern void
447 status_t retres);
448
449
461extern status_t
463 xml_msg_hdr_t *msg,
464 const rpc_err_rec_t *err,
465 int32 indent,
466 boolean isfirst,
467 boolean islast);
468
469
476extern ncx_backptr_t *
478
479
487extern ncx_backptr_t *
489
490
499extern status_t
501 rpc_msg_t *msg,
502 obj_template_t *rpcobj);
503
504
514extern status_t
516 rpc_msg_t *msg,
517 obj_template_t *rpcobj,
518 xml_node_t *method);
519
520
531extern status_t
533 rpc_msg_t *msg,
534 status_t psdres);
535
536
549extern status_t
551 rpc_msg_t *msg,
552 xml_node_t *method_node);
553
554
569extern status_t
571 rpc_msg_t *msg,
572 xml_node_t *method_node,
573 val_value_t *action_val);
574
575
581extern rpc_msg_t *
583
584
592extern boolean
594
595
601extern void
603
604
611extern boolean
613
614
615#ifdef WITH_YCONTROL
626extern status_t
627 agt_rpc_register_subsys_callback (const xmlChar *subsys_id,
628 const xmlChar *modname,
629 const xmlChar *revision,
630 const xmlChar *rpcname);
631
632
642extern void
643 agt_rpc_unregister_subsys_callback (const xmlChar *subsys_id,
644 const xmlChar *modname,
645 const xmlChar *revision,
646 const xmlChar *rpcname);
647
648#endif // WITH_YCONTROL
649
650
657extern void
659 rpc_msg_t *msg);
660
661
668extern void
669 agt_rpc_add_return_vals (dlq_hdr_t *return_valQ,
670 rpc_msg_t *msg);
671
672
678extern void
680
681
682#ifdef WITH_YCONTROL
699extern status_t
700 agt_rpc_handle_subsys_request (void *sil_sa_cb,
701 ses_cb_t *scb,
702 const xmlChar *modname,
703 const xmlChar *rpcname,
704 val_value_t *rpc_input_val,
705 val_value_t *mpid_val,
706 dlq_hdr_t *return_dataQ);
707
708
723extern status_t
724 agt_rpc_handle_subsys_action (void *sil_sa_cb,
725 ses_cb_t *scb,
726 const xmlChar *path,
727 val_value_t *action_input_val,
728 val_value_t *mpid_val,
729 dlq_hdr_t *return_dataQ);
730#endif // WITH_YCONTROL
731
732
741extern void
742 agt_rpc_finish_reply (uint32 sid,
743 void *msg);
744
745
759extern void
761
762
763#ifdef WITH_YCONTROL
769extern void
771
772
779extern agt_rpc_subsys_t *
780 agt_rpc_new_subsys (const xmlChar *subsys_id);
781
782
790extern agt_rpc_subsys_t *
791 agt_rpc_find_subsys (dlq_hdr_t *subsysQ,
792 const xmlChar *subsys_id);
793
794
811extern status_t
813 rpc_msg_t *msg,
814 const xmlChar *rpc_module,
815 const xmlChar *rpc_name,
816 val_value_t *rpc_method,
817 const xmlChar *out_filespec);
818
819#endif // WITH_YCONTROL
820
821
829extern void
831
832
844extern status_t
846 rpc_msg_t *msg,
847 val_value_t *action_val,
848 xml_node_t *method,
849 obj_template_t *rpcobj);
850
851
854#ifdef __cplusplus
855} /* end extern 'C' */
856#endif
857
858#endif /* _H_agt_rpc */
@ brief 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:4194
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:4584
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:3704
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:4412
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:2945
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:4746
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:4885
rpc_msg_t * agt_rpc_new_dummy_msg(void)
Create a dummy rpc_msg_t.
Definition: agt_rpc.c:4379
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:5663
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:5436
boolean agt_rpc_callback_is_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4473
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:4141
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:4272
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:5061
agt_rpc_subsys_t * agt_rpc_new_subsys(const xmlChar *subsys_id)
Malloc and Initialize a subsys record.
Definition: agt_rpc.c:5374
void agt_rpc_cleanup(void)
Cleanup the agt_rpc module.
Definition: agt_rpc.c:2839
void agt_rpc_send_error_reply(ses_cb_t *scb, status_t retres)
Operation failed or was never attempted.
Definition: agt_rpc.c:3949
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:5396
status_t agt_rpc_register_method(const xmlChar *module, const xmlChar *method_name, agt_rpc_phase_t phase, agt_rpc_method_t method)
add callback for 1 phase of RPC processing
Definition: agt_rpc.c:2866
#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:4346
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:3819
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:4063
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:4304
boolean agt_rpc_dispatch(ses_cb_t *scb, xml_node_t *top)
Dispatch an incoming <rpc> request.
Definition: agt_rpc.c:3115
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:4835
void agt_rpc_reorder_dataQ(rpc_msg_t *msg)
Reorder the dataQ.
Definition: agt_rpc.c:5288
void agt_rpc_unregister_method(const xmlChar *module, const xmlChar *method_name)
remove the callback functions for all phases of RPC or Action processing for the specified RPC method...
Definition: agt_rpc.c:3063
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:4121
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:5720
void agt_rpc_free_subsys(agt_rpc_subsys_t *cb)
Clean and free a subsys record.
Definition: agt_rpc.c:5356
status_t agt_rpc_init(void)
Initialize the agt_rpc module.
Definition: agt_rpc.c:2804
void agt_rpc_callback_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4444
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:5858
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:2989
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:5249
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:3589
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:3657
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:4104
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:4813
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:4856
@ 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:210
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:1229
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:181
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.