3 * Copyright (C) Cumulus Networks, Inc.
6 * This file is part of FRR.
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include "sharpd/sharp_zebra.h"
33 #include "sharpd/sharp_vty.h"
34 #ifndef VTYSH_EXTRACT_PL
35 #include "sharpd/sharp_vty_clippy.c"
38 extern uint32_t total_routes
;
39 extern uint32_t installed_routes
;
40 extern uint32_t removed_routes
;
42 DEFPY (install_routes
,
44 "sharp install routes A.B.C.D$start nexthop A.B.C.D$nexthop (1-1000000)$routes",
45 "Sharp routing Protocol\n"
46 "install some routes\n"
48 "Address to start /32 generation at\n"
51 "How many to create\n")
58 total_routes
= routes
;
61 memset(&p
, 0, sizeof(p
));
62 memset(&nhop
, 0, sizeof(nhop
));
68 nhop
.gate
.ipv4
= nexthop
;
69 nhop
.type
= NEXTHOP_TYPE_IPV4
;
71 zlog_debug("Inserting %ld routes", routes
);
73 temp
= ntohl(p
.u
.prefix4
.s_addr
);
74 for (i
= 0 ; i
< routes
; i
++) {
76 p
.u
.prefix4
.s_addr
= htonl(++temp
);
82 DEFPY(vrf_label
, vrf_label_cmd
,
83 "sharp label <ip$ipv4|ipv6$ipv6> vrf NAME$name label (0-100000)$label",
84 "Sharp Routing Protocol\n"
85 "Give a vrf a label\n"
86 "Pop and forward for IPv4\n"
87 "Pop and forward for IPv6\n"
89 "The label to use, 0 specifies remove the label installed from previous\n"
90 "Specified range to use\n")
93 afi_t afi
= (ipv4
) ? AFI_IP
: AFI_IP6
;
95 if (strcmp(name
, "default") == 0)
96 vrf
= vrf_lookup_by_id(VRF_DEFAULT
);
98 vrf
= vrf_lookup_by_name(name
);
101 vty_out(vty
, "Unable to find vrf you silly head");
102 return CMD_WARNING_CONFIG_FAILED
;
106 label
= MPLS_LABEL_NONE
;
108 vrf_label_add(vrf
->vrf_id
, afi
, label
);
112 DEFPY (remove_routes
,
114 "sharp remove routes A.B.C.D$start (1-1000000)$routes",
115 "Sharp Routing Protocol\n"
116 "Remove some routes\n"
119 "Routes to uniinstall\n")
125 total_routes
= routes
;
128 memset(&p
, 0, sizeof(p
));
134 zlog_debug("Removing %ld routes", routes
);
136 temp
= ntohl(p
.u
.prefix4
.s_addr
);
137 for (i
= 0; i
< routes
; i
++) {
139 p
.u
.prefix4
.s_addr
= htonl(++temp
);
145 void sharp_vty_init(void)
147 install_element(ENABLE_NODE
, &install_routes_cmd
);
148 install_element(ENABLE_NODE
, &remove_routes_cmd
);
149 install_element(ENABLE_NODE
, &vrf_label_cmd
);