1 /* 2 * 3 ***** BEGIN LICENSE BLOCK ***** 4 5 Copyright (C) 2009-2020 Olof Hagsand 6 7 This file is part of CLIXON. 8 9 Licensed under the Apache License, Version 2.0 (the "License"); 10 you may not use this file except in compliance with the License. 11 You may obtain a copy of the License at 12 13 http://www.apache.org/licenses/LICENSE-2.0 14 15 Unless required by applicable law or agreed to in writing, software 16 distributed under the License is distributed on an "AS IS" BASIS, 17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 See the License for the specific language governing permissions and 19 limitations under the License. 20 21 Alternatively, the contents of this file may be used under the terms of 22 the GNU General Public License Version 3 or later (the "GPL"), 23 in which case the provisions of the GPL are applicable instead 24 of those above. If you wish to allow use of your version of this file only 25 under the terms of the GPL, and not to allow others to 26 use your version of this file under the terms of Apache License version 2, 27 indicate your decision by deleting the provisions above and replace them with 28 the notice and other provisions required by the GPL. If you do not delete 29 the provisions above, a recipient may use your version of this file under 30 the terms of any one of the Apache License version 2 or the GPL. 31 32 ***** END LICENSE BLOCK ***** 33 34 * 35 * This file defines the internal YANG data structures used by the Clixon implementation 36 * This file SHOULD ONLY be included by clixon_yang.h. 37 * Accesses should be made via the API defined in clixon_yang.h 38 */ 39 40 #ifndef _CLIXON_YANG_INTERNAL_H_ 41 #define _CLIXON_YANG_INTERNAL_H_ 42 43 /*! Yang type cache. Yang type statements can cache all typedef info here 44 * @note unions not cached 45 */ 46 struct yang_type_cache{ 47 int yc_options; /* See YANG_OPTIONS_* that determines pattern/ 48 fraction fields. */ 49 cvec *yc_cvv; /* Range and length restriction. (if YANG_OPTION_ 50 LENGTH|RANGE. Can be a vector if multiple 51 ranges*/ 52 cvec *yc_patterns; /* list of regexp, if cvec_len() > 0 */ 53 int yc_rxmode; /* need to store mode for freeing since handle may not be available */ 54 cvec *yc_regexps; /* list of _compiled_ regexp, if cvec_len() > 0 */ 55 uint8_t yc_fraction; /* Fraction digits for decimal64 (if 56 YANG_OPTIONS_FRACTION_DIGITS */ 57 yang_stmt *yc_resolved; /* Resolved type object, can be NULL - note direct ptr */ 58 }; 59 typedef struct yang_type_cache yang_type_cache; 60 61 /*! yang statement 62 */ 63 struct yang_stmt{ 64 int ys_len; /* Number of children */ 65 struct yang_stmt **ys_stmt; /* Vector of children statement pointers */ 66 struct yang_stmt *ys_parent; /* Backpointer to parent: yang-stmt or yang-spec */ 67 enum rfc_6020 ys_keyword; /* See clicon_yang_parse.tab.h */ 68 69 char *ys_argument; /* String / argument depending on keyword */ 70 uint16_t ys_flags; /* Flags according to YANG_FLAG_MARK and others */ 71 yang_stmt *ys_mymodule; /* Shortcut to "my" module. Augmented 72 nodes can belong to other 73 modules than the ancestor module */ 74 cg_var *ys_cv; /* cligen variable. See ys_populate() 75 Following stmts have cv:s: 76 leaf: for default value 77 leaf-list, 78 config: boolean true or false 79 mandatory: boolean true or false 80 fraction-digits for fraction-digits 81 unknown-stmt (optional argument) 82 */ 83 cvec *ys_cvec; /* List of stmt-specific variables 84 Y_RANGE: range_min, range_max 85 Y_LIST: vector of keys 86 Y_TYPE & identity: store all derived 87 types as <module>:<id> list 88 */ 89 yang_type_cache *ys_typecache; /* If ys_keyword==Y_TYPE, cache all typedef data except unions */ 90 char *ys_when_xpath; /* Special conditional for a "when"-associated augment xpath */ 91 cvec *ys_when_nsc; /* Special conditional for a "when"-associated augment namespace ctx */ 92 int _ys_vector_i; /* internal use: yn_each */ 93 94 }; 95 96 97 #endif /* _CLIXON_YANG_INTERNAL_H_ */ 98 99