Removed external direct access to the yang_stmt struct.
This commit is contained in:
parent
cef0dc5a22
commit
65c809b1c3
17 changed files with 85 additions and 120 deletions
|
|
@ -38,6 +38,9 @@
|
|||
#ifndef _CLIXON_XML_MAP_H_
|
||||
#define _CLIXON_XML_MAP_H_
|
||||
|
||||
/* declared in clixon_yang_internal */
|
||||
typedef enum yang_class yang_class;
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,16 +40,10 @@
|
|||
#define _CLIXON_YANG_H_
|
||||
|
||||
|
||||
/*
|
||||
* Actually cligen variable stuff XXX
|
||||
*/
|
||||
#define V_UNIQUE 0x01 /* Variable flag */
|
||||
#define V_UNSET 0x08 /* Variable is unset, ie no default */
|
||||
|
||||
/*
|
||||
* Types
|
||||
*/
|
||||
struct xml;
|
||||
/*! YANG keywords from RFC6020.
|
||||
* See also keywords generated by yacc/bison in clicon_yang_parse.tab.h, but they start with K_
|
||||
* instead of Y_
|
||||
|
|
@ -142,85 +136,20 @@ enum yang_class{
|
|||
};
|
||||
typedef enum yang_class yang_class;
|
||||
|
||||
#define YANG_FLAG_MARK 0x01 /* Marker for dynamic algorithms, eg expand */
|
||||
struct xml;
|
||||
|
||||
/* Yang data node
|
||||
* See RFC7950 Sec 3:
|
||||
* o data node: A node in the schema tree that can be instantiated in a
|
||||
* data tree. One of container, leaf, leaf-list, list, anydata, and
|
||||
* anyxml.
|
||||
* XXX move to function
|
||||
*/
|
||||
#define yang_datanode(y) ((y)->ys_keyword == Y_CONTAINER || (y)->ys_keyword == Y_LEAF || (y)->ys_keyword == Y_LIST || (y)->ys_keyword == Y_LEAF_LIST || (y)->ys_keyword == Y_ANYXML || (y)->ys_keyword == Y_ANYDATA)
|
||||
|
||||
/* Yang data definition statement
|
||||
* See RFC 7950 Sec 3:
|
||||
* o data definition statement: A statement that defines new data
|
||||
* nodes. One of "container", "leaf", "leaf-list", "list", "choice",
|
||||
* "case", "augment", "uses", "anydata", and "anyxml".
|
||||
*/
|
||||
#define yang_datadefinition(y) (yang_datanode(y) || (y)->ys_keyword == Y_CHOICE || (y)->ys_keyword == Y_CASE || (y)->ys_keyword == Y_AUGMENT || (y)->ys_keyword == Y_USES)
|
||||
|
||||
/* Yang schema node .
|
||||
* See RFC 7950 Sec 3:
|
||||
* o schema node: A node in the schema tree. One of action, container,
|
||||
* leaf, leaf-list, list, choice, case, rpc, input, output,
|
||||
* notification, anydata, and anyxml.
|
||||
*/
|
||||
#define yang_schemanode(y) (yang_datanode(y) || (y)->ys_keyword == Y_RPC || (y)->ys_keyword == Y_CHOICE || (y)->ys_keyword == Y_CASE || (y)->ys_keyword == Y_INPUT || (y)->ys_keyword == Y_OUTPUT || (y)->ys_keyword == Y_NOTIFICATION)
|
||||
|
||||
|
||||
typedef struct yang_stmt yang_stmt; /* Defined in clixon_yang_internal */
|
||||
|
||||
/*! Yang type cache. Yang type statements can cache all typedef info here
|
||||
* @note unions not cached
|
||||
*/
|
||||
struct yang_type_cache{
|
||||
int yc_options; /* See YANG_OPTIONS_* that determines pattern/
|
||||
fraction fields. */
|
||||
cvec *yc_cvv; /* Range and length restriction. (if YANG_OPTION_
|
||||
LENGTH|RANGE. Can be a vector if multiple
|
||||
ranges*/
|
||||
char *yc_pattern; /* regex (posix) (if YANG_OPTIONS_PATTERN) */
|
||||
uint8_t yc_fraction; /* Fraction digits for decimal64 (if
|
||||
YANG_OPTIONS_FRACTION_DIGITS */
|
||||
yang_stmt *yc_resolved; /* Resolved type object, can be NULL - note direct ptr */
|
||||
};
|
||||
typedef struct yang_type_cache yang_type_cache;
|
||||
|
||||
/*! yang statement
|
||||
*/
|
||||
|
||||
struct yang_stmt{
|
||||
int ys_len; /* Number of children */
|
||||
struct yang_stmt **ys_stmt; /* Vector of children statement pointers */
|
||||
struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */
|
||||
enum rfc_6020 ys_keyword; /* See clicon_yang_parse.tab.h */
|
||||
|
||||
char *ys_argument; /* String / argument depending on keyword */
|
||||
int ys_flags; /* Flags according to YANG_FLAG_* above */
|
||||
yang_stmt *ys_module; /* Shortcut to "my" module. Augmented
|
||||
nodes can belong to other
|
||||
modules than the ancestor module */
|
||||
|
||||
char *ys_extra; /* For unknown */
|
||||
cg_var *ys_cv; /* cligen variable. See ys_populate()
|
||||
Following stmts have cv:s:
|
||||
leaf: for default value
|
||||
leaf-list,
|
||||
config: boolean true or false
|
||||
mandatory: boolean true or false
|
||||
fraction-digits for fraction-digits
|
||||
unknown-stmt (argument)
|
||||
*/
|
||||
cvec *ys_cvec; /* List of stmt-specific variables
|
||||
Y_RANGE: range_min, range_max
|
||||
Y_LIST: vector of keys
|
||||
Y_TYPE & identity: store all derived types
|
||||
*/
|
||||
yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */
|
||||
int _ys_vector_i; /* internal use: yn_each */
|
||||
};
|
||||
|
||||
typedef int (yang_applyfn_t)(yang_stmt *ys, void *arg);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@
|
|||
/*
|
||||
* Types
|
||||
*/
|
||||
|
||||
/* declared in clixon_yang_internal */
|
||||
typedef struct yang_type_cache yang_type_cache;
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue