]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_mpls_vty.c
vtysh: fix build failure in vtysh_writeconfig_integrated()
[mirror_frr.git] / zebra / zebra_mpls_vty.c
CommitLineData
41675b4c
RW
1/* Zebra MPLS 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
41675b4c
RW
24#include "memory.h"
25#include "if.h"
26#include "prefix.h"
27#include "command.h"
28#include "table.h"
29#include "rib.h"
30#include "nexthop.h"
31#include "vrf.h"
32#include "mpls.h"
33#include "lib/json.h"
34
35#include "zebra/zserv.h"
36#include "zebra/zebra_vrf.h"
37#include "zebra/zebra_mpls.h"
38#include "zebra/zebra_rnh.h"
39#include "zebra/redistribute.h"
40#include "zebra/zebra_routemap.h"
41#include "zebra/zebra_static.h"
42
43static int
44zebra_mpls_transit_lsp (struct vty *vty, int add_cmd, const char *inlabel_str,
45 const char *gate_str, const char *outlabel_str,
46 const char *flag_str)
47{
48 struct zebra_vrf *zvrf;
49 int ret;
50 enum nexthop_types_t gtype;
51 union g_addr gate;
52 mpls_label_t label;
53 mpls_label_t in_label, out_label;
54
55 zvrf = vrf_info_lookup(VRF_DEFAULT);
56 if (!zvrf)
57 {
58 vty_out (vty, "%% Default VRF does not exist%s", VTY_NEWLINE);
59 return CMD_WARNING;
60 }
61
62 if (!inlabel_str)
63 {
64 vty_out (vty, "%% No Label Information%s", VTY_NEWLINE);
65 return CMD_WARNING;
66 }
67
68 out_label = MPLS_IMP_NULL_LABEL; /* as initialization */
69 label = atoi(inlabel_str);
70 if (!IS_MPLS_UNRESERVED_LABEL(label))
71 {
72 vty_out (vty, "%% Invalid label%s", VTY_NEWLINE);
73 return CMD_WARNING;
74 }
75
76 if (add_cmd)
77 {
78 if (!gate_str)
79 {
80 vty_out (vty, "%% No Nexthop Information%s", VTY_NEWLINE);
81 return CMD_WARNING;
82 }
83 if (!outlabel_str)
84 {
85 vty_out (vty, "%% No Outgoing label Information%s", VTY_NEWLINE);
86 return CMD_WARNING;
87 }
88 }
89
90 in_label = label;
91 gtype = NEXTHOP_TYPE_BLACKHOLE; /* as initialization */
92
93 if (gate_str)
94 {
95 /* Gateway is a IPv4 or IPv6 nexthop. */
96 ret = inet_pton (AF_INET6, gate_str, &gate.ipv6);
97 if (ret)
98 gtype = NEXTHOP_TYPE_IPV6;
99 else
100 {
101 ret = inet_pton (AF_INET, gate_str, &gate.ipv4);
102 if (ret)
103 gtype = NEXTHOP_TYPE_IPV4;
104 else
105 {
106 vty_out (vty, "%% Invalid nexthop%s", VTY_NEWLINE);
107 return CMD_WARNING;
108 }
109 }
110 }
111
112 if (outlabel_str)
113 {
114 if (outlabel_str[0] == 'i')
115 out_label = MPLS_IMP_NULL_LABEL;
e64f3c32
RW
116 else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV4)
117 out_label = MPLS_V4_EXP_NULL_LABEL;
118 else if (outlabel_str[0] == 'e' && gtype == NEXTHOP_TYPE_IPV6)
119 out_label = MPLS_V6_EXP_NULL_LABEL;
41675b4c
RW
120 else
121 out_label = atoi(outlabel_str);
122 }
123
124 if (add_cmd)
125 {
126#if defined(HAVE_CUMULUS)
127 /* Check that label value is consistent. */
128 if (!zebra_mpls_lsp_label_consistent (zvrf, in_label, out_label, gtype,
129 &gate, NULL, 0))
130 {
131 vty_out (vty, "%% Label value not consistent%s",
132 VTY_NEWLINE);
133 return CMD_WARNING;
134 }
135#endif /* HAVE_CUMULUS */
136
137 ret = zebra_mpls_static_lsp_add (zvrf, in_label, out_label, gtype,
138 &gate, NULL, 0);
139 }
140 else
141 ret = zebra_mpls_static_lsp_del (zvrf, in_label, gtype, &gate, NULL, 0);
142
143 if (ret)
144 {
145 vty_out (vty, "%% LSP cannot be %s%s",
146 add_cmd ? "added" : "deleted", VTY_NEWLINE);
147 return CMD_WARNING;
148 }
149
150 return CMD_SUCCESS;
151}
152
153DEFUN (mpls_transit_lsp,
154 mpls_transit_lsp_cmd,
e64f3c32 155 "mpls lsp <16-1048575> (A.B.C.D|X:X::X:X) (<16-1048575>|explicit-null|implicit-null)",
41675b4c
RW
156 MPLS_STR
157 "Establish label switched path\n"
158 "Incoming MPLS label\n"
159 "IPv4 gateway address\n"
160 "IPv6 gateway address\n"
161 "Outgoing MPLS label\n"
e64f3c32 162 "Use Explicit-Null label\n"
41675b4c
RW
163 "Use Implicit-Null label\n")
164{
165 return zebra_mpls_transit_lsp (vty, 1, argv[0], argv[1], argv[2], NULL);
166}
167
168DEFUN (no_mpls_transit_lsp,
169 no_mpls_transit_lsp_cmd,
170 "no mpls lsp <16-1048575> (A.B.C.D|X:X::X:X)",
171 NO_STR
172 MPLS_STR
173 "Establish label switched path\n"
174 "Incoming MPLS label\n"
175 "IPv4 gateway address\n"
176 "IPv6 gateway address\n")
177{
178 return zebra_mpls_transit_lsp (vty, 0, argv[0], argv[1], NULL, NULL);
179}
180
181ALIAS (no_mpls_transit_lsp,
182 no_mpls_transit_lsp_out_label_cmd,
e64f3c32 183 "no mpls lsp <16-1048575> (A.B.C.D|X:X::X:X) (<16-1048575>|explicit-null|implicit-null)",
41675b4c
RW
184 NO_STR
185 MPLS_STR
186 "Establish label switched path\n"
187 "Incoming MPLS label\n"
188 "IPv4 gateway address\n"
189 "IPv6 gateway address\n"
190 "Outgoing MPLS label\n"
e64f3c32 191 "Use Explicit-Null label\n"
41675b4c
RW
192 "Use Implicit-Null label\n")
193
194DEFUN (no_mpls_transit_lsp_all,
195 no_mpls_transit_lsp_all_cmd,
196 "no mpls lsp <16-1048575>",
197 NO_STR
198 MPLS_STR
199 "Establish label switched path\n"
200 "Incoming MPLS label\n")
201{
202 return zebra_mpls_transit_lsp (vty, 0, argv[0], NULL, NULL, NULL);
203}
204
205/* Static route configuration. */
206DEFUN (ip_route_label,
207 ip_route_label_cmd,
208 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) label WORD",
209 IP_STR
210 "Establish static routes\n"
211 "IP destination prefix (e.g. 10.0.0.0/8)\n"
212 "IP gateway address\n"
213 "IP gateway interface name\n"
214 "Null interface\n"
215 "Specify label(s) for this route\n"
216 "One or more labels separated by '/'\n")
217{
218 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL,
219 NULL, NULL, argv[2]);
220}
221
222DEFUN (ip_route_tag_label,
223 ip_route_tag_label_cmd,
dc9ffce8 224 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD",
41675b4c
RW
225 IP_STR
226 "Establish static routes\n"
227 "IP destination prefix (e.g. 10.0.0.0/8)\n"
228 "IP gateway address\n"
229 "IP gateway interface name\n"
230 "Null interface\n"
231 "Set tag for this route\n"
232 "Tag value\n"
233 "Specify label(s) for this route\n"
234 "One or more labels separated by '/'\n")
235{
236 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2],
237 NULL, NULL, argv[3]);
238}
239
240/* Mask as A.B.C.D format. */
241DEFUN (ip_route_mask_label,
242 ip_route_mask_label_cmd,
243 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) label WORD",
244 IP_STR
245 "Establish static routes\n"
246 "IP destination prefix\n"
247 "IP destination prefix mask\n"
248 "IP gateway address\n"
249 "IP gateway interface name\n"
250 "Null interface\n"
251 "Specify label(s) for this route\n"
252 "One or more labels separated by '/'\n")
253{
254 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL,
255 NULL, NULL, argv[3]);
256}
257
258DEFUN (ip_route_mask_tag_label,
259 ip_route_mask_tag_label_cmd,
dc9ffce8 260 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD",
41675b4c
RW
261 IP_STR
262 "Establish static routes\n"
263 "IP destination prefix\n"
264 "IP destination prefix mask\n"
265 "IP gateway address\n"
266 "IP gateway interface name\n"
267 "Null interface\n"
268 "Set tag for this route\n"
269 "Tag value\n"
270 "Specify label(s) for this route\n"
271 "One or more labels separated by '/'\n")
272
273{
274 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3],
275 NULL, NULL, argv[4]);
276}
277
278/* Distance option value. */
279DEFUN (ip_route_distance_label,
280 ip_route_distance_label_cmd,
281 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> label WORD",
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 "Null interface\n"
288 "Distance value for this route\n"
289 "Specify label(s) for this route\n"
290 "One or more labels separated by '/'\n")
291{
292 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, NULL,
293 argv[2], NULL, argv[3]);
294}
295
296DEFUN (ip_route_tag_distance_label,
297 ip_route_tag_distance_label_cmd,
dc9ffce8 298 "ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
299 IP_STR
300 "Establish static routes\n"
301 "IP destination prefix (e.g. 10.0.0.0/8)\n"
302 "IP gateway address\n"
303 "IP gateway interface name\n"
304 "Null interface\n"
305 "Set tag for this route\n"
306 "Tag value\n"
307 "Distance value for this route\n"
308 "Specify label(s) for this route\n"
309 "One or more labels separated by '/'\n")
310
311{
312 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], NULL, argv[2],
313 argv[3], NULL, argv[4]);
314}
315
316DEFUN (ip_route_mask_distance_label,
317 ip_route_mask_distance_label_cmd,
318 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255> label WORD",
319 IP_STR
320 "Establish static routes\n"
321 "IP destination prefix\n"
322 "IP destination prefix mask\n"
323 "IP gateway address\n"
324 "IP gateway interface name\n"
325 "Null interface\n"
326 "Distance value for this route\n"
327 "Specify label(s) for this route\n"
328 "One or more labels separated by '/'\n")
329{
330 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, NULL,
331 argv[3], NULL, argv[4]);
332}
333
334DEFUN (ip_route_mask_tag_distance_label,
335 ip_route_mask_tag_distance_label_cmd,
dc9ffce8 336 "ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
337 IP_STR
338 "Establish static routes\n"
339 "IP destination prefix\n"
340 "IP destination prefix mask\n"
341 "IP gateway address\n"
342 "IP gateway interface name\n"
343 "Null interface\n"
344 "Set tag for this route\n"
345 "Tag value\n"
346 "Distance value for this route\n"
347 "Specify label(s) for this route\n"
348 "One or more labels separated by '/'\n")
349{
350 return zebra_static_ipv4 (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], NULL, argv[3],
351 argv[4], NULL, argv[5]);
352}
353
354DEFUN (no_ip_route_label,
355 no_ip_route_label_cmd,
356 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) label WORD",
357 NO_STR
358 IP_STR
359 "Establish static routes\n"
360 "IP destination prefix (e.g. 10.0.0.0/8)\n"
361 "IP gateway address\n"
362 "IP gateway interface name\n"
363 "Null interface\n"
364 "Specify label(s) for this route\n"
365 "One or more labels separated by '/'\n")
366{
367 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL,
368 NULL, NULL, argv[2]);
369}
370
371DEFUN (no_ip_route_tag_label,
372 no_ip_route_tag_label_cmd,
dc9ffce8 373 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD",
41675b4c
RW
374 NO_STR
375 IP_STR
376 "Establish static routes\n"
377 "IP destination prefix (e.g. 10.0.0.0/8)\n"
378 "IP gateway address\n"
379 "IP gateway interface name\n"
380 "Null interface\n"
381 "Tag of this route\n"
382 "Tag value\n"
383 "Specify label(s) for this route\n"
384 "One or more labels separated by '/'\n")
385{
386 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2],
387 NULL, NULL, argv[3]);
388}
389
390DEFUN (no_ip_route_mask_label,
391 no_ip_route_mask_label_cmd,
392 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) label WORD",
393 NO_STR
394 IP_STR
395 "Establish static routes\n"
396 "IP destination prefix\n"
397 "IP destination prefix mask\n"
398 "IP gateway address\n"
399 "IP gateway interface name\n"
400 "Null interface\n"
401 "Specify label(s) for this route\n"
402 "One or more labels separated by '/'\n")
403{
404 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL,
405 NULL, NULL, argv[3]);
406}
407
408DEFUN (no_ip_route_mask_tag_label,
409 no_ip_route_mask_tag_label_cmd,
dc9ffce8 410 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> label WORD",
41675b4c
RW
411 NO_STR
412 IP_STR
413 "Establish static routes\n"
414 "IP destination prefix\n"
415 "IP destination prefix mask\n"
416 "IP gateway address\n"
417 "IP gateway interface name\n"
418 "Null interface\n"
419 "Tag of this route\n"
420 "Tag value\n"
421 "Specify label(s) for this route\n"
422 "One or more labels separated by '/'\n")
423{
424 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3],
425 NULL, NULL, argv[4]);
426}
427
428DEFUN (no_ip_route_distance_label,
429 no_ip_route_distance_label_cmd,
430 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) <1-255> label WORD",
431 NO_STR
432 IP_STR
433 "Establish static routes\n"
434 "IP destination prefix (e.g. 10.0.0.0/8)\n"
435 "IP gateway address\n"
436 "IP gateway interface name\n"
437 "Null interface\n"
438 "Distance value for this route\n"
439 "Specify label(s) for this route\n"
440 "One or more labels separated by '/'\n")
441{
442 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, NULL,
443 argv[2], NULL, argv[3]);
444}
445
446DEFUN (no_ip_route_tag_distance_label,
447 no_ip_route_tag_distance_label_cmd,
dc9ffce8 448 "no ip route A.B.C.D/M (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
449 NO_STR
450 IP_STR
451 "Establish static routes\n"
452 "IP destination prefix (e.g. 10.0.0.0/8)\n"
453 "IP gateway address\n"
454 "IP gateway interface name\n"
455 "Null interface\n"
456 "Tag of this route\n"
457 "Tag value\n"
458 "Distance value for this route\n"
459 "Specify label(s) for this route\n"
460 "One or more labels separated by '/'\n")
461{
462 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], NULL, argv[2],
463 argv[3], NULL, argv[4]);
464}
465
466DEFUN (no_ip_route_mask_distance_label,
467 no_ip_route_mask_distance_label_cmd,
468 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) <1-255>",
469 NO_STR
470 IP_STR
471 "Establish static routes\n"
472 "IP destination prefix\n"
473 "IP destination prefix mask\n"
474 "IP gateway address\n"
475 "IP gateway interface name\n"
476 "Null interface\n"
477 "Distance value for this route\n"
478 "Specify label(s) for this route\n"
479 "One or more labels separated by '/'\n")
480{
481 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, NULL,
482 argv[3], NULL, argv[5]);
483}
484
485DEFUN (no_ip_route_mask_tag_distance_label,
486 no_ip_route_mask_tag_distance_label_cmd,
dc9ffce8 487 "no ip route A.B.C.D A.B.C.D (A.B.C.D|INTERFACE|null0) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
488 NO_STR
489 IP_STR
490 "Establish static routes\n"
491 "IP destination prefix\n"
492 "IP destination prefix mask\n"
493 "IP gateway address\n"
494 "IP gateway interface name\n"
495 "Null interface\n"
496 "Tag of this route\n"
497 "Tag value\n"
498 "Distance value for this route\n"
499 "Specify label(s) for this route\n"
500 "One or more labels separated by '/'\n")
501{
502 return zebra_static_ipv4 (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], NULL, argv[3],
503 argv[4], NULL, argv[5]);
504}
505
506DEFUN (ipv6_route_label,
507 ipv6_route_label_cmd,
508 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) label WORD",
509 IP_STR
510 "Establish static routes\n"
511 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
512 "IPv6 gateway address\n"
513 "IPv6 gateway interface name\n"
514 "Specify label(s) for this route\n"
515 "One or more labels separated by '/'\n")
516{
517 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, argv[2]);
518}
519
520DEFUN (ipv6_route_tag_label,
521 ipv6_route_tag_label_cmd,
dc9ffce8 522 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> label WORD",
41675b4c
RW
523 IP_STR
524 "Establish static routes\n"
525 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
526 "IPv6 gateway address\n"
527 "IPv6 gateway interface name\n"
528 "Set tag for this route\n"
529 "Tag value\n"
530 "Specify label(s) for this route\n"
531 "One or more labels separated by '/'\n")
532{
533 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, argv[3]);
534}
535
536DEFUN (ipv6_route_ifname_label,
537 ipv6_route_ifname_label_cmd,
538 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
539 IP_STR
540 "Establish static routes\n"
541 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
542 "IPv6 gateway address\n"
543 "IPv6 gateway interface name\n"
544 "Specify label(s) for this route\n"
545 "One or more labels separated by '/'\n")
546{
547 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, argv[3]);
548}
549DEFUN (ipv6_route_ifname_tag_label,
550 ipv6_route_ifname_tag_label_cmd,
dc9ffce8 551 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> label WORD",
41675b4c
RW
552 IP_STR
553 "Establish static routes\n"
554 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
555 "IPv6 gateway address\n"
556 "IPv6 gateway interface name\n"
557 "Set tag for this route\n"
558 "Tag value\n"
559 "Specify label(s) for this route\n"
560 "One or more labels separated by '/'\n")
561{
562 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, argv[4]);
563}
564
565DEFUN (ipv6_route_pref_label,
566 ipv6_route_pref_label_cmd,
567 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> label WORD",
568 IP_STR
569 "Establish static routes\n"
570 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
571 "IPv6 gateway address\n"
572 "IPv6 gateway interface name\n"
573 "Distance value for this prefix\n"
574 "Specify label(s) for this route\n"
575 "One or more labels separated by '/'\n")
576{
577 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, argv[3]);
578}
579
580DEFUN (ipv6_route_pref_tag_label,
581 ipv6_route_pref_tag_label_cmd,
dc9ffce8 582 "ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
583 IP_STR
584 "Establish static routes\n"
585 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
586 "IPv6 gateway address\n"
587 "IPv6 gateway interface name\n"
588 "Set tag for this route\n"
589 "Tag value\n"
590 "Distance value for this prefix\n"
591 "Specify label(s) for this route\n"
592 "One or more labels separated by '/'\n")
593{
594 return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, argv[4]);
595}
596
597DEFUN (ipv6_route_ifname_pref_label,
598 ipv6_route_ifname_pref_label_cmd,
599 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> label WORD",
600 IP_STR
601 "Establish static routes\n"
602 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
603 "IPv6 gateway address\n"
604 "IPv6 gateway interface name\n"
605 "Distance value for this prefix\n"
606 "Specify label(s) for this route\n"
607 "One or more labels separated by '/'\n")
608{
609 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, argv[4]);
610}
611
612DEFUN (ipv6_route_ifname_pref_tag_label,
613 ipv6_route_ifname_pref_tag_label_cmd,
dc9ffce8 614 "ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
615 IP_STR
616 "Establish static routes\n"
617 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
618 "IPv6 gateway address\n"
619 "IPv6 gateway interface name\n"
620 "Set tag for this route\n"
621 "Tag value\n"
622 "Distance value for this prefix\n"
623 "Specify label(s) for this route\n"
624 "One or more labels separated by '/'\n")
625{
626 return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, argv[5]);
627}
628
629DEFUN (no_ipv6_route_label,
630 no_ipv6_route_label_cmd,
631 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) label WORD",
632 NO_STR
633 IP_STR
634 "Establish static routes\n"
635 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
636 "IPv6 gateway address\n"
637 "IPv6 gateway interface name\n"
638 "Specify label(s) for this route\n"
639 "One or more labels separated by '/'\n")
640{
641 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL, argv[2]);
642}
643
644DEFUN (no_ipv6_route_tag_label,
645 no_ipv6_route_tag_label_cmd,
dc9ffce8 646 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> label WORD",
41675b4c
RW
647 NO_STR
648 IP_STR
649 "Establish static routes\n"
650 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
651 "IPv6 gateway address\n"
652 "IPv6 gateway interface name\n"
653 "Set tag for this route\n"
654 "Tag value\n"
655 "Specify label(s) for this route\n"
656 "One or more labels separated by '/'\n")
657{
658 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], NULL, NULL, argv[3]);
659}
660
661DEFUN (no_ipv6_route_ifname_label,
662 no_ipv6_route_ifname_label_cmd,
663 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE label WORD",
664 NO_STR
665 IP_STR
666 "Establish static routes\n"
667 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
668 "IPv6 gateway address\n"
669 "IPv6 gateway interface name\n"
670 "Specify label(s) for this route\n"
671 "One or more labels separated by '/'\n")
672{
673 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL, argv[3]);
674}
675
676DEFUN (no_ipv6_route_ifname_tag_label,
677 no_ipv6_route_ifname_tag_label_cmd,
dc9ffce8 678 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> label WORD",
41675b4c
RW
679 NO_STR
680 IP_STR
681 "Establish static routes\n"
682 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
683 "IPv6 gateway address\n"
684 "IPv6 gateway interface name\n"
685 "Set tag for this route\n"
686 "Tag value\n"
687 "Specify label(s) for this route\n"
688 "One or more labels separated by '/'\n")
689{
690 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], NULL, NULL, argv[4]);
691}
692
693DEFUN (no_ipv6_route_pref_label,
694 no_ipv6_route_pref_label_cmd,
695 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) <1-255> label WORD",
696 NO_STR
697 IP_STR
698 "Establish static routes\n"
699 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
700 "IPv6 gateway address\n"
701 "IPv6 gateway interface name\n"
702 "Distance value for this prefix\n"
703 "Specify label(s) for this route\n"
704 "One or more labels separated by '/'\n")
705{
706 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL, argv[3]);
707}
708
709DEFUN (no_ipv6_route_pref_tag_label,
710 no_ipv6_route_pref_tag_label_cmd,
dc9ffce8 711 "no ipv6 route X:X::X:X/M (X:X::X:X|INTERFACE) tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
712 NO_STR
713 IP_STR
714 "Establish static routes\n"
715 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
716 "IPv6 gateway address\n"
717 "IPv6 gateway interface name\n"
718 "Set tag for this route\n"
719 "Tag value\n"
720 "Distance value for this prefix\n"
721 "Specify label(s) for this route\n"
722 "One or more labels separated by '/'\n")
723{
724 return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], argv[3], NULL, argv[4]);
725}
726
727DEFUN (no_ipv6_route_ifname_pref_label,
728 no_ipv6_route_ifname_pref_label_cmd,
729 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE <1-255> label WORD",
730 NO_STR
731 IP_STR
732 "Establish static routes\n"
733 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
734 "IPv6 gateway address\n"
735 "IPv6 gateway interface name\n"
736 "Distance value for this prefix\n"
737 "Specify label(s) for this route\n"
738 "One or more labels separated by '/'\n")
739{
740 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL, argv[4]);
741}
742
743DEFUN (no_ipv6_route_ifname_pref_tag_label,
744 no_ipv6_route_ifname_pref_tag_label_cmd,
dc9ffce8 745 "no ipv6 route X:X::X:X/M X:X::X:X INTERFACE tag <1-4294967295> <1-255> label WORD",
41675b4c
RW
746 NO_STR
747 IP_STR
748 "Establish static routes\n"
749 "IPv6 destination prefix (e.g. 3ffe:506::/32)\n"
750 "IPv6 gateway address\n"
751 "IPv6 gateway interface name\n"
752 "Set tag for this route\n"
753 "Tag value\n"
754 "Distance value for this prefix\n"
755 "Specify label(s) for this route\n"
756 "One or more labels separated by '/'\n")
757{
758 return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], argv[4], NULL, argv[5]);
759}
760
761/* MPLS LSP configuration write function. */
762static int
763zebra_mpls_config (struct vty *vty)
764{
765 int write = 0;
766 struct zebra_vrf *zvrf;
767
768 zvrf = vrf_info_lookup(VRF_DEFAULT);
769 if (!zvrf)
770 return 0;
771
772 write += zebra_mpls_write_lsp_config(vty, zvrf);
773 return write;
774}
775
776DEFUN (show_mpls_table,
777 show_mpls_table_cmd,
778 "show mpls table {json}",
779 SHOW_STR
780 MPLS_STR
781 "MPLS table\n"
782 "JavaScript Object Notation\n")
783{
784 struct zebra_vrf *zvrf;
785 u_char use_json = (argv[0] != NULL);
786
787 zvrf = vrf_info_lookup(VRF_DEFAULT);
788 zebra_mpls_print_lsp_table(vty, zvrf, use_json);
789 return CMD_SUCCESS;
790}
791
792DEFUN (show_mpls_table_lsp,
793 show_mpls_table_lsp_cmd,
794 "show mpls table <16-1048575> {json}",
795 SHOW_STR
796 MPLS_STR
797 "MPLS table\n"
798 "LSP to display information about\n"
799 "JavaScript Object Notation\n")
800{
801 u_int32_t label;
802 struct zebra_vrf *zvrf;
803 u_char use_json = (argv[1] != NULL);
804
805 zvrf = vrf_info_lookup(VRF_DEFAULT);
806 label = atoi(argv[0]);
807 zebra_mpls_print_lsp (vty, zvrf, label, use_json);
808 return CMD_SUCCESS;
809}
810
fe6c7157
RW
811DEFUN (show_mpls_status,
812 show_mpls_status_cmd,
813 "show mpls status",
814 SHOW_STR
815 "MPLS information\n"
816 "MPLS status\n")
817{
818 vty_out (vty, "MPLS support enabled: %s%s", (mpls_enabled) ? "yes" :
819 "no (mpls kernel extensions not detected)", VTY_NEWLINE);
820 return CMD_SUCCESS;
821}
822
41675b4c
RW
823/* MPLS node for MPLS LSP. */
824static struct cmd_node mpls_node = { MPLS_NODE, "", 1 };
825
826/* MPLS VTY. */
827void
828zebra_mpls_vty_init (void)
829{
fe6c7157
RW
830 install_element (VIEW_NODE, &show_mpls_status_cmd);
831 install_element (ENABLE_NODE, &show_mpls_status_cmd);
832
833 if (! mpls_enabled)
834 return;
835
41675b4c
RW
836 install_node (&mpls_node, zebra_mpls_config);
837
838 install_element (CONFIG_NODE, &ip_route_label_cmd);
839 install_element (CONFIG_NODE, &ip_route_tag_label_cmd);
840 install_element (CONFIG_NODE, &ip_route_mask_label_cmd);
841 install_element (CONFIG_NODE, &ip_route_mask_tag_label_cmd);
842 install_element (CONFIG_NODE, &no_ip_route_label_cmd);
843 install_element (CONFIG_NODE, &no_ip_route_tag_label_cmd);
844 install_element (CONFIG_NODE, &no_ip_route_mask_label_cmd);
845 install_element (CONFIG_NODE, &no_ip_route_mask_tag_label_cmd);
846 install_element (CONFIG_NODE, &ip_route_distance_label_cmd);
847 install_element (CONFIG_NODE, &ip_route_tag_distance_label_cmd);
848 install_element (CONFIG_NODE, &ip_route_mask_distance_label_cmd);
849 install_element (CONFIG_NODE, &ip_route_mask_tag_distance_label_cmd);
850 install_element (CONFIG_NODE, &no_ip_route_distance_label_cmd);
851 install_element (CONFIG_NODE, &no_ip_route_tag_distance_label_cmd);
852 install_element (CONFIG_NODE, &no_ip_route_mask_distance_label_cmd);
853 install_element (CONFIG_NODE, &no_ip_route_mask_tag_distance_label_cmd);
854
855 install_element (CONFIG_NODE, &ipv6_route_label_cmd);
856 install_element (CONFIG_NODE, &ipv6_route_ifname_label_cmd);
857 install_element (CONFIG_NODE, &no_ipv6_route_label_cmd);
858 install_element (CONFIG_NODE, &no_ipv6_route_ifname_label_cmd);
859 install_element (CONFIG_NODE, &ipv6_route_pref_label_cmd);
860 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_label_cmd);
861 install_element (CONFIG_NODE, &no_ipv6_route_pref_label_cmd);
862 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_label_cmd);
863 install_element (CONFIG_NODE, &ipv6_route_tag_label_cmd);
864 install_element (CONFIG_NODE, &ipv6_route_ifname_tag_label_cmd);
865 install_element (CONFIG_NODE, &ipv6_route_pref_tag_label_cmd);
866 install_element (CONFIG_NODE, &ipv6_route_ifname_pref_tag_label_cmd);
867 install_element (CONFIG_NODE, &no_ipv6_route_tag_label_cmd);
868 install_element (CONFIG_NODE, &no_ipv6_route_ifname_tag_label_cmd);
869 install_element (CONFIG_NODE, &no_ipv6_route_pref_tag_label_cmd);
870 install_element (CONFIG_NODE, &no_ipv6_route_ifname_pref_tag_label_cmd);
871
872 install_element (CONFIG_NODE, &mpls_transit_lsp_cmd);
873 install_element (CONFIG_NODE, &no_mpls_transit_lsp_cmd);
874 install_element (CONFIG_NODE, &no_mpls_transit_lsp_out_label_cmd);
875 install_element (CONFIG_NODE, &no_mpls_transit_lsp_all_cmd);
876
877 install_element (VIEW_NODE, &show_mpls_table_cmd);
878 install_element (ENABLE_NODE, &show_mpls_table_cmd);
879 install_element (VIEW_NODE, &show_mpls_table_lsp_cmd);
880 install_element (ENABLE_NODE, &show_mpls_table_lsp_cmd);
881}