]> git.proxmox.com Git - mirror_frr.git/blame - tools/gen_yang_deviations.c
bgpd: attr evpn attributes should be modified before interning attr
[mirror_frr.git] / tools / gen_yang_deviations.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
1c2facd1
RW
2/*
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
1c2facd1
RW
5 */
6
7#define REALLY_NEED_PLAIN_GETOPT 1
8
9#include <zebra.h>
10
11#include <unistd.h>
12
13#include "yang.h"
14#include "northbound.h"
15
16static void __attribute__((noreturn)) usage(int status)
17{
18 fprintf(stderr, "usage: gen_yang_deviations [-h] MODULE\n");
19 exit(status);
20}
21
3bb513c3 22static int generate_yang_deviation(const struct lysc_node *snode, void *arg)
1c2facd1
RW
23{
24 char xpath[XPATH_MAXLEN];
25
26 yang_snode_get_path(snode, YANG_PATH_SCHEMA, xpath, sizeof(xpath));
27
28 printf(" deviation \"%s\" {\n", xpath);
29 printf(" deviate not-supported;\n");
30 printf(" }\n\n");
e0ccfad2
RW
31
32 return YANG_ITER_CONTINUE;
1c2facd1
RW
33}
34
35int main(int argc, char *argv[])
36{
37 struct yang_module *module;
38 int opt;
39
40 while ((opt = getopt(argc, argv, "h")) != -1) {
41 switch (opt) {
42 case 'h':
43 usage(EXIT_SUCCESS);
44 /* NOTREACHED */
45 default:
46 usage(EXIT_FAILURE);
47 /* NOTREACHED */
48 }
49 }
50 argc -= optind;
51 argv += optind;
52 if (argc != 1)
53 usage(EXIT_FAILURE);
54
3bb513c3 55 yang_init(false, false);
1c2facd1
RW
56
57 /* Load YANG module. */
58 module = yang_module_load(argv[0]);
59
60 /* Generate deviations. */
3bb513c3 61 yang_snodes_iterate(module->info, generate_yang_deviation, 0, NULL);
1c2facd1
RW
62
63 /* Cleanup and exit. */
64 yang_terminate();
65
66 return 0;
67}