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 | |
| 24 | #include "if.h" |
| 25 | #include "prefix.h" |
| 26 | #include "command.h" |
| 27 | #include "table.h" |
| 28 | #include "rib.h" |
| 29 | |
| 30 | /* Return route type string for VTY output. */ |
| 31 | const char * |
| 32 | route_type_str (u_char type) |
| 33 | { |
| 34 | switch (type) |
| 35 | { |
| 36 | case ZEBRA_ROUTE_SYSTEM: |
| 37 | return "system"; |
| 38 | case ZEBRA_ROUTE_KERNEL: |
| 39 | return "kernel"; |
| 40 | case ZEBRA_ROUTE_CONNECT: |
| 41 | return "connected"; |
| 42 | case ZEBRA_ROUTE_STATIC: |
| 43 | return "static"; |
| 44 | case ZEBRA_ROUTE_RIP: |
| 45 | return "rip"; |
| 46 | case ZEBRA_ROUTE_RIPNG: |
| 47 | return "rip"; |
| 48 | case ZEBRA_ROUTE_OSPF: |
| 49 | return "ospf"; |
| 50 | case ZEBRA_ROUTE_OSPF6: |
| 51 | return "ospf"; |
| 52 | case ZEBRA_ROUTE_BGP: |
| 53 | return "bgp"; |
| 54 | default: |
| 55 | return "unknown"; |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | /* Return route type string for VTY output. */ |
| 60 | const char |
| 61 | route_type_char (u_char type) |
| 62 | { |
| 63 | switch (type) |
| 64 | { |
| 65 | case ZEBRA_ROUTE_SYSTEM: |
| 66 | return 'S'; |
| 67 | case ZEBRA_ROUTE_KERNEL: |
| 68 | return 'K'; |
| 69 | case ZEBRA_ROUTE_CONNECT: |
| 70 | return 'C'; |
| 71 | case ZEBRA_ROUTE_STATIC: |
| 72 | return 'S'; |
| 73 | case ZEBRA_ROUTE_RIP: |
| 74 | return 'R'; |
| 75 | case ZEBRA_ROUTE_RIPNG: |
| 76 | return 'R'; |
| 77 | case ZEBRA_ROUTE_OSPF: |
| 78 | return 'O'; |
| 79 | case ZEBRA_ROUTE_OSPF6: |
| 80 | return 'O'; |
| 81 | case ZEBRA_ROUTE_BGP: |
| 82 | return 'B'; |
| 83 | default: |
| 84 | return '?'; |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | /* General fucntion for static route. */ |
| 89 | int |
| 90 | zebra_static_ipv4 (struct vty *vty, int add_cmd, |
| 91 | char *dest_str, char *mask_str, char *gate_str, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 92 | char *flag_str, char *distance_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 93 | { |
| 94 | int ret; |
| 95 | u_char distance; |
| 96 | struct prefix p; |
| 97 | struct in_addr gate; |
| 98 | struct in_addr mask; |
| 99 | char *ifname; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 100 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | |
| 102 | ret = str2prefix (dest_str, &p); |
| 103 | if (ret <= 0) |
| 104 | { |
| 105 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 106 | return CMD_WARNING; |
| 107 | } |
| 108 | |
| 109 | /* Cisco like mask notation. */ |
| 110 | if (mask_str) |
| 111 | { |
| 112 | ret = inet_aton (mask_str, &mask); |
| 113 | if (ret == 0) |
| 114 | { |
| 115 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 116 | return CMD_WARNING; |
| 117 | } |
| 118 | p.prefixlen = ip_masklen (mask); |
| 119 | } |
| 120 | |
| 121 | /* Apply mask for given prefix. */ |
| 122 | apply_mask (&p); |
| 123 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 124 | /* Route flags */ |
| 125 | if (flag_str) { |
| 126 | switch(flag_str[0]) { |
| 127 | case 'r': |
| 128 | case 'R': /* XXX */ |
| 129 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 130 | break; |
| 131 | case 'b': |
| 132 | case 'B': /* XXX */ |
| 133 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 134 | break; |
| 135 | default: |
| 136 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
| 137 | break; |
| 138 | } |
| 139 | } |
| 140 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 141 | /* Administrative distance. */ |
| 142 | if (distance_str) |
| 143 | distance = atoi (distance_str); |
| 144 | else |
| 145 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 146 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 147 | /* When gateway is A.B.C.D format, gate is treated as nexthop |
| 148 | address other case gate is treated as interface name. */ |
| 149 | ret = inet_aton (gate_str, &gate); |
| 150 | if (ret) |
| 151 | ifname = NULL; |
| 152 | else |
| 153 | ifname = gate_str; |
| 154 | |
| 155 | if (add_cmd) |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 156 | static_add_ipv4 (&p, ifname ? NULL : &gate, ifname, flag, distance, 0); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | else |
| 158 | static_delete_ipv4 (&p, ifname ? NULL : &gate, ifname, distance, 0); |
| 159 | |
| 160 | return CMD_SUCCESS; |
| 161 | } |
| 162 | |
| 163 | /* Static route configuration. */ |
| 164 | DEFUN (ip_route, |
| 165 | ip_route_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 166 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 167 | IP_STR |
| 168 | "Establish static routes\n" |
| 169 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 170 | "IP gateway address\n" |
| 171 | "IP gateway interface name\n") |
| 172 | { |
| 173 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL); |
| 174 | } |
| 175 | |
| 176 | DEFUN (ip_route_flags, |
| 177 | ip_route_flags_cmd, |
| 178 | "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] | 179 | IP_STR |
| 180 | "Establish static routes\n" |
| 181 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 182 | "IP gateway address\n" |
| 183 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 184 | "Emit an ICMP unreachable when matched\n" |
| 185 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 186 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 187 | 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] | 188 | } |
| 189 | |
| 190 | /* Mask as A.B.C.D format. */ |
| 191 | DEFUN (ip_route_mask, |
| 192 | ip_route_mask_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 193 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE)", |
| 194 | IP_STR |
| 195 | "Establish static routes\n" |
| 196 | "IP destination prefix\n" |
| 197 | "IP destination prefix mask\n" |
| 198 | "IP gateway address\n" |
| 199 | "IP gateway interface name\n") |
| 200 | { |
| 201 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 202 | } |
| 203 | |
| 204 | DEFUN (ip_route_mask_flags, |
| 205 | ip_route_mask_flags_cmd, |
| 206 | "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] | 207 | IP_STR |
| 208 | "Establish static routes\n" |
| 209 | "IP destination prefix\n" |
| 210 | "IP destination prefix mask\n" |
| 211 | "IP gateway address\n" |
| 212 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 213 | "Emit an ICMP unreachable when matched\n" |
| 214 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 215 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 216 | 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] | 217 | } |
| 218 | |
| 219 | /* Distance option value. */ |
| 220 | DEFUN (ip_route_distance, |
| 221 | ip_route_distance_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 222 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 223 | IP_STR |
| 224 | "Establish static routes\n" |
| 225 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 226 | "IP gateway address\n" |
| 227 | "IP gateway interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 228 | "Distance value for this route\n") |
| 229 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 230 | return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2]); |
| 231 | } |
| 232 | |
| 233 | DEFUN (ip_route_flags_distance, |
| 234 | ip_route_flags_distance_cmd, |
| 235 | "ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 236 | IP_STR |
| 237 | "Establish static routes\n" |
| 238 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 239 | "IP gateway address\n" |
| 240 | "IP gateway interface name\n" |
| 241 | "Emit an ICMP unreachable when matched\n" |
| 242 | "Silently discard pkts when matched\n" |
| 243 | "Distance value for this route\n") |
| 244 | { |
| 245 | 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] | 246 | } |
| 247 | |
| 248 | DEFUN (ip_route_mask_distance, |
| 249 | ip_route_mask_distance_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 250 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 251 | IP_STR |
| 252 | "Establish static routes\n" |
| 253 | "IP destination prefix\n" |
| 254 | "IP destination prefix mask\n" |
| 255 | "IP gateway address\n" |
| 256 | "IP gateway interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 257 | "Distance value for this route\n") |
| 258 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 259 | return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 260 | } |
| 261 | |
| 262 | DEFUN (ip_route_mask_flags_distance, |
| 263 | ip_route_mask_flags_distance_cmd, |
| 264 | "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 265 | IP_STR |
| 266 | "Establish static routes\n" |
| 267 | "IP destination prefix\n" |
| 268 | "IP destination prefix mask\n" |
| 269 | "IP gateway address\n" |
| 270 | "IP gateway interface name\n" |
| 271 | "Distance value for this route\n" |
| 272 | "Emit an ICMP unreachable when matched\n" |
| 273 | "Silently discard pkts when matched\n") |
| 274 | { |
| 275 | 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] | 276 | } |
| 277 | |
| 278 | DEFUN (no_ip_route, |
| 279 | no_ip_route_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 280 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE)", |
| 281 | NO_STR |
| 282 | IP_STR |
| 283 | "Establish static routes\n" |
| 284 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 285 | "IP gateway address\n" |
| 286 | "IP gateway interface name\n") |
| 287 | { |
| 288 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL); |
| 289 | } |
| 290 | |
| 291 | ALIAS (no_ip_route, |
| 292 | no_ip_route_flags_cmd, |
| 293 | "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] | 294 | NO_STR |
| 295 | IP_STR |
| 296 | "Establish static routes\n" |
| 297 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 298 | "IP gateway address\n" |
| 299 | "IP gateway interface name\n" |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 300 | "Emit an ICMP unreachable when matched\n" |
| 301 | "Silently discard pkts when matched\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 302 | |
| 303 | DEFUN (no_ip_route_mask, |
| 304 | no_ip_route_mask_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 305 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE)", |
| 306 | NO_STR |
| 307 | IP_STR |
| 308 | "Establish static routes\n" |
| 309 | "IP destination prefix\n" |
| 310 | "IP destination prefix mask\n" |
| 311 | "IP gateway address\n" |
| 312 | "IP gateway interface name\n") |
| 313 | { |
| 314 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL); |
| 315 | } |
| 316 | |
| 317 | ALIAS (no_ip_route_mask, |
| 318 | no_ip_route_mask_flags_cmd, |
| 319 | "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] | 320 | NO_STR |
| 321 | IP_STR |
| 322 | "Establish static routes\n" |
| 323 | "IP destination prefix\n" |
| 324 | "IP destination prefix mask\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 | |
| 330 | DEFUN (no_ip_route_distance, |
| 331 | no_ip_route_distance_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 332 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 333 | NO_STR |
| 334 | IP_STR |
| 335 | "Establish static routes\n" |
| 336 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 337 | "IP gateway address\n" |
| 338 | "IP gateway interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 339 | "Distance value for this route\n") |
| 340 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 341 | return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2]); |
| 342 | } |
| 343 | |
| 344 | DEFUN (no_ip_route_flags_distance, |
| 345 | no_ip_route_flags_distance_cmd, |
| 346 | "no ip route A.B.C.D/M (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 347 | NO_STR |
| 348 | IP_STR |
| 349 | "Establish static routes\n" |
| 350 | "IP destination prefix (e.g. 10.0.0.0/8)\n" |
| 351 | "IP gateway address\n" |
| 352 | "IP gateway interface name\n" |
| 353 | "Emit an ICMP unreachable when matched\n" |
| 354 | "Silently discard pkts when matched\n" |
| 355 | "Distance value for this route\n") |
| 356 | { |
| 357 | 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] | 358 | } |
| 359 | |
| 360 | DEFUN (no_ip_route_mask_distance, |
| 361 | no_ip_route_mask_distance_cmd, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 362 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) <1-255>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 363 | NO_STR |
| 364 | IP_STR |
| 365 | "Establish static routes\n" |
| 366 | "IP destination prefix\n" |
| 367 | "IP destination prefix mask\n" |
| 368 | "IP gateway address\n" |
| 369 | "IP gateway interface name\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 370 | "Distance value for this route\n") |
| 371 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 372 | return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 373 | } |
| 374 | |
| 375 | DEFUN (no_ip_route_mask_flags_distance, |
| 376 | no_ip_route_mask_flags_distance_cmd, |
| 377 | "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE) (reject|blackhole) <1-255>", |
| 378 | NO_STR |
| 379 | IP_STR |
| 380 | "Establish static routes\n" |
| 381 | "IP destination prefix\n" |
| 382 | "IP destination prefix mask\n" |
| 383 | "IP gateway address\n" |
| 384 | "IP gateway interface name\n" |
| 385 | "Emit an ICMP unreachable when matched\n" |
| 386 | "Silently discard pkts when matched\n" |
| 387 | "Distance value for this route\n") |
| 388 | { |
| 389 | 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] | 390 | } |
| 391 | |
| 392 | /* New RIB. Detailed information for IPv4 route. */ |
| 393 | void |
| 394 | vty_show_ip_route_detail (struct vty *vty, struct route_node *rn) |
| 395 | { |
| 396 | struct rib *rib; |
| 397 | struct nexthop *nexthop; |
| 398 | |
| 399 | for (rib = rn->info; rib; rib = rib->next) |
| 400 | { |
| 401 | vty_out (vty, "Routing entry for %s/%d%s", |
| 402 | inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen, |
| 403 | VTY_NEWLINE); |
| 404 | vty_out (vty, " Known via \"%s\"", route_type_str (rib->type)); |
| 405 | vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric); |
| 406 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
| 407 | vty_out (vty, ", best"); |
| 408 | if (rib->refcnt) |
| 409 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 410 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 411 | vty_out (vty, ", blackhole"); |
| 412 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 413 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 414 | vty_out (vty, "%s", VTY_NEWLINE); |
| 415 | |
| 416 | #define ONE_DAY_SECOND 60*60*24 |
| 417 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 418 | if (rib->type == ZEBRA_ROUTE_RIP |
| 419 | || rib->type == ZEBRA_ROUTE_OSPF |
| 420 | || rib->type == ZEBRA_ROUTE_BGP) |
| 421 | { |
| 422 | time_t uptime; |
| 423 | struct tm *tm; |
| 424 | |
| 425 | uptime = time (NULL); |
| 426 | uptime -= rib->uptime; |
| 427 | tm = gmtime (&uptime); |
| 428 | |
| 429 | vty_out (vty, " Last update "); |
| 430 | |
| 431 | if (uptime < ONE_DAY_SECOND) |
| 432 | vty_out (vty, "%02d:%02d:%02d", |
| 433 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 434 | else if (uptime < ONE_WEEK_SECOND) |
| 435 | vty_out (vty, "%dd%02dh%02dm", |
| 436 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 437 | else |
| 438 | vty_out (vty, "%02dw%dd%02dh", |
| 439 | tm->tm_yday/7, |
| 440 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 441 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 442 | } |
| 443 | |
| 444 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 445 | { |
| 446 | vty_out (vty, " %c", |
| 447 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' '); |
| 448 | |
| 449 | switch (nexthop->type) |
| 450 | { |
| 451 | case NEXTHOP_TYPE_IPV4: |
| 452 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 453 | vty_out (vty, " %s", inet_ntoa (nexthop->gate.ipv4)); |
| 454 | if (nexthop->ifindex) |
| 455 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 456 | break; |
| 457 | case NEXTHOP_TYPE_IFINDEX: |
| 458 | vty_out (vty, " directly connected, %s", |
| 459 | ifindex2ifname (nexthop->ifindex)); |
| 460 | break; |
| 461 | case NEXTHOP_TYPE_IFNAME: |
| 462 | vty_out (vty, " directly connected, %s", nexthop->ifname); |
| 463 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 464 | default: |
| 465 | break; |
| 466 | } |
| 467 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 468 | vty_out (vty, " inactive"); |
| 469 | |
| 470 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 471 | { |
| 472 | vty_out (vty, " (recursive"); |
| 473 | |
| 474 | switch (nexthop->rtype) |
| 475 | { |
| 476 | case NEXTHOP_TYPE_IPV4: |
| 477 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 478 | vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4)); |
| 479 | break; |
| 480 | case NEXTHOP_TYPE_IFINDEX: |
| 481 | case NEXTHOP_TYPE_IFNAME: |
| 482 | vty_out (vty, " is directly connected, %s)", |
| 483 | ifindex2ifname (nexthop->rifindex)); |
| 484 | break; |
| 485 | default: |
| 486 | break; |
| 487 | } |
| 488 | } |
| 489 | vty_out (vty, "%s", VTY_NEWLINE); |
| 490 | } |
| 491 | vty_out (vty, "%s", VTY_NEWLINE); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | void |
| 496 | vty_show_ip_route (struct vty *vty, struct route_node *rn, struct rib *rib) |
| 497 | { |
| 498 | struct nexthop *nexthop; |
| 499 | int len = 0; |
| 500 | char buf[BUFSIZ]; |
| 501 | |
| 502 | /* Nexthop information. */ |
| 503 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 504 | { |
| 505 | if (nexthop == rib->nexthop) |
| 506 | { |
| 507 | /* Prefix information. */ |
| 508 | len = vty_out (vty, "%c%c%c %s/%d", |
| 509 | route_type_char (rib->type), |
| 510 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 511 | ? '>' : ' ', |
| 512 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 513 | ? '*' : ' ', |
| 514 | inet_ntop (AF_INET, &rn->p.u.prefix, buf, BUFSIZ), |
| 515 | rn->p.prefixlen); |
| 516 | |
| 517 | /* Distance and metric display. */ |
| 518 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 519 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 520 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 521 | rib->metric); |
| 522 | } |
| 523 | else |
| 524 | vty_out (vty, " %c%*c", |
| 525 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 526 | ? '*' : ' ', |
| 527 | len - 3, ' '); |
| 528 | |
| 529 | switch (nexthop->type) |
| 530 | { |
| 531 | case NEXTHOP_TYPE_IPV4: |
| 532 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 533 | vty_out (vty, " via %s", inet_ntoa (nexthop->gate.ipv4)); |
| 534 | if (nexthop->ifindex) |
| 535 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 536 | break; |
| 537 | case NEXTHOP_TYPE_IFINDEX: |
| 538 | vty_out (vty, " is directly connected, %s", |
| 539 | ifindex2ifname (nexthop->ifindex)); |
| 540 | break; |
| 541 | case NEXTHOP_TYPE_IFNAME: |
| 542 | vty_out (vty, " is directly connected, %s", nexthop->ifname); |
| 543 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 544 | default: |
| 545 | break; |
| 546 | } |
| 547 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 548 | vty_out (vty, " inactive"); |
| 549 | |
| 550 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 551 | { |
| 552 | vty_out (vty, " (recursive"); |
| 553 | |
| 554 | switch (nexthop->rtype) |
| 555 | { |
| 556 | case NEXTHOP_TYPE_IPV4: |
| 557 | case NEXTHOP_TYPE_IPV4_IFINDEX: |
| 558 | vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4)); |
| 559 | break; |
| 560 | case NEXTHOP_TYPE_IFINDEX: |
| 561 | case NEXTHOP_TYPE_IFNAME: |
| 562 | vty_out (vty, " is directly connected, %s)", |
| 563 | ifindex2ifname (nexthop->rifindex)); |
| 564 | break; |
| 565 | default: |
| 566 | break; |
| 567 | } |
| 568 | } |
| 569 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 570 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 571 | vty_out (vty, ", bh"); |
| 572 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 573 | vty_out (vty, ", rej"); |
| 574 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 575 | if (rib->type == ZEBRA_ROUTE_RIP |
| 576 | || rib->type == ZEBRA_ROUTE_OSPF |
| 577 | || rib->type == ZEBRA_ROUTE_BGP) |
| 578 | { |
| 579 | time_t uptime; |
| 580 | struct tm *tm; |
| 581 | |
| 582 | uptime = time (NULL); |
| 583 | uptime -= rib->uptime; |
| 584 | tm = gmtime (&uptime); |
| 585 | |
| 586 | #define ONE_DAY_SECOND 60*60*24 |
| 587 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 588 | |
| 589 | if (uptime < ONE_DAY_SECOND) |
| 590 | vty_out (vty, ", %02d:%02d:%02d", |
| 591 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 592 | else if (uptime < ONE_WEEK_SECOND) |
| 593 | vty_out (vty, ", %dd%02dh%02dm", |
| 594 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 595 | else |
| 596 | vty_out (vty, ", %02dw%dd%02dh", |
| 597 | tm->tm_yday/7, |
| 598 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 599 | } |
| 600 | vty_out (vty, "%s", VTY_NEWLINE); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | #define SHOW_ROUTE_V4_HEADER "Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,%s B - BGP, > - selected route, * - FIB route%s%s" |
| 605 | |
| 606 | DEFUN (show_ip_route, |
| 607 | show_ip_route_cmd, |
| 608 | "show ip route", |
| 609 | SHOW_STR |
| 610 | IP_STR |
| 611 | "IP routing table\n") |
| 612 | { |
| 613 | struct route_table *table; |
| 614 | struct route_node *rn; |
| 615 | struct rib *rib; |
| 616 | int first = 1; |
| 617 | |
| 618 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 619 | if (! table) |
| 620 | return CMD_SUCCESS; |
| 621 | |
| 622 | /* Show all IPv4 routes. */ |
| 623 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 624 | for (rib = rn->info; rib; rib = rib->next) |
| 625 | { |
| 626 | if (first) |
| 627 | { |
| 628 | vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, VTY_NEWLINE, |
| 629 | VTY_NEWLINE); |
| 630 | first = 0; |
| 631 | } |
| 632 | vty_show_ip_route (vty, rn, rib); |
| 633 | } |
| 634 | return CMD_SUCCESS; |
| 635 | } |
| 636 | |
| 637 | DEFUN (show_ip_route_prefix_longer, |
| 638 | show_ip_route_prefix_longer_cmd, |
| 639 | "show ip route A.B.C.D/M longer-prefixes", |
| 640 | SHOW_STR |
| 641 | IP_STR |
| 642 | "IP routing table\n" |
| 643 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 644 | "Show route matching the specified Network/Mask pair only\n") |
| 645 | { |
| 646 | struct route_table *table; |
| 647 | struct route_node *rn; |
| 648 | struct rib *rib; |
| 649 | struct prefix p; |
| 650 | int ret; |
| 651 | int first = 1; |
| 652 | |
| 653 | ret = str2prefix (argv[0], &p); |
| 654 | if (! ret) |
| 655 | { |
| 656 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 657 | return CMD_WARNING; |
| 658 | } |
| 659 | |
| 660 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 661 | if (! table) |
| 662 | return CMD_SUCCESS; |
| 663 | |
| 664 | /* Show matched type IPv4 routes. */ |
| 665 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 666 | for (rib = rn->info; rib; rib = rib->next) |
| 667 | if (prefix_match (&p, &rn->p)) |
| 668 | { |
| 669 | if (first) |
| 670 | { |
| 671 | vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, |
| 672 | VTY_NEWLINE, VTY_NEWLINE); |
| 673 | first = 0; |
| 674 | } |
| 675 | vty_show_ip_route (vty, rn, rib); |
| 676 | } |
| 677 | return CMD_SUCCESS; |
| 678 | } |
| 679 | |
| 680 | DEFUN (show_ip_route_supernets, |
| 681 | show_ip_route_supernets_cmd, |
| 682 | "show ip route supernets-only", |
| 683 | SHOW_STR |
| 684 | IP_STR |
| 685 | "IP routing table\n" |
| 686 | "Show supernet entries only\n") |
| 687 | { |
| 688 | struct route_table *table; |
| 689 | struct route_node *rn; |
| 690 | struct rib *rib; |
| 691 | u_int32_t addr; |
| 692 | int first = 1; |
| 693 | |
| 694 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 695 | if (! table) |
| 696 | return CMD_SUCCESS; |
| 697 | |
| 698 | /* Show matched type IPv4 routes. */ |
| 699 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 700 | for (rib = rn->info; rib; rib = rib->next) |
| 701 | { |
| 702 | addr = ntohl (rn->p.u.prefix4.s_addr); |
| 703 | |
| 704 | if ((IN_CLASSC (addr) && rn->p.prefixlen < 24) |
| 705 | || (IN_CLASSB (addr) && rn->p.prefixlen < 16) |
| 706 | || (IN_CLASSA (addr) && rn->p.prefixlen < 8)) |
| 707 | { |
| 708 | if (first) |
| 709 | { |
| 710 | vty_out (vty, SHOW_ROUTE_V4_HEADER, VTY_NEWLINE, |
| 711 | VTY_NEWLINE, VTY_NEWLINE); |
| 712 | first = 0; |
| 713 | } |
| 714 | vty_show_ip_route (vty, rn, rib); |
| 715 | } |
| 716 | } |
| 717 | return CMD_SUCCESS; |
| 718 | } |
| 719 | |
| 720 | DEFUN (show_ip_route_protocol, |
| 721 | show_ip_route_protocol_cmd, |
| 722 | "show ip route (bgp|connected|kernel|ospf|rip|static)", |
| 723 | SHOW_STR |
| 724 | IP_STR |
| 725 | "IP routing table\n" |
| 726 | "Border Gateway Protocol (BGP)\n" |
| 727 | "Connected\n" |
| 728 | "Kernel\n" |
| 729 | "Open Shortest Path First (OSPF)\n" |
| 730 | "Routing Information Protocol (RIP)\n" |
| 731 | "Static routes\n") |
| 732 | { |
| 733 | int type; |
| 734 | struct route_table *table; |
| 735 | struct route_node *rn; |
| 736 | struct rib *rib; |
| 737 | int first = 1; |
| 738 | |
| 739 | if (strncmp (argv[0], "b", 1) == 0) |
| 740 | type = ZEBRA_ROUTE_BGP; |
| 741 | else if (strncmp (argv[0], "c", 1) == 0) |
| 742 | type = ZEBRA_ROUTE_CONNECT; |
| 743 | else if (strncmp (argv[0], "k", 1) ==0) |
| 744 | type = ZEBRA_ROUTE_KERNEL; |
| 745 | else if (strncmp (argv[0], "o", 1) == 0) |
| 746 | type = ZEBRA_ROUTE_OSPF; |
| 747 | else if (strncmp (argv[0], "r", 1) == 0) |
| 748 | type = ZEBRA_ROUTE_RIP; |
| 749 | else if (strncmp (argv[0], "s", 1) == 0) |
| 750 | type = ZEBRA_ROUTE_STATIC; |
| 751 | else |
| 752 | { |
| 753 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 754 | return CMD_WARNING; |
| 755 | } |
| 756 | |
| 757 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 758 | if (! table) |
| 759 | return CMD_SUCCESS; |
| 760 | |
| 761 | /* Show matched type IPv4 routes. */ |
| 762 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 763 | for (rib = rn->info; rib; rib = rib->next) |
| 764 | if (rib->type == type) |
| 765 | { |
| 766 | if (first) |
| 767 | { |
| 768 | vty_out (vty, SHOW_ROUTE_V4_HEADER, |
| 769 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 770 | first = 0; |
| 771 | } |
| 772 | vty_show_ip_route (vty, rn, rib); |
| 773 | } |
| 774 | return CMD_SUCCESS; |
| 775 | } |
| 776 | |
| 777 | DEFUN (show_ip_route_addr, |
| 778 | show_ip_route_addr_cmd, |
| 779 | "show ip route A.B.C.D", |
| 780 | SHOW_STR |
| 781 | IP_STR |
| 782 | "IP routing table\n" |
| 783 | "Network in the IP routing table to display\n") |
| 784 | { |
| 785 | int ret; |
| 786 | struct prefix_ipv4 p; |
| 787 | struct route_table *table; |
| 788 | struct route_node *rn; |
| 789 | |
| 790 | ret = str2prefix_ipv4 (argv[0], &p); |
| 791 | if (ret <= 0) |
| 792 | { |
| 793 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 794 | return CMD_WARNING; |
| 795 | } |
| 796 | |
| 797 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 798 | if (! table) |
| 799 | return CMD_SUCCESS; |
| 800 | |
| 801 | rn = route_node_match (table, (struct prefix *) &p); |
| 802 | if (! rn) |
| 803 | { |
| 804 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 805 | return CMD_WARNING; |
| 806 | } |
| 807 | |
| 808 | vty_show_ip_route_detail (vty, rn); |
| 809 | |
| 810 | route_unlock_node (rn); |
| 811 | |
| 812 | return CMD_SUCCESS; |
| 813 | } |
| 814 | |
| 815 | DEFUN (show_ip_route_prefix, |
| 816 | show_ip_route_prefix_cmd, |
| 817 | "show ip route A.B.C.D/M", |
| 818 | SHOW_STR |
| 819 | IP_STR |
| 820 | "IP routing table\n" |
| 821 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") |
| 822 | { |
| 823 | int ret; |
| 824 | struct prefix_ipv4 p; |
| 825 | struct route_table *table; |
| 826 | struct route_node *rn; |
| 827 | |
| 828 | ret = str2prefix_ipv4 (argv[0], &p); |
| 829 | if (ret <= 0) |
| 830 | { |
| 831 | vty_out (vty, "%% Malformed IPv4 address%s", VTY_NEWLINE); |
| 832 | return CMD_WARNING; |
| 833 | } |
| 834 | |
| 835 | table = vrf_table (AFI_IP, SAFI_UNICAST, 0); |
| 836 | if (! table) |
| 837 | return CMD_SUCCESS; |
| 838 | |
| 839 | rn = route_node_match (table, (struct prefix *) &p); |
| 840 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 841 | { |
| 842 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 843 | return CMD_WARNING; |
| 844 | } |
| 845 | |
| 846 | vty_show_ip_route_detail (vty, rn); |
| 847 | |
| 848 | route_unlock_node (rn); |
| 849 | |
| 850 | return CMD_SUCCESS; |
| 851 | } |
| 852 | |
| 853 | void |
| 854 | zebra_show_ip_route (struct vty *vty, struct vrf *vrf) |
| 855 | { |
| 856 | vty_out (vty, "IP routing table name is %s(%d)%s", |
| 857 | vrf->name ? vrf->name : "", vrf->id, VTY_NEWLINE); |
| 858 | |
| 859 | vty_out (vty, "Route Source Networks%s", VTY_NEWLINE); |
| 860 | vty_out (vty, "connected %d%s", 0, VTY_NEWLINE); |
| 861 | vty_out (vty, "static %d%s", 0, VTY_NEWLINE); |
| 862 | vty_out (vty, "rip %d%s", 0, VTY_NEWLINE); |
| 863 | |
| 864 | vty_out (vty, "bgp %d%s", 0, VTY_NEWLINE); |
| 865 | vty_out (vty, " External: %d Internal: %d Local: %d%s", |
| 866 | 0, 0, 0, VTY_NEWLINE); |
| 867 | |
| 868 | vty_out (vty, "ospf %d%s", 0, VTY_NEWLINE); |
| 869 | vty_out (vty, |
| 870 | " Intra-area: %d Inter-area: %d External-1: %d External-2: %d%s", |
| 871 | 0, 0, 0, 0, VTY_NEWLINE); |
| 872 | vty_out (vty, " NSSA External-1: %d NSSA External-2: %d%s", |
| 873 | 0, 0, VTY_NEWLINE); |
| 874 | |
| 875 | vty_out (vty, "internal %d%s", 0, VTY_NEWLINE); |
| 876 | vty_out (vty, "Total %d%s", 0, VTY_NEWLINE); |
| 877 | } |
| 878 | |
| 879 | /* Show route summary. */ |
| 880 | DEFUN (show_ip_route_summary, |
| 881 | show_ip_route_summary_cmd, |
| 882 | "show ip route summary", |
| 883 | SHOW_STR |
| 884 | IP_STR |
| 885 | "IP routing table\n" |
| 886 | "Summary of all routes\n") |
| 887 | { |
| 888 | struct vrf *vrf; |
| 889 | |
| 890 | /* Default table id is zero. */ |
| 891 | vrf = vrf_lookup (0); |
| 892 | if (! vrf) |
| 893 | { |
| 894 | vty_out (vty, "%% No Default-IP-Routing-Table%s", VTY_NEWLINE); |
| 895 | return CMD_WARNING; |
| 896 | } |
| 897 | |
| 898 | zebra_show_ip_route (vty, vrf); |
| 899 | |
| 900 | return CMD_SUCCESS; |
| 901 | } |
| 902 | |
| 903 | /* Write IPv4 static route configuration. */ |
| 904 | int |
| 905 | static_config_ipv4 (struct vty *vty) |
| 906 | { |
| 907 | struct route_node *rn; |
| 908 | struct static_ipv4 *si; |
| 909 | struct route_table *stable; |
| 910 | int write; |
| 911 | |
| 912 | write = 0; |
| 913 | |
| 914 | /* Lookup table. */ |
| 915 | stable = vrf_static_table (AFI_IP, SAFI_UNICAST, 0); |
| 916 | if (! stable) |
| 917 | return -1; |
| 918 | |
| 919 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 920 | for (si = rn->info; si; si = si->next) |
| 921 | { |
| 922 | vty_out (vty, "ip route %s/%d", inet_ntoa (rn->p.u.prefix4), |
| 923 | rn->p.prefixlen); |
| 924 | |
| 925 | switch (si->type) |
| 926 | { |
| 927 | case STATIC_IPV4_GATEWAY: |
| 928 | vty_out (vty, " %s", inet_ntoa (si->gate.ipv4)); |
| 929 | break; |
| 930 | case STATIC_IPV4_IFNAME: |
| 931 | vty_out (vty, " %s", si->gate.ifname); |
| 932 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 933 | } |
| 934 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 935 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 936 | vty_out (vty, " %s", "reject"); |
| 937 | |
| 938 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 939 | vty_out (vty, " %s", "blackhole"); |
| 940 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 941 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 942 | vty_out (vty, " %d", si->distance); |
| 943 | vty_out (vty, "%s", VTY_NEWLINE); |
| 944 | |
| 945 | write = 1; |
| 946 | } |
| 947 | return write; |
| 948 | } |
| 949 | |
| 950 | #ifdef HAVE_IPV6 |
| 951 | /* General fucntion for IPv6 static route. */ |
| 952 | int |
| 953 | static_ipv6_func (struct vty *vty, int add_cmd, char *dest_str, |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 954 | char *gate_str, char *ifname, char *flag_str, char *distance_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 955 | { |
| 956 | int ret; |
| 957 | u_char distance; |
| 958 | struct prefix p; |
| 959 | struct in6_addr *gate = NULL; |
| 960 | struct in6_addr gate_addr; |
| 961 | u_char type = 0; |
| 962 | int table = 0; |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 963 | u_char flag = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 964 | |
| 965 | ret = str2prefix (dest_str, &p); |
| 966 | if (ret <= 0) |
| 967 | { |
| 968 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 969 | return CMD_WARNING; |
| 970 | } |
| 971 | |
| 972 | /* Apply mask for given prefix. */ |
| 973 | apply_mask (&p); |
| 974 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 975 | /* Route flags */ |
| 976 | if (flag_str) { |
| 977 | switch(flag_str[0]) { |
| 978 | case 'r': |
| 979 | case 'R': /* XXX */ |
| 980 | SET_FLAG (flag, ZEBRA_FLAG_REJECT); |
| 981 | break; |
| 982 | case 'b': |
| 983 | case 'B': /* XXX */ |
| 984 | SET_FLAG (flag, ZEBRA_FLAG_BLACKHOLE); |
| 985 | break; |
| 986 | default: |
| 987 | vty_out (vty, "%% Malformed flag %s %s", flag_str, VTY_NEWLINE); |
| 988 | break; |
| 989 | } |
| 990 | } |
| 991 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 992 | /* Administrative distance. */ |
| 993 | if (distance_str) |
| 994 | distance = atoi (distance_str); |
| 995 | else |
| 996 | distance = ZEBRA_STATIC_DISTANCE_DEFAULT; |
| 997 | |
| 998 | /* When gateway is valid IPv6 addrees, then gate is treated as |
| 999 | nexthop address other case gate is treated as interface name. */ |
| 1000 | ret = inet_pton (AF_INET6, gate_str, &gate_addr); |
| 1001 | |
| 1002 | if (ifname) |
| 1003 | { |
| 1004 | /* When ifname is specified. It must be come with gateway |
| 1005 | address. */ |
| 1006 | if (ret != 1) |
| 1007 | { |
| 1008 | vty_out (vty, "%% Malformed address%s", VTY_NEWLINE); |
| 1009 | return CMD_WARNING; |
| 1010 | } |
| 1011 | type = STATIC_IPV6_GATEWAY_IFNAME; |
| 1012 | gate = &gate_addr; |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | if (ret == 1) |
| 1017 | { |
| 1018 | type = STATIC_IPV6_GATEWAY; |
| 1019 | gate = &gate_addr; |
| 1020 | } |
| 1021 | else |
| 1022 | { |
| 1023 | type = STATIC_IPV6_IFNAME; |
| 1024 | ifname = gate_str; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | if (add_cmd) |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1029 | static_add_ipv6 (&p, type, gate, ifname, flag, distance, table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1030 | else |
| 1031 | static_delete_ipv6 (&p, type, gate, ifname, distance, table); |
| 1032 | |
| 1033 | return CMD_SUCCESS; |
| 1034 | } |
| 1035 | |
| 1036 | DEFUN (ipv6_route, |
| 1037 | ipv6_route_cmd, |
| 1038 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1039 | IP_STR |
| 1040 | "Establish static routes\n" |
| 1041 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1042 | "IPv6 gateway address\n" |
| 1043 | "IPv6 gateway interface name\n") |
| 1044 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1045 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL); |
| 1046 | } |
| 1047 | |
| 1048 | DEFUN (ipv6_route_flags, |
| 1049 | ipv6_route_flags_cmd, |
| 1050 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1051 | IP_STR |
| 1052 | "Establish static routes\n" |
| 1053 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1054 | "IPv6 gateway address\n" |
| 1055 | "IPv6 gateway interface name\n" |
| 1056 | "Emit an ICMP unreachable when matched\n" |
| 1057 | "Silently discard pkts when matched\n") |
| 1058 | { |
| 1059 | 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] | 1060 | } |
| 1061 | |
| 1062 | DEFUN (ipv6_route_ifname, |
| 1063 | ipv6_route_ifname_cmd, |
| 1064 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1065 | IP_STR |
| 1066 | "Establish static routes\n" |
| 1067 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1068 | "IPv6 gateway address\n" |
| 1069 | "IPv6 gateway interface name\n") |
| 1070 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1071 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL); |
| 1072 | } |
| 1073 | |
| 1074 | DEFUN (ipv6_route_ifname_flags, |
| 1075 | ipv6_route_ifname_flags_cmd, |
| 1076 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1077 | IP_STR |
| 1078 | "Establish static routes\n" |
| 1079 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1080 | "IPv6 gateway address\n" |
| 1081 | "IPv6 gateway interface name\n" |
| 1082 | "Emit an ICMP unreachable when matched\n" |
| 1083 | "Silently discard pkts when matched\n") |
| 1084 | { |
| 1085 | 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] | 1086 | } |
| 1087 | |
| 1088 | DEFUN (ipv6_route_pref, |
| 1089 | ipv6_route_pref_cmd, |
| 1090 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1091 | IP_STR |
| 1092 | "Establish static routes\n" |
| 1093 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1094 | "IPv6 gateway address\n" |
| 1095 | "IPv6 gateway interface name\n" |
| 1096 | "Distance value for this prefix\n") |
| 1097 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1098 | return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1099 | } |
| 1100 | |
| 1101 | DEFUN (ipv6_route_flags_pref, |
| 1102 | ipv6_route_flags_pref_cmd, |
| 1103 | "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1104 | IP_STR |
| 1105 | "Establish static routes\n" |
| 1106 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1107 | "IPv6 gateway address\n" |
| 1108 | "IPv6 gateway interface name\n" |
| 1109 | "Emit an ICMP unreachable when matched\n" |
| 1110 | "Silently discard pkts when matched\n" |
| 1111 | "Distance value for this prefix\n") |
| 1112 | { |
| 1113 | 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] | 1114 | } |
| 1115 | |
| 1116 | DEFUN (ipv6_route_ifname_pref, |
| 1117 | ipv6_route_ifname_pref_cmd, |
| 1118 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1119 | IP_STR |
| 1120 | "Establish static routes\n" |
| 1121 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1122 | "IPv6 gateway address\n" |
| 1123 | "IPv6 gateway interface name\n" |
| 1124 | "Distance value for this prefix\n") |
| 1125 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1126 | return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1127 | } |
| 1128 | |
| 1129 | DEFUN (ipv6_route_ifname_flags_pref, |
| 1130 | ipv6_route_ifname_flags_pref_cmd, |
| 1131 | "ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1132 | IP_STR |
| 1133 | "Establish static routes\n" |
| 1134 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1135 | "IPv6 gateway address\n" |
| 1136 | "IPv6 gateway interface name\n" |
| 1137 | "Emit an ICMP unreachable when matched\n" |
| 1138 | "Silently discard pkts when matched\n" |
| 1139 | "Distance value for this prefix\n") |
| 1140 | { |
| 1141 | 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] | 1142 | } |
| 1143 | |
| 1144 | DEFUN (no_ipv6_route, |
| 1145 | no_ipv6_route_cmd, |
| 1146 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE)", |
| 1147 | NO_STR |
| 1148 | IP_STR |
| 1149 | "Establish static routes\n" |
| 1150 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1151 | "IPv6 gateway address\n" |
| 1152 | "IPv6 gateway interface name\n") |
| 1153 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1154 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1155 | } |
| 1156 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1157 | ALIAS (no_ipv6_route, |
| 1158 | no_ipv6_route_flags_cmd, |
| 1159 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole)", |
| 1160 | NO_STR |
| 1161 | IP_STR |
| 1162 | "Establish static routes\n" |
| 1163 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1164 | "IPv6 gateway address\n" |
| 1165 | "IPv6 gateway interface name\n" |
| 1166 | "Emit an ICMP unreachable when matched\n" |
| 1167 | "Silently discard pkts when matched\n") |
| 1168 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1169 | DEFUN (no_ipv6_route_ifname, |
| 1170 | no_ipv6_route_ifname_cmd, |
| 1171 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE", |
| 1172 | NO_STR |
| 1173 | IP_STR |
| 1174 | "Establish static routes\n" |
| 1175 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1176 | "IPv6 gateway address\n" |
| 1177 | "IPv6 gateway interface name\n") |
| 1178 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1179 | 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] | 1180 | } |
| 1181 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1182 | ALIAS (no_ipv6_route_ifname, |
| 1183 | no_ipv6_route_ifname_flags_cmd, |
| 1184 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole)", |
| 1185 | NO_STR |
| 1186 | IP_STR |
| 1187 | "Establish static routes\n" |
| 1188 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1189 | "IPv6 gateway address\n" |
| 1190 | "IPv6 gateway interface name\n" |
| 1191 | "Emit an ICMP unreachable when matched\n" |
| 1192 | "Silently discard pkts when matched\n") |
| 1193 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1194 | DEFUN (no_ipv6_route_pref, |
| 1195 | no_ipv6_route_pref_cmd, |
| 1196 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255>", |
| 1197 | NO_STR |
| 1198 | IP_STR |
| 1199 | "Establish static routes\n" |
| 1200 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1201 | "IPv6 gateway address\n" |
| 1202 | "IPv6 gateway interface name\n" |
| 1203 | "Distance value for this prefix\n") |
| 1204 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1205 | return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2]); |
| 1206 | } |
| 1207 | |
| 1208 | DEFUN (no_ipv6_route_flags_pref, |
| 1209 | no_ipv6_route_flags_pref_cmd, |
| 1210 | "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) (reject|blackhole) <1-255>", |
| 1211 | NO_STR |
| 1212 | IP_STR |
| 1213 | "Establish static routes\n" |
| 1214 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1215 | "IPv6 gateway address\n" |
| 1216 | "IPv6 gateway interface name\n" |
| 1217 | "Emit an ICMP unreachable when matched\n" |
| 1218 | "Silently discard pkts when matched\n" |
| 1219 | "Distance value for this prefix\n") |
| 1220 | { |
| 1221 | /* We do not care about argv[2] */ |
| 1222 | 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] | 1223 | } |
| 1224 | |
| 1225 | DEFUN (no_ipv6_route_ifname_pref, |
| 1226 | no_ipv6_route_ifname_pref_cmd, |
| 1227 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255>", |
| 1228 | NO_STR |
| 1229 | IP_STR |
| 1230 | "Establish static routes\n" |
| 1231 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1232 | "IPv6 gateway address\n" |
| 1233 | "IPv6 gateway interface name\n" |
| 1234 | "Distance value for this prefix\n") |
| 1235 | { |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1236 | return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3]); |
| 1237 | } |
| 1238 | |
| 1239 | DEFUN (no_ipv6_route_ifname_flags_pref, |
| 1240 | no_ipv6_route_ifname_flags_pref_cmd, |
| 1241 | "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE (reject|blackhole) <1-255>", |
| 1242 | NO_STR |
| 1243 | IP_STR |
| 1244 | "Establish static routes\n" |
| 1245 | "IPv6 destination prefix (e.g. 3ffe:506::/32)\n" |
| 1246 | "IPv6 gateway address\n" |
| 1247 | "IPv6 gateway interface name\n" |
| 1248 | "Emit an ICMP unreachable when matched\n" |
| 1249 | "Silently discard pkts when matched\n" |
| 1250 | "Distance value for this prefix\n") |
| 1251 | { |
| 1252 | 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] | 1253 | } |
| 1254 | |
| 1255 | /* New RIB. Detailed information for IPv4 route. */ |
| 1256 | void |
| 1257 | vty_show_ipv6_route_detail (struct vty *vty, struct route_node *rn) |
| 1258 | { |
| 1259 | struct rib *rib; |
| 1260 | struct nexthop *nexthop; |
| 1261 | char buf[BUFSIZ]; |
| 1262 | |
| 1263 | for (rib = rn->info; rib; rib = rib->next) |
| 1264 | { |
| 1265 | vty_out (vty, "Routing entry for %s/%d%s", |
| 1266 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 1267 | rn->p.prefixlen, |
| 1268 | VTY_NEWLINE); |
| 1269 | vty_out (vty, " Known via \"%s\"", route_type_str (rib->type)); |
| 1270 | vty_out (vty, ", distance %d, metric %d", rib->distance, rib->metric); |
| 1271 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) |
| 1272 | vty_out (vty, ", best"); |
| 1273 | if (rib->refcnt) |
| 1274 | vty_out (vty, ", refcnt %ld", rib->refcnt); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1275 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1276 | vty_out (vty, ", blackhole"); |
| 1277 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1278 | vty_out (vty, ", reject"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1279 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1280 | |
| 1281 | #define ONE_DAY_SECOND 60*60*24 |
| 1282 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1283 | if (rib->type == ZEBRA_ROUTE_RIPNG |
| 1284 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 1285 | || rib->type == ZEBRA_ROUTE_BGP) |
| 1286 | { |
| 1287 | time_t uptime; |
| 1288 | struct tm *tm; |
| 1289 | |
| 1290 | uptime = time (NULL); |
| 1291 | uptime -= rib->uptime; |
| 1292 | tm = gmtime (&uptime); |
| 1293 | |
| 1294 | vty_out (vty, " Last update "); |
| 1295 | |
| 1296 | if (uptime < ONE_DAY_SECOND) |
| 1297 | vty_out (vty, "%02d:%02d:%02d", |
| 1298 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1299 | else if (uptime < ONE_WEEK_SECOND) |
| 1300 | vty_out (vty, "%dd%02dh%02dm", |
| 1301 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1302 | else |
| 1303 | vty_out (vty, "%02dw%dd%02dh", |
| 1304 | tm->tm_yday/7, |
| 1305 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1306 | vty_out (vty, " ago%s", VTY_NEWLINE); |
| 1307 | } |
| 1308 | |
| 1309 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 1310 | { |
| 1311 | vty_out (vty, " %c", |
| 1312 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) ? '*' : ' '); |
| 1313 | |
| 1314 | switch (nexthop->type) |
| 1315 | { |
| 1316 | case NEXTHOP_TYPE_IPV6: |
| 1317 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1318 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1319 | vty_out (vty, " %s", |
| 1320 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 1321 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1322 | vty_out (vty, ", %s", nexthop->ifname); |
| 1323 | else if (nexthop->ifindex) |
| 1324 | vty_out (vty, ", via %s", ifindex2ifname (nexthop->ifindex)); |
| 1325 | break; |
| 1326 | case NEXTHOP_TYPE_IFINDEX: |
| 1327 | vty_out (vty, " directly connected, %s", |
| 1328 | ifindex2ifname (nexthop->ifindex)); |
| 1329 | break; |
| 1330 | case NEXTHOP_TYPE_IFNAME: |
| 1331 | vty_out (vty, " directly connected, %s", |
| 1332 | nexthop->ifname); |
| 1333 | break; |
| 1334 | default: |
| 1335 | break; |
| 1336 | } |
| 1337 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 1338 | vty_out (vty, " inactive"); |
| 1339 | |
| 1340 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 1341 | { |
| 1342 | vty_out (vty, " (recursive"); |
| 1343 | |
| 1344 | switch (nexthop->rtype) |
| 1345 | { |
| 1346 | case NEXTHOP_TYPE_IPV6: |
| 1347 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1348 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1349 | vty_out (vty, " via %s)", |
| 1350 | inet_ntop (AF_INET6, &nexthop->rgate.ipv6, |
| 1351 | buf, BUFSIZ)); |
| 1352 | if (nexthop->rifindex) |
| 1353 | vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex)); |
| 1354 | break; |
| 1355 | case NEXTHOP_TYPE_IFINDEX: |
| 1356 | case NEXTHOP_TYPE_IFNAME: |
| 1357 | vty_out (vty, " is directly connected, %s)", |
| 1358 | ifindex2ifname (nexthop->rifindex)); |
| 1359 | break; |
| 1360 | default: |
| 1361 | break; |
| 1362 | } |
| 1363 | } |
| 1364 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1365 | } |
| 1366 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1367 | } |
| 1368 | } |
| 1369 | |
| 1370 | void |
| 1371 | vty_show_ipv6_route (struct vty *vty, struct route_node *rn, |
| 1372 | struct rib *rib) |
| 1373 | { |
| 1374 | struct nexthop *nexthop; |
| 1375 | int len = 0; |
| 1376 | char buf[BUFSIZ]; |
| 1377 | |
| 1378 | /* Nexthop information. */ |
| 1379 | for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) |
| 1380 | { |
| 1381 | if (nexthop == rib->nexthop) |
| 1382 | { |
| 1383 | /* Prefix information. */ |
| 1384 | len = vty_out (vty, "%c%c%c %s/%d", |
| 1385 | route_type_char (rib->type), |
| 1386 | CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED) |
| 1387 | ? '>' : ' ', |
| 1388 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1389 | ? '*' : ' ', |
| 1390 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 1391 | rn->p.prefixlen); |
| 1392 | |
| 1393 | /* Distance and metric display. */ |
| 1394 | if (rib->type != ZEBRA_ROUTE_CONNECT |
| 1395 | && rib->type != ZEBRA_ROUTE_KERNEL) |
| 1396 | len += vty_out (vty, " [%d/%d]", rib->distance, |
| 1397 | rib->metric); |
| 1398 | } |
| 1399 | else |
| 1400 | vty_out (vty, " %c%*c", |
| 1401 | CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB) |
| 1402 | ? '*' : ' ', |
| 1403 | len - 3, ' '); |
| 1404 | |
| 1405 | switch (nexthop->type) |
| 1406 | { |
| 1407 | case NEXTHOP_TYPE_IPV6: |
| 1408 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1409 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1410 | vty_out (vty, " via %s", |
| 1411 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, buf, BUFSIZ)); |
| 1412 | if (nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME) |
| 1413 | vty_out (vty, ", %s", nexthop->ifname); |
| 1414 | else if (nexthop->ifindex) |
| 1415 | vty_out (vty, ", %s", ifindex2ifname (nexthop->ifindex)); |
| 1416 | break; |
| 1417 | case NEXTHOP_TYPE_IFINDEX: |
| 1418 | vty_out (vty, " is directly connected, %s", |
| 1419 | ifindex2ifname (nexthop->ifindex)); |
| 1420 | break; |
| 1421 | case NEXTHOP_TYPE_IFNAME: |
| 1422 | vty_out (vty, " is directly connected, %s", |
| 1423 | nexthop->ifname); |
| 1424 | break; |
| 1425 | default: |
| 1426 | break; |
| 1427 | } |
| 1428 | if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE)) |
| 1429 | vty_out (vty, " inactive"); |
| 1430 | |
| 1431 | if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE)) |
| 1432 | { |
| 1433 | vty_out (vty, " (recursive"); |
| 1434 | |
| 1435 | switch (nexthop->rtype) |
| 1436 | { |
| 1437 | case NEXTHOP_TYPE_IPV6: |
| 1438 | case NEXTHOP_TYPE_IPV6_IFINDEX: |
| 1439 | case NEXTHOP_TYPE_IPV6_IFNAME: |
| 1440 | vty_out (vty, " via %s)", |
| 1441 | inet_ntop (AF_INET6, &nexthop->rgate.ipv6, |
| 1442 | buf, BUFSIZ)); |
| 1443 | if (nexthop->rifindex) |
| 1444 | vty_out (vty, ", %s", ifindex2ifname (nexthop->rifindex)); |
| 1445 | break; |
| 1446 | case NEXTHOP_TYPE_IFINDEX: |
| 1447 | case NEXTHOP_TYPE_IFNAME: |
| 1448 | vty_out (vty, " is directly connected, %s)", |
| 1449 | ifindex2ifname (nexthop->rifindex)); |
| 1450 | break; |
| 1451 | default: |
| 1452 | break; |
| 1453 | } |
| 1454 | } |
| 1455 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1456 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1457 | vty_out (vty, ", bh"); |
| 1458 | if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_REJECT)) |
| 1459 | vty_out (vty, ", rej"); |
| 1460 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1461 | if (rib->type == ZEBRA_ROUTE_RIPNG |
| 1462 | || rib->type == ZEBRA_ROUTE_OSPF6 |
| 1463 | || rib->type == ZEBRA_ROUTE_BGP) |
| 1464 | { |
| 1465 | time_t uptime; |
| 1466 | struct tm *tm; |
| 1467 | |
| 1468 | uptime = time (NULL); |
| 1469 | uptime -= rib->uptime; |
| 1470 | tm = gmtime (&uptime); |
| 1471 | |
| 1472 | #define ONE_DAY_SECOND 60*60*24 |
| 1473 | #define ONE_WEEK_SECOND 60*60*24*7 |
| 1474 | |
| 1475 | if (uptime < ONE_DAY_SECOND) |
| 1476 | vty_out (vty, ", %02d:%02d:%02d", |
| 1477 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 1478 | else if (uptime < ONE_WEEK_SECOND) |
| 1479 | vty_out (vty, ", %dd%02dh%02dm", |
| 1480 | tm->tm_yday, tm->tm_hour, tm->tm_min); |
| 1481 | else |
| 1482 | vty_out (vty, ", %02dw%dd%02dh", |
| 1483 | tm->tm_yday/7, |
| 1484 | tm->tm_yday - ((tm->tm_yday/7) * 7), tm->tm_hour); |
| 1485 | } |
| 1486 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | #define SHOW_ROUTE_V6_HEADER "Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3,%s B - BGP, * - FIB route.%s%s" |
| 1491 | |
| 1492 | DEFUN (show_ipv6_route, |
| 1493 | show_ipv6_route_cmd, |
| 1494 | "show ipv6 route", |
| 1495 | SHOW_STR |
| 1496 | IP_STR |
| 1497 | "IPv6 routing table\n") |
| 1498 | { |
| 1499 | struct route_table *table; |
| 1500 | struct route_node *rn; |
| 1501 | struct rib *rib; |
| 1502 | int first = 1; |
| 1503 | |
| 1504 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1505 | if (! table) |
| 1506 | return CMD_SUCCESS; |
| 1507 | |
| 1508 | /* Show all IPv6 route. */ |
| 1509 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1510 | for (rib = rn->info; rib; rib = rib->next) |
| 1511 | { |
| 1512 | if (first) |
| 1513 | { |
| 1514 | vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 1515 | first = 0; |
| 1516 | } |
| 1517 | vty_show_ipv6_route (vty, rn, rib); |
| 1518 | } |
| 1519 | return CMD_SUCCESS; |
| 1520 | } |
| 1521 | |
| 1522 | DEFUN (show_ipv6_route_prefix_longer, |
| 1523 | show_ipv6_route_prefix_longer_cmd, |
| 1524 | "show ipv6 route X:X::X:X/M longer-prefixes", |
| 1525 | SHOW_STR |
| 1526 | IP_STR |
| 1527 | "IPv6 routing table\n" |
| 1528 | "IPv6 prefix\n" |
| 1529 | "Show route matching the specified Network/Mask pair only\n") |
| 1530 | { |
| 1531 | struct route_table *table; |
| 1532 | struct route_node *rn; |
| 1533 | struct rib *rib; |
| 1534 | struct prefix p; |
| 1535 | int ret; |
| 1536 | int first = 1; |
| 1537 | |
| 1538 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1539 | if (! table) |
| 1540 | return CMD_SUCCESS; |
| 1541 | |
| 1542 | ret = str2prefix (argv[0], &p); |
| 1543 | if (! ret) |
| 1544 | { |
| 1545 | vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE); |
| 1546 | return CMD_WARNING; |
| 1547 | } |
| 1548 | |
| 1549 | /* Show matched type IPv6 routes. */ |
| 1550 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1551 | for (rib = rn->info; rib; rib = rib->next) |
| 1552 | if (prefix_match (&p, &rn->p)) |
| 1553 | { |
| 1554 | if (first) |
| 1555 | { |
| 1556 | vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 1557 | first = 0; |
| 1558 | } |
| 1559 | vty_show_ipv6_route (vty, rn, rib); |
| 1560 | } |
| 1561 | return CMD_SUCCESS; |
| 1562 | } |
| 1563 | |
| 1564 | DEFUN (show_ipv6_route_protocol, |
| 1565 | show_ipv6_route_protocol_cmd, |
| 1566 | "show ipv6 route (bgp|connected|kernel|ospf6|ripng|static)", |
| 1567 | SHOW_STR |
| 1568 | IP_STR |
| 1569 | "IP routing table\n" |
| 1570 | "Border Gateway Protocol (BGP)\n" |
| 1571 | "Connected\n" |
| 1572 | "Kernel\n" |
| 1573 | "Open Shortest Path First (OSPFv3)\n" |
| 1574 | "Routing Information Protocol (RIPng)\n" |
| 1575 | "Static routes\n") |
| 1576 | { |
| 1577 | int type; |
| 1578 | struct route_table *table; |
| 1579 | struct route_node *rn; |
| 1580 | struct rib *rib; |
| 1581 | int first = 1; |
| 1582 | |
| 1583 | if (strncmp (argv[0], "b", 1) == 0) |
| 1584 | type = ZEBRA_ROUTE_BGP; |
| 1585 | else if (strncmp (argv[0], "c", 1) == 0) |
| 1586 | type = ZEBRA_ROUTE_CONNECT; |
| 1587 | else if (strncmp (argv[0], "k", 1) ==0) |
| 1588 | type = ZEBRA_ROUTE_KERNEL; |
| 1589 | else if (strncmp (argv[0], "o", 1) == 0) |
| 1590 | type = ZEBRA_ROUTE_OSPF6; |
| 1591 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1592 | type = ZEBRA_ROUTE_RIPNG; |
| 1593 | else if (strncmp (argv[0], "s", 1) == 0) |
| 1594 | type = ZEBRA_ROUTE_STATIC; |
| 1595 | else |
| 1596 | { |
| 1597 | vty_out (vty, "Unknown route type%s", VTY_NEWLINE); |
| 1598 | return CMD_WARNING; |
| 1599 | } |
| 1600 | |
| 1601 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1602 | if (! table) |
| 1603 | return CMD_SUCCESS; |
| 1604 | |
| 1605 | /* Show matched type IPv6 routes. */ |
| 1606 | for (rn = route_top (table); rn; rn = route_next (rn)) |
| 1607 | for (rib = rn->info; rib; rib = rib->next) |
| 1608 | if (rib->type == type) |
| 1609 | { |
| 1610 | if (first) |
| 1611 | { |
| 1612 | vty_out (vty, SHOW_ROUTE_V6_HEADER, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); |
| 1613 | first = 0; |
| 1614 | } |
| 1615 | vty_show_ipv6_route (vty, rn, rib); |
| 1616 | } |
| 1617 | return CMD_SUCCESS; |
| 1618 | } |
| 1619 | |
| 1620 | DEFUN (show_ipv6_route_addr, |
| 1621 | show_ipv6_route_addr_cmd, |
| 1622 | "show ipv6 route X:X::X:X", |
| 1623 | SHOW_STR |
| 1624 | IP_STR |
| 1625 | "IPv6 routing table\n" |
| 1626 | "IPv6 Address\n") |
| 1627 | { |
| 1628 | int ret; |
| 1629 | struct prefix_ipv6 p; |
| 1630 | struct route_table *table; |
| 1631 | struct route_node *rn; |
| 1632 | |
| 1633 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1634 | if (ret <= 0) |
| 1635 | { |
| 1636 | vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE); |
| 1637 | return CMD_WARNING; |
| 1638 | } |
| 1639 | |
| 1640 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1641 | if (! table) |
| 1642 | return CMD_SUCCESS; |
| 1643 | |
| 1644 | rn = route_node_match (table, (struct prefix *) &p); |
| 1645 | if (! rn) |
| 1646 | { |
| 1647 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1648 | return CMD_WARNING; |
| 1649 | } |
| 1650 | |
| 1651 | vty_show_ipv6_route_detail (vty, rn); |
| 1652 | |
| 1653 | route_unlock_node (rn); |
| 1654 | |
| 1655 | return CMD_SUCCESS; |
| 1656 | } |
| 1657 | |
| 1658 | DEFUN (show_ipv6_route_prefix, |
| 1659 | show_ipv6_route_prefix_cmd, |
| 1660 | "show ipv6 route X:X::X:X/M", |
| 1661 | SHOW_STR |
| 1662 | IP_STR |
| 1663 | "IPv6 routing table\n" |
| 1664 | "IPv6 prefix\n") |
| 1665 | { |
| 1666 | int ret; |
| 1667 | struct prefix_ipv6 p; |
| 1668 | struct route_table *table; |
| 1669 | struct route_node *rn; |
| 1670 | |
| 1671 | ret = str2prefix_ipv6 (argv[0], &p); |
| 1672 | if (ret <= 0) |
| 1673 | { |
| 1674 | vty_out (vty, "Malformed IPv6 prefix%s", VTY_NEWLINE); |
| 1675 | return CMD_WARNING; |
| 1676 | } |
| 1677 | |
| 1678 | table = vrf_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1679 | if (! table) |
| 1680 | return CMD_SUCCESS; |
| 1681 | |
| 1682 | rn = route_node_match (table, (struct prefix *) &p); |
| 1683 | if (! rn || rn->p.prefixlen != p.prefixlen) |
| 1684 | { |
| 1685 | vty_out (vty, "%% Network not in table%s", VTY_NEWLINE); |
| 1686 | return CMD_WARNING; |
| 1687 | } |
| 1688 | |
| 1689 | vty_show_ipv6_route_detail (vty, rn); |
| 1690 | |
| 1691 | route_unlock_node (rn); |
| 1692 | |
| 1693 | return CMD_SUCCESS; |
| 1694 | } |
| 1695 | |
| 1696 | |
| 1697 | /* Write IPv6 static route configuration. */ |
| 1698 | int |
| 1699 | static_config_ipv6 (struct vty *vty) |
| 1700 | { |
| 1701 | struct route_node *rn; |
| 1702 | struct static_ipv6 *si; |
| 1703 | int write; |
| 1704 | char buf[BUFSIZ]; |
| 1705 | struct route_table *stable; |
| 1706 | |
| 1707 | write = 0; |
| 1708 | |
| 1709 | /* Lookup table. */ |
| 1710 | stable = vrf_static_table (AFI_IP6, SAFI_UNICAST, 0); |
| 1711 | if (! stable) |
| 1712 | return -1; |
| 1713 | |
| 1714 | for (rn = route_top (stable); rn; rn = route_next (rn)) |
| 1715 | for (si = rn->info; si; si = si->next) |
| 1716 | { |
| 1717 | vty_out (vty, "ipv6 route %s/%d", |
| 1718 | inet_ntop (AF_INET6, &rn->p.u.prefix6, buf, BUFSIZ), |
| 1719 | rn->p.prefixlen); |
| 1720 | |
| 1721 | switch (si->type) |
| 1722 | { |
| 1723 | case STATIC_IPV6_GATEWAY: |
| 1724 | vty_out (vty, " %s", inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ)); |
| 1725 | break; |
| 1726 | case STATIC_IPV6_IFNAME: |
| 1727 | vty_out (vty, " %s", si->ifname); |
| 1728 | break; |
| 1729 | case STATIC_IPV6_GATEWAY_IFNAME: |
| 1730 | vty_out (vty, " %s %s", |
| 1731 | inet_ntop (AF_INET6, &si->ipv6, buf, BUFSIZ), si->ifname); |
| 1732 | break; |
| 1733 | } |
| 1734 | |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1735 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_REJECT)) |
| 1736 | vty_out (vty, " %s", "reject"); |
| 1737 | |
| 1738 | if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) |
| 1739 | vty_out (vty, " %s", "blackhole"); |
| 1740 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1741 | if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) |
| 1742 | vty_out (vty, " %d", si->distance); |
| 1743 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1744 | |
| 1745 | write = 1; |
| 1746 | } |
| 1747 | return write; |
| 1748 | } |
| 1749 | #endif /* HAVE_IPV6 */ |
| 1750 | |
| 1751 | /* Static ip route configuration write function. */ |
| 1752 | int |
| 1753 | zebra_ip_config (struct vty *vty) |
| 1754 | { |
| 1755 | int write = 0; |
| 1756 | |
| 1757 | write += static_config_ipv4 (vty); |
| 1758 | #ifdef HAVE_IPV6 |
| 1759 | write += static_config_ipv6 (vty); |
| 1760 | #endif /* HAVE_IPV6 */ |
| 1761 | |
| 1762 | return write; |
| 1763 | } |
| 1764 | |
| 1765 | /* IP node for static routes. */ |
| 1766 | struct cmd_node ip_node = { IP_NODE, "", 1 }; |
| 1767 | |
| 1768 | /* Route VTY. */ |
| 1769 | void |
| 1770 | zebra_vty_route_init () |
| 1771 | { |
| 1772 | install_node (&ip_node, zebra_ip_config); |
| 1773 | |
| 1774 | install_element (CONFIG_NODE, &ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1775 | install_element (CONFIG_NODE, &ip_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1776 | install_element (CONFIG_NODE, &ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1777 | install_element (CONFIG_NODE, &ip_route_mask_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1778 | install_element (CONFIG_NODE, &no_ip_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1779 | install_element (CONFIG_NODE, &no_ip_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1780 | install_element (CONFIG_NODE, &no_ip_route_mask_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1781 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1782 | install_element (CONFIG_NODE, &ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1783 | install_element (CONFIG_NODE, &ip_route_flags_distance_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1784 | install_element (CONFIG_NODE, &ip_route_mask_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1785 | install_element (CONFIG_NODE, &ip_route_mask_flags_distance_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1786 | install_element (CONFIG_NODE, &no_ip_route_distance_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1787 | install_element (CONFIG_NODE, &no_ip_route_flags_distance_cmd); |
| 1788 | install_element (CONFIG_NODE, &no_ip_route_mask_flags_distance_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1789 | |
| 1790 | install_element (VIEW_NODE, &show_ip_route_cmd); |
| 1791 | install_element (VIEW_NODE, &show_ip_route_addr_cmd); |
| 1792 | install_element (VIEW_NODE, &show_ip_route_prefix_cmd); |
| 1793 | install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd); |
| 1794 | install_element (VIEW_NODE, &show_ip_route_protocol_cmd); |
| 1795 | install_element (VIEW_NODE, &show_ip_route_supernets_cmd); |
| 1796 | install_element (ENABLE_NODE, &show_ip_route_cmd); |
| 1797 | install_element (ENABLE_NODE, &show_ip_route_addr_cmd); |
| 1798 | install_element (ENABLE_NODE, &show_ip_route_prefix_cmd); |
| 1799 | install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd); |
| 1800 | install_element (ENABLE_NODE, &show_ip_route_protocol_cmd); |
| 1801 | install_element (ENABLE_NODE, &show_ip_route_supernets_cmd); |
| 1802 | |
| 1803 | #if 0 |
| 1804 | install_element (VIEW_NODE, &show_ip_route_summary_cmd); |
| 1805 | install_element (ENABLE_NODE, &show_ip_route_summary_cmd); |
| 1806 | #endif /* 0 */ |
| 1807 | |
| 1808 | #ifdef HAVE_IPV6 |
| 1809 | install_element (CONFIG_NODE, &ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1810 | install_element (CONFIG_NODE, &ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1811 | install_element (CONFIG_NODE, &ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1812 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1813 | install_element (CONFIG_NODE, &no_ipv6_route_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1814 | install_element (CONFIG_NODE, &no_ipv6_route_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1815 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1816 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1817 | install_element (CONFIG_NODE, &ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1818 | install_element (CONFIG_NODE, &ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1819 | install_element (CONFIG_NODE, &ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1820 | install_element (CONFIG_NODE, &ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1821 | install_element (CONFIG_NODE, &no_ipv6_route_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1822 | install_element (CONFIG_NODE, &no_ipv6_route_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1823 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_cmd); |
hasso | 81dfcaa | 2003-05-25 19:21:25 +0000 | [diff] [blame] | 1824 | install_element (CONFIG_NODE, &no_ipv6_route_ifname_flags_pref_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1825 | install_element (VIEW_NODE, &show_ipv6_route_cmd); |
| 1826 | install_element (VIEW_NODE, &show_ipv6_route_protocol_cmd); |
| 1827 | install_element (VIEW_NODE, &show_ipv6_route_addr_cmd); |
| 1828 | install_element (VIEW_NODE, &show_ipv6_route_prefix_cmd); |
| 1829 | install_element (VIEW_NODE, &show_ipv6_route_prefix_longer_cmd); |
| 1830 | install_element (ENABLE_NODE, &show_ipv6_route_cmd); |
| 1831 | install_element (ENABLE_NODE, &show_ipv6_route_protocol_cmd); |
| 1832 | install_element (ENABLE_NODE, &show_ipv6_route_addr_cmd); |
| 1833 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_cmd); |
| 1834 | install_element (ENABLE_NODE, &show_ipv6_route_prefix_longer_cmd); |
| 1835 | #endif /* HAVE_IPV6 */ |
| 1836 | } |
| 1837 | |
| 1838 | void |
| 1839 | zebra_vty_init () |
| 1840 | { |
| 1841 | zebra_vty_route_init (); |
| 1842 | } |