yumapro  20.10-12
YumaPro SDK
agt_xpath.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_agt_xpath
13 #define _H_agt_xpath
14 
15 /* FILE: agt_xpath.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
29 /*********************************************************************
30 * *
31 * C H A N G E H I S T O R Y *
32 * *
33 *********************************************************************
34 
35 date init comment
36 ----------------------------------------------------------------------
37 27-jan-09 abb Begun
38 
39 */
40 
41 #ifndef _H_cfg
42 #include "cfg.h"
43 #endif
44 
45 #ifndef _H_rpc
46 #include "rpc.h"
47 #endif
48 
49 #ifndef _H_ses
50 #include "ses.h"
51 #endif
52 
53 #ifndef _H_status
54 #include "status.h"
55 #endif
56 
57 #ifndef _H_xml_msg
58 #include "xml_msg.h"
59 #endif
60 
61 #ifndef _H_val
62 #include "val.h"
63 #endif
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /********************************************************************
70 * *
71 * F U N C T I O N S *
72 * *
73 *********************************************************************/
74 
75 
109 extern status_t
110  agt_xpath_output_filter (ses_cb_t *scb,
111  rpc_msg_t *msg,
112  const cfg_template_t *cfg,
113  boolean getop,
114  int32 indent);
115 
116 
138 extern status_t
139  agt_xpath_output_cvt_filter (ses_cb_t *scb,
140  rpc_msg_t *msg,
141  const cfg_template_t *cfg,
142  xpath_pcb_t *pcb,
143  boolean getop,
144  int32 indent);
145 
146 
164 extern boolean
165  agt_xpath_test_filter (xml_msg_hdr_t *msghdr,
166  ses_cb_t *scb,
167  val_value_t *selectval,
168  val_value_t *val);
169 
173 #ifdef __cplusplus
174 } /* end extern 'C' */
175 #endif
176 
177 #endif /* _H_agt_xpath */
xpath1_get2.h
XPath 1.0 expression support for server GET2 callback functions.
XP_FORM_GETCB
@ XP_FORM_GETCB
normal GET2 CB
Definition: xpath.h:448
ses.h
NETCONF Session Common definitions module.
cfg.h
agt_xpath_output_cvt_filter
status_t agt_xpath_output_cvt_filter(ses_cb_t *scb, rpc_msg_t *msg, const cfg_template_t *cfg, xpath_pcb_t *pcb, boolean getop, int32 indent)
Output an XPath filter converted from Subtree.
Definition: agt_xpath.c:2304
agt_util.h
Utility Functions for NCX Server method routines.
xpath1_aio.h
Xpath 1.0 search support; XPath function library. Interface to the AIO GET2 object callback API.
xpath1_dump_result
void xpath1_dump_result(log_debug_t lvl, xpath_pcb_t *pcb, xpath_result_t *result, const char *banner)
Generate log output displaying the contents of a result.
Definition: xpath1.c:6737
val_get_xpathpcb
xpath_pcb_t * val_get_xpathpcb(val_value_t *val)
Get the XPath parser control block in the specified value struct.
Definition: val_util.c:4264
xpath1_aio_get_next_aio_ptr
val_value_t * xpath1_aio_get_next_aio_ptr(val_value_t *entry)
Get the next AIO val value in the valQ Queue.
Definition: xpath1_aio.c:572
OP_INSOP_AFTER
@ OP_INSOP_AFTER
insert after foo
Definition: op.h:142
obj_is_in_aio_get2
boolean obj_is_in_aio_get2(obj_template_t *obj)
Check if this object is a child of a node with sil-aio-get2 extension setup or if this object itself ...
Definition: obj.c:18305
obj_has_aio_list
boolean obj_has_aio_list(obj_template_t *obj)
Check is AIO object is a list or if its parent is a list object.
Definition: obj.c:18458
xpath_need_get2_processing
boolean xpath_need_get2_processing(xpath_result_t *result)
Check if the result nodeset contains any XP_RNT_GET2 nodes.
Definition: xpath.c:4783
OP_INSOP_BEFORE
@ OP_INSOP_BEFORE
insert before foo
Definition: op.h:141
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
xpath_init_resnode
void xpath_init_resnode(xpath_resnode_t *resnode)
Initialize an XPath result node struct.
Definition: xpath.c:3217
val.h
Value Node Basic Support.
xml_wr_full_check_val2
void xml_wr_full_check_val2(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean force_xmlns, boolean expand_varexpr, xmlns_id_t parent_nsid)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3561
xml_util.h
XML Utilities.
agt_rpc.h
NETCONF protocol remote procedure call server-side definitions.
xpath_cvt_boolean
boolean xpath_cvt_boolean(const xpath_result_t *result)
Convert an XPath result to a boolean answer.
Definition: xpath.c:3630
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.
xpath1_aio_check_ascend_lists
boolean xpath1_aio_check_ascend_lists(val_value_t *useval, xpath_get2_cb_t *cb)
Check if all the ascendent AIO lists are correct lists for the current val value and XPath GET2 contr...
Definition: xpath1_aio.c:749
xml_wr.h
XML Write functions.
OP_INSOP_FIRST
@ OP_INSOP_FIRST
insert first
Definition: op.h:139
val_get_next_index
val_index_t * val_get_next_index(const val_index_t *valindex)
Get the next index entry, if any for this value node.
Definition: val.c:10714
xml_wr_check_child_obj
void xml_wr_check_child_obj(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn)
Generate entire val_value_t *w/filter) for GET2.
Definition: xml_wr.c:4130
val_compare
int32 val_compare(const val_value_t *val1, const val_value_t *val2)
Compare 2 val_value_t struct value contents.
Definition: val.c:9456
XP_RNT_GET2
@ XP_RNT_GET2
get2ptr
Definition: xpath.h:426
op.h
NETCONF protocol operations.
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxconst.h
Contains NCX constants.
dlq_reverse_que
void dlq_reverse_que(dlq_hdr_t *que)
Reverse the order of all the entries in a Q.
Definition: dlq.c:1070
val_has_index
boolean val_has_index(const val_value_t *val)
Determine if this value has an index.
Definition: val.c:10660
obj_is_list
boolean obj_is_list(const obj_template_t *obj)
Check if object is a YANG list.
Definition: obj.c:13349
dlq_insertAhead
void dlq_insertAhead(void *newP, void *nodeP)
insert the new queue entry before the current entry
Definition: dlq.c:447
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
xmlns_id_t
uint16 xmlns_id_t
integer handle for registered namespaces
Definition: xmlns.h:89
xml_wr_check_child_obj_ex
void xml_wr_check_child_obj_ex(ses_cb_t *scb, xml_msg_hdr_t *msg, getcb_get2_t *parent_get2cb, obj_template_t *objnode, int32 indent, val_nodetest_fn_t testfn)
Write an entire <get2> val_value_t out from the obj_template_t callback.
Definition: xml_wr.c:4191
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
agt_val.h
NETCONF Server database callback handler.
xpath1.h
XPath 1.0 expression support.
obj_is_leafy
boolean obj_is_leafy(const obj_template_t *obj)
Check if object is a proper leaf or leaflist.
Definition: obj.c:13478
def_reg.h
Definition Registry module.
val_nodetest_fn_t
boolean(* val_nodetest_fn_t)(xml_msg_hdr_t *mhdr, ncx_withdefaults_t withdef, boolean realtest, val_value_t *node)
user function callback template to test output of a specified node.
Definition: val_util.h:132
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
xpath.h
Schema and data model Xpath search support.
SES_MY_USERNAME
#define SES_MY_USERNAME(S)
get username
Definition: ses.h:111
NCX_PROTO_RESTCONF
@ NCX_PROTO_RESTCONF
IETF RESTCONF.
Definition: ncxtypes.h:788
getcb_new_get2_lookup
getcb_get2_lookup_t * getcb_new_get2_lookup(obj_template_t *obj, dlq_hdr_t *keyvalQ)
Create a new getcb_get2_lookup struct.
Definition: getcb.c:7865
agt_util_get_testfn
val_nodetest_fn_t agt_util_get_testfn(xml_msg_hdr_t *msg, boolean getop)
Get the test function that should be used for a specific get operation based on with-default paramete...
Definition: agt_util.c:6910
agt_xpath.h
Server XPath filter processing for select attribute in <filter> element in <get> and <get-config> ope...
val_get_nsid
xmlns_id_t val_get_nsid(const val_value_t *val)
Get the namespace ID for the specified value node.
Definition: val.c:12277
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
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
ses_message_indent_count
int32 ses_message_indent_count(const ses_cb_t *scb)
Get the message indent count for this session.
Definition: ses.c:2822
xpath1_res_match_get2node
boolean xpath1_res_match_get2node(xpath_get2_cb_t *cb1, xpath_get2_cb_t *cb2)
Compare two GET2 CBs.
Definition: xpath1_res.c:1345
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
xpath_free_result
void xpath_free_result(xpath_result_t *result)
Free a malloced XPath result struct.
Definition: xpath.c:3107
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
getcb_clone_keyQ
status_t getcb_clone_keyQ(dlq_hdr_t *srcQ, dlq_hdr_t *destQ)
Copy all the key val_value_t structs to the other queue.
Definition: getcb.c:8779
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
val_util.h
Value Node Utilities.
xml_wr_max_check_val
void xml_wr_max_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean force_xmlns)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3423
xpath1_aio_find_aiocb_que
xpath_aio_cb_t * xpath1_aio_find_aiocb_que(dlq_hdr_t *aioQ, obj_template_t *obj)
Find AIO control block by object.
Definition: xpath1_aio.c:407
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
ses_is_dbapi_system_session
boolean ses_is_dbapi_system_session(ses_cb_t *scb)
Check if the specified session is a DB-API control session for system edits.
Definition: ses.c:4478
val_child.h
Value Node Child Access Support.
xml_wr_end_elem
void xml_wr_end_elem(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t nsid, const xmlChar *elname, int32 indent)
Write an end tag to the specified session.
Definition: xml_wr.c:3114
xpath1_dump_resnode
void xpath1_dump_resnode(log_debug_t lvl, xpath_resnode_t *resnode, const char *banner)
Generate log output displaying the contents of an XPath resnode.
Definition: xpath1.c:6829
OP_INSOP_NONE
@ OP_INSOP_NONE
not set
Definition: op.h:138
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
getcb_free_get2cb
void getcb_free_get2cb(getcb_get2_t *get2cb)
Clean and free a malloced GET2 control block.
Definition: getcb.c:5694
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.
xpath1_get2_expand_result
status_t xpath1_get2_expand_result(xpath_pcb_t *pcb, xpath_result_t *result, boolean leaflist_only)
Check the result for GET2 nodes that need to be retrieved.
Definition: xpath1_get2.c:2105
dlq_count
unsigned int dlq_count(const dlq_hdrT *listP)
get the number of queue entries in the listP queue list
Definition: dlq.c:994
ses_is_system_session
boolean ses_is_system_session(ses_cb_t *scb)
Check if the specified session is an internal system session.
Definition: ses.c:4441
xml_wr_full_val
void xml_wr_full_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent)
Generate entire val_value_t.
Definition: xml_wr.c:3650
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
agt.h
Multi-Protocol Network Management Server.
xml_wr_check_val
void xml_wr_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn)
Write an NCX value in XML encoding while checking nodes for suppression of output with the supplied t...
Definition: xml_wr.c:3357
XP_RST_GET2_DONE
@ XP_RST_GET2_DONE
GET2 callback done.
Definition: xpath.h:438
XP_RNT_VAL
@ XP_RNT_VAL
valptr
Definition: xpath.h:424
xml_wr_full_check_val
void xml_wr_full_check_val(ses_cb_t *scb, xml_msg_hdr_t *msg, val_value_t *val, int32 indent, val_nodetest_fn_t testfn, boolean expand_varexpr)
Generate entire val_value_t *w/filter)
Definition: xml_wr.c:3517
xpath_free_resnode
void xpath_free_resnode(xpath_resnode_t *resnode)
Free a malloced XPath result node struct.
Definition: xpath.c:3240
xpath1_prune_nodeset
void xpath1_prune_nodeset(xpath_pcb_t *pcb, xpath_result_t *result)
Check the current result nodeset and remove any redundant nodes from a NETCONF POV.
Definition: xpath1.c:5770
OP_INSOP_LAST
@ OP_INSOP_LAST
insert last (default)
Definition: op.h:140
xml_msg_get_max_depth
uint32 xml_msg_get_max_depth(xml_msg_hdr_t *msg)
Get the message max_depth value.
Definition: xml_msg.c:1343
xml_wr_begin_elem_ex
void xml_wr_begin_elem_ex(ses_cb_t *scb, xml_msg_hdr_t *msg, xmlns_id_t parent_nsid, xmlns_id_t nsid, const xmlChar *elname, const dlq_hdr_t *attrQ, boolean isattrq, int32 indent, boolean empty)
Write a start or empty XML tag to the specified session.
Definition: xml_wr.c:3001
xml_msg.h
XML and JSON Message send and receive support.
agt_acm_val_read_allowed
boolean agt_acm_val_read_allowed(xml_msg_hdr_t *msg, const xmlChar *user, val_value_t *val)
Check if the specified user is allowed to read a value node.
Definition: agt_acm.c:618
agt_xpath_output_filter
status_t agt_xpath_output_filter(ses_cb_t *scb, rpc_msg_t *msg, const cfg_template_t *cfg, boolean getop, int32 indent)
Output an XPath filter.
Definition: agt_xpath.c:2227
log_debug4_append
void void void void void void void void void void void void void void log_debug4_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG4 log entry.
getcb_new_keyval2
getcb_keyval_t * getcb_new_keyval2(val_value_t *keynode, obj_template_t *keyobj, boolean fixed_value)
Create a new Get2 keyval holder using val backptr.
Definition: getcb.c:7757
getcb_new_get2cb
getcb_get2_t * getcb_new_get2cb(void)
Malloc and init a new get2 control block.
Definition: getcb.c:5672
xpath1_res_flatten_result
status_t xpath1_res_flatten_result(xpath_pcb_t *pcb, xpath_result_t *result)
Convert any vahdr resnodes to valptr resnodes for simplified processing.
Definition: xpath1_res.c:928
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
agt_xpath_test_filter
boolean agt_xpath_test_filter(xml_msg_hdr_t *msghdr, ses_cb_t *scb, val_value_t *selectval, val_value_t *val)
Test an XPath filter for a notification.
Definition: agt_xpath.c:2361
xml_msg_set_start_depth
void xml_msg_set_start_depth(xml_msg_hdr_t *msg, uint32 start_depth)
Set the message start_depth value.
Definition: xml_msg.c:1393
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
rpc_err.h
NETCONF protocol standard error definitions.
obj_is_top_aio_get2
boolean obj_is_top_aio_get2(obj_template_t *obj)
Check if this object is a really top level holder of extension sil-aio-get2.
Definition: obj.c:18349
dlq_deque
void * dlq_deque(dlq_hdrT *listP)
remove the first queue node from the queue list
Definition: dlq.c:286
xpath1_aio_find_aiocb_full
xpath_aio_cb_t * xpath1_aio_find_aiocb_full(dlq_hdr_t *aioQ, obj_template_t *obj, xpath_get2_cb_t *cb)
Find AIO control block by object and also check if the AIO CB is the correct control block with the s...
Definition: xpath1_aio.c:354
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.
xpath1_check_node_exists
boolean xpath1_check_node_exists(xpath_pcb_t *pcb, dlq_hdr_t *resultQ, const val_value_t *val)
Check if any ancestor-ot-self node is already in the specified Q.
Definition: xpath1.c:5867
XML_MSG_XGET_REQ
#define XML_MSG_XGET_REQ(M)
<get> for XPath filter
Definition: xml_msg.h:301
xpath1_aio_get_first_aio_ptr
val_value_t * xpath1_aio_get_first_aio_ptr(xpath_aio_cb_t *cb)
Get the first AIO val value in the valQ Queue.
Definition: xpath1_aio.c:545
val_get_metaQ
dlq_hdr_t * val_get_metaQ(val_value_t *val)
Get the meta Q header for the value.
Definition: val.c:5391
xpath1_check_resnode_exists
boolean xpath1_check_resnode_exists(xpath_pcb_t *pcb, dlq_hdr_t *resultQ, xpath_resnode_t *resnode)
Check if any ancestor-ot-self node is already in the specified Q.
Definition: xpath1.c:5989
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
XPATH_GET2CB_OBJ
#define XPATH_GET2CB_OBJ(N)
access the GET2 control block object in xpath_get2_node_t (N)
Definition: xpath.h:319
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
ncx.h
YANG module utility functions.
agt_rpcerr.h
NETCONF protocol <rpc-error> server-side handler.
xpath_get_resnode_val
val_value_t * xpath_get_resnode_val(xpath_resnode_t *resnode)
Get the resnode value pointer from a resnode, if any.
Definition: xpath.c:4113
obj_get_level
uint32 obj_get_level(const obj_template_t *obj)
Get the nest level for the specified object Top-level is '1' Does not count groupings as a level.
Definition: obj.c:11833
obj.h
Data Object Support.
XP_FORM_GETCB_CHILD
@ XP_FORM_GETCB_CHILD
child node CB
Definition: xpath.h:450
XML_MSG_SET_LOOKUPQ
#define XML_MSG_SET_LOOKUPQ(M, Q)
Set GET2 lookup entry.
Definition: xml_msg.h:237
xpath1_eval_xmlexpr
xpath_result_t * xpath1_eval_xmlexpr(xmlTextReaderPtr reader, xpath_pcb_t *pcb, val_value_t *val, val_value_t *docroot, boolean logerrors, boolean configonly, status_t *res)
Evaluate an XML document expression.
Definition: xpath1.c:5643
xpath1_res.h
XPath 1.0 expression support; result support.
XP_RT_BOOLEAN
@ XP_RT_BOOLEAN
boolean result
Definition: xpath.h:350
xpath1_get2_get_resnode_parent
void xpath1_get2_get_resnode_parent(xpath_get2_node_t *get2node, val_value_t **parentval, xpath_get2_cb_t **parent_cb)
Get the resnode parent.
Definition: xpath1_get2.c:2062
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
XML_MSG_GET2_TARGET
#define XML_MSG_GET2_TARGET(M)
GET2 request target terminal node.
Definition: xml_msg.h:270
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
xpath_clean_resnode
void xpath_clean_resnode(xpath_resnode_t *resnode)
Clean an XPath result node struct.
Definition: xpath.c:3289
VAL_IS_INDEX
#define VAL_IS_INDEX(V)
Check if the value is a key leaf.
Definition: val.h:666
XP_RT_NODESET
@ XP_RT_NODESET
node-set result
Definition: xpath.h:347
xmlns.h
XML namespace support.
obj_is_root
boolean obj_is_root(const obj_template_t *obj)
Check if object is marked as a root object.
Definition: obj.c:14152
status.h
Global error messages for status code enumerations.
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
dlq.h
dlq provides general double-linked list and queue support:
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
val_get_first_index
val_index_t * val_get_first_index(const val_value_t *val)
Get the first index entry, if any for this value node.
Definition: val.c:10685