]> git.proxmox.com Git - mirror_frr.git/blob - tools/gen_yang_deviations.c
bgpd: Allow 'no set community`
[mirror_frr.git] / tools / gen_yang_deviations.c
1 /*
2 * Copyright (C) 2018 NetDEF, Inc.
3 * Renato Westphal
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #define REALLY_NEED_PLAIN_GETOPT 1
21
22 #include <zebra.h>
23
24 #include <unistd.h>
25
26 #include "yang.h"
27 #include "northbound.h"
28
29 static void __attribute__((noreturn)) usage(int status)
30 {
31 fprintf(stderr, "usage: gen_yang_deviations [-h] MODULE\n");
32 exit(status);
33 }
34
35 static int generate_yang_deviation(const struct lys_node *snode, void *arg)
36 {
37 char xpath[XPATH_MAXLEN];
38
39 yang_snode_get_path(snode, YANG_PATH_SCHEMA, xpath, sizeof(xpath));
40
41 printf(" deviation \"%s\" {\n", xpath);
42 printf(" deviate not-supported;\n");
43 printf(" }\n\n");
44
45 return YANG_ITER_CONTINUE;
46 }
47
48 int main(int argc, char *argv[])
49 {
50 struct yang_module *module;
51 int opt;
52
53 while ((opt = getopt(argc, argv, "h")) != -1) {
54 switch (opt) {
55 case 'h':
56 usage(EXIT_SUCCESS);
57 /* NOTREACHED */
58 default:
59 usage(EXIT_FAILURE);
60 /* NOTREACHED */
61 }
62 }
63 argc -= optind;
64 argv += optind;
65 if (argc != 1)
66 usage(EXIT_FAILURE);
67
68 yang_init();
69
70 /* Load YANG module. */
71 module = yang_module_load(argv[0]);
72
73 /* Generate deviations. */
74 yang_snodes_iterate_module(module->info, generate_yang_deviation,
75 YANG_ITER_FILTER_IMPLICIT, NULL);
76
77 /* Cleanup and exit. */
78 yang_terminate();
79
80 return 0;
81 }