blob: 6f18050f7ae21579431d01ca88555d7ab0450692 [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 */
Radek Krejci0935f412019-08-20 16:15:18 +020014
15#include "plugins_exts.h"
16
Radek Krejci47fab892020-11-05 17:02:41 +010017#include <stdint.h>
Radek Krejci535ea9f2020-05-29 16:01:05 +020018#include <string.h>
19
Radek Krejcid6b76452019-09-03 17:03:03 +020020#include "plugins_exts_metadata.c"
Radek Krejci535ea9f2020-05-29 16:01:05 +020021#include "plugins_exts_nacm.c"
Radek Krejci5fa32a32021-02-08 18:12:38 +010022#include "plugins_exts_yangdata.c"
Radek Krejci0935f412019-08-20 16:15:18 +020023
24/**
25 * @brief list of all extension plugins implemented internally
26 */
Radek Krejcif13b87b2020-12-01 22:02:17 +010027struct lyext_plugins_list lyext_plugins_internal[] = {
Radek Krejci0935f412019-08-20 16:15:18 +020028 {"ietf-netconf-acm", "2012-02-22", "default-deny-write", &nacm_plugin},
29 {"ietf-netconf-acm", "2018-02-14", "default-deny-write", &nacm_plugin},
30 {"ietf-netconf-acm", "2012-02-22", "default-deny-all", &nacm_plugin},
31 {"ietf-netconf-acm", "2018-02-14", "default-deny-all", &nacm_plugin},
Radek Krejcid6b76452019-09-03 17:03:03 +020032 {"ietf-yang-metadata", "2016-08-05", "annotation", &metadata_plugin},
Radek Krejci5fa32a32021-02-08 18:12:38 +010033 {"ietf-restconf", "2017-01-26", "yang-data", &yangdata_plugin},
Radek Krejci0935f412019-08-20 16:15:18 +020034 {NULL, NULL, NULL, NULL} /* terminating item */
35};
36
37/* TODO support for external extension plugins */
38
39struct lyext_plugin *
40lyext_get_plugin(struct lysc_ext *ext)
41{
Radek Krejci1deb5be2020-08-26 16:43:36 +020042 for (uint8_t u = 0; lyext_plugins_internal[u].module; ++u) {
Radek Krejci0935f412019-08-20 16:15:18 +020043 if (!strcmp(ext->name, lyext_plugins_internal[u].name) &&
44 !strcmp(ext->module->name, lyext_plugins_internal[u].module) &&
45 (!lyext_plugins_internal[u].revision || !strcmp(ext->module->revision, lyext_plugins_internal[u].revision))) {
46 /* we have the match */
47 return lyext_plugins_internal[u].plugin;
48 }
49 }
50
51 return NULL;
52}