yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches

Support YANG data definition statements. More...

Collaboration diagram for YANG Object Parsing:

Functions

status_t yang_obj_consume_datadef (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *que, obj_template_t *parent)
 Parse the next N tokens as a data-def-stmt. More...
 
status_t yang_obj_consume_datadef_grp (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *que, obj_template_t *parent, grp_template_t *grp)
 Parse the next N tokens as a data-def-stmt (in a grouping) More...
 
status_t yang_obj_consume_rpc (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod)
 Parse the next N tokens as a rpc-stmt. More...
 
status_t yang_obj_consume_notification (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod)
 Parse the next N tokens as a notification-stmt. More...
 
status_t yang_obj_consume_augment (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod)
 Parse the next N tokens as a top-level augment-stmt. More...
 
status_t yang_obj_consume_deviation (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod)
 Parse the next N tokens as a top-level deviation-stmt. More...
 
status_t yang_obj_resolve_datadefs (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve data-def-stmts. More...
 
status_t yang_obj_resolve_uses (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolves uses-stmts. More...
 
status_t yang_obj_resolve_augments (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve augment statements. More...
 
status_t yang_obj_resolve_augments_final (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve augmnet statements (final pass) More...
 
status_t yang_obj_resolve_deviations (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod)
 Resolve deviation-stmts. More...
 
status_t yang_obj_resolve_final (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ, boolean ingrouping, boolean is_top)
 Resolve objects (final pass) More...
 
status_t yang_obj_top_resolve_final (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve top-level objects (final pass) More...
 
status_t yang_obj_resolve_xpath (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve XPath statements. More...
 
status_t yang_obj_resolve_xpath_final (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Resolve XPath statements (final pass) More...
 
status_t yang_obj_check_leafref_loops (tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Check all leafref objects for hard-wired object loops Must be done after yang_obj_resolve_xpath. More...
 
status_t yang_obj_remove_deleted_nodes (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *datadefQ)
 Find any nodes marked for deletion and remove them. More...
 
status_t set_tkc_error (tk_chain_t *tkc, ncx_module_t *mod, ncx_error_t *err, status_t res)
 utility function for setting and reporting tkc errors. More...
 
status_t yang_obj_add_object (tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *que, obj_template_t *obj)
 Check if an object already exists, and add it if not. More...
 
status_t yang_obj_consume_structure (yang_pcb_t *pcb, tk_chain_t *tkc, ncx_module_t *mod, dlq_hdr_t *que)
 Parse the next N tokens as a structure as defined in RFC 8791. More...
 

Detailed Description

Support YANG data definition statements.

        - data-def-stmt support
          - container-stmt
          - leaf-stmt
          - leaf-list-stmt
          - list-stmt
          - choice-stmt
          - uses-stmt
          - augment-stmt

    YANG module parser, data-def-stmt support

        /ns1:value/ns2:value/ns3:value/...
An obj_template_t is essentially a QName node in the
conceptual <config> element,

Every leaf/leaf-list definition node has a typ_def_t,
and every value instance node has a val_value_t struct.
This allows engine callbacks to process arbitrarily complex
data structues with the same code.
    There are 13 types of objects:

      enum constant          has value node
      ----------------------------------------
      OBJ_TYP_ANYXML            Y (1)
      OBJ_TYP_CONTAINER         Y
      OBJ_TYP_LEAF              Y
      OBJ_TYP_LEAF_LIST         Y
      OBJ_TYP_LIST              Y
      OBJ_TYP_CHOICE            N
      OBJ_TYP_CASE              N
      OBJ_TYP_USES              N
      OBJ_TYP_REFINE            N
      OBJ_TYP_AUGMENT           N
      OBJ_TYP_RPC               N
      OBJ_TYP_RPCIO             Y (2)
      OBJ_TYP_NOTIF             N

   (1) ANYXML is not stored in the value tree as type anyxml.
       It is converted as follows:
           Complex Node -> NCX_BT_CONTAINER
           Simple Node  -> NCX_BT_STRING
           Empty Node   -> NCX_BT_EMPTY

   (2) RPCIO nodes are instantiated only within the implementation,
       to act as a container for collected parameters or results.
       It is not found under the <config> element.

These objects are grouped as follows:

5 Pass Validation Process

In pass 1, the source file is parsed into YANG tokens. String concatentation are quoted string adjustment are handled in this pass.

In pass 2, the objects are parsed via yang_obj_consume_datadef. Syntax errors and any other static errors are reported

In pass 3, the object definitions are validated for correctness, via the yang_obj_resolve_datadefs function. This is mixed with calls to yang_typ_resolve_typedefs and yang_grp_resolve_groupings.

Uses and augments are not expanded in pass 3, so some details like key validation for a list cannot be done, since the contents may depend on the expanded uses or descendant form augment statement.

In pass 4, groupings are completed with yang_grp_resolve_complete. Then all the uses-based data is cloned and placed into the tree, via yang_obj_resolve_uses

In pass 5, all the augment-based data is cloned and placed into the tree, via yang_obj_resolve_augments

The uses and augment objects are kept for XSD and other translation, and needed for internal data sharing. In a cloned object, a minimal amount of data is copied, and the rest is shadowed with back-pointers.

For the 'uses' statement, refined objects are merged into the cloned tree as specified by the grouping and any refine statements within the uses statement.

For the 'augment' statement, one exact clone of each augmenting node is placed in the target, based on the schema node target for the augment clause.

Function Documentation

◆ set_tkc_error()

status_t set_tkc_error ( tk_chain_t tkc,
ncx_module_t mod,
ncx_error_t err,
status_t  res 
)

utility function for setting and reporting tkc errors.

Parameters
tkcthe parser token chain (may be NULL)
modthe module
errerror record to set
resthe error status.
Returns
the error status.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yang_obj_add_object()

status_t yang_obj_add_object ( tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  que,
obj_template_t obj 
)

Check if an object already exists, and add it if not.

Error messages are printed by this function!! Do not duplicate error messages upon error return

'obj' is either deleted or added at the end of this fn

Parameters
tkctoken chain
modmodule in progress
queQ to hold the obj_template_t that gets created
objobject to add
Returns
status of the operation

◆ yang_obj_check_leafref_loops()

status_t yang_obj_check_leafref_loops ( tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Check all leafref objects for hard-wired object loops Must be done after yang_obj_resolve_xpath.

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
tkctoken chain from parsing (needed for error msgs)
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yang_obj_consume_augment()

status_t yang_obj_consume_augment ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod 
)

Parse the next N tokens as a top-level augment-stmt.

Create a obj_template_t struct and add it to the specified module

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the 'augment' keyword

New augment object added to module

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
Returns
status of the operation

◆ yang_obj_consume_datadef()

status_t yang_obj_consume_datadef ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  que,
obj_template_t parent 
)

Parse the next N tokens as a data-def-stmt.

Create a obj_template_t struct and add it to the specified module

First pass of a 3 pass compiler

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the first keyword, starting the specific data definition

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
quequeue will get the obj_template_t
parentparent object or NULL if top-level data-def-stmt
Returns
status of the operation

◆ yang_obj_consume_datadef_grp()

status_t yang_obj_consume_datadef_grp ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  que,
obj_template_t parent,
grp_template_t grp 
)

Parse the next N tokens as a data-def-stmt (in a grouping)

Create a obj_template_t struct and add it to the specified module

First pass of a 3 pass compiler

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the first keyword, starting the specific data definition

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
quequeue will get the obj_template_t
parentparent object or NULL if top-level data-def-stmt
grpgrp_template_t containing 'que'
Returns
status of the operation
Here is the caller graph for this function:

◆ yang_obj_consume_deviation()

status_t yang_obj_consume_deviation ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod 
)

Parse the next N tokens as a top-level deviation-stmt.

Create a obj_deviation_t struct and add it to the specified module

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the 'deviation' keyword

New deviation struct added to module deviationQ

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
Returns
status of the operation
Here is the call graph for this function:

◆ yang_obj_consume_notification()

status_t yang_obj_consume_notification ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod 
)

Parse the next N tokens as a notification-stmt.

Create a obj_template_t struct and add it to the specified module

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the 'notification' keyword

New notification added to module

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
Returns
status of the operation

◆ yang_obj_consume_rpc()

status_t yang_obj_consume_rpc ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod 
)

Parse the next N tokens as a rpc-stmt.

Create a obj_template_t struct and add it to the specified module

First pass of a 3 pass compiler

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the 'rpc' keyword

New RPC added to module

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
Returns
status of the operation

◆ yang_obj_consume_structure()

status_t yang_obj_consume_structure ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  que 
)

Parse the next N tokens as a structure as defined in RFC 8791.

Create and fill in an obj_template_t struct.

Error messages are printed by this function!! Do not duplicate error messages upon error return

Current token is the 'sx:structure' keyword

Parameters
pcbparser control block to use
tkcthe parser token chain (may be NULL)
modthe module
queQ to hold the obj_template_t that gets created
Returns
status of the operation
Here is the call graph for this function:

◆ yang_obj_remove_deleted_nodes()

status_t yang_obj_remove_deleted_nodes ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Find any nodes marked for deletion and remove them.

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yang_obj_resolve_augments()

status_t yang_obj_resolve_augments ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve augment statements.

Third pass object validation

Expand and validate any augment clauses within any objects within the datadefQ

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation

◆ yang_obj_resolve_augments_final()

status_t yang_obj_resolve_augments_final ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve augmnet statements (final pass)

Fourth pass object expand augments

Clone any list keys missed in yang_obj_resolve_augments This only occurs for augments of external objects, so only top-level augment-stmts need to be checked.

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the call graph for this function:

◆ yang_obj_resolve_datadefs()

status_t yang_obj_resolve_datadefs ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve data-def-stmts.

First pass object validation

Analyze the entire datadefQ within the module struct Finish all the clauses within this struct that may have been defered because of possible forward references

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the caller graph for this function:

◆ yang_obj_resolve_deviations()

status_t yang_obj_resolve_deviations ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod 
)

Resolve deviation-stmts.

Validate any deviation statements within the module deviationQ

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain from parsing (needed for error msgs)
modmodule in progress
Returns
status of the operation
Here is the call graph for this function:

◆ yang_obj_resolve_final()

status_t yang_obj_resolve_final ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ,
boolean  ingrouping,
boolean  is_top 
)

Resolve objects (final pass)

Fourth pass object validation

Check various final stage errors and warnings within a single file

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
ingroupingTRUE if this object being resolved from yang_grp_resolve_final
FALSE otherwise
is_topTRUE if top level object in a module datadefQ
FALSE otherwise
Returns
status of the operation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yang_obj_resolve_uses()

status_t yang_obj_resolve_uses ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolves uses-stmts.

Second pass object validation This calls expand_uses not resolve_uses!

Refine-stmts have already been patched into objects in phase 1. Expand and validate any uses clauses within any objects within the datadefQ.

Validate and expand any augments within a uses-stmt

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yang_obj_resolve_xpath()

status_t yang_obj_resolve_xpath ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve XPath statements.

Fifth (and final) pass object validation

Check all leafref, must, and when XPath expressions to make sure they are well-formed

Checks the cooked objects, and skips all groupings uses, and augment nodes

MUST BE CALLED AFTER yang_obj_resolve_final

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation

◆ yang_obj_resolve_xpath_final()

status_t yang_obj_resolve_xpath_final ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve XPath statements (final pass)

Fifth pass validate defvals for XPath leafs Sometimes XPath validation deffered to redo pass

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation

◆ yang_obj_top_resolve_final()

status_t yang_obj_top_resolve_final ( yang_pcb_t pcb,
tk_chain_t tkc,
ncx_module_t mod,
dlq_hdr_t *  datadefQ 
)

Resolve top-level objects (final pass)

Fourth pass object validation; for top-level module with submodules

Check various final stage errors and warnings within a single file

Error messages are printed by this function!! Do not duplicate error messages upon error return

Parameters
pcbparser control block to use
tkctoken chain
modmodule in progress
datadefQQ of obj_template_t structs to check
Returns
status of the operation
Here is the call graph for this function:
Here is the caller graph for this function: