yumapro  23.10T-7
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
160#ifdef WITH_YCONTROL
161 dlq_hdr_t subsysQ;
162#endif
163
165
166
177typedef status_t
179 rpc_msg_t *msg,
180 uint32 indent);
181
182
187typedef struct agt_rpc_subsys_t_ {
189 dlq_hdr_t qhdr;
190
192 const xmlChar *subsys_id;
193
197
198
199/********************************************************************
200* *
201* F U N C T I O N S *
202* *
203*********************************************************************/
204
205
215extern status_t
216 agt_rpc_init (void);
217
218
225extern void
226 agt_rpc_cleanup (void);
227
228
241extern status_t
242 agt_rpc_register_method (const xmlChar *module,
243 const xmlChar *method_name,
244 agt_rpc_phase_t phase,
245 agt_rpc_method_t method);
246
247
256extern void
257 agt_rpc_support_method (const xmlChar *module,
258 const xmlChar *method_name);
259
260
269extern void
270 agt_rpc_unsupport_method (const xmlChar *module,
271 const xmlChar *method_name);
272
273
281extern void
282 agt_rpc_unregister_method (const xmlChar *module,
283 const xmlChar *method_name);
284
285
298extern boolean
300 xml_node_t *top);
301
302
331extern status_t
332 agt_rpc_load_config_file (const xmlChar *filespec,
333 cfg_template_t *cfg,
334 boolean isload,
335 ses_id_t use_sid,
336 dlq_hdr_t *errQ,
337 boolean do_config_change,
338 const rpc_msg_t *reqmsg);
339
340
365extern val_value_t *
366 agt_rpc_get_config_file (const xmlChar *filespec,
367 cfg_template_t *targetcfg,
368 ses_id_t use_sid,
369 dlq_hdr_t *errorQ,
370 status_t *res);
371
372
393extern status_t
394 agt_rpc_load_config_file_val (const xmlChar *filespec,
395 ses_id_t use_sid,
396 val_value_t **configval,
397 dlq_hdr_t *errorQ);
398
399
417extern status_t
419
420
433extern status_t
435 val_value_t *rpcerror);
436
437
446extern void
448 status_t retres);
449
450
462extern status_t
464 xml_msg_hdr_t *msg,
465 const rpc_err_rec_t *err,
466 int32 indent,
467 boolean isfirst,
468 boolean islast);
469
470
477extern ncx_backptr_t *
479
480
488extern ncx_backptr_t *
490
491
500extern status_t
502 rpc_msg_t *msg,
503 obj_template_t *rpcobj);
504
505
515extern status_t
517 rpc_msg_t *msg,
518 obj_template_t *rpcobj,
519 xml_node_t *method);
520
521
532extern status_t
534 rpc_msg_t *msg,
535 status_t psdres);
536
537
550extern status_t
552 rpc_msg_t *msg,
553 xml_node_t *method_node);
554
555
570extern status_t
572 rpc_msg_t *msg,
573 xml_node_t *method_node,
574 val_value_t *action_val);
575
576
582extern rpc_msg_t *
584
585
593extern boolean
595
596
602extern void
604
605
612extern boolean
614
615
616#ifdef WITH_YCONTROL
627extern status_t
628 agt_rpc_register_subsys_callback (const xmlChar *subsys_id,
629 const xmlChar *modname,
630 const xmlChar *revision,
631 const xmlChar *rpcname);
632
633
643extern void
644 agt_rpc_unregister_subsys_callback (const xmlChar *subsys_id,
645 const xmlChar *modname,
646 const xmlChar *revision,
647 const xmlChar *rpcname);
648
649#endif // WITH_YCONTROL
650
651
658extern void
660 rpc_msg_t *msg);
661
662
669extern void
670 agt_rpc_add_return_vals (dlq_hdr_t *return_valQ,
671 rpc_msg_t *msg);
672
673
679extern void
681
682
683#ifdef WITH_YCONTROL
700extern status_t
701 agt_rpc_handle_subsys_request (void *sil_sa_cb,
702 ses_cb_t *scb,
703 const xmlChar *modname,
704 const xmlChar *rpcname,
705 val_value_t *rpc_input_val,
706 val_value_t *mpid_val,
707 dlq_hdr_t *return_dataQ);
708
709
724extern status_t
725 agt_rpc_handle_subsys_action (void *sil_sa_cb,
726 ses_cb_t *scb,
727 const xmlChar *path,
728 val_value_t *action_input_val,
729 val_value_t *mpid_val,
730 dlq_hdr_t *return_dataQ);
731#endif // WITH_YCONTROL
732
733
742extern void
743 agt_rpc_finish_reply (uint32 sid,
744 void *msg);
745
746
760extern void
762
763
764#ifdef WITH_YCONTROL
770extern void
772
773
780extern agt_rpc_subsys_t *
781 agt_rpc_new_subsys (const xmlChar *subsys_id);
782
783
791extern agt_rpc_subsys_t *
792 agt_rpc_find_subsys (dlq_hdr_t *subsysQ,
793 const xmlChar *subsys_id);
794
795
812extern status_t
814 rpc_msg_t *msg,
815 const xmlChar *rpc_module,
816 const xmlChar *rpc_name,
817 val_value_t *rpc_method,
818 const xmlChar *out_filespec);
819
820#endif // WITH_YCONTROL
821
822
830extern void
832
833
845extern status_t
847 rpc_msg_t *msg,
848 val_value_t *action_val,
849 xml_node_t *method,
850 obj_template_t *rpcobj);
851
852
855#ifdef __cplusplus
856} /* end extern 'C' */
857#endif
858
859#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:4172
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:4562
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:3682
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:4390
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:2923
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:4724
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:4863
rpc_msg_t * agt_rpc_new_dummy_msg(void)
Create a dummy rpc_msg_t.
Definition: agt_rpc.c:4357
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:5626
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:5399
boolean agt_rpc_callback_is_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4451
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:4119
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:4250
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:5029
agt_rpc_subsys_t * agt_rpc_new_subsys(const xmlChar *subsys_id)
Malloc and Initialize a subsys record.
Definition: agt_rpc.c:5337
void agt_rpc_cleanup(void)
Cleanup the agt_rpc module.
Definition: agt_rpc.c:2818
void agt_rpc_send_error_reply(ses_cb_t *scb, status_t retres)
Operation failed or was never attempted.
Definition: agt_rpc.c:3927
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:5359
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:2844
#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:4324
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:3797
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:4041
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:4282
boolean agt_rpc_dispatch(ses_cb_t *scb, xml_node_t *top)
Dispatch an incoming <rpc> request.
Definition: agt_rpc.c:3093
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:4813
void agt_rpc_reorder_dataQ(rpc_msg_t *msg)
Reorder the dataQ.
Definition: agt_rpc.c:5251
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:3041
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:4099
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:5683
void agt_rpc_free_subsys(agt_rpc_subsys_t *cb)
Clean and free a subsys record.
Definition: agt_rpc.c:5319
status_t agt_rpc_init(void)
Initialize the agt_rpc module.
Definition: agt_rpc.c:2783
void agt_rpc_callback_regdone(obj_template_t *obj)
Set the RPC as register done.
Definition: agt_rpc.c:4422
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:5821
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:2967
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
void agt_rpc_finish_reply(uint32 sid, void *msg)
Finish the rpc-reply for a remote operation.
Definition: agt_rpc.c:5212
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:3567
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:3635
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:4082
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:4791
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:4834
@ 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
Q of agt_rpc_subsys_t.
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:187
dlq_hdr_t qhdr
queue header
Definition: agt_rpc.h:189
status_t res
subsystem status
Definition: agt_rpc.h:195
const xmlChar * subsys_id
backptr to agt_sil_state->subsys_id
Definition: agt_rpc.h:192
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:1526
representation of one module or submodule during and after parsing
Definition: ncxtypes.h:1134
One YANG data-def-stmt.
Definition: obj.h:1209
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:911
Common Encoding Message Header No longer XML specific!! Used by JSON and CBOR parsing as well!...
Definition: xml_msg.h:397
gather node data into a simple struct.
Definition: xml_util.h:207
XML Utilities.