]> git.proxmox.com Git - mirror_frr.git/blobdiff - sharpd/sharp_vty.c
Merge pull request #2974 from donaldsharp/v4_and_v6
[mirror_frr.git] / sharpd / sharp_vty.c
index 0e7d1f2c29758f4529f4cd051a690480a25b41f4..9462eb575c602473cc48622264a917d27a1678dd 100644 (file)
@@ -39,16 +39,59 @@ extern uint32_t total_routes;
 extern uint32_t installed_routes;
 extern uint32_t removed_routes;
 
+DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
+      "sharp watch nexthop X:X::X:X$nhop",
+      "Sharp routing Protocol\n"
+      "Watch for changes\n"
+      "Watch for nexthop changes\n"
+      "The v6 nexthop to signal for watching\n")
+{
+       struct prefix p;
+
+       memset(&p, 0, sizeof(p));
+
+       p.prefixlen = 128;
+       memcpy(&p.u.prefix6, &nhop, 16);
+       p.family = AF_INET6;
+
+       sharp_zebra_nexthop_watch(&p, true);
+
+       return CMD_SUCCESS;
+}
+
+DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
+      "sharp watch nexthop A.B.C.D$nhop",
+      "Sharp routing Protocol\n"
+      "Watch for changes\n"
+      "Watch for nexthop changes\n"
+      "The v4 nexthop to signal for watching\n")
+{
+       struct prefix p;
+
+       memset(&p, 0, sizeof(p));
+
+       p.prefixlen = 32;
+       p.u.prefix4 = nhop;
+       p.family = AF_INET;
+
+       sharp_zebra_nexthop_watch(&p, true);
+
+       return CMD_SUCCESS;
+}
+
 DEFPY (install_routes,
        install_routes_cmd,
-       "sharp install routes A.B.C.D$start nexthop A.B.C.D$nexthop (1-1000000)$routes",
+       "sharp install routes A.B.C.D$start nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6> (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp routing Protocol\n"
        "install some routes\n"
        "Routes to install\n"
        "Address to start /32 generation at\n"
-       "Nexthop to use\n"
-       "Nexthop address\n"
-       "How many to create\n")
+       "Nexthop to use(Can be an IPv4 or IPv6 address)\n"
+       "V4 Nexthop address to use\n"
+       "V6 Nexthop address to use\n"
+       "How many to create\n"
+       "Instance to use\n"
+       "Instance\n")
 {
        int i;
        struct prefix p;
@@ -65,14 +108,19 @@ DEFPY (install_routes,
        p.prefixlen = 32;
        p.u.prefix4 = start;
 
-       nhop.gate.ipv4 = nexthop;
-       nhop.type = NEXTHOP_TYPE_IPV4;
+       if (nexthop4.s_addr != INADDR_ANY) {
+               nhop.gate.ipv4 = nexthop4;
+               nhop.type = NEXTHOP_TYPE_IPV4;
+       } else {
+               memcpy(&nhop.gate.ipv6, &nexthop6, IPV6_MAX_BYTELEN);
+               nhop.type = NEXTHOP_TYPE_IPV6;
+       }
 
        zlog_debug("Inserting %ld routes", routes);
 
        temp = ntohl(p.u.prefix4.s_addr);
-       for (i = 0 ; i < routes ; i++) {
-               route_add(&p, &nhop);
+       for (i = 0; i < routes; i++) {
+               route_add(&p, (uint8_t)instance, &nhop);
                p.u.prefix4.s_addr = htonl(++temp);
        }
 
@@ -111,17 +159,18 @@ DEFPY(vrf_label, vrf_label_cmd,
 
 DEFPY (remove_routes,
        remove_routes_cmd,
-       "sharp remove routes A.B.C.D$start (1-1000000)$routes",
+       "sharp remove routes A.B.C.D$start (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp Routing Protocol\n"
        "Remove some routes\n"
        "Routes to remove\n"
        "Starting spot\n"
-       "Routes to uniinstall\n")
+       "Routes to uniinstall\n"
+       "instance to use\n"
+       "Value of instance\n")
 {
        int i;
        struct prefix p;
        uint32_t temp;
-
        total_routes = routes;
        removed_routes = 0;
 
@@ -134,8 +183,8 @@ DEFPY (remove_routes,
        zlog_debug("Removing %ld routes", routes);
 
        temp = ntohl(p.u.prefix4.s_addr);
-       for (i = 0; i < routes ; i++) {
-               route_delete(&p);
+       for (i = 0; i < routes; i++) {
+               route_delete(&p, (uint8_t)instance);
                p.u.prefix4.s_addr = htonl(++temp);
        }
 
@@ -147,5 +196,7 @@ void sharp_vty_init(void)
        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, &watch_nexthop_v6_cmd);
+       install_element(ENABLE_NODE, &watch_nexthop_v4_cmd);
        return;
 }