Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 1 | /** |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 2 | * @page transition1_2 Transition Manual (1.x -> 2.0) |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 3 | * |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 4 | * [TOC] |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 5 | * |
| 6 | * Rewriting libyang codebase and creating libyang version 2.0 was motivated mainly by improving long term maintainability. |
| 7 | * Especially some of the features and design decisions become killers for further development and maintaining the libyang |
| 8 | * codebase. On the other hand, most of the principles introduced in libyang 1.x to handle YANG schemas and manipulate |
| 9 | * instantiated data have proved successful. Therefore, we have decided to keep the basic mechanisms from version 1.x and |
| 10 | * remove the problematic features and modify the improper design decisions. Despite the vision to keep with the mechanisms |
| 11 | * also the API, the new version became a great opportunity to clean up the API and improve its usability mainly by unifying |
| 12 | * how the libyang functions are used. So, in the end, this manual is not just a description of the removed features listing |
| 13 | * removed, modified or added functions. The API should be even better prepared for adding new features and functions. |
| 14 | * Shortly, almost everything has changed at least a little, so you cannot move from version 1.x to 2.0 just by replacing |
| 15 | * code snippets. However, we believe that the change is good and libyang 2.0 is simply better. |
| 16 | * |
| 17 | * In this Manual, we want to introduce the differences between libyang 1.x and 2.0. It is intended for the transition |
| 18 | * from 1.x to 2.0, so if you are new to libyang, simply go to the @ref howto section, this Manual is not for you. |
| 19 | * |
| 20 | * The complete generated list of changes (without any additional notes) can be found in |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 21 | * <a href="../compat_report_1_2.html">the compatibility report</a>. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 22 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 23 | * @section transition1_2General General Changes |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 24 | * |
| 25 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 26 | * @subsection transition1_2GeneralErros Errors Handling |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 27 | * |
| 28 | * The most visible change is probably the changed approach to handling errors. While libyang 1.x was using variable |
| 29 | * *ly_errno* to provide error information in case the called function failed, there is no such variable in libyang 2.0. |
| 30 | * On the other hand, most API functions now return ::LY_ERR values directly stating the result. In addition, in case |
| 31 | * the error is somehow connected with the [context](@ref howtoContext), more detailed error information can be obtained |
| 32 | * from the context handler itself. Mainly this change is responsible for the backward incompatibility of almost all |
| 33 | * functions between versions 1.x and 2.0. |
| 34 | * |
| 35 | * Here is the overview of the changed / removed / added functions connected with errors and logging. |
| 36 | * |
| 37 | * libyang 1.x | libyang 2.0 | Notes |
| 38 | * :-------------------------|:-------------------------------------|:------------------------------------------------------- |
| 39 | * - | ::ly_err_last() | New API for handling errors. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 40 | * ly_verb_dbg() | ::ly_log_dbg_groups() | Rename to align with the names of the accepted values. |
| 41 | * ly_verb() | ::ly_log_level() | ^ |
| 42 | * |
| 43 | * More information about error handling in libyang 2.0 can be found at @ref howtoErrors page. |
| 44 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 45 | * @subsection transition1_2GeneralInOut Input / Output Processing |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 46 | * |
| 47 | * libyang 2.0 introduces input (::ly_in) and output (::ly_out) handlers covering the specific input sources for parsers and |
| 48 | * output targets for printers. They are supposed mainly to simplify parser's and printer's API to avoid the need for |
| 49 | * separate functions for each source/target. The handlers can be used repeatedly to split the inputs or join the outputs. |
| 50 | * |
| 51 | * More information can be found at @ref howtoInput and @ref howtoOutput pages. |
| 52 | * |
| 53 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 54 | * @subsection transition1_2GeneralOutputFormatting Output Formatting |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 55 | * |
| 56 | * In libyang 1.x, there was an inconsistency in printing schemas and data. While the schemas were always printed formatted, |
| 57 | * the data were printed by default without additional indentation. It is clearly visible in the YIN format of the schema, |
| 58 | * which is XML, and the XML encoding of the data. While there was a possibility to format data output with the LYP_FORMAT |
| 59 | * flag, it wasn't possible to change schema output formatting. |
Michal Vasko | a24b9af | 2020-11-09 20:57:39 +0100 | [diff] [blame] | 60 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 61 | * libyang 2.0 unifies the behavior of all printers. By default, all the output formats are formatted now. Both, the data as |
| 62 | * well as the schema printers, accept the option to remove additional formatting (different for the specific format, usually |
| 63 | * indentations and blank lines): ::LYD_PRINT_SHRINK for the data printer and ::LYS_PRINT_SHRINK for the schema printer. |
| 64 | * |
| 65 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 66 | * @subsection transition1_2GeneralXPath Addressing |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 67 | * |
| 68 | * If you compare the @ref howtoXPath page from libyang 1.x and 2.0 documentation, you will be probably confused since they |
| 69 | * seem very different. In fact, we have tried to simplify the API by removing the original Schema path format from the |
| 70 | * public API. Since this format is used in YANG format, libyang still supports it internally, but it is not possible to use |
| 71 | * it anywhere in the API. The new formats XPath and Path, mentioned at the @ref howtoXPath page, are both the Data paths |
| 72 | * used in libyang 1.x. The Path format is a subset of XPath format limited to refer to a single node. |
| 73 | * |
| 74 | * This change was reflected in functions serving to get a node based on the specified path. Unfortunately, when comparing |
| 75 | * old and new API, the transition can be confusing since the names are sometimes overloaded (be careful mainly of |
| 76 | * ::lys_find_path()). The following table depicts the changes, but probably a better approach is to handle the functions as |
| 77 | * a completely new API. |
| 78 | * |
| 79 | * libyang 1.x | libyang 2.0 | Notes |
| 80 | * :-------------------------|:-------------------------------------|:------------------------------------------------------- |
| 81 | * ly_ctx_find_path() | - | To simplify the different [types of paths](@ref howtoXPath), the Schema path format is not supported for now. If there will be use cases for it, it can be re-added later, but for now try using ::lys_find_xpath(). |
| 82 | * %lys_find_path() | - | To simplify the different [types of paths](@ref howtoXPath), the Schema path format is not supported for now. If there will be use cases for it, it can be re-added later, but for now try using ::lys_find_xpath(). |
| 83 | * ly_ctx_get_node() | ::lys_find_path() | Renamed to unify API functions, note that there was lys_find_path in libyang 1.x with different functionality in comparison to the function of the same name from libyang 2.0. |
| 84 | * - | ::lys_find_path_atoms() | Extension of ::lys_find_path(). |
| 85 | * - | ::lys_find_lypath_atoms() | ^ |
| 86 | * - | ::lys_find_xpath() | New function reflecting updated @ref howtoXPath\. |
| 87 | * lys_xpath_atomize() | ::lys_find_xpath_atoms() | Rename to unify with the new API, extends ::lys_find_xpath(). |
| 88 | * - | ::lys_find_expr_atoms() | Extension of ::lys_find_xpath(). |
Radek Krejci | 635d2b8 | 2021-01-04 11:26:51 +0100 | [diff] [blame] | 89 | * %lyd_path() | ::lyd_path() | Same purpose, just extended functionality. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 90 | * lyd_find_path() | ::lyd_find_xpath() | Rename to unify with the new API. |
Michal Vasko | 257bdcf | 2021-01-14 13:15:30 +0100 | [diff] [blame] | 91 | * - | ::lyd_find_path() | Simplified version of ::lyd_find_path(). |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 92 | * - | ::lyxp_get_expr() | Added functionality due to the changed representation of XPath expressions. |
| 93 | * ly_path_data2schema() | - | Removed since the schema path is not available in API. |
| 94 | * ly_path_xml2json() | - | Removed since done internally, note that even the generic XML parser is not available now. |
| 95 | * lys_node_xpath_atomize() | - | Removed as useless/redundant, use ::lys_find_xpath_atoms(). |
| 96 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 97 | * @section transition1_2Context Context |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 98 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 99 | * Context, as a concept of a storage interconnecting YANG modules into a YANG schema and YANG schema with the instantiated |
| 100 | * data, was preserved. However, it is now more supposed to be prepared just once before connecting it with any instantiated |
| 101 | * data. The possibility of removing YANG modules from the context was completely dropped. Furthermore, we would like to |
| 102 | * introduce some kind of context lock to completely abandon any change of the YANG modules after starting work with the |
| 103 | * instantiated data. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 104 | * |
Radek Krejci | 90ed21e | 2021-04-12 14:47:46 +0200 | [diff] [blame] | 105 | * Another change to note is the removed destructor of private data (::lysc_node.priv) in ::ly_ctx_destroy(). The mechanism |
| 106 | * was not reliable with the context recompilation and the splitted parsed and compiled schema trees or the complexity of |
| 107 | * YANG extensions. It is better to let the caller maintain the allocated data directly via some memory pool or using |
| 108 | * ::lysc_tree_dfs_full() since he is the best to know where the additional data were added. |
| 109 | * |
| 110 | * The meaining of the ::lysc_node.priv pointer can be now also changed by ::LY_CTX_SET_PRIV_PARSED context option, which |
| 111 | * makes libyang to connect the original parsed schema node structure (::lysp_node) into the compiled nodes via their 'priv' |
| 112 | * pointer. |
| 113 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 114 | * Other significant changes connected with the context are depicted in the following table. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 115 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 116 | * libyang 1.x | libyang 2.0 | Notes |
| 117 | * :-------------------------|:-------------------------------------|:------------------------------------------------------- |
| 118 | * ly_ctx_clean() | - | Removed functionality of manipulating with the context and the modules already placed in the context. |
| 119 | * ly_ctx_remove_module() | - | ^ |
| 120 | * ly_ctx_set_module_data_clb() and the associated ly_module_data_clb type. | - | ^ |
| 121 | * ly_ctx_get_disabled_module() and the associated ly_ctx_get_disabled_module_iter() | - | ^ |
Michal Vasko | 794ab4b | 2021-03-31 09:42:19 +0200 | [diff] [blame] | 122 | * ly_ctx_info() | ::ly_ctx_get_yanglib_data() | Clarification of what to expect as the output of the function and possibility to specify custom content ID. |
| 123 | * ly_ctx_get_module_set_id() | ::ly_ctx_get_change_count() | The functionality is the same but the exact meaning of the value was clarified. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 124 | * - | ::ly_ctx_unset_searchdir_last() | Extend the functionality of the ::ly_ctx_unset_searchdir() to make its use easier. |
| 125 | * ly_ctx_get_module_older() | - | Removed functionality. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 126 | * - | ::ly_ctx_get_module_implemented() | Supplement for ::ly_ctx_get_module() |
| 127 | * - | ::ly_ctx_get_module_latest() | ^ |
| 128 | * - | ::ly_ctx_get_module_implemented_ns() | Supplement for ::ly_ctx_get_module_ns() |
| 129 | * - | ::ly_ctx_get_module_latest_ns() | ^ |
Michal Vasko | 8dc3199 | 2021-02-22 10:30:47 +0100 | [diff] [blame] | 130 | * - | ::ly_ctx_get_submodule_latest() | Supplement for ::ly_ctx_get_submodule() |
| 131 | * - | ::ly_ctx_get_submodule2_latest() | Supplement for ::ly_ctx_get_submodule2() |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 132 | * ly_ctx_get_module_by_ns() | ::ly_ctx_get_module_ns () | Redesign the API - replace some of the parameters with standalone supplement functions. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 133 | * ly_ctx_unset_searchdirs() | ::ly_ctx_unset_searchdir() | Simplify API and instead of index numbers, work with the values themselves. |
| 134 | * ly_ctx_set*() | ::ly_ctx_set_options() | API simplification. |
| 135 | * ly_ctx_unset*() | ::ly_ctx_unset_options() | ^ |
Radek Krejci | 90ed21e | 2021-04-12 14:47:46 +0200 | [diff] [blame] | 136 | * ly_ctx_destroy() | ::ly_ctx_destroy() | The destructor callback parameter was removed, see the notes above. |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 137 | * |
| 138 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 139 | * @section transition1_2Schemas YANG Modules (Schema) |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 140 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 141 | * The most significant change between libyang 1.x and 2.0 can be found in schema structures. The schema tree now has two |
| 142 | * different forms - parsed and compiled trees. While the parsed tree reflects the source of the YANG module, the compiled |
| 143 | * tree represents the final tree used to validate the instantiated data. Both formats can be found inside the covering |
| 144 | * ::lys_module structure. More about the new structures can be found at @ref howtoSchema page. |
| 145 | * |
| 146 | * This is an essential change allowing speed up and simplification of data validation, but requiring carefully determine |
| 147 | * which format is more suitable for the specific use case. As mentioned, the compiled trees are better for data validation |
| 148 | * and getting information about the intentioned structure of the schema with all the applied groupings, type modifications, |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 149 | * augments, deviations, and any defined if-features. On the other hand, the parsed trees are useful for the schema format conversions since they |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 150 | * provide the original structure of the modules. There is a number of new functions intended to work only with the |
| 151 | * parsed or the compiled tree. These functions are prefixed with `lysp_` and `lysp_` prefixes. |
| 152 | * |
| 153 | * Schema parser, as well as printer functions, are now extended to accept new |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 154 | * [input / output handlers](@ref transition1_2GeneralInOut). The previous API working directly with inputs and outputs is |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 155 | * preserved (or slightly changed), but the functions can be limited in the functionality of the new API. More information |
| 156 | * can be found at @ref howtoSchemaParsers and @ref howtoSchemaPrinters pages. |
| 157 | * |
| 158 | * libyang 1.x | libyang 2.0 | Notes |
| 159 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 160 | * - | ::lys_parse() | New generic schema parser API using [generic input handler](@ref howtoInput). |
| 161 | * - | ::lys_print_module() | New generic schema printer API using [generic output handler](@ref howtoOutput). |
| 162 | * - | ::lys_print_node() | ^ |
| 163 | * - | ::lys_print_submodule() | ^ |
| 164 | * |
| 165 | * |
| 166 | * The following table introduces other significant changes in the API functions connected with the schema. |
| 167 | * |
| 168 | * libyang 1.x | libyang 2.0 | Notes |
| 169 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
Michal Vasko | 14ed9cd | 2021-01-28 14:16:25 +0100 | [diff] [blame] | 170 | * lys_set_private() | - | Not needed, all ::lysc_node compatible structures have this pointer so it can be accessed directly. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 171 | * lys_is_disabled() | - | Make no sense since the nodes disabled by if-feature are not present in the compiled tree. |
| 172 | * lys_features_list() | - | Not needed, the list of features is available in the parsed tree of the module and submodule. |
Michal Vasko | 08c8b27 | 2020-11-24 18:11:30 +0100 | [diff] [blame] | 173 | * lys_features_enable(), lys_features_enable_force() | ::lys_set_implemented() | Set of enabled features can be changed but it causes the whole context (all the modules) to recompile. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 174 | * lys_features_disable(), lys_features_disable_force() | - | ^ |
| 175 | * lys_features_state() | - | Redesign of the features handling in the schema tree, the feature's status is newly directly visible as ::LYS_FENABLED flag (in parsed feature structure). |
| 176 | * - | ::lys_feature_value() | Simplified API to get feature's state only based on a feature name string. |
| 177 | * - | ::lysp_feature_next() | After redesigning features handling, this function helps to iterate over all features connected with the module. |
| 178 | * lys_iffeature_value() | ::lysc_iffeature_value() | Renamed, but note that after features handling redesign, the compiled if-feature structure to evaluate is only in ::lysp_feature.iffeatures_c. |
| 179 | * lys_iffeature_value() | - | Not needed since the if-feature statements are directly applied onto the compiled tree. |
| 180 | * lys_is_disabled() | - | ^ |
| 181 | * lys_parent() | - | The compiled tree is more straightforward without the need to take care of nodes added via augments. |
| 182 | * lys_main_module() | - | The compiled tree does not include submodules, so there is always only the main module. |
| 183 | * lys_node_module() | - | ^ |
| 184 | * lys_set_enabled() | - | It is not possible to change context this way (remove or disable modules). |
| 185 | * lys_set_disabled() | - | ^ |
| 186 | * - | ::lys_find_child() | Helpers wrapper around ::lys_getnext(). |
Radek Krejci | 035dacf | 2021-02-12 18:25:53 +0100 | [diff] [blame] | 187 | * - | ::lys_getnext_ext() | Alternative to ::lys_getnext() allowing processing schema trees inside extension instances. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 188 | * - | ::lys_nodetype2str() | New functionality. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 189 | * lys_is_key() | ::lysc_is_key() | Renamed to connect with the compiled schema tree. |
| 190 | * - | ::lysc_is_userordered() | Added functionality to simplify the examination of generic compiled schema nodes. |
Michal Vasko | 5c123b0 | 2020-12-04 14:34:04 +0100 | [diff] [blame] | 191 | * - | ::lysc_is_np_cont() | ^ |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 192 | * - | ::lysc_node_child() | ^ |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 193 | * - | ::lysc_node_actions() | ^ |
| 194 | * - | ::lysc_node_notifs() | ^ |
Michal Vasko | 544e58a | 2021-01-28 14:33:41 +0100 | [diff] [blame] | 195 | * - | ::lysp_node_child() | Added functionality to simplify the examination of generic parsed schema nodes. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 196 | * - | ::lysp_node_actions() | ^ |
| 197 | * - | ::lysp_node_notifs() | ^ |
| 198 | * - | ::lysp_node_groupings() | ^ |
| 199 | * - | ::lysp_node_typedefs() | ^ |
| 200 | * - | ::lysc_tree_dfs_full() | Alternative DFS passing implementation to ::LYSC_TREE_DFS_BEGIN macro. |
| 201 | * - | ::lysc_module_dfs_full() | Supplement functionality to ::lysc_tree_dfs_full(). |
| 202 | * lys_path(), lys_data_path() | ::lysc_path() | Redesigned functionality. |
| 203 | * lys_data_path_pattern() | - | Removed as useless |
| 204 | * lys_implemented_module() | ::ly_ctx_get_module_implemented() | Removed, the same result can be simply achieved using ::ly_ctx_get_module_implemented(). |
| 205 | * |
| 206 | * There is a set of functions available to implement data type plugins for storing and manipulating data values in a more |
| 207 | * natural way to the specific data type. For example, IPv4 address type is defined as a string with a pattern, but it is |
| 208 | * more effective and usual to store and handle IPv4 as a 32-bit number. |
| 209 | * |
Radek Krejci | 0b01330 | 2021-03-29 15:22:32 +0200 | [diff] [blame] | 210 | * libyang 1.x | libyang 2.0 | Notes |
| 211 | * :----------------------------|:---------------------------------|:-------------------------------------------------------- |
| 212 | * lys_getnext_union_type() | - | Removed after the type representation redesign. |
| 213 | * - | ::lyplg_type_identity_isderived()| Helper functions for base types. |
| 214 | * - | ::lyplg_type_parse_dec64() | ^ |
| 215 | * - | ::lyplg_type_parse_int() | ^ |
| 216 | * - | ::lyplg_type_parse_uint() | ^ |
| 217 | * - | ::lyplg_type_validate_patterns() | ^ |
| 218 | * - | ::lyplg_type_validate_range() | ^ |
| 219 | * - | ::lyplg_type_get_prefix() | Helper functions for processing prefixes in data values. |
| 220 | * - | ::lyplg_type_prefix_data_new() | ^ |
| 221 | * - | ::lyplg_type_prefix_data_dup() | ^ |
| 222 | * - | ::lyplg_type_prefix_data_free() | ^ |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 223 | * |
| 224 | * |
Radek Krejci | 7510412 | 2021-04-01 15:37:45 +0200 | [diff] [blame] | 225 | * YANG extensions are supported via [extension plugins API](@ref pluginsExtensions) allowing to implement specific extension |
| 226 | * and load its support into libyang as a shared module. libyang implements several extensions on its own (see |
| 227 | * @ref howtoPluginsExtensions), but even these internal implementations use the same API. The API and [mechanism of loading |
| 228 | * external plugins](@ref howtoPlugins) changed a lot in contrast to libyang 1.x. The plugins are now loaded automatically |
| 229 | * with creating the first libyang context. The only public function to handle external plugins is ::lyplg_add(). |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 230 | * |
| 231 | * |
| 232 | * libyang 1.x | libyang 2.0 | Notes |
| 233 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
Radek Krejci | 7510412 | 2021-04-01 15:37:45 +0200 | [diff] [blame] | 234 | * lys_ext_complex_get_substmt()| lysc_ext_substmt() | Changed design of the extensions and the way how it's substatements are accessed. |
| 235 | * lys_ext_instance_presence() | lysc_ext_substmt() | ^ |
| 236 | * lys_ext_instance_substmt() | lysc_ext_substmt() | ^ |
| 237 | * ly_clean_plugins() | - | Manipulating external plugins (from plugins directories) is now automatically connected with creating (first) and destroying (last) libyang contexts. |
| 238 | * ly_get_loaded_plugins() | - | ^ |
| 239 | * ly_load_plugins() | - | ^ |
| 240 | * ly_register_exts() | ::lyplg_add() | Redesigned to a common function for any plugin type. |
| 241 | * ly_register_types() | ::lyplg_add() | ^ |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 242 | * |
| 243 | * |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 244 | * @section transition1_2Data Data Instances |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 245 | * |
| 246 | * Conceptually, the data tree did not change as much as the schema tree. There is still a generic ::lyd_node structure that |
| 247 | * maps according to the schema node's nodetype to some of the other lyd_node_* structures. All the data nodes were extended |
| 248 | * by hashes to improve performance when searching and processing data trees. The hashes are used for example in the |
Michal Vasko | 787ce39 | 2021-01-11 11:34:02 +0100 | [diff] [blame] | 249 | * lyd_find_* functions. |
| 250 | * |
| 251 | * All the data nodes are also implicitly ordered following the order of the schema nodes. This is the |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 252 | * reason to change the insertion function. Only the user-ordered lists and leaf-lists can be now placed relative to other |
| 253 | * instances of the same list/leaf-list. Otherwise, the data instance is always inserted/created at the correct place beside |
| 254 | * the right sibling nodes. |
| 255 | * |
Michal Vasko | 787ce39 | 2021-01-11 11:34:02 +0100 | [diff] [blame] | 256 | * For any functions that are available on inputs of different scale (node, subtree, all siblings, whole data tree), |
| 257 | * there are several variants of the specific function with suffix specifying what exactly the processed input will be |
| 258 | * (_single, _tree, _siblings, _all). This way the behavior is always clear in the code. |
| 259 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 260 | * libyang 1.x | libyang 2.0 | Notes |
| 261 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 262 | * %lyd_insert_after() | ::lyd_insert_after() | Changed meaning by limiting applicability only to user-ordered list and leaf-list instances. |
| 263 | * %lyd_insert_before() | ::lyd_insert_before() | ^ |
| 264 | * lyd_schema_sort() | - | Not necessary since the nodes are sorted implicitly. |
| 265 | * |
| 266 | * |
| 267 | * Parsing data instances in XML format is newly done directly, without any interstep. Therefore, complete XML API |
| 268 | * (lyxml_*() functions) from libyang 1.x was removed. |
| 269 | * |
| 270 | * Parser's API was simplified to avoid variadic parameters. The functions are newly split to parsed data, notifications, |
| 271 | * RPCs and replies to the RPCs. Similarly to the schema parsers, also the new data parser API works with |
Michal Vasko | b131989 | 2024-02-26 16:15:40 +0100 | [diff] [blame] | 272 | * [input handlers](@ref transition1_2GeneralInOut). The data printer's API was also extended to use new |
| 273 | * [output handlers](@ref transition1_2GeneralInOut). However, part of the previous API working directly with inputs |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 274 | * and outputs was preserved. More information about the data parser and printer can be found at |
| 275 | * @ref howtoDataParsers and @ref howtoDataPrinters pages. |
| 276 | * |
| 277 | * libyang 1.x | libyang 2.0 | Notes |
| 278 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 279 | * - | ::lyd_parse_data() | Redesigned data tree parser. |
| 280 | * lyd_parse_xml() | - | XML tree format was removed. |
| 281 | * lyd_parse_fd() | ::lyd_parse_data_fd() | Renamed and limited to data trees only. |
| 282 | * lyd_parse_mem() | ::lyd_parse_data_mem() | ^ |
| 283 | * lyd_parse_path() | ::lyd_parse_data_path() | ^ |
Radek Krejci | f16e254 | 2021-02-17 15:39:23 +0100 | [diff] [blame] | 284 | * - | ::lyd_parse_ext_data() | Separated function for parsing data trees matching a schema tree of the given extension instance. |
Michal Vasko | e066574 | 2021-02-11 11:08:44 +0100 | [diff] [blame] | 285 | * - | ::lyd_parse_op() | Separated function for parsing RPCs, actions, replies, and notifications. |
Radek Krejci | f16e254 | 2021-02-17 15:39:23 +0100 | [diff] [blame] | 286 | * - | ::lyd_parse_ext_op() | Separated function for parsing RPCs, actions, replies, and notifications of the given extension instance. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 287 | * - | ::lyd_print_all() | New API accepting ::ly_out. |
| 288 | * - | ::lyd_print_tree() | ^ |
| 289 | * |
| 290 | * |
| 291 | * Data validation is still done as part of the parser's process. The standalone functionality is available to check the |
| 292 | * result of data manipulation with the values of the terminal nodes or with the structure of the data tree. In contrast to |
| 293 | * libyang 1.x, adding the default nodes was made available as a standalone function to simplify the data manipulation |
| 294 | * process before the final validation. |
| 295 | * |
Michal Vasko | a24b9af | 2020-11-09 20:57:39 +0100 | [diff] [blame] | 296 | * Many validation flags were removed because they became obsolete (LYD_OPT_DESTRUCT, LYD_OPT_WHENAUTODEL, |
| 297 | * LYD_OPT_NOEXTDEPS, LYD_OPT_DATA_NO_YANGLIB, LYD_OPT_VAL_DIFF) or we consider them redundant (LYD_OPT_OBSOLETE, |
| 298 | * LYD_OPT_NOSIBLINGS, LYD_OPT_DATA_ADD_YANGLIB). As for LYD_OPT_TRUSTED, this option was mostly replaced with |
| 299 | * ::LYD_PARSE_ONLY because both skip validation but with the significant difference that LYD_OPT_TRUSTED also sets |
| 300 | * the data node flags to be considered validated. The current option ::LYD_PARSE_ONLY does not do this because |
| 301 | * there is now much better support for working with non-validated data trees. Also, in case an invalid tree was marked |
| 302 | * as validated, it could lead to some undesired behavior, which is now avoided. |
| 303 | * |
| 304 | * Worth mentioning is a difference in the LYB format, which now also stores its validation flags. So, in case |
| 305 | * a validated data tree is stored, it is also loaded as validated. |
| 306 | * |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 307 | * libyang 1.x | libyang 2.0 | Notes |
| 308 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 309 | * lyd_validate() | ::lyd_validate_all(), ::lyd_validate_op() | Redesigned functionality. |
| 310 | * lyd_validate_modules() | ::lyd_validate_module() | ^ |
| 311 | * lyd_validate_value(), lyd_value_type() | ::lyd_value_validate() | Redesigned functionality. |
| 312 | * - | ::lyd_new_implicit_all() | New in API to explicitly add default nodes, previously done only as part of the validation process. |
| 313 | * - | ::lyd_new_implicit_module() | Supplement functionality to ::lyd_new_implicit_all(). |
| 314 | * - | ::lyd_new_implicit_tree() | ^ |
| 315 | * |
| 316 | * |
| 317 | * The `diff` functionality was completely redesigned. Instead of the array of operations to transform one tree into another, |
| 318 | * the difference between two data trees has newly a form of the annotated data tree describing the differences. A number of |
| 319 | * functions to use the diff tree was added into API. To simply compare just nodes, there are the `compare` functions. |
| 320 | * |
| 321 | * libyang 1.x | libyang 2.0 | Notes |
| 322 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 323 | * lyd_diff() | ::lyd_diff_tree() | Redesigned functionality. |
| 324 | * - | ::lyd_diff_siblings() | Supplement functionality to ::lyd_diff_tree(). |
| 325 | * - | ::lyd_diff_apply_all() | ^ |
| 326 | * - | ::lyd_diff_apply_module() | ^ |
| 327 | * - | ::lyd_diff_merge_all() | ^ |
| 328 | * - | ::lyd_diff_merge_module() | ^ |
| 329 | * - | ::lyd_diff_merge_tree() | ^ |
| 330 | * - | ::lyd_diff_reverse_all() | ^ |
| 331 | * lyd_free_diff() | - | Removed. |
| 332 | * lyd_free_val_diff() | - | Removed. |
| 333 | * - | ::lyd_compare_single() | Added functionality. |
| 334 | * - | ::lyd_compare_meta() | Supplement functionality to ::lyd_compare_single() |
| 335 | * - | ::lyd_compare_siblings() | ^ |
| 336 | * |
| 337 | * |
| 338 | * For now, the functionality of moving data between two different contexts is not implemented. If you have a real use case |
| 339 | * for this functionality, let us know. |
| 340 | * |
| 341 | * libyang 1.x | libyang 2.0 | Notes |
| 342 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 343 | * lyd_dup() | ::lyd_dup_single() | Redesigned functionality. |
| 344 | * lyd_dup_withsiblings() | ::lyd_dup_siblings() | ^ |
| 345 | * - | ::lyd_dup_meta_single() | Supplement functionality to ::lyd_dup_single(). |
| 346 | * lyd_dup_to_ctx() | - | Transferring data from one context to another is not supported. |
| 347 | * lyd_merge() | ::lyd_merge_tree() | Renamed. |
| 348 | * - | ::lyd_merge_siblings() | Supplement functionality to ::lyd_merge_tree() |
| 349 | * lyd_merge_to_ctx() | - | Transferring data from one context to another is not supported. |
| 350 | * |
| 351 | * |
| 352 | * There is a significant change in the value structure in terminal nodes. Thanks to the changes in the schema tree, |
| 353 | * it is now much more straightforward to get the type of the value and work with the alternative representation of the value |
| 354 | * fitting better to its type. There is also a new API for the type plugins (see @ref howtoPluginsTypes). Even the base YANG |
| 355 | * data types are now implemented using this API and can be taken as examples for implementing derived data types. |
| 356 | * |
| 357 | * libyang 1.x | libyang 2.0 | Notes |
| 358 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 359 | * lyd_new(), lyd_new_output() | ::lyd_new_inner(), ::lyd_new_list(), ::lyd_new_list2() | Redesigned functionality to better fit new lyd_node structures, creating RPC's output data is now done via a flag parameter of the functions. |
| 360 | * lyd_new_leaf(), lyd_new_output_leaf() | ::lyd_new_term() | ^ |
| 361 | * lyd_new_anydata(), lyd_new_output_anydata() | ::lyd_new_any() | ^ |
Radek Krejci | 0b963da | 2021-03-12 13:23:44 +0100 | [diff] [blame] | 362 | * lyd_new_yangdata() | ::lyd_new_ext_inner(), ::lyd_new_ext_list(), ::lyd_new_ext_term(), ::lyd_new_ext_any() | Additional functionality to lyd_new_* functions to cover top-level nodes in extension instances. |
Michal Vasko | 8d65f85 | 2021-02-17 11:28:13 +0100 | [diff] [blame] | 363 | * lyd_insert_attr() | ::lyd_new_meta() | Unify naming used in other functions with the similar functionality. |
| 364 | * - | ::lyd_new_attr() | Added functionality to store the data (temporarily) not connected with schema definitions. |
| 365 | * - | ::lyd_new_attr2() | ^ |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 366 | * - | ::lyd_new_opaq() | ^ |
Michal Vasko | 8d65f85 | 2021-02-17 11:28:13 +0100 | [diff] [blame] | 367 | * - | ::lyd_new_opaq2() | ^ |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 368 | * - | ::lyd_new_path2() | Supplement functionality to ::lyd_new_path(). |
Václav Kubernát | c68ca21 | 2021-11-03 11:07:45 +0100 | [diff] [blame] | 369 | * LYD_PATH_OPT_NOPARENTRET | ::lyd_new_path2() | ::lyd_new_path2() returns both the first parent and the wanted node. |
| 370 | * LYD_PATH_OPT_EDIT | ::LYD_NEW_PATH_OPAQ | This functionality was replaced by opaq nodes. |
Radek Krejci | 95ccd1b | 2021-03-12 14:57:22 +0100 | [diff] [blame] | 371 | * - | ::lyd_new_ext_path() | Supplement functionality to ::lyd_new_path() covering data defined in extension instances. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 372 | * lyd_insert() | ::lyd_insert_child() | Renamed to better distinguish from ::lyd_insert_sibling(). |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 373 | * lyd_change_leaf() | ::lyd_change_term() | Align naming with changed names of data structures. |
| 374 | * - | ::lyd_change_meta() | Transferred functionality of ::lyd_change_term() to metadata. |
| 375 | * - | ::lyd_any_copy_value() | Added functionality. |
| 376 | * lyd_free() | ::lyd_free_tree() | Renamed. |
| 377 | * lyd_free_withsiblings() | ::lyd_free_all() | ^ |
| 378 | * - | ::lyd_free_siblings() | Supplement functionality to ::lyd_free_siblings(). |
| 379 | * lyd_free_attr() | ::lyd_free_attr_single() | Renamed. |
| 380 | * - | ::lyd_free_attr_siblings() | Supplement functionality to ::lyd_free_attr_single(). |
| 381 | * - | ::lyd_free_meta_single() | Added functionality. |
| 382 | * - | ::lyd_free_meta_siblings() | ^ |
| 383 | * lyd_unlink() | ::lyd_unlink_tree() | Renamed. |
| 384 | * |
| 385 | * |
| 386 | * Here is the table of other changes in data API. |
| 387 | * |
| 388 | * libyang 1.x | libyang 2.0 | Notes |
| 389 | * :----------------------------|:--------------------------------|:--------------------------------------------------------- |
| 390 | * lyd_find_instance() | - | Removed. |
| 391 | * lyd_find_sibling() | - | Removed, functionality can be replaced by ::lyd_find_sibling_val(). |
| 392 | * lyd_find_sibling_set() | - | ^ |
| 393 | * - | ::lyd_find_sibling_first() | Alternative function to ::lyd_find_sibling_val(). |
| 394 | * - | ::lyd_find_meta() | New functionality. |
| 395 | * lyd_wd_default() | ::lyd_is_default() | Renamed to unlink from with-default capability. |
| 396 | * - | ::lyd_parent() | New wrapper to get generic ::lyd_node pointer of the parent. |
| 397 | * - | ::lyd_child(), ::lyd_child_no_keys() | New wrapper to cover all children possibilities hidden behind a generic ::lyd_node structure. |
| 398 | * - | ::lyd_owner_module() | Added functionality. |
| 399 | * - | ::lyd_value_compare() | Added Functionality. |
Michal Vasko | 2c1f66d | 2024-01-22 14:36:13 +0100 | [diff] [blame] | 400 | * - | ::lyd_find_target() | Added functionality for the instance-identifier representation. |
Radek Krejci | fba9c62 | 2020-10-30 08:28:54 +0100 | [diff] [blame] | 401 | * lyd_node_module() | - | Not necessary since the connection with the compiled modules is much more straightforward. |
| 402 | * lyd_leaf_type() | - | Not necessary since the real type information is much more clear from the new ::lyd_value. |
| 403 | * lyd_dec64_to_double() | - | Removed as useless. |
| 404 | * lyd_node_should_print() | - | ^ |
| 405 | |
Radek Krejci | 8678fa4 | 2020-08-18 16:07:28 +0200 | [diff] [blame] | 406 | */ |