blob: 1487745b1546a2d19cfc44087429b0fd60bf092a [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
paul718e3742002-12-13 20:15:29 +000033/* General fucntion for static route. */
paula1ac18c2005-06-28 17:17:12 +000034static int
hasso39db97e2004-10-12 20:50:58 +000035zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str,
36 const char *mask_str, const char *gate_str,
37 const char *flag_str, const char *distance_str)
paul718e3742002-12-13 20:15:29 +000038{
39 int ret;
40 u_char distance;
41 struct prefix p;
42 struct in_addr gate;
43 struct in_addr mask;
hasso39db97e2004-10-12 20:50:58 +000044 const char *ifname;
hasso81dfcaa2003-05-25 19:21:25 +000045 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +000046
47 ret = str2prefix (dest_str, &p);
48 if (ret <= 0)
49 {
50 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
51 return CMD_WARNING;
52 }
53
54 /* Cisco like mask notation. */
55 if (mask_str)
56 {
57 ret = inet_aton (mask_str, &mask);
58 if (ret == 0)
paul595db7f2003-05-25 21:35:06 +000059 {
60 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
61 return CMD_WARNING;
62 }
paul718e3742002-12-13 20:15:29 +000063 p.prefixlen = ip_masklen (mask);
64 }
65
66 /* Apply mask for given prefix. */
67 apply_mask (&p);
68
paul595db7f2003-05-25 21:35:06 +000069 /* Administrative distance. */
70 if (distance_str)
71 distance = atoi (distance_str);
72 else
73 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
74
75 /* Null0 static route. */
hasso457ef552003-05-28 12:02:15 +000076 if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0))
paul595db7f2003-05-25 21:35:06 +000077 {
78 if (flag_str)
79 {
80 vty_out (vty, "%% can not have flag %s with Null0%s", flag_str, VTY_NEWLINE);
81 return CMD_WARNING;
82 }
83 if (add_cmd)
paul7021c422003-07-15 12:52:22 +000084 static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0);
paul595db7f2003-05-25 21:35:06 +000085 else
86 static_delete_ipv4 (&p, NULL, NULL, distance, 0);
87 return CMD_SUCCESS;
88 }
89
hasso81dfcaa2003-05-25 19:21:25 +000090 /* Route flags */
91 if (flag_str) {
92 switch(flag_str[0]) {
93 case 'r':
94 case 'R': /* XXX */
95 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
96 break;
97 case 'b':
98 case 'B': /* XXX */
99 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
100 break;
101 default:
102 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +0000103 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +0000104 }
105 }
106
hasso457ef552003-05-28 12:02:15 +0000107 if (gate_str == NULL)
108 {
109 if (add_cmd)
110 static_add_ipv4 (&p, NULL, NULL, flag, distance, 0);
111 else
112 static_delete_ipv4 (&p, NULL, NULL, distance, 0);
113
114 return CMD_SUCCESS;
115 }
116
paul718e3742002-12-13 20:15:29 +0000117 /* When gateway is A.B.C.D format, gate is treated as nexthop
118 address other case gate is treated as interface name. */
119 ret = inet_aton (gate_str, &gate);
120 if (ret)
121 ifname = NULL;
122 else
123 ifname = gate_str;
124
125 if (add_cmd)
hasso81dfcaa2003-05-25 19:21:25 +0000126 static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, distance, 0);
paul718e3742002-12-13 20:15:29 +0000127 else
128 static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, distance, 0);
129
130 return CMD_SUCCESS;
131}
132
133/* Static route configuration. */
134DEFUN (ip_route,
135 ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000136 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000137 IP_STR
138 "Establish static routes\n"
139 "IP destination prefix (e.g. 10.0.0.0/8)\n"
140 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000141 "IP gateway interface name\n"
142 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000143{
144 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL);
145}
146
147DEFUN (ip_route_flags,
148 ip_route_flags_cmd,
149 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000150 IP_STR
151 "Establish static routes\n"
152 "IP destination prefix (e.g. 10.0.0.0/8)\n"
153 "IP gateway address\n"
154 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000155 "Emit an ICMP unreachable when matched\n"
156 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000157{
hasso81dfcaa2003-05-25 19:21:25 +0000158 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL);
paul718e3742002-12-13 20:15:29 +0000159}
160
hasso457ef552003-05-28 12:02:15 +0000161DEFUN (ip_route_flags2,
162 ip_route_flags2_cmd,
163 "ip route A.B.C.D/M (reject|blackhole)",
164 IP_STR
165 "Establish static routes\n"
166 "IP destination prefix (e.g. 10.0.0.0/8)\n"
167 "Emit an ICMP unreachable when matched\n"
168 "Silently discard pkts when matched\n")
169{
170 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL);
171}
172
paul718e3742002-12-13 20:15:29 +0000173/* Mask as A.B.C.D format. */
174DEFUN (ip_route_mask,
175 ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000176 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000177 IP_STR
178 "Establish static routes\n"
179 "IP destination prefix\n"
180 "IP destination prefix mask\n"
181 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000182 "IP gateway interface name\n"
183 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000184{
185 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
186}
187
188DEFUN (ip_route_mask_flags,
189 ip_route_mask_flags_cmd,
190 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000191 IP_STR
192 "Establish static routes\n"
193 "IP destination prefix\n"
194 "IP destination prefix mask\n"
195 "IP gateway address\n"
196 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000197 "Emit an ICMP unreachable when matched\n"
198 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000199{
hasso81dfcaa2003-05-25 19:21:25 +0000200 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +0000201}
202
hasso457ef552003-05-28 12:02:15 +0000203DEFUN (ip_route_mask_flags2,
204 ip_route_mask_flags2_cmd,
205 "ip route A.B.C.D A.B.C.D (reject|blackhole)",
206 IP_STR
207 "Establish static routes\n"
208 "IP destination prefix\n"
209 "IP destination prefix mask\n"
210 "Emit an ICMP unreachable when matched\n"
211 "Silently discard pkts when matched\n")
212{
213 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
214}
215
paul718e3742002-12-13 20:15:29 +0000216/* Distance option value. */
217DEFUN (ip_route_distance,
218 ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000219 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000220 IP_STR
221 "Establish static routes\n"
222 "IP destination prefix (e.g. 10.0.0.0/8)\n"
223 "IP gateway address\n"
224 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000225 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000226 "Distance value for this route\n")
227{
hasso81dfcaa2003-05-25 19:21:25 +0000228 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]);
229}
230
231DEFUN (ip_route_flags_distance,
232 ip_route_flags_distance_cmd,
233 "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
234 IP_STR
235 "Establish static routes\n"
236 "IP destination prefix (e.g. 10.0.0.0/8)\n"
237 "IP gateway address\n"
238 "IP gateway interface name\n"
239 "Emit an ICMP unreachable when matched\n"
240 "Silently discard pkts when matched\n"
241 "Distance value for this route\n")
242{
243 return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000244}
245
hasso457ef552003-05-28 12:02:15 +0000246DEFUN (ip_route_flags_distance2,
247 ip_route_flags_distance2_cmd,
248 "ip route A.B.C.D/M (reject|blackhole) <1-255>",
249 IP_STR
250 "Establish static routes\n"
251 "IP destination prefix (e.g. 10.0.0.0/8)\n"
252 "Emit an ICMP unreachable when matched\n"
253 "Silently discard pkts when matched\n"
254 "Distance value for this route\n")
255{
256 return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2]);
257}
258
paul718e3742002-12-13 20:15:29 +0000259DEFUN (ip_route_mask_distance,
260 ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000261 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000262 IP_STR
263 "Establish static routes\n"
264 "IP destination prefix\n"
265 "IP destination prefix mask\n"
266 "IP gateway address\n"
267 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000268 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000269 "Distance value for this route\n")
270{
hasso81dfcaa2003-05-25 19:21:25 +0000271 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
272}
273
274DEFUN (ip_route_mask_flags_distance,
275 ip_route_mask_flags_distance_cmd,
276 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
277 IP_STR
278 "Establish static routes\n"
279 "IP destination prefix\n"
280 "IP destination prefix mask\n"
281 "IP gateway address\n"
282 "IP gateway interface name\n"
283 "Distance value for this route\n"
284 "Emit an ICMP unreachable when matched\n"
285 "Silently discard pkts when matched\n")
286{
287 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000288}
289
hasso457ef552003-05-28 12:02:15 +0000290DEFUN (ip_route_mask_flags_distance2,
291 ip_route_mask_flags_distance2_cmd,
292 "ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
293 IP_STR
294 "Establish static routes\n"
295 "IP destination prefix\n"
296 "IP destination prefix mask\n"
297 "Distance value for this route\n"
298 "Emit an ICMP unreachable when matched\n"
299 "Silently discard pkts when matched\n")
300{
301 return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
302}
303
paul718e3742002-12-13 20:15:29 +0000304DEFUN (no_ip_route,
305 no_ip_route_cmd,
paul595db7f2003-05-25 21:35:06 +0000306 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000307 NO_STR
308 IP_STR
309 "Establish static routes\n"
310 "IP destination prefix (e.g. 10.0.0.0/8)\n"
311 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000312 "IP gateway interface name\n"
313 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000314{
315 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL);
316}
317
318ALIAS (no_ip_route,
319 no_ip_route_flags_cmd,
320 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000321 NO_STR
322 IP_STR
323 "Establish static routes\n"
324 "IP destination prefix (e.g. 10.0.0.0/8)\n"
325 "IP gateway address\n"
326 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000327 "Emit an ICMP unreachable when matched\n"
328 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000329
hasso457ef552003-05-28 12:02:15 +0000330DEFUN (no_ip_route_flags2,
331 no_ip_route_flags2_cmd,
332 "no ip route A.B.C.D/M (reject|blackhole)",
333 NO_STR
334 IP_STR
335 "Establish static routes\n"
336 "IP destination prefix (e.g. 10.0.0.0/8)\n"
337 "Emit an ICMP unreachable when matched\n"
338 "Silently discard pkts when matched\n")
339{
340 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL);
341}
342
paul718e3742002-12-13 20:15:29 +0000343DEFUN (no_ip_route_mask,
344 no_ip_route_mask_cmd,
paul595db7f2003-05-25 21:35:06 +0000345 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)",
hasso81dfcaa2003-05-25 19:21:25 +0000346 NO_STR
347 IP_STR
348 "Establish static routes\n"
349 "IP destination prefix\n"
350 "IP destination prefix mask\n"
351 "IP gateway address\n"
paul595db7f2003-05-25 21:35:06 +0000352 "IP gateway interface name\n"
353 "Null interface\n")
hasso81dfcaa2003-05-25 19:21:25 +0000354{
355 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
356}
357
358ALIAS (no_ip_route_mask,
359 no_ip_route_mask_flags_cmd,
360 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole)",
paul718e3742002-12-13 20:15:29 +0000361 NO_STR
362 IP_STR
363 "Establish static routes\n"
364 "IP destination prefix\n"
365 "IP destination prefix mask\n"
366 "IP gateway address\n"
367 "IP gateway interface name\n"
hasso81dfcaa2003-05-25 19:21:25 +0000368 "Emit an ICMP unreachable when matched\n"
369 "Silently discard pkts when matched\n")
paul718e3742002-12-13 20:15:29 +0000370
hasso457ef552003-05-28 12:02:15 +0000371DEFUN (no_ip_route_mask_flags2,
372 no_ip_route_mask_flags2_cmd,
373 "no ip route A.B.C.D A.B.C.D (reject|blackhole)",
374 NO_STR
375 IP_STR
376 "Establish static routes\n"
377 "IP destination prefix\n"
378 "IP destination prefix mask\n"
379 "Emit an ICMP unreachable when matched\n"
380 "Silently discard pkts when matched\n")
381{
382 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
383}
384
paul718e3742002-12-13 20:15:29 +0000385DEFUN (no_ip_route_distance,
386 no_ip_route_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000387 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>",
paul718e3742002-12-13 20:15:29 +0000388 NO_STR
389 IP_STR
390 "Establish static routes\n"
391 "IP destination prefix (e.g. 10.0.0.0/8)\n"
392 "IP gateway address\n"
393 "IP gateway interface name\n"
paul595db7f2003-05-25 21:35:06 +0000394 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000395 "Distance value for this route\n")
396{
hasso81dfcaa2003-05-25 19:21:25 +0000397 return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]);
398}
399
400DEFUN (no_ip_route_flags_distance,
401 no_ip_route_flags_distance_cmd,
402 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
403 NO_STR
404 IP_STR
405 "Establish static routes\n"
406 "IP destination prefix (e.g. 10.0.0.0/8)\n"
407 "IP gateway address\n"
408 "IP gateway interface name\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, 0, argv[0], NULL, argv[1], argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +0000414}
415
hasso457ef552003-05-28 12:02:15 +0000416DEFUN (no_ip_route_flags_distance2,
417 no_ip_route_flags_distance2_cmd,
418 "no ip route A.B.C.D/M (reject|blackhole) <1-255>",
419 NO_STR
420 IP_STR
421 "Establish static routes\n"
422 "IP destination prefix (e.g. 10.0.0.0/8)\n"
423 "Emit an ICMP unreachable when matched\n"
424 "Silently discard pkts when matched\n"
425 "Distance value for this route\n")
426{
427 return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2]);
428}
429
paul718e3742002-12-13 20:15:29 +0000430DEFUN (no_ip_route_mask_distance,
431 no_ip_route_mask_distance_cmd,
paul595db7f2003-05-25 21:35:06 +0000432 "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 +0000433 NO_STR
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"
paul595db7f2003-05-25 21:35:06 +0000440 "Null interface\n"
paul718e3742002-12-13 20:15:29 +0000441 "Distance value for this route\n")
442{
hasso81dfcaa2003-05-25 19:21:25 +0000443 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
444}
445
446DEFUN (no_ip_route_mask_flags_distance,
447 no_ip_route_mask_flags_distance_cmd,
448 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>",
449 NO_STR
450 IP_STR
451 "Establish static routes\n"
452 "IP destination prefix\n"
453 "IP destination prefix mask\n"
454 "IP gateway address\n"
455 "IP gateway interface name\n"
456 "Emit an ICMP unreachable when matched\n"
457 "Silently discard pkts when matched\n"
458 "Distance value for this route\n")
459{
460 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +0000461}
462
hasso457ef552003-05-28 12:02:15 +0000463DEFUN (no_ip_route_mask_flags_distance2,
464 no_ip_route_mask_flags_distance2_cmd,
465 "no ip route A.B.C.D A.B.C.D (reject|blackhole) <1-255>",
466 NO_STR
467 IP_STR
468 "Establish static routes\n"
469 "IP destination prefix\n"
470 "IP destination prefix mask\n"
471 "Emit an ICMP unreachable when matched\n"
472 "Silently discard pkts when matched\n"
473 "Distance value for this route\n")
474{
475 return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
476}
477
Paul Jakma7514fb72007-05-02 16:05:35 +0000478char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
479
480DEFUN (ip_protocol,
481 ip_protocol_cmd,
482 "ip protocol PROTO route-map ROUTE-MAP",
483 NO_STR
484 "Apply route map to PROTO\n"
485 "Protocol name\n"
486 "Route map name\n")
487{
488 int i;
489
490 if (strcasecmp(argv[0], "any") == 0)
491 i = ZEBRA_ROUTE_MAX;
492 else
493 i = proto_name2num(argv[0]);
494 if (i < 0)
495 {
496 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
497 VTY_NEWLINE);
498 return CMD_WARNING;
499 }
500 if (proto_rm[AFI_IP][i])
501 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
502 proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
503 return CMD_SUCCESS;
504}
505
506DEFUN (no_ip_protocol,
507 no_ip_protocol_cmd,
508 "no ip protocol PROTO",
509 NO_STR
510 "Remove route map from PROTO\n"
511 "Protocol name\n")
512{
513 int i;
514
515 if (strcasecmp(argv[0], "any") == 0)
516 i = ZEBRA_ROUTE_MAX;
517 else
518 i = proto_name2num(argv[0]);
519 if (i < 0)
520 {
521 vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
522 VTY_NEWLINE);
523 return CMD_WARNING;
524 }
525 if (proto_rm[AFI_IP][i])
526 XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
527 proto_rm[AFI_IP][i] = NULL;
528 return CMD_SUCCESS;
529}
530
paul718e3742002-12-13 20:15:29 +0000531/* New RIB. Detailed information for IPv4 route. */
paula1ac18c2005-06-28 17:17:12 +0000532static void
paul718e3742002-12-13 20:15:29 +0000533vty_show_ip_route_detail (struct vty *vty, struct route_node *rn)
534{
535 struct rib *rib;
536 struct nexthop *nexthop;
537
538 for (rib = rn->info; rib; rib = rib->next)
539 {
540 vty_out (vty, "Routing entry for %s/%d%s",
541 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
542 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +0000543 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
paul718e3742002-12-13 20:15:29 +0000544 vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric);
545 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
546 vty_out (vty, ", best");
547 if (rib->refcnt)
548 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +0000549 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
550 vty_out (vty, ", blackhole");
551 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
552 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +0000553 vty_out (vty, "%s", VTY_NEWLINE);
554
555#define ONE_DAY_SECOND 60*60*24
556#define ONE_WEEK_SECOND 60*60*24*7
557 if (rib->type == ZEBRA_ROUTE_RIP
558 || rib->type == ZEBRA_ROUTE_OSPF
jardin9e867fe2003-12-23 08:56:18 +0000559 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000560 || rib->type == ZEBRA_ROUTE_BGP)
561 {
562 time_t uptime;
563 struct tm *tm;
564
565 uptime = time (NULL);
566 uptime -= rib->uptime;
567 tm = gmtime (&uptime);
568
569 vty_out (vty, " Last update ");
570
571 if (uptime < ONE_DAY_SECOND)
572 vty_out (vty, "%02d:%02d:%02d",
573 tm->tm_hour, tm->tm_min, tm->tm_sec);
574 else if (uptime < ONE_WEEK_SECOND)
575 vty_out (vty, "%dd%02dh%02dm",
576 tm->tm_yday, tm->tm_hour, tm->tm_min);
577 else
578 vty_out (vty, "%02dw%dd%02dh",
579 tm->tm_yday/7,
580 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
581 vty_out (vty, " ago%s", VTY_NEWLINE);
582 }
583
584 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
585 {
Paul Jakma7514fb72007-05-02 16:05:35 +0000586 char addrstr[32];
587
paul718e3742002-12-13 20:15:29 +0000588 vty_out (vty, " %c",
589 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ');
590
591 switch (nexthop->type)
592 {
593 case NEXTHOP_TYPE_IPV4:
594 case NEXTHOP_TYPE_IPV4_IFINDEX:
595 vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4));
596 if (nexthop->ifindex)
597 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
598 break;
599 case NEXTHOP_TYPE_IFINDEX:
600 vty_out (vty, " directly connected, %s",
601 ifindex2ifname (nexthop->ifindex));
602 break;
603 case NEXTHOP_TYPE_IFNAME:
604 vty_out (vty, " directly connected, %s", nexthop->ifname);
605 break;
paul595db7f2003-05-25 21:35:06 +0000606 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000607 vty_out (vty, " directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000608 break;
paul7021c422003-07-15 12:52:22 +0000609 default:
paul718e3742002-12-13 20:15:29 +0000610 break;
611 }
612 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
613 vty_out (vty, " inactive");
614
615 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
616 {
617 vty_out (vty, " (recursive");
618
619 switch (nexthop->rtype)
620 {
621 case NEXTHOP_TYPE_IPV4:
622 case NEXTHOP_TYPE_IPV4_IFINDEX:
623 vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
624 break;
625 case NEXTHOP_TYPE_IFINDEX:
626 case NEXTHOP_TYPE_IFNAME:
627 vty_out (vty, " is directly connected, %s)",
628 ifindex2ifname (nexthop->rifindex));
629 break;
630 default:
631 break;
632 }
633 }
Paul Jakma7514fb72007-05-02 16:05:35 +0000634 switch (nexthop->type)
635 {
636 case NEXTHOP_TYPE_IPV4:
637 case NEXTHOP_TYPE_IPV4_IFINDEX:
638 case NEXTHOP_TYPE_IPV4_IFNAME:
639 if (nexthop->src.ipv4.s_addr)
640 {
641 if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr,
642 sizeof addrstr))
643 vty_out (vty, ", src %s", addrstr);
644 }
645 break;
646 case NEXTHOP_TYPE_IPV6:
647 case NEXTHOP_TYPE_IPV6_IFINDEX:
648 case NEXTHOP_TYPE_IPV6_IFNAME:
649 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
650 {
651 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr,
652 sizeof addrstr))
653 vty_out (vty, ", src %s", addrstr);
654 }
655 break;
656 default:
657 break;
658 }
paul718e3742002-12-13 20:15:29 +0000659 vty_out (vty, "%s", VTY_NEWLINE);
660 }
661 vty_out (vty, "%s", VTY_NEWLINE);
662 }
663}
664
paula1ac18c2005-06-28 17:17:12 +0000665static void
paul718e3742002-12-13 20:15:29 +0000666vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib)
667{
668 struct nexthop *nexthop;
669 int len = 0;
670 char buf[BUFSIZ];
671
672 /* Nexthop information. */
673 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
674 {
675 if (nexthop == rib->nexthop)
676 {
677 /* Prefix information. */
678 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +0000679 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +0000680 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
681 ? '>' : ' ',
682 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
683 ? '*' : ' ',
684 inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ),
685 rn->p.prefixlen);
686
687 /* Distance and metric display. */
688 if (rib->type != ZEBRA_ROUTE_CONNECT
689 && rib->type != ZEBRA_ROUTE_KERNEL)
690 len += vty_out (vty, " [%d/%d]", rib->distance,
691 rib->metric);
692 }
693 else
694 vty_out (vty, " %c%*c",
695 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
696 ? '*' : ' ',
697 len - 3, ' ');
698
699 switch (nexthop->type)
700 {
701 case NEXTHOP_TYPE_IPV4:
702 case NEXTHOP_TYPE_IPV4_IFINDEX:
703 vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4));
704 if (nexthop->ifindex)
705 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
706 break;
707 case NEXTHOP_TYPE_IFINDEX:
708 vty_out (vty, " is directly connected, %s",
709 ifindex2ifname (nexthop->ifindex));
710 break;
711 case NEXTHOP_TYPE_IFNAME:
712 vty_out (vty, " is directly connected, %s", nexthop->ifname);
713 break;
paul595db7f2003-05-25 21:35:06 +0000714 case NEXTHOP_TYPE_BLACKHOLE:
paul7021c422003-07-15 12:52:22 +0000715 vty_out (vty, " is directly connected, Null0");
paul595db7f2003-05-25 21:35:06 +0000716 break;
paul7021c422003-07-15 12:52:22 +0000717 default:
paul718e3742002-12-13 20:15:29 +0000718 break;
719 }
720 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
721 vty_out (vty, " inactive");
722
723 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
724 {
725 vty_out (vty, " (recursive");
726
727 switch (nexthop->rtype)
728 {
729 case NEXTHOP_TYPE_IPV4:
730 case NEXTHOP_TYPE_IPV4_IFINDEX:
731 vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
732 break;
733 case NEXTHOP_TYPE_IFINDEX:
734 case NEXTHOP_TYPE_IFNAME:
735 vty_out (vty, " is directly connected, %s)",
736 ifindex2ifname (nexthop->rifindex));
737 break;
738 default:
739 break;
740 }
741 }
Paul Jakma7514fb72007-05-02 16:05:35 +0000742 switch (nexthop->type)
743 {
744 case NEXTHOP_TYPE_IPV4:
745 case NEXTHOP_TYPE_IPV4_IFINDEX:
746 case NEXTHOP_TYPE_IPV4_IFNAME:
747 if (nexthop->src.ipv4.s_addr)
748 {
749 if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf))
750 vty_out (vty, ", src %s", buf);
751 }
752 break;
753 case NEXTHOP_TYPE_IPV6:
754 case NEXTHOP_TYPE_IPV6_IFINDEX:
755 case NEXTHOP_TYPE_IPV6_IFNAME:
756 if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any))
757 {
758 if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf))
759 vty_out (vty, ", src %s", buf);
760 }
761 break;
762 default:
763 break;
764 }
paul718e3742002-12-13 20:15:29 +0000765
hasso81dfcaa2003-05-25 19:21:25 +0000766 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
767 vty_out (vty, ", bh");
768 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
769 vty_out (vty, ", rej");
770
paul718e3742002-12-13 20:15:29 +0000771 if (rib->type == ZEBRA_ROUTE_RIP
772 || rib->type == ZEBRA_ROUTE_OSPF
jardin9e867fe2003-12-23 08:56:18 +0000773 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +0000774 || rib->type == ZEBRA_ROUTE_BGP)
775 {
776 time_t uptime;
777 struct tm *tm;
778
779 uptime = time (NULL);
780 uptime -= rib->uptime;
781 tm = gmtime (&uptime);
782
783#define ONE_DAY_SECOND 60*60*24
784#define ONE_WEEK_SECOND 60*60*24*7
785
786 if (uptime < ONE_DAY_SECOND)
787 vty_out (vty, ", %02d:%02d:%02d",
788 tm->tm_hour, tm->tm_min, tm->tm_sec);
789 else if (uptime < ONE_WEEK_SECOND)
790 vty_out (vty, ", %dd%02dh%02dm",
791 tm->tm_yday, tm->tm_hour, tm->tm_min);
792 else
793 vty_out (vty, ", %02dw%dd%02dh",
794 tm->tm_yday/7,
795 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
796 }
797 vty_out (vty, "%s", VTY_NEWLINE);
798 }
799}
800
hasso39db97e2004-10-12 20:50:58 +0000801#define SHOW_ROUTE_V4_HEADER "Codes: K - kernel route, C - connected, " \
802 "S - static, R - RIP, O - OSPF,%s I - ISIS, B - BGP, " \
803 "> - selected route, * - FIB route%s%s"
paul718e3742002-12-13 20:15:29 +0000804
805DEFUN (show_ip_route,
806 show_ip_route_cmd,
807 "show ip route",
808 SHOW_STR
809 IP_STR
810 "IP routing table\n")
811{
812 struct route_table *table;
813 struct route_node *rn;
814 struct rib *rib;
815 int first = 1;
816
817 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
818 if (! table)
819 return CMD_SUCCESS;
820
821 /* Show all IPv4 routes. */
822 for (rn = route_top (table); rn; rn = route_next (rn))
823 for (rib = rn->info; rib; rib = rib->next)
824 {
825 if (first)
826 {
827 vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, VTY_NEWLINE,
828 VTY_NEWLINE);
829 first = 0;
830 }
831 vty_show_ip_route (vty, rn, rib);
832 }
833 return CMD_SUCCESS;
834}
835
836DEFUN (show_ip_route_prefix_longer,
837 show_ip_route_prefix_longer_cmd,
838 "show ip route A.B.C.D/M longer-prefixes",
839 SHOW_STR
840 IP_STR
841 "IP routing table\n"
842 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
843 "Show route matching the specified Network/Mask pair only\n")
844{
845 struct route_table *table;
846 struct route_node *rn;
847 struct rib *rib;
848 struct prefix p;
849 int ret;
850 int first = 1;
851
852 ret = str2prefix (argv[0], &p);
853 if (! ret)
854 {
855 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
856 return CMD_WARNING;
857 }
858
859 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
860 if (! table)
861 return CMD_SUCCESS;
862
863 /* Show matched type IPv4 routes. */
864 for (rn = route_top (table); rn; rn = route_next (rn))
865 for (rib = rn->info; rib; rib = rib->next)
866 if (prefix_match (&p, &rn->p))
867 {
868 if (first)
869 {
870 vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE,
871 VTY_NEWLINE, VTY_NEWLINE);
872 first = 0;
873 }
874 vty_show_ip_route (vty, rn, rib);
875 }
876 return CMD_SUCCESS;
877}
878
879DEFUN (show_ip_route_supernets,
880 show_ip_route_supernets_cmd,
881 "show ip route supernets-only",
882 SHOW_STR
883 IP_STR
884 "IP routing table\n"
885 "Show supernet entries only\n")
886{
887 struct route_table *table;
888 struct route_node *rn;
889 struct rib *rib;
890 u_int32_t addr;
891 int first = 1;
892
893 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
894 if (! table)
895 return CMD_SUCCESS;
896
897 /* Show matched type IPv4 routes. */
898 for (rn = route_top (table); rn; rn = route_next (rn))
899 for (rib = rn->info; rib; rib = rib->next)
900 {
901 addr = ntohl (rn->p.u.prefix4.s_addr);
902
903 if ((IN_CLASSC (addr) && rn->p.prefixlen < 24)
904 || (IN_CLASSB (addr) && rn->p.prefixlen < 16)
905 || (IN_CLASSA (addr) && rn->p.prefixlen < 8))
906 {
907 if (first)
908 {
909 vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE,
910 VTY_NEWLINE, VTY_NEWLINE);
911 first = 0;
912 }
913 vty_show_ip_route (vty, rn, rib);
914 }
915 }
916 return CMD_SUCCESS;
917}
918
919DEFUN (show_ip_route_protocol,
920 show_ip_route_protocol_cmd,
hasso39ff11d2004-10-12 15:55:19 +0000921 "show ip route (bgp|connected|isis|kernel|ospf|rip|static)",
paul718e3742002-12-13 20:15:29 +0000922 SHOW_STR
923 IP_STR
924 "IP routing table\n"
925 "Border Gateway Protocol (BGP)\n"
926 "Connected\n"
hasso39ff11d2004-10-12 15:55:19 +0000927 "ISO IS-IS (ISIS)\n"
paul718e3742002-12-13 20:15:29 +0000928 "Kernel\n"
929 "Open Shortest Path First (OSPF)\n"
930 "Routing Information Protocol (RIP)\n"
931 "Static routes\n")
932{
933 int type;
934 struct route_table *table;
935 struct route_node *rn;
936 struct rib *rib;
937 int first = 1;
938
939 if (strncmp (argv[0], "b", 1) == 0)
940 type = ZEBRA_ROUTE_BGP;
941 else if (strncmp (argv[0], "c", 1) == 0)
942 type = ZEBRA_ROUTE_CONNECT;
943 else if (strncmp (argv[0], "k", 1) ==0)
944 type = ZEBRA_ROUTE_KERNEL;
945 else if (strncmp (argv[0], "o", 1) == 0)
946 type = ZEBRA_ROUTE_OSPF;
jardin9e867fe2003-12-23 08:56:18 +0000947 else if (strncmp (argv[0], "i", 1) == 0)
948 type = ZEBRA_ROUTE_ISIS;
paul718e3742002-12-13 20:15:29 +0000949 else if (strncmp (argv[0], "r", 1) == 0)
950 type = ZEBRA_ROUTE_RIP;
951 else if (strncmp (argv[0], "s", 1) == 0)
952 type = ZEBRA_ROUTE_STATIC;
953 else
954 {
955 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
956 return CMD_WARNING;
957 }
958
959 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
960 if (! table)
961 return CMD_SUCCESS;
962
963 /* Show matched type IPv4 routes. */
964 for (rn = route_top (table); rn; rn = route_next (rn))
965 for (rib = rn->info; rib; rib = rib->next)
966 if (rib->type == type)
967 {
968 if (first)
969 {
970 vty_out (vty, SHOW_ROUTE_V4_HEADER,
971 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
972 first = 0;
973 }
974 vty_show_ip_route (vty, rn, rib);
975 }
976 return CMD_SUCCESS;
977}
978
979DEFUN (show_ip_route_addr,
980 show_ip_route_addr_cmd,
981 "show ip route A.B.C.D",
982 SHOW_STR
983 IP_STR
984 "IP routing table\n"
985 "Network in the IP routing table to display\n")
986{
987 int ret;
988 struct prefix_ipv4 p;
989 struct route_table *table;
990 struct route_node *rn;
991
992 ret = str2prefix_ipv4 (argv[0], &p);
993 if (ret <= 0)
994 {
995 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
996 return CMD_WARNING;
997 }
998
999 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1000 if (! table)
1001 return CMD_SUCCESS;
1002
1003 rn = route_node_match (table, (struct prefix *) &p);
1004 if (! rn)
1005 {
1006 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1007 return CMD_WARNING;
1008 }
1009
1010 vty_show_ip_route_detail (vty, rn);
1011
1012 route_unlock_node (rn);
1013
1014 return CMD_SUCCESS;
1015}
1016
1017DEFUN (show_ip_route_prefix,
1018 show_ip_route_prefix_cmd,
1019 "show ip route A.B.C.D/M",
1020 SHOW_STR
1021 IP_STR
1022 "IP routing table\n"
1023 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1024{
1025 int ret;
1026 struct prefix_ipv4 p;
1027 struct route_table *table;
1028 struct route_node *rn;
1029
1030 ret = str2prefix_ipv4 (argv[0], &p);
1031 if (ret <= 0)
1032 {
1033 vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE);
1034 return CMD_WARNING;
1035 }
1036
1037 table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
1038 if (! table)
1039 return CMD_SUCCESS;
1040
1041 rn = route_node_match (table, (struct prefix *) &p);
1042 if (! rn || rn->p.prefixlen != p.prefixlen)
1043 {
1044 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1045 return CMD_WARNING;
1046 }
1047
1048 vty_show_ip_route_detail (vty, rn);
1049
1050 route_unlock_node (rn);
1051
1052 return CMD_SUCCESS;
1053}
1054
paula1ac18c2005-06-28 17:17:12 +00001055static void
paul718e3742002-12-13 20:15:29 +00001056zebra_show_ip_route (struct vty *vty, struct vrf *vrf)
1057{
1058 vty_out (vty, "IP routing table name is %s(%d)%s",
1059 vrf->name ? vrf->name : "", vrf->id, VTY_NEWLINE);
1060
1061 vty_out (vty, "Route Source Networks%s", VTY_NEWLINE);
1062 vty_out (vty, "connected %d%s", 0, VTY_NEWLINE);
1063 vty_out (vty, "static %d%s", 0, VTY_NEWLINE);
1064 vty_out (vty, "rip %d%s", 0, VTY_NEWLINE);
1065
1066 vty_out (vty, "bgp %d%s", 0, VTY_NEWLINE);
1067 vty_out (vty, " External: %d Internal: %d Local: %d%s",
1068 0, 0, 0, VTY_NEWLINE);
1069
1070 vty_out (vty, "ospf %d%s", 0, VTY_NEWLINE);
1071 vty_out (vty,
1072 " Intra-area: %d Inter-area: %d External-1: %d External-2: %d%s",
1073 0, 0, 0, 0, VTY_NEWLINE);
1074 vty_out (vty, " NSSA External-1: %d NSSA External-2: %d%s",
1075 0, 0, VTY_NEWLINE);
1076
1077 vty_out (vty, "internal %d%s", 0, VTY_NEWLINE);
1078 vty_out (vty, "Total %d%s", 0, VTY_NEWLINE);
1079}
1080
1081/* Show route summary. */
1082DEFUN (show_ip_route_summary,
1083 show_ip_route_summary_cmd,
1084 "show ip route summary",
1085 SHOW_STR
1086 IP_STR
1087 "IP routing table\n"
1088 "Summary of all routes\n")
1089{
1090 struct vrf *vrf;
1091
1092 /* Default table id is zero. */
1093 vrf = vrf_lookup (0);
1094 if (! vrf)
1095 {
1096 vty_out (vty, "%% No Default-IP-Routing-Table%s", VTY_NEWLINE);
1097 return CMD_WARNING;
1098 }
1099
1100 zebra_show_ip_route (vty, vrf);
1101
1102 return CMD_SUCCESS;
1103}
1104
1105/* Write IPv4 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00001106static int
paul718e3742002-12-13 20:15:29 +00001107static_config_ipv4 (struct vty *vty)
1108{
1109 struct route_node *rn;
1110 struct static_ipv4 *si;
1111 struct route_table *stable;
1112 int write;
1113
1114 write = 0;
1115
1116 /* Lookup table. */
1117 stable = vrf_static_table (AFI_IP, SAFI_UNICAST, 0);
1118 if (! stable)
1119 return -1;
1120
1121 for (rn = route_top (stable); rn; rn = route_next (rn))
1122 for (si = rn->info; si; si = si->next)
1123 {
paul7021c422003-07-15 12:52:22 +00001124 vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4),
1125 rn->p.prefixlen);
paul718e3742002-12-13 20:15:29 +00001126
paul7021c422003-07-15 12:52:22 +00001127 switch (si->type)
1128 {
1129 case STATIC_IPV4_GATEWAY:
1130 vty_out (vty, " %s", inet_ntoa (si->gate.ipv4));
1131 break;
1132 case STATIC_IPV4_IFNAME:
1133 vty_out (vty, " %s", si->gate.ifname);
1134 break;
1135 case STATIC_IPV4_BLACKHOLE:
1136 vty_out (vty, " Null0");
1137 break;
1138 }
1139
1140 /* flags are incompatible with STATIC_IPV4_BLACKHOLE */
1141 if (si->type != STATIC_IPV4_BLACKHOLE)
1142 {
1143 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
1144 vty_out (vty, " %s", "reject");
paul718e3742002-12-13 20:15:29 +00001145
paul7021c422003-07-15 12:52:22 +00001146 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
1147 vty_out (vty, " %s", "blackhole");
1148 }
hasso81dfcaa2003-05-25 19:21:25 +00001149
paul7021c422003-07-15 12:52:22 +00001150 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
1151 vty_out (vty, " %d", si->distance);
hasso81dfcaa2003-05-25 19:21:25 +00001152
paul7021c422003-07-15 12:52:22 +00001153 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00001154
paul7021c422003-07-15 12:52:22 +00001155 write = 1;
paul718e3742002-12-13 20:15:29 +00001156 }
1157 return write;
1158}
1159
1160#ifdef HAVE_IPV6
1161/* General fucntion for IPv6 static route. */
paula1ac18c2005-06-28 17:17:12 +00001162static int
hasso39db97e2004-10-12 20:50:58 +00001163static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str,
1164 const char *gate_str, const char *ifname,
1165 const char *flag_str, const char *distance_str)
paul718e3742002-12-13 20:15:29 +00001166{
1167 int ret;
1168 u_char distance;
1169 struct prefix p;
1170 struct in6_addr *gate = NULL;
1171 struct in6_addr gate_addr;
1172 u_char type = 0;
1173 int table = 0;
hasso81dfcaa2003-05-25 19:21:25 +00001174 u_char flag = 0;
paul718e3742002-12-13 20:15:29 +00001175
1176 ret = str2prefix (dest_str, &p);
1177 if (ret <= 0)
1178 {
1179 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1180 return CMD_WARNING;
1181 }
1182
1183 /* Apply mask for given prefix. */
1184 apply_mask (&p);
1185
hasso81dfcaa2003-05-25 19:21:25 +00001186 /* Route flags */
1187 if (flag_str) {
1188 switch(flag_str[0]) {
1189 case 'r':
1190 case 'R': /* XXX */
1191 SET_FLAG (flag, ZEBRA_FLAG_REJECT);
1192 break;
1193 case 'b':
1194 case 'B': /* XXX */
1195 SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE);
1196 break;
1197 default:
1198 vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE);
paul595db7f2003-05-25 21:35:06 +00001199 return CMD_WARNING;
hasso81dfcaa2003-05-25 19:21:25 +00001200 }
1201 }
1202
paul718e3742002-12-13 20:15:29 +00001203 /* Administrative distance. */
1204 if (distance_str)
1205 distance = atoi (distance_str);
1206 else
1207 distance = ZEBRA_STATIC_DISTANCE_DEFAULT;
1208
1209 /* When gateway is valid IPv6 addrees, then gate is treated as
1210 nexthop address other case gate is treated as interface name. */
1211 ret = inet_pton (AF_INET6, gate_str, &gate_addr);
1212
1213 if (ifname)
1214 {
1215 /* When ifname is specified. It must be come with gateway
1216 address. */
1217 if (ret != 1)
1218 {
1219 vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
1220 return CMD_WARNING;
1221 }
1222 type = STATIC_IPV6_GATEWAY_IFNAME;
1223 gate = &gate_addr;
1224 }
1225 else
1226 {
1227 if (ret == 1)
1228 {
1229 type = STATIC_IPV6_GATEWAY;
1230 gate = &gate_addr;
1231 }
1232 else
1233 {
1234 type = STATIC_IPV6_IFNAME;
1235 ifname = gate_str;
1236 }
1237 }
1238
1239 if (add_cmd)
hasso81dfcaa2003-05-25 19:21:25 +00001240 static_add_ipv6 (&p, type, gate, ifname, flag, distance, table);
paul718e3742002-12-13 20:15:29 +00001241 else
1242 static_delete_ipv6 (&p, type, gate, ifname, distance, table);
1243
1244 return CMD_SUCCESS;
1245}
1246
1247DEFUN (ipv6_route,
1248 ipv6_route_cmd,
1249 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1250 IP_STR
1251 "Establish static routes\n"
1252 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1253 "IPv6 gateway address\n"
1254 "IPv6 gateway interface name\n")
1255{
hasso81dfcaa2003-05-25 19:21:25 +00001256 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL);
1257}
1258
1259DEFUN (ipv6_route_flags,
1260 ipv6_route_flags_cmd,
1261 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1262 IP_STR
1263 "Establish static routes\n"
1264 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1265 "IPv6 gateway address\n"
1266 "IPv6 gateway interface name\n"
1267 "Emit an ICMP unreachable when matched\n"
1268 "Silently discard pkts when matched\n")
1269{
1270 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL);
paul718e3742002-12-13 20:15:29 +00001271}
1272
1273DEFUN (ipv6_route_ifname,
1274 ipv6_route_ifname_cmd,
1275 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1276 IP_STR
1277 "Establish static routes\n"
1278 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1279 "IPv6 gateway address\n"
1280 "IPv6 gateway interface name\n")
1281{
hasso81dfcaa2003-05-25 19:21:25 +00001282 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL);
1283}
1284
1285DEFUN (ipv6_route_ifname_flags,
1286 ipv6_route_ifname_flags_cmd,
1287 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1288 IP_STR
1289 "Establish static routes\n"
1290 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1291 "IPv6 gateway address\n"
1292 "IPv6 gateway interface name\n"
1293 "Emit an ICMP unreachable when matched\n"
1294 "Silently discard pkts when matched\n")
1295{
1296 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL);
paul718e3742002-12-13 20:15:29 +00001297}
1298
1299DEFUN (ipv6_route_pref,
1300 ipv6_route_pref_cmd,
1301 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1302 IP_STR
1303 "Establish static routes\n"
1304 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1305 "IPv6 gateway address\n"
1306 "IPv6 gateway interface name\n"
1307 "Distance value for this prefix\n")
1308{
hasso81dfcaa2003-05-25 19:21:25 +00001309 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]);
1310}
1311
1312DEFUN (ipv6_route_flags_pref,
1313 ipv6_route_flags_pref_cmd,
1314 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1315 IP_STR
1316 "Establish static routes\n"
1317 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1318 "IPv6 gateway address\n"
1319 "IPv6 gateway interface name\n"
1320 "Emit an ICMP unreachable when matched\n"
1321 "Silently discard pkts when matched\n"
1322 "Distance value for this prefix\n")
1323{
1324 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001325}
1326
1327DEFUN (ipv6_route_ifname_pref,
1328 ipv6_route_ifname_pref_cmd,
1329 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1330 IP_STR
1331 "Establish static routes\n"
1332 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1333 "IPv6 gateway address\n"
1334 "IPv6 gateway interface name\n"
1335 "Distance value for this prefix\n")
1336{
hasso81dfcaa2003-05-25 19:21:25 +00001337 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]);
1338}
1339
1340DEFUN (ipv6_route_ifname_flags_pref,
1341 ipv6_route_ifname_flags_pref_cmd,
1342 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1343 IP_STR
1344 "Establish static routes\n"
1345 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1346 "IPv6 gateway address\n"
1347 "IPv6 gateway interface name\n"
1348 "Emit an ICMP unreachable when matched\n"
1349 "Silently discard pkts when matched\n"
1350 "Distance value for this prefix\n")
1351{
1352 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001353}
1354
1355DEFUN (no_ipv6_route,
1356 no_ipv6_route_cmd,
1357 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)",
1358 NO_STR
1359 IP_STR
1360 "Establish static routes\n"
1361 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1362 "IPv6 gateway address\n"
1363 "IPv6 gateway interface name\n")
1364{
hasso81dfcaa2003-05-25 19:21:25 +00001365 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001366}
1367
hasso81dfcaa2003-05-25 19:21:25 +00001368ALIAS (no_ipv6_route,
1369 no_ipv6_route_flags_cmd,
1370 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)",
1371 NO_STR
1372 IP_STR
1373 "Establish static routes\n"
1374 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1375 "IPv6 gateway address\n"
1376 "IPv6 gateway interface name\n"
1377 "Emit an ICMP unreachable when matched\n"
1378 "Silently discard pkts when matched\n")
1379
paul718e3742002-12-13 20:15:29 +00001380DEFUN (no_ipv6_route_ifname,
1381 no_ipv6_route_ifname_cmd,
1382 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE",
1383 NO_STR
1384 IP_STR
1385 "Establish static routes\n"
1386 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1387 "IPv6 gateway address\n"
1388 "IPv6 gateway interface name\n")
1389{
hasso81dfcaa2003-05-25 19:21:25 +00001390 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL);
paul718e3742002-12-13 20:15:29 +00001391}
1392
hasso81dfcaa2003-05-25 19:21:25 +00001393ALIAS (no_ipv6_route_ifname,
1394 no_ipv6_route_ifname_flags_cmd,
1395 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)",
1396 NO_STR
1397 IP_STR
1398 "Establish static routes\n"
1399 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1400 "IPv6 gateway address\n"
1401 "IPv6 gateway interface name\n"
1402 "Emit an ICMP unreachable when matched\n"
1403 "Silently discard pkts when matched\n")
1404
paul718e3742002-12-13 20:15:29 +00001405DEFUN (no_ipv6_route_pref,
1406 no_ipv6_route_pref_cmd,
1407 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>",
1408 NO_STR
1409 IP_STR
1410 "Establish static routes\n"
1411 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1412 "IPv6 gateway address\n"
1413 "IPv6 gateway interface name\n"
1414 "Distance value for this prefix\n")
1415{
hasso81dfcaa2003-05-25 19:21:25 +00001416 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]);
1417}
1418
1419DEFUN (no_ipv6_route_flags_pref,
1420 no_ipv6_route_flags_pref_cmd,
1421 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>",
1422 NO_STR
1423 IP_STR
1424 "Establish static routes\n"
1425 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1426 "IPv6 gateway address\n"
1427 "IPv6 gateway interface name\n"
1428 "Emit an ICMP unreachable when matched\n"
1429 "Silently discard pkts when matched\n"
1430 "Distance value for this prefix\n")
1431{
1432 /* We do not care about argv[2] */
1433 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]);
paul718e3742002-12-13 20:15:29 +00001434}
1435
1436DEFUN (no_ipv6_route_ifname_pref,
1437 no_ipv6_route_ifname_pref_cmd,
1438 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>",
1439 NO_STR
1440 IP_STR
1441 "Establish static routes\n"
1442 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1443 "IPv6 gateway address\n"
1444 "IPv6 gateway interface name\n"
1445 "Distance value for this prefix\n")
1446{
hasso81dfcaa2003-05-25 19:21:25 +00001447 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]);
1448}
1449
1450DEFUN (no_ipv6_route_ifname_flags_pref,
1451 no_ipv6_route_ifname_flags_pref_cmd,
1452 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>",
1453 NO_STR
1454 IP_STR
1455 "Establish static routes\n"
1456 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
1457 "IPv6 gateway address\n"
1458 "IPv6 gateway interface name\n"
1459 "Emit an ICMP unreachable when matched\n"
1460 "Silently discard pkts when matched\n"
1461 "Distance value for this prefix\n")
1462{
1463 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]);
paul718e3742002-12-13 20:15:29 +00001464}
1465
paul595db7f2003-05-25 21:35:06 +00001466/* New RIB. Detailed information for IPv6 route. */
paula1ac18c2005-06-28 17:17:12 +00001467static void
paul718e3742002-12-13 20:15:29 +00001468vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn)
1469{
1470 struct rib *rib;
1471 struct nexthop *nexthop;
1472 char buf[BUFSIZ];
1473
1474 for (rib = rn->info; rib; rib = rib->next)
1475 {
1476 vty_out (vty, "Routing entry for %s/%d%s",
1477 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1478 rn->p.prefixlen,
1479 VTY_NEWLINE);
ajsf52d13c2005-10-01 17:38:06 +00001480 vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type));
paul718e3742002-12-13 20:15:29 +00001481 vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric);
1482 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
1483 vty_out (vty, ", best");
1484 if (rib->refcnt)
1485 vty_out (vty, ", refcnt %ld", rib->refcnt);
hasso81dfcaa2003-05-25 19:21:25 +00001486 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1487 vty_out (vty, ", blackhole");
1488 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1489 vty_out (vty, ", reject");
paul718e3742002-12-13 20:15:29 +00001490 vty_out (vty, "%s", VTY_NEWLINE);
1491
1492#define ONE_DAY_SECOND 60*60*24
1493#define ONE_WEEK_SECOND 60*60*24*7
1494 if (rib->type == ZEBRA_ROUTE_RIPNG
1495 || rib->type == ZEBRA_ROUTE_OSPF6
jardin9e867fe2003-12-23 08:56:18 +00001496 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001497 || rib->type == ZEBRA_ROUTE_BGP)
1498 {
1499 time_t uptime;
1500 struct tm *tm;
1501
1502 uptime = time (NULL);
1503 uptime -= rib->uptime;
1504 tm = gmtime (&uptime);
1505
1506 vty_out (vty, " Last update ");
1507
1508 if (uptime < ONE_DAY_SECOND)
1509 vty_out (vty, "%02d:%02d:%02d",
1510 tm->tm_hour, tm->tm_min, tm->tm_sec);
1511 else if (uptime < ONE_WEEK_SECOND)
1512 vty_out (vty, "%dd%02dh%02dm",
1513 tm->tm_yday, tm->tm_hour, tm->tm_min);
1514 else
1515 vty_out (vty, "%02dw%dd%02dh",
1516 tm->tm_yday/7,
1517 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1518 vty_out (vty, " ago%s", VTY_NEWLINE);
1519 }
1520
1521 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1522 {
1523 vty_out (vty, " %c",
1524 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ');
1525
1526 switch (nexthop->type)
1527 {
1528 case NEXTHOP_TYPE_IPV6:
1529 case NEXTHOP_TYPE_IPV6_IFINDEX:
1530 case NEXTHOP_TYPE_IPV6_IFNAME:
1531 vty_out (vty, " %s",
1532 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1533 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1534 vty_out (vty, ", %s", nexthop->ifname);
1535 else if (nexthop->ifindex)
1536 vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex));
1537 break;
1538 case NEXTHOP_TYPE_IFINDEX:
1539 vty_out (vty, " directly connected, %s",
1540 ifindex2ifname (nexthop->ifindex));
1541 break;
1542 case NEXTHOP_TYPE_IFNAME:
1543 vty_out (vty, " directly connected, %s",
1544 nexthop->ifname);
1545 break;
1546 default:
1547 break;
1548 }
1549 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1550 vty_out (vty, " inactive");
1551
1552 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1553 {
1554 vty_out (vty, " (recursive");
1555
1556 switch (nexthop->rtype)
1557 {
1558 case NEXTHOP_TYPE_IPV6:
1559 case NEXTHOP_TYPE_IPV6_IFINDEX:
1560 case NEXTHOP_TYPE_IPV6_IFNAME:
1561 vty_out (vty, " via %s)",
1562 inet_ntop (AF_INET6, &nexthop->rgate.ipv6,
1563 buf, BUFSIZ));
1564 if (nexthop->rifindex)
1565 vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex));
1566 break;
1567 case NEXTHOP_TYPE_IFINDEX:
1568 case NEXTHOP_TYPE_IFNAME:
1569 vty_out (vty, " is directly connected, %s)",
1570 ifindex2ifname (nexthop->rifindex));
1571 break;
1572 default:
1573 break;
1574 }
1575 }
1576 vty_out (vty, "%s", VTY_NEWLINE);
1577 }
1578 vty_out (vty, "%s", VTY_NEWLINE);
1579 }
1580}
1581
paula1ac18c2005-06-28 17:17:12 +00001582static void
paul718e3742002-12-13 20:15:29 +00001583vty_show_ipv6_route (struct vty *vty, struct route_node *rn,
1584 struct rib *rib)
1585{
1586 struct nexthop *nexthop;
1587 int len = 0;
1588 char buf[BUFSIZ];
1589
1590 /* Nexthop information. */
1591 for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
1592 {
1593 if (nexthop == rib->nexthop)
1594 {
1595 /* Prefix information. */
1596 len = vty_out (vty, "%c%c%c %s/%d",
ajsf52d13c2005-10-01 17:38:06 +00001597 zebra_route_char (rib->type),
paul718e3742002-12-13 20:15:29 +00001598 CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)
1599 ? '>' : ' ',
1600 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1601 ? '*' : ' ',
1602 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1603 rn->p.prefixlen);
1604
1605 /* Distance and metric display. */
1606 if (rib->type != ZEBRA_ROUTE_CONNECT
1607 && rib->type != ZEBRA_ROUTE_KERNEL)
1608 len += vty_out (vty, " [%d/%d]", rib->distance,
1609 rib->metric);
1610 }
1611 else
1612 vty_out (vty, " %c%*c",
1613 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
1614 ? '*' : ' ',
1615 len - 3, ' ');
1616
1617 switch (nexthop->type)
1618 {
1619 case NEXTHOP_TYPE_IPV6:
1620 case NEXTHOP_TYPE_IPV6_IFINDEX:
1621 case NEXTHOP_TYPE_IPV6_IFNAME:
1622 vty_out (vty, " via %s",
1623 inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ));
1624 if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
1625 vty_out (vty, ", %s", nexthop->ifname);
1626 else if (nexthop->ifindex)
1627 vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex));
1628 break;
1629 case NEXTHOP_TYPE_IFINDEX:
1630 vty_out (vty, " is directly connected, %s",
1631 ifindex2ifname (nexthop->ifindex));
1632 break;
1633 case NEXTHOP_TYPE_IFNAME:
1634 vty_out (vty, " is directly connected, %s",
1635 nexthop->ifname);
1636 break;
1637 default:
1638 break;
1639 }
1640 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
1641 vty_out (vty, " inactive");
1642
1643 if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
1644 {
1645 vty_out (vty, " (recursive");
1646
1647 switch (nexthop->rtype)
1648 {
1649 case NEXTHOP_TYPE_IPV6:
1650 case NEXTHOP_TYPE_IPV6_IFINDEX:
1651 case NEXTHOP_TYPE_IPV6_IFNAME:
1652 vty_out (vty, " via %s)",
1653 inet_ntop (AF_INET6, &nexthop->rgate.ipv6,
1654 buf, BUFSIZ));
1655 if (nexthop->rifindex)
1656 vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex));
1657 break;
1658 case NEXTHOP_TYPE_IFINDEX:
1659 case NEXTHOP_TYPE_IFNAME:
1660 vty_out (vty, " is directly connected, %s)",
1661 ifindex2ifname (nexthop->rifindex));
1662 break;
1663 default:
1664 break;
1665 }
1666 }
1667
hasso81dfcaa2003-05-25 19:21:25 +00001668 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE))
1669 vty_out (vty, ", bh");
1670 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT))
1671 vty_out (vty, ", rej");
1672
paul718e3742002-12-13 20:15:29 +00001673 if (rib->type == ZEBRA_ROUTE_RIPNG
1674 || rib->type == ZEBRA_ROUTE_OSPF6
jardin9e867fe2003-12-23 08:56:18 +00001675 || rib->type == ZEBRA_ROUTE_ISIS
paul718e3742002-12-13 20:15:29 +00001676 || rib->type == ZEBRA_ROUTE_BGP)
1677 {
1678 time_t uptime;
1679 struct tm *tm;
1680
1681 uptime = time (NULL);
1682 uptime -= rib->uptime;
1683 tm = gmtime (&uptime);
1684
1685#define ONE_DAY_SECOND 60*60*24
1686#define ONE_WEEK_SECOND 60*60*24*7
1687
1688 if (uptime < ONE_DAY_SECOND)
1689 vty_out (vty, ", %02d:%02d:%02d",
1690 tm->tm_hour, tm->tm_min, tm->tm_sec);
1691 else if (uptime < ONE_WEEK_SECOND)
1692 vty_out (vty, ", %dd%02dh%02dm",
1693 tm->tm_yday, tm->tm_hour, tm->tm_min);
1694 else
1695 vty_out (vty, ", %02dw%dd%02dh",
1696 tm->tm_yday/7,
1697 tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour);
1698 }
1699 vty_out (vty, "%s", VTY_NEWLINE);
1700 }
1701}
1702
jardin9e867fe2003-12-23 08:56:18 +00001703#define SHOW_ROUTE_V6_HEADER "Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3,%s I - ISIS, B - BGP, * - FIB route.%s%s"
paul718e3742002-12-13 20:15:29 +00001704
1705DEFUN (show_ipv6_route,
1706 show_ipv6_route_cmd,
1707 "show ipv6 route",
1708 SHOW_STR
1709 IP_STR
1710 "IPv6 routing table\n")
1711{
1712 struct route_table *table;
1713 struct route_node *rn;
1714 struct rib *rib;
1715 int first = 1;
1716
1717 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1718 if (! table)
1719 return CMD_SUCCESS;
1720
1721 /* Show all IPv6 route. */
1722 for (rn = route_top (table); rn; rn = route_next (rn))
1723 for (rib = rn->info; rib; rib = rib->next)
1724 {
1725 if (first)
1726 {
1727 vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1728 first = 0;
1729 }
1730 vty_show_ipv6_route (vty, rn, rib);
1731 }
1732 return CMD_SUCCESS;
1733}
1734
1735DEFUN (show_ipv6_route_prefix_longer,
1736 show_ipv6_route_prefix_longer_cmd,
1737 "show ipv6 route X:X::X:X/M longer-prefixes",
1738 SHOW_STR
1739 IP_STR
1740 "IPv6 routing table\n"
1741 "IPv6 prefix\n"
1742 "Show route matching the specified Network/Mask pair only\n")
1743{
1744 struct route_table *table;
1745 struct route_node *rn;
1746 struct rib *rib;
1747 struct prefix p;
1748 int ret;
1749 int first = 1;
1750
1751 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1752 if (! table)
1753 return CMD_SUCCESS;
1754
1755 ret = str2prefix (argv[0], &p);
1756 if (! ret)
1757 {
1758 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
1759 return CMD_WARNING;
1760 }
1761
1762 /* Show matched type IPv6 routes. */
1763 for (rn = route_top (table); rn; rn = route_next (rn))
1764 for (rib = rn->info; rib; rib = rib->next)
1765 if (prefix_match (&p, &rn->p))
1766 {
1767 if (first)
1768 {
1769 vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1770 first = 0;
1771 }
1772 vty_show_ipv6_route (vty, rn, rib);
1773 }
1774 return CMD_SUCCESS;
1775}
1776
1777DEFUN (show_ipv6_route_protocol,
1778 show_ipv6_route_protocol_cmd,
hassob8adec12004-12-18 16:03:28 +00001779 "show ipv6 route (bgp|connected|isis|kernel|ospf6|ripng|static)",
paul718e3742002-12-13 20:15:29 +00001780 SHOW_STR
1781 IP_STR
1782 "IP routing table\n"
1783 "Border Gateway Protocol (BGP)\n"
1784 "Connected\n"
hassob8adec12004-12-18 16:03:28 +00001785 "ISO IS-IS (ISIS)\n"
paul718e3742002-12-13 20:15:29 +00001786 "Kernel\n"
1787 "Open Shortest Path First (OSPFv3)\n"
1788 "Routing Information Protocol (RIPng)\n"
1789 "Static routes\n")
1790{
1791 int type;
1792 struct route_table *table;
1793 struct route_node *rn;
1794 struct rib *rib;
1795 int first = 1;
1796
1797 if (strncmp (argv[0], "b", 1) == 0)
1798 type = ZEBRA_ROUTE_BGP;
1799 else if (strncmp (argv[0], "c", 1) == 0)
1800 type = ZEBRA_ROUTE_CONNECT;
1801 else if (strncmp (argv[0], "k", 1) ==0)
1802 type = ZEBRA_ROUTE_KERNEL;
1803 else if (strncmp (argv[0], "o", 1) == 0)
1804 type = ZEBRA_ROUTE_OSPF6;
jardin9e867fe2003-12-23 08:56:18 +00001805 else if (strncmp (argv[0], "i", 1) == 0)
1806 type = ZEBRA_ROUTE_ISIS;
paul718e3742002-12-13 20:15:29 +00001807 else if (strncmp (argv[0], "r", 1) == 0)
1808 type = ZEBRA_ROUTE_RIPNG;
1809 else if (strncmp (argv[0], "s", 1) == 0)
1810 type = ZEBRA_ROUTE_STATIC;
1811 else
1812 {
1813 vty_out (vty, "Unknown route type%s", VTY_NEWLINE);
1814 return CMD_WARNING;
1815 }
1816
1817 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1818 if (! table)
1819 return CMD_SUCCESS;
1820
1821 /* Show matched type IPv6 routes. */
1822 for (rn = route_top (table); rn; rn = route_next (rn))
1823 for (rib = rn->info; rib; rib = rib->next)
1824 if (rib->type == type)
1825 {
1826 if (first)
1827 {
1828 vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
1829 first = 0;
1830 }
1831 vty_show_ipv6_route (vty, rn, rib);
1832 }
1833 return CMD_SUCCESS;
1834}
1835
1836DEFUN (show_ipv6_route_addr,
1837 show_ipv6_route_addr_cmd,
1838 "show ipv6 route X:X::X:X",
1839 SHOW_STR
1840 IP_STR
1841 "IPv6 routing table\n"
1842 "IPv6 Address\n")
1843{
1844 int ret;
1845 struct prefix_ipv6 p;
1846 struct route_table *table;
1847 struct route_node *rn;
1848
1849 ret = str2prefix_ipv6 (argv[0], &p);
1850 if (ret <= 0)
1851 {
1852 vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);
1853 return CMD_WARNING;
1854 }
1855
1856 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1857 if (! table)
1858 return CMD_SUCCESS;
1859
1860 rn = route_node_match (table, (struct prefix *) &p);
1861 if (! rn)
1862 {
1863 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1864 return CMD_WARNING;
1865 }
1866
1867 vty_show_ipv6_route_detail (vty, rn);
1868
1869 route_unlock_node (rn);
1870
1871 return CMD_SUCCESS;
1872}
1873
1874DEFUN (show_ipv6_route_prefix,
1875 show_ipv6_route_prefix_cmd,
1876 "show ipv6 route X:X::X:X/M",
1877 SHOW_STR
1878 IP_STR
1879 "IPv6 routing table\n"
1880 "IPv6 prefix\n")
1881{
1882 int ret;
1883 struct prefix_ipv6 p;
1884 struct route_table *table;
1885 struct route_node *rn;
1886
1887 ret = str2prefix_ipv6 (argv[0], &p);
1888 if (ret <= 0)
1889 {
1890 vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE);
1891 return CMD_WARNING;
1892 }
1893
1894 table = vrf_table (AFI_IP6, SAFI_UNICAST, 0);
1895 if (! table)
1896 return CMD_SUCCESS;
1897
1898 rn = route_node_match (table, (struct prefix *) &p);
1899 if (! rn || rn->p.prefixlen != p.prefixlen)
1900 {
1901 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
1902 return CMD_WARNING;
1903 }
1904
1905 vty_show_ipv6_route_detail (vty, rn);
1906
1907 route_unlock_node (rn);
1908
1909 return CMD_SUCCESS;
1910}
1911
Paul Jakma7514fb72007-05-02 16:05:35 +00001912DEFUN (show_ip_protocol,
1913 show_ip_protocol_cmd,
1914 "show ip protocol",
1915 SHOW_STR
1916 IP_STR
1917 "IP protocol filtering status\n")
1918{
1919 int i;
1920
1921 vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE);
1922 vty_out(vty, "------------------------%s", VTY_NEWLINE);
1923 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
1924 {
1925 if (proto_rm[AFI_IP][i])
1926 vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i),
1927 proto_rm[AFI_IP][i],
1928 VTY_NEWLINE);
1929 else
1930 vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE);
1931 }
1932 if (proto_rm[AFI_IP][i])
1933 vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i],
1934 VTY_NEWLINE);
1935 else
1936 vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE);
1937
1938 return CMD_SUCCESS;
1939}
paul718e3742002-12-13 20:15:29 +00001940
1941/* Write IPv6 static route configuration. */
paula1ac18c2005-06-28 17:17:12 +00001942static int
paul718e3742002-12-13 20:15:29 +00001943static_config_ipv6 (struct vty *vty)
1944{
1945 struct route_node *rn;
1946 struct static_ipv6 *si;
1947 int write;
1948 char buf[BUFSIZ];
1949 struct route_table *stable;
1950
1951 write = 0;
1952
1953 /* Lookup table. */
1954 stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0);
1955 if (! stable)
1956 return -1;
1957
1958 for (rn = route_top (stable); rn; rn = route_next (rn))
1959 for (si = rn->info; si; si = si->next)
1960 {
1961 vty_out (vty, "ipv6 route %s/%d",
1962 inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ),
1963 rn->p.prefixlen);
1964
1965 switch (si->type)
1966 {
1967 case STATIC_IPV6_GATEWAY:
1968 vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ));
1969 break;
1970 case STATIC_IPV6_IFNAME:
1971 vty_out (vty, " %s", si->ifname);
1972 break;
1973 case STATIC_IPV6_GATEWAY_IFNAME:
1974 vty_out (vty, " %s %s",
1975 inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname);
1976 break;
1977 }
1978
hasso81dfcaa2003-05-25 19:21:25 +00001979 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT))
1980 vty_out (vty, " %s", "reject");
1981
1982 if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE))
1983 vty_out (vty, " %s", "blackhole");
1984
paul718e3742002-12-13 20:15:29 +00001985 if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT)
1986 vty_out (vty, " %d", si->distance);
1987 vty_out (vty, "%s", VTY_NEWLINE);
1988
1989 write = 1;
1990 }
1991 return write;
1992}
1993#endif /* HAVE_IPV6 */
1994
1995/* Static ip route configuration write function. */
paula1ac18c2005-06-28 17:17:12 +00001996static int
paul718e3742002-12-13 20:15:29 +00001997zebra_ip_config (struct vty *vty)
1998{
1999 int write = 0;
2000
2001 write += static_config_ipv4 (vty);
2002#ifdef HAVE_IPV6
2003 write += static_config_ipv6 (vty);
2004#endif /* HAVE_IPV6 */
2005
2006 return write;
2007}
2008
Paul Jakma7514fb72007-05-02 16:05:35 +00002009/* ip protocol configuration write function */
2010static int config_write_protocol(struct vty *vty)
2011{
2012 int i;
2013
2014 for (i=0;i<ZEBRA_ROUTE_MAX;i++)
2015 {
2016 if (proto_rm[AFI_IP][i])
2017 vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i),
2018 proto_rm[AFI_IP][i], VTY_NEWLINE);
2019 }
2020 if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX])
2021 vty_out (vty, "ip protocol %s route-map %s%s", "any",
2022 proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE);
2023
2024 return 1;
2025}
2026
2027/* table node for protocol filtering */
2028struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 };
2029
paul718e3742002-12-13 20:15:29 +00002030/* IP node for static routes. */
2031struct cmd_node ip_node = { IP_NODE, "", 1 };
2032
2033/* Route VTY. */
2034void
paula1ac18c2005-06-28 17:17:12 +00002035zebra_vty_init (void)
paul718e3742002-12-13 20:15:29 +00002036{
2037 install_node (&ip_node, zebra_ip_config);
Paul Jakma7514fb72007-05-02 16:05:35 +00002038 install_node (&protocol_node, config_write_protocol);
paul718e3742002-12-13 20:15:29 +00002039
Paul Jakma7514fb72007-05-02 16:05:35 +00002040 install_element (CONFIG_NODE, &ip_protocol_cmd);
2041 install_element (CONFIG_NODE, &no_ip_protocol_cmd);
2042 install_element (VIEW_NODE, &show_ip_protocol_cmd);
2043 install_element (ENABLE_NODE, &show_ip_protocol_cmd);
paul718e3742002-12-13 20:15:29 +00002044 install_element (CONFIG_NODE, &ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002045 install_element (CONFIG_NODE, &ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002046 install_element (CONFIG_NODE, &ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002047 install_element (CONFIG_NODE, &ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002048 install_element (CONFIG_NODE, &ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002049 install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002050 install_element (CONFIG_NODE, &no_ip_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002051 install_element (CONFIG_NODE, &no_ip_route_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002052 install_element (CONFIG_NODE, &no_ip_route_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002053 install_element (CONFIG_NODE, &no_ip_route_mask_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002054 install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd);
hasso457ef552003-05-28 12:02:15 +00002055 install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd);
paul718e3742002-12-13 20:15:29 +00002056 install_element (CONFIG_NODE, &ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002057 install_element (CONFIG_NODE, &ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002058 install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002059 install_element (CONFIG_NODE, &ip_route_mask_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002060 install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002061 install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002062 install_element (CONFIG_NODE, &no_ip_route_distance_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002063 install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002064 install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002065 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd);
hasso457ef552003-05-28 12:02:15 +00002066 install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd);
paul718e3742002-12-13 20:15:29 +00002067
2068 install_element (VIEW_NODE, &show_ip_route_cmd);
2069 install_element (VIEW_NODE, &show_ip_route_addr_cmd);
2070 install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
2071 install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
2072 install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
2073 install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
2074 install_element (ENABLE_NODE, &show_ip_route_cmd);
2075 install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
2076 install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
2077 install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
2078 install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
2079 install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
2080
2081#if 0
2082 install_element (VIEW_NODE, &show_ip_route_summary_cmd);
2083 install_element (ENABLE_NODE, &show_ip_route_summary_cmd);
2084#endif /* 0 */
2085
2086#ifdef HAVE_IPV6
2087 install_element (CONFIG_NODE, &ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002088 install_element (CONFIG_NODE, &ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002089 install_element (CONFIG_NODE, &ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002090 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002091 install_element (CONFIG_NODE, &no_ipv6_route_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002092 install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002093 install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002094 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd);
paul718e3742002-12-13 20:15:29 +00002095 install_element (CONFIG_NODE, &ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002096 install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002097 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002098 install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002099 install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002100 install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002101 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd);
hasso81dfcaa2003-05-25 19:21:25 +00002102 install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd);
paul718e3742002-12-13 20:15:29 +00002103 install_element (VIEW_NODE, &show_ipv6_route_cmd);
2104 install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd);
2105 install_element (VIEW_NODE, &show_ipv6_route_addr_cmd);
2106 install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd);
2107 install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd);
2108 install_element (ENABLE_NODE, &show_ipv6_route_cmd);
2109 install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd);
2110 install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd);
2111 install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd);
2112 install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd);
2113#endif /* HAVE_IPV6 */
2114}