paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* 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 Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 24 | #include "memory.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "if.h" |
| 26 | #include "prefix.h" |
| 27 | #include "command.h" |
| 28 | #include "table.h" |
| 29 | #include "rib.h" |
| 30 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 31 | #include "zebra/zserv.h" |
| 32 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | /* General fucntion for static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 34 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 35 | zebra_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) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | { |
| 39 | int ret; |
| 40 | u_char distance; |
| 41 | struct prefix p; |
| 42 | struct in_addr gate; |
| 43 | struct in_addr mask; |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 44 | const char *ifname; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 45 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 46 | |
| 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) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 59 | { |
| 60 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 61 | return CMD_WARNING; |
| 62 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 63 | p.prefixlen = ip_masklen (mask); |
| 64 | } |
| 65 | |
| 66 | /* Apply mask for given prefix. */ |
| 67 | apply_mask (&p); |
| 68 | |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 69 | /* Administrative distance. */ |
| 70 | if (distance_str) |
| 71 | distance = atoi (distance_str); |
| 72 | else |
| 73 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 74 | |
| 75 | /* Null0 static route. */ |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 76 | if ((gate_str != NULL) && (strncasecmp (gate_str, "Null0", strlen (gate_str)) == 0)) |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 77 | { |
| 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) |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 84 | static_add_ipv4 (&p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, 0); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 85 | else |
| 86 | static_delete_ipv4 (&p, NULL, NULL, distance, 0); |
| 87 | return CMD_SUCCESS; |
| 88 | } |
| 89 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 90 | /* 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); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 103 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 107 | 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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 117 | /* 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) |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 126 | static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, distance, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | else |
| 128 | static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, distance, 0); |
| 129 | |
| 130 | return CMD_SUCCESS; |
| 131 | } |
| 132 | |
| 133 | /* Static route configuration. */ |
| 134 | DEFUN (ip_route, |
| 135 | ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 136 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 137 | IP_STR |
| 138 | "Establish static routes\n" |
| 139 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 140 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 141 | "IP gateway interface name\n" |
| 142 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 143 | { |
| 144 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL); |
| 145 | } |
| 146 | |
| 147 | DEFUN (ip_route_flags, |
| 148 | ip_route_flags_cmd, |
| 149 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | 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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 155 | "Emit an ICMP unreachable when matched\n" |
| 156 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 158 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | } |
| 160 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 161 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 173 | /* Mask as A.B.C.D format. */ |
| 174 | DEFUN (ip_route_mask, |
| 175 | ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 176 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 177 | IP_STR |
| 178 | "Establish static routes\n" |
| 179 | "IP destination prefix\n" |
| 180 | "IP destination prefix mask\n" |
| 181 | "IP gateway address\n" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 182 | "IP gateway interface name\n" |
| 183 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 184 | { |
| 185 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 186 | } |
| 187 | |
| 188 | DEFUN (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 191 | 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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 197 | "Emit an ICMP unreachable when matched\n" |
| 198 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 199 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 200 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | } |
| 202 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 203 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 216 | /* Distance option value. */ |
| 217 | DEFUN (ip_route_distance, |
| 218 | ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 219 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 220 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 225 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 226 | "Distance value for this route\n") |
| 227 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 228 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]); |
| 229 | } |
| 230 | |
| 231 | DEFUN (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]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | } |
| 245 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 246 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 259 | DEFUN (ip_route_mask_distance, |
| 260 | ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 261 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 262 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 268 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 269 | "Distance value for this route\n") |
| 270 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 271 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 272 | } |
| 273 | |
| 274 | DEFUN (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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 283 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 284 | "Silently discard pkts when matched\n" |
| 285 | "Distance value for this route\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 286 | { |
| 287 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 288 | } |
| 289 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 290 | DEFUN (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" |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 297 | "Emit an ICMP unreachable when matched\n" |
Christian Franke | 2b00515 | 2013-09-30 12:27:49 +0000 | [diff] [blame] | 298 | "Silently discard pkts when matched\n" |
| 299 | "Distance value for this route\n") |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 300 | { |
| 301 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]); |
| 302 | } |
| 303 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 304 | DEFUN (no_ip_route, |
| 305 | no_ip_route_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 306 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 307 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 312 | "IP gateway interface name\n" |
| 313 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 314 | { |
| 315 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL); |
| 316 | } |
| 317 | |
| 318 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 321 | 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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 327 | "Emit an ICMP unreachable when matched\n" |
| 328 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 329 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 330 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | DEFUN (no_ip_route_mask, |
| 344 | no_ip_route_mask_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 345 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0)", |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 346 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 352 | "IP gateway interface name\n" |
| 353 | "Null interface\n") |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 354 | { |
| 355 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL); |
| 356 | } |
| 357 | |
| 358 | ALIAS (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)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 361 | 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" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 368 | "Emit an ICMP unreachable when matched\n" |
| 369 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 370 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 371 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 385 | DEFUN (no_ip_route_distance, |
| 386 | no_ip_route_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 387 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 388 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 394 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 395 | "Distance value for this route\n") |
| 396 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 397 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]); |
| 398 | } |
| 399 | |
| 400 | DEFUN (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]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 414 | } |
| 415 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 416 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 430 | DEFUN (no_ip_route_mask_distance, |
| 431 | no_ip_route_mask_distance_cmd, |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 432 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 433 | 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" |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 440 | "Null interface\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 441 | "Distance value for this route\n") |
| 442 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 443 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 444 | } |
| 445 | |
| 446 | DEFUN (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]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 461 | } |
| 462 | |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 463 | DEFUN (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 Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 478 | char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */ |
| 479 | |
| 480 | DEFUN (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 | |
| 506 | DEFUN (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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | /* New RIB. Detailed information for IPv4 route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 532 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 533 | vty_show_ip_route_detail (struct vty *vty, struct route_node *rn) |
| 534 | { |
| 535 | struct rib *rib; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 536 | struct nexthop *nexthop, *tnexthop; |
| 537 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 539 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 540 | { |
| 541 | vty_out (vty, "Routing entry for %s/%d%s", |
| 542 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 543 | VTY_NEWLINE); |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 544 | vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type)); |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 545 | vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 546 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
| 547 | vty_out (vty, ", best"); |
| 548 | if (rib->refcnt) |
| 549 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 550 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 551 | vty_out (vty, ", blackhole"); |
| 552 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 553 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | vty_out (vty, "%s", VTY_NEWLINE); |
| 555 | |
| 556 | #define ONE_DAY_SECOND 60*60*24 |
| 557 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 558 | if (rib->type == ZEBRA_ROUTE_RIP |
| 559 | || rib->type == ZEBRA_ROUTE_OSPF |
Juliusz Chroboczek | 578ce37 | 2012-02-09 13:42:28 +0100 | [diff] [blame] | 560 | || rib->type == ZEBRA_ROUTE_BABEL |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 561 | || rib->type == ZEBRA_ROUTE_ISIS |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 562 | || rib->type == ZEBRA_ROUTE_BGP) |
| 563 | { |
| 564 | time_t uptime; |
| 565 | struct tm *tm; |
| 566 | |
| 567 | uptime = time (NULL); |
| 568 | uptime -= rib->uptime; |
| 569 | tm = gmtime (&uptime); |
| 570 | |
| 571 | vty_out (vty, " Last update "); |
| 572 | |
| 573 | if (uptime < ONE_DAY_SECOND) |
| 574 | vty_out (vty, "%02d:%02d:%02d", |
| 575 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 576 | else if (uptime < ONE_WEEK_SECOND) |
| 577 | vty_out (vty, "%dd%02dh%02dm", |
| 578 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 579 | else |
| 580 | vty_out (vty, "%02dw%dd%02dh", |
| 581 | tm->tm_yday/7, |
| 582 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 583 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 584 | } |
| 585 | |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 586 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 587 | { |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 588 | char addrstr[32]; |
| 589 | |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 590 | vty_out (vty, " %c%s", |
| 591 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', |
| 592 | recursing ? " " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 593 | |
| 594 | switch (nexthop->type) |
| 595 | { |
| 596 | case NEXTHOP_TYPE_IPV4: |
| 597 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 598 | vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4)); |
| 599 | if (nexthop->ifindex) |
| 600 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 601 | break; |
| 602 | case NEXTHOP_TYPE_IFINDEX: |
| 603 | vty_out (vty, " directly connected, %s", |
| 604 | ifindex2ifname (nexthop->ifindex)); |
| 605 | break; |
| 606 | case NEXTHOP_TYPE_IFNAME: |
| 607 | vty_out (vty, " directly connected, %s", nexthop->ifname); |
| 608 | break; |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 609 | case NEXTHOP_TYPE_BLACKHOLE: |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 610 | vty_out (vty, " directly connected, Null0"); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 611 | break; |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 612 | default: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 613 | break; |
| 614 | } |
| 615 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 616 | vty_out (vty, " inactive"); |
| 617 | |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 618 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
| 619 | vty_out (vty, " onlink"); |
| 620 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 621 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 622 | vty_out (vty, " (recursive)"); |
Christian Franke | 5b9f518 | 2013-05-25 14:01:34 +0000 | [diff] [blame] | 623 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 624 | switch (nexthop->type) |
| 625 | { |
| 626 | case NEXTHOP_TYPE_IPV4: |
| 627 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 628 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 629 | if (nexthop->src.ipv4.s_addr) |
| 630 | { |
| 631 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, addrstr, |
| 632 | sizeof addrstr)) |
| 633 | vty_out (vty, ", src %s", addrstr); |
| 634 | } |
| 635 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 636 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 637 | case NEXTHOP_TYPE_IPV6: |
| 638 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 639 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 640 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 641 | { |
| 642 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, addrstr, |
| 643 | sizeof addrstr)) |
| 644 | vty_out (vty, ", src %s", addrstr); |
| 645 | } |
| 646 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 647 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 648 | default: |
| 649 | break; |
| 650 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 651 | vty_out (vty, "%s", VTY_NEWLINE); |
| 652 | } |
| 653 | vty_out (vty, "%s", VTY_NEWLINE); |
| 654 | } |
| 655 | } |
| 656 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 657 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 658 | vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib) |
| 659 | { |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 660 | struct nexthop *nexthop, *tnexthop; |
| 661 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 662 | int len = 0; |
| 663 | char buf[BUFSIZ]; |
| 664 | |
| 665 | /* Nexthop information. */ |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 666 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 667 | { |
| 668 | if (nexthop == rib->nexthop) |
| 669 | { |
| 670 | /* Prefix information. */ |
| 671 | len = vty_out (vty, "%c%c%c %s/%d", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 672 | zebra_route_char (rib->type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 673 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 674 | ? '>' : ' ', |
| 675 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 676 | ? '*' : ' ', |
| 677 | inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ), |
| 678 | rn->p.prefixlen); |
| 679 | |
| 680 | /* Distance and metric display. */ |
| 681 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 682 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 683 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 684 | rib->metric); |
| 685 | } |
| 686 | else |
| 687 | vty_out (vty, " %c%*c", |
| 688 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 689 | ? '*' : ' ', |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 690 | len - 3 + (2 * recursing), ' '); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 691 | |
| 692 | switch (nexthop->type) |
| 693 | { |
| 694 | case NEXTHOP_TYPE_IPV4: |
| 695 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 696 | vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4)); |
| 697 | if (nexthop->ifindex) |
| 698 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 699 | break; |
| 700 | case NEXTHOP_TYPE_IFINDEX: |
| 701 | vty_out (vty, " is directly connected, %s", |
| 702 | ifindex2ifname (nexthop->ifindex)); |
| 703 | break; |
| 704 | case NEXTHOP_TYPE_IFNAME: |
| 705 | vty_out (vty, " is directly connected, %s", nexthop->ifname); |
| 706 | break; |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 707 | case NEXTHOP_TYPE_BLACKHOLE: |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 708 | vty_out (vty, " is directly connected, Null0"); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 709 | break; |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 710 | default: |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 711 | break; |
| 712 | } |
| 713 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 714 | vty_out (vty, " inactive"); |
| 715 | |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 716 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
| 717 | vty_out (vty, " onlink"); |
| 718 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 719 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 720 | vty_out (vty, " (recursive)"); |
| 721 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 722 | switch (nexthop->type) |
| 723 | { |
| 724 | case NEXTHOP_TYPE_IPV4: |
| 725 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 726 | case NEXTHOP_TYPE_IPV4_IFNAME: |
| 727 | if (nexthop->src.ipv4.s_addr) |
| 728 | { |
| 729 | if (inet_ntop(AF_INET, &nexthop->src.ipv4, buf, sizeof buf)) |
| 730 | vty_out (vty, ", src %s", buf); |
| 731 | } |
| 732 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 733 | #ifdef HAVE_IPV6 |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 734 | case NEXTHOP_TYPE_IPV6: |
| 735 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 736 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 737 | if (!IPV6_ADDR_SAME(&nexthop->src.ipv6, &in6addr_any)) |
| 738 | { |
| 739 | if (inet_ntop(AF_INET6, &nexthop->src.ipv6, buf, sizeof buf)) |
| 740 | vty_out (vty, ", src %s", buf); |
| 741 | } |
| 742 | break; |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 743 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 744 | default: |
| 745 | break; |
| 746 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 747 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 748 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 749 | vty_out (vty, ", bh"); |
| 750 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 751 | vty_out (vty, ", rej"); |
| 752 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 753 | if (rib->type == ZEBRA_ROUTE_RIP |
| 754 | || rib->type == ZEBRA_ROUTE_OSPF |
Juliusz Chroboczek | 578ce37 | 2012-02-09 13:42:28 +0100 | [diff] [blame] | 755 | || rib->type == ZEBRA_ROUTE_BABEL |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 756 | || rib->type == ZEBRA_ROUTE_ISIS |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 757 | || rib->type == ZEBRA_ROUTE_BGP) |
| 758 | { |
| 759 | time_t uptime; |
| 760 | struct tm *tm; |
| 761 | |
| 762 | uptime = time (NULL); |
| 763 | uptime -= rib->uptime; |
| 764 | tm = gmtime (&uptime); |
| 765 | |
| 766 | #define ONE_DAY_SECOND 60*60*24 |
| 767 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 768 | |
| 769 | if (uptime < ONE_DAY_SECOND) |
| 770 | vty_out (vty, ", %02d:%02d:%02d", |
| 771 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 772 | else if (uptime < ONE_WEEK_SECOND) |
| 773 | vty_out (vty, ", %dd%02dh%02dm", |
| 774 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 775 | else |
| 776 | vty_out (vty, ", %02dw%dd%02dh", |
| 777 | tm->tm_yday/7, |
| 778 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 779 | } |
| 780 | vty_out (vty, "%s", VTY_NEWLINE); |
| 781 | } |
| 782 | } |
| 783 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 784 | DEFUN (show_ip_route, |
| 785 | show_ip_route_cmd, |
| 786 | "show ip route", |
| 787 | SHOW_STR |
| 788 | IP_STR |
| 789 | "IP routing table\n") |
| 790 | { |
| 791 | struct route_table *table; |
| 792 | struct route_node *rn; |
| 793 | struct rib *rib; |
| 794 | int first = 1; |
| 795 | |
| 796 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 797 | if (! table) |
| 798 | return CMD_SUCCESS; |
| 799 | |
| 800 | /* Show all IPv4 routes. */ |
| 801 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 802 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | { |
| 804 | if (first) |
| 805 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 806 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 807 | first = 0; |
| 808 | } |
| 809 | vty_show_ip_route (vty, rn, rib); |
| 810 | } |
| 811 | return CMD_SUCCESS; |
| 812 | } |
| 813 | |
| 814 | DEFUN (show_ip_route_prefix_longer, |
| 815 | show_ip_route_prefix_longer_cmd, |
| 816 | "show ip route A.B.C.D/M longer-prefixes", |
| 817 | SHOW_STR |
| 818 | IP_STR |
| 819 | "IP routing table\n" |
| 820 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 821 | "Show route matching the specified Network/Mask pair only\n") |
| 822 | { |
| 823 | struct route_table *table; |
| 824 | struct route_node *rn; |
| 825 | struct rib *rib; |
| 826 | struct prefix p; |
| 827 | int ret; |
| 828 | int first = 1; |
| 829 | |
| 830 | ret = str2prefix (argv[0], &p); |
| 831 | if (! ret) |
| 832 | { |
| 833 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 834 | return CMD_WARNING; |
| 835 | } |
| 836 | |
| 837 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 838 | if (! table) |
| 839 | return CMD_SUCCESS; |
| 840 | |
| 841 | /* Show matched type IPv4 routes. */ |
| 842 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 843 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 844 | if (prefix_match (&p, &rn->p)) |
| 845 | { |
| 846 | if (first) |
| 847 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 848 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | first = 0; |
| 850 | } |
| 851 | vty_show_ip_route (vty, rn, rib); |
| 852 | } |
| 853 | return CMD_SUCCESS; |
| 854 | } |
| 855 | |
| 856 | DEFUN (show_ip_route_supernets, |
| 857 | show_ip_route_supernets_cmd, |
| 858 | "show ip route supernets-only", |
| 859 | SHOW_STR |
| 860 | IP_STR |
| 861 | "IP routing table\n" |
| 862 | "Show supernet entries only\n") |
| 863 | { |
| 864 | struct route_table *table; |
| 865 | struct route_node *rn; |
| 866 | struct rib *rib; |
| 867 | u_int32_t addr; |
| 868 | int first = 1; |
| 869 | |
| 870 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 871 | if (! table) |
| 872 | return CMD_SUCCESS; |
| 873 | |
| 874 | /* Show matched type IPv4 routes. */ |
| 875 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 876 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | { |
| 878 | addr = ntohl (rn->p.u.prefix4.s_addr); |
| 879 | |
| 880 | if ((IN_CLASSC (addr) && rn->p.prefixlen < 24) |
| 881 | || (IN_CLASSB (addr) && rn->p.prefixlen < 16) |
| 882 | || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) |
| 883 | { |
| 884 | if (first) |
| 885 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 886 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 887 | first = 0; |
| 888 | } |
| 889 | vty_show_ip_route (vty, rn, rib); |
| 890 | } |
| 891 | } |
| 892 | return CMD_SUCCESS; |
| 893 | } |
| 894 | |
| 895 | DEFUN (show_ip_route_protocol, |
| 896 | show_ip_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 897 | "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | SHOW_STR |
| 899 | IP_STR |
| 900 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 901 | QUAGGA_IP_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 902 | { |
| 903 | int type; |
| 904 | struct route_table *table; |
| 905 | struct route_node *rn; |
| 906 | struct rib *rib; |
| 907 | int first = 1; |
| 908 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 909 | type = proto_redistnum (AFI_IP, argv[0]); |
| 910 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 911 | { |
| 912 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 913 | return CMD_WARNING; |
| 914 | } |
| 915 | |
| 916 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 917 | if (! table) |
| 918 | return CMD_SUCCESS; |
| 919 | |
| 920 | /* Show matched type IPv4 routes. */ |
| 921 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 922 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 923 | if (rib->type == type) |
| 924 | { |
| 925 | if (first) |
| 926 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 927 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 928 | first = 0; |
| 929 | } |
| 930 | vty_show_ip_route (vty, rn, rib); |
| 931 | } |
| 932 | return CMD_SUCCESS; |
| 933 | } |
| 934 | |
| 935 | DEFUN (show_ip_route_addr, |
| 936 | show_ip_route_addr_cmd, |
| 937 | "show ip route A.B.C.D", |
| 938 | SHOW_STR |
| 939 | IP_STR |
| 940 | "IP routing table\n" |
| 941 | "Network in the IP routing table to display\n") |
| 942 | { |
| 943 | int ret; |
| 944 | struct prefix_ipv4 p; |
| 945 | struct route_table *table; |
| 946 | struct route_node *rn; |
| 947 | |
| 948 | ret = str2prefix_ipv4 (argv[0], &p); |
| 949 | if (ret <= 0) |
| 950 | { |
| 951 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 952 | return CMD_WARNING; |
| 953 | } |
| 954 | |
| 955 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 956 | if (! table) |
| 957 | return CMD_SUCCESS; |
| 958 | |
| 959 | rn = route_node_match (table, (struct prefix *) &p); |
| 960 | if (! rn) |
| 961 | { |
| 962 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 963 | return CMD_WARNING; |
| 964 | } |
| 965 | |
| 966 | vty_show_ip_route_detail (vty, rn); |
| 967 | |
| 968 | route_unlock_node (rn); |
| 969 | |
| 970 | return CMD_SUCCESS; |
| 971 | } |
| 972 | |
| 973 | DEFUN (show_ip_route_prefix, |
| 974 | show_ip_route_prefix_cmd, |
| 975 | "show ip route A.B.C.D/M", |
| 976 | SHOW_STR |
| 977 | IP_STR |
| 978 | "IP routing table\n" |
| 979 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 980 | { |
| 981 | int ret; |
| 982 | struct prefix_ipv4 p; |
| 983 | struct route_table *table; |
| 984 | struct route_node *rn; |
| 985 | |
| 986 | ret = str2prefix_ipv4 (argv[0], &p); |
| 987 | if (ret <= 0) |
| 988 | { |
| 989 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 990 | return CMD_WARNING; |
| 991 | } |
| 992 | |
| 993 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 994 | if (! table) |
| 995 | return CMD_SUCCESS; |
| 996 | |
| 997 | rn = route_node_match (table, (struct prefix *) &p); |
| 998 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 999 | { |
| 1000 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 1001 | if (rn) |
| 1002 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1003 | return CMD_WARNING; |
| 1004 | } |
| 1005 | |
| 1006 | vty_show_ip_route_detail (vty, rn); |
| 1007 | |
| 1008 | route_unlock_node (rn); |
| 1009 | |
| 1010 | return CMD_SUCCESS; |
| 1011 | } |
| 1012 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1013 | static void |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1014 | vty_show_ip_route_summary (struct vty *vty, struct route_table *table) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1015 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1016 | struct route_node *rn; |
| 1017 | struct rib *rib; |
| 1018 | struct nexthop *nexthop; |
| 1019 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1020 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1021 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1022 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1023 | u_int32_t i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1024 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1025 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1026 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1027 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1028 | RNODE_FOREACH_RIB (rn, rib) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1029 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 1030 | { |
| 1031 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1032 | rib_cnt[rib->type]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1033 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1034 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1035 | { |
| 1036 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1037 | fib_cnt[rib->type]++; |
| 1038 | } |
| 1039 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1040 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1041 | { |
| 1042 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1043 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1044 | || nexthop_has_fib_child(nexthop)) |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1045 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1046 | } |
| 1047 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1048 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1049 | vty_out (vty, "%-20s %-20s %-20s %s", |
| 1050 | "Route Source", "Routes", "FIB", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1051 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1052 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1053 | { |
| 1054 | if (rib_cnt[i] > 0) |
| 1055 | { |
| 1056 | if (i == ZEBRA_ROUTE_BGP) |
| 1057 | { |
| 1058 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 1059 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 1060 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1061 | VTY_NEWLINE); |
| 1062 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 1063 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1064 | VTY_NEWLINE); |
| 1065 | } |
| 1066 | else |
| 1067 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 1068 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 1069 | } |
| 1070 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1071 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1072 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 1073 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 1074 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1075 | } |
| 1076 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 1077 | /* |
| 1078 | * Implementation of the ip route summary prefix command. |
| 1079 | * |
| 1080 | * This command prints the primary prefixes that have been installed by various |
| 1081 | * protocols on the box. |
| 1082 | * |
| 1083 | */ |
| 1084 | static void |
| 1085 | vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) |
| 1086 | { |
| 1087 | struct route_node *rn; |
| 1088 | struct rib *rib; |
| 1089 | struct nexthop *nexthop; |
| 1090 | #define ZEBRA_ROUTE_IBGP ZEBRA_ROUTE_MAX |
| 1091 | #define ZEBRA_ROUTE_TOTAL (ZEBRA_ROUTE_IBGP + 1) |
| 1092 | u_int32_t rib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1093 | u_int32_t fib_cnt[ZEBRA_ROUTE_TOTAL + 1]; |
| 1094 | u_int32_t i; |
| 1095 | int cnt; |
| 1096 | |
| 1097 | memset (&rib_cnt, 0, sizeof(rib_cnt)); |
| 1098 | memset (&fib_cnt, 0, sizeof(fib_cnt)); |
| 1099 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1100 | RNODE_FOREACH_RIB (rn, rib) |
| 1101 | { |
| 1102 | |
| 1103 | /* |
| 1104 | * In case of ECMP, count only once. |
| 1105 | */ |
| 1106 | cnt = 0; |
| 1107 | for (nexthop = rib->nexthop; (!cnt && nexthop); nexthop = nexthop->next) |
| 1108 | { |
| 1109 | cnt++; |
| 1110 | rib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1111 | rib_cnt[rib->type]++; |
| 1112 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1113 | { |
| 1114 | fib_cnt[ZEBRA_ROUTE_TOTAL]++; |
| 1115 | fib_cnt[rib->type]++; |
| 1116 | } |
| 1117 | if (rib->type == ZEBRA_ROUTE_BGP && |
| 1118 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_IBGP)) |
| 1119 | { |
| 1120 | rib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1121 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)) |
| 1122 | fib_cnt[ZEBRA_ROUTE_IBGP]++; |
| 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | vty_out (vty, "%-20s %-20s %-20s %s", |
| 1128 | "Route Source", "Prefix Routes", "FIB", VTY_NEWLINE); |
| 1129 | |
| 1130 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 1131 | { |
| 1132 | if (rib_cnt[i] > 0) |
| 1133 | { |
| 1134 | if (i == ZEBRA_ROUTE_BGP) |
| 1135 | { |
| 1136 | vty_out (vty, "%-20s %-20d %-20d %s", "ebgp", |
| 1137 | rib_cnt[ZEBRA_ROUTE_BGP] - rib_cnt[ZEBRA_ROUTE_IBGP], |
| 1138 | fib_cnt[ZEBRA_ROUTE_BGP] - fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1139 | VTY_NEWLINE); |
| 1140 | vty_out (vty, "%-20s %-20d %-20d %s", "ibgp", |
| 1141 | rib_cnt[ZEBRA_ROUTE_IBGP], fib_cnt[ZEBRA_ROUTE_IBGP], |
| 1142 | VTY_NEWLINE); |
| 1143 | } |
| 1144 | else |
| 1145 | vty_out (vty, "%-20s %-20d %-20d %s", zebra_route_string(i), |
| 1146 | rib_cnt[i], fib_cnt[i], VTY_NEWLINE); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | vty_out (vty, "------%s", VTY_NEWLINE); |
| 1151 | vty_out (vty, "%-20s %-20d %-20d %s", "Totals", rib_cnt[ZEBRA_ROUTE_TOTAL], |
| 1152 | fib_cnt[ZEBRA_ROUTE_TOTAL], VTY_NEWLINE); |
| 1153 | } |
| 1154 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1155 | /* Show route summary. */ |
| 1156 | DEFUN (show_ip_route_summary, |
| 1157 | show_ip_route_summary_cmd, |
| 1158 | "show ip route summary", |
| 1159 | SHOW_STR |
| 1160 | IP_STR |
| 1161 | "IP routing table\n" |
| 1162 | "Summary of all routes\n") |
| 1163 | { |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1164 | struct route_table *table; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1165 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1166 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1167 | if (! table) |
| 1168 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1169 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 1170 | vty_show_ip_route_summary (vty, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | |
| 1172 | return CMD_SUCCESS; |
| 1173 | } |
| 1174 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 1175 | /* Show route summary prefix. */ |
| 1176 | DEFUN (show_ip_route_summary_prefix, |
| 1177 | show_ip_route_summary_prefix_cmd, |
| 1178 | "show ip route summary prefix", |
| 1179 | SHOW_STR |
| 1180 | IP_STR |
| 1181 | "IP routing table\n" |
| 1182 | "Summary of all routes\n" |
| 1183 | "Prefix routes\n") |
| 1184 | { |
| 1185 | struct route_table *table; |
| 1186 | |
| 1187 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 1188 | if (! table) |
| 1189 | return CMD_SUCCESS; |
| 1190 | |
| 1191 | vty_show_ip_route_summary_prefix (vty, table); |
| 1192 | |
| 1193 | return CMD_SUCCESS; |
| 1194 | } |
| 1195 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1196 | /* Write IPv4 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1197 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1198 | static_config_ipv4 (struct vty *vty) |
| 1199 | { |
| 1200 | struct route_node *rn; |
| 1201 | struct static_ipv4 *si; |
| 1202 | struct route_table *stable; |
| 1203 | int write; |
| 1204 | |
| 1205 | write = 0; |
| 1206 | |
| 1207 | /* Lookup table. */ |
| 1208 | stable = vrf_static_table (AFI_IP, SAFI_UNICAST, 0); |
| 1209 | if (! stable) |
| 1210 | return -1; |
| 1211 | |
| 1212 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 1213 | for (si = rn->info; si; si = si->next) |
| 1214 | { |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1215 | vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4), |
| 1216 | rn->p.prefixlen); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1217 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1218 | switch (si->type) |
| 1219 | { |
| 1220 | case STATIC_IPV4_GATEWAY: |
| 1221 | vty_out (vty, " %s", inet_ntoa (si->gate.ipv4)); |
| 1222 | break; |
| 1223 | case STATIC_IPV4_IFNAME: |
| 1224 | vty_out (vty, " %s", si->gate.ifname); |
| 1225 | break; |
| 1226 | case STATIC_IPV4_BLACKHOLE: |
| 1227 | vty_out (vty, " Null0"); |
| 1228 | break; |
| 1229 | } |
| 1230 | |
| 1231 | /* flags are incompatible with STATIC_IPV4_BLACKHOLE */ |
| 1232 | if (si->type != STATIC_IPV4_BLACKHOLE) |
| 1233 | { |
| 1234 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 1235 | vty_out (vty, " %s", "reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1236 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1237 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1238 | vty_out (vty, " %s", "blackhole"); |
| 1239 | } |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1240 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1241 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 1242 | vty_out (vty, " %d", si->distance); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1243 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1244 | vty_out (vty, "%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1245 | |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 1246 | write = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | } |
| 1248 | return write; |
| 1249 | } |
Andrew J. Schorr | 0930331 | 2007-05-30 20:10:34 +0000 | [diff] [blame] | 1250 | |
| 1251 | DEFUN (show_ip_protocol, |
| 1252 | show_ip_protocol_cmd, |
| 1253 | "show ip protocol", |
| 1254 | SHOW_STR |
| 1255 | IP_STR |
| 1256 | "IP protocol filtering status\n") |
| 1257 | { |
| 1258 | int i; |
| 1259 | |
| 1260 | vty_out(vty, "Protocol : route-map %s", VTY_NEWLINE); |
| 1261 | vty_out(vty, "------------------------%s", VTY_NEWLINE); |
| 1262 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 1263 | { |
| 1264 | if (proto_rm[AFI_IP][i]) |
| 1265 | vty_out (vty, "%-10s : %-10s%s", zebra_route_string(i), |
| 1266 | proto_rm[AFI_IP][i], |
| 1267 | VTY_NEWLINE); |
| 1268 | else |
| 1269 | vty_out (vty, "%-10s : none%s", zebra_route_string(i), VTY_NEWLINE); |
| 1270 | } |
| 1271 | if (proto_rm[AFI_IP][i]) |
| 1272 | vty_out (vty, "%-10s : %-10s%s", "any", proto_rm[AFI_IP][i], |
| 1273 | VTY_NEWLINE); |
| 1274 | else |
| 1275 | vty_out (vty, "%-10s : none%s", "any", VTY_NEWLINE); |
| 1276 | |
| 1277 | return CMD_SUCCESS; |
| 1278 | } |
| 1279 | |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 1280 | /* |
| 1281 | * Show IP mroute command to dump the BGP Multicast |
| 1282 | * routing table |
| 1283 | */ |
| 1284 | DEFUN (show_ip_mroute, |
| 1285 | show_ip_mroute_cmd, |
| 1286 | "show ip mroute", |
| 1287 | SHOW_STR |
| 1288 | IP_STR |
| 1289 | "IP Multicast routing table\n") |
| 1290 | { |
| 1291 | struct route_table *table; |
| 1292 | struct route_node *rn; |
| 1293 | struct rib *rib; |
| 1294 | int first = 1; |
| 1295 | |
| 1296 | table = vrf_table (AFI_IP, SAFI_MULTICAST, 0); |
| 1297 | if (! table) |
| 1298 | return CMD_SUCCESS; |
| 1299 | |
| 1300 | /* Show all IPv4 routes. */ |
| 1301 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1302 | RNODE_FOREACH_RIB (rn, rib) |
Joachim Nilsson | 36735ed | 2012-05-09 13:38:36 +0200 | [diff] [blame] | 1303 | { |
| 1304 | if (first) |
| 1305 | { |
| 1306 | vty_out (vty, SHOW_ROUTE_V4_HEADER); |
| 1307 | first = 0; |
| 1308 | } |
| 1309 | vty_show_ip_route (vty, rn, rib); |
| 1310 | } |
| 1311 | return CMD_SUCCESS; |
| 1312 | } |
| 1313 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1314 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1315 | #ifdef HAVE_IPV6 |
| 1316 | /* General fucntion for IPv6 static route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1317 | static int |
hasso | 39db97e | 2004-10-12 20:50:58 +0000 | [diff] [blame] | 1318 | static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, |
| 1319 | const char *gate_str, const char *ifname, |
| 1320 | const char *flag_str, const char *distance_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1321 | { |
| 1322 | int ret; |
| 1323 | u_char distance; |
| 1324 | struct prefix p; |
| 1325 | struct in6_addr *gate = NULL; |
| 1326 | struct in6_addr gate_addr; |
| 1327 | u_char type = 0; |
| 1328 | int table = 0; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1329 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1330 | |
| 1331 | ret = str2prefix (dest_str, &p); |
| 1332 | if (ret <= 0) |
| 1333 | { |
| 1334 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 1335 | return CMD_WARNING; |
| 1336 | } |
| 1337 | |
| 1338 | /* Apply mask for given prefix. */ |
| 1339 | apply_mask (&p); |
| 1340 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1341 | /* Route flags */ |
| 1342 | if (flag_str) { |
| 1343 | switch(flag_str[0]) { |
| 1344 | case 'r': |
| 1345 | case 'R': /* XXX */ |
| 1346 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 1347 | break; |
| 1348 | case 'b': |
| 1349 | case 'B': /* XXX */ |
| 1350 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 1351 | break; |
| 1352 | default: |
| 1353 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 1354 | return CMD_WARNING; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1355 | } |
| 1356 | } |
| 1357 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1358 | /* Administrative distance. */ |
| 1359 | if (distance_str) |
| 1360 | distance = atoi (distance_str); |
| 1361 | else |
| 1362 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 1363 | |
| 1364 | /* When gateway is valid IPv6 addrees, then gate is treated as |
| 1365 | nexthop address other case gate is treated as interface name. */ |
| 1366 | ret = inet_pton (AF_INET6, gate_str, &gate_addr); |
| 1367 | |
| 1368 | if (ifname) |
| 1369 | { |
| 1370 | /* When ifname is specified. It must be come with gateway |
| 1371 | address. */ |
| 1372 | if (ret != 1) |
| 1373 | { |
| 1374 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 1375 | return CMD_WARNING; |
| 1376 | } |
| 1377 | type = STATIC_IPV6_GATEWAY_IFNAME; |
| 1378 | gate = &gate_addr; |
| 1379 | } |
| 1380 | else |
| 1381 | { |
| 1382 | if (ret == 1) |
| 1383 | { |
| 1384 | type = STATIC_IPV6_GATEWAY; |
| 1385 | gate = &gate_addr; |
| 1386 | } |
| 1387 | else |
| 1388 | { |
| 1389 | type = STATIC_IPV6_IFNAME; |
| 1390 | ifname = gate_str; |
| 1391 | } |
| 1392 | } |
| 1393 | |
| 1394 | if (add_cmd) |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1395 | static_add_ipv6 (&p, type, gate, ifname, flag, distance, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1396 | else |
| 1397 | static_delete_ipv6 (&p, type, gate, ifname, distance, table); |
| 1398 | |
| 1399 | return CMD_SUCCESS; |
| 1400 | } |
| 1401 | |
| 1402 | DEFUN (ipv6_route, |
| 1403 | ipv6_route_cmd, |
| 1404 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1405 | IP_STR |
| 1406 | "Establish static routes\n" |
| 1407 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1408 | "IPv6 gateway address\n" |
| 1409 | "IPv6 gateway interface name\n") |
| 1410 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1411 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL); |
| 1412 | } |
| 1413 | |
| 1414 | DEFUN (ipv6_route_flags, |
| 1415 | ipv6_route_flags_cmd, |
| 1416 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1417 | IP_STR |
| 1418 | "Establish static routes\n" |
| 1419 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1420 | "IPv6 gateway address\n" |
| 1421 | "IPv6 gateway interface name\n" |
| 1422 | "Emit an ICMP unreachable when matched\n" |
| 1423 | "Silently discard pkts when matched\n") |
| 1424 | { |
| 1425 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | DEFUN (ipv6_route_ifname, |
| 1429 | ipv6_route_ifname_cmd, |
| 1430 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1431 | IP_STR |
| 1432 | "Establish static routes\n" |
| 1433 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1434 | "IPv6 gateway address\n" |
| 1435 | "IPv6 gateway interface name\n") |
| 1436 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1437 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 1438 | } |
| 1439 | |
| 1440 | DEFUN (ipv6_route_ifname_flags, |
| 1441 | ipv6_route_ifname_flags_cmd, |
| 1442 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1443 | IP_STR |
| 1444 | "Establish static routes\n" |
| 1445 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1446 | "IPv6 gateway address\n" |
| 1447 | "IPv6 gateway interface name\n" |
| 1448 | "Emit an ICMP unreachable when matched\n" |
| 1449 | "Silently discard pkts when matched\n") |
| 1450 | { |
| 1451 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1452 | } |
| 1453 | |
| 1454 | DEFUN (ipv6_route_pref, |
| 1455 | ipv6_route_pref_cmd, |
| 1456 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1457 | IP_STR |
| 1458 | "Establish static routes\n" |
| 1459 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1460 | "IPv6 gateway address\n" |
| 1461 | "IPv6 gateway interface name\n" |
| 1462 | "Distance value for this prefix\n") |
| 1463 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1464 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1465 | } |
| 1466 | |
| 1467 | DEFUN (ipv6_route_flags_pref, |
| 1468 | ipv6_route_flags_pref_cmd, |
| 1469 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1470 | IP_STR |
| 1471 | "Establish static routes\n" |
| 1472 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1473 | "IPv6 gateway address\n" |
| 1474 | "IPv6 gateway interface name\n" |
| 1475 | "Emit an ICMP unreachable when matched\n" |
| 1476 | "Silently discard pkts when matched\n" |
| 1477 | "Distance value for this prefix\n") |
| 1478 | { |
| 1479 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | DEFUN (ipv6_route_ifname_pref, |
| 1483 | ipv6_route_ifname_pref_cmd, |
| 1484 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1485 | IP_STR |
| 1486 | "Establish static routes\n" |
| 1487 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1488 | "IPv6 gateway address\n" |
| 1489 | "IPv6 gateway interface name\n" |
| 1490 | "Distance value for this prefix\n") |
| 1491 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1492 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1493 | } |
| 1494 | |
| 1495 | DEFUN (ipv6_route_ifname_flags_pref, |
| 1496 | ipv6_route_ifname_flags_pref_cmd, |
| 1497 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1498 | IP_STR |
| 1499 | "Establish static routes\n" |
| 1500 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1501 | "IPv6 gateway address\n" |
| 1502 | "IPv6 gateway interface name\n" |
| 1503 | "Emit an ICMP unreachable when matched\n" |
| 1504 | "Silently discard pkts when matched\n" |
| 1505 | "Distance value for this prefix\n") |
| 1506 | { |
| 1507 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1508 | } |
| 1509 | |
| 1510 | DEFUN (no_ipv6_route, |
| 1511 | no_ipv6_route_cmd, |
| 1512 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1513 | NO_STR |
| 1514 | IP_STR |
| 1515 | "Establish static routes\n" |
| 1516 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1517 | "IPv6 gateway address\n" |
| 1518 | "IPv6 gateway interface name\n") |
| 1519 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1520 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1521 | } |
| 1522 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1523 | ALIAS (no_ipv6_route, |
| 1524 | no_ipv6_route_flags_cmd, |
| 1525 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1526 | NO_STR |
| 1527 | IP_STR |
| 1528 | "Establish static routes\n" |
| 1529 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1530 | "IPv6 gateway address\n" |
| 1531 | "IPv6 gateway interface name\n" |
| 1532 | "Emit an ICMP unreachable when matched\n" |
| 1533 | "Silently discard pkts when matched\n") |
| 1534 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1535 | DEFUN (no_ipv6_route_ifname, |
| 1536 | no_ipv6_route_ifname_cmd, |
| 1537 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1538 | NO_STR |
| 1539 | IP_STR |
| 1540 | "Establish static routes\n" |
| 1541 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1542 | "IPv6 gateway address\n" |
| 1543 | "IPv6 gateway interface name\n") |
| 1544 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1545 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1546 | } |
| 1547 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1548 | ALIAS (no_ipv6_route_ifname, |
| 1549 | no_ipv6_route_ifname_flags_cmd, |
| 1550 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1551 | NO_STR |
| 1552 | IP_STR |
| 1553 | "Establish static routes\n" |
| 1554 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1555 | "IPv6 gateway address\n" |
| 1556 | "IPv6 gateway interface name\n" |
| 1557 | "Emit an ICMP unreachable when matched\n" |
| 1558 | "Silently discard pkts when matched\n") |
| 1559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1560 | DEFUN (no_ipv6_route_pref, |
| 1561 | no_ipv6_route_pref_cmd, |
| 1562 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1563 | NO_STR |
| 1564 | IP_STR |
| 1565 | "Establish static routes\n" |
| 1566 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1567 | "IPv6 gateway address\n" |
| 1568 | "IPv6 gateway interface name\n" |
| 1569 | "Distance value for this prefix\n") |
| 1570 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1571 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1572 | } |
| 1573 | |
| 1574 | DEFUN (no_ipv6_route_flags_pref, |
| 1575 | no_ipv6_route_flags_pref_cmd, |
| 1576 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1577 | NO_STR |
| 1578 | IP_STR |
| 1579 | "Establish static routes\n" |
| 1580 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1581 | "IPv6 gateway address\n" |
| 1582 | "IPv6 gateway interface name\n" |
| 1583 | "Emit an ICMP unreachable when matched\n" |
| 1584 | "Silently discard pkts when matched\n" |
| 1585 | "Distance value for this prefix\n") |
| 1586 | { |
| 1587 | /* We do not care about argv[2] */ |
| 1588 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | DEFUN (no_ipv6_route_ifname_pref, |
| 1592 | no_ipv6_route_ifname_pref_cmd, |
| 1593 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1594 | NO_STR |
| 1595 | IP_STR |
| 1596 | "Establish static routes\n" |
| 1597 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1598 | "IPv6 gateway address\n" |
| 1599 | "IPv6 gateway interface name\n" |
| 1600 | "Distance value for this prefix\n") |
| 1601 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1602 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1603 | } |
| 1604 | |
| 1605 | DEFUN (no_ipv6_route_ifname_flags_pref, |
| 1606 | no_ipv6_route_ifname_flags_pref_cmd, |
| 1607 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1608 | NO_STR |
| 1609 | IP_STR |
| 1610 | "Establish static routes\n" |
| 1611 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1612 | "IPv6 gateway address\n" |
| 1613 | "IPv6 gateway interface name\n" |
| 1614 | "Emit an ICMP unreachable when matched\n" |
| 1615 | "Silently discard pkts when matched\n" |
| 1616 | "Distance value for this prefix\n") |
| 1617 | { |
| 1618 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4]); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1619 | } |
| 1620 | |
paul | 595db7f | 2003-05-25 21:35:06 +0000 | [diff] [blame] | 1621 | /* New RIB. Detailed information for IPv6 route. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1622 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1623 | vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn) |
| 1624 | { |
| 1625 | struct rib *rib; |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1626 | struct nexthop *nexthop, *tnexthop; |
| 1627 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1628 | char buf[BUFSIZ]; |
| 1629 | |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1630 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | { |
| 1632 | vty_out (vty, "Routing entry for %s/%d%s", |
| 1633 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 1634 | rn->p.prefixlen, |
| 1635 | VTY_NEWLINE); |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 1636 | vty_out (vty, " Known via \"%s\"", zebra_route_string (rib->type)); |
Jorge Boncompte [DTI2] | ddc943d | 2012-04-13 13:46:07 +0200 | [diff] [blame] | 1637 | vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1638 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
| 1639 | vty_out (vty, ", best"); |
| 1640 | if (rib->refcnt) |
| 1641 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1642 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1643 | vty_out (vty, ", blackhole"); |
| 1644 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1645 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1646 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1647 | |
| 1648 | #define ONE_DAY_SECOND 60*60*24 |
| 1649 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1650 | if (rib->type == ZEBRA_ROUTE_RIPNG |
| 1651 | || rib->type == ZEBRA_ROUTE_OSPF6 |
Juliusz Chroboczek | 578ce37 | 2012-02-09 13:42:28 +0100 | [diff] [blame] | 1652 | || rib->type == ZEBRA_ROUTE_BABEL |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 1653 | || rib->type == ZEBRA_ROUTE_ISIS |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | || rib->type == ZEBRA_ROUTE_BGP) |
| 1655 | { |
| 1656 | time_t uptime; |
| 1657 | struct tm *tm; |
| 1658 | |
| 1659 | uptime = time (NULL); |
| 1660 | uptime -= rib->uptime; |
| 1661 | tm = gmtime (&uptime); |
| 1662 | |
| 1663 | vty_out (vty, " Last update "); |
| 1664 | |
| 1665 | if (uptime < ONE_DAY_SECOND) |
| 1666 | vty_out (vty, "%02d:%02d:%02d", |
| 1667 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1668 | else if (uptime < ONE_WEEK_SECOND) |
| 1669 | vty_out (vty, "%dd%02dh%02dm", |
| 1670 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1671 | else |
| 1672 | vty_out (vty, "%02dw%dd%02dh", |
| 1673 | tm->tm_yday/7, |
| 1674 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1675 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 1676 | } |
| 1677 | |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1678 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1679 | { |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1680 | vty_out (vty, " %c%s", |
| 1681 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' ', |
| 1682 | recursing ? " " : ""); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1683 | |
| 1684 | switch (nexthop->type) |
| 1685 | { |
| 1686 | case NEXTHOP_TYPE_IPV6: |
| 1687 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1688 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1689 | vty_out (vty, " %s", |
| 1690 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 1691 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1692 | vty_out (vty, ", %s", nexthop->ifname); |
| 1693 | else if (nexthop->ifindex) |
| 1694 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 1695 | break; |
| 1696 | case NEXTHOP_TYPE_IFINDEX: |
| 1697 | vty_out (vty, " directly connected, %s", |
| 1698 | ifindex2ifname (nexthop->ifindex)); |
| 1699 | break; |
| 1700 | case NEXTHOP_TYPE_IFNAME: |
| 1701 | vty_out (vty, " directly connected, %s", |
| 1702 | nexthop->ifname); |
| 1703 | break; |
| 1704 | default: |
| 1705 | break; |
| 1706 | } |
| 1707 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 1708 | vty_out (vty, " inactive"); |
| 1709 | |
Christian Franke | e8d3d29 | 2013-07-05 15:35:39 +0000 | [diff] [blame] | 1710 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ONLINK)) |
| 1711 | vty_out (vty, " onlink"); |
| 1712 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1713 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1714 | vty_out (vty, " (recursive)"); |
| 1715 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1716 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1717 | } |
| 1718 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1719 | } |
| 1720 | } |
| 1721 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 1722 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1723 | vty_show_ipv6_route (struct vty *vty, struct route_node *rn, |
| 1724 | struct rib *rib) |
| 1725 | { |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1726 | struct nexthop *nexthop, *tnexthop; |
| 1727 | int recursing; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1728 | int len = 0; |
| 1729 | char buf[BUFSIZ]; |
| 1730 | |
| 1731 | /* Nexthop information. */ |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1732 | for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1733 | { |
| 1734 | if (nexthop == rib->nexthop) |
| 1735 | { |
| 1736 | /* Prefix information. */ |
| 1737 | len = vty_out (vty, "%c%c%c %s/%d", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 1738 | zebra_route_char (rib->type), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1739 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 1740 | ? '>' : ' ', |
| 1741 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1742 | ? '*' : ' ', |
| 1743 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 1744 | rn->p.prefixlen); |
| 1745 | |
| 1746 | /* Distance and metric display. */ |
| 1747 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 1748 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 1749 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 1750 | rib->metric); |
| 1751 | } |
| 1752 | else |
| 1753 | vty_out (vty, " %c%*c", |
| 1754 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1755 | ? '*' : ' ', |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1756 | len - 3 + (2 * recursing), ' '); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1757 | |
| 1758 | switch (nexthop->type) |
| 1759 | { |
| 1760 | case NEXTHOP_TYPE_IPV6: |
| 1761 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1762 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1763 | vty_out (vty, " via %s", |
| 1764 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 1765 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1766 | vty_out (vty, ", %s", nexthop->ifname); |
| 1767 | else if (nexthop->ifindex) |
| 1768 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 1769 | break; |
| 1770 | case NEXTHOP_TYPE_IFINDEX: |
| 1771 | vty_out (vty, " is directly connected, %s", |
| 1772 | ifindex2ifname (nexthop->ifindex)); |
| 1773 | break; |
| 1774 | case NEXTHOP_TYPE_IFNAME: |
| 1775 | vty_out (vty, " is directly connected, %s", |
| 1776 | nexthop->ifname); |
| 1777 | break; |
| 1778 | default: |
| 1779 | break; |
| 1780 | } |
| 1781 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 1782 | vty_out (vty, " inactive"); |
| 1783 | |
| 1784 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
Christian Franke | fa713d9 | 2013-07-05 15:35:37 +0000 | [diff] [blame] | 1785 | vty_out (vty, " (recursive)"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1787 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1788 | vty_out (vty, ", bh"); |
| 1789 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1790 | vty_out (vty, ", rej"); |
| 1791 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1792 | if (rib->type == ZEBRA_ROUTE_RIPNG |
| 1793 | || rib->type == ZEBRA_ROUTE_OSPF6 |
Juliusz Chroboczek | 578ce37 | 2012-02-09 13:42:28 +0100 | [diff] [blame] | 1794 | || rib->type == ZEBRA_ROUTE_BABEL |
jardin | 9e867fe | 2003-12-23 08:56:18 +0000 | [diff] [blame] | 1795 | || rib->type == ZEBRA_ROUTE_ISIS |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1796 | || rib->type == ZEBRA_ROUTE_BGP) |
| 1797 | { |
| 1798 | time_t uptime; |
| 1799 | struct tm *tm; |
| 1800 | |
| 1801 | uptime = time (NULL); |
| 1802 | uptime -= rib->uptime; |
| 1803 | tm = gmtime (&uptime); |
| 1804 | |
| 1805 | #define ONE_DAY_SECOND 60*60*24 |
| 1806 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1807 | |
| 1808 | if (uptime < ONE_DAY_SECOND) |
| 1809 | vty_out (vty, ", %02d:%02d:%02d", |
| 1810 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1811 | else if (uptime < ONE_WEEK_SECOND) |
| 1812 | vty_out (vty, ", %dd%02dh%02dm", |
| 1813 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1814 | else |
| 1815 | vty_out (vty, ", %02dw%dd%02dh", |
| 1816 | tm->tm_yday/7, |
| 1817 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1818 | } |
| 1819 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1820 | } |
| 1821 | } |
| 1822 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1823 | DEFUN (show_ipv6_route, |
| 1824 | show_ipv6_route_cmd, |
| 1825 | "show ipv6 route", |
| 1826 | SHOW_STR |
| 1827 | IP_STR |
| 1828 | "IPv6 routing table\n") |
| 1829 | { |
| 1830 | struct route_table *table; |
| 1831 | struct route_node *rn; |
| 1832 | struct rib *rib; |
| 1833 | int first = 1; |
| 1834 | |
| 1835 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1836 | if (! table) |
| 1837 | return CMD_SUCCESS; |
| 1838 | |
| 1839 | /* Show all IPv6 route. */ |
| 1840 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1841 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1842 | { |
| 1843 | if (first) |
| 1844 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1845 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1846 | first = 0; |
| 1847 | } |
| 1848 | vty_show_ipv6_route (vty, rn, rib); |
| 1849 | } |
| 1850 | return CMD_SUCCESS; |
| 1851 | } |
| 1852 | |
| 1853 | DEFUN (show_ipv6_route_prefix_longer, |
| 1854 | show_ipv6_route_prefix_longer_cmd, |
| 1855 | "show ipv6 route X:X::X:X/M longer-prefixes", |
| 1856 | SHOW_STR |
| 1857 | IP_STR |
| 1858 | "IPv6 routing table\n" |
| 1859 | "IPv6 prefix\n" |
| 1860 | "Show route matching the specified Network/Mask pair only\n") |
| 1861 | { |
| 1862 | struct route_table *table; |
| 1863 | struct route_node *rn; |
| 1864 | struct rib *rib; |
| 1865 | struct prefix p; |
| 1866 | int ret; |
| 1867 | int first = 1; |
| 1868 | |
| 1869 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1870 | if (! table) |
| 1871 | return CMD_SUCCESS; |
| 1872 | |
| 1873 | ret = str2prefix (argv[0], &p); |
| 1874 | if (! ret) |
| 1875 | { |
| 1876 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 1877 | return CMD_WARNING; |
| 1878 | } |
| 1879 | |
| 1880 | /* Show matched type IPv6 routes. */ |
| 1881 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1882 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1883 | if (prefix_match (&p, &rn->p)) |
| 1884 | { |
| 1885 | if (first) |
| 1886 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1887 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1888 | first = 0; |
| 1889 | } |
| 1890 | vty_show_ipv6_route (vty, rn, rib); |
| 1891 | } |
| 1892 | return CMD_SUCCESS; |
| 1893 | } |
| 1894 | |
| 1895 | DEFUN (show_ipv6_route_protocol, |
| 1896 | show_ipv6_route_protocol_cmd, |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1897 | "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1898 | SHOW_STR |
| 1899 | IP_STR |
| 1900 | "IP routing table\n" |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1901 | QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | { |
| 1903 | int type; |
| 1904 | struct route_table *table; |
| 1905 | struct route_node *rn; |
| 1906 | struct rib *rib; |
| 1907 | int first = 1; |
| 1908 | |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1909 | type = proto_redistnum (AFI_IP6, argv[0]); |
| 1910 | if (type < 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1911 | { |
| 1912 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 1913 | return CMD_WARNING; |
| 1914 | } |
| 1915 | |
| 1916 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1917 | if (! table) |
| 1918 | return CMD_SUCCESS; |
| 1919 | |
| 1920 | /* Show matched type IPv6 routes. */ |
| 1921 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 1922 | RNODE_FOREACH_RIB (rn, rib) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1923 | if (rib->type == type) |
| 1924 | { |
| 1925 | if (first) |
| 1926 | { |
David Lamparter | e0ca5fd | 2009-09-16 01:52:42 +0200 | [diff] [blame] | 1927 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1928 | first = 0; |
| 1929 | } |
| 1930 | vty_show_ipv6_route (vty, rn, rib); |
| 1931 | } |
| 1932 | return CMD_SUCCESS; |
| 1933 | } |
| 1934 | |
| 1935 | DEFUN (show_ipv6_route_addr, |
| 1936 | show_ipv6_route_addr_cmd, |
| 1937 | "show ipv6 route X:X::X:X", |
| 1938 | SHOW_STR |
| 1939 | IP_STR |
| 1940 | "IPv6 routing table\n" |
| 1941 | "IPv6 Address\n") |
| 1942 | { |
| 1943 | int ret; |
| 1944 | struct prefix_ipv6 p; |
| 1945 | struct route_table *table; |
| 1946 | struct route_node *rn; |
| 1947 | |
| 1948 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1949 | if (ret <= 0) |
| 1950 | { |
| 1951 | vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); |
| 1952 | return CMD_WARNING; |
| 1953 | } |
| 1954 | |
| 1955 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1956 | if (! table) |
| 1957 | return CMD_SUCCESS; |
| 1958 | |
| 1959 | rn = route_node_match (table, (struct prefix *) &p); |
| 1960 | if (! rn) |
| 1961 | { |
| 1962 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1963 | return CMD_WARNING; |
| 1964 | } |
| 1965 | |
| 1966 | vty_show_ipv6_route_detail (vty, rn); |
| 1967 | |
| 1968 | route_unlock_node (rn); |
| 1969 | |
| 1970 | return CMD_SUCCESS; |
| 1971 | } |
| 1972 | |
| 1973 | DEFUN (show_ipv6_route_prefix, |
| 1974 | show_ipv6_route_prefix_cmd, |
| 1975 | "show ipv6 route X:X::X:X/M", |
| 1976 | SHOW_STR |
| 1977 | IP_STR |
| 1978 | "IPv6 routing table\n" |
| 1979 | "IPv6 prefix\n") |
| 1980 | { |
| 1981 | int ret; |
| 1982 | struct prefix_ipv6 p; |
| 1983 | struct route_table *table; |
| 1984 | struct route_node *rn; |
| 1985 | |
| 1986 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1987 | if (ret <= 0) |
| 1988 | { |
| 1989 | vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); |
| 1990 | return CMD_WARNING; |
| 1991 | } |
| 1992 | |
| 1993 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1994 | if (! table) |
| 1995 | return CMD_SUCCESS; |
| 1996 | |
| 1997 | rn = route_node_match (table, (struct prefix *) &p); |
| 1998 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 1999 | { |
| 2000 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
Lu Feng | 969d355 | 2014-10-21 06:24:07 +0000 | [diff] [blame] | 2001 | if (rn) |
| 2002 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2003 | return CMD_WARNING; |
| 2004 | } |
| 2005 | |
| 2006 | vty_show_ipv6_route_detail (vty, rn); |
| 2007 | |
| 2008 | route_unlock_node (rn); |
| 2009 | |
| 2010 | return CMD_SUCCESS; |
| 2011 | } |
| 2012 | |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2013 | /* Show route summary. */ |
| 2014 | DEFUN (show_ipv6_route_summary, |
| 2015 | show_ipv6_route_summary_cmd, |
| 2016 | "show ipv6 route summary", |
| 2017 | SHOW_STR |
| 2018 | IP_STR |
| 2019 | "IPv6 routing table\n" |
| 2020 | "Summary of all IPv6 routes\n") |
| 2021 | { |
| 2022 | struct route_table *table; |
| 2023 | |
| 2024 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2025 | if (! table) |
| 2026 | return CMD_SUCCESS; |
| 2027 | |
| 2028 | vty_show_ip_route_summary (vty, table); |
| 2029 | |
| 2030 | return CMD_SUCCESS; |
| 2031 | } |
| 2032 | |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 2033 | /* Show ipv6 route summary prefix. */ |
| 2034 | DEFUN (show_ipv6_route_summary_prefix, |
| 2035 | show_ipv6_route_summary_prefix_cmd, |
| 2036 | "show ipv6 route summary prefix", |
| 2037 | SHOW_STR |
| 2038 | IP_STR |
| 2039 | "IPv6 routing table\n" |
| 2040 | "Summary of all IPv6 routes\n" |
| 2041 | "Prefix routes\n") |
| 2042 | { |
| 2043 | struct route_table *table; |
| 2044 | |
| 2045 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2046 | if (! table) |
| 2047 | return CMD_SUCCESS; |
| 2048 | |
| 2049 | vty_show_ip_route_summary_prefix (vty, table); |
| 2050 | |
| 2051 | return CMD_SUCCESS; |
| 2052 | } |
| 2053 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2054 | /* |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2055 | * Show IPv6 mroute command.Used to dump |
| 2056 | * the Multicast routing table. |
| 2057 | */ |
| 2058 | |
| 2059 | DEFUN (show_ipv6_mroute, |
| 2060 | show_ipv6_mroute_cmd, |
| 2061 | "show ipv6 mroute", |
| 2062 | SHOW_STR |
| 2063 | IP_STR |
| 2064 | "IPv6 Multicast routing table\n") |
| 2065 | { |
| 2066 | struct route_table *table; |
| 2067 | struct route_node *rn; |
| 2068 | struct rib *rib; |
| 2069 | int first = 1; |
| 2070 | |
| 2071 | table = vrf_table (AFI_IP6, SAFI_MULTICAST, 0); |
| 2072 | if (! table) |
| 2073 | return CMD_SUCCESS; |
| 2074 | |
| 2075 | /* Show all IPv6 route. */ |
| 2076 | for (rn = route_top (table); rn; rn = route_next (rn)) |
Avneesh Sachdev | 9fd92e3 | 2012-11-13 22:48:53 +0000 | [diff] [blame] | 2077 | RNODE_FOREACH_RIB (rn, rib) |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2078 | { |
| 2079 | if (first) |
| 2080 | { |
G.Balaji | cb32fd6 | 2011-11-27 20:09:40 +0530 | [diff] [blame] | 2081 | vty_out (vty, SHOW_ROUTE_V6_HEADER); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2082 | first = 0; |
| 2083 | } |
| 2084 | vty_show_ipv6_route (vty, rn, rib); |
| 2085 | } |
| 2086 | return CMD_SUCCESS; |
| 2087 | } |
| 2088 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2089 | /* Write IPv6 static route configuration. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2090 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2091 | static_config_ipv6 (struct vty *vty) |
| 2092 | { |
| 2093 | struct route_node *rn; |
| 2094 | struct static_ipv6 *si; |
| 2095 | int write; |
| 2096 | char buf[BUFSIZ]; |
| 2097 | struct route_table *stable; |
| 2098 | |
| 2099 | write = 0; |
| 2100 | |
| 2101 | /* Lookup table. */ |
| 2102 | stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0); |
| 2103 | if (! stable) |
| 2104 | return -1; |
| 2105 | |
| 2106 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 2107 | for (si = rn->info; si; si = si->next) |
| 2108 | { |
| 2109 | vty_out (vty, "ipv6 route %s/%d", |
| 2110 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 2111 | rn->p.prefixlen); |
| 2112 | |
| 2113 | switch (si->type) |
| 2114 | { |
| 2115 | case STATIC_IPV6_GATEWAY: |
| 2116 | vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ)); |
| 2117 | break; |
| 2118 | case STATIC_IPV6_IFNAME: |
| 2119 | vty_out (vty, " %s", si->ifname); |
| 2120 | break; |
| 2121 | case STATIC_IPV6_GATEWAY_IFNAME: |
| 2122 | vty_out (vty, " %s %s", |
| 2123 | inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname); |
| 2124 | break; |
| 2125 | } |
| 2126 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2127 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 2128 | vty_out (vty, " %s", "reject"); |
| 2129 | |
| 2130 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 2131 | vty_out (vty, " %s", "blackhole"); |
| 2132 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2133 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 2134 | vty_out (vty, " %d", si->distance); |
| 2135 | vty_out (vty, "%s", VTY_NEWLINE); |
| 2136 | |
| 2137 | write = 1; |
| 2138 | } |
| 2139 | return write; |
| 2140 | } |
| 2141 | #endif /* HAVE_IPV6 */ |
| 2142 | |
| 2143 | /* Static ip route configuration write function. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2144 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2145 | zebra_ip_config (struct vty *vty) |
| 2146 | { |
| 2147 | int write = 0; |
| 2148 | |
| 2149 | write += static_config_ipv4 (vty); |
| 2150 | #ifdef HAVE_IPV6 |
| 2151 | write += static_config_ipv6 (vty); |
| 2152 | #endif /* HAVE_IPV6 */ |
| 2153 | |
| 2154 | return write; |
| 2155 | } |
| 2156 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2157 | /* ip protocol configuration write function */ |
| 2158 | static int config_write_protocol(struct vty *vty) |
| 2159 | { |
| 2160 | int i; |
| 2161 | |
| 2162 | for (i=0;i<ZEBRA_ROUTE_MAX;i++) |
| 2163 | { |
| 2164 | if (proto_rm[AFI_IP][i]) |
| 2165 | vty_out (vty, "ip protocol %s route-map %s%s", zebra_route_string(i), |
| 2166 | proto_rm[AFI_IP][i], VTY_NEWLINE); |
| 2167 | } |
| 2168 | if (proto_rm[AFI_IP][ZEBRA_ROUTE_MAX]) |
| 2169 | vty_out (vty, "ip protocol %s route-map %s%s", "any", |
| 2170 | proto_rm[AFI_IP][ZEBRA_ROUTE_MAX], VTY_NEWLINE); |
| 2171 | |
| 2172 | return 1; |
| 2173 | } |
| 2174 | |
| 2175 | /* table node for protocol filtering */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 2176 | static struct cmd_node protocol_node = { PROTOCOL_NODE, "", 1 }; |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2177 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2178 | /* IP node for static routes. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 2179 | static struct cmd_node ip_node = { IP_NODE, "", 1 }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2180 | |
| 2181 | /* Route VTY. */ |
| 2182 | void |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 2183 | zebra_vty_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2184 | { |
| 2185 | install_node (&ip_node, zebra_ip_config); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2186 | install_node (&protocol_node, config_write_protocol); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2187 | |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 2188 | install_element (CONFIG_NODE, &ip_protocol_cmd); |
| 2189 | install_element (CONFIG_NODE, &no_ip_protocol_cmd); |
| 2190 | install_element (VIEW_NODE, &show_ip_protocol_cmd); |
| 2191 | install_element (ENABLE_NODE, &show_ip_protocol_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2192 | install_element (CONFIG_NODE, &ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2193 | install_element (CONFIG_NODE, &ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2194 | install_element (CONFIG_NODE, &ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2195 | install_element (CONFIG_NODE, &ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2196 | install_element (CONFIG_NODE, &ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2197 | install_element (CONFIG_NODE, &ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2198 | install_element (CONFIG_NODE, &no_ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2199 | install_element (CONFIG_NODE, &no_ip_route_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2200 | install_element (CONFIG_NODE, &no_ip_route_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2201 | install_element (CONFIG_NODE, &no_ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2202 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2203 | install_element (CONFIG_NODE, &no_ip_route_mask_flags2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2204 | install_element (CONFIG_NODE, &ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2205 | install_element (CONFIG_NODE, &ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2206 | install_element (CONFIG_NODE, &ip_route_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2207 | install_element (CONFIG_NODE, &ip_route_mask_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2208 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2209 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2210 | install_element (CONFIG_NODE, &no_ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2211 | install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2212 | install_element (CONFIG_NODE, &no_ip_route_flags_distance2_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2213 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd); |
hasso | 457ef55 | 2003-05-28 12:02:15 +0000 | [diff] [blame] | 2214 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance2_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2215 | |
| 2216 | install_element (VIEW_NODE, &show_ip_route_cmd); |
| 2217 | install_element (VIEW_NODE, &show_ip_route_addr_cmd); |
| 2218 | install_element (VIEW_NODE, &show_ip_route_prefix_cmd); |
| 2219 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd); |
| 2220 | install_element (VIEW_NODE, &show_ip_route_protocol_cmd); |
| 2221 | install_element (VIEW_NODE, &show_ip_route_supernets_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2222 | install_element (VIEW_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 2223 | install_element (VIEW_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2224 | install_element (ENABLE_NODE, &show_ip_route_cmd); |
| 2225 | install_element (ENABLE_NODE, &show_ip_route_addr_cmd); |
| 2226 | install_element (ENABLE_NODE, &show_ip_route_prefix_cmd); |
| 2227 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd); |
| 2228 | install_element (ENABLE_NODE, &show_ip_route_protocol_cmd); |
| 2229 | install_element (ENABLE_NODE, &show_ip_route_supernets_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2230 | install_element (ENABLE_NODE, &show_ip_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 2231 | install_element (ENABLE_NODE, &show_ip_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2232 | |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2233 | install_element (VIEW_NODE, &show_ip_mroute_cmd); |
| 2234 | install_element (ENABLE_NODE, &show_ip_mroute_cmd); |
| 2235 | |
| 2236 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2237 | #ifdef HAVE_IPV6 |
| 2238 | install_element (CONFIG_NODE, &ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2239 | install_element (CONFIG_NODE, &ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2240 | install_element (CONFIG_NODE, &ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2241 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2242 | install_element (CONFIG_NODE, &no_ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2243 | install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2244 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2245 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2246 | install_element (CONFIG_NODE, &ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2247 | install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2249 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2250 | install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2251 | install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2252 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 2253 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2254 | install_element (VIEW_NODE, &show_ipv6_route_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2255 | install_element (VIEW_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 2256 | install_element (VIEW_NODE, &show_ipv6_route_summary_prefix_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2257 | install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd); |
| 2258 | install_element (VIEW_NODE, &show_ipv6_route_addr_cmd); |
| 2259 | install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd); |
| 2260 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd); |
| 2261 | install_element (ENABLE_NODE, &show_ipv6_route_cmd); |
| 2262 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd); |
| 2263 | install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd); |
| 2264 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd); |
| 2265 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd); |
Stig Thormodsrud | 61691c9 | 2008-11-04 15:45:07 -0800 | [diff] [blame] | 2266 | install_element (ENABLE_NODE, &show_ipv6_route_summary_cmd); |
Dinesh G Dutt | 56a5f77 | 2014-09-30 12:58:04 -0700 | [diff] [blame^] | 2267 | install_element (ENABLE_NODE, &show_ipv6_route_summary_prefix_cmd); |
G.Balaji | cddf391 | 2011-11-26 21:59:32 +0400 | [diff] [blame] | 2268 | |
| 2269 | install_element (VIEW_NODE, &show_ipv6_mroute_cmd); |
| 2270 | install_element (ENABLE_NODE, &show_ipv6_mroute_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2271 | #endif /* HAVE_IPV6 */ |
| 2272 | } |