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