1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
|
/*
* SHARP - vty code
* Copyright (C) Cumulus Networks, Inc.
* Donald Sharp
*
* This file is part of FRR.
*
* FRR is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* FRR is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "vty.h"
#include "command.h"
#include "prefix.h"
#include "nexthop.h"
#include "log.h"
#include "vrf.h"
#include "zclient.h"
#include "nexthop_group.h"
#include "sharpd/sharp_globals.h"
#include "sharpd/sharp_zebra.h"
#include "sharpd/sharp_nht.h"
#include "sharpd/sharp_vty.h"
#ifndef VTYSH_EXTRACT_PL
#include "sharpd/sharp_vty_clippy.c"
#endif
DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
"sharp watch [vrf NAME$vrf_name] <nexthop$n X:X::X:X$nhop|import$import X:X::X:X/M$inhop> [connected$connected]",
"Sharp routing Protocol\n"
"Watch for changes\n"
"The vrf we would like to watch if non-default\n"
"The NAME of the vrf\n"
"Watch for nexthop changes\n"
"The v6 nexthop to signal for watching\n"
"Watch for import check changes\n"
"The v6 prefix to signal for watching\n"
"Should the route be connected\n")
{
struct vrf *vrf;
struct prefix p;
bool type_import;
if (!vrf_name)
vrf_name = VRF_DEFAULT_NAME;
vrf = vrf_lookup_by_name(vrf_name);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name);
return CMD_WARNING;
}
memset(&p, 0, sizeof(p));
if (n) {
type_import = false;
p.prefixlen = 128;
memcpy(&p.u.prefix6, &nhop, 16);
p.family = AF_INET6;
} else {
type_import = true;
p = *(const struct prefix *)inhop;
}
sharp_nh_tracker_get(&p);
sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
true, !!connected);
return CMD_SUCCESS;
}
DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
"sharp watch [vrf NAME$vrf_name] <nexthop$n A.B.C.D$nhop|import$import A.B.C.D/M$inhop> [connected$connected]",
"Sharp routing Protocol\n"
"Watch for changes\n"
"The vrf we would like to watch if non-default\n"
"The NAME of the vrf\n"
"Watch for nexthop changes\n"
"The v4 address to signal for watching\n"
"Watch for import check changes\n"
"The v4 prefix for import check to watch\n"
"Should the route be connected\n")
{
struct vrf *vrf;
struct prefix p;
bool type_import;
if (!vrf_name)
vrf_name = VRF_DEFAULT_NAME;
vrf = vrf_lookup_by_name(vrf_name);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name);
return CMD_WARNING;
}
memset(&p, 0, sizeof(p));
if (n) {
type_import = false;
p.prefixlen = 32;
p.u.prefix4 = nhop;
p.family = AF_INET;
}
else {
type_import = true;
p = *(const struct prefix *)inhop;
}
sharp_nh_tracker_get(&p);
sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
true, !!connected);
return CMD_SUCCESS;
}
DEFPY(sharp_nht_data_dump,
sharp_nht_data_dump_cmd,
"sharp data nexthop",
"Sharp routing Protocol\n"
"Data about what is going on\n"
"Nexthop information\n")
{
sharp_nh_tracker_dump(vty);
return CMD_SUCCESS;
}
DEFPY (install_routes_data_dump,
install_routes_data_dump_cmd,
"sharp data route",
"Sharp routing Protocol\n"
"Data about what is going on\n"
"Route Install/Removal Information\n")
{
char buf[PREFIX_STRLEN];
struct timeval r;
timersub(&sg.r.t_end, &sg.r.t_start, &r);
vty_out(vty, "Prefix: %s Total: %u %u %u Time: %jd.%ld\n",
prefix2str(&sg.r.orig_prefix, buf, sizeof(buf)),
sg.r.total_routes,
sg.r.installed_routes,
sg.r.removed_routes,
(intmax_t)r.tv_sec, (long)r.tv_usec);
return CMD_SUCCESS;
}
DEFPY (install_routes,
install_routes_cmd,
"sharp install routes [vrf NAME$vrf_name]\
<A.B.C.D$start4|X:X::X:X$start6>\
<nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|\
nexthop-group NHGNAME$nexthop_group>\
[backup$backup <A.B.C.D$backup_nexthop4|X:X::X:X$backup_nexthop6>] \
(1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
"Sharp routing Protocol\n"
"install some routes\n"
"Routes to install\n"
"The vrf we would like to install into if non-default\n"
"The NAME of the vrf\n"
"v4 Address to start /32 generation at\n"
"v6 Address to start /32 generation at\n"
"Nexthop to use(Can be an IPv4 or IPv6 address)\n"
"V4 Nexthop address to use\n"
"V6 Nexthop address to use\n"
"Nexthop-Group to use\n"
"The Name of the nexthop-group\n"
"Backup nexthop to use(Can be an IPv4 or IPv6 address)\n"
"Backup V4 Nexthop address to use\n"
"Backup V6 Nexthop address to use\n"
"How many to create\n"
"Instance to use\n"
"Instance\n"
"Should we repeat this command\n"
"How many times to repeat this command\n")
{
struct vrf *vrf;
struct prefix prefix;
uint32_t rts;
uint32_t nhgid = 0;
sg.r.total_routes = routes;
sg.r.installed_routes = 0;
if (rpt >= 2)
sg.r.repeat = rpt * 2;
else
sg.r.repeat = 0;
memset(&prefix, 0, sizeof(prefix));
memset(&sg.r.orig_prefix, 0, sizeof(sg.r.orig_prefix));
memset(&sg.r.nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.nhop_group, 0, sizeof(sg.r.nhop_group));
memset(&sg.r.backup_nhop, 0, sizeof(sg.r.nhop));
memset(&sg.r.backup_nhop_group, 0, sizeof(sg.r.nhop_group));
if (start4.s_addr != 0) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = start4;
} else {
prefix.family = AF_INET6;
prefix.prefixlen = 128;
prefix.u.prefix6 = start6;
}
sg.r.orig_prefix = prefix;
if (!vrf_name)
vrf_name = VRF_DEFAULT_NAME;
vrf = vrf_lookup_by_name(vrf_name);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name);
return CMD_WARNING;
}
/* Explicit backup not available with named nexthop-group */
if (backup && nexthop_group) {
vty_out(vty, "%% Invalid: cannot specify both nexthop-group and backup\n");
return CMD_WARNING;
}
if (nexthop_group) {
struct nexthop_group_cmd *nhgc = nhgc_find(nexthop_group);
if (!nhgc) {
vty_out(vty,
"Specified Nexthop Group: %s does not exist\n",
nexthop_group);
return CMD_WARNING;
}
nhgid = sharp_nhgroup_get_id(nexthop_group);
sg.r.nhgid = nhgid;
sg.r.nhop_group.nexthop = nhgc->nhg.nexthop;
/* Use group's backup nexthop info if present */
if (nhgc->backup_list_name[0]) {
struct nexthop_group_cmd *bnhgc =
nhgc_find(nhgc->backup_list_name);
if (!bnhgc) {
vty_out(vty, "%% Backup group %s not found for group %s\n",
nhgc->backup_list_name,
nhgc->name);
return CMD_WARNING;
}
sg.r.backup_nhop.vrf_id = vrf->vrf_id;
sg.r.backup_nhop_group.nexthop = bnhgc->nhg.nexthop;
}
} else {
if (nexthop4.s_addr != INADDR_ANY) {
sg.r.nhop.gate.ipv4 = nexthop4;
sg.r.nhop.type = NEXTHOP_TYPE_IPV4;
} else {
sg.r.nhop.gate.ipv6 = nexthop6;
sg.r.nhop.type = NEXTHOP_TYPE_IPV6;
}
sg.r.nhop.vrf_id = vrf->vrf_id;
sg.r.nhop_group.nexthop = &sg.r.nhop;
}
/* Use single backup nexthop if specified */
if (backup) {
/* Set flag and index in primary nexthop */
SET_FLAG(sg.r.nhop.flags, NEXTHOP_FLAG_HAS_BACKUP);
sg.r.nhop.backup_num = 1;
sg.r.nhop.backup_idx[0] = 0;
if (backup_nexthop4.s_addr != INADDR_ANY) {
sg.r.backup_nhop.gate.ipv4 = backup_nexthop4;
sg.r.backup_nhop.type = NEXTHOP_TYPE_IPV4;
} else {
sg.r.backup_nhop.gate.ipv6 = backup_nexthop6;
sg.r.backup_nhop.type = NEXTHOP_TYPE_IPV6;
}
sg.r.backup_nhop.vrf_id = vrf->vrf_id;
sg.r.backup_nhop_group.nexthop = &sg.r.backup_nhop;
}
sg.r.inst = instance;
sg.r.vrf_id = vrf->vrf_id;
rts = routes;
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst,
nhgid, &sg.r.nhop_group,
&sg.r.backup_nhop_group, rts);
return CMD_SUCCESS;
}
DEFPY(vrf_label, vrf_label_cmd,
"sharp label <ip$ipv4|ipv6$ipv6> vrf NAME$vrf_name label (0-100000)$label",
"Sharp Routing Protocol\n"
"Give a vrf a label\n"
"Pop and forward for IPv4\n"
"Pop and forward for IPv6\n"
VRF_CMD_HELP_STR
"The label to use, 0 specifies remove the label installed from previous\n"
"Specified range to use\n")
{
struct vrf *vrf;
afi_t afi = (ipv4) ? AFI_IP : AFI_IP6;
if (strcmp(vrf_name, "default") == 0)
vrf = vrf_lookup_by_id(VRF_DEFAULT);
else
vrf = vrf_lookup_by_name(vrf_name);
if (!vrf) {
vty_out(vty, "Unable to find vrf you silly head");
return CMD_WARNING_CONFIG_FAILED;
}
if (label == 0)
label = MPLS_LABEL_NONE;
vrf_label_add(vrf->vrf_id, afi, label);
return CMD_SUCCESS;
}
DEFPY (remove_routes,
remove_routes_cmd,
"sharp remove routes [vrf NAME$vrf_name] <A.B.C.D$start4|X:X::X:X$start6> (1-1000000)$routes [instance (0-255)$instance]",
"Sharp Routing Protocol\n"
"Remove some routes\n"
"Routes to remove\n"
"The vrf we would like to remove from if non-default\n"
"The NAME of the vrf\n"
"v4 Starting spot\n"
"v6 Starting spot\n"
"Routes to uninstall\n"
"instance to use\n"
"Value of instance\n")
{
struct vrf *vrf;
struct prefix prefix;
sg.r.total_routes = routes;
sg.r.removed_routes = 0;
uint32_t rts;
memset(&prefix, 0, sizeof(prefix));
if (start4.s_addr != 0) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = start4;
} else {
prefix.family = AF_INET6;
prefix.prefixlen = 128;
prefix.u.prefix6 = start6;
}
vrf = vrf_lookup_by_name(vrf_name ? vrf_name : VRF_DEFAULT_NAME);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name ? vrf_name : VRF_DEFAULT_NAME);
return CMD_WARNING;
}
sg.r.inst = instance;
sg.r.vrf_id = vrf->vrf_id;
rts = routes;
sharp_remove_routes_helper(&prefix, sg.r.vrf_id,
sg.r.inst, rts);
return CMD_SUCCESS;
}
DEFUN_NOSH (show_debugging_sharpd,
show_debugging_sharpd_cmd,
"show debugging [sharp]",
SHOW_STR
DEBUG_STR
"Sharp Information\n")
{
vty_out(vty, "Sharp debugging status:\n");
return CMD_SUCCESS;
}
DEFPY (sharp_lsp_prefix_v4, sharp_lsp_prefix_v4_cmd,
"sharp lsp [update]$update (0-100000)$inlabel\
nexthop-group NHGNAME$nhgname\
[prefix A.B.C.D/M$pfx\
" FRR_IP_REDIST_STR_ZEBRA "$type_str [instance (0-255)$instance]]",
"Sharp Routing Protocol\n"
"Add an LSP\n"
"Update an LSP\n"
"The ingress label to use\n"
"Use nexthops from a nexthop-group\n"
"The nexthop-group name\n"
"Label a prefix\n"
"The v4 prefix to label\n"
FRR_IP_REDIST_HELP_STR_ZEBRA
"Instance to use\n"
"Instance\n")
{
struct nexthop_group_cmd *nhgc = NULL;
struct nexthop_group_cmd *backup_nhgc = NULL;
struct nexthop_group *backup_nhg = NULL;
struct prefix p = {};
int type = 0;
bool update_p;
update_p = (update != NULL);
/* We're offered a v4 prefix */
if (pfx->family > 0 && type_str) {
p.family = pfx->family;
p.prefixlen = pfx->prefixlen;
p.u.prefix4 = pfx->prefix;
type = proto_redistnum(AFI_IP, type_str);
if (type < 0) {
vty_out(vty, "%% Unknown route type '%s'\n", type_str);
return CMD_WARNING;
}
} else if (pfx->family > 0 || type_str) {
vty_out(vty, "%% Must supply both prefix and type\n");
return CMD_WARNING;
}
nhgc = nhgc_find(nhgname);
if (!nhgc) {
vty_out(vty, "%% Nexthop-group '%s' does not exist\n",
nhgname);
return CMD_WARNING;
}
if (nhgc->nhg.nexthop == NULL) {
vty_out(vty, "%% Nexthop-group '%s' is empty\n", nhgname);
return CMD_WARNING;
}
/* Use group's backup nexthop info if present */
if (nhgc->backup_list_name[0]) {
backup_nhgc = nhgc_find(nhgc->backup_list_name);
if (!backup_nhgc) {
vty_out(vty,
"%% Backup group %s not found for group %s\n",
nhgc->backup_list_name,
nhgname);
return CMD_WARNING;
}
backup_nhg = &(backup_nhgc->nhg);
}
if (sharp_install_lsps_helper(true /*install*/, update_p,
pfx->family > 0 ? &p : NULL,
type, instance, inlabel,
&(nhgc->nhg), backup_nhg) == 0)
return CMD_SUCCESS;
else {
vty_out(vty, "%% LSP install failed!\n");
return CMD_WARNING;
}
}
DEFPY(sharp_remove_lsp_prefix_v4, sharp_remove_lsp_prefix_v4_cmd,
"sharp remove lsp \
(0-100000)$inlabel\
[nexthop-group NHGNAME$nhgname] \
[prefix A.B.C.D/M$pfx\
" FRR_IP_REDIST_STR_SHARPD "$type_str [instance (0-255)$instance]]",
"Sharp Routing Protocol\n"
"Remove data\n"
"Remove an LSP\n"
"The ingress label\n"
"Use nexthops from a nexthop-group\n"
"The nexthop-group name\n"
"Specify a v4 prefix\n"
"The v4 prefix to label\n"
FRR_IP_REDIST_HELP_STR_SHARPD
"Routing instance\n"
"Instance to use\n")
{
struct nexthop_group_cmd *nhgc = NULL;
struct prefix p = {};
int type = 0;
struct nexthop_group *nhg = NULL;
/* We're offered a v4 prefix */
if (pfx->family > 0 && type_str) {
p.family = pfx->family;
p.prefixlen = pfx->prefixlen;
p.u.prefix4 = pfx->prefix;
type = proto_redistnum(AFI_IP, type_str);
if (type < 0) {
vty_out(vty, "%% Unknown route type '%s'\n", type_str);
return CMD_WARNING;
}
} else if (pfx->family > 0 || type_str) {
vty_out(vty, "%% Must supply both prefix and type\n");
return CMD_WARNING;
}
if (nhgname) {
nhgc = nhgc_find(nhgname);
if (!nhgc) {
vty_out(vty, "%% Nexthop-group '%s' does not exist\n",
nhgname);
return CMD_WARNING;
}
if (nhgc->nhg.nexthop == NULL) {
vty_out(vty, "%% Nexthop-group '%s' is empty\n",
nhgname);
return CMD_WARNING;
}
nhg = &(nhgc->nhg);
}
if (sharp_install_lsps_helper(false /*!install*/, false,
pfx->family > 0 ? &p : NULL,
type, instance, inlabel, nhg, NULL) == 0)
return CMD_SUCCESS;
else {
vty_out(vty, "%% LSP remove failed!\n");
return CMD_WARNING;
}
}
DEFPY (logpump,
logpump_cmd,
"sharp logpump duration (1-60) frequency (1-1000000) burst (1-1000)",
"Sharp Routing Protocol\n"
"Generate bulk log messages for testing\n"
"Duration of run (s)\n"
"Duration of run (s)\n"
"Frequency of bursts (s^-1)\n"
"Frequency of bursts (s^-1)\n"
"Number of log messages per each burst\n"
"Number of log messages per each burst\n")
{
sharp_logpump_run(vty, duration, frequency, burst);
return CMD_SUCCESS;
}
DEFPY (create_session,
create_session_cmd,
"sharp create session (1-1024)",
"Sharp Routing Protocol\n"
"Create data\n"
"Create a test session\n"
"Session ID\n")
{
if (sharp_zclient_create(session) != 0) {
vty_out(vty, "%% Client session error\n");
return CMD_WARNING;
}
return CMD_SUCCESS;
}
DEFPY (remove_session,
remove_session_cmd,
"sharp remove session (1-1024)",
"Sharp Routing Protocol\n"
"Remove data\n"
"Remove a test session\n"
"Session ID\n")
{
sharp_zclient_delete(session);
return CMD_SUCCESS;
}
DEFPY (send_opaque,
send_opaque_cmd,
"sharp send opaque type (1-255) (1-1000)$count",
SHARP_STR
"Send messages for testing\n"
"Send opaque messages\n"
"Type code to send\n"
"Type code to send\n"
"Number of messages to send\n")
{
sharp_opaque_send(type, 0, 0, 0, count);
return CMD_SUCCESS;
}
DEFPY (send_opaque_unicast,
send_opaque_unicast_cmd,
"sharp send opaque unicast type (1-255) \
" FRR_IP_REDIST_STR_ZEBRA "$proto_str \
[{instance (0-1000) | session (1-1000)}] (1-1000)$count",
SHARP_STR
"Send messages for testing\n"
"Send opaque messages\n"
"Send unicast messages\n"
"Type code to send\n"
"Type code to send\n"
FRR_IP_REDIST_HELP_STR_ZEBRA
"Daemon instance\n"
"Daemon instance\n"
"Session ID\n"
"Session ID\n"
"Number of messages to send\n")
{
uint32_t proto;
proto = proto_redistnum(AFI_IP, proto_str);
sharp_opaque_send(type, proto, instance, session, count);
return CMD_SUCCESS;
}
DEFPY (send_opaque_reg,
send_opaque_reg_cmd,
"sharp send opaque <reg$reg | unreg> \
" FRR_IP_REDIST_STR_ZEBRA "$proto_str \
[{instance (0-1000) | session (1-1000)}] type (1-1000)",
SHARP_STR
"Send messages for testing\n"
"Send opaque messages\n"
"Send opaque registration\n"
"Send opaque unregistration\n"
FRR_IP_REDIST_HELP_STR_ZEBRA
"Daemon instance\n"
"Daemon instance\n"
"Session ID\n"
"Session ID\n"
"Opaque sub-type code\n"
"Opaque sub-type code\n")
{
int proto;
proto = proto_redistnum(AFI_IP, proto_str);
sharp_opaque_reg_send((reg != NULL), proto, instance, session, type);
return CMD_SUCCESS;
}
DEFPY (neigh_discover,
neigh_discover_cmd,
"sharp neigh discover [vrf NAME$vrf_name] <A.B.C.D$dst4|X:X::X:X$dst6> IFNAME$ifname",
SHARP_STR
"Discover neighbours\n"
"Send an ARP/NDP request\n"
VRF_CMD_HELP_STR
"v4 Destination address\n"
"v6 Destination address\n"
"Interface name\n")
{
struct vrf *vrf;
struct interface *ifp;
struct prefix prefix;
memset(&prefix, 0, sizeof(prefix));
if (dst4.s_addr != 0) {
prefix.family = AF_INET;
prefix.prefixlen = 32;
prefix.u.prefix4 = dst4;
} else {
prefix.family = AF_INET6;
prefix.prefixlen = 128;
prefix.u.prefix6 = dst6;
}
vrf = vrf_lookup_by_name(vrf_name ? vrf_name : VRF_DEFAULT_NAME);
if (!vrf) {
vty_out(vty, "The vrf NAME specified: %s does not exist\n",
vrf_name ? vrf_name : VRF_DEFAULT_NAME);
return CMD_WARNING;
}
ifp = if_lookup_by_name_vrf(ifname, vrf);
if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n", ifname);
return CMD_WARNING;
}
sharp_zebra_send_arp(ifp, &prefix);
return CMD_SUCCESS;
}
void sharp_vty_init(void)
{
install_element(ENABLE_NODE, &install_routes_data_dump_cmd);
install_element(ENABLE_NODE, &install_routes_cmd);
install_element(ENABLE_NODE, &remove_routes_cmd);
install_element(ENABLE_NODE, &vrf_label_cmd);
install_element(ENABLE_NODE, &sharp_nht_data_dump_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v6_cmd);
install_element(ENABLE_NODE, &watch_nexthop_v4_cmd);
install_element(ENABLE_NODE, &sharp_lsp_prefix_v4_cmd);
install_element(ENABLE_NODE, &sharp_remove_lsp_prefix_v4_cmd);
install_element(ENABLE_NODE, &logpump_cmd);
install_element(ENABLE_NODE, &create_session_cmd);
install_element(ENABLE_NODE, &remove_session_cmd);
install_element(ENABLE_NODE, &send_opaque_cmd);
install_element(ENABLE_NODE, &send_opaque_unicast_cmd);
install_element(ENABLE_NODE, &send_opaque_reg_cmd);
install_element(ENABLE_NODE, &neigh_discover_cmd);
install_element(VIEW_NODE, &show_debugging_sharpd_cmd);
return;
}
|