blob: 29c01c3ca0e52522500ac6506667c3fd8577a0f8 [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 Marques96bb2662014-07-14 11:19:00 -030033static int do_show_ip_route(struct vty *vty, safi_t safi);
David Lamparterca2b1052015-01-22 19:12:35 +010034static void vty_show_ip_route_detail (struct vty *vty, struct route_node *rn,
35 int mcast);
Everton Marques96bb2662014-07-14 11:19:00 -030036
37/* General function for static route. */
paula1ac18c2005-06-28 17:17:12 +000038static int
Everton Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Marques96bb2662014-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 Lamparter9e6366d2015-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 Marques96bb2662014-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 Lamparter9e6366d2015-01-22 19:03:53 +0100157 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1],
158 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques96bb2662014-07-14 11:19:00 -0300159}
160
David Lamparter9e6366d2015-01-22 19:03:53 +0100161ALIAS (ip_mroute_dist,
162 ip_mroute_cmd,
163 "ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
164 IP_STR
165 "Configure static unicast route into MRIB for multicast RPF lookup\n"
166 "IP destination prefix (e.g. 10.0.0.0/8)\n"
167 "Nexthop address\n"
168 "Nexthop interface name\n")
169
170DEFUN (no_ip_mroute_dist,
171 no_ip_mroute_dist_cmd,
172 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>",
Everton Marques96bb2662014-07-14 11:19:00 -0300173 IP_STR
174 "Configure static unicast route into MRIB for multicast RPF lookup\n"
175 "IP destination prefix (e.g. 10.0.0.0/8)\n"
176 "Nexthop address\n"
177 "Nexthop interface name\n"
178 "Distance\n")
179{
David Lamparter9e6366d2015-01-22 19:03:53 +0100180 return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1],
181 NULL, argc > 2 ? argv[2] : NULL);
Everton Marques96bb2662014-07-14 11:19:00 -0300182}
183
David Lamparter9e6366d2015-01-22 19:03:53 +0100184ALIAS (no_ip_mroute_dist,
185 no_ip_mroute_cmd,
186 "no ip mroute A.B.C.D/M (A.B.C.D|INTERFACE)",
187 NO_STR
188 IP_STR
189 "Configure static unicast route into MRIB for multicast RPF lookup\n"
190 "IP destination prefix (e.g. 10.0.0.0/8)\n"
191 "Nexthop address\n"
192 "Nexthop interface name\n")
193
David Lamparter240c56f2015-01-06 19:53:24 +0100194DEFUN (ip_multicast_mode,
195 ip_multicast_mode_cmd,
196 "ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
197 IP_STR
198 "Multicast options\n"
199 "RPF lookup behavior\n"
200 "Lookup in unicast RIB only\n"
201 "Lookup in multicast RIB only\n"
202 "Try multicast RIB first, fall back to unicast RIB\n"
203 "Lookup both, use entry with lower distance\n"
204 "Lookup both, use entry with longer prefix\n")
205{
206 if (!strncmp (argv[0], "u", 1))
207 multicast_mode_ipv4_set (MCAST_URIB_ONLY);
208 else if (!strncmp (argv[0], "mrib-o", 6))
209 multicast_mode_ipv4_set (MCAST_MRIB_ONLY);
210 else if (!strncmp (argv[0], "mrib-t", 6))
211 multicast_mode_ipv4_set (MCAST_MIX_MRIB_FIRST);
212 else if (!strncmp (argv[0], "low", 3))
213 multicast_mode_ipv4_set (MCAST_MIX_DISTANCE);
214 else if (!strncmp (argv[0], "lon", 3))
215 multicast_mode_ipv4_set (MCAST_MIX_PFXLEN);
216 else
217 {
218 vty_out (vty, "Invalid mode specified%s", VTY_NEWLINE);
219 return CMD_WARNING;
220 }
221
222 return CMD_SUCCESS;
223}
224
225DEFUN (no_ip_multicast_mode,
226 no_ip_multicast_mode_cmd,
227 "no ip multicast rpf-lookup-mode (urib-only|mrib-only|mrib-then-urib|lower-distance|longer-prefix)",
228 NO_STR
229 IP_STR
230 "Multicast options\n"
231 "RPF lookup behavior\n"
232 "Lookup in unicast RIB only\n"
233 "Lookup in multicast RIB only\n"
234 "Try multicast RIB first, fall back to unicast RIB\n"
235 "Lookup both, use entry with lower distance\n"
236 "Lookup both, use entry with longer prefix\n")
237{
238 multicast_mode_ipv4_set (MCAST_NO_CONFIG);
239 return CMD_SUCCESS;
240}
241
242ALIAS (no_ip_multicast_mode,
243 no_ip_multicast_mode_noarg_cmd,
244 "no ip multicast rpf-lookup-mode",
245 NO_STR
246 IP_STR
247 "Multicast options\n"
248 "RPF lookup behavior\n")
249
Everton Marques96bb2662014-07-14 11:19:00 -0300250DEFUN (show_ip_rpf,
251 show_ip_rpf_cmd,
252 "show ip rpf",
253 SHOW_STR
254 IP_STR
255 "Display RPF information for multicast source\n")
256{
257 return do_show_ip_route(vty, SAFI_MULTICAST);
258}
259
David Lamparterca2b1052015-01-22 19:12:35 +0100260DEFUN (show_ip_rpf_addr,
261 show_ip_rpf_addr_cmd,
262 "show ip rpf A.B.C.D",
263 SHOW_STR
264 IP_STR
265 "Display RPF information for multicast source\n"
266 "IP multicast source address (e.g. 10.0.0.0)\n")
267{
268 struct in_addr addr;
269 struct route_node *rn;
270 struct rib *rib;
271 int ret;
272
273 ret = inet_aton (argv[0], &addr);
274 if (ret == 0)
275 {
276 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
277 return CMD_WARNING;
278 }
279
280 rib = rib_match_ipv4_multicast (addr, &rn);
281
282 if (rib)
283 vty_show_ip_route_detail (vty, rn, 1);
284 else
285 vty_out (vty, "%% No match for RPF lookup%s", VTY_NEWLINE);
286
287 return CMD_SUCCESS;
288}
289
paul718e3742002-12-13 20:15:29 +0000290/* Static route configuration. */
291DEFUN (ip_route,
292 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000293 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000294 IP_STR
295 "Establish static routes\n"
296 "IP destination prefix (e.g. 10.0.0.0/8)\n"
297 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000298 "IP gateway interface name\n"
299 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000300{
301 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
302}
303
304DEFUN (ip_route_flags,
305 ip_route_flags_cmd,
306 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000307 IP_STR
308 "Establish static routes\n"
309 "IP destination prefix (e.g. 10.0.0.0/8)\n"
310 "IP gateway address\n"
311 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000312 "Emit an ICMP unreachable when matched\n"
313 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000314{
hasso81dfcaa2003-05-25 19:21:25 +0000315 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
paul718e3742002-12-13 20:15:29 +0000316}
317
hasso457ef552003-05-28 12:02:15 +0000318DEFUN (ip_route_flags2,
319 ip_route_flags2_cmd,
320 "ip route A.B.C.D/M (reject|blackhole)",
321 IP_STR
322 "Establish static routes\n"
323 "IP destination prefix (e.g. 10.0.0.0/8)\n"
324 "Emit an ICMP unreachable when matched\n"
325 "Silently discard pkts when matched\n")
326{
327 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
328}
329
paul718e3742002-12-13 20:15:29 +0000330/* Mask as A.B.C.D format. */
331DEFUN (ip_route_mask,
332 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000333 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000334 IP_STR
335 "Establish static routes\n"
336 "IP destination prefix\n"
337 "IP destination prefix mask\n"
338 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000339 "IP gateway interface name\n"
340 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000341{
342 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
343}
344
345DEFUN (ip_route_mask_flags,
346 ip_route_mask_flags_cmd,
347 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000348 IP_STR
349 "Establish static routes\n"
350 "IP destination prefix\n"
351 "IP destination prefix mask\n"
352 "IP gateway address\n"
353 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000354 "Emit an ICMP unreachable when matched\n"
355 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000356{
hasso81dfcaa2003-05-25 19:21:25 +0000357 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000358}
359
hasso457ef552003-05-28 12:02:15 +0000360DEFUN (ip_route_mask_flags2,
361 ip_route_mask_flags2_cmd,
362 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
363 IP_STR
364 "Establish static routes\n"
365 "IP destination prefix\n"
366 "IP destination prefix mask\n"
367 "Emit an ICMP unreachable when matched\n"
368 "Silently discard pkts when matched\n")
369{
370 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
371}
372
paul718e3742002-12-13 20:15:29 +0000373/* Distance option value. */
374DEFUN (ip_route_distance,
375 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000376 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000377 IP_STR
378 "Establish static routes\n"
379 "IP destination prefix (e.g. 10.0.0.0/8)\n"
380 "IP gateway address\n"
381 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000382 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000383 "Distance value for this route\n")
384{
hasso81dfcaa2003-05-25 19:21:25 +0000385 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
386}
387
388DEFUN (ip_route_flags_distance,
389 ip_route_flags_distance_cmd,
390 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
391 IP_STR
392 "Establish static routes\n"
393 "IP destination prefix (e.g. 10.0.0.0/8)\n"
394 "IP gateway address\n"
395 "IP gateway interface name\n"
396 "Emit an ICMP unreachable when matched\n"
397 "Silently discard pkts when matched\n"
398 "Distance value for this route\n")
399{
400 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000401}
402
hasso457ef552003-05-28 12:02:15 +0000403DEFUN (ip_route_flags_distance2,
404 ip_route_flags_distance2_cmd,
405 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
406 IP_STR
407 "Establish static routes\n"
408 "IP destination prefix (e.g. 10.0.0.0/8)\n"
409 "Emit an ICMP unreachable when matched\n"
410 "Silently discard pkts when matched\n"
411 "Distance value for this route\n")
412{
413 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
414}
415
paul718e3742002-12-13 20:15:29 +0000416DEFUN (ip_route_mask_distance,
417 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000418 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000419 IP_STR
420 "Establish static routes\n"
421 "IP destination prefix\n"
422 "IP destination prefix mask\n"
423 "IP gateway address\n"
424 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000425 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000426 "Distance value for this route\n")
427{
hasso81dfcaa2003-05-25 19:21:25 +0000428 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
429}
430
431DEFUN (ip_route_mask_flags_distance,
432 ip_route_mask_flags_distance_cmd,
433 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
434 IP_STR
435 "Establish static routes\n"
436 "IP destination prefix\n"
437 "IP destination prefix mask\n"
438 "IP gateway address\n"
439 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000440 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000441 "Silently discard pkts when matched\n"
442 "Distance value for this route\n")
hasso81dfcaa2003-05-25 19:21:25 +0000443{
444 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000445}
446
hasso457ef552003-05-28 12:02:15 +0000447DEFUN (ip_route_mask_flags_distance2,
448 ip_route_mask_flags_distance2_cmd,
449 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
450 IP_STR
451 "Establish static routes\n"
452 "IP destination prefix\n"
453 "IP destination prefix mask\n"
hasso457ef552003-05-28 12:02:15 +0000454 "Emit an ICMP unreachable when matched\n"
Christian Franke2b005152013-09-30 12:27:49 +0000455 "Silently discard pkts when matched\n"
456 "Distance value for this route\n")
hasso457ef552003-05-28 12:02:15 +0000457{
458 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
459}
460
paul718e3742002-12-13 20:15:29 +0000461DEFUN (no_ip_route,
462 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000463 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000464 NO_STR
465 IP_STR
466 "Establish static routes\n"
467 "IP destination prefix (e.g. 10.0.0.0/8)\n"
468 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000469 "IP gateway interface name\n"
470 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000471{
472 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
473}
474
475ALIAS (no_ip_route,
476 no_ip_route_flags_cmd,
477 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000478 NO_STR
479 IP_STR
480 "Establish static routes\n"
481 "IP destination prefix (e.g. 10.0.0.0/8)\n"
482 "IP gateway address\n"
483 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000484 "Emit an ICMP unreachable when matched\n"
485 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000486
hasso457ef552003-05-28 12:02:15 +0000487DEFUN (no_ip_route_flags2,
488 no_ip_route_flags2_cmd,
489 "no ip route A.B.C.D/M (reject|blackhole)",
490 NO_STR
491 IP_STR
492 "Establish static routes\n"
493 "IP destination prefix (e.g. 10.0.0.0/8)\n"
494 "Emit an ICMP unreachable when matched\n"
495 "Silently discard pkts when matched\n")
496{
497 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
498}
499
paul718e3742002-12-13 20:15:29 +0000500DEFUN (no_ip_route_mask,
501 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000502 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000503 NO_STR
504 IP_STR
505 "Establish static routes\n"
506 "IP destination prefix\n"
507 "IP destination prefix mask\n"
508 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000509 "IP gateway interface name\n"
510 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000511{
512 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
513}
514
515ALIAS (no_ip_route_mask,
516 no_ip_route_mask_flags_cmd,
517 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000518 NO_STR
519 IP_STR
520 "Establish static routes\n"
521 "IP destination prefix\n"
522 "IP destination prefix mask\n"
523 "IP gateway address\n"
524 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000525 "Emit an ICMP unreachable when matched\n"
526 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000527
hasso457ef552003-05-28 12:02:15 +0000528DEFUN (no_ip_route_mask_flags2,
529 no_ip_route_mask_flags2_cmd,
530 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
531 NO_STR
532 IP_STR
533 "Establish static routes\n"
534 "IP destination prefix\n"
535 "IP destination prefix mask\n"
536 "Emit an ICMP unreachable when matched\n"
537 "Silently discard pkts when matched\n")
538{
539 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
540}
541
paul718e3742002-12-13 20:15:29 +0000542DEFUN (no_ip_route_distance,
543 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000544 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000545 NO_STR
546 IP_STR
547 "Establish static routes\n"
548 "IP destination prefix (e.g. 10.0.0.0/8)\n"
549 "IP gateway address\n"
550 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000551 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000552 "Distance value for this route\n")
553{
hasso81dfcaa2003-05-25 19:21:25 +0000554 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
555}
556
557DEFUN (no_ip_route_flags_distance,
558 no_ip_route_flags_distance_cmd,
559 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
560 NO_STR
561 IP_STR
562 "Establish static routes\n"
563 "IP destination prefix (e.g. 10.0.0.0/8)\n"
564 "IP gateway address\n"
565 "IP gateway interface name\n"
566 "Emit an ICMP unreachable when matched\n"
567 "Silently discard pkts when matched\n"
568 "Distance value for this route\n")
569{
570 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000571}
572
hasso457ef552003-05-28 12:02:15 +0000573DEFUN (no_ip_route_flags_distance2,
574 no_ip_route_flags_distance2_cmd,
575 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
576 NO_STR
577 IP_STR
578 "Establish static routes\n"
579 "IP destination prefix (e.g. 10.0.0.0/8)\n"
580 "Emit an ICMP unreachable when matched\n"
581 "Silently discard pkts when matched\n"
582 "Distance value for this route\n")
583{
584 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
585}
586
paul718e3742002-12-13 20:15:29 +0000587DEFUN (no_ip_route_mask_distance,
588 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000589 "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 +0000590 NO_STR
591 IP_STR
592 "Establish static routes\n"
593 "IP destination prefix\n"
594 "IP destination prefix mask\n"
595 "IP gateway address\n"
596 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000597 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000598 "Distance value for this route\n")
599{
hasso81dfcaa2003-05-25 19:21:25 +0000600 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
601}
602
603DEFUN (no_ip_route_mask_flags_distance,
604 no_ip_route_mask_flags_distance_cmd,
605 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
606 NO_STR
607 IP_STR
608 "Establish static routes\n"
609 "IP destination prefix\n"
610 "IP destination prefix mask\n"
611 "IP gateway address\n"
612 "IP gateway interface name\n"
613 "Emit an ICMP unreachable when matched\n"
614 "Silently discard pkts when matched\n"
615 "Distance value for this route\n")
616{
617 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000618}
619
hasso457ef552003-05-28 12:02:15 +0000620DEFUN (no_ip_route_mask_flags_distance2,
621 no_ip_route_mask_flags_distance2_cmd,
622 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
623 NO_STR
624 IP_STR
625 "Establish static routes\n"
626 "IP destination prefix\n"
627 "IP destination prefix mask\n"
628 "Emit an ICMP unreachable when matched\n"
629 "Silently discard pkts when matched\n"
630 "Distance value for this route\n")
631{
632 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
633}
634
Paul Jakma7514fb72007-05-02 16:05:35 +0000635char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
636
637DEFUN (ip_protocol,
638 ip_protocol_cmd,
639 "ip protocol PROTO route-map ROUTE-MAP",
640 NO_STR
641 "Apply route map to PROTO\n"
642 "Protocol name\n"
643 "Route map name\n")
644{
645 int i;
646
647 if (strcasecmp(argv[0], "any") == 0)
648 i = ZEBRA_ROUTE_MAX;
649 else
650 i = proto_name2num(argv[0]);
651 if (i < 0)
652 {
653 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
654 VTY_NEWLINE);
655 return CMD_WARNING;
656 }
657 if (proto_rm[AFI_IP][i])
658 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
659 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
660 return CMD_SUCCESS;
661}
662
663DEFUN (no_ip_protocol,
664 no_ip_protocol_cmd,
665 "no ip protocol PROTO",
666 NO_STR
667 "Remove route map from PROTO\n"
668 "Protocol name\n")
669{
670 int i;
671
672 if (strcasecmp(argv[0], "any") == 0)
673 i = ZEBRA_ROUTE_MAX;
674 else
675 i = proto_name2num(argv[0]);
676 if (i < 0)
677 {
678 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
679 VTY_NEWLINE);
680 return CMD_WARNING;
681 }
682 if (proto_rm[AFI_IP][i])
683 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
684 proto_rm[AFI_IP][i] = NULL;
685 return CMD_SUCCESS;
686}
687
paul718e3742002-12-13 20:15:29 +0000688/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +0000689static void
David Lamparterca2b1052015-01-22 19:12:35 +0100690vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast)
paul718e3742002-12-13 20:15:29 +0000691{
692 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +0000693 struct nexthop *nexthop, *tnexthop;
694 int recursing;
paul718e3742002-12-13 20:15:29 +0000695
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000696 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000697 {
David Lamparterca2b1052015-01-22 19:12:35 +0100698 const char *mcast_info;
699 if (mcast)
700 {
701 rib_table_info_t *info = rn->table->info;
702 mcast_info = (info->safi == SAFI_MULTICAST)
703 ? " using Multicast RIB"
704 : " using Unicast RIB";
705 }
706 vty_out (vty, "Routing entry for %s/%d%s%s",
707 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, mcast_info,
paul718e3742002-12-13 20:15:29 +0000708 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +0000709 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +0200710 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +0000711 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
712 vty_out (vty, ", best");
713 if (rib->refcnt)
714 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +0000715 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
716 vty_out (vty, ", blackhole");
717 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
718 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +0000719 vty_out (vty, "%s", VTY_NEWLINE);
720
721#define ONE_DAY_SECOND 60*60*24
722#define ONE_WEEK_SECOND 60*60*24*7
723 if (rib->type == ZEBRA_ROUTE_RIP
724 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100725 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000726 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000727 || rib->type == ZEBRA_ROUTE_BGP)
728 {
729 time_t uptime;
730 struct tm *tm;
731
732 uptime = time (NULL);
733 uptime -= rib->uptime;
734 tm = gmtime (&uptime);
735
736 vty_out (vty, " Last update ");
737
738 if (uptime < ONE_DAY_SECOND)
739 vty_out (vty, "%02d:%02d:%02d",
740 tm->tm_hour, tm->tm_min, tm->tm_sec);
741 else if (uptime < ONE_WEEK_SECOND)
742 vty_out (vty, "%dd%02dh%02dm",
743 tm->tm_yday, tm->tm_hour, tm->tm_min);
744 else
745 vty_out (vty, "%02dw%dd%02dh",
746 tm->tm_yday/7,
747 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
748 vty_out (vty, " ago%s", VTY_NEWLINE);
749 }
750
Christian Frankefa713d92013-07-05 15:35:37 +0000751 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000752 {
Paul Jakma7514fb72007-05-02 16:05:35 +0000753 char addrstr[32];
754
Christian Frankefa713d92013-07-05 15:35:37 +0000755 vty_out (vty, " %c%s",
756 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
757 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +0000758
759 switch (nexthop->type)
760 {
761 case NEXTHOP_TYPE_IPV4:
762 case NEXTHOP_TYPE_IPV4_IFINDEX:
763 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
764 if (nexthop->ifindex)
765 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
766 break;
767 case NEXTHOP_TYPE_IFINDEX:
768 vty_out (vty, " directly connected, %s",
769 ifindex2ifname (nexthop->ifindex));
770 break;
771 case NEXTHOP_TYPE_IFNAME:
772 vty_out (vty, " directly connected, %s", nexthop->ifname);
773 break;
paul595db7f2003-05-25 21:35:06 +0000774 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000775 vty_out (vty, " directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000776 break;
paul7021c422003-07-15 12:52:22 +0000777 default:
paul718e3742002-12-13 20:15:29 +0000778 break;
779 }
780 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
781 vty_out (vty, " inactive");
782
Christian Frankee8d3d292013-07-05 15:35:39 +0000783 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
784 vty_out (vty, " onlink");
785
paul718e3742002-12-13 20:15:29 +0000786 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000787 vty_out (vty, " (recursive)");
Christian Franke5b9f5182013-05-25 14:01:34 +0000788
Paul Jakma7514fb72007-05-02 16:05:35 +0000789 switch (nexthop->type)
790 {
791 case NEXTHOP_TYPE_IPV4:
792 case NEXTHOP_TYPE_IPV4_IFINDEX:
793 case NEXTHOP_TYPE_IPV4_IFNAME:
794 if (nexthop->src.ipv4.s_addr)
795 {
796 if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
797 sizeof addrstr))
798 vty_out (vty, ", src %s", addrstr);
799 }
800 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000801#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000802 case NEXTHOP_TYPE_IPV6:
803 case NEXTHOP_TYPE_IPV6_IFINDEX:
804 case NEXTHOP_TYPE_IPV6_IFNAME:
805 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
806 {
807 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
808 sizeof addrstr))
809 vty_out (vty, ", src %s", addrstr);
810 }
811 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000812#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000813 default:
814 break;
815 }
paul718e3742002-12-13 20:15:29 +0000816 vty_out (vty, "%s", VTY_NEWLINE);
817 }
818 vty_out (vty, "%s", VTY_NEWLINE);
819 }
820}
821
paula1ac18c2005-06-28 17:17:12 +0000822static void
paul718e3742002-12-13 20:15:29 +0000823vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
824{
Christian Frankefa713d92013-07-05 15:35:37 +0000825 struct nexthop *nexthop, *tnexthop;
826 int recursing;
paul718e3742002-12-13 20:15:29 +0000827 int len = 0;
828 char buf[BUFSIZ];
829
830 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +0000831 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +0000832 {
833 if (nexthop == rib->nexthop)
834 {
835 /* Prefix information. */
836 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +0000837 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +0000838 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
839 ? '>' : ' ',
840 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
841 ? '*' : ' ',
842 inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ),
843 rn->p.prefixlen);
844
845 /* Distance and metric display. */
846 if (rib->type != ZEBRA_ROUTE_CONNECT
847 && rib->type != ZEBRA_ROUTE_KERNEL)
848 len += vty_out (vty, " [%d/%d]", rib->distance,
849 rib->metric);
850 }
851 else
852 vty_out (vty, " %c%*c",
853 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
854 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +0000855 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +0000856
857 switch (nexthop->type)
858 {
859 case NEXTHOP_TYPE_IPV4:
860 case NEXTHOP_TYPE_IPV4_IFINDEX:
861 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
862 if (nexthop->ifindex)
863 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
864 break;
865 case NEXTHOP_TYPE_IFINDEX:
866 vty_out (vty, " is directly connected, %s",
867 ifindex2ifname (nexthop->ifindex));
868 break;
869 case NEXTHOP_TYPE_IFNAME:
870 vty_out (vty, " is directly connected, %s", nexthop->ifname);
871 break;
paul595db7f2003-05-25 21:35:06 +0000872 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000873 vty_out (vty, " is directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000874 break;
paul7021c422003-07-15 12:52:22 +0000875 default:
paul718e3742002-12-13 20:15:29 +0000876 break;
877 }
878 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
879 vty_out (vty, " inactive");
880
Christian Frankee8d3d292013-07-05 15:35:39 +0000881 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
882 vty_out (vty, " onlink");
883
paul718e3742002-12-13 20:15:29 +0000884 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +0000885 vty_out (vty, " (recursive)");
886
Paul Jakma7514fb72007-05-02 16:05:35 +0000887 switch (nexthop->type)
888 {
889 case NEXTHOP_TYPE_IPV4:
890 case NEXTHOP_TYPE_IPV4_IFINDEX:
891 case NEXTHOP_TYPE_IPV4_IFNAME:
892 if (nexthop->src.ipv4.s_addr)
893 {
894 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
895 vty_out (vty, ", src %s", buf);
896 }
897 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000898#ifdef HAVE_IPV6
Paul Jakma7514fb72007-05-02 16:05:35 +0000899 case NEXTHOP_TYPE_IPV6:
900 case NEXTHOP_TYPE_IPV6_IFINDEX:
901 case NEXTHOP_TYPE_IPV6_IFNAME:
902 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
903 {
904 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
905 vty_out (vty, ", src %s", buf);
906 }
907 break;
Andrew J. Schorr09303312007-05-30 20:10:34 +0000908#endif /* HAVE_IPV6 */
Paul Jakma7514fb72007-05-02 16:05:35 +0000909 default:
910 break;
911 }
paul718e3742002-12-13 20:15:29 +0000912
hasso81dfcaa2003-05-25 19:21:25 +0000913 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
914 vty_out (vty, ", bh");
915 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
916 vty_out (vty, ", rej");
917
paul718e3742002-12-13 20:15:29 +0000918 if (rib->type == ZEBRA_ROUTE_RIP
919 || rib->type == ZEBRA_ROUTE_OSPF
Juliusz Chroboczek578ce372012-02-09 13:42:28 +0100920 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +0000921 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000922 || rib->type == ZEBRA_ROUTE_BGP)
923 {
924 time_t uptime;
925 struct tm *tm;
926
927 uptime = time (NULL);
928 uptime -= rib->uptime;
929 tm = gmtime (&uptime);
930
931#define ONE_DAY_SECOND 60*60*24
932#define ONE_WEEK_SECOND 60*60*24*7
933
934 if (uptime < ONE_DAY_SECOND)
935 vty_out (vty, ", %02d:%02d:%02d",
936 tm->tm_hour, tm->tm_min, tm->tm_sec);
937 else if (uptime < ONE_WEEK_SECOND)
938 vty_out (vty, ", %dd%02dh%02dm",
939 tm->tm_yday, tm->tm_hour, tm->tm_min);
940 else
941 vty_out (vty, ", %02dw%dd%02dh",
942 tm->tm_yday/7,
943 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
944 }
945 vty_out (vty, "%s", VTY_NEWLINE);
946 }
947}
948
paul718e3742002-12-13 20:15:29 +0000949DEFUN (show_ip_route,
950 show_ip_route_cmd,
951 "show ip route",
952 SHOW_STR
953 IP_STR
954 "IP routing table\n")
955{
Everton Marques96bb2662014-07-14 11:19:00 -0300956 return do_show_ip_route(vty, SAFI_UNICAST);
957}
958
959static int do_show_ip_route(struct vty *vty, safi_t safi) {
paul718e3742002-12-13 20:15:29 +0000960 struct route_table *table;
961 struct route_node *rn;
962 struct rib *rib;
963 int first = 1;
964
Everton Marques96bb2662014-07-14 11:19:00 -0300965 table = vrf_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +0000966 if (! table)
967 return CMD_SUCCESS;
968
969 /* Show all IPv4 routes. */
970 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +0000971 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +0000972 {
973 if (first)
974 {
David Lampartere0ca5fd2009-09-16 01:52:42 +0200975 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +0000976 first = 0;
977 }
978 vty_show_ip_route (vty, rn, rib);
979 }
980 return CMD_SUCCESS;
981}
982
983DEFUN (show_ip_route_prefix_longer,
984 show_ip_route_prefix_longer_cmd,
985 "show ip route A.B.C.D/M longer-prefixes",
986 SHOW_STR
987 IP_STR
988 "IP routing table\n"
989 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
990 "Show route matching the specified Network/Mask pair only\n")
991{
992 struct route_table *table;
993 struct route_node *rn;
994 struct rib *rib;
995 struct prefix p;
996 int ret;
997 int first = 1;
998
999 ret = str2prefix (argv[0], &p);
1000 if (! ret)
1001 {
1002 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1003 return CMD_WARNING;
1004 }
1005
1006 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1007 if (! table)
1008 return CMD_SUCCESS;
1009
1010 /* Show matched type IPv4 routes. */
1011 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001012 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001013 if (prefix_match (&p, &rn->p))
1014 {
1015 if (first)
1016 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001017 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001018 first = 0;
1019 }
1020 vty_show_ip_route (vty, rn, rib);
1021 }
1022 return CMD_SUCCESS;
1023}
1024
1025DEFUN (show_ip_route_supernets,
1026 show_ip_route_supernets_cmd,
1027 "show ip route supernets-only",
1028 SHOW_STR
1029 IP_STR
1030 "IP routing table\n"
1031 "Show supernet entries only\n")
1032{
1033 struct route_table *table;
1034 struct route_node *rn;
1035 struct rib *rib;
1036 u_int32_t addr;
1037 int first = 1;
1038
1039 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1040 if (! table)
1041 return CMD_SUCCESS;
1042
1043 /* Show matched type IPv4 routes. */
1044 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001045 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001046 {
1047 addr = ntohl (rn->p.u.prefix4.s_addr);
1048
1049 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
1050 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
1051 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
1052 {
1053 if (first)
1054 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001055 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001056 first = 0;
1057 }
1058 vty_show_ip_route (vty, rn, rib);
1059 }
1060 }
1061 return CMD_SUCCESS;
1062}
1063
1064DEFUN (show_ip_route_protocol,
1065 show_ip_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02001066 "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00001067 SHOW_STR
1068 IP_STR
1069 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02001070 QUAGGA_IP_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00001071{
1072 int type;
1073 struct route_table *table;
1074 struct route_node *rn;
1075 struct rib *rib;
1076 int first = 1;
1077
David Lampartere0ca5fd2009-09-16 01:52:42 +02001078 type = proto_redistnum (AFI_IP, argv[0]);
1079 if (type < 0)
paul718e3742002-12-13 20:15:29 +00001080 {
1081 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1082 return CMD_WARNING;
1083 }
1084
1085 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1086 if (! table)
1087 return CMD_SUCCESS;
1088
1089 /* Show matched type IPv4 routes. */
1090 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001091 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001092 if (rib->type == type)
1093 {
1094 if (first)
1095 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02001096 vty_out (vty, SHOW_ROUTE_V4_HEADER);
paul718e3742002-12-13 20:15:29 +00001097 first = 0;
1098 }
1099 vty_show_ip_route (vty, rn, rib);
1100 }
1101 return CMD_SUCCESS;
1102}
1103
1104DEFUN (show_ip_route_addr,
1105 show_ip_route_addr_cmd,
1106 "show ip route A.B.C.D",
1107 SHOW_STR
1108 IP_STR
1109 "IP routing table\n"
1110 "Network in the IP routing table to display\n")
1111{
1112 int ret;
1113 struct prefix_ipv4 p;
1114 struct route_table *table;
1115 struct route_node *rn;
1116
1117 ret = str2prefix_ipv4 (argv[0], &p);
1118 if (ret <= 0)
1119 {
1120 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1121 return CMD_WARNING;
1122 }
1123
1124 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1125 if (! table)
1126 return CMD_SUCCESS;
1127
1128 rn = route_node_match (table, (struct prefix *) &p);
1129 if (! rn)
1130 {
1131 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1132 return CMD_WARNING;
1133 }
1134
David Lamparterca2b1052015-01-22 19:12:35 +01001135 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001136
1137 route_unlock_node (rn);
1138
1139 return CMD_SUCCESS;
1140}
1141
1142DEFUN (show_ip_route_prefix,
1143 show_ip_route_prefix_cmd,
1144 "show ip route A.B.C.D/M",
1145 SHOW_STR
1146 IP_STR
1147 "IP routing table\n"
1148 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1149{
1150 int ret;
1151 struct prefix_ipv4 p;
1152 struct route_table *table;
1153 struct route_node *rn;
1154
1155 ret = str2prefix_ipv4 (argv[0], &p);
1156 if (ret <= 0)
1157 {
1158 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1159 return CMD_WARNING;
1160 }
1161
1162 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1163 if (! table)
1164 return CMD_SUCCESS;
1165
1166 rn = route_node_match (table, (struct prefix *) &p);
1167 if (! rn || rn->p.prefixlen != p.prefixlen)
1168 {
1169 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00001170 if (rn)
1171 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00001172 return CMD_WARNING;
1173 }
1174
David Lamparterca2b1052015-01-22 19:12:35 +01001175 vty_show_ip_route_detail (vty, rn, 0);
paul718e3742002-12-13 20:15:29 +00001176
1177 route_unlock_node (rn);
1178
1179 return CMD_SUCCESS;
1180}
1181
paula1ac18c2005-06-28 17:17:12 +00001182static void
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001183vty_show_ip_route_summary (struct vty *vty, struct route_table *table)
paul718e3742002-12-13 20:15:29 +00001184{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001185 struct route_node *rn;
1186 struct rib *rib;
1187 struct nexthop *nexthop;
1188#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1189#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1190 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1191 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1192 u_int32_t i;
paul718e3742002-12-13 20:15:29 +00001193
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001194 memset (&rib_cnt, 0, sizeof(rib_cnt));
1195 memset (&fib_cnt, 0, sizeof(fib_cnt));
1196 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001197 RNODE_FOREACH_RIB (rn, rib)
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001198 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1199 {
1200 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1201 rib_cnt[rib->type]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001202 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1203 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001204 {
1205 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1206 fib_cnt[rib->type]++;
1207 }
1208 if (rib->type == ZEBRA_ROUTE_BGP &&
1209 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1210 {
1211 rib_cnt[ZEBRA_ROUTE_IBGP]++;
Christian Frankefa713d92013-07-05 15:35:37 +00001212 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1213 || nexthop_has_fib_child(nexthop))
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001214 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1215 }
1216 }
paul718e3742002-12-13 20:15:29 +00001217
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001218 vty_out (vty, "%-20s %-20s %-20s %s",
1219 "Route Source", "Routes", "FIB", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001220
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001221 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1222 {
1223 if (rib_cnt[i] > 0)
1224 {
1225 if (i == ZEBRA_ROUTE_BGP)
1226 {
1227 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1228 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1229 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1230 VTY_NEWLINE);
1231 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1232 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1233 VTY_NEWLINE);
1234 }
1235 else
1236 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1237 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1238 }
1239 }
paul718e3742002-12-13 20:15:29 +00001240
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001241 vty_out (vty, "------%s", VTY_NEWLINE);
1242 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1243 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001244}
1245
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001246/*
1247 * Implementation of the ip route summary prefix command.
1248 *
1249 * This command prints the primary prefixes that have been installed by various
1250 * protocols on the box.
1251 *
1252 */
1253static void
1254vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table)
1255{
1256 struct route_node *rn;
1257 struct rib *rib;
1258 struct nexthop *nexthop;
1259#define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX
1260#define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1)
1261 u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1262 u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1];
1263 u_int32_t i;
1264 int cnt;
1265
1266 memset (&rib_cnt, 0, sizeof(rib_cnt));
1267 memset (&fib_cnt, 0, sizeof(fib_cnt));
1268 for (rn = route_top (table); rn; rn = route_next (rn))
1269 RNODE_FOREACH_RIB (rn, rib)
1270 {
1271
1272 /*
1273 * In case of ECMP, count only once.
1274 */
1275 cnt = 0;
1276 for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next)
1277 {
1278 cnt++;
1279 rib_cnt[ZEBRA_ROUTE_TOTAL]++;
1280 rib_cnt[rib->type]++;
1281 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1282 {
1283 fib_cnt[ZEBRA_ROUTE_TOTAL]++;
1284 fib_cnt[rib->type]++;
1285 }
1286 if (rib->type == ZEBRA_ROUTE_BGP &&
1287 CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP))
1288 {
1289 rib_cnt[ZEBRA_ROUTE_IBGP]++;
1290 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
1291 fib_cnt[ZEBRA_ROUTE_IBGP]++;
1292 }
1293 }
1294 }
1295
1296 vty_out (vty, "%-20s %-20s %-20s %s",
1297 "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE);
1298
1299 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
1300 {
1301 if (rib_cnt[i] > 0)
1302 {
1303 if (i == ZEBRA_ROUTE_BGP)
1304 {
1305 vty_out (vty, "%-20s %-20d %-20d %s", "ebgp",
1306 rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP],
1307 fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP],
1308 VTY_NEWLINE);
1309 vty_out (vty, "%-20s %-20d %-20d %s", "ibgp",
1310 rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP],
1311 VTY_NEWLINE);
1312 }
1313 else
1314 vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i),
1315 rib_cnt[i], fib_cnt[i], VTY_NEWLINE);
1316 }
1317 }
1318
1319 vty_out (vty, "------%s", VTY_NEWLINE);
1320 vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL],
1321 fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE);
1322}
1323
paul718e3742002-12-13 20:15:29 +00001324/* Show route summary. */
1325DEFUN (show_ip_route_summary,
1326 show_ip_route_summary_cmd,
1327 "show ip route summary",
1328 SHOW_STR
1329 IP_STR
1330 "IP routing table\n"
1331 "Summary of all routes\n")
1332{
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001333 struct route_table *table;
paul718e3742002-12-13 20:15:29 +00001334
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001335 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1336 if (! table)
1337 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001338
Stig Thormodsrud61691c92008-11-04 15:45:07 -08001339 vty_show_ip_route_summary (vty, table);
paul718e3742002-12-13 20:15:29 +00001340
1341 return CMD_SUCCESS;
1342}
1343
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07001344/* Show route summary prefix. */
1345DEFUN (show_ip_route_summary_prefix,
1346 show_ip_route_summary_prefix_cmd,
1347 "show ip route summary prefix",
1348 SHOW_STR
1349 IP_STR
1350 "IP routing table\n"
1351 "Summary of all routes\n"
1352 "Prefix routes\n")
1353{
1354 struct route_table *table;
1355
1356 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1357 if (! table)
1358 return CMD_SUCCESS;
1359
1360 vty_show_ip_route_summary_prefix (vty, table);
1361
1362 return CMD_SUCCESS;
1363}
1364
paul718e3742002-12-13 20:15:29 +00001365/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00001366static int
Everton Marques96bb2662014-07-14 11:19:00 -03001367static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
paul718e3742002-12-13 20:15:29 +00001368{
1369 struct route_node *rn;
1370 struct static_ipv4 *si;
1371 struct route_table *stable;
1372 int write;
1373
1374 write = 0;
1375
1376 /* Lookup table. */
Everton Marques96bb2662014-07-14 11:19:00 -03001377 stable = vrf_static_table (AFI_IP, safi, 0);
paul718e3742002-12-13 20:15:29 +00001378 if (! stable)
1379 return -1;
1380
1381 for (rn = route_top (stable); rn; rn = route_next (rn))
1382 for (si = rn->info; si; si = si->next)
1383 {
Everton Marques96bb2662014-07-14 11:19:00 -03001384 vty_out (vty, "%s %s/%d", cmd, inet_ntoa (rn->p.u.prefix4),
paul7021c422003-07-15 12:52:22 +00001385 rn->p.prefixlen);
paul718e3742002-12-13 20:15:29 +00001386
paul7021c422003-07-15 12:52:22 +00001387 switch (si->type)
1388 {
1389 case STATIC_IPV4_GATEWAY:
1390 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
1391 break;
1392 case STATIC_IPV4_IFNAME:
1393 vty_out (vty, " %s", si->gate.ifname);
1394 break;
1395 case STATIC_IPV4_BLACKHOLE:
1396 vty_out (vty, " Null0");
1397 break;
1398 }
1399
1400 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
1401 if (si->type != STATIC_IPV4_BLACKHOLE)
1402 {
1403 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
1404 vty_out (vty, " %s", "reject");
paul718e3742002-12-13 20:15:29 +00001405
paul7021c422003-07-15 12:52:22 +00001406 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
1407 vty_out (vty, " %s", "blackhole");
1408 }
hasso81dfcaa2003-05-25 19:21:25 +00001409
paul7021c422003-07-15 12:52:22 +00001410 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
1411 vty_out (vty, " %d", si->distance);
hasso81dfcaa2003-05-25 19:21:25 +00001412
paul7021c422003-07-15 12:52:22 +00001413 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001414
paul7021c422003-07-15 12:52:22 +00001415 write = 1;
paul718e3742002-12-13 20:15:29 +00001416 }
1417 return write;
1418}
Andrew J. Schorr09303312007-05-30 20:10:34 +00001419
1420DEFUN (show_ip_protocol,
1421 show_ip_protocol_cmd,
1422 "show ip protocol",
1423 SHOW_STR
1424 IP_STR
1425 "IP protocol filtering status\n")
1426{
1427 int i;
1428
1429 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
1430 vty_out(vty, "------------------------%s", VTY_NEWLINE);
1431 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
1432 {
1433 if (proto_rm[AFI_IP][i])
1434 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
1435 proto_rm[AFI_IP][i],
1436 VTY_NEWLINE);
1437 else
1438 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
1439 }
1440 if (proto_rm[AFI_IP][i])
1441 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
1442 VTY_NEWLINE);
1443 else
1444 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
1445
1446 return CMD_SUCCESS;
1447}
1448
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001449/*
1450 * Show IP mroute command to dump the BGP Multicast
1451 * routing table
1452 */
1453DEFUN (show_ip_mroute,
1454 show_ip_mroute_cmd,
1455 "show ip mroute",
1456 SHOW_STR
1457 IP_STR
1458 "IP Multicast routing table\n")
1459{
1460 struct route_table *table;
1461 struct route_node *rn;
1462 struct rib *rib;
1463 int first = 1;
1464
1465 table = vrf_table (AFI_IP, SAFI_MULTICAST, 0);
1466 if (! table)
1467 return CMD_SUCCESS;
1468
1469 /* Show all IPv4 routes. */
1470 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001471 RNODE_FOREACH_RIB (rn, rib)
Joachim Nilsson36735ed2012-05-09 13:38:36 +02001472 {
1473 if (first)
1474 {
1475 vty_out (vty, SHOW_ROUTE_V4_HEADER);
1476 first = 0;
1477 }
1478 vty_show_ip_route (vty, rn, rib);
1479 }
1480 return CMD_SUCCESS;
1481}
1482
David Lamparter6b0655a2014-06-04 06:53:35 +02001483
paul718e3742002-12-13 20:15:29 +00001484#ifdef HAVE_IPV6
1485/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00001486static int
hasso39db97e2004-10-12 20:50:58 +00001487static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
1488 const char *gate_str, const char *ifname,
1489 const char *flag_str, const char *distance_str)
paul718e3742002-12-13 20:15:29 +00001490{
1491 int ret;
1492 u_char distance;
1493 struct prefix p;
1494 struct in6_addr *gate = NULL;
1495 struct in6_addr gate_addr;
1496 u_char type = 0;
1497 int table = 0;
hasso81dfcaa2003-05-25 19:21:25 +00001498 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00001499
1500 ret = str2prefix (dest_str, &p);
1501 if (ret <= 0)
1502 {
1503 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1504 return CMD_WARNING;
1505 }
1506
1507 /* Apply mask for given prefix. */
1508 apply_mask (&p);
1509
hasso81dfcaa2003-05-25 19:21:25 +00001510 /* Route flags */
1511 if (flag_str) {
1512 switch(flag_str[0]) {
1513 case 'r':
1514 case 'R': /* XXX */
1515 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
1516 break;
1517 case 'b':
1518 case 'B': /* XXX */
1519 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
1520 break;
1521 default:
1522 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00001523 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00001524 }
1525 }
1526
paul718e3742002-12-13 20:15:29 +00001527 /* Administrative distance. */
1528 if (distance_str)
1529 distance = atoi (distance_str);
1530 else
1531 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
1532
1533 /* When gateway is valid IPv6 addrees, then gate is treated as
1534 nexthop address other case gate is treated as interface name. */
1535 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
1536
1537 if (ifname)
1538 {
1539 /* When ifname is specified. It must be come with gateway
1540 address. */
1541 if (ret != 1)
1542 {
1543 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1544 return CMD_WARNING;
1545 }
1546 type = STATIC_IPV6_GATEWAY_IFNAME;
1547 gate = &gate_addr;
1548 }
1549 else
1550 {
1551 if (ret == 1)
1552 {
1553 type = STATIC_IPV6_GATEWAY;
1554 gate = &gate_addr;
1555 }
1556 else
1557 {
1558 type = STATIC_IPV6_IFNAME;
1559 ifname = gate_str;
1560 }
1561 }
1562
1563 if (add_cmd)
hasso81dfcaa2003-05-25 19:21:25 +00001564 static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
paul718e3742002-12-13 20:15:29 +00001565 else
1566 static_delete_ipv6 (&p, type, gate, ifname, distance, table);
1567
1568 return CMD_SUCCESS;
1569}
1570
1571DEFUN (ipv6_route,
1572 ipv6_route_cmd,
1573 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1574 IP_STR
1575 "Establish static routes\n"
1576 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1577 "IPv6 gateway address\n"
1578 "IPv6 gateway interface name\n")
1579{
hasso81dfcaa2003-05-25 19:21:25 +00001580 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
1581}
1582
1583DEFUN (ipv6_route_flags,
1584 ipv6_route_flags_cmd,
1585 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
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 "Emit an ICMP unreachable when matched\n"
1592 "Silently discard pkts when matched\n")
1593{
1594 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
paul718e3742002-12-13 20:15:29 +00001595}
1596
1597DEFUN (ipv6_route_ifname,
1598 ipv6_route_ifname_cmd,
1599 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1600 IP_STR
1601 "Establish static routes\n"
1602 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1603 "IPv6 gateway address\n"
1604 "IPv6 gateway interface name\n")
1605{
hasso81dfcaa2003-05-25 19:21:25 +00001606 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
1607}
1608
1609DEFUN (ipv6_route_ifname_flags,
1610 ipv6_route_ifname_flags_cmd,
1611 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1612 IP_STR
1613 "Establish static routes\n"
1614 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1615 "IPv6 gateway address\n"
1616 "IPv6 gateway interface name\n"
1617 "Emit an ICMP unreachable when matched\n"
1618 "Silently discard pkts when matched\n")
1619{
1620 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +00001621}
1622
1623DEFUN (ipv6_route_pref,
1624 ipv6_route_pref_cmd,
1625 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1626 IP_STR
1627 "Establish static routes\n"
1628 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1629 "IPv6 gateway address\n"
1630 "IPv6 gateway interface name\n"
1631 "Distance value for this prefix\n")
1632{
hasso81dfcaa2003-05-25 19:21:25 +00001633 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
1634}
1635
1636DEFUN (ipv6_route_flags_pref,
1637 ipv6_route_flags_pref_cmd,
1638 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1639 IP_STR
1640 "Establish static routes\n"
1641 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1642 "IPv6 gateway address\n"
1643 "IPv6 gateway interface name\n"
1644 "Emit an ICMP unreachable when matched\n"
1645 "Silently discard pkts when matched\n"
1646 "Distance value for this prefix\n")
1647{
1648 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001649}
1650
1651DEFUN (ipv6_route_ifname_pref,
1652 ipv6_route_ifname_pref_cmd,
1653 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1654 IP_STR
1655 "Establish static routes\n"
1656 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1657 "IPv6 gateway address\n"
1658 "IPv6 gateway interface name\n"
1659 "Distance value for this prefix\n")
1660{
hasso81dfcaa2003-05-25 19:21:25 +00001661 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
1662}
1663
1664DEFUN (ipv6_route_ifname_flags_pref,
1665 ipv6_route_ifname_flags_pref_cmd,
1666 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1667 IP_STR
1668 "Establish static routes\n"
1669 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1670 "IPv6 gateway address\n"
1671 "IPv6 gateway interface name\n"
1672 "Emit an ICMP unreachable when matched\n"
1673 "Silently discard pkts when matched\n"
1674 "Distance value for this prefix\n")
1675{
1676 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001677}
1678
1679DEFUN (no_ipv6_route,
1680 no_ipv6_route_cmd,
1681 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1682 NO_STR
1683 IP_STR
1684 "Establish static routes\n"
1685 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1686 "IPv6 gateway address\n"
1687 "IPv6 gateway interface name\n")
1688{
hasso81dfcaa2003-05-25 19:21:25 +00001689 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001690}
1691
hasso81dfcaa2003-05-25 19:21:25 +00001692ALIAS (no_ipv6_route,
1693 no_ipv6_route_flags_cmd,
1694 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1695 NO_STR
1696 IP_STR
1697 "Establish static routes\n"
1698 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1699 "IPv6 gateway address\n"
1700 "IPv6 gateway interface name\n"
1701 "Emit an ICMP unreachable when matched\n"
1702 "Silently discard pkts when matched\n")
1703
paul718e3742002-12-13 20:15:29 +00001704DEFUN (no_ipv6_route_ifname,
1705 no_ipv6_route_ifname_cmd,
1706 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1707 NO_STR
1708 IP_STR
1709 "Establish static routes\n"
1710 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1711 "IPv6 gateway address\n"
1712 "IPv6 gateway interface name\n")
1713{
hasso81dfcaa2003-05-25 19:21:25 +00001714 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001715}
1716
hasso81dfcaa2003-05-25 19:21:25 +00001717ALIAS (no_ipv6_route_ifname,
1718 no_ipv6_route_ifname_flags_cmd,
1719 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1720 NO_STR
1721 IP_STR
1722 "Establish static routes\n"
1723 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1724 "IPv6 gateway address\n"
1725 "IPv6 gateway interface name\n"
1726 "Emit an ICMP unreachable when matched\n"
1727 "Silently discard pkts when matched\n")
1728
paul718e3742002-12-13 20:15:29 +00001729DEFUN (no_ipv6_route_pref,
1730 no_ipv6_route_pref_cmd,
1731 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1732 NO_STR
1733 IP_STR
1734 "Establish static routes\n"
1735 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1736 "IPv6 gateway address\n"
1737 "IPv6 gateway interface name\n"
1738 "Distance value for this prefix\n")
1739{
hasso81dfcaa2003-05-25 19:21:25 +00001740 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
1741}
1742
1743DEFUN (no_ipv6_route_flags_pref,
1744 no_ipv6_route_flags_pref_cmd,
1745 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1746 NO_STR
1747 IP_STR
1748 "Establish static routes\n"
1749 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1750 "IPv6 gateway address\n"
1751 "IPv6 gateway interface name\n"
1752 "Emit an ICMP unreachable when matched\n"
1753 "Silently discard pkts when matched\n"
1754 "Distance value for this prefix\n")
1755{
1756 /* We do not care about argv[2] */
1757 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001758}
1759
1760DEFUN (no_ipv6_route_ifname_pref,
1761 no_ipv6_route_ifname_pref_cmd,
1762 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1763 NO_STR
1764 IP_STR
1765 "Establish static routes\n"
1766 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1767 "IPv6 gateway address\n"
1768 "IPv6 gateway interface name\n"
1769 "Distance value for this prefix\n")
1770{
hasso81dfcaa2003-05-25 19:21:25 +00001771 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
1772}
1773
1774DEFUN (no_ipv6_route_ifname_flags_pref,
1775 no_ipv6_route_ifname_flags_pref_cmd,
1776 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1777 NO_STR
1778 IP_STR
1779 "Establish static routes\n"
1780 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1781 "IPv6 gateway address\n"
1782 "IPv6 gateway interface name\n"
1783 "Emit an ICMP unreachable when matched\n"
1784 "Silently discard pkts when matched\n"
1785 "Distance value for this prefix\n")
1786{
1787 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001788}
1789
paul595db7f2003-05-25 21:35:06 +00001790/* New RIB. Detailed information for IPv6 route. */
paula1ac18c2005-06-28 17:17:12 +00001791static void
paul718e3742002-12-13 20:15:29 +00001792vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
1793{
1794 struct rib *rib;
Christian Frankefa713d92013-07-05 15:35:37 +00001795 struct nexthop *nexthop, *tnexthop;
1796 int recursing;
paul718e3742002-12-13 20:15:29 +00001797 char buf[BUFSIZ];
1798
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00001799 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00001800 {
1801 vty_out (vty, "Routing entry for %s/%d%s",
1802 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1803 rn->p.prefixlen,
1804 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001805 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02001806 vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric);
paul718e3742002-12-13 20:15:29 +00001807 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
1808 vty_out (vty, ", best");
1809 if (rib->refcnt)
1810 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001811 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1812 vty_out (vty, ", blackhole");
1813 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1814 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001815 vty_out (vty, "%s", VTY_NEWLINE);
1816
1817#define ONE_DAY_SECOND 60*60*24
1818#define ONE_WEEK_SECOND 60*60*24*7
1819 if (rib->type == ZEBRA_ROUTE_RIPNG
1820 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001821 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001822 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001823 || rib->type == ZEBRA_ROUTE_BGP)
1824 {
1825 time_t uptime;
1826 struct tm *tm;
1827
1828 uptime = time (NULL);
1829 uptime -= rib->uptime;
1830 tm = gmtime (&uptime);
1831
1832 vty_out (vty, " Last update ");
1833
1834 if (uptime < ONE_DAY_SECOND)
1835 vty_out (vty, "%02d:%02d:%02d",
1836 tm->tm_hour, tm->tm_min, tm->tm_sec);
1837 else if (uptime < ONE_WEEK_SECOND)
1838 vty_out (vty, "%dd%02dh%02dm",
1839 tm->tm_yday, tm->tm_hour, tm->tm_min);
1840 else
1841 vty_out (vty, "%02dw%dd%02dh",
1842 tm->tm_yday/7,
1843 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1844 vty_out (vty, " ago%s", VTY_NEWLINE);
1845 }
1846
Christian Frankefa713d92013-07-05 15:35:37 +00001847 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001848 {
Christian Frankefa713d92013-07-05 15:35:37 +00001849 vty_out (vty, " %c%s",
1850 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ',
1851 recursing ? " " : "");
paul718e3742002-12-13 20:15:29 +00001852
1853 switch (nexthop->type)
1854 {
1855 case NEXTHOP_TYPE_IPV6:
1856 case NEXTHOP_TYPE_IPV6_IFINDEX:
1857 case NEXTHOP_TYPE_IPV6_IFNAME:
1858 vty_out (vty, " %s",
1859 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1860 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1861 vty_out (vty, ", %s", nexthop->ifname);
1862 else if (nexthop->ifindex)
1863 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
1864 break;
1865 case NEXTHOP_TYPE_IFINDEX:
1866 vty_out (vty, " directly connected, %s",
1867 ifindex2ifname (nexthop->ifindex));
1868 break;
1869 case NEXTHOP_TYPE_IFNAME:
1870 vty_out (vty, " directly connected, %s",
1871 nexthop->ifname);
1872 break;
1873 default:
1874 break;
1875 }
1876 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1877 vty_out (vty, " inactive");
1878
Christian Frankee8d3d292013-07-05 15:35:39 +00001879 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK))
1880 vty_out (vty, " onlink");
1881
paul718e3742002-12-13 20:15:29 +00001882 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001883 vty_out (vty, " (recursive)");
1884
paul718e3742002-12-13 20:15:29 +00001885 vty_out (vty, "%s", VTY_NEWLINE);
1886 }
1887 vty_out (vty, "%s", VTY_NEWLINE);
1888 }
1889}
1890
paula1ac18c2005-06-28 17:17:12 +00001891static void
paul718e3742002-12-13 20:15:29 +00001892vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
1893 struct rib *rib)
1894{
Christian Frankefa713d92013-07-05 15:35:37 +00001895 struct nexthop *nexthop, *tnexthop;
1896 int recursing;
paul718e3742002-12-13 20:15:29 +00001897 int len = 0;
1898 char buf[BUFSIZ];
1899
1900 /* Nexthop information. */
Christian Frankefa713d92013-07-05 15:35:37 +00001901 for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing))
paul718e3742002-12-13 20:15:29 +00001902 {
1903 if (nexthop == rib->nexthop)
1904 {
1905 /* Prefix information. */
1906 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +00001907 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001908 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1909 ? '>' : ' ',
1910 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1911 ? '*' : ' ',
1912 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1913 rn->p.prefixlen);
1914
1915 /* Distance and metric display. */
1916 if (rib->type != ZEBRA_ROUTE_CONNECT
1917 && rib->type != ZEBRA_ROUTE_KERNEL)
1918 len += vty_out (vty, " [%d/%d]", rib->distance,
1919 rib->metric);
1920 }
1921 else
1922 vty_out (vty, " %c%*c",
1923 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1924 ? '*' : ' ',
Christian Frankefa713d92013-07-05 15:35:37 +00001925 len - 3 + (2 * recursing), ' ');
paul718e3742002-12-13 20:15:29 +00001926
1927 switch (nexthop->type)
1928 {
1929 case NEXTHOP_TYPE_IPV6:
1930 case NEXTHOP_TYPE_IPV6_IFINDEX:
1931 case NEXTHOP_TYPE_IPV6_IFNAME:
1932 vty_out (vty, " via %s",
1933 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1934 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1935 vty_out (vty, ", %s", nexthop->ifname);
1936 else if (nexthop->ifindex)
1937 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
1938 break;
1939 case NEXTHOP_TYPE_IFINDEX:
1940 vty_out (vty, " is directly connected, %s",
1941 ifindex2ifname (nexthop->ifindex));
1942 break;
1943 case NEXTHOP_TYPE_IFNAME:
1944 vty_out (vty, " is directly connected, %s",
1945 nexthop->ifname);
1946 break;
1947 default:
1948 break;
1949 }
1950 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1951 vty_out (vty, " inactive");
1952
1953 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
Christian Frankefa713d92013-07-05 15:35:37 +00001954 vty_out (vty, " (recursive)");
paul718e3742002-12-13 20:15:29 +00001955
hasso81dfcaa2003-05-25 19:21:25 +00001956 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1957 vty_out (vty, ", bh");
1958 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1959 vty_out (vty, ", rej");
1960
paul718e3742002-12-13 20:15:29 +00001961 if (rib->type == ZEBRA_ROUTE_RIPNG
1962 || rib->type == ZEBRA_ROUTE_OSPF6
Juliusz Chroboczek578ce372012-02-09 13:42:28 +01001963 || rib->type == ZEBRA_ROUTE_BABEL
jardin9e867fe2003-12-23 08:56:18 +00001964 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001965 || rib->type == ZEBRA_ROUTE_BGP)
1966 {
1967 time_t uptime;
1968 struct tm *tm;
1969
1970 uptime = time (NULL);
1971 uptime -= rib->uptime;
1972 tm = gmtime (&uptime);
1973
1974#define ONE_DAY_SECOND 60*60*24
1975#define ONE_WEEK_SECOND 60*60*24*7
1976
1977 if (uptime < ONE_DAY_SECOND)
1978 vty_out (vty, ", %02d:%02d:%02d",
1979 tm->tm_hour, tm->tm_min, tm->tm_sec);
1980 else if (uptime < ONE_WEEK_SECOND)
1981 vty_out (vty, ", %dd%02dh%02dm",
1982 tm->tm_yday, tm->tm_hour, tm->tm_min);
1983 else
1984 vty_out (vty, ", %02dw%dd%02dh",
1985 tm->tm_yday/7,
1986 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1987 }
1988 vty_out (vty, "%s", VTY_NEWLINE);
1989 }
1990}
1991
paul718e3742002-12-13 20:15:29 +00001992DEFUN (show_ipv6_route,
1993 show_ipv6_route_cmd,
1994 "show ipv6 route",
1995 SHOW_STR
1996 IP_STR
1997 "IPv6 routing table\n")
1998{
1999 struct route_table *table;
2000 struct route_node *rn;
2001 struct rib *rib;
2002 int first = 1;
2003
2004 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2005 if (! table)
2006 return CMD_SUCCESS;
2007
2008 /* Show all IPv6 route. */
2009 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002010 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002011 {
2012 if (first)
2013 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002014 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002015 first = 0;
2016 }
2017 vty_show_ipv6_route (vty, rn, rib);
2018 }
2019 return CMD_SUCCESS;
2020}
2021
2022DEFUN (show_ipv6_route_prefix_longer,
2023 show_ipv6_route_prefix_longer_cmd,
2024 "show ipv6 route X:X::X:X/M longer-prefixes",
2025 SHOW_STR
2026 IP_STR
2027 "IPv6 routing table\n"
2028 "IPv6 prefix\n"
2029 "Show route matching the specified Network/Mask pair only\n")
2030{
2031 struct route_table *table;
2032 struct route_node *rn;
2033 struct rib *rib;
2034 struct prefix p;
2035 int ret;
2036 int first = 1;
2037
2038 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2039 if (! table)
2040 return CMD_SUCCESS;
2041
2042 ret = str2prefix (argv[0], &p);
2043 if (! ret)
2044 {
2045 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
2046 return CMD_WARNING;
2047 }
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 (prefix_match (&p, &rn->p))
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_protocol,
2065 show_ipv6_route_protocol_cmd,
David Lampartere0ca5fd2009-09-16 01:52:42 +02002066 "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA,
paul718e3742002-12-13 20:15:29 +00002067 SHOW_STR
2068 IP_STR
2069 "IP routing table\n"
David Lampartere0ca5fd2009-09-16 01:52:42 +02002070 QUAGGA_IP6_REDIST_HELP_STR_ZEBRA)
paul718e3742002-12-13 20:15:29 +00002071{
2072 int type;
2073 struct route_table *table;
2074 struct route_node *rn;
2075 struct rib *rib;
2076 int first = 1;
2077
David Lampartere0ca5fd2009-09-16 01:52:42 +02002078 type = proto_redistnum (AFI_IP6, argv[0]);
2079 if (type < 0)
paul718e3742002-12-13 20:15:29 +00002080 {
2081 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
2082 return CMD_WARNING;
2083 }
2084
2085 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2086 if (! table)
2087 return CMD_SUCCESS;
2088
2089 /* Show matched type IPv6 routes. */
2090 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002091 RNODE_FOREACH_RIB (rn, rib)
paul718e3742002-12-13 20:15:29 +00002092 if (rib->type == type)
2093 {
2094 if (first)
2095 {
David Lampartere0ca5fd2009-09-16 01:52:42 +02002096 vty_out (vty, SHOW_ROUTE_V6_HEADER);
paul718e3742002-12-13 20:15:29 +00002097 first = 0;
2098 }
2099 vty_show_ipv6_route (vty, rn, rib);
2100 }
2101 return CMD_SUCCESS;
2102}
2103
2104DEFUN (show_ipv6_route_addr,
2105 show_ipv6_route_addr_cmd,
2106 "show ipv6 route X:X::X:X",
2107 SHOW_STR
2108 IP_STR
2109 "IPv6 routing table\n"
2110 "IPv6 Address\n")
2111{
2112 int ret;
2113 struct prefix_ipv6 p;
2114 struct route_table *table;
2115 struct route_node *rn;
2116
2117 ret = str2prefix_ipv6 (argv[0], &p);
2118 if (ret <= 0)
2119 {
2120 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
2121 return CMD_WARNING;
2122 }
2123
2124 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2125 if (! table)
2126 return CMD_SUCCESS;
2127
2128 rn = route_node_match (table, (struct prefix *) &p);
2129 if (! rn)
2130 {
2131 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
2132 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
2142DEFUN (show_ipv6_route_prefix,
2143 show_ipv6_route_prefix_cmd,
2144 "show ipv6 route X:X::X:X/M",
2145 SHOW_STR
2146 IP_STR
2147 "IPv6 routing table\n"
2148 "IPv6 prefix\n")
2149{
2150 int ret;
2151 struct prefix_ipv6 p;
2152 struct route_table *table;
2153 struct route_node *rn;
2154
2155 ret = str2prefix_ipv6 (argv[0], &p);
2156 if (ret <= 0)
2157 {
2158 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
2159 return CMD_WARNING;
2160 }
2161
2162 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2163 if (! table)
2164 return CMD_SUCCESS;
2165
2166 rn = route_node_match (table, (struct prefix *) &p);
2167 if (! rn || rn->p.prefixlen != p.prefixlen)
2168 {
2169 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
Lu Feng969d3552014-10-21 06:24:07 +00002170 if (rn)
2171 route_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00002172 return CMD_WARNING;
2173 }
2174
2175 vty_show_ipv6_route_detail (vty, rn);
2176
2177 route_unlock_node (rn);
2178
2179 return CMD_SUCCESS;
2180}
2181
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002182/* Show route summary. */
2183DEFUN (show_ipv6_route_summary,
2184 show_ipv6_route_summary_cmd,
2185 "show ipv6 route summary",
2186 SHOW_STR
2187 IP_STR
2188 "IPv6 routing table\n"
2189 "Summary of all IPv6 routes\n")
2190{
2191 struct route_table *table;
2192
2193 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2194 if (! table)
2195 return CMD_SUCCESS;
2196
2197 vty_show_ip_route_summary (vty, table);
2198
2199 return CMD_SUCCESS;
2200}
2201
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002202/* Show ipv6 route summary prefix. */
2203DEFUN (show_ipv6_route_summary_prefix,
2204 show_ipv6_route_summary_prefix_cmd,
2205 "show ipv6 route summary prefix",
2206 SHOW_STR
2207 IP_STR
2208 "IPv6 routing table\n"
2209 "Summary of all IPv6 routes\n"
2210 "Prefix routes\n")
2211{
2212 struct route_table *table;
2213
2214 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
2215 if (! table)
2216 return CMD_SUCCESS;
2217
2218 vty_show_ip_route_summary_prefix (vty, table);
2219
2220 return CMD_SUCCESS;
2221}
2222
G.Balajicddf3912011-11-26 21:59:32 +04002223/*
G.Balajicddf3912011-11-26 21:59:32 +04002224 * Show IPv6 mroute command.Used to dump
2225 * the Multicast routing table.
2226 */
2227
2228DEFUN (show_ipv6_mroute,
2229 show_ipv6_mroute_cmd,
2230 "show ipv6 mroute",
2231 SHOW_STR
2232 IP_STR
2233 "IPv6 Multicast routing table\n")
2234{
2235 struct route_table *table;
2236 struct route_node *rn;
2237 struct rib *rib;
2238 int first = 1;
2239
2240 table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0);
2241 if (! table)
2242 return CMD_SUCCESS;
2243
2244 /* Show all IPv6 route. */
2245 for (rn = route_top (table); rn; rn = route_next (rn))
Avneesh Sachdev9fd92e32012-11-13 22:48:53 +00002246 RNODE_FOREACH_RIB (rn, rib)
G.Balajicddf3912011-11-26 21:59:32 +04002247 {
2248 if (first)
2249 {
G.Balajicb32fd62011-11-27 20:09:40 +05302250 vty_out (vty, SHOW_ROUTE_V6_HEADER);
G.Balajicddf3912011-11-26 21:59:32 +04002251 first = 0;
2252 }
2253 vty_show_ipv6_route (vty, rn, rib);
2254 }
2255 return CMD_SUCCESS;
2256}
2257
paul718e3742002-12-13 20:15:29 +00002258/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00002259static int
paul718e3742002-12-13 20:15:29 +00002260static_config_ipv6 (struct vty *vty)
2261{
2262 struct route_node *rn;
2263 struct static_ipv6 *si;
2264 int write;
2265 char buf[BUFSIZ];
2266 struct route_table *stable;
2267
2268 write = 0;
2269
2270 /* Lookup table. */
2271 stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0);
2272 if (! stable)
2273 return -1;
2274
2275 for (rn = route_top (stable); rn; rn = route_next (rn))
2276 for (si = rn->info; si; si = si->next)
2277 {
2278 vty_out (vty, "ipv6 route %s/%d",
2279 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
2280 rn->p.prefixlen);
2281
2282 switch (si->type)
2283 {
2284 case STATIC_IPV6_GATEWAY:
2285 vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
2286 break;
2287 case STATIC_IPV6_IFNAME:
2288 vty_out (vty, " %s", si->ifname);
2289 break;
2290 case STATIC_IPV6_GATEWAY_IFNAME:
2291 vty_out (vty, " %s %s",
2292 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
2293 break;
2294 }
2295
hasso81dfcaa2003-05-25 19:21:25 +00002296 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
2297 vty_out (vty, " %s", "reject");
2298
2299 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
2300 vty_out (vty, " %s", "blackhole");
2301
paul718e3742002-12-13 20:15:29 +00002302 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
2303 vty_out (vty, " %d", si->distance);
2304 vty_out (vty, "%s", VTY_NEWLINE);
2305
2306 write = 1;
2307 }
2308 return write;
2309}
2310#endif /* HAVE_IPV6 */
2311
2312/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00002313static int
paul718e3742002-12-13 20:15:29 +00002314zebra_ip_config (struct vty *vty)
2315{
2316 int write = 0;
2317
Everton Marques96bb2662014-07-14 11:19:00 -03002318 write += static_config_ipv4 (vty, SAFI_UNICAST, "ip route");
2319 write += static_config_ipv4 (vty, SAFI_MULTICAST, "ip mroute");
paul718e3742002-12-13 20:15:29 +00002320#ifdef HAVE_IPV6
2321 write += static_config_ipv6 (vty);
2322#endif /* HAVE_IPV6 */
2323
2324 return write;
2325}
2326
David Lamparter240c56f2015-01-06 19:53:24 +01002327static int config_write_vty(struct vty *vty)
2328{
Paul Jakma7514fb72007-05-02 16:05:35 +00002329 int i;
David Lamparter240c56f2015-01-06 19:53:24 +01002330 enum multicast_mode ipv4_multicast_mode = multicast_mode_ipv4_get ();
2331
2332 if (ipv4_multicast_mode != MCAST_NO_CONFIG)
2333 vty_out (vty, "ip multicast rpf-lookup-mode %s%s",
2334 ipv4_multicast_mode == MCAST_URIB_ONLY ? "urib-only" :
2335 ipv4_multicast_mode == MCAST_MRIB_ONLY ? "mrib-only" :
2336 ipv4_multicast_mode == MCAST_MIX_MRIB_FIRST ? "mrib-then-urib" :
2337 ipv4_multicast_mode == MCAST_MIX_DISTANCE ? "lower-distance" :
2338 "longer-prefix",
2339 VTY_NEWLINE);
Paul Jakma7514fb72007-05-02 16:05:35 +00002340
2341 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2342 {
2343 if (proto_rm[AFI_IP][i])
2344 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
2345 proto_rm[AFI_IP][i], VTY_NEWLINE);
2346 }
2347 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
2348 vty_out (vty, "ip protocol %s route-map %s%s", "any",
2349 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
2350
2351 return 1;
2352}
2353
2354/* table node for protocol filtering */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002355static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
Paul Jakma7514fb72007-05-02 16:05:35 +00002356
paul718e3742002-12-13 20:15:29 +00002357/* IP node for static routes. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08002358static struct cmd_node ip_node = { IP_NODE, "", 1 };
paul718e3742002-12-13 20:15:29 +00002359
2360/* Route VTY. */
2361void
paula1ac18c2005-06-28 17:17:12 +00002362zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00002363{
2364 install_node (&ip_node, zebra_ip_config);
David Lamparter240c56f2015-01-06 19:53:24 +01002365 install_node (&protocol_node, config_write_vty);
paul718e3742002-12-13 20:15:29 +00002366
Everton Marques96bb2662014-07-14 11:19:00 -03002367 install_element (CONFIG_NODE, &ip_mroute_cmd);
David Lamparter9e6366d2015-01-22 19:03:53 +01002368 install_element (CONFIG_NODE, &ip_mroute_dist_cmd);
Everton Marques96bb2662014-07-14 11:19:00 -03002369 install_element (CONFIG_NODE, &no_ip_mroute_cmd);
David Lamparter9e6366d2015-01-22 19:03:53 +01002370 install_element (CONFIG_NODE, &no_ip_mroute_dist_cmd);
David Lamparter240c56f2015-01-06 19:53:24 +01002371 install_element (CONFIG_NODE, &ip_multicast_mode_cmd);
2372 install_element (CONFIG_NODE, &no_ip_multicast_mode_cmd);
2373 install_element (CONFIG_NODE, &no_ip_multicast_mode_noarg_cmd);
Paul Jakma7514fb72007-05-02 16:05:35 +00002374 install_element (CONFIG_NODE, &ip_protocol_cmd);
2375 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
2376 install_element (VIEW_NODE, &show_ip_protocol_cmd);
2377 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00002378 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002379 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002380 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002381 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002382 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002383 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002384 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002385 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002386 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002387 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002388 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002389 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002390 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002391 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002392 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002393 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002394 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002395 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002396 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002397 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002398 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002399 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002400 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002401
2402 install_element (VIEW_NODE, &show_ip_route_cmd);
2403 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
2404 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
2405 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
2406 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
2407 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002408 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002409 install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002410 install_element (ENABLE_NODE, &show_ip_route_cmd);
2411 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
2412 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
2413 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
2414 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
2415 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
paul718e3742002-12-13 20:15:29 +00002416 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002417 install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002418
G.Balajicddf3912011-11-26 21:59:32 +04002419 install_element (VIEW_NODE, &show_ip_mroute_cmd);
2420 install_element (ENABLE_NODE, &show_ip_mroute_cmd);
2421
Everton Marques96bb2662014-07-14 11:19:00 -03002422 install_element (VIEW_NODE, &show_ip_rpf_cmd);
2423 install_element (ENABLE_NODE, &show_ip_rpf_cmd);
David Lamparterca2b1052015-01-22 19:12:35 +01002424 install_element (VIEW_NODE, &show_ip_rpf_addr_cmd);
2425 install_element (ENABLE_NODE, &show_ip_rpf_addr_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002426
paul718e3742002-12-13 20:15:29 +00002427#ifdef HAVE_IPV6
2428 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002429 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002430 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002431 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002432 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002433 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002434 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002435 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002436 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002437 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002438 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002439 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002440 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002441 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002442 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002443 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002444 install_element (VIEW_NODE, &show_ipv6_route_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002445 install_element (VIEW_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002446 install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd);
paul718e3742002-12-13 20:15:29 +00002447 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
2448 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
2449 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
2450 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
2451 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
2452 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
2453 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
2454 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
2455 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
Stig Thormodsrud61691c92008-11-04 15:45:07 -08002456 install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd);
Dinesh G Dutt56a5f772014-09-30 12:58:04 -07002457 install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd);
G.Balajicddf3912011-11-26 21:59:32 +04002458
2459 install_element (VIEW_NODE, &show_ipv6_mroute_cmd);
2460 install_element (ENABLE_NODE, &show_ipv6_mroute_cmd);
paul718e3742002-12-13 20:15:29 +00002461#endif /* HAVE_IPV6 */
2462}