/src/frr/bgpd/bgp_nexthop_clippy.c
Line | Count | Source |
1 | | /* show_ip_bgp_nexthop => "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] nexthop [<A.B.C.D|X:X::X:X>$nhop] [<ipv4$afi [A.B.C.D$nhop]|ipv6$afi [X:X::X:X$nhop]>] [detail$detail] [json$uj]" */ |
2 | | DEFUN_CMD_FUNC_DECL(show_ip_bgp_nexthop) |
3 | | #define funcdecl_show_ip_bgp_nexthop static int show_ip_bgp_nexthop_magic(\ |
4 | | const struct cmd_element *self __attribute__ ((unused)),\ |
5 | | struct vty *vty __attribute__ ((unused)),\ |
6 | | int argc __attribute__ ((unused)),\ |
7 | | struct cmd_token *argv[] __attribute__ ((unused)),\ |
8 | | const char * vrf,\ |
9 | | const union sockunion * nhop,\ |
10 | | const char * nhop_str __attribute__ ((unused)),\ |
11 | | const char * afi,\ |
12 | | const char * detail,\ |
13 | | const char * uj) |
14 | | funcdecl_show_ip_bgp_nexthop; |
15 | | DEFUN_CMD_FUNC_TEXT(show_ip_bgp_nexthop) |
16 | 0 | { |
17 | 0 | #if 5 /* anything to parse? */ |
18 | 0 | int _i; |
19 | 0 | #if 1 /* anything that can fail? */ |
20 | 0 | unsigned _fail = 0, _failcnt = 0; |
21 | 0 | #endif |
22 | 0 | const char *vrf = NULL; |
23 | 0 | union sockunion s__nhop = { .sa.sa_family = AF_UNSPEC }, *nhop = NULL; |
24 | 0 | const char *nhop_str = NULL; |
25 | 0 | const char *afi = NULL; |
26 | 0 | const char *detail = NULL; |
27 | 0 | const char *uj = NULL; |
28 | |
|
29 | 0 | for (_i = 0; _i < argc; _i++) { |
30 | 0 | if (!argv[_i]->varname) |
31 | 0 | continue; |
32 | 0 | #if 1 /* anything that can fail? */ |
33 | 0 | _fail = 0; |
34 | 0 | #endif |
35 | |
|
36 | 0 | if (!strcmp(argv[_i]->varname, "vrf")) { |
37 | 0 | vrf = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
38 | 0 | } |
39 | 0 | if (!strcmp(argv[_i]->varname, "nhop")) { |
40 | 0 | nhop_str = argv[_i]->arg; |
41 | 0 | if (argv[_i]->text[0] == 'X') { |
42 | 0 | s__nhop.sa.sa_family = AF_INET6; |
43 | 0 | _fail = !inet_pton(AF_INET6, argv[_i]->arg, &s__nhop.sin6.sin6_addr); |
44 | 0 | nhop = &s__nhop; |
45 | 0 | } else { |
46 | 0 | s__nhop.sa.sa_family = AF_INET; |
47 | 0 | _fail = !inet_aton(argv[_i]->arg, &s__nhop.sin.sin_addr); |
48 | 0 | nhop = &s__nhop; |
49 | 0 | } |
50 | 0 | } |
51 | 0 | if (!strcmp(argv[_i]->varname, "afi")) { |
52 | 0 | afi = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
53 | 0 | } |
54 | 0 | if (!strcmp(argv[_i]->varname, "detail")) { |
55 | 0 | detail = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
56 | 0 | } |
57 | 0 | if (!strcmp(argv[_i]->varname, "uj")) { |
58 | 0 | uj = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
59 | 0 | } |
60 | 0 | #if 1 /* anything that can fail? */ |
61 | 0 | if (_fail) |
62 | 0 | vty_out (vty, "%% invalid input for %s: %s\n", |
63 | 0 | argv[_i]->varname, argv[_i]->arg); |
64 | 0 | _failcnt += _fail; |
65 | 0 | #endif |
66 | 0 | } |
67 | 0 | #if 1 /* anything that can fail? */ |
68 | 0 | if (_failcnt) |
69 | 0 | return CMD_WARNING; |
70 | 0 | #endif |
71 | 0 | #endif |
72 | | |
73 | 0 | return show_ip_bgp_nexthop_magic(self, vty, argc, argv, vrf, nhop, nhop_str, afi, detail, uj); |
74 | 0 | } |
75 | | |
76 | | /* show_ip_bgp_import_check => "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] import-check-table [detail$detail] [json$uj]" */ |
77 | | DEFUN_CMD_FUNC_DECL(show_ip_bgp_import_check) |
78 | | #define funcdecl_show_ip_bgp_import_check static int show_ip_bgp_import_check_magic(\ |
79 | | const struct cmd_element *self __attribute__ ((unused)),\ |
80 | | struct vty *vty __attribute__ ((unused)),\ |
81 | | int argc __attribute__ ((unused)),\ |
82 | | struct cmd_token *argv[] __attribute__ ((unused)),\ |
83 | | const char * vrf,\ |
84 | | const char * detail,\ |
85 | | const char * uj) |
86 | | funcdecl_show_ip_bgp_import_check; |
87 | | DEFUN_CMD_FUNC_TEXT(show_ip_bgp_import_check) |
88 | 0 | { |
89 | 0 | #if 3 /* anything to parse? */ |
90 | 0 | int _i; |
91 | | #if 0 /* anything that can fail? */ |
92 | | unsigned _fail = 0, _failcnt = 0; |
93 | | #endif |
94 | 0 | const char *vrf = NULL; |
95 | 0 | const char *detail = NULL; |
96 | 0 | const char *uj = NULL; |
97 | |
|
98 | 0 | for (_i = 0; _i < argc; _i++) { |
99 | 0 | if (!argv[_i]->varname) |
100 | 0 | continue; |
101 | | #if 0 /* anything that can fail? */ |
102 | | _fail = 0; |
103 | | #endif |
104 | | |
105 | 0 | if (!strcmp(argv[_i]->varname, "vrf")) { |
106 | 0 | vrf = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
107 | 0 | } |
108 | 0 | if (!strcmp(argv[_i]->varname, "detail")) { |
109 | 0 | detail = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
110 | 0 | } |
111 | 0 | if (!strcmp(argv[_i]->varname, "uj")) { |
112 | 0 | uj = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
113 | 0 | } |
114 | | #if 0 /* anything that can fail? */ |
115 | | if (_fail) |
116 | | vty_out (vty, "%% invalid input for %s: %s\n", |
117 | | argv[_i]->varname, argv[_i]->arg); |
118 | | _failcnt += _fail; |
119 | | #endif |
120 | 0 | } |
121 | | #if 0 /* anything that can fail? */ |
122 | | if (_failcnt) |
123 | | return CMD_WARNING; |
124 | | #endif |
125 | 0 | #endif |
126 | |
|
127 | 0 | return show_ip_bgp_import_check_magic(self, vty, argc, argv, vrf, detail, uj); |
128 | 0 | } |
129 | | |
130 | | /* show_ip_bgp_instance_all_nexthop => "show [ip] bgp <view|vrf> all nexthop [<ipv4|ipv6>$afi] [detail$detail] [json$uj]" */ |
131 | | DEFUN_CMD_FUNC_DECL(show_ip_bgp_instance_all_nexthop) |
132 | | #define funcdecl_show_ip_bgp_instance_all_nexthop static int show_ip_bgp_instance_all_nexthop_magic(\ |
133 | | const struct cmd_element *self __attribute__ ((unused)),\ |
134 | | struct vty *vty __attribute__ ((unused)),\ |
135 | | int argc __attribute__ ((unused)),\ |
136 | | struct cmd_token *argv[] __attribute__ ((unused)),\ |
137 | | const char * afi,\ |
138 | | const char * detail,\ |
139 | | const char * uj) |
140 | | funcdecl_show_ip_bgp_instance_all_nexthop; |
141 | | DEFUN_CMD_FUNC_TEXT(show_ip_bgp_instance_all_nexthop) |
142 | 0 | { |
143 | 0 | #if 3 /* anything to parse? */ |
144 | 0 | int _i; |
145 | | #if 0 /* anything that can fail? */ |
146 | | unsigned _fail = 0, _failcnt = 0; |
147 | | #endif |
148 | 0 | const char *afi = NULL; |
149 | 0 | const char *detail = NULL; |
150 | 0 | const char *uj = NULL; |
151 | |
|
152 | 0 | for (_i = 0; _i < argc; _i++) { |
153 | 0 | if (!argv[_i]->varname) |
154 | 0 | continue; |
155 | | #if 0 /* anything that can fail? */ |
156 | | _fail = 0; |
157 | | #endif |
158 | | |
159 | 0 | if (!strcmp(argv[_i]->varname, "afi")) { |
160 | 0 | afi = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
161 | 0 | } |
162 | 0 | if (!strcmp(argv[_i]->varname, "detail")) { |
163 | 0 | detail = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
164 | 0 | } |
165 | 0 | if (!strcmp(argv[_i]->varname, "uj")) { |
166 | 0 | uj = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg; |
167 | 0 | } |
168 | | #if 0 /* anything that can fail? */ |
169 | | if (_fail) |
170 | | vty_out (vty, "%% invalid input for %s: %s\n", |
171 | | argv[_i]->varname, argv[_i]->arg); |
172 | | _failcnt += _fail; |
173 | | #endif |
174 | 0 | } |
175 | | #if 0 /* anything that can fail? */ |
176 | | if (_failcnt) |
177 | | return CMD_WARNING; |
178 | | #endif |
179 | 0 | #endif |
180 | |
|
181 | 0 | return show_ip_bgp_instance_all_nexthop_magic(self, vty, argc, argv, afi, detail, uj); |
182 | 0 | } |
183 | | |