yumapro  21.10T-12
YumaPro SDK
rpc.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 #ifndef _H_rpc
13 #define _H_rpc
14 /* FILE: 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 
33 date init comment
34 ----------------------------------------------------------------------
35 01-may-05 abb Begun.
36 */
37 
38 #include <time.h>
39 #include <xmlstring.h>
40 
41 
42 #ifndef _H_dlq
43 #include "dlq.h"
44 #endif
45 
46 #ifndef _H_ncxtypes
47 #include "ncxtypes.h"
48 #endif
49 
50 #ifndef _H_op
51 #include "op.h"
52 #endif
53 
54 #ifndef _H_status
55 #include "status.h"
56 #endif
57 
58 #ifndef _H_val
59 #include "val.h"
60 #endif
61 
62 #ifndef _H_xmlns
63 #include "xmlns.h"
64 #endif
65 
66 #ifndef _H_xml_msg
67 #include "xml_msg.h"
68 #endif
69 
70 #ifndef _H_xml_util
71 #include "xml_util.h"
72 #endif
73 
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77 
78 /********************************************************************
79 * *
80 * C O N S T A N T S *
81 * *
82 *********************************************************************/
83 #define RPC_STR_REQ "rpc"
84 #define RPC_STR_RPY "rpc-reply"
85 #define RPC_STR_ERR "rpc-error"
86 #define RPC_STR_MSG_ID "message-id"
87 #define RPC_STR_GRP_ID "group-id"
88 
89 #define RPC_MHDR(MSG) &(MSG)->mhdr
90 
91 #define RPC_ERR_QUEUE(MSG) &(MSG)->mhdr.errQ
92 
93 #define RPC_MSG_SET_REPLAY(MSG) (MSG)->rpc_replay_config = true
94 
95 #define RPC_MSG_IS_REPLAY(MSG) (MSG)->rpc_replay_config
96 
97 #define RPC_MSG_ID(MSG) (MSG)->rpc_message_id
98 
99 #define RPC_MSG_SIL_SA_CB(MSG) (MSG)->rpc_sil_sa_cb
100 
101 #define RPC_MSG_TXCB(MSG) (MSG)->rpc_txcb
102 
103 #define RPC_MSG_GETBULK(MSG) (MSG)->mhdr.getbulk_cb
104 
105 #define RPC_MSG_SET_WITH_TEMPLATE(MSG) (MSG)->rpc_with_template = true
106 
107 #define RPC_MSG_IS_WITH_TEMPLATE(MSG) (MSG)->rpc_with_template
108 
109 #define RPC_MSG_METHOD(MSG) (MSG)->rpc_method
110 
111 #define RPC_SET_DEFER_REPLY(MSG) (MSG)->rpc_defer_reply = TRUE
112 
113 #define RPC_IS_DEFER_REPLY(MSG) ((MSG)->rpc_defer_reply)
114 
115 /* yp-gnmi control block. Used in restconf processing code */
116 #define RPC_MSG_YPGNMI_GETCB(MSG) (MSG)->mhdr.gnmi_getcb
117 
118 /* yp-gnmi control block. Used in restconf processing code */
119 #define RPC_MSG_YPGNMI_EDITCB(MSG) (MSG)->mhdr.gnmi_editcb
120 
121 #define RPC_MSG_REPLY_TYPE(MSG) (MSG)->rpc_reply_type
122 
123 #define RPC_MSG_STATUS(MSG) (MSG)->rpc_status
124 
125 #define RPC_MSG_START_TIME(MSG) (MSG)->rpc_start_time
126 
127 #define RPC_MSG_SUBRPC_FILESPEC(MSG) (MSG)->subrpc_filespec
128 
129 #define RPC_MSG_USER1(MSG) (MSG)->rpc_user1
130 
131 #define RPC_MSG_USER2(MSG) (MSG)->rpc_user2
132 
133 #define RPC_MSG_DATA_TYPE(MSG) (MSG)->rpc_data_type
134 
135 #define RPC_MSG_DATACB(MSG) (MSG)->rpc_datacb
136 
137 
138 /********************************************************************
139 * *
140 * T Y P E S *
141 * *
142 *********************************************************************/
143 
156 typedef enum rpc_data_t_ {
163 
168 } rpc_data_t;
169 
170 
172 typedef enum rpc_rpytyp_t_ {
177 } rpc_rpytyp_t;
178 
179 
181 typedef struct rpc_msg_t_ {
185  dlq_hdr_t qhdr;
186 
195 
201  xml_attrs_t *rpc_in_attrs; /* borrowed from <rpc> elem */
202 
211  struct obj_template_t_ *rpc_method;
212 
217 
222 
227 
235 
237  struct sil_sa_cb_t_ *rpc_sil_sa_cb;
238 
244  dlq_hdr_t rpc_inputQ;
251  void *rpc_user1;
252 
254  void *rpc_user2;
255 
258 
272  rpc_data_t rpc_data_type;
273 
279  void *rpc_datacb;
280 
287  dlq_hdr_t rpc_dataQ;
288 
293 
297  struct agt_cfg_transaction_t_ *rpc_txcb;
298 
303 
308  xmlChar *rpc_message_id;
309 
314  xmlChar *rpc_trace_id;
315 
318 
321 
326  dlq_hdr_t hook_inputQ;
327 
332 
338 
340  rpc_rpytyp_t rpc_reply_type;
341 
344 
347 
352  const xmlChar *subrpc_filespec;
353 
354 } rpc_msg_t;
355 
356 
357 /********************************************************************
358 * *
359 * F U N C T I O N S *
360 * *
361 *********************************************************************/
362 
363 
369 extern rpc_msg_t *
370  rpc_new_msg (void);
371 
372 
379 extern rpc_msg_t *
380  rpc_new_out_msg (void);
381 
382 
388 extern void
389  rpc_free_msg (rpc_msg_t *msg);
390 
391 
404 extern void rpc_msg_add_error_data (rpc_msg_t *msg,
405  val_value_t *val);
406 
407 
414 extern const xmlChar *
415  rpc_msg_get_reply_type (rpc_rpytyp_t rpytyp);
416 
417 
421 #ifdef __cplusplus
422 } /* end extern 'C' */
423 #endif
424 
425 #endif /* _H_rpc */
void * rpc_user2
Same use as rpc_user1.
Definition: rpc.h:254
rpc_data_t rpc_data_type
incoming: get method reply handling builtin For RPC operations that return data, this enumeration MUS...
Definition: rpc.h:272
NETCONF protocol operation filter spec.
Definition: op.h:182
val_value_t * rpc_input
Value tree representing the container of &#39;input&#39; parameters for this RPC operation.
Definition: rpc.h:234
dlq provides general double-linked list and queue support:
Common Encoding Message Header No longer XML specific!! Used by JSON parsing as well!! Allows common ...
Definition: xml_msg.h:351
boolean rpc_defer_reply
YPSERVER mode is skipping the regular rpc-reply phase and will send the reply after doing the remote ...
Definition: rpc.h:331
xml_msg_hdr_t mhdr
generic XML message header Most in-message state is kept in the mhdr There are several places in the ...
Definition: rpc.h:194
void rpc_free_msg(rpc_msg_t *msg)
Free all the memory used by the specified rpc_msg_t.
Definition: rpc.c:152
time_t rpc_start_time
saved timestamp when started for audit record
Definition: rpc.h:346
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
rpc_data_t
Type of the <rpc-reply> data source.
Definition: rpc.h:156
status_t rpc_status
saved processing status for audit record
Definition: rpc.h:343
boolean rpc_with_template
–with-template parameter was seen in the validate phase
Definition: rpc.h:320
boolean rpc_replay_config
TRUE if this RPC is being called in replay config mode.
Definition: rpc.h:317
rpc_rpytyp_t
Type of the <rpc-reply> sent to client.
Definition: rpc.h:172
op_errop_t rpc_err_option
Enum value for the <error-option> parameter.
Definition: rpc.h:221
xmlChar * rpc_trace_id
debugging and audit message string.
Definition: rpc.h:314
const xmlChar * subrpc_filespec
saved by agt_db_api.c so the ycontrol callback function can generate an external value with the DB-AP...
Definition: rpc.h:352
STD is used by YANG rpc or action stmts; no extra <data> container will be added to the <rpc-reply> c...
Definition: rpc.h:167
struct obj_template_t_ * rpc_method
incoming: Back-pointer to the object template for this RPC operation.
Definition: rpc.h:211
STD is used by <get> and <get-config> to force a <data> container in the NETCONF namespace.
Definition: rpc.h:162
op_errop_t
NETCONF edit-config error-option types.
Definition: op.h:173
Value Node Basic Support.
xmlChar * rpc_message_id
debugging and audit message string.
Definition: rpc.h:308
op_editop_t rpc_top_editop
Enum value for the <default-operation> parameter.
Definition: rpc.h:226
rpc_msg_t * rpc_new_msg(void)
Malloc and initialize a new rpc_msg_t struct.
Definition: rpc.c:84
YANG module data structures Many internal representations of YANG module constructs.
struct sil_sa_cb_t_ * rpc_sil_sa_cb
backptr to SIL-SA edit control block if WITH_YCONTROL=1
Definition: rpc.h:237
void rpc_msg_add_error_data(rpc_msg_t *msg, val_value_t *val)
Add error data to the response message.
Definition: rpc.c:213
uint32 rpc_returncode
Internal return code used to control nested callbacks.
Definition: rpc.h:257
not set
Definition: rpc.h:173
not set
Definition: rpc.h:157
op_editop_t
NETCONF edit-config operation types.
Definition: op.h:122
XML Utilities.
xml_attrs_t * rpc_in_attrs
incoming: top-level rpc element data Queue of xml_attr_t representing any XML attributes that were pr...
Definition: rpc.h:201
XML and JSON Message send and receive support.
one value to match one type
Definition: val.h:876
reply is error
Definition: rpc.h:175
reply is data
Definition: rpc.h:176
rpc_msg_t * rpc_new_out_msg(void)
Malloc and initialize a new rpc_msg_t struct for output or for dummy use.
Definition: rpc.c:126
void * rpc_datacb
For operations that return streamed data, this pointer is set to the desired callback function to use...
Definition: rpc.h:279
status_t
global error return code
Definition: status_enum.h:186
reply is ok
Definition: rpc.h:174
op_filter_t rpc_filter
Internal structure for optimizing subtree and XPath retrieval operations.
Definition: rpc.h:292
struct agt_cfg_transaction_t_ * rpc_txcb
incoming: agent database edit transaction control block must be freed by an upper layer if set to mal...
Definition: rpc.h:297
Global error messages for status code enumerations.
const xmlChar * rpc_msg_get_reply_type(rpc_rpytyp_t rpytyp)
Get the reply type string from the message type.
Definition: rpc.c:235
boolean rpc_parse_errors
load-config parse-error and –startup-error=continue flag if the val_purge_errors_from_root function ...
Definition: rpc.h:302
NETCONF protocol operations.
xml_attrs_t rpc_defer_in_attrs
the top->attrs gets deleted so a deferred rpc-reply needs to save the rpc_in_attrs.
Definition: rpc.h:337
int rpc_agt_state
incoming: SERVER RPC processing state Enum value (0, 1, 2) for the current RPC callback phase...
Definition: rpc.h:216
rpc_rpytyp_t rpc_reply_type
saved reply type needed for audit record
Definition: rpc.h:340
XML namespace support.
dlq_hdr_t xml_attrs_t
queue of xml_attr_t
Definition: xml_util.h:152
void * rpc_user1
Void pointer that can be used by method routines to save context or whatever to store SIL-specific da...
Definition: rpc.h:251