yumapro  20.10-12
YumaPro SDK
agt_action.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 #ifndef _H_agt_action
12 #define _H_agt_action
13 
14 /* FILE: agt_action.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 03-jan-16 abb Begun
36 
37 */
38 
39 #ifndef _H_agt_rpc
40 #include "agt_rpc.h"
41 #endif
42 
43 #ifndef _H_rpc
44 #include "rpc.h"
45 #endif
46 
47 #ifndef _H_ses
48 #include "ses.h"
49 #endif
50 
51 #ifndef _H_status_enum
52 #include "status_enum.h"
53 #endif
54 
55 #ifndef _H_val
56 #include "val.h"
57 #endif
58 
59 #ifndef _H_xml_util
60 #include "xml_util.h"
61 #endif
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 
68 /********************************************************************
69 * *
70 * T Y P E S *
71 * *
72 *********************************************************************/
73 
74 
125 typedef status_t
126  (*agt_action_cb_t) (ses_cb_t *scb,
127  rpc_msg_t *msg,
128  xml_node_t *methnode,
129  val_value_t *actionval);
130 
131 
133 typedef struct agt_action_cbset_t_ {
136 
138  boolean regdone;
139 
140 #ifdef WITH_YCONTROL
141 
144  dlq_hdr_t subsysQ;
145 #endif
146 
147 } agt_action_cbset_t;
148 
149 
150 /********************************************************************
151 * *
152 * F U N C T I O N S *
153 * *
154 *********************************************************************/
155 
156 
162 extern status_t
163  agt_action_init (void);
164 
165 
171 extern void
172  agt_action_cleanup (void);
173 
174 
184 extern status_t
185  agt_action_register_action (const xmlChar *defpath,
186  agt_rpc_phase_t phase,
187  agt_action_cb_t action_cb);
188 
189 
196 extern void
197  agt_action_unregister_action (const xmlChar *defpath);
198 
199 
205 extern boolean
206  agt_action_is_action (obj_template_t *rpcobj);
207 
208 
225 extern status_t
226  agt_action_parse_input (ses_cb_t *scb,
227  rpc_msg_t *msg,
228  xml_node_t *method,
229  obj_template_t *rpcobj,
230  val_value_t **action_val);
231 
239 extern boolean
240  agt_action_callback_set (obj_template_t *obj);
241 
242 
248 extern void agt_action_callback_regdone (obj_template_t *obj);
249 
250 
257 extern boolean
258  agt_action_callback_is_regdone (obj_template_t *obj);
259 
260 
261 #ifdef WITH_YCONTROL
262 
269 extern status_t
270  agt_action_register_subsys_callback (const xmlChar *subsys_id,
271  const xmlChar *defpath);
272 
273 
280 extern void
281  agt_action_unregister_subsys_callback (const xmlChar *subsys_id,
282  const xmlChar *defpath);
283 
284 #endif // WITH_YCONTROL
285 
286 
293 extern val_value_t *
294  agt_action_find_node (val_value_t *val);
295 
296 
304 extern void
305  agt_action_unload_module (ncx_module_t *mod);
306 
307 
311 #ifdef __cplusplus
312 } /* end extern 'C' */
313 #endif
314 
315 #endif /* _H_agt_action */
agt_rpc_find_subsys
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:4874
agt_action_is_action
boolean agt_action_is_action(obj_template_t *rpcobj)
Check if the specified node is the action.
Definition: agt_action.c:256
ses.h
NETCONF Session Common definitions module.
agt_action_cleanup
void agt_action_cleanup(void)
Cleanup the Action handler.
Definition: agt_action.c:232
DUMP_VAL_LOG
@ DUMP_VAL_LOG
dump val to main log
Definition: val.h:777
agt_action_parse_input
status_t agt_action_parse_input(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *method, obj_template_t *rpcobj, val_value_t **action_val)
RPC "<action>" received, parse parameters against anydata 'action'.
Definition: agt_action.c:412
cfg.h
agt_rpc_new_subsys
agt_rpc_subsys_t * agt_rpc_new_subsys(const xmlChar *subsys_id)
Malloc and Initialize a subsys record.
Definition: agt_rpc.c:4852
agt_action_cbset_t_::acb
agt_action_cb_t acb[AGT_RPC_NUM_CALLBACK_PHASES]
array of callback functions keyed by callback phase
Definition: agt_action.h:135
ERR_NCX_WRONG_NODETYP
@ ERR_NCX_WRONG_NODETYP
282
Definition: status_enum.h:325
agt_util.h
Utility Functions for NCX Server method routines.
agt_rpc_register_method
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:2557
agt_action_register_action
status_t agt_action_register_action(const xmlChar *defpath, agt_rpc_phase_t phase, agt_action_cb_t action_cb)
add callback for 1 phase of action processing
Definition: agt_action.c:280
tstamp.h
Timestamp utilities.
ncx_find_backptr
ncx_backptr_t * ncx_find_backptr(const dlq_hdr_t *que, void *node)
Find the specified back pointer struct.
Definition: ncx.c:11609
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
val.h
Value Node Basic Support.
xml_util.h
XML Utilities.
agt_action_unregister_subsys_callback
void agt_action_unregister_subsys_callback(const xmlChar *subsys_id, const xmlChar *defpath)
Unregister an object specific ACTION callback function.
Definition: agt_action.c:654
rpc_err_dump_errors
void rpc_err_dump_errors(const rpc_msg_t *msg, log_debug_t lvl)
Dump the error messages in the RPC message error Q.
Definition: rpc_err.c:488
AGT_RPC_PH_PARSE
@ AGT_RPC_PH_PARSE
(1) NO CB FOR THIS STATE
Definition: agt_rpc.h:124
agt_rpc.h
NETCONF protocol remote procedure call server-side definitions.
AGT_RPC_PH_VALIDATE
@ AGT_RPC_PH_VALIDATE
(2) cb after the input is parsed
Definition: agt_rpc.h:115
agt_action_callback_is_regdone
boolean agt_action_callback_is_regdone(obj_template_t *obj)
Set the ACTION as register done.
Definition: agt_action.c:540
status_enum.h
global error status code enumerations
ncx_clean_backptrQ
void ncx_clean_backptrQ(dlq_hdr_t *backptrQ)
Clean an entire Q of ncx_backptr_t structs.
Definition: ncx.c:11470
obj_get_mod
ncx_module_t * obj_get_mod(obj_template_t *obj)
Get the module pointer for this object.
Definition: obj.c:12218
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
agt_action.h
NETCONF Server YANG action handler.
xml_wr.h
XML Write functions.
ncx_next_backptr
ncx_backptr_t * ncx_next_backptr(ncx_backptr_t *curptr)
Get next back pointer struct.
Definition: ncx.c:11545
agt_action_cbset_t_
the agt_rpc module stores a set of callbacks for each RPC
Definition: agt_action.h:133
op.h
NETCONF protocol operations.
ncxmod.h
NCX Module Load Manager.
agt_action_find_node
val_value_t * agt_action_find_node(val_value_t *val)
Find the nested node that is an action.
Definition: agt_action.c:730
NCX_DC_CONFIG
@ NCX_DC_CONFIG
persistent config
Definition: ncxtypes.h:192
agt_cb.h
NETCONF Server Data Model callback handler.
obj_is_action
boolean obj_is_action(const obj_template_t *obj)
Check if the object is a YANG 1.1 action.
Definition: obj.c:14028
agt_action_unload_module
void agt_action_unload_module(ncx_module_t *mod)
Check all the action objects from this module and clean any callbacks because the module is being unl...
Definition: agt_action.c:766
xmlns_yang_id
xmlns_id_t xmlns_yang_id(void)
Get the ID for the YANG namespace or 0 if it doesn't exist.
Definition: xmlns.c:1017
agt_rpc_unregister_method
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:2759
agt_val.h
NETCONF Server database callback handler.
agt_action_unregister_action
void agt_action_unregister_action(const xmlChar *defpath)
remove a callback for all phases of action processing
Definition: agt_action.c:369
agt_action_register_subsys_callback
status_t agt_action_register_subsys_callback(const xmlChar *subsys_id, const xmlChar *defpath)
Register an object specific ACTION callback function.
Definition: agt_action.c:573
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
agt_action_cb_t
status_t(* agt_action_cb_t)(ses_cb_t *scb, rpc_msg_t *msg, xml_node_t *methnode, val_value_t *actionval)
Template for Action server callbacks.
Definition: agt_action.h:126
obj_force_root
void obj_force_root(obj_template_t *obj)
Set the object as an anydata type of root.
Definition: obj.c:14168
ERR_NCX_MOD_NOT_FOUND
@ ERR_NCX_MOD_NOT_FOUND
236
Definition: status_enum.h:275
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
obj_get_name
const xmlChar * obj_get_name(const obj_template_t *obj)
Get the name field for this obj.
Definition: obj.c:10511
ncx_find_object
obj_template_t * ncx_find_object(ncx_module_t *mod, const xmlChar *objname)
Find a top level module object.
Definition: ncx.c:4345
dlq_createSQue
void dlq_createSQue(dlq_hdrT *queAddr)
create a static queue header
Definition: dlq.c:177
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
LOG_DEBUG_WARN
@ LOG_DEBUG_WARN
all errors + warnings
Definition: log.h:391
dlq_remove
void dlq_remove(void *nodeP)
remove the queue entry from its queue list entry MUST have been enqueued somehow before this function...
Definition: dlq.c:519
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
rpc.h
NETCONF protocol remote procedure call common definitions.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
ERR_INTERNAL_INIT_SEQ
@ ERR_INTERNAL_INIT_SEQ
007
Definition: status_enum.h:197
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
AGT_RPC_NUM_CALLBACK_PHASES
#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
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
yangconst.h
Contains YANG constants separated to prevent H file include loops.
YANG_K_ACTION
#define YANG_K_ACTION
YANG keyword/YIN element names.
Definition: yangconst.h:108
agt.h
Multi-Protocol Network Management Server.
agt_action_cbset_t_::regdone
boolean regdone
flag registration done
Definition: agt_action.h:138
val_dump_value_max
void val_dump_value_max(val_value_t *val, int32 startindent, int32 indent_amount, val_dumpvalue_mode_t dumpmode, ncx_display_mode_t display_mode, boolean with_meta, boolean configonly, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5859
agt_val_parse_nc
status_t agt_val_parse_nc(ses_cb_t *scb, xml_msg_hdr_t *msg, obj_template_t *obj, const xml_node_t *startnode, ncx_data_class_t parentdc, val_value_t *retval)
Parse NETCONF PDU sub-contents into value fields.
Definition: agt_val_parse.c:118
agt_action_cbset_t_::subsysQ
dlq_hdr_t subsysQ
Q of agt_rpc_subsys_t for transaction handling to 0 or more subsystem handlers for this action.
Definition: agt_action.h:144
ncx_first_backptr
ncx_backptr_t * ncx_first_backptr(dlq_hdr_t *que)
Get first back pointer struct.
Definition: ncx.c:11513
agt_val_parse.h
XML Parameter Value Parser Module.
obj_get_mod_name
const xmlChar * obj_get_mod_name(const obj_template_t *obj)
Get the module name for this object.
Definition: obj.c:12176
SES_IS_DUMMY
#define SES_IS_DUMMY(S)
test if this is a dummy session
Definition: ses.h:135
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
val_get_next_child
val_value_t * val_get_next_child(const val_value_t *curchild)
Get the next child node.
Definition: val.c:8496
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
AGT_RPC_PH_INVOKE
@ AGT_RPC_PH_INVOKE
(3) cb to invoke the requested method
Definition: agt_rpc.h:118
agt_action_callback_set
boolean agt_action_callback_set(obj_template_t *obj)
Check if an ACTION callback is registered for this object for SIL-SA usage.
Definition: agt_action.c:479
AGT_ACTION_MOD
#define AGT_ACTION_MOD
YANG attributes module name.
Definition: agt.h:436
ncx_remove_backptr
void ncx_remove_backptr(ncx_backptr_t *ptr)
Remove the specified backptr for deletion.
Definition: ncx.c:11592
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
XML_MSG_ACTIONVAL
#define XML_MSG_ACTIONVAL(M)
Get YANG 1.1 action value node.
Definition: xml_msg.h:264
rpc_err.h
NETCONF protocol standard error definitions.
agt_cfg.h
Manage Server configuration edit transactions.
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
val_get_first_child
val_value_t * val_get_first_child(const val_value_t *parent)
Get the first child node.
Definition: val.c:8477
dlq_empty
#define dlq_empty(listP)
check if queue list is empty
Definition: dlq.h:367
agt_acm.h
NETCONF Server Access Control Entry Points.
ncx_get_backptr_node
void * ncx_get_backptr_node(ncx_backptr_t *backptr)
Get the back pointer node pointer.
Definition: ncx.c:11577
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
agt_rpcerr.h
NETCONF protocol <rpc-error> server-side handler.
obj.h
Data Object Support.
LOG_DEBUG_DEBUG3
@ LOG_DEBUG_DEBUG3
debug level 3
Definition: log.h:396
agt_action_callback_regdone
void agt_action_callback_regdone(obj_template_t *obj)
Set the ACTION as register done.
Definition: agt_action.c:511
NCX_DISPLAY_MODE_MODULE
@ NCX_DISPLAY_MODE_MODULE
plain CLI display mode with YANG module names added to nodes
Definition: ncxtypes.h:457
agt_rpc_free_subsys
void agt_rpc_free_subsys(agt_rpc_subsys_t *cb)
Clean and free a subsys record.
Definition: agt_rpc.c:4834
xpath_find_schema_target_int
status_t xpath_find_schema_target_int(const xmlChar *target, obj_template_t **targobj)
@
Definition: xpath.c:2475
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
ncx_find_module
ncx_module_t * ncx_find_module(const xmlChar *modname, const xmlChar *revision)
Find a ncx_module_t in the ncx_sesmodQ.
Definition: ncx.c:3227
ncx_free_backptr
void ncx_free_backptr(ncx_backptr_t *ptr)
Free an ncx_backptr_t struct.
Definition: ncx.c:11433
status.h
Global error messages for status code enumerations.
log_debug3_append
void void void void void void void void void void void void log_debug3_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG3 log entry.
obj_get_nsid
xmlns_id_t obj_get_nsid(const obj_template_t *obj)
Get the namespace ID for this object.
Definition: obj.c:12395
ncx_new_backptr
ncx_backptr_t * ncx_new_backptr(void *node)
Malloc and initialize a new ncx_backptr_t struct.
Definition: ncx.c:11412
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
agt_action_init
status_t agt_action_init(void)
Initialize the Action handler.
Definition: agt_action.c:182
NCX_DEF_INDENT
#define NCX_DEF_INDENT
default indent amount for nesting XML or other structured output
Definition: ncxconst.h:441