yumapro  20.10-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_ {
182  dlq_hdr_t qhdr;
189  xml_msg_hdr_t mhdr;
190 
192  xml_attrs_t *rpc_in_attrs; /* borrowed from <rpc> elem */
193 
202 
205  op_errop_t rpc_err_option;
206  op_editop_t rpc_top_editop;
211  val_value_t *rpc_input; /* malloced in rpc_new_msg */
212 
215 
221  dlq_hdr_t rpc_inputQ;
228  void *rpc_user1;
229  void *rpc_user2;
231  uint32 rpc_returncode;
240  rpc_data_t rpc_data_type;
241  void *rpc_datacb;
242  dlq_hdr_t rpc_dataQ;
243  op_filter_t rpc_filter;
249 
254 
256  xmlChar *rpc_message_id;
257  xmlChar *rpc_trace_id;
263 
268  dlq_hdr_t hook_inputQ;
274 
281  rpc_rpytyp_t rpc_reply_type;
282  status_t rpc_status;
283  time_t rpc_start_time;
289  const xmlChar *subrpc_filespec;
290 
291 } rpc_msg_t;
292 
293 
294 /********************************************************************
295 * *
296 * F U N C T I O N S *
297 * *
298 *********************************************************************/
299 
300 
306 extern rpc_msg_t *
307  rpc_new_msg (void);
308 
309 
316 extern rpc_msg_t *
317  rpc_new_out_msg (void);
318 
319 
325 extern void
326  rpc_free_msg (rpc_msg_t *msg);
327 
328 
341 extern void rpc_msg_add_error_data (rpc_msg_t *msg,
342  val_value_t *val);
343 
344 
351 extern const xmlChar *
352  rpc_msg_get_reply_type (rpc_rpytyp_t rpytyp);
353 
354 
358 #ifdef __cplusplus
359 } /* end extern 'C' */
360 #endif
361 
362 #endif /* _H_rpc */
rpc_msg_t_
NETCONF Server and Client RPC Request/Reply Message Header.
Definition: rpc.h:181
cfg.h
RPC_RPYTYP_NONE
@ RPC_RPYTYP_NONE
not set
Definition: rpc.h:173
xml_msg_clean_hdr
void xml_msg_clean_hdr(xml_msg_hdr_t *msg)
Clean all the memory used by the specified xml_msg_hdr_t but do not free the struct itself.
Definition: xml_msg.c:438
rpc_msg_t_::rpc_parse_errors
boolean rpc_parse_errors
load-config parse-error and –startup-error=continue flag if the val_purge_errors_from_root function i...
Definition: rpc.h:253
rpc_msg_t_::mhdr
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:189
rpc_rpytyp_t_
rpc_rpytyp_t_
Type of the <rpc-reply> sent to client.
Definition: rpc.h:172
agt_cfg_transaction_t_
Transaction Control Block.
Definition: agt_cfg.h:224
rpc_msg_t_::rpc_defer_reply
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:273
rpc_msg_t_::rpc_with_template
boolean rpc_with_template
–with-template parameter was seen in the validate phase
Definition: rpc.h:262
val.h
Value Node Basic Support.
xml_util.h
XML Utilities.
rpc_msg_t_::rpc_defer_in_attrs
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:278
rpc_msg_t_::rpc_agt_state
int rpc_agt_state
incoming: SERVER RPC processing state
Definition: rpc.h:204
RPC_RPYTYP_OK
@ RPC_RPYTYP_OK
reply is ok
Definition: rpc.h:174
RPC_DATA_YANG
@ RPC_DATA_YANG
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
op.h
NETCONF protocol operations.
rpc_msg_t_::rpc_start_time
time_t rpc_start_time
timestamp when started
Definition: rpc.h:283
xml_clean_attrs
void xml_clean_attrs(xml_attrs_t *attrs)
clean an xml_attrs_t variable
Definition: xml_util.c:1243
rpc_msg_t_::rpc_data_type
rpc_data_t rpc_data_type
incoming: get method reply handling builtin If the rpc_datacb is non-NULL then it will be used as a c...
Definition: rpc.h:240
OP_EDITOP_MERGE
@ OP_EDITOP_MERGE
edit op is merge
Definition: op.h:124
rpc_msg_t_::rpc_datacb
void * rpc_datacb
agt_rpc_data_cb_t
Definition: rpc.h:241
rpc_msg_t_::qhdr
dlq_hdr_t qhdr
queue header
Definition: rpc.h:182
xml_init_attrs
void xml_init_attrs(xml_attrs_t *attrs)
initialize an xml_attrs_t variable
Definition: xml_util.c:745
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
rpc_msg_t_::rpc_method
struct obj_template_t_ * rpc_method
incoming: 2nd-level method name element data, used in agt_output_filter to check get or get-config; c...
Definition: rpc.h:201
rpc_new_out_msg
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
rpc.h
NETCONF protocol remote procedure call common definitions.
rpc_msg_t_::hook_inputQ
dlq_hdr_t hook_inputQ
points to add_edit_value node comming from the users freed in the end of transaction.
Definition: rpc.h:268
rpc_msg_t_::rpc_replay_config
boolean rpc_replay_config
replay config mode
Definition: rpc.h:259
rpc_msg_t_::subrpc_filespec
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:289
rpc_msg_t_::rpc_reply_type
rpc_rpytyp_t rpc_reply_type
saved for audit record if needed
Definition: rpc.h:281
xml_msg_init_hdr
void xml_msg_init_hdr(xml_msg_hdr_t *msg)
Initialize a new xml_msg_hdr_t struct.
Definition: xml_msg.c:393
xml_msg.h
XML and JSON Message send and receive support.
rpc_msg_t_::rpc_input
val_value_t * rpc_input
for an action, the rpc_input node is not used; Instead the rpc_actionval backptr is used instead
Definition: rpc.h:211
rpc_msg_t_::rpc_status
status_t rpc_status
processing status
Definition: rpc.h:282
rpc_msg_t_::rpc_inputQ
dlq_hdr_t rpc_inputQ
the rpc_inputQ is used with JSON encoded input since an array is allowed at the top-level; it is used...
Definition: rpc.h:221
rpc_msg_t_::rpc_user1
void * rpc_user1
incoming: hooks for method routines to save context or whatever hack: transfer pointers from validate...
Definition: rpc.h:228
rpc_data_t_
rpc_data_t_
Type of the <rpc-reply> data source.
Definition: rpc.h:156
ncxtypes.h
YANG module data structures Many internal representations of YANG module constructs.
rpc_msg_t_::rpc_user2
void * rpc_user2
2nd user pointer
Definition: rpc.h:229
rpc_new_msg
rpc_msg_t * rpc_new_msg(void)
Malloc and initialize a new rpc_msg_t struct.
Definition: rpc.c:84
rpc_err.h
NETCONF protocol standard error definitions.
rpc_msg_add_error_data
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
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
rpc_free_msg
void rpc_free_msg(rpc_msg_t *msg)
Free all the memory used by the specified rpc_msg_t.
Definition: rpc.c:152
rpc_msg_t_::rpc_dataQ
dlq_hdr_t rpc_dataQ
data reply: Q of val_value_t
Definition: rpc.h:242
rpc_msg_t_::rpc_filter
op_filter_t rpc_filter
backptrs for get* methods
Definition: rpc.h:243
RPC_DATA_STD
@ RPC_DATA_STD
STD is used by <get> and <get-config> to force a <data> container in the NETCONF namespace.
Definition: rpc.h:162
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
ncx.h
YANG module utility functions.
rpc_msg_t_::rpc_txcb
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:248
xml_attrs_t
dlq_hdr_t xml_attrs_t
queue of xml_attr_t
Definition: xml_util.h:151
obj.h
Data Object Support.
RPC_DATA_NONE
@ RPC_DATA_NONE
not set
Definition: rpc.h:157
rpc_msg_t_::rpc_sil_sa_cb
struct sil_sa_cb_t_ * rpc_sil_sa_cb
backptr to SIL-SA edit control block if WITH_YCONTROL=1
Definition: rpc.h:214
rpc_msg_t_::rpc_in_attrs
xml_attrs_t * rpc_in_attrs
incoming: top-level rpc element data
Definition: rpc.h:192
rpc_msg_get_reply_type
const xmlChar * rpc_msg_get_reply_type(rpc_rpytyp_t rpytyp)
Get the reply type string from the message type.
Definition: rpc.c:235
dlq_enque
void dlq_enque(REG void *newP, REG dlq_hdrT *listP)
add a queue node to the end of a queue list Add newP to listP
Definition: dlq.c:246
sil_sa_cb_t_
control block for the SIL-SA module
Definition: sil_sa_types.h:167
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
rpc_msg_t_::rpc_trace_id
xmlChar * rpc_trace_id
backptr into rpc_in_attrs
Definition: rpc.h:257
rpc_msg_t_::rpc_returncode
uint32 rpc_returncode
for nested callbacks
Definition: rpc.h:231
rpc_msg_t_::rpc_err_option
op_errop_t rpc_err_option
error option
Definition: rpc.h:205
RPC_RPYTYP_ERROR
@ RPC_RPYTYP_ERROR
reply is error
Definition: rpc.h:175
xmlns.h
XML namespace support.
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
status.h
Global error messages for status code enumerations.
dlq.h
dlq provides general double-linked list and queue support:
rpc_msg_t_::rpc_message_id
xmlChar * rpc_message_id
debugging and audit message strings
Definition: rpc.h:256
rpc_msg_t_::rpc_top_editop
op_editop_t rpc_top_editop
for edit-config
Definition: rpc.h:206
RPC_RPYTYP_DATA
@ RPC_RPYTYP_DATA
reply is data
Definition: rpc.h:176
obj_template_t_
One YANG data-def-stmt.
Definition: obj.h:1056