blob: 1e39ebdd03ff287af29168ff2ddeb38094f9c165 [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);
David Lamparter3b02fe82015-01-22 19:12:35 +010034static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
35 int mcast);
Everton Marques33d86db2014-07-14 11:19:00 -030036
37/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000038static int
Everton Marques33d86db2014-07-14 11:19:00 -030039zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd,
40 const char *dest_str, const char *mask_str,
41 const char *gate_str, const char *flag_str,
42 const char *distance_str)
paul718e3742002-12-13 20:15:29 +000043{
44 int ret;
45 u_char distance;
46 struct prefix p;
47 struct in_addr gate;
48 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000049 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000050 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +000051
52 ret = str2prefix (dest_str, &p);
53 if (ret <= 0)
54 {
55 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
56 return CMD_WARNING;
57 }
58
59 /* Cisco like mask notation. */
60 if (mask_str)
61 {
62 ret = inet_aton (mask_str, &mask);
63 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000064 {
65 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
66 return CMD_WARNING;
67 }
paul718e3742002-12-13 20:15:29 +000068 p.prefixlen = ip_masklen (mask);
69 }
70
71 /* Apply mask for given prefix. */
72 apply_mask (&p);
73
paul595db7f2003-05-25 21:35:06 +000074 /* Administrative distance. */
75 if (distance_str)
76 distance = atoi (distance_str);
77 else
78 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
79
80 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000081 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000082 {
83 if (flag_str)
84 {
85 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
86 return CMD_WARNING;
87 }
88 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -030089 static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
paul595db7f2003-05-25 21:35:06 +000090 else
Everton Marques33d86db2014-07-14 11:19:00 -030091 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
paul595db7f2003-05-25 21:35:06 +000092 return CMD_SUCCESS;
93 }
94
hasso81dfcaa2003-05-25 19:21:25 +000095 /* Route flags */
96 if (flag_str) {
97 switch(flag_str[0]) {
98 case 'r':
99 case 'R': /* XXX */
100 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
101 break;
102 case 'b':
103 case 'B': /* XXX */
104 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
105 break;
106 default:
107 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000108 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000109 }
110 }
111
hasso457ef552003-05-28 12:02:15 +0000112 if (gate_str == NULL)
113 {
114 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -0300115 static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, 0);
hasso457ef552003-05-28 12:02:15 +0000116 else
Everton Marques33d86db2014-07-14 11:19:00 -0300117 static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, 0);
hasso457ef552003-05-28 12:02:15 +0000118
119 return CMD_SUCCESS;
120 }
121
paul718e3742002-12-13 20:15:29 +0000122 /* When gateway is A.B.C.D format, gate is treated as nexthop
123 address other case gate is treated as interface name. */
124 ret = inet_aton (gate_str, &gate);
125 if (ret)
126 ifname = NULL;
127 else
128 ifname = gate_str;
129
130 if (add_cmd)
Everton Marques33d86db2014-07-14 11:19:00 -0300131 static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, 0);
paul718e3742002-12-13 20:15:29 +0000132 else
Everton Marques33d86db2014-07-14 11:19:00 -0300133 static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, 0);
paul718e3742002-12-13 20:15:29 +0000134
135 return CMD_SUCCESS;
136}
137
Everton Marques33d86db2014-07-14 11:19:00 -0300138static int
139zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
140 const char *mask_str, const char *gate_str,
141 const char *flag_str, const char *distance_str)
142{
143 return zebra_static_ipv4_safi(vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, gate_str, flag_str, distance_str);
144}
145
146/* Static unicast routes for multicast RPF lookup. */
David Lampartera76681b2015-01-22 19:03:53 +0100147DEFUN (ip_mroute_dist,
148 ip_mroute_dist_cmd,
149 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300150 IP_STR
151 "Configure static unicast route into MRIB for multicast RPF lookup\n"
152 "IP destination prefix (e.g. 10.0.0.0/8)\n"
153 "Nexthop address\n"
154 "Nexthop interface name\n"
155 "Distance\n")
156{
David Lamparter863f20c2015-01-27 20:24:15 +0100157 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100158 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
159 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300160}
161
David Lampartera76681b2015-01-22 19:03:53 +0100162ALIAS (ip_mroute_dist,
163 ip_mroute_cmd,
164 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
165 IP_STR
166 "Configure static unicast route into MRIB for multicast RPF lookup\n"
167 "IP destination prefix (e.g. 10.0.0.0/8)\n"
168 "Nexthop address\n"
169 "Nexthop interface name\n")
170
171DEFUN (no_ip_mroute_dist,
172 no_ip_mroute_dist_cmd,
173 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques33d86db2014-07-14 11:19:00 -0300174 IP_STR
175 "Configure static unicast route into MRIB for multicast RPF lookup\n"
176 "IP destination prefix (e.g. 10.0.0.0/8)\n"
177 "Nexthop address\n"
178 "Nexthop interface name\n"
179 "Distance\n")
180{
David Lamparter863f20c2015-01-27 20:24:15 +0100181 VTY_WARN_EXPERIMENTAL();
David Lampartera76681b2015-01-22 19:03:53 +0100182 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
183 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques33d86db2014-07-14 11:19:00 -0300184}
185
David Lampartera76681b2015-01-22 19:03:53 +0100186ALIAS (no_ip_mroute_dist,
187 no_ip_mroute_cmd,
188 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
189 NO_STR
190 IP_STR
191 "Configure static unicast route into MRIB for multicast RPF lookup\n"
192 "IP destination prefix (e.g. 10.0.0.0/8)\n"
193 "Nexthop address\n"
194 "Nexthop interface name\n")
195
David Lamparterbd078122015-01-06 19:53:24 +0100196DEFUN (ip_multicast_mode,
197 ip_multicast_mode_cmd,
198 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
199 IP_STR
200 "Multicast options\n"
201 "RPF lookup behavior\n"
202 "Lookup in unicast RIB only\n"
203 "Lookup in multicast RIB only\n"
204 "Try multicast RIB first, fall back to unicast RIB\n"
205 "Lookup both, use entry with lower distance\n"
206 "Lookup both, use entry with longer prefix\n")
207{
David Lamparter863f20c2015-01-27 20:24:15 +0100208 VTY_WARN_EXPERIMENTAL();
209
David Lamparterbd078122015-01-06 19:53:24 +0100210 if (!strncmp (argv[0], "u", 1))
211 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
212 else if (!strncmp (argv[0], "mrib-o", 6))
213 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
214 else if (!strncmp (argv[0], "mrib-t", 6))
215 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
216 else if (!strncmp (argv[0], "low", 3))
217 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
218 else if (!strncmp (argv[0], "lon", 3))
219 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
220 else
221 {
222 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
223 return CMD_WARNING;
224 }
225
226 return CMD_SUCCESS;
227}
228
229DEFUN (no_ip_multicast_mode,
230 no_ip_multicast_mode_cmd,
231 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
232 NO_STR
233 IP_STR
234 "Multicast options\n"
235 "RPF lookup behavior\n"
236 "Lookup in unicast RIB only\n"
237 "Lookup in multicast RIB only\n"
238 "Try multicast RIB first, fall back to unicast RIB\n"
239 "Lookup both, use entry with lower distance\n"
240 "Lookup both, use entry with longer prefix\n")
241{
242 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
243 return CMD_SUCCESS;
244}
245
246ALIAS (no_ip_multicast_mode,
247 no_ip_multicast_mode_noarg_cmd,
248 "no ip multicast rpf-lookup-mode",
249 NO_STR
250 IP_STR
251 "Multicast options\n"
252 "RPF lookup behavior\n")
253
Everton Marques33d86db2014-07-14 11:19:00 -0300254DEFUN (show_ip_rpf,
255 show_ip_rpf_cmd,
256 "show ip rpf",
257 SHOW_STR
258 IP_STR
259 "Display RPF information for multicast source\n")
260{
David Lamparter863f20c2015-01-27 20:24:15 +0100261 VTY_WARN_EXPERIMENTAL();
Everton Marques33d86db2014-07-14 11:19:00 -0300262 return do_show_ip_route(vty, SAFI_MULTICAST);
263}
264
David Lamparter3b02fe82015-01-22 19:12:35 +0100265DEFUN (show_ip_rpf_addr,
266 show_ip_rpf_addr_cmd,
267 "show ip rpf A.B.C.D",
268 SHOW_STR
269 IP_STR
270 "Display RPF information for multicast source\n"
271 "IP multicast source address (e.g. 10.0.0.0)\n")
272{
273 struct in_addr addr;
274 struct route_node *rn;
275 struct rib *rib;
276 int ret;
277
David Lamparter863f20c2015-01-27 20:24:15 +0100278 VTY_WARN_EXPERIMENTAL();
279
David Lamparter3b02fe82015-01-22 19:12:35 +0100280 ret = inet_aton (argv[0], &addr);
281 if (ret == 0)
282 {
283 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
284 return CMD_WARNING;
285 }
286
287 rib = rib_match_ipv4_multicast (addr, &rn);
288
289 if (rib)
290 vty_show_ip_route_detail (vty, rn, 1);
291 else
292 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
293
294 return CMD_SUCCESS;
295}
296
paul718e3742002-12-13 20:15:29 +0000297/* Static route configuration. */
298DEFUN (ip_route,
299 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000300 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000301 IP_STR
302 "Establish static routes\n"
303 "IP destination prefix (e.g. 10.0.0.0/8)\n"
304 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000305 "IP gateway interface name\n"
306 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000307{
308 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
309}
310
311DEFUN (ip_route_flags,
312 ip_route_flags_cmd,
313 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000314 IP_STR
315 "Establish static routes\n"
316 "IP destination prefix (e.g. 10.0.0.0/8)\n"
317 "IP gateway address\n"
318 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000319 "Emit an ICMP unreachable when matched\n"
320 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000321{
hasso81dfcaa2003-05-25 19:21:25 +0000322 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
paul718e3742002-12-13 20:15:29 +0000323}
324
hasso457ef552003-05-28 12:02:15 +0000325DEFUN (ip_route_flags2,
326 ip_route_flags2_cmd,
327 "ip route A.B.C.D/M (reject|blackhole)",
328 IP_STR
329 "Establish static routes\n"
330 "IP destination prefix (e.g. 10.0.0.0/8)\n"
331 "Emit an ICMP unreachable when matched\n"
332 "Silently discard pkts when matched\n")
333{
334 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
335}
336
paul718e3742002-12-13 20:15:29 +0000337/* Mask as A.B.C.D format. */
338DEFUN (ip_route_mask,
339 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000340 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000341 IP_STR
342 "Establish static routes\n"
343 "IP destination prefix\n"
344 "IP destination prefix mask\n"
345 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000346 "IP gateway interface name\n"
347 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000348{
349 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
350}
351
352DEFUN (ip_route_mask_flags,
353 ip_route_mask_flags_cmd,
354 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000355 IP_STR
356 "Establish static routes\n"
357 "IP destination prefix\n"
358 "IP destination prefix mask\n"
359 "IP gateway address\n"
360 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000361 "Emit an ICMP unreachable when matched\n"
362 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000363{
hasso81dfcaa2003-05-25 19:21:25 +0000364 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000365}
366
hasso457ef552003-05-28 12:02:15 +0000367DEFUN (ip_route_mask_flags2,
368 ip_route_mask_flags2_cmd,
369 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
370 IP_STR
371 "Establish static routes\n"
372 "IP destination prefix\n"
373 "IP destination prefix mask\n"
374 "Emit an ICMP unreachable when matched\n"
375 "Silently discard pkts when matched\n")
376{
377 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
378}
379
paul718e3742002-12-13 20:15:29 +0000380/* Distance option value. */
381DEFUN (ip_route_distance,
382 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000383 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000384 IP_STR
385 "Establish static routes\n"
386 "IP destination prefix (e.g. 10.0.0.0/8)\n"
387 "IP gateway address\n"
388 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000389 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000390 "Distance value for this route\n")
391{
hasso81dfcaa2003-05-25 19:21:25 +0000392 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
393}
394
395DEFUN (ip_route_flags_distance,
396 ip_route_flags_distance_cmd,
397 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
398 IP_STR
399 "Establish static routes\n"
400 "IP destination prefix (e.g. 10.0.0.0/8)\n"
401 "IP gateway address\n"
402 "IP gateway interface name\n"
403 "Emit an ICMP unreachable when matched\n"
404 "Silently discard pkts when matched\n"
405 "Distance value for this route\n")
406{
407 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000408}
409
hasso457ef552003-05-28 12:02:15 +0000410DEFUN (ip_route_flags_distance2,
411 ip_route_flags_distance2_cmd,
412 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
413 IP_STR
414 "Establish static routes\n"
415 "IP destination prefix (e.g. 10.0.0.0/8)\n"
416 "Emit an ICMP unreachable when matched\n"
417 "Silently discard pkts when matched\n"
418 "Distance value for this route\n")
419{
420 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
421}
422
paul718e3742002-12-13 20:15:29 +0000423DEFUN (ip_route_mask_distance,
424 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000425 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000426 IP_STR
427 "Establish static routes\n"
428 "IP destination prefix\n"
429 "IP destination prefix mask\n"
430 "IP gateway address\n"
431 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000432 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000433 "Distance value for this route\n")
434{
hasso81dfcaa2003-05-25 19:21:25 +0000435 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
436}
437
438DEFUN (ip_route_mask_flags_distance,
439 ip_route_mask_flags_distance_cmd,
440 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
441 IP_STR
442 "Establish static routes\n"
443 "IP destination prefix\n"
444 "IP destination prefix mask\n"
445 "IP gateway address\n"
446 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000447 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000448 "Silently discard pkts when matched\n"
449 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000450{
451 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000452}
453
hasso457ef552003-05-28 12:02:15 +0000454DEFUN (ip_route_mask_flags_distance2,
455 ip_route_mask_flags_distance2_cmd,
456 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
457 IP_STR
458 "Establish static routes\n"
459 "IP destination prefix\n"
460 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000461 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000462 "Silently discard pkts when matched\n"
463 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000464{
465 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
466}
467
paul718e3742002-12-13 20:15:29 +0000468DEFUN (no_ip_route,
469 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000470 "no ip route A.B.C.D/M (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 (e.g. 10.0.0.0/8)\n"
475 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000476 "IP gateway interface name\n"
477 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000478{
479 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
480}
481
482ALIAS (no_ip_route,
483 no_ip_route_flags_cmd,
484 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000485 NO_STR
486 IP_STR
487 "Establish static routes\n"
488 "IP destination prefix (e.g. 10.0.0.0/8)\n"
489 "IP gateway address\n"
490 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000491 "Emit an ICMP unreachable when matched\n"
492 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000493
hasso457ef552003-05-28 12:02:15 +0000494DEFUN (no_ip_route_flags2,
495 no_ip_route_flags2_cmd,
496 "no ip route A.B.C.D/M (reject|blackhole)",
497 NO_STR
498 IP_STR
499 "Establish static routes\n"
500 "IP destination prefix (e.g. 10.0.0.0/8)\n"
501 "Emit an ICMP unreachable when matched\n"
502 "Silently discard pkts when matched\n")
503{
504 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
505}
506
paul718e3742002-12-13 20:15:29 +0000507DEFUN (no_ip_route_mask,
508 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000509 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000510 NO_STR
511 IP_STR
512 "Establish static routes\n"
513 "IP destination prefix\n"
514 "IP destination prefix mask\n"
515 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000516 "IP gateway interface name\n"
517 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000518{
519 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
520}
521
522ALIAS (no_ip_route_mask,
523 no_ip_route_mask_flags_cmd,
524 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000525 NO_STR
526 IP_STR
527 "Establish static routes\n"
528 "IP destination prefix\n"
529 "IP destination prefix mask\n"
530 "IP gateway address\n"
531 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000532 "Emit an ICMP unreachable when matched\n"
533 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000534
hasso457ef552003-05-28 12:02:15 +0000535DEFUN (no_ip_route_mask_flags2,
536 no_ip_route_mask_flags2_cmd,
537 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
538 NO_STR
539 IP_STR
540 "Establish static routes\n"
541 "IP destination prefix\n"
542 "IP destination prefix mask\n"
543 "Emit an ICMP unreachable when matched\n"
544 "Silently discard pkts when matched\n")
545{
546 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
547}
548
paul718e3742002-12-13 20:15:29 +0000549DEFUN (no_ip_route_distance,
550 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000551 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000552 NO_STR
553 IP_STR
554 "Establish static routes\n"
555 "IP destination prefix (e.g. 10.0.0.0/8)\n"
556 "IP gateway address\n"
557 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000558 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000559 "Distance value for this route\n")
560{
hasso81dfcaa2003-05-25 19:21:25 +0000561 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
562}
563
564DEFUN (no_ip_route_flags_distance,
565 no_ip_route_flags_distance_cmd,
566 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
567 NO_STR
568 IP_STR
569 "Establish static routes\n"
570 "IP destination prefix (e.g. 10.0.0.0/8)\n"
571 "IP gateway address\n"
572 "IP gateway interface name\n"
573 "Emit an ICMP unreachable when matched\n"
574 "Silently discard pkts when matched\n"
575 "Distance value for this route\n")
576{
577 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000578}
579
hasso457ef552003-05-28 12:02:15 +0000580DEFUN (no_ip_route_flags_distance2,
581 no_ip_route_flags_distance2_cmd,
582 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
583 NO_STR
584 IP_STR
585 "Establish static routes\n"
586 "IP destination prefix (e.g. 10.0.0.0/8)\n"
587 "Emit an ICMP unreachable when matched\n"
588 "Silently discard pkts when matched\n"
589 "Distance value for this route\n")
590{
591 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
592}
593
paul718e3742002-12-13 20:15:29 +0000594DEFUN (no_ip_route_mask_distance,
595 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000596 "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 +0000597 NO_STR
598 IP_STR
599 "Establish static routes\n"
600 "IP destination prefix\n"
601 "IP destination prefix mask\n"
602 "IP gateway address\n"
603 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000604 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000605 "Distance value for this route\n")
606{
hasso81dfcaa2003-05-25 19:21:25 +0000607 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
608}
609
610DEFUN (no_ip_route_mask_flags_distance,
611 no_ip_route_mask_flags_distance_cmd,
612 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
613 NO_STR
614 IP_STR
615 "Establish static routes\n"
616 "IP destination prefix\n"
617 "IP destination prefix mask\n"
618 "IP gateway address\n"
619 "IP gateway interface name\n"
620 "Emit an ICMP unreachable when matched\n"
621 "Silently discard pkts when matched\n"
622 "Distance value for this route\n")
623{
624 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000625}
626
hasso457ef552003-05-28 12:02:15 +0000627DEFUN (no_ip_route_mask_flags_distance2,
628 no_ip_route_mask_flags_distance2_cmd,
629 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
630 NO_STR
631 IP_STR
632 "Establish static routes\n"
633 "IP destination prefix\n"
634 "IP destination prefix mask\n"
635 "Emit an ICMP unreachable when matched\n"
636 "Silently discard pkts when matched\n"
637 "Distance value for this route\n")
638{
639 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
640}
641
Paul Jakma7514fb72007-05-02 16:05:35 +0000642char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
643
644DEFUN (ip_protocol,
645 ip_protocol_cmd,
646 "ip protocol PROTO route-map ROUTE-MAP",
647 NO_STR
648 "Apply route map to PROTO\n"
649 "Protocol name\n"
650 "Route map name\n")
651{
652 int i;
653
654 if (strcasecmp(argv[0], "any") == 0)
655 i = ZEBRA_ROUTE_MAX;
656 else
657 i = proto_name2num(argv[0]);
658 if (i < 0)
659 {
660 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
661 VTY_NEWLINE);
662 return CMD_WARNING;
663 }
664 if (proto_rm[AFI_IP][i])
665 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
666 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
667 return CMD_SUCCESS;
668}
669
670DEFUN (no_ip_protocol,
671 no_ip_protocol_cmd,
672 "no ip protocol PROTO",
673 NO_STR
674 "Remove route map from PROTO\n"
675 "Protocol name\n")
676{
677 int i;
678
679 if (strcasecmp(argv[0], "any") == 0)
680 i = ZEBRA_ROUTE_MAX;
681 else
682 i = proto_name2num(argv[0]);
683 if (i < 0)
684 {
685 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
686 VTY_NEWLINE);
687 return CMD_WARNING;
688 }
689 if (proto_rm[AFI_IP][i])
690 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
691 proto_rm[AFI_IP][i] = NULL;
692 return CMD_SUCCESS;
693}
694
paul718e3742002-12-13 20:15:29 +0000695/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +0000696static void
David Lamparter3b02fe82015-01-22 19:12:35 +0100697vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +0000698{
699 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +0000700 struct nexthop *nexthop, *tnexthop;
701 int recursing;
paul718e3742002-12-13 20:15:29 +0000702
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000703 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000704 {
David Lamparter09037f82015-03-03 09:08:27 +0100705 const char *mcast_info = "";
David Lamparter3b02fe82015-01-22 19:12:35 +0100706 if (mcast)
707 {
708 rib_table_info_t *info = rn->table->info;
709 mcast_info = (info->safi == SAFI_MULTICAST)
710 ? " using Multicast RIB"
711 : " using Unicast RIB";
712 }
713 vty_out (vty, "Routing entry for %s/%d%s%s",
714 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, mcast_info,
paul718e3742002-12-13 20:15:29 +0000715 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +0000716 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +0200717 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +0000718 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
719 vty_out (vty, ", best");
720 if (rib->refcnt)
721 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +0000722 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
723 vty_out (vty, ", blackhole");
724 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
725 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +0000726 vty_out (vty, "%s", VTY_NEWLINE);
727
728#define ONE_DAY_SECOND 60*60*24
729#define ONE_WEEK_SECOND 60*60*24*7
730 if (rib->type == ZEBRA_ROUTE_RIP
731 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100732 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000733 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000734 || rib->type == ZEBRA_ROUTE_BGP)
735 {
736 time_t uptime;
737 struct tm *tm;
738
739 uptime = time (NULL);
740 uptime -= rib->uptime;
741 tm = gmtime (&uptime);
742
743 vty_out (vty, " Last update ");
744
745 if (uptime < ONE_DAY_SECOND)
746 vty_out (vty, "%02d:%02d:%02d",
747 tm->tm_hour, tm->tm_min, tm->tm_sec);
748 else if (uptime < ONE_WEEK_SECOND)
749 vty_out (vty, "%dd%02dh%02dm",
750 tm->tm_yday, tm->tm_hour, tm->tm_min);
751 else
752 vty_out (vty, "%02dw%dd%02dh",
753 tm->tm_yday/7,
754 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
755 vty_out (vty, " ago%s", VTY_NEWLINE);
756 }
757
Christian Frankefa713d92013-07-05 15:35:37 +0000758 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000759 {
Paul Jakma7514fb72007-05-02 16:05:35 +0000760 char addrstr[32];
761
Christian Frankefa713d92013-07-05 15:35:37 +0000762 vty_out (vty, " %c%s",
763 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
764 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +0000765
766 switch (nexthop->type)
767 {
768 case NEXTHOP_TYPE_IPV4:
769 case NEXTHOP_TYPE_IPV4_IFINDEX:
770 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
771 if (nexthop->ifindex)
772 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
773 break;
774 case NEXTHOP_TYPE_IFINDEX:
775 vty_out (vty, " directly connected, %s",
776 ifindex2ifname (nexthop->ifindex));
777 break;
778 case NEXTHOP_TYPE_IFNAME:
779 vty_out (vty, " directly connected, %s", nexthop->ifname);
780 break;
paul595db7f2003-05-25 21:35:06 +0000781 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000782 vty_out (vty, " directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000783 break;
paul7021c422003-07-15 12:52:22 +0000784 default:
paul718e3742002-12-13 20:15:29 +0000785 break;
786 }
787 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
788 vty_out (vty, " inactive");
789
Christian Frankee8d3d292013-07-05 15:35:39 +0000790 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
791 vty_out (vty, " onlink");
792
paul718e3742002-12-13 20:15:29 +0000793 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000794 vty_out (vty, " (recursive)");
Christian Franke5b9f5182013-05-25 14:01:34 +0000795
Paul Jakma7514fb72007-05-02 16:05:35 +0000796 switch (nexthop->type)
797 {
798 case NEXTHOP_TYPE_IPV4:
799 case NEXTHOP_TYPE_IPV4_IFINDEX:
800 case NEXTHOP_TYPE_IPV4_IFNAME:
801 if (nexthop->src.ipv4.s_addr)
802 {
803 if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
804 sizeof addrstr))
805 vty_out (vty, ", src %s", addrstr);
806 }
807 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000808#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000809 case NEXTHOP_TYPE_IPV6:
810 case NEXTHOP_TYPE_IPV6_IFINDEX:
811 case NEXTHOP_TYPE_IPV6_IFNAME:
812 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
813 {
814 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
815 sizeof addrstr))
816 vty_out (vty, ", src %s", addrstr);
817 }
818 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000819#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000820 default:
821 break;
822 }
paul718e3742002-12-13 20:15:29 +0000823 vty_out (vty, "%s", VTY_NEWLINE);
824 }
825 vty_out (vty, "%s", VTY_NEWLINE);
826 }
827}
828
paula1ac18c2005-06-28 17:17:12 +0000829static void
paul718e3742002-12-13 20:15:29 +0000830vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
831{
Christian Frankefa713d92013-07-05 15:35:37 +0000832 struct nexthop *nexthop, *tnexthop;
833 int recursing;
paul718e3742002-12-13 20:15:29 +0000834 int len = 0;
835 char buf[BUFSIZ];
836
837 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +0000838 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000839 {
840 if (nexthop == rib->nexthop)
841 {
842 /* Prefix information. */
843 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +0000844 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +0000845 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
846 ? '>' : ' ',
847 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
848 ? '*' : ' ',
849 inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ),
850 rn->p.prefixlen);
851
852 /* Distance and metric display. */
853 if (rib->type != ZEBRA_ROUTE_CONNECT
854 && rib->type != ZEBRA_ROUTE_KERNEL)
855 len += vty_out (vty, " [%d/%d]", rib->distance,
856 rib->metric);
857 }
858 else
859 vty_out (vty, " %c%*c",
860 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
861 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +0000862 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +0000863
864 switch (nexthop->type)
865 {
866 case NEXTHOP_TYPE_IPV4:
867 case NEXTHOP_TYPE_IPV4_IFINDEX:
868 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
869 if (nexthop->ifindex)
870 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
871 break;
872 case NEXTHOP_TYPE_IFINDEX:
873 vty_out (vty, " is directly connected, %s",
874 ifindex2ifname (nexthop->ifindex));
875 break;
876 case NEXTHOP_TYPE_IFNAME:
877 vty_out (vty, " is directly connected, %s", nexthop->ifname);
878 break;
paul595db7f2003-05-25 21:35:06 +0000879 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000880 vty_out (vty, " is directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000881 break;
paul7021c422003-07-15 12:52:22 +0000882 default:
paul718e3742002-12-13 20:15:29 +0000883 break;
884 }
885 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
886 vty_out (vty, " inactive");
887
Christian Frankee8d3d292013-07-05 15:35:39 +0000888 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
889 vty_out (vty, " onlink");
890
paul718e3742002-12-13 20:15:29 +0000891 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000892 vty_out (vty, " (recursive)");
893
Paul Jakma7514fb72007-05-02 16:05:35 +0000894 switch (nexthop->type)
895 {
896 case NEXTHOP_TYPE_IPV4:
897 case NEXTHOP_TYPE_IPV4_IFINDEX:
898 case NEXTHOP_TYPE_IPV4_IFNAME:
899 if (nexthop->src.ipv4.s_addr)
900 {
901 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
902 vty_out (vty, ", src %s", buf);
903 }
904 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000905#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000906 case NEXTHOP_TYPE_IPV6:
907 case NEXTHOP_TYPE_IPV6_IFINDEX:
908 case NEXTHOP_TYPE_IPV6_IFNAME:
909 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
910 {
911 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
912 vty_out (vty, ", src %s", buf);
913 }
914 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000915#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000916 default:
917 break;
918 }
paul718e3742002-12-13 20:15:29 +0000919
hasso81dfcaa2003-05-25 19:21:25 +0000920 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
921 vty_out (vty, ", bh");
922 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
923 vty_out (vty, ", rej");
924
paul718e3742002-12-13 20:15:29 +0000925 if (rib->type == ZEBRA_ROUTE_RIP
926 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100927 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000928 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000929 || rib->type == ZEBRA_ROUTE_BGP)
930 {
931 time_t uptime;
932 struct tm *tm;
933
934 uptime = time (NULL);
935 uptime -= rib->uptime;
936 tm = gmtime (&uptime);
937
938#define ONE_DAY_SECOND 60*60*24
939#define ONE_WEEK_SECOND 60*60*24*7
940
941 if (uptime < ONE_DAY_SECOND)
942 vty_out (vty, ", %02d:%02d:%02d",
943 tm->tm_hour, tm->tm_min, tm->tm_sec);
944 else if (uptime < ONE_WEEK_SECOND)
945 vty_out (vty, ", %dd%02dh%02dm",
946 tm->tm_yday, tm->tm_hour, tm->tm_min);
947 else
948 vty_out (vty, ", %02dw%dd%02dh",
949 tm->tm_yday/7,
950 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
951 }
952 vty_out (vty, "%s", VTY_NEWLINE);
953 }
954}
955
paul718e3742002-12-13 20:15:29 +0000956DEFUN (show_ip_route,
957 show_ip_route_cmd,
958 "show ip route",
959 SHOW_STR
960 IP_STR
961 "IP routing table\n")
962{
Everton Marques33d86db2014-07-14 11:19:00 -0300963 return do_show_ip_route(vty, SAFI_UNICAST);
964}
965
966static int do_show_ip_route(struct vty *vty, safi_t safi) {
paul718e3742002-12-13 20:15:29 +0000967 struct route_table *table;
968 struct route_node *rn;
969 struct rib *rib;
970 int first = 1;
971
Everton Marques33d86db2014-07-14 11:19:00 -0300972 table = vrf_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +0000973 if (! table)
974 return CMD_SUCCESS;
975
976 /* Show all IPv4 routes. */
977 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000978 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000979 {
980 if (first)
981 {
David Lampartere0ca5fd2009-09-16 01:52:42 +0200982 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +0000983 first = 0;
984 }
985 vty_show_ip_route (vty, rn, rib);
986 }
987 return CMD_SUCCESS;
988}
989
990DEFUN (show_ip_route_prefix_longer,
991 show_ip_route_prefix_longer_cmd,
992 "show ip route A.B.C.D/M longer-prefixes",
993 SHOW_STR
994 IP_STR
995 "IP routing table\n"
996 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
997 "Show route matching the specified Network/Mask pair only\n")
998{
999 struct route_table *table;
1000 struct route_node *rn;
1001 struct rib *rib;
1002 struct prefix p;
1003 int ret;
1004 int first = 1;
1005
1006 ret = str2prefix (argv[0], &p);
1007 if (! ret)
1008 {
1009 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1010 return CMD_WARNING;
1011 }
1012
1013 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1014 if (! table)
1015 return CMD_SUCCESS;
1016
1017 /* Show matched type IPv4 routes. */
1018 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001019 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001020 if (prefix_match (&p, &rn->p))
1021 {
1022 if (first)
1023 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001024 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001025 first = 0;
1026 }
1027 vty_show_ip_route (vty, rn, rib);
1028 }
1029 return CMD_SUCCESS;
1030}
1031
1032DEFUN (show_ip_route_supernets,
1033 show_ip_route_supernets_cmd,
1034 "show ip route supernets-only",
1035 SHOW_STR
1036 IP_STR
1037 "IP routing table\n"
1038 "Show supernet entries only\n")
1039{
1040 struct route_table *table;
1041 struct route_node *rn;
1042 struct rib *rib;
1043 u_int32_t addr;
1044 int first = 1;
1045
1046 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1047 if (! table)
1048 return CMD_SUCCESS;
1049
1050 /* Show matched type IPv4 routes. */
1051 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001052 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001053 {
1054 addr = ntohl (rn->p.u.prefix4.s_addr);
1055
1056 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1057 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
1058 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
1059 {
1060 if (first)
1061 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001062 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001063 first = 0;
1064 }
1065 vty_show_ip_route (vty, rn, rib);
1066 }
1067 }
1068 return CMD_SUCCESS;
1069}
1070
1071DEFUN (show_ip_route_protocol,
1072 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001073 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001074 SHOW_STR
1075 IP_STR
1076 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001077 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001078{
1079 int type;
1080 struct route_table *table;
1081 struct route_node *rn;
1082 struct rib *rib;
1083 int first = 1;
1084
David Lampartere0ca5fd2009-09-16 01:52:42 +02001085 type = proto_redistnum (AFI_IP, argv[0]);
1086 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001087 {
1088 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1089 return CMD_WARNING;
1090 }
1091
1092 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1093 if (! table)
1094 return CMD_SUCCESS;
1095
1096 /* Show matched type IPv4 routes. */
1097 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001098 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001099 if (rib->type == type)
1100 {
1101 if (first)
1102 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001103 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001104 first = 0;
1105 }
1106 vty_show_ip_route (vty, rn, rib);
1107 }
1108 return CMD_SUCCESS;
1109}
1110
1111DEFUN (show_ip_route_addr,
1112 show_ip_route_addr_cmd,
1113 "show ip route A.B.C.D",
1114 SHOW_STR
1115 IP_STR
1116 "IP routing table\n"
1117 "Network in the IP routing table to display\n")
1118{
1119 int ret;
1120 struct prefix_ipv4 p;
1121 struct route_table *table;
1122 struct route_node *rn;
1123
1124 ret = str2prefix_ipv4 (argv[0], &p);
1125 if (ret <= 0)
1126 {
1127 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1128 return CMD_WARNING;
1129 }
1130
1131 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1132 if (! table)
1133 return CMD_SUCCESS;
1134
1135 rn = route_node_match (table, (struct prefix *) &p);
1136 if (! rn)
1137 {
1138 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1139 return CMD_WARNING;
1140 }
1141
David Lamparter3b02fe82015-01-22 19:12:35 +01001142 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001143
1144 route_unlock_node (rn);
1145
1146 return CMD_SUCCESS;
1147}
1148
1149DEFUN (show_ip_route_prefix,
1150 show_ip_route_prefix_cmd,
1151 "show ip route A.B.C.D/M",
1152 SHOW_STR
1153 IP_STR
1154 "IP routing table\n"
1155 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1156{
1157 int ret;
1158 struct prefix_ipv4 p;
1159 struct route_table *table;
1160 struct route_node *rn;
1161
1162 ret = str2prefix_ipv4 (argv[0], &p);
1163 if (ret <= 0)
1164 {
1165 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1166 return CMD_WARNING;
1167 }
1168
1169 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1170 if (! table)
1171 return CMD_SUCCESS;
1172
1173 rn = route_node_match (table, (struct prefix *) &p);
1174 if (! rn || rn->p.prefixlen != p.prefixlen)
1175 {
1176 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001177 if (rn)
1178 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001179 return CMD_WARNING;
1180 }
1181
David Lamparter3b02fe82015-01-22 19:12:35 +01001182 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001183
1184 route_unlock_node (rn);
1185
1186 return CMD_SUCCESS;
1187}
1188
paula1ac18c2005-06-28 17:17:12 +00001189static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001190vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001191{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001192 struct route_node *rn;
1193 struct rib *rib;
1194 struct nexthop *nexthop;
1195#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1196#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1197 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1198 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1199 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001200
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001201 memset (&rib_cnt, 0, sizeof(rib_cnt));
1202 memset (&fib_cnt, 0, sizeof(fib_cnt));
1203 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001204 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001205 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1206 {
1207 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1208 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001209 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1210 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001211 {
1212 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1213 fib_cnt[rib->type]++;
1214 }
1215 if (rib->type == ZEBRA_ROUTE_BGP &&
1216 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1217 {
1218 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001219 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1220 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001221 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1222 }
1223 }
paul718e3742002-12-13 20:15:29 +00001224
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001225 vty_out (vty, "%-20s %-20s %-20s %s",
1226 "Route Source", "Routes", "FIB", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001227
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001228 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1229 {
1230 if (rib_cnt[i] > 0)
1231 {
1232 if (i == ZEBRA_ROUTE_BGP)
1233 {
1234 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1235 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1236 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1237 VTY_NEWLINE);
1238 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1239 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1240 VTY_NEWLINE);
1241 }
1242 else
1243 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1244 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1245 }
1246 }
paul718e3742002-12-13 20:15:29 +00001247
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001248 vty_out (vty, "------%s", VTY_NEWLINE);
1249 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1250 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001251}
1252
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001253/*
1254 * Implementation of the ip route summary prefix command.
1255 *
1256 * This command prints the primary prefixes that have been installed by various
1257 * protocols on the box.
1258 *
1259 */
1260static void
1261vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1262{
1263 struct route_node *rn;
1264 struct rib *rib;
1265 struct nexthop *nexthop;
1266#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1267#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1268 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1269 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1270 u_int32_t i;
1271 int cnt;
1272
1273 memset (&rib_cnt, 0, sizeof(rib_cnt));
1274 memset (&fib_cnt, 0, sizeof(fib_cnt));
1275 for (rn = route_top (table); rn; rn = route_next (rn))
1276 RNODE_FOREACH_RIB (rn, rib)
1277 {
1278
1279 /*
1280 * In case of ECMP, count only once.
1281 */
1282 cnt = 0;
1283 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1284 {
1285 cnt++;
1286 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1287 rib_cnt[rib->type]++;
1288 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1289 {
1290 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1291 fib_cnt[rib->type]++;
1292 }
1293 if (rib->type == ZEBRA_ROUTE_BGP &&
1294 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1295 {
1296 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1297 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1298 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1299 }
1300 }
1301 }
1302
1303 vty_out (vty, "%-20s %-20s %-20s %s",
1304 "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
1305
1306 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1307 {
1308 if (rib_cnt[i] > 0)
1309 {
1310 if (i == ZEBRA_ROUTE_BGP)
1311 {
1312 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1313 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1314 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1315 VTY_NEWLINE);
1316 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1317 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1318 VTY_NEWLINE);
1319 }
1320 else
1321 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1322 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1323 }
1324 }
1325
1326 vty_out (vty, "------%s", VTY_NEWLINE);
1327 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1328 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
1329}
1330
paul718e3742002-12-13 20:15:29 +00001331/* Show route summary. */
1332DEFUN (show_ip_route_summary,
1333 show_ip_route_summary_cmd,
1334 "show ip route summary",
1335 SHOW_STR
1336 IP_STR
1337 "IP routing table\n"
1338 "Summary of all routes\n")
1339{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001340 struct route_table *table;
paul718e3742002-12-13 20:15:29 +00001341
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001342 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1343 if (! table)
1344 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001345
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001346 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00001347
1348 return CMD_SUCCESS;
1349}
1350
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001351/* Show route summary prefix. */
1352DEFUN (show_ip_route_summary_prefix,
1353 show_ip_route_summary_prefix_cmd,
1354 "show ip route summary prefix",
1355 SHOW_STR
1356 IP_STR
1357 "IP routing table\n"
1358 "Summary of all routes\n"
1359 "Prefix routes\n")
1360{
1361 struct route_table *table;
1362
1363 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1364 if (! table)
1365 return CMD_SUCCESS;
1366
1367 vty_show_ip_route_summary_prefix (vty, table);
1368
1369 return CMD_SUCCESS;
1370}
1371
paul718e3742002-12-13 20:15:29 +00001372/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00001373static int
Everton Marques33d86db2014-07-14 11:19:00 -03001374static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00001375{
1376 struct route_node *rn;
1377 struct static_ipv4 *si;
1378 struct route_table *stable;
1379 int write;
1380
1381 write = 0;
1382
1383 /* Lookup table. */
Everton Marques33d86db2014-07-14 11:19:00 -03001384 stable = vrf_static_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +00001385 if (! stable)
1386 return -1;
1387
1388 for (rn = route_top (stable); rn; rn = route_next (rn))
1389 for (si = rn->info; si; si = si->next)
1390 {
Everton Marques33d86db2014-07-14 11:19:00 -03001391 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
paul7021c422003-07-15 12:52:22 +00001392 rn->p.prefixlen);
paul718e3742002-12-13 20:15:29 +00001393
paul7021c422003-07-15 12:52:22 +00001394 switch (si->type)
1395 {
1396 case STATIC_IPV4_GATEWAY:
1397 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
1398 break;
1399 case STATIC_IPV4_IFNAME:
1400 vty_out (vty, " %s", si->gate.ifname);
1401 break;
1402 case STATIC_IPV4_BLACKHOLE:
1403 vty_out (vty, " Null0");
1404 break;
1405 }
1406
1407 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
1408 if (si->type != STATIC_IPV4_BLACKHOLE)
1409 {
1410 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
1411 vty_out (vty, " %s", "reject");
paul718e3742002-12-13 20:15:29 +00001412
paul7021c422003-07-15 12:52:22 +00001413 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
1414 vty_out (vty, " %s", "blackhole");
1415 }
hasso81dfcaa2003-05-25 19:21:25 +00001416
paul7021c422003-07-15 12:52:22 +00001417 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
1418 vty_out (vty, " %d", si->distance);
hasso81dfcaa2003-05-25 19:21:25 +00001419
paul7021c422003-07-15 12:52:22 +00001420 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001421
paul7021c422003-07-15 12:52:22 +00001422 write = 1;
paul718e3742002-12-13 20:15:29 +00001423 }
1424 return write;
1425}
Andrew J. Schorr09303312007-05-30 20:10:34 +00001426
1427DEFUN (show_ip_protocol,
1428 show_ip_protocol_cmd,
1429 "show ip protocol",
1430 SHOW_STR
1431 IP_STR
1432 "IP protocol filtering status\n")
1433{
1434 int i;
1435
1436 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
1437 vty_out(vty, "------------------------%s", VTY_NEWLINE);
1438 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
1439 {
1440 if (proto_rm[AFI_IP][i])
1441 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
1442 proto_rm[AFI_IP][i],
1443 VTY_NEWLINE);
1444 else
1445 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
1446 }
1447 if (proto_rm[AFI_IP][i])
1448 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
1449 VTY_NEWLINE);
1450 else
1451 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
1452
1453 return CMD_SUCCESS;
1454}
1455
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001456/*
1457 * Show IP mroute command to dump the BGP Multicast
1458 * routing table
1459 */
1460DEFUN (show_ip_mroute,
1461 show_ip_mroute_cmd,
1462 "show ip mroute",
1463 SHOW_STR
1464 IP_STR
1465 "IP Multicast routing table\n")
1466{
1467 struct route_table *table;
1468 struct route_node *rn;
1469 struct rib *rib;
1470 int first = 1;
1471
1472 table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
1473 if (! table)
1474 return CMD_SUCCESS;
1475
1476 /* Show all IPv4 routes. */
1477 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001478 RNODE_FOREACH_RIB (rn, rib)
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001479 {
1480 if (first)
1481 {
1482 vty_out (vty, SHOW_ROUTE_V4_HEADER);
1483 first = 0;
1484 }
1485 vty_show_ip_route (vty, rn, rib);
1486 }
1487 return CMD_SUCCESS;
1488}
1489
David Lamparter6b0655a2014-06-04 06:53:35 +02001490
paul718e3742002-12-13 20:15:29 +00001491#ifdef HAVE_IPV6
1492/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00001493static int
hasso39db97e2004-10-12 20:50:58 +00001494static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
1495 const char *gate_str, const char *ifname,
1496 const char *flag_str, const char *distance_str)
paul718e3742002-12-13 20:15:29 +00001497{
1498 int ret;
1499 u_char distance;
1500 struct prefix p;
1501 struct in6_addr *gate = NULL;
1502 struct in6_addr gate_addr;
1503 u_char type = 0;
1504 int table = 0;
hasso81dfcaa2003-05-25 19:21:25 +00001505 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00001506
1507 ret = str2prefix (dest_str, &p);
1508 if (ret <= 0)
1509 {
1510 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1511 return CMD_WARNING;
1512 }
1513
1514 /* Apply mask for given prefix. */
1515 apply_mask (&p);
1516
hasso81dfcaa2003-05-25 19:21:25 +00001517 /* Route flags */
1518 if (flag_str) {
1519 switch(flag_str[0]) {
1520 case 'r':
1521 case 'R': /* XXX */
1522 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
1523 break;
1524 case 'b':
1525 case 'B': /* XXX */
1526 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
1527 break;
1528 default:
1529 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00001530 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00001531 }
1532 }
1533
paul718e3742002-12-13 20:15:29 +00001534 /* Administrative distance. */
1535 if (distance_str)
1536 distance = atoi (distance_str);
1537 else
1538 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
1539
1540 /* When gateway is valid IPv6 addrees, then gate is treated as
1541 nexthop address other case gate is treated as interface name. */
1542 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
1543
1544 if (ifname)
1545 {
1546 /* When ifname is specified. It must be come with gateway
1547 address. */
1548 if (ret != 1)
1549 {
1550 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1551 return CMD_WARNING;
1552 }
1553 type = STATIC_IPV6_GATEWAY_IFNAME;
1554 gate = &gate_addr;
1555 }
1556 else
1557 {
1558 if (ret == 1)
1559 {
1560 type = STATIC_IPV6_GATEWAY;
1561 gate = &gate_addr;
1562 }
1563 else
1564 {
1565 type = STATIC_IPV6_IFNAME;
1566 ifname = gate_str;
1567 }
1568 }
1569
1570 if (add_cmd)
hasso81dfcaa2003-05-25 19:21:25 +00001571 static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
paul718e3742002-12-13 20:15:29 +00001572 else
1573 static_delete_ipv6 (&p, type, gate, ifname, distance, table);
1574
1575 return CMD_SUCCESS;
1576}
1577
1578DEFUN (ipv6_route,
1579 ipv6_route_cmd,
1580 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1581 IP_STR
1582 "Establish static routes\n"
1583 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1584 "IPv6 gateway address\n"
1585 "IPv6 gateway interface name\n")
1586{
hasso81dfcaa2003-05-25 19:21:25 +00001587 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
1588}
1589
1590DEFUN (ipv6_route_flags,
1591 ipv6_route_flags_cmd,
1592 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1593 IP_STR
1594 "Establish static routes\n"
1595 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1596 "IPv6 gateway address\n"
1597 "IPv6 gateway interface name\n"
1598 "Emit an ICMP unreachable when matched\n"
1599 "Silently discard pkts when matched\n")
1600{
1601 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
paul718e3742002-12-13 20:15:29 +00001602}
1603
1604DEFUN (ipv6_route_ifname,
1605 ipv6_route_ifname_cmd,
1606 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1607 IP_STR
1608 "Establish static routes\n"
1609 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1610 "IPv6 gateway address\n"
1611 "IPv6 gateway interface name\n")
1612{
hasso81dfcaa2003-05-25 19:21:25 +00001613 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
1614}
1615
1616DEFUN (ipv6_route_ifname_flags,
1617 ipv6_route_ifname_flags_cmd,
1618 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1619 IP_STR
1620 "Establish static routes\n"
1621 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1622 "IPv6 gateway address\n"
1623 "IPv6 gateway interface name\n"
1624 "Emit an ICMP unreachable when matched\n"
1625 "Silently discard pkts when matched\n")
1626{
1627 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +00001628}
1629
1630DEFUN (ipv6_route_pref,
1631 ipv6_route_pref_cmd,
1632 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1633 IP_STR
1634 "Establish static routes\n"
1635 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1636 "IPv6 gateway address\n"
1637 "IPv6 gateway interface name\n"
1638 "Distance value for this prefix\n")
1639{
hasso81dfcaa2003-05-25 19:21:25 +00001640 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
1641}
1642
1643DEFUN (ipv6_route_flags_pref,
1644 ipv6_route_flags_pref_cmd,
1645 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1646 IP_STR
1647 "Establish static routes\n"
1648 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1649 "IPv6 gateway address\n"
1650 "IPv6 gateway interface name\n"
1651 "Emit an ICMP unreachable when matched\n"
1652 "Silently discard pkts when matched\n"
1653 "Distance value for this prefix\n")
1654{
1655 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001656}
1657
1658DEFUN (ipv6_route_ifname_pref,
1659 ipv6_route_ifname_pref_cmd,
1660 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1661 IP_STR
1662 "Establish static routes\n"
1663 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1664 "IPv6 gateway address\n"
1665 "IPv6 gateway interface name\n"
1666 "Distance value for this prefix\n")
1667{
hasso81dfcaa2003-05-25 19:21:25 +00001668 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
1669}
1670
1671DEFUN (ipv6_route_ifname_flags_pref,
1672 ipv6_route_ifname_flags_pref_cmd,
1673 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1674 IP_STR
1675 "Establish static routes\n"
1676 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1677 "IPv6 gateway address\n"
1678 "IPv6 gateway interface name\n"
1679 "Emit an ICMP unreachable when matched\n"
1680 "Silently discard pkts when matched\n"
1681 "Distance value for this prefix\n")
1682{
1683 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001684}
1685
1686DEFUN (no_ipv6_route,
1687 no_ipv6_route_cmd,
1688 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1689 NO_STR
1690 IP_STR
1691 "Establish static routes\n"
1692 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1693 "IPv6 gateway address\n"
1694 "IPv6 gateway interface name\n")
1695{
hasso81dfcaa2003-05-25 19:21:25 +00001696 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001697}
1698
hasso81dfcaa2003-05-25 19:21:25 +00001699ALIAS (no_ipv6_route,
1700 no_ipv6_route_flags_cmd,
1701 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1702 NO_STR
1703 IP_STR
1704 "Establish static routes\n"
1705 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1706 "IPv6 gateway address\n"
1707 "IPv6 gateway interface name\n"
1708 "Emit an ICMP unreachable when matched\n"
1709 "Silently discard pkts when matched\n")
1710
paul718e3742002-12-13 20:15:29 +00001711DEFUN (no_ipv6_route_ifname,
1712 no_ipv6_route_ifname_cmd,
1713 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1714 NO_STR
1715 IP_STR
1716 "Establish static routes\n"
1717 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1718 "IPv6 gateway address\n"
1719 "IPv6 gateway interface name\n")
1720{
hasso81dfcaa2003-05-25 19:21:25 +00001721 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001722}
1723
hasso81dfcaa2003-05-25 19:21:25 +00001724ALIAS (no_ipv6_route_ifname,
1725 no_ipv6_route_ifname_flags_cmd,
1726 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1727 NO_STR
1728 IP_STR
1729 "Establish static routes\n"
1730 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1731 "IPv6 gateway address\n"
1732 "IPv6 gateway interface name\n"
1733 "Emit an ICMP unreachable when matched\n"
1734 "Silently discard pkts when matched\n")
1735
paul718e3742002-12-13 20:15:29 +00001736DEFUN (no_ipv6_route_pref,
1737 no_ipv6_route_pref_cmd,
1738 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1739 NO_STR
1740 IP_STR
1741 "Establish static routes\n"
1742 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1743 "IPv6 gateway address\n"
1744 "IPv6 gateway interface name\n"
1745 "Distance value for this prefix\n")
1746{
hasso81dfcaa2003-05-25 19:21:25 +00001747 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
1748}
1749
1750DEFUN (no_ipv6_route_flags_pref,
1751 no_ipv6_route_flags_pref_cmd,
1752 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1753 NO_STR
1754 IP_STR
1755 "Establish static routes\n"
1756 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1757 "IPv6 gateway address\n"
1758 "IPv6 gateway interface name\n"
1759 "Emit an ICMP unreachable when matched\n"
1760 "Silently discard pkts when matched\n"
1761 "Distance value for this prefix\n")
1762{
1763 /* We do not care about argv[2] */
1764 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001765}
1766
1767DEFUN (no_ipv6_route_ifname_pref,
1768 no_ipv6_route_ifname_pref_cmd,
1769 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1770 NO_STR
1771 IP_STR
1772 "Establish static routes\n"
1773 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1774 "IPv6 gateway address\n"
1775 "IPv6 gateway interface name\n"
1776 "Distance value for this prefix\n")
1777{
hasso81dfcaa2003-05-25 19:21:25 +00001778 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
1779}
1780
1781DEFUN (no_ipv6_route_ifname_flags_pref,
1782 no_ipv6_route_ifname_flags_pref_cmd,
1783 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1784 NO_STR
1785 IP_STR
1786 "Establish static routes\n"
1787 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1788 "IPv6 gateway address\n"
1789 "IPv6 gateway interface name\n"
1790 "Emit an ICMP unreachable when matched\n"
1791 "Silently discard pkts when matched\n"
1792 "Distance value for this prefix\n")
1793{
1794 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001795}
1796
paul595db7f2003-05-25 21:35:06 +00001797/* New RIB. Detailed information for IPv6 route. */
paula1ac18c2005-06-28 17:17:12 +00001798static void
paul718e3742002-12-13 20:15:29 +00001799vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
1800{
1801 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001802 struct nexthop *nexthop, *tnexthop;
1803 int recursing;
paul718e3742002-12-13 20:15:29 +00001804 char buf[BUFSIZ];
1805
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001806 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001807 {
1808 vty_out (vty, "Routing entry for %s/%d%s",
1809 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1810 rn->p.prefixlen,
1811 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001812 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001813 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +00001814 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
1815 vty_out (vty, ", best");
1816 if (rib->refcnt)
1817 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001818 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1819 vty_out (vty, ", blackhole");
1820 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1821 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001822 vty_out (vty, "%s", VTY_NEWLINE);
1823
1824#define ONE_DAY_SECOND 60*60*24
1825#define ONE_WEEK_SECOND 60*60*24*7
1826 if (rib->type == ZEBRA_ROUTE_RIPNG
1827 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001828 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001829 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001830 || rib->type == ZEBRA_ROUTE_BGP)
1831 {
1832 time_t uptime;
1833 struct tm *tm;
1834
1835 uptime = time (NULL);
1836 uptime -= rib->uptime;
1837 tm = gmtime (&uptime);
1838
1839 vty_out (vty, " Last update ");
1840
1841 if (uptime < ONE_DAY_SECOND)
1842 vty_out (vty, "%02d:%02d:%02d",
1843 tm->tm_hour, tm->tm_min, tm->tm_sec);
1844 else if (uptime < ONE_WEEK_SECOND)
1845 vty_out (vty, "%dd%02dh%02dm",
1846 tm->tm_yday, tm->tm_hour, tm->tm_min);
1847 else
1848 vty_out (vty, "%02dw%dd%02dh",
1849 tm->tm_yday/7,
1850 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1851 vty_out (vty, " ago%s", VTY_NEWLINE);
1852 }
1853
Christian Frankefa713d92013-07-05 15:35:37 +00001854 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001855 {
Christian Frankefa713d92013-07-05 15:35:37 +00001856 vty_out (vty, " %c%s",
1857 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1858 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +00001859
1860 switch (nexthop->type)
1861 {
1862 case NEXTHOP_TYPE_IPV6:
1863 case NEXTHOP_TYPE_IPV6_IFINDEX:
1864 case NEXTHOP_TYPE_IPV6_IFNAME:
1865 vty_out (vty, " %s",
1866 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1867 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1868 vty_out (vty, ", %s", nexthop->ifname);
1869 else if (nexthop->ifindex)
1870 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
1871 break;
1872 case NEXTHOP_TYPE_IFINDEX:
1873 vty_out (vty, " directly connected, %s",
1874 ifindex2ifname (nexthop->ifindex));
1875 break;
1876 case NEXTHOP_TYPE_IFNAME:
1877 vty_out (vty, " directly connected, %s",
1878 nexthop->ifname);
1879 break;
1880 default:
1881 break;
1882 }
1883 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1884 vty_out (vty, " inactive");
1885
Christian Frankee8d3d292013-07-05 15:35:39 +00001886 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1887 vty_out (vty, " onlink");
1888
paul718e3742002-12-13 20:15:29 +00001889 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001890 vty_out (vty, " (recursive)");
1891
paul718e3742002-12-13 20:15:29 +00001892 vty_out (vty, "%s", VTY_NEWLINE);
1893 }
1894 vty_out (vty, "%s", VTY_NEWLINE);
1895 }
1896}
1897
paula1ac18c2005-06-28 17:17:12 +00001898static void
paul718e3742002-12-13 20:15:29 +00001899vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
1900 struct rib *rib)
1901{
Christian Frankefa713d92013-07-05 15:35:37 +00001902 struct nexthop *nexthop, *tnexthop;
1903 int recursing;
paul718e3742002-12-13 20:15:29 +00001904 int len = 0;
1905 char buf[BUFSIZ];
1906
1907 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001908 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001909 {
1910 if (nexthop == rib->nexthop)
1911 {
1912 /* Prefix information. */
1913 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +00001914 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001915 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1916 ? '>' : ' ',
1917 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1918 ? '*' : ' ',
1919 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1920 rn->p.prefixlen);
1921
1922 /* Distance and metric display. */
1923 if (rib->type != ZEBRA_ROUTE_CONNECT
1924 && rib->type != ZEBRA_ROUTE_KERNEL)
1925 len += vty_out (vty, " [%d/%d]", rib->distance,
1926 rib->metric);
1927 }
1928 else
1929 vty_out (vty, " %c%*c",
1930 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1931 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001932 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001933
1934 switch (nexthop->type)
1935 {
1936 case NEXTHOP_TYPE_IPV6:
1937 case NEXTHOP_TYPE_IPV6_IFINDEX:
1938 case NEXTHOP_TYPE_IPV6_IFNAME:
1939 vty_out (vty, " via %s",
1940 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1941 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1942 vty_out (vty, ", %s", nexthop->ifname);
1943 else if (nexthop->ifindex)
1944 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
1945 break;
1946 case NEXTHOP_TYPE_IFINDEX:
1947 vty_out (vty, " is directly connected, %s",
1948 ifindex2ifname (nexthop->ifindex));
1949 break;
1950 case NEXTHOP_TYPE_IFNAME:
1951 vty_out (vty, " is directly connected, %s",
1952 nexthop->ifname);
1953 break;
1954 default:
1955 break;
1956 }
1957 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1958 vty_out (vty, " inactive");
1959
1960 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001961 vty_out (vty, " (recursive)");
paul718e3742002-12-13 20:15:29 +00001962
hasso81dfcaa2003-05-25 19:21:25 +00001963 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1964 vty_out (vty, ", bh");
1965 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1966 vty_out (vty, ", rej");
1967
paul718e3742002-12-13 20:15:29 +00001968 if (rib->type == ZEBRA_ROUTE_RIPNG
1969 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001970 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001971 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001972 || rib->type == ZEBRA_ROUTE_BGP)
1973 {
1974 time_t uptime;
1975 struct tm *tm;
1976
1977 uptime = time (NULL);
1978 uptime -= rib->uptime;
1979 tm = gmtime (&uptime);
1980
1981#define ONE_DAY_SECOND 60*60*24
1982#define ONE_WEEK_SECOND 60*60*24*7
1983
1984 if (uptime < ONE_DAY_SECOND)
1985 vty_out (vty, ", %02d:%02d:%02d",
1986 tm->tm_hour, tm->tm_min, tm->tm_sec);
1987 else if (uptime < ONE_WEEK_SECOND)
1988 vty_out (vty, ", %dd%02dh%02dm",
1989 tm->tm_yday, tm->tm_hour, tm->tm_min);
1990 else
1991 vty_out (vty, ", %02dw%dd%02dh",
1992 tm->tm_yday/7,
1993 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1994 }
1995 vty_out (vty, "%s", VTY_NEWLINE);
1996 }
1997}
1998
paul718e3742002-12-13 20:15:29 +00001999DEFUN (show_ipv6_route,
2000 show_ipv6_route_cmd,
2001 "show ipv6 route",
2002 SHOW_STR
2003 IP_STR
2004 "IPv6 routing table\n")
2005{
2006 struct route_table *table;
2007 struct route_node *rn;
2008 struct rib *rib;
2009 int first = 1;
2010
2011 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2012 if (! table)
2013 return CMD_SUCCESS;
2014
2015 /* Show all IPv6 route. */
2016 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002017 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002018 {
2019 if (first)
2020 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002021 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002022 first = 0;
2023 }
2024 vty_show_ipv6_route (vty, rn, rib);
2025 }
2026 return CMD_SUCCESS;
2027}
2028
2029DEFUN (show_ipv6_route_prefix_longer,
2030 show_ipv6_route_prefix_longer_cmd,
2031 "show ipv6 route X:X::X:X/M longer-prefixes",
2032 SHOW_STR
2033 IP_STR
2034 "IPv6 routing table\n"
2035 "IPv6 prefix\n"
2036 "Show route matching the specified Network/Mask pair only\n")
2037{
2038 struct route_table *table;
2039 struct route_node *rn;
2040 struct rib *rib;
2041 struct prefix p;
2042 int ret;
2043 int first = 1;
2044
2045 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2046 if (! table)
2047 return CMD_SUCCESS;
2048
2049 ret = str2prefix (argv[0], &p);
2050 if (! ret)
2051 {
2052 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2053 return CMD_WARNING;
2054 }
2055
2056 /* Show matched type IPv6 routes. */
2057 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002058 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002059 if (prefix_match (&p, &rn->p))
2060 {
2061 if (first)
2062 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002063 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002064 first = 0;
2065 }
2066 vty_show_ipv6_route (vty, rn, rib);
2067 }
2068 return CMD_SUCCESS;
2069}
2070
2071DEFUN (show_ipv6_route_protocol,
2072 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02002073 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00002074 SHOW_STR
2075 IP_STR
2076 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02002077 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00002078{
2079 int type;
2080 struct route_table *table;
2081 struct route_node *rn;
2082 struct rib *rib;
2083 int first = 1;
2084
David Lampartere0ca5fd2009-09-16 01:52:42 +02002085 type = proto_redistnum (AFI_IP6, argv[0]);
2086 if (type < 0)
paul718e3742002-12-13 20:15:29 +00002087 {
2088 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2089 return CMD_WARNING;
2090 }
2091
2092 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2093 if (! table)
2094 return CMD_SUCCESS;
2095
2096 /* Show matched type IPv6 routes. */
2097 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002098 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002099 if (rib->type == type)
2100 {
2101 if (first)
2102 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002103 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002104 first = 0;
2105 }
2106 vty_show_ipv6_route (vty, rn, rib);
2107 }
2108 return CMD_SUCCESS;
2109}
2110
2111DEFUN (show_ipv6_route_addr,
2112 show_ipv6_route_addr_cmd,
2113 "show ipv6 route X:X::X:X",
2114 SHOW_STR
2115 IP_STR
2116 "IPv6 routing table\n"
2117 "IPv6 Address\n")
2118{
2119 int ret;
2120 struct prefix_ipv6 p;
2121 struct route_table *table;
2122 struct route_node *rn;
2123
2124 ret = str2prefix_ipv6 (argv[0], &p);
2125 if (ret <= 0)
2126 {
2127 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
2128 return CMD_WARNING;
2129 }
2130
2131 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2132 if (! table)
2133 return CMD_SUCCESS;
2134
2135 rn = route_node_match (table, (struct prefix *) &p);
2136 if (! rn)
2137 {
2138 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2139 return CMD_WARNING;
2140 }
2141
2142 vty_show_ipv6_route_detail (vty, rn);
2143
2144 route_unlock_node (rn);
2145
2146 return CMD_SUCCESS;
2147}
2148
2149DEFUN (show_ipv6_route_prefix,
2150 show_ipv6_route_prefix_cmd,
2151 "show ipv6 route X:X::X:X/M",
2152 SHOW_STR
2153 IP_STR
2154 "IPv6 routing table\n"
2155 "IPv6 prefix\n")
2156{
2157 int ret;
2158 struct prefix_ipv6 p;
2159 struct route_table *table;
2160 struct route_node *rn;
2161
2162 ret = str2prefix_ipv6 (argv[0], &p);
2163 if (ret <= 0)
2164 {
2165 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
2166 return CMD_WARNING;
2167 }
2168
2169 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2170 if (! table)
2171 return CMD_SUCCESS;
2172
2173 rn = route_node_match (table, (struct prefix *) &p);
2174 if (! rn || rn->p.prefixlen != p.prefixlen)
2175 {
2176 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00002177 if (rn)
2178 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00002179 return CMD_WARNING;
2180 }
2181
2182 vty_show_ipv6_route_detail (vty, rn);
2183
2184 route_unlock_node (rn);
2185
2186 return CMD_SUCCESS;
2187}
2188
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002189/* Show route summary. */
2190DEFUN (show_ipv6_route_summary,
2191 show_ipv6_route_summary_cmd,
2192 "show ipv6 route summary",
2193 SHOW_STR
2194 IP_STR
2195 "IPv6 routing table\n"
2196 "Summary of all IPv6 routes\n")
2197{
2198 struct route_table *table;
2199
2200 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2201 if (! table)
2202 return CMD_SUCCESS;
2203
2204 vty_show_ip_route_summary (vty, table);
2205
2206 return CMD_SUCCESS;
2207}
2208
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002209/* Show ipv6 route summary prefix. */
2210DEFUN (show_ipv6_route_summary_prefix,
2211 show_ipv6_route_summary_prefix_cmd,
2212 "show ipv6 route summary prefix",
2213 SHOW_STR
2214 IP_STR
2215 "IPv6 routing table\n"
2216 "Summary of all IPv6 routes\n"
2217 "Prefix routes\n")
2218{
2219 struct route_table *table;
2220
2221 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2222 if (! table)
2223 return CMD_SUCCESS;
2224
2225 vty_show_ip_route_summary_prefix (vty, table);
2226
2227 return CMD_SUCCESS;
2228}
2229
G.Balajicddf3912011-11-26 21:59:32 +04002230/*
G.Balajicddf3912011-11-26 21:59:32 +04002231 * Show IPv6 mroute command.Used to dump
2232 * the Multicast routing table.
2233 */
2234
2235DEFUN (show_ipv6_mroute,
2236 show_ipv6_mroute_cmd,
2237 "show ipv6 mroute",
2238 SHOW_STR
2239 IP_STR
2240 "IPv6 Multicast routing table\n")
2241{
2242 struct route_table *table;
2243 struct route_node *rn;
2244 struct rib *rib;
2245 int first = 1;
2246
2247 table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0);
2248 if (! table)
2249 return CMD_SUCCESS;
2250
2251 /* Show all IPv6 route. */
2252 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002253 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04002254 {
2255 if (first)
2256 {
G.Balajicb32fd62011-11-27 20:09:40 +05302257 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04002258 first = 0;
2259 }
2260 vty_show_ipv6_route (vty, rn, rib);
2261 }
2262 return CMD_SUCCESS;
2263}
2264
paul718e3742002-12-13 20:15:29 +00002265/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002266static int
paul718e3742002-12-13 20:15:29 +00002267static_config_ipv6 (struct vty *vty)
2268{
2269 struct route_node *rn;
2270 struct static_ipv6 *si;
2271 int write;
2272 char buf[BUFSIZ];
2273 struct route_table *stable;
2274
2275 write = 0;
2276
2277 /* Lookup table. */
2278 stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0);
2279 if (! stable)
2280 return -1;
2281
2282 for (rn = route_top (stable); rn; rn = route_next (rn))
2283 for (si = rn->info; si; si = si->next)
2284 {
2285 vty_out (vty, "ipv6 route %s/%d",
2286 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
2287 rn->p.prefixlen);
2288
2289 switch (si->type)
2290 {
2291 case STATIC_IPV6_GATEWAY:
2292 vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
2293 break;
2294 case STATIC_IPV6_IFNAME:
2295 vty_out (vty, " %s", si->ifname);
2296 break;
2297 case STATIC_IPV6_GATEWAY_IFNAME:
2298 vty_out (vty, " %s %s",
2299 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
2300 break;
2301 }
2302
hasso81dfcaa2003-05-25 19:21:25 +00002303 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2304 vty_out (vty, " %s", "reject");
2305
2306 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2307 vty_out (vty, " %s", "blackhole");
2308
paul718e3742002-12-13 20:15:29 +00002309 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2310 vty_out (vty, " %d", si->distance);
2311 vty_out (vty, "%s", VTY_NEWLINE);
2312
2313 write = 1;
2314 }
2315 return write;
2316}
2317#endif /* HAVE_IPV6 */
2318
2319/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00002320static int
paul718e3742002-12-13 20:15:29 +00002321zebra_ip_config (struct vty *vty)
2322{
2323 int write = 0;
2324
Everton Marques33d86db2014-07-14 11:19:00 -03002325 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
2326 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00002327#ifdef HAVE_IPV6
2328 write += static_config_ipv6 (vty);
2329#endif /* HAVE_IPV6 */
2330
2331 return write;
2332}
2333
David Lamparterbd078122015-01-06 19:53:24 +01002334static int config_write_vty(struct vty *vty)
2335{
Paul Jakma7514fb72007-05-02 16:05:35 +00002336 int i;
David Lamparterbd078122015-01-06 19:53:24 +01002337 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
2338
2339 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
2340 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
2341 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
2342 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
2343 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
2344 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
2345 "longer-prefix",
2346 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00002347
2348 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2349 {
2350 if (proto_rm[AFI_IP][i])
2351 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
2352 proto_rm[AFI_IP][i], VTY_NEWLINE);
2353 }
2354 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
2355 vty_out (vty, "ip protocol %s route-map %s%s", "any",
2356 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
2357
2358 return 1;
2359}
2360
2361/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002362static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00002363
paul718e3742002-12-13 20:15:29 +00002364/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002365static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00002366
2367/* Route VTY. */
2368void
paula1ac18c2005-06-28 17:17:12 +00002369zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00002370{
2371 install_node (&ip_node, zebra_ip_config);
David Lamparterbd078122015-01-06 19:53:24 +01002372 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00002373
Everton Marques33d86db2014-07-14 11:19:00 -03002374 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01002375 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques33d86db2014-07-14 11:19:00 -03002376 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lampartera76681b2015-01-22 19:03:53 +01002377 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparterbd078122015-01-06 19:53:24 +01002378 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
2379 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
2380 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00002381 install_element (CONFIG_NODE, &ip_protocol_cmd);
2382 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
2383 install_element (VIEW_NODE, &show_ip_protocol_cmd);
2384 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00002385 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002386 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002387 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002388 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002389 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002390 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002391 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002392 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002393 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002394 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002395 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002396 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002397 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002398 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002399 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002400 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002401 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002402 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002403 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002404 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002405 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002406 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002407 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002408
2409 install_element (VIEW_NODE, &show_ip_route_cmd);
2410 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
2411 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
2412 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
2413 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
2414 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002415 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002416 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002417 install_element (ENABLE_NODE, &show_ip_route_cmd);
2418 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
2419 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
2420 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
2421 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
2422 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00002423 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002424 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002425
G.Balajicddf3912011-11-26 21:59:32 +04002426 install_element (VIEW_NODE, &show_ip_mroute_cmd);
2427 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
2428
Everton Marques33d86db2014-07-14 11:19:00 -03002429 install_element (VIEW_NODE, &show_ip_rpf_cmd);
2430 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparter3b02fe82015-01-22 19:12:35 +01002431 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
2432 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002433
paul718e3742002-12-13 20:15:29 +00002434#ifdef HAVE_IPV6
2435 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002436 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002437 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002438 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002439 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002440 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002441 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002442 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002443 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002444 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002445 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002446 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002447 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002448 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002449 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002450 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002451 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002452 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002453 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002454 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
2455 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
2456 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
2457 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
2458 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
2459 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
2460 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
2461 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
2462 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002463 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002464 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002465
2466 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
2467 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
paul718e3742002-12-13 20:15:29 +00002468#endif /* HAVE_IPV6 */
2469}