blob: 720f8289e0d14b4bfc5e0c3615ca2941fa382d3a [file] [log] [blame]
Radek Krejci0935f412019-08-20 16:15:18 +02001/**
2 * @file plugins_exts.c
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief Internally implemented YANG extensions.
5 *
6 * Copyright (c) 2019 CESNET, z.s.p.o.
7 *
8 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * https://opensource.org/licenses/BSD-3-Clause
13 */
14#include "common.h"
15
16#include "plugins_exts.h"
17
18#include "plugins_exts_nacm.c"
19
20/**
21 * @brief list of all extension plugins implemented internally
22 */
23struct lyext_plugins_list lyext_plugins_internal[5] = {
24 {"ietf-netconf-acm", "2012-02-22", "default-deny-write", &nacm_plugin},
25 {"ietf-netconf-acm", "2018-02-14", "default-deny-write", &nacm_plugin},
26 {"ietf-netconf-acm", "2012-02-22", "default-deny-all", &nacm_plugin},
27 {"ietf-netconf-acm", "2018-02-14", "default-deny-all", &nacm_plugin},
28 {NULL, NULL, NULL, NULL} /* terminating item */
29};
30
31/* TODO support for external extension plugins */
32
33struct lyext_plugin *
34lyext_get_plugin(struct lysc_ext *ext)
35{
36 unsigned int u;
37
38 for (u = 0; lyext_plugins_internal[u].module; ++u) {
39 if (!strcmp(ext->name, lyext_plugins_internal[u].name) &&
40 !strcmp(ext->module->name, lyext_plugins_internal[u].module) &&
41 (!lyext_plugins_internal[u].revision || !strcmp(ext->module->revision, lyext_plugins_internal[u].revision))) {
42 /* we have the match */
43 return lyext_plugins_internal[u].plugin;
44 }
45 }
46
47 return NULL;
48}
49
50API const char *
51lyext_parent2str(LYEXT_PARENT type)
52{
53 switch(type) {
54 case LYEXT_PAR_MODULE:
55 return "module";
56 case LYEXT_PAR_NODE:
57 return "data node";
58 case LYEXT_PAR_INPUT:
59 return "input";
60 case LYEXT_PAR_OUTPUT:
61 return "output";
62 case LYEXT_PAR_TYPE:
63 return "type";
64 case LYEXT_PAR_TYPE_BIT:
65 return "bit";
66 case LYEXT_PAR_TYPE_ENUM:
67 return "enum";
68 case LYEXT_PAR_FEATURE:
69 return "feature";
70 case LYEXT_PAR_MUST:
71 return "must";
72 case LYEXT_PAR_PATTERN:
73 return "pattern";
74 case LYEXT_PAR_LENGTH:
75 return "length";
76 case LYEXT_PAR_RANGE:
77 return "range";
78 case LYEXT_PAR_WHEN:
79 return "when";
80 case LYEXT_PAR_IDENT:
81 return "identity";
82 case LYEXT_PAR_EXT:
83 return "extension instance";
84 case LYEXT_PAR_IMPORT:
85 return "import";
86/* YANG allows extension instances inside the following statements,
87 * but they do not have any meaning in current libyang
88 case LYEXT_PAR_TPDF:
89 return "typedef";
90 case LYEXT_PAR_EXTINST:
91 return "extension";
92 case LYEXT_PAR_REFINE:
93 return "refine";
94 case LYEXT_PAR_DEVIATION:
95 return "deviation";
96 case LYEXT_PAR_DEVIATE:
97 return "deviate";
98 case LYEXT_PAR_INCLUDE:
99 return "include";
100 case LYEXT_PAR_REVISION:
101 return "revision";
102 */
103 default:
104 return "unknown";
105 }
106}