blob: f00e35eff56fc245c73e600057c911599fb2e44e [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Zebra VTY functions
2 * Copyright (C) 2002 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
Paul Jakma7514fb72007-05-02 16:05:35 +000024#include "memory.h"
paul718e3742002-12-13 20:15:29 +000025#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
30
paula1ac18c2005-06-28 17:17:12 +000031#include "zebra/zserv.h"
32
Everton Marques33d86db2014-07-14 11:19:00 -030033static int do_show_ip_route(struct vty *vty, safi_t safi);
34
35/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000036static int
Everton Marques33d86db2014-07-14 11:19:00 -030037zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
38 const char *dest_str, const char *mask_str,
39 const char *gate_str, const char *flag_str,
40 const char *distance_str)
paul718e3742002-12-13 20:15:29 +000041{
42 int ret;
43 u_char distance;
44 struct prefix p;
45 struct in_addr gate;
46 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000047 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000048 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +000049
50 ret = str2prefix (dest_str, &p);
51 if (ret <= 0)
52 {
53 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
54 return CMD_WARNING;
55 }
56
57 /* Cisco like mask notation. */
58 if (mask_str)
59 {
60 ret = inet_aton (mask_str, &mask);
61 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000062 {
63 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
64 return CMD_WARNING;
65 }
paul718e3742002-12-13 20:15:29 +000066 p.prefixlen = ip_masklen (mask);
67 }
68
69 /* Apply mask for given prefix. */
70 apply_mask (&p);
71
paul595db7f2003-05-25 21:35:06 +000072 /* Administrative distance. */
73 if (distance_str)
74 distance = atoi (distance_str);
75 else
76 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
77
78 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000079 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000080 {
81 if (flag_str)
82 {
83 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
84 return CMD_WARNING;
85 }
86 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -030087 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
paul595db7f2003-05-25 21:35:06 +000088 else
Everton Marques33d86db2014-07-14 11:19:00 -030089 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
paul595db7f2003-05-25 21:35:06 +000090 return CMD_SUCCESS;
91 }
92
hasso81dfcaa2003-05-25 19:21:25 +000093 /* Route flags */
94 if (flag_str) {
95 switch(flag_str[0]) {
96 case 'r':
97 case 'R': /* XXX */
98 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
99 break;
100 case 'b':
101 case 'B': /* XXX */
102 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
103 break;
104 default:
105 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000106 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000107 }
108 }
109
hasso457ef552003-05-28 12:02:15 +0000110 if (gate_str == NULL)
111 {
112 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -0300113 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, 0);
hasso457ef552003-05-28 12:02:15 +0000114 else
Everton Marques33d86db2014-07-14 11:19:00 -0300115 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
hasso457ef552003-05-28 12:02:15 +0000116
117 return CMD_SUCCESS;
118 }
119
paul718e3742002-12-13 20:15:29 +0000120 /* When gateway is A.B.C.D format, gate is treated as nexthop
121 address other case gate is treated as interface name. */
122 ret = inet_aton (gate_str, &gate);
123 if (ret)
124 ifname = NULL;
125 else
126 ifname = gate_str;
127
128 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -0300129 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, 0);
paul718e3742002-12-13 20:15:29 +0000130 else
Everton Marques33d86db2014-07-14 11:19:00 -0300131 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, 0);
paul718e3742002-12-13 20:15:29 +0000132
133 return CMD_SUCCESS;
134}
135
Everton Marques33d86db2014-07-14 11:19:00 -0300136static int
137zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
138 const char *mask_str, const char *gate_str,
139 const char *flag_str, const char *distance_str)
140{
141 return zebra_static_ipv4_safi(vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, gate_str, flag_str, distance_str);
142}
143
144/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100145DEFUN (ip_mroute_dist,
146 ip_mroute_dist_cmd,
147 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300148 IP_STR
149 "Configure static unicast route into MRIB for multicast RPF lookup\n"
150 "IP destination prefix (e.g. 10.0.0.0/8)\n"
151 "Nexthop address\n"
152 "Nexthop interface name\n"
153 "Distance\n")
154{
David Lampartera76681b2015-01-22 19:03:53 +0100155 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
156 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300157}
158
David Lampartera76681b2015-01-22 19:03:53 +0100159ALIAS (ip_mroute_dist,
160 ip_mroute_cmd,
161 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
162 IP_STR
163 "Configure static unicast route into MRIB for multicast RPF lookup\n"
164 "IP destination prefix (e.g. 10.0.0.0/8)\n"
165 "Nexthop address\n"
166 "Nexthop interface name\n")
167
168DEFUN (no_ip_mroute_dist,
169 no_ip_mroute_dist_cmd,
170 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300171 IP_STR
172 "Configure static unicast route into MRIB for multicast RPF lookup\n"
173 "IP destination prefix (e.g. 10.0.0.0/8)\n"
174 "Nexthop address\n"
175 "Nexthop interface name\n"
176 "Distance\n")
177{
David Lampartera76681b2015-01-22 19:03:53 +0100178 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
179 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300180}
181
David Lampartera76681b2015-01-22 19:03:53 +0100182ALIAS (no_ip_mroute_dist,
183 no_ip_mroute_cmd,
184 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
185 NO_STR
186 IP_STR
187 "Configure static unicast route into MRIB for multicast RPF lookup\n"
188 "IP destination prefix (e.g. 10.0.0.0/8)\n"
189 "Nexthop address\n"
190 "Nexthop interface name\n")
191
David Lamparterbd078122015-01-06 19:53:24 +0100192DEFUN (ip_multicast_mode,
193 ip_multicast_mode_cmd,
194 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
195 IP_STR
196 "Multicast options\n"
197 "RPF lookup behavior\n"
198 "Lookup in unicast RIB only\n"
199 "Lookup in multicast RIB only\n"
200 "Try multicast RIB first, fall back to unicast RIB\n"
201 "Lookup both, use entry with lower distance\n"
202 "Lookup both, use entry with longer prefix\n")
203{
204 if (!strncmp (argv[0], "u", 1))
205 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
206 else if (!strncmp (argv[0], "mrib-o", 6))
207 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
208 else if (!strncmp (argv[0], "mrib-t", 6))
209 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
210 else if (!strncmp (argv[0], "low", 3))
211 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
212 else if (!strncmp (argv[0], "lon", 3))
213 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
214 else
215 {
216 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
217 return CMD_WARNING;
218 }
219
220 return CMD_SUCCESS;
221}
222
223DEFUN (no_ip_multicast_mode,
224 no_ip_multicast_mode_cmd,
225 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
226 NO_STR
227 IP_STR
228 "Multicast options\n"
229 "RPF lookup behavior\n"
230 "Lookup in unicast RIB only\n"
231 "Lookup in multicast RIB only\n"
232 "Try multicast RIB first, fall back to unicast RIB\n"
233 "Lookup both, use entry with lower distance\n"
234 "Lookup both, use entry with longer prefix\n")
235{
236 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
237 return CMD_SUCCESS;
238}
239
240ALIAS (no_ip_multicast_mode,
241 no_ip_multicast_mode_noarg_cmd,
242 "no ip multicast rpf-lookup-mode",
243 NO_STR
244 IP_STR
245 "Multicast options\n"
246 "RPF lookup behavior\n")
247
Everton Marques33d86db2014-07-14 11:19:00 -0300248DEFUN (show_ip_rpf,
249 show_ip_rpf_cmd,
250 "show ip rpf",
251 SHOW_STR
252 IP_STR
253 "Display RPF information for multicast source\n")
254{
255 return do_show_ip_route(vty, SAFI_MULTICAST);
256}
257
paul718e3742002-12-13 20:15:29 +0000258/* Static route configuration. */
259DEFUN (ip_route,
260 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000261 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000262 IP_STR
263 "Establish static routes\n"
264 "IP destination prefix (e.g. 10.0.0.0/8)\n"
265 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000266 "IP gateway interface name\n"
267 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000268{
269 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
270}
271
272DEFUN (ip_route_flags,
273 ip_route_flags_cmd,
274 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000275 IP_STR
276 "Establish static routes\n"
277 "IP destination prefix (e.g. 10.0.0.0/8)\n"
278 "IP gateway address\n"
279 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000280 "Emit an ICMP unreachable when matched\n"
281 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000282{
hasso81dfcaa2003-05-25 19:21:25 +0000283 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
paul718e3742002-12-13 20:15:29 +0000284}
285
hasso457ef552003-05-28 12:02:15 +0000286DEFUN (ip_route_flags2,
287 ip_route_flags2_cmd,
288 "ip route A.B.C.D/M (reject|blackhole)",
289 IP_STR
290 "Establish static routes\n"
291 "IP destination prefix (e.g. 10.0.0.0/8)\n"
292 "Emit an ICMP unreachable when matched\n"
293 "Silently discard pkts when matched\n")
294{
295 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
296}
297
paul718e3742002-12-13 20:15:29 +0000298/* Mask as A.B.C.D format. */
299DEFUN (ip_route_mask,
300 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000301 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000302 IP_STR
303 "Establish static routes\n"
304 "IP destination prefix\n"
305 "IP destination prefix mask\n"
306 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000307 "IP gateway interface name\n"
308 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000309{
310 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
311}
312
313DEFUN (ip_route_mask_flags,
314 ip_route_mask_flags_cmd,
315 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000316 IP_STR
317 "Establish static routes\n"
318 "IP destination prefix\n"
319 "IP destination prefix mask\n"
320 "IP gateway address\n"
321 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000322 "Emit an ICMP unreachable when matched\n"
323 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000324{
hasso81dfcaa2003-05-25 19:21:25 +0000325 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000326}
327
hasso457ef552003-05-28 12:02:15 +0000328DEFUN (ip_route_mask_flags2,
329 ip_route_mask_flags2_cmd,
330 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
331 IP_STR
332 "Establish static routes\n"
333 "IP destination prefix\n"
334 "IP destination prefix mask\n"
335 "Emit an ICMP unreachable when matched\n"
336 "Silently discard pkts when matched\n")
337{
338 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
339}
340
paul718e3742002-12-13 20:15:29 +0000341/* Distance option value. */
342DEFUN (ip_route_distance,
343 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000344 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000345 IP_STR
346 "Establish static routes\n"
347 "IP destination prefix (e.g. 10.0.0.0/8)\n"
348 "IP gateway address\n"
349 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000350 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000351 "Distance value for this route\n")
352{
hasso81dfcaa2003-05-25 19:21:25 +0000353 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
354}
355
356DEFUN (ip_route_flags_distance,
357 ip_route_flags_distance_cmd,
358 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
359 IP_STR
360 "Establish static routes\n"
361 "IP destination prefix (e.g. 10.0.0.0/8)\n"
362 "IP gateway address\n"
363 "IP gateway interface name\n"
364 "Emit an ICMP unreachable when matched\n"
365 "Silently discard pkts when matched\n"
366 "Distance value for this route\n")
367{
368 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000369}
370
hasso457ef552003-05-28 12:02:15 +0000371DEFUN (ip_route_flags_distance2,
372 ip_route_flags_distance2_cmd,
373 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
374 IP_STR
375 "Establish static routes\n"
376 "IP destination prefix (e.g. 10.0.0.0/8)\n"
377 "Emit an ICMP unreachable when matched\n"
378 "Silently discard pkts when matched\n"
379 "Distance value for this route\n")
380{
381 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
382}
383
paul718e3742002-12-13 20:15:29 +0000384DEFUN (ip_route_mask_distance,
385 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000386 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000387 IP_STR
388 "Establish static routes\n"
389 "IP destination prefix\n"
390 "IP destination prefix mask\n"
391 "IP gateway address\n"
392 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000393 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000394 "Distance value for this route\n")
395{
hasso81dfcaa2003-05-25 19:21:25 +0000396 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
397}
398
399DEFUN (ip_route_mask_flags_distance,
400 ip_route_mask_flags_distance_cmd,
401 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
402 IP_STR
403 "Establish static routes\n"
404 "IP destination prefix\n"
405 "IP destination prefix mask\n"
406 "IP gateway address\n"
407 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000408 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000409 "Silently discard pkts when matched\n"
410 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000411{
412 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000413}
414
hasso457ef552003-05-28 12:02:15 +0000415DEFUN (ip_route_mask_flags_distance2,
416 ip_route_mask_flags_distance2_cmd,
417 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
418 IP_STR
419 "Establish static routes\n"
420 "IP destination prefix\n"
421 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000422 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000423 "Silently discard pkts when matched\n"
424 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000425{
426 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
427}
428
paul718e3742002-12-13 20:15:29 +0000429DEFUN (no_ip_route,
430 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000431 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000432 NO_STR
433 IP_STR
434 "Establish static routes\n"
435 "IP destination prefix (e.g. 10.0.0.0/8)\n"
436 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000437 "IP gateway interface name\n"
438 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000439{
440 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
441}
442
443ALIAS (no_ip_route,
444 no_ip_route_flags_cmd,
445 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000446 NO_STR
447 IP_STR
448 "Establish static routes\n"
449 "IP destination prefix (e.g. 10.0.0.0/8)\n"
450 "IP gateway address\n"
451 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000452 "Emit an ICMP unreachable when matched\n"
453 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000454
hasso457ef552003-05-28 12:02:15 +0000455DEFUN (no_ip_route_flags2,
456 no_ip_route_flags2_cmd,
457 "no ip route A.B.C.D/M (reject|blackhole)",
458 NO_STR
459 IP_STR
460 "Establish static routes\n"
461 "IP destination prefix (e.g. 10.0.0.0/8)\n"
462 "Emit an ICMP unreachable when matched\n"
463 "Silently discard pkts when matched\n")
464{
465 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
466}
467
paul718e3742002-12-13 20:15:29 +0000468DEFUN (no_ip_route_mask,
469 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000470 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000471 NO_STR
472 IP_STR
473 "Establish static routes\n"
474 "IP destination prefix\n"
475 "IP destination prefix mask\n"
476 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000477 "IP gateway interface name\n"
478 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000479{
480 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
481}
482
483ALIAS (no_ip_route_mask,
484 no_ip_route_mask_flags_cmd,
485 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000486 NO_STR
487 IP_STR
488 "Establish static routes\n"
489 "IP destination prefix\n"
490 "IP destination prefix mask\n"
491 "IP gateway address\n"
492 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000493 "Emit an ICMP unreachable when matched\n"
494 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000495
hasso457ef552003-05-28 12:02:15 +0000496DEFUN (no_ip_route_mask_flags2,
497 no_ip_route_mask_flags2_cmd,
498 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
499 NO_STR
500 IP_STR
501 "Establish static routes\n"
502 "IP destination prefix\n"
503 "IP destination prefix mask\n"
504 "Emit an ICMP unreachable when matched\n"
505 "Silently discard pkts when matched\n")
506{
507 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
508}
509
paul718e3742002-12-13 20:15:29 +0000510DEFUN (no_ip_route_distance,
511 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000512 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000513 NO_STR
514 IP_STR
515 "Establish static routes\n"
516 "IP destination prefix (e.g. 10.0.0.0/8)\n"
517 "IP gateway address\n"
518 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000519 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000520 "Distance value for this route\n")
521{
hasso81dfcaa2003-05-25 19:21:25 +0000522 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
523}
524
525DEFUN (no_ip_route_flags_distance,
526 no_ip_route_flags_distance_cmd,
527 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
528 NO_STR
529 IP_STR
530 "Establish static routes\n"
531 "IP destination prefix (e.g. 10.0.0.0/8)\n"
532 "IP gateway address\n"
533 "IP gateway interface name\n"
534 "Emit an ICMP unreachable when matched\n"
535 "Silently discard pkts when matched\n"
536 "Distance value for this route\n")
537{
538 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000539}
540
hasso457ef552003-05-28 12:02:15 +0000541DEFUN (no_ip_route_flags_distance2,
542 no_ip_route_flags_distance2_cmd,
543 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
544 NO_STR
545 IP_STR
546 "Establish static routes\n"
547 "IP destination prefix (e.g. 10.0.0.0/8)\n"
548 "Emit an ICMP unreachable when matched\n"
549 "Silently discard pkts when matched\n"
550 "Distance value for this route\n")
551{
552 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
553}
554
paul718e3742002-12-13 20:15:29 +0000555DEFUN (no_ip_route_mask_distance,
556 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000557 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000558 NO_STR
559 IP_STR
560 "Establish static routes\n"
561 "IP destination prefix\n"
562 "IP destination prefix mask\n"
563 "IP gateway address\n"
564 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000565 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000566 "Distance value for this route\n")
567{
hasso81dfcaa2003-05-25 19:21:25 +0000568 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
569}
570
571DEFUN (no_ip_route_mask_flags_distance,
572 no_ip_route_mask_flags_distance_cmd,
573 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
574 NO_STR
575 IP_STR
576 "Establish static routes\n"
577 "IP destination prefix\n"
578 "IP destination prefix mask\n"
579 "IP gateway address\n"
580 "IP gateway interface name\n"
581 "Emit an ICMP unreachable when matched\n"
582 "Silently discard pkts when matched\n"
583 "Distance value for this route\n")
584{
585 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000586}
587
hasso457ef552003-05-28 12:02:15 +0000588DEFUN (no_ip_route_mask_flags_distance2,
589 no_ip_route_mask_flags_distance2_cmd,
590 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
591 NO_STR
592 IP_STR
593 "Establish static routes\n"
594 "IP destination prefix\n"
595 "IP destination prefix mask\n"
596 "Emit an ICMP unreachable when matched\n"
597 "Silently discard pkts when matched\n"
598 "Distance value for this route\n")
599{
600 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
601}
602
Paul Jakma7514fb72007-05-02 16:05:35 +0000603char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
604
605DEFUN (ip_protocol,
606 ip_protocol_cmd,
607 "ip protocol PROTO route-map ROUTE-MAP",
608 NO_STR
609 "Apply route map to PROTO\n"
610 "Protocol name\n"
611 "Route map name\n")
612{
613 int i;
614
615 if (strcasecmp(argv[0], "any") == 0)
616 i = ZEBRA_ROUTE_MAX;
617 else
618 i = proto_name2num(argv[0]);
619 if (i < 0)
620 {
621 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
622 VTY_NEWLINE);
623 return CMD_WARNING;
624 }
625 if (proto_rm[AFI_IP][i])
626 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
627 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
628 return CMD_SUCCESS;
629}
630
631DEFUN (no_ip_protocol,
632 no_ip_protocol_cmd,
633 "no ip protocol PROTO",
634 NO_STR
635 "Remove route map from PROTO\n"
636 "Protocol name\n")
637{
638 int i;
639
640 if (strcasecmp(argv[0], "any") == 0)
641 i = ZEBRA_ROUTE_MAX;
642 else
643 i = proto_name2num(argv[0]);
644 if (i < 0)
645 {
646 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
647 VTY_NEWLINE);
648 return CMD_WARNING;
649 }
650 if (proto_rm[AFI_IP][i])
651 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
652 proto_rm[AFI_IP][i] = NULL;
653 return CMD_SUCCESS;
654}
655
paul718e3742002-12-13 20:15:29 +0000656/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +0000657static void
paul718e3742002-12-13 20:15:29 +0000658vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
659{
660 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +0000661 struct nexthop *nexthop, *tnexthop;
662 int recursing;
paul718e3742002-12-13 20:15:29 +0000663
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000664 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000665 {
666 vty_out (vty, "Routing entry for %s/%d%s",
667 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
668 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +0000669 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +0200670 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +0000671 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
672 vty_out (vty, ", best");
673 if (rib->refcnt)
674 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +0000675 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
676 vty_out (vty, ", blackhole");
677 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
678 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +0000679 vty_out (vty, "%s", VTY_NEWLINE);
680
681#define ONE_DAY_SECOND 60*60*24
682#define ONE_WEEK_SECOND 60*60*24*7
683 if (rib->type == ZEBRA_ROUTE_RIP
684 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100685 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000686 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000687 || rib->type == ZEBRA_ROUTE_BGP)
688 {
689 time_t uptime;
690 struct tm *tm;
691
692 uptime = time (NULL);
693 uptime -= rib->uptime;
694 tm = gmtime (&uptime);
695
696 vty_out (vty, " Last update ");
697
698 if (uptime < ONE_DAY_SECOND)
699 vty_out (vty, "%02d:%02d:%02d",
700 tm->tm_hour, tm->tm_min, tm->tm_sec);
701 else if (uptime < ONE_WEEK_SECOND)
702 vty_out (vty, "%dd%02dh%02dm",
703 tm->tm_yday, tm->tm_hour, tm->tm_min);
704 else
705 vty_out (vty, "%02dw%dd%02dh",
706 tm->tm_yday/7,
707 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
708 vty_out (vty, " ago%s", VTY_NEWLINE);
709 }
710
Christian Frankefa713d92013-07-05 15:35:37 +0000711 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000712 {
Paul Jakma7514fb72007-05-02 16:05:35 +0000713 char addrstr[32];
714
Christian Frankefa713d92013-07-05 15:35:37 +0000715 vty_out (vty, " %c%s",
716 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
717 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +0000718
719 switch (nexthop->type)
720 {
721 case NEXTHOP_TYPE_IPV4:
722 case NEXTHOP_TYPE_IPV4_IFINDEX:
723 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
724 if (nexthop->ifindex)
725 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
726 break;
727 case NEXTHOP_TYPE_IFINDEX:
728 vty_out (vty, " directly connected, %s",
729 ifindex2ifname (nexthop->ifindex));
730 break;
731 case NEXTHOP_TYPE_IFNAME:
732 vty_out (vty, " directly connected, %s", nexthop->ifname);
733 break;
paul595db7f2003-05-25 21:35:06 +0000734 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000735 vty_out (vty, " directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000736 break;
paul7021c422003-07-15 12:52:22 +0000737 default:
paul718e3742002-12-13 20:15:29 +0000738 break;
739 }
740 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
741 vty_out (vty, " inactive");
742
Christian Frankee8d3d292013-07-05 15:35:39 +0000743 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
744 vty_out (vty, " onlink");
745
paul718e3742002-12-13 20:15:29 +0000746 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000747 vty_out (vty, " (recursive)");
Christian Franke5b9f5182013-05-25 14:01:34 +0000748
Paul Jakma7514fb72007-05-02 16:05:35 +0000749 switch (nexthop->type)
750 {
751 case NEXTHOP_TYPE_IPV4:
752 case NEXTHOP_TYPE_IPV4_IFINDEX:
753 case NEXTHOP_TYPE_IPV4_IFNAME:
754 if (nexthop->src.ipv4.s_addr)
755 {
756 if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
757 sizeof addrstr))
758 vty_out (vty, ", src %s", addrstr);
759 }
760 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000761#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000762 case NEXTHOP_TYPE_IPV6:
763 case NEXTHOP_TYPE_IPV6_IFINDEX:
764 case NEXTHOP_TYPE_IPV6_IFNAME:
765 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
766 {
767 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
768 sizeof addrstr))
769 vty_out (vty, ", src %s", addrstr);
770 }
771 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000772#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000773 default:
774 break;
775 }
paul718e3742002-12-13 20:15:29 +0000776 vty_out (vty, "%s", VTY_NEWLINE);
777 }
778 vty_out (vty, "%s", VTY_NEWLINE);
779 }
780}
781
paula1ac18c2005-06-28 17:17:12 +0000782static void
paul718e3742002-12-13 20:15:29 +0000783vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
784{
Christian Frankefa713d92013-07-05 15:35:37 +0000785 struct nexthop *nexthop, *tnexthop;
786 int recursing;
paul718e3742002-12-13 20:15:29 +0000787 int len = 0;
788 char buf[BUFSIZ];
789
790 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +0000791 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000792 {
793 if (nexthop == rib->nexthop)
794 {
795 /* Prefix information. */
796 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +0000797 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +0000798 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
799 ? '>' : ' ',
800 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
801 ? '*' : ' ',
802 inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ),
803 rn->p.prefixlen);
804
805 /* Distance and metric display. */
806 if (rib->type != ZEBRA_ROUTE_CONNECT
807 && rib->type != ZEBRA_ROUTE_KERNEL)
808 len += vty_out (vty, " [%d/%d]", rib->distance,
809 rib->metric);
810 }
811 else
812 vty_out (vty, " %c%*c",
813 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
814 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +0000815 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +0000816
817 switch (nexthop->type)
818 {
819 case NEXTHOP_TYPE_IPV4:
820 case NEXTHOP_TYPE_IPV4_IFINDEX:
821 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
822 if (nexthop->ifindex)
823 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
824 break;
825 case NEXTHOP_TYPE_IFINDEX:
826 vty_out (vty, " is directly connected, %s",
827 ifindex2ifname (nexthop->ifindex));
828 break;
829 case NEXTHOP_TYPE_IFNAME:
830 vty_out (vty, " is directly connected, %s", nexthop->ifname);
831 break;
paul595db7f2003-05-25 21:35:06 +0000832 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000833 vty_out (vty, " is directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000834 break;
paul7021c422003-07-15 12:52:22 +0000835 default:
paul718e3742002-12-13 20:15:29 +0000836 break;
837 }
838 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
839 vty_out (vty, " inactive");
840
Christian Frankee8d3d292013-07-05 15:35:39 +0000841 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
842 vty_out (vty, " onlink");
843
paul718e3742002-12-13 20:15:29 +0000844 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000845 vty_out (vty, " (recursive)");
846
Paul Jakma7514fb72007-05-02 16:05:35 +0000847 switch (nexthop->type)
848 {
849 case NEXTHOP_TYPE_IPV4:
850 case NEXTHOP_TYPE_IPV4_IFINDEX:
851 case NEXTHOP_TYPE_IPV4_IFNAME:
852 if (nexthop->src.ipv4.s_addr)
853 {
854 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
855 vty_out (vty, ", src %s", buf);
856 }
857 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000858#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000859 case NEXTHOP_TYPE_IPV6:
860 case NEXTHOP_TYPE_IPV6_IFINDEX:
861 case NEXTHOP_TYPE_IPV6_IFNAME:
862 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
863 {
864 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
865 vty_out (vty, ", src %s", buf);
866 }
867 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000868#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000869 default:
870 break;
871 }
paul718e3742002-12-13 20:15:29 +0000872
hasso81dfcaa2003-05-25 19:21:25 +0000873 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
874 vty_out (vty, ", bh");
875 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
876 vty_out (vty, ", rej");
877
paul718e3742002-12-13 20:15:29 +0000878 if (rib->type == ZEBRA_ROUTE_RIP
879 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100880 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000881 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000882 || rib->type == ZEBRA_ROUTE_BGP)
883 {
884 time_t uptime;
885 struct tm *tm;
886
887 uptime = time (NULL);
888 uptime -= rib->uptime;
889 tm = gmtime (&uptime);
890
891#define ONE_DAY_SECOND 60*60*24
892#define ONE_WEEK_SECOND 60*60*24*7
893
894 if (uptime < ONE_DAY_SECOND)
895 vty_out (vty, ", %02d:%02d:%02d",
896 tm->tm_hour, tm->tm_min, tm->tm_sec);
897 else if (uptime < ONE_WEEK_SECOND)
898 vty_out (vty, ", %dd%02dh%02dm",
899 tm->tm_yday, tm->tm_hour, tm->tm_min);
900 else
901 vty_out (vty, ", %02dw%dd%02dh",
902 tm->tm_yday/7,
903 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
904 }
905 vty_out (vty, "%s", VTY_NEWLINE);
906 }
907}
908
paul718e3742002-12-13 20:15:29 +0000909DEFUN (show_ip_route,
910 show_ip_route_cmd,
911 "show ip route",
912 SHOW_STR
913 IP_STR
914 "IP routing table\n")
915{
Everton Marques33d86db2014-07-14 11:19:00 -0300916 return do_show_ip_route(vty, SAFI_UNICAST);
917}
918
919static int do_show_ip_route(struct vty *vty, safi_t safi) {
paul718e3742002-12-13 20:15:29 +0000920 struct route_table *table;
921 struct route_node *rn;
922 struct rib *rib;
923 int first = 1;
924
Everton Marques33d86db2014-07-14 11:19:00 -0300925 table = vrf_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +0000926 if (! table)
927 return CMD_SUCCESS;
928
929 /* Show all IPv4 routes. */
930 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000931 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000932 {
933 if (first)
934 {
David Lampartere0ca5fd2009-09-16 01:52:42 +0200935 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +0000936 first = 0;
937 }
938 vty_show_ip_route (vty, rn, rib);
939 }
940 return CMD_SUCCESS;
941}
942
943DEFUN (show_ip_route_prefix_longer,
944 show_ip_route_prefix_longer_cmd,
945 "show ip route A.B.C.D/M longer-prefixes",
946 SHOW_STR
947 IP_STR
948 "IP routing table\n"
949 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
950 "Show route matching the specified Network/Mask pair only\n")
951{
952 struct route_table *table;
953 struct route_node *rn;
954 struct rib *rib;
955 struct prefix p;
956 int ret;
957 int first = 1;
958
959 ret = str2prefix (argv[0], &p);
960 if (! ret)
961 {
962 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
963 return CMD_WARNING;
964 }
965
966 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
967 if (! table)
968 return CMD_SUCCESS;
969
970 /* Show matched type IPv4 routes. */
971 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000972 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000973 if (prefix_match (&p, &rn->p))
974 {
975 if (first)
976 {
David Lampartere0ca5fd2009-09-16 01:52:42 +0200977 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +0000978 first = 0;
979 }
980 vty_show_ip_route (vty, rn, rib);
981 }
982 return CMD_SUCCESS;
983}
984
985DEFUN (show_ip_route_supernets,
986 show_ip_route_supernets_cmd,
987 "show ip route supernets-only",
988 SHOW_STR
989 IP_STR
990 "IP routing table\n"
991 "Show supernet entries only\n")
992{
993 struct route_table *table;
994 struct route_node *rn;
995 struct rib *rib;
996 u_int32_t addr;
997 int first = 1;
998
999 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1000 if (! table)
1001 return CMD_SUCCESS;
1002
1003 /* Show matched type IPv4 routes. */
1004 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001005 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001006 {
1007 addr = ntohl (rn->p.u.prefix4.s_addr);
1008
1009 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1010 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
1011 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
1012 {
1013 if (first)
1014 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001015 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001016 first = 0;
1017 }
1018 vty_show_ip_route (vty, rn, rib);
1019 }
1020 }
1021 return CMD_SUCCESS;
1022}
1023
1024DEFUN (show_ip_route_protocol,
1025 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001026 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001027 SHOW_STR
1028 IP_STR
1029 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001030 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001031{
1032 int type;
1033 struct route_table *table;
1034 struct route_node *rn;
1035 struct rib *rib;
1036 int first = 1;
1037
David Lampartere0ca5fd2009-09-16 01:52:42 +02001038 type = proto_redistnum (AFI_IP, argv[0]);
1039 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001040 {
1041 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1042 return CMD_WARNING;
1043 }
1044
1045 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1046 if (! table)
1047 return CMD_SUCCESS;
1048
1049 /* Show matched type IPv4 routes. */
1050 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001051 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001052 if (rib->type == type)
1053 {
1054 if (first)
1055 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001056 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001057 first = 0;
1058 }
1059 vty_show_ip_route (vty, rn, rib);
1060 }
1061 return CMD_SUCCESS;
1062}
1063
1064DEFUN (show_ip_route_addr,
1065 show_ip_route_addr_cmd,
1066 "show ip route A.B.C.D",
1067 SHOW_STR
1068 IP_STR
1069 "IP routing table\n"
1070 "Network in the IP routing table to display\n")
1071{
1072 int ret;
1073 struct prefix_ipv4 p;
1074 struct route_table *table;
1075 struct route_node *rn;
1076
1077 ret = str2prefix_ipv4 (argv[0], &p);
1078 if (ret <= 0)
1079 {
1080 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1081 return CMD_WARNING;
1082 }
1083
1084 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1085 if (! table)
1086 return CMD_SUCCESS;
1087
1088 rn = route_node_match (table, (struct prefix *) &p);
1089 if (! rn)
1090 {
1091 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1092 return CMD_WARNING;
1093 }
1094
1095 vty_show_ip_route_detail (vty, rn);
1096
1097 route_unlock_node (rn);
1098
1099 return CMD_SUCCESS;
1100}
1101
1102DEFUN (show_ip_route_prefix,
1103 show_ip_route_prefix_cmd,
1104 "show ip route A.B.C.D/M",
1105 SHOW_STR
1106 IP_STR
1107 "IP routing table\n"
1108 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1109{
1110 int ret;
1111 struct prefix_ipv4 p;
1112 struct route_table *table;
1113 struct route_node *rn;
1114
1115 ret = str2prefix_ipv4 (argv[0], &p);
1116 if (ret <= 0)
1117 {
1118 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1119 return CMD_WARNING;
1120 }
1121
1122 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1123 if (! table)
1124 return CMD_SUCCESS;
1125
1126 rn = route_node_match (table, (struct prefix *) &p);
1127 if (! rn || rn->p.prefixlen != p.prefixlen)
1128 {
1129 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001130 if (rn)
1131 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001132 return CMD_WARNING;
1133 }
1134
1135 vty_show_ip_route_detail (vty, rn);
1136
1137 route_unlock_node (rn);
1138
1139 return CMD_SUCCESS;
1140}
1141
paula1ac18c2005-06-28 17:17:12 +00001142static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001143vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001144{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001145 struct route_node *rn;
1146 struct rib *rib;
1147 struct nexthop *nexthop;
1148#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1149#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1150 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1151 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1152 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001153
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001154 memset (&rib_cnt, 0, sizeof(rib_cnt));
1155 memset (&fib_cnt, 0, sizeof(fib_cnt));
1156 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001157 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001158 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1159 {
1160 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1161 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001162 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1163 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001164 {
1165 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1166 fib_cnt[rib->type]++;
1167 }
1168 if (rib->type == ZEBRA_ROUTE_BGP &&
1169 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1170 {
1171 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001172 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1173 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001174 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1175 }
1176 }
paul718e3742002-12-13 20:15:29 +00001177
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001178 vty_out (vty, "%-20s %-20s %-20s %s",
1179 "Route Source", "Routes", "FIB", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001180
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001181 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1182 {
1183 if (rib_cnt[i] > 0)
1184 {
1185 if (i == ZEBRA_ROUTE_BGP)
1186 {
1187 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1188 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1189 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1190 VTY_NEWLINE);
1191 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1192 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1193 VTY_NEWLINE);
1194 }
1195 else
1196 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1197 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1198 }
1199 }
paul718e3742002-12-13 20:15:29 +00001200
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001201 vty_out (vty, "------%s", VTY_NEWLINE);
1202 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1203 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001204}
1205
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001206/*
1207 * Implementation of the ip route summary prefix command.
1208 *
1209 * This command prints the primary prefixes that have been installed by various
1210 * protocols on the box.
1211 *
1212 */
1213static void
1214vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1215{
1216 struct route_node *rn;
1217 struct rib *rib;
1218 struct nexthop *nexthop;
1219#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1220#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1221 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1222 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1223 u_int32_t i;
1224 int cnt;
1225
1226 memset (&rib_cnt, 0, sizeof(rib_cnt));
1227 memset (&fib_cnt, 0, sizeof(fib_cnt));
1228 for (rn = route_top (table); rn; rn = route_next (rn))
1229 RNODE_FOREACH_RIB (rn, rib)
1230 {
1231
1232 /*
1233 * In case of ECMP, count only once.
1234 */
1235 cnt = 0;
1236 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1237 {
1238 cnt++;
1239 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1240 rib_cnt[rib->type]++;
1241 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1242 {
1243 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1244 fib_cnt[rib->type]++;
1245 }
1246 if (rib->type == ZEBRA_ROUTE_BGP &&
1247 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1248 {
1249 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1250 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1251 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1252 }
1253 }
1254 }
1255
1256 vty_out (vty, "%-20s %-20s %-20s %s",
1257 "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
1258
1259 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1260 {
1261 if (rib_cnt[i] > 0)
1262 {
1263 if (i == ZEBRA_ROUTE_BGP)
1264 {
1265 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1266 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1267 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1268 VTY_NEWLINE);
1269 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1270 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1271 VTY_NEWLINE);
1272 }
1273 else
1274 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1275 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1276 }
1277 }
1278
1279 vty_out (vty, "------%s", VTY_NEWLINE);
1280 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1281 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
1282}
1283
paul718e3742002-12-13 20:15:29 +00001284/* Show route summary. */
1285DEFUN (show_ip_route_summary,
1286 show_ip_route_summary_cmd,
1287 "show ip route summary",
1288 SHOW_STR
1289 IP_STR
1290 "IP routing table\n"
1291 "Summary of all routes\n")
1292{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001293 struct route_table *table;
paul718e3742002-12-13 20:15:29 +00001294
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001295 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1296 if (! table)
1297 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001298
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001299 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00001300
1301 return CMD_SUCCESS;
1302}
1303
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001304/* Show route summary prefix. */
1305DEFUN (show_ip_route_summary_prefix,
1306 show_ip_route_summary_prefix_cmd,
1307 "show ip route summary prefix",
1308 SHOW_STR
1309 IP_STR
1310 "IP routing table\n"
1311 "Summary of all routes\n"
1312 "Prefix routes\n")
1313{
1314 struct route_table *table;
1315
1316 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1317 if (! table)
1318 return CMD_SUCCESS;
1319
1320 vty_show_ip_route_summary_prefix (vty, table);
1321
1322 return CMD_SUCCESS;
1323}
1324
paul718e3742002-12-13 20:15:29 +00001325/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00001326static int
Everton Marques33d86db2014-07-14 11:19:00 -03001327static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00001328{
1329 struct route_node *rn;
1330 struct static_ipv4 *si;
1331 struct route_table *stable;
1332 int write;
1333
1334 write = 0;
1335
1336 /* Lookup table. */
Everton Marques33d86db2014-07-14 11:19:00 -03001337 stable = vrf_static_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +00001338 if (! stable)
1339 return -1;
1340
1341 for (rn = route_top (stable); rn; rn = route_next (rn))
1342 for (si = rn->info; si; si = si->next)
1343 {
Everton Marques33d86db2014-07-14 11:19:00 -03001344 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
paul7021c422003-07-15 12:52:22 +00001345 rn->p.prefixlen);
paul718e3742002-12-13 20:15:29 +00001346
paul7021c422003-07-15 12:52:22 +00001347 switch (si->type)
1348 {
1349 case STATIC_IPV4_GATEWAY:
1350 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
1351 break;
1352 case STATIC_IPV4_IFNAME:
1353 vty_out (vty, " %s", si->gate.ifname);
1354 break;
1355 case STATIC_IPV4_BLACKHOLE:
1356 vty_out (vty, " Null0");
1357 break;
1358 }
1359
1360 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
1361 if (si->type != STATIC_IPV4_BLACKHOLE)
1362 {
1363 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
1364 vty_out (vty, " %s", "reject");
paul718e3742002-12-13 20:15:29 +00001365
paul7021c422003-07-15 12:52:22 +00001366 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
1367 vty_out (vty, " %s", "blackhole");
1368 }
hasso81dfcaa2003-05-25 19:21:25 +00001369
paul7021c422003-07-15 12:52:22 +00001370 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
1371 vty_out (vty, " %d", si->distance);
hasso81dfcaa2003-05-25 19:21:25 +00001372
paul7021c422003-07-15 12:52:22 +00001373 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001374
paul7021c422003-07-15 12:52:22 +00001375 write = 1;
paul718e3742002-12-13 20:15:29 +00001376 }
1377 return write;
1378}
Andrew J. Schorr09303312007-05-30 20:10:34 +00001379
1380DEFUN (show_ip_protocol,
1381 show_ip_protocol_cmd,
1382 "show ip protocol",
1383 SHOW_STR
1384 IP_STR
1385 "IP protocol filtering status\n")
1386{
1387 int i;
1388
1389 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
1390 vty_out(vty, "------------------------%s", VTY_NEWLINE);
1391 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
1392 {
1393 if (proto_rm[AFI_IP][i])
1394 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
1395 proto_rm[AFI_IP][i],
1396 VTY_NEWLINE);
1397 else
1398 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
1399 }
1400 if (proto_rm[AFI_IP][i])
1401 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
1402 VTY_NEWLINE);
1403 else
1404 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
1405
1406 return CMD_SUCCESS;
1407}
1408
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001409/*
1410 * Show IP mroute command to dump the BGP Multicast
1411 * routing table
1412 */
1413DEFUN (show_ip_mroute,
1414 show_ip_mroute_cmd,
1415 "show ip mroute",
1416 SHOW_STR
1417 IP_STR
1418 "IP Multicast routing table\n")
1419{
1420 struct route_table *table;
1421 struct route_node *rn;
1422 struct rib *rib;
1423 int first = 1;
1424
1425 table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
1426 if (! table)
1427 return CMD_SUCCESS;
1428
1429 /* Show all IPv4 routes. */
1430 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001431 RNODE_FOREACH_RIB (rn, rib)
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001432 {
1433 if (first)
1434 {
1435 vty_out (vty, SHOW_ROUTE_V4_HEADER);
1436 first = 0;
1437 }
1438 vty_show_ip_route (vty, rn, rib);
1439 }
1440 return CMD_SUCCESS;
1441}
1442
David Lamparter6b0655a2014-06-04 06:53:35 +02001443
paul718e3742002-12-13 20:15:29 +00001444#ifdef HAVE_IPV6
1445/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00001446static int
hasso39db97e2004-10-12 20:50:58 +00001447static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
1448 const char *gate_str, const char *ifname,
1449 const char *flag_str, const char *distance_str)
paul718e3742002-12-13 20:15:29 +00001450{
1451 int ret;
1452 u_char distance;
1453 struct prefix p;
1454 struct in6_addr *gate = NULL;
1455 struct in6_addr gate_addr;
1456 u_char type = 0;
1457 int table = 0;
hasso81dfcaa2003-05-25 19:21:25 +00001458 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00001459
1460 ret = str2prefix (dest_str, &p);
1461 if (ret <= 0)
1462 {
1463 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1464 return CMD_WARNING;
1465 }
1466
1467 /* Apply mask for given prefix. */
1468 apply_mask (&p);
1469
hasso81dfcaa2003-05-25 19:21:25 +00001470 /* Route flags */
1471 if (flag_str) {
1472 switch(flag_str[0]) {
1473 case 'r':
1474 case 'R': /* XXX */
1475 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
1476 break;
1477 case 'b':
1478 case 'B': /* XXX */
1479 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
1480 break;
1481 default:
1482 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00001483 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00001484 }
1485 }
1486
paul718e3742002-12-13 20:15:29 +00001487 /* Administrative distance. */
1488 if (distance_str)
1489 distance = atoi (distance_str);
1490 else
1491 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
1492
1493 /* When gateway is valid IPv6 addrees, then gate is treated as
1494 nexthop address other case gate is treated as interface name. */
1495 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
1496
1497 if (ifname)
1498 {
1499 /* When ifname is specified. It must be come with gateway
1500 address. */
1501 if (ret != 1)
1502 {
1503 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1504 return CMD_WARNING;
1505 }
1506 type = STATIC_IPV6_GATEWAY_IFNAME;
1507 gate = &gate_addr;
1508 }
1509 else
1510 {
1511 if (ret == 1)
1512 {
1513 type = STATIC_IPV6_GATEWAY;
1514 gate = &gate_addr;
1515 }
1516 else
1517 {
1518 type = STATIC_IPV6_IFNAME;
1519 ifname = gate_str;
1520 }
1521 }
1522
1523 if (add_cmd)
hasso81dfcaa2003-05-25 19:21:25 +00001524 static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
paul718e3742002-12-13 20:15:29 +00001525 else
1526 static_delete_ipv6 (&p, type, gate, ifname, distance, table);
1527
1528 return CMD_SUCCESS;
1529}
1530
1531DEFUN (ipv6_route,
1532 ipv6_route_cmd,
1533 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1534 IP_STR
1535 "Establish static routes\n"
1536 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1537 "IPv6 gateway address\n"
1538 "IPv6 gateway interface name\n")
1539{
hasso81dfcaa2003-05-25 19:21:25 +00001540 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
1541}
1542
1543DEFUN (ipv6_route_flags,
1544 ipv6_route_flags_cmd,
1545 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1546 IP_STR
1547 "Establish static routes\n"
1548 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1549 "IPv6 gateway address\n"
1550 "IPv6 gateway interface name\n"
1551 "Emit an ICMP unreachable when matched\n"
1552 "Silently discard pkts when matched\n")
1553{
1554 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
paul718e3742002-12-13 20:15:29 +00001555}
1556
1557DEFUN (ipv6_route_ifname,
1558 ipv6_route_ifname_cmd,
1559 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1560 IP_STR
1561 "Establish static routes\n"
1562 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1563 "IPv6 gateway address\n"
1564 "IPv6 gateway interface name\n")
1565{
hasso81dfcaa2003-05-25 19:21:25 +00001566 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
1567}
1568
1569DEFUN (ipv6_route_ifname_flags,
1570 ipv6_route_ifname_flags_cmd,
1571 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1572 IP_STR
1573 "Establish static routes\n"
1574 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1575 "IPv6 gateway address\n"
1576 "IPv6 gateway interface name\n"
1577 "Emit an ICMP unreachable when matched\n"
1578 "Silently discard pkts when matched\n")
1579{
1580 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +00001581}
1582
1583DEFUN (ipv6_route_pref,
1584 ipv6_route_pref_cmd,
1585 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1586 IP_STR
1587 "Establish static routes\n"
1588 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1589 "IPv6 gateway address\n"
1590 "IPv6 gateway interface name\n"
1591 "Distance value for this prefix\n")
1592{
hasso81dfcaa2003-05-25 19:21:25 +00001593 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
1594}
1595
1596DEFUN (ipv6_route_flags_pref,
1597 ipv6_route_flags_pref_cmd,
1598 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1599 IP_STR
1600 "Establish static routes\n"
1601 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1602 "IPv6 gateway address\n"
1603 "IPv6 gateway interface name\n"
1604 "Emit an ICMP unreachable when matched\n"
1605 "Silently discard pkts when matched\n"
1606 "Distance value for this prefix\n")
1607{
1608 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001609}
1610
1611DEFUN (ipv6_route_ifname_pref,
1612 ipv6_route_ifname_pref_cmd,
1613 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1614 IP_STR
1615 "Establish static routes\n"
1616 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1617 "IPv6 gateway address\n"
1618 "IPv6 gateway interface name\n"
1619 "Distance value for this prefix\n")
1620{
hasso81dfcaa2003-05-25 19:21:25 +00001621 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
1622}
1623
1624DEFUN (ipv6_route_ifname_flags_pref,
1625 ipv6_route_ifname_flags_pref_cmd,
1626 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1627 IP_STR
1628 "Establish static routes\n"
1629 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1630 "IPv6 gateway address\n"
1631 "IPv6 gateway interface name\n"
1632 "Emit an ICMP unreachable when matched\n"
1633 "Silently discard pkts when matched\n"
1634 "Distance value for this prefix\n")
1635{
1636 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001637}
1638
1639DEFUN (no_ipv6_route,
1640 no_ipv6_route_cmd,
1641 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1642 NO_STR
1643 IP_STR
1644 "Establish static routes\n"
1645 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1646 "IPv6 gateway address\n"
1647 "IPv6 gateway interface name\n")
1648{
hasso81dfcaa2003-05-25 19:21:25 +00001649 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001650}
1651
hasso81dfcaa2003-05-25 19:21:25 +00001652ALIAS (no_ipv6_route,
1653 no_ipv6_route_flags_cmd,
1654 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1655 NO_STR
1656 IP_STR
1657 "Establish static routes\n"
1658 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1659 "IPv6 gateway address\n"
1660 "IPv6 gateway interface name\n"
1661 "Emit an ICMP unreachable when matched\n"
1662 "Silently discard pkts when matched\n")
1663
paul718e3742002-12-13 20:15:29 +00001664DEFUN (no_ipv6_route_ifname,
1665 no_ipv6_route_ifname_cmd,
1666 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1667 NO_STR
1668 IP_STR
1669 "Establish static routes\n"
1670 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1671 "IPv6 gateway address\n"
1672 "IPv6 gateway interface name\n")
1673{
hasso81dfcaa2003-05-25 19:21:25 +00001674 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001675}
1676
hasso81dfcaa2003-05-25 19:21:25 +00001677ALIAS (no_ipv6_route_ifname,
1678 no_ipv6_route_ifname_flags_cmd,
1679 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1680 NO_STR
1681 IP_STR
1682 "Establish static routes\n"
1683 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1684 "IPv6 gateway address\n"
1685 "IPv6 gateway interface name\n"
1686 "Emit an ICMP unreachable when matched\n"
1687 "Silently discard pkts when matched\n")
1688
paul718e3742002-12-13 20:15:29 +00001689DEFUN (no_ipv6_route_pref,
1690 no_ipv6_route_pref_cmd,
1691 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1692 NO_STR
1693 IP_STR
1694 "Establish static routes\n"
1695 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1696 "IPv6 gateway address\n"
1697 "IPv6 gateway interface name\n"
1698 "Distance value for this prefix\n")
1699{
hasso81dfcaa2003-05-25 19:21:25 +00001700 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
1701}
1702
1703DEFUN (no_ipv6_route_flags_pref,
1704 no_ipv6_route_flags_pref_cmd,
1705 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1706 NO_STR
1707 IP_STR
1708 "Establish static routes\n"
1709 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1710 "IPv6 gateway address\n"
1711 "IPv6 gateway interface name\n"
1712 "Emit an ICMP unreachable when matched\n"
1713 "Silently discard pkts when matched\n"
1714 "Distance value for this prefix\n")
1715{
1716 /* We do not care about argv[2] */
1717 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001718}
1719
1720DEFUN (no_ipv6_route_ifname_pref,
1721 no_ipv6_route_ifname_pref_cmd,
1722 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1723 NO_STR
1724 IP_STR
1725 "Establish static routes\n"
1726 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1727 "IPv6 gateway address\n"
1728 "IPv6 gateway interface name\n"
1729 "Distance value for this prefix\n")
1730{
hasso81dfcaa2003-05-25 19:21:25 +00001731 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
1732}
1733
1734DEFUN (no_ipv6_route_ifname_flags_pref,
1735 no_ipv6_route_ifname_flags_pref_cmd,
1736 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1737 NO_STR
1738 IP_STR
1739 "Establish static routes\n"
1740 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1741 "IPv6 gateway address\n"
1742 "IPv6 gateway interface name\n"
1743 "Emit an ICMP unreachable when matched\n"
1744 "Silently discard pkts when matched\n"
1745 "Distance value for this prefix\n")
1746{
1747 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001748}
1749
paul595db7f2003-05-25 21:35:06 +00001750/* New RIB. Detailed information for IPv6 route. */
paula1ac18c2005-06-28 17:17:12 +00001751static void
paul718e3742002-12-13 20:15:29 +00001752vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
1753{
1754 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001755 struct nexthop *nexthop, *tnexthop;
1756 int recursing;
paul718e3742002-12-13 20:15:29 +00001757 char buf[BUFSIZ];
1758
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001759 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001760 {
1761 vty_out (vty, "Routing entry for %s/%d%s",
1762 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1763 rn->p.prefixlen,
1764 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001765 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001766 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +00001767 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
1768 vty_out (vty, ", best");
1769 if (rib->refcnt)
1770 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001771 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1772 vty_out (vty, ", blackhole");
1773 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1774 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001775 vty_out (vty, "%s", VTY_NEWLINE);
1776
1777#define ONE_DAY_SECOND 60*60*24
1778#define ONE_WEEK_SECOND 60*60*24*7
1779 if (rib->type == ZEBRA_ROUTE_RIPNG
1780 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001781 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001782 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001783 || rib->type == ZEBRA_ROUTE_BGP)
1784 {
1785 time_t uptime;
1786 struct tm *tm;
1787
1788 uptime = time (NULL);
1789 uptime -= rib->uptime;
1790 tm = gmtime (&uptime);
1791
1792 vty_out (vty, " Last update ");
1793
1794 if (uptime < ONE_DAY_SECOND)
1795 vty_out (vty, "%02d:%02d:%02d",
1796 tm->tm_hour, tm->tm_min, tm->tm_sec);
1797 else if (uptime < ONE_WEEK_SECOND)
1798 vty_out (vty, "%dd%02dh%02dm",
1799 tm->tm_yday, tm->tm_hour, tm->tm_min);
1800 else
1801 vty_out (vty, "%02dw%dd%02dh",
1802 tm->tm_yday/7,
1803 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1804 vty_out (vty, " ago%s", VTY_NEWLINE);
1805 }
1806
Christian Frankefa713d92013-07-05 15:35:37 +00001807 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001808 {
Christian Frankefa713d92013-07-05 15:35:37 +00001809 vty_out (vty, " %c%s",
1810 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1811 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +00001812
1813 switch (nexthop->type)
1814 {
1815 case NEXTHOP_TYPE_IPV6:
1816 case NEXTHOP_TYPE_IPV6_IFINDEX:
1817 case NEXTHOP_TYPE_IPV6_IFNAME:
1818 vty_out (vty, " %s",
1819 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1820 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1821 vty_out (vty, ", %s", nexthop->ifname);
1822 else if (nexthop->ifindex)
1823 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
1824 break;
1825 case NEXTHOP_TYPE_IFINDEX:
1826 vty_out (vty, " directly connected, %s",
1827 ifindex2ifname (nexthop->ifindex));
1828 break;
1829 case NEXTHOP_TYPE_IFNAME:
1830 vty_out (vty, " directly connected, %s",
1831 nexthop->ifname);
1832 break;
1833 default:
1834 break;
1835 }
1836 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1837 vty_out (vty, " inactive");
1838
Christian Frankee8d3d292013-07-05 15:35:39 +00001839 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1840 vty_out (vty, " onlink");
1841
paul718e3742002-12-13 20:15:29 +00001842 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001843 vty_out (vty, " (recursive)");
1844
paul718e3742002-12-13 20:15:29 +00001845 vty_out (vty, "%s", VTY_NEWLINE);
1846 }
1847 vty_out (vty, "%s", VTY_NEWLINE);
1848 }
1849}
1850
paula1ac18c2005-06-28 17:17:12 +00001851static void
paul718e3742002-12-13 20:15:29 +00001852vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
1853 struct rib *rib)
1854{
Christian Frankefa713d92013-07-05 15:35:37 +00001855 struct nexthop *nexthop, *tnexthop;
1856 int recursing;
paul718e3742002-12-13 20:15:29 +00001857 int len = 0;
1858 char buf[BUFSIZ];
1859
1860 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001861 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001862 {
1863 if (nexthop == rib->nexthop)
1864 {
1865 /* Prefix information. */
1866 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +00001867 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001868 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1869 ? '>' : ' ',
1870 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1871 ? '*' : ' ',
1872 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1873 rn->p.prefixlen);
1874
1875 /* Distance and metric display. */
1876 if (rib->type != ZEBRA_ROUTE_CONNECT
1877 && rib->type != ZEBRA_ROUTE_KERNEL)
1878 len += vty_out (vty, " [%d/%d]", rib->distance,
1879 rib->metric);
1880 }
1881 else
1882 vty_out (vty, " %c%*c",
1883 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1884 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001885 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001886
1887 switch (nexthop->type)
1888 {
1889 case NEXTHOP_TYPE_IPV6:
1890 case NEXTHOP_TYPE_IPV6_IFINDEX:
1891 case NEXTHOP_TYPE_IPV6_IFNAME:
1892 vty_out (vty, " via %s",
1893 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1894 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1895 vty_out (vty, ", %s", nexthop->ifname);
1896 else if (nexthop->ifindex)
1897 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
1898 break;
1899 case NEXTHOP_TYPE_IFINDEX:
1900 vty_out (vty, " is directly connected, %s",
1901 ifindex2ifname (nexthop->ifindex));
1902 break;
1903 case NEXTHOP_TYPE_IFNAME:
1904 vty_out (vty, " is directly connected, %s",
1905 nexthop->ifname);
1906 break;
1907 default:
1908 break;
1909 }
1910 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1911 vty_out (vty, " inactive");
1912
1913 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001914 vty_out (vty, " (recursive)");
paul718e3742002-12-13 20:15:29 +00001915
hasso81dfcaa2003-05-25 19:21:25 +00001916 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1917 vty_out (vty, ", bh");
1918 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1919 vty_out (vty, ", rej");
1920
paul718e3742002-12-13 20:15:29 +00001921 if (rib->type == ZEBRA_ROUTE_RIPNG
1922 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001923 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001924 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001925 || rib->type == ZEBRA_ROUTE_BGP)
1926 {
1927 time_t uptime;
1928 struct tm *tm;
1929
1930 uptime = time (NULL);
1931 uptime -= rib->uptime;
1932 tm = gmtime (&uptime);
1933
1934#define ONE_DAY_SECOND 60*60*24
1935#define ONE_WEEK_SECOND 60*60*24*7
1936
1937 if (uptime < ONE_DAY_SECOND)
1938 vty_out (vty, ", %02d:%02d:%02d",
1939 tm->tm_hour, tm->tm_min, tm->tm_sec);
1940 else if (uptime < ONE_WEEK_SECOND)
1941 vty_out (vty, ", %dd%02dh%02dm",
1942 tm->tm_yday, tm->tm_hour, tm->tm_min);
1943 else
1944 vty_out (vty, ", %02dw%dd%02dh",
1945 tm->tm_yday/7,
1946 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1947 }
1948 vty_out (vty, "%s", VTY_NEWLINE);
1949 }
1950}
1951
paul718e3742002-12-13 20:15:29 +00001952DEFUN (show_ipv6_route,
1953 show_ipv6_route_cmd,
1954 "show ipv6 route",
1955 SHOW_STR
1956 IP_STR
1957 "IPv6 routing table\n")
1958{
1959 struct route_table *table;
1960 struct route_node *rn;
1961 struct rib *rib;
1962 int first = 1;
1963
1964 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1965 if (! table)
1966 return CMD_SUCCESS;
1967
1968 /* Show all IPv6 route. */
1969 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001970 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001971 {
1972 if (first)
1973 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001974 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00001975 first = 0;
1976 }
1977 vty_show_ipv6_route (vty, rn, rib);
1978 }
1979 return CMD_SUCCESS;
1980}
1981
1982DEFUN (show_ipv6_route_prefix_longer,
1983 show_ipv6_route_prefix_longer_cmd,
1984 "show ipv6 route X:X::X:X/M longer-prefixes",
1985 SHOW_STR
1986 IP_STR
1987 "IPv6 routing table\n"
1988 "IPv6 prefix\n"
1989 "Show route matching the specified Network/Mask pair only\n")
1990{
1991 struct route_table *table;
1992 struct route_node *rn;
1993 struct rib *rib;
1994 struct prefix p;
1995 int ret;
1996 int first = 1;
1997
1998 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1999 if (! table)
2000 return CMD_SUCCESS;
2001
2002 ret = str2prefix (argv[0], &p);
2003 if (! ret)
2004 {
2005 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2006 return CMD_WARNING;
2007 }
2008
2009 /* Show matched type IPv6 routes. */
2010 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002011 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002012 if (prefix_match (&p, &rn->p))
2013 {
2014 if (first)
2015 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002016 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002017 first = 0;
2018 }
2019 vty_show_ipv6_route (vty, rn, rib);
2020 }
2021 return CMD_SUCCESS;
2022}
2023
2024DEFUN (show_ipv6_route_protocol,
2025 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02002026 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00002027 SHOW_STR
2028 IP_STR
2029 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02002030 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00002031{
2032 int type;
2033 struct route_table *table;
2034 struct route_node *rn;
2035 struct rib *rib;
2036 int first = 1;
2037
David Lampartere0ca5fd2009-09-16 01:52:42 +02002038 type = proto_redistnum (AFI_IP6, argv[0]);
2039 if (type < 0)
paul718e3742002-12-13 20:15:29 +00002040 {
2041 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2042 return CMD_WARNING;
2043 }
2044
2045 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2046 if (! table)
2047 return CMD_SUCCESS;
2048
2049 /* Show matched type IPv6 routes. */
2050 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002051 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002052 if (rib->type == type)
2053 {
2054 if (first)
2055 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002056 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002057 first = 0;
2058 }
2059 vty_show_ipv6_route (vty, rn, rib);
2060 }
2061 return CMD_SUCCESS;
2062}
2063
2064DEFUN (show_ipv6_route_addr,
2065 show_ipv6_route_addr_cmd,
2066 "show ipv6 route X:X::X:X",
2067 SHOW_STR
2068 IP_STR
2069 "IPv6 routing table\n"
2070 "IPv6 Address\n")
2071{
2072 int ret;
2073 struct prefix_ipv6 p;
2074 struct route_table *table;
2075 struct route_node *rn;
2076
2077 ret = str2prefix_ipv6 (argv[0], &p);
2078 if (ret <= 0)
2079 {
2080 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
2081 return CMD_WARNING;
2082 }
2083
2084 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2085 if (! table)
2086 return CMD_SUCCESS;
2087
2088 rn = route_node_match (table, (struct prefix *) &p);
2089 if (! rn)
2090 {
2091 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2092 return CMD_WARNING;
2093 }
2094
2095 vty_show_ipv6_route_detail (vty, rn);
2096
2097 route_unlock_node (rn);
2098
2099 return CMD_SUCCESS;
2100}
2101
2102DEFUN (show_ipv6_route_prefix,
2103 show_ipv6_route_prefix_cmd,
2104 "show ipv6 route X:X::X:X/M",
2105 SHOW_STR
2106 IP_STR
2107 "IPv6 routing table\n"
2108 "IPv6 prefix\n")
2109{
2110 int ret;
2111 struct prefix_ipv6 p;
2112 struct route_table *table;
2113 struct route_node *rn;
2114
2115 ret = str2prefix_ipv6 (argv[0], &p);
2116 if (ret <= 0)
2117 {
2118 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
2119 return CMD_WARNING;
2120 }
2121
2122 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2123 if (! table)
2124 return CMD_SUCCESS;
2125
2126 rn = route_node_match (table, (struct prefix *) &p);
2127 if (! rn || rn->p.prefixlen != p.prefixlen)
2128 {
2129 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00002130 if (rn)
2131 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00002132 return CMD_WARNING;
2133 }
2134
2135 vty_show_ipv6_route_detail (vty, rn);
2136
2137 route_unlock_node (rn);
2138
2139 return CMD_SUCCESS;
2140}
2141
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002142/* Show route summary. */
2143DEFUN (show_ipv6_route_summary,
2144 show_ipv6_route_summary_cmd,
2145 "show ipv6 route summary",
2146 SHOW_STR
2147 IP_STR
2148 "IPv6 routing table\n"
2149 "Summary of all IPv6 routes\n")
2150{
2151 struct route_table *table;
2152
2153 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2154 if (! table)
2155 return CMD_SUCCESS;
2156
2157 vty_show_ip_route_summary (vty, table);
2158
2159 return CMD_SUCCESS;
2160}
2161
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002162/* Show ipv6 route summary prefix. */
2163DEFUN (show_ipv6_route_summary_prefix,
2164 show_ipv6_route_summary_prefix_cmd,
2165 "show ipv6 route summary prefix",
2166 SHOW_STR
2167 IP_STR
2168 "IPv6 routing table\n"
2169 "Summary of all IPv6 routes\n"
2170 "Prefix routes\n")
2171{
2172 struct route_table *table;
2173
2174 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2175 if (! table)
2176 return CMD_SUCCESS;
2177
2178 vty_show_ip_route_summary_prefix (vty, table);
2179
2180 return CMD_SUCCESS;
2181}
2182
G.Balajicddf3912011-11-26 21:59:32 +04002183/*
G.Balajicddf3912011-11-26 21:59:32 +04002184 * Show IPv6 mroute command.Used to dump
2185 * the Multicast routing table.
2186 */
2187
2188DEFUN (show_ipv6_mroute,
2189 show_ipv6_mroute_cmd,
2190 "show ipv6 mroute",
2191 SHOW_STR
2192 IP_STR
2193 "IPv6 Multicast routing table\n")
2194{
2195 struct route_table *table;
2196 struct route_node *rn;
2197 struct rib *rib;
2198 int first = 1;
2199
2200 table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0);
2201 if (! table)
2202 return CMD_SUCCESS;
2203
2204 /* Show all IPv6 route. */
2205 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002206 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04002207 {
2208 if (first)
2209 {
G.Balajicb32fd62011-11-27 20:09:40 +05302210 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04002211 first = 0;
2212 }
2213 vty_show_ipv6_route (vty, rn, rib);
2214 }
2215 return CMD_SUCCESS;
2216}
2217
paul718e3742002-12-13 20:15:29 +00002218/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002219static int
paul718e3742002-12-13 20:15:29 +00002220static_config_ipv6 (struct vty *vty)
2221{
2222 struct route_node *rn;
2223 struct static_ipv6 *si;
2224 int write;
2225 char buf[BUFSIZ];
2226 struct route_table *stable;
2227
2228 write = 0;
2229
2230 /* Lookup table. */
2231 stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0);
2232 if (! stable)
2233 return -1;
2234
2235 for (rn = route_top (stable); rn; rn = route_next (rn))
2236 for (si = rn->info; si; si = si->next)
2237 {
2238 vty_out (vty, "ipv6 route %s/%d",
2239 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
2240 rn->p.prefixlen);
2241
2242 switch (si->type)
2243 {
2244 case STATIC_IPV6_GATEWAY:
2245 vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
2246 break;
2247 case STATIC_IPV6_IFNAME:
2248 vty_out (vty, " %s", si->ifname);
2249 break;
2250 case STATIC_IPV6_GATEWAY_IFNAME:
2251 vty_out (vty, " %s %s",
2252 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
2253 break;
2254 }
2255
hasso81dfcaa2003-05-25 19:21:25 +00002256 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2257 vty_out (vty, " %s", "reject");
2258
2259 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2260 vty_out (vty, " %s", "blackhole");
2261
paul718e3742002-12-13 20:15:29 +00002262 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2263 vty_out (vty, " %d", si->distance);
2264 vty_out (vty, "%s", VTY_NEWLINE);
2265
2266 write = 1;
2267 }
2268 return write;
2269}
2270#endif /* HAVE_IPV6 */
2271
2272/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00002273static int
paul718e3742002-12-13 20:15:29 +00002274zebra_ip_config (struct vty *vty)
2275{
2276 int write = 0;
2277
Everton Marques33d86db2014-07-14 11:19:00 -03002278 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
2279 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00002280#ifdef HAVE_IPV6
2281 write += static_config_ipv6 (vty);
2282#endif /* HAVE_IPV6 */
2283
2284 return write;
2285}
2286
David Lamparterbd078122015-01-06 19:53:24 +01002287static int config_write_vty(struct vty *vty)
2288{
Paul Jakma7514fb72007-05-02 16:05:35 +00002289 int i;
David Lamparterbd078122015-01-06 19:53:24 +01002290 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
2291
2292 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
2293 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
2294 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
2295 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
2296 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
2297 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
2298 "longer-prefix",
2299 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00002300
2301 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2302 {
2303 if (proto_rm[AFI_IP][i])
2304 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
2305 proto_rm[AFI_IP][i], VTY_NEWLINE);
2306 }
2307 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
2308 vty_out (vty, "ip protocol %s route-map %s%s", "any",
2309 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
2310
2311 return 1;
2312}
2313
2314/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002315static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00002316
paul718e3742002-12-13 20:15:29 +00002317/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002318static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00002319
2320/* Route VTY. */
2321void
paula1ac18c2005-06-28 17:17:12 +00002322zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00002323{
2324 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01002325 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00002326
Everton Marques33d86db2014-07-14 11:19:00 -03002327 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01002328 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03002329 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01002330 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01002331 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
2332 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
2333 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00002334 install_element (CONFIG_NODE, &ip_protocol_cmd);
2335 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
2336 install_element (VIEW_NODE, &show_ip_protocol_cmd);
2337 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00002338 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002339 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002340 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002341 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002342 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002343 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002344 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002345 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002346 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002347 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002348 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002349 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002350 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002351 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002352 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002353 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002354 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002355 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002356 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002357 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002358 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002359 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002360 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002361
2362 install_element (VIEW_NODE, &show_ip_route_cmd);
2363 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
2364 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
2365 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
2366 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
2367 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002368 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002369 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002370 install_element (ENABLE_NODE, &show_ip_route_cmd);
2371 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
2372 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
2373 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
2374 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
2375 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00002376 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002377 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002378
G.Balajicddf3912011-11-26 21:59:32 +04002379 install_element (VIEW_NODE, &show_ip_mroute_cmd);
2380 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
2381
Everton Marques33d86db2014-07-14 11:19:00 -03002382 install_element (VIEW_NODE, &show_ip_rpf_cmd);
2383 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002384
paul718e3742002-12-13 20:15:29 +00002385#ifdef HAVE_IPV6
2386 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002387 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002388 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002389 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002390 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002391 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002392 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002393 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002394 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002395 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002396 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002397 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002398 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002399 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002400 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002401 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002402 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002403 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002404 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002405 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
2406 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
2407 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
2408 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
2409 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
2410 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
2411 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
2412 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
2413 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002414 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002415 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002416
2417 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
2418 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
paul718e3742002-12-13 20:15:29 +00002419#endif /* HAVE_IPV6 */
2420}