]> git.proxmox.com Git - mirror_frr.git/blobdiff - vtysh/extract.pl.in
zebra: Refactor kernel_rtm to be a bit smarter about how it handles options
[mirror_frr.git] / vtysh / extract.pl.in
index f33c7b9603a10c7ac3a24586dadfb96135e4e13a..596f01738ad19a09bd8fe904d82a3a2dcad4e844 100755 (executable)
@@ -29,16 +29,18 @@ print <<EOF;
 #include "command.h"
 #include "linklist.h"
 
-#include "vtysh.h"
+#include "vtysh/vtysh.h"
 
 EOF
 
 my $cli_stomp = 0;
 
-foreach (@ARGV) {
-    $file = $_;
+sub scan_file {
+    my ( $file, $fabricd) = @_;
+
+    $cppadd = $fabricd ? "-DFABRICD=1" : "";
 
-    open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -I@top_builddir@ -I@srcdir@/ -I@srcdir@/.. -I@top_srcdir@/lib -I@top_builddir@/lib -I@top_srcdir@/bgpd -I@top_srcdir@/@LIBRFP@ -I@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $file |");
+    open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -Ivtysh/@top_builddir@ -Ivtysh/@top_srcdir@ -Ivtysh/@top_srcdir@/lib -Ivtysh/@top_builddir@/lib -Ivtysh/@top_srcdir@/bgpd -Ivtysh/@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $cppadd $file |");
     local $/; undef $/;
     $line = <FH>;
     close (FH);
@@ -77,14 +79,24 @@ foreach (@ARGV) {
         $cmd =~ s/^\s+//g;
         $cmd =~ s/\s+$//g;
 
+        if ($fabricd) {
+            $cmd = "fabricd_" . $cmd;
+        }
+
         # $protocol is VTYSH_PROTO format for redirection of user input
         if ($file =~ /lib\/keychain\.c$/) {
-            $protocol = "VTYSH_RIPD";
+            $protocol = "VTYSH_RIPD|VTYSH_EIGRPD";
         }
         elsif ($file =~ /lib\/routemap\.c$/) {
-            $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD";
+            $protocol = "VTYSH_RMAP";
         }
         elsif ($file =~ /lib\/vrf\.c$/) {
+            $protocol = "VTYSH_VRF";
+        }
+        elsif ($file =~ /lib\/if\.c$/) {
+            $protocol = "VTYSH_INTERFACE";
+        }
+        elsif ($file =~ /lib\/logicalrouter\.c$/) {
             $protocol = "VTYSH_ALL";
         }
         elsif ($file =~ /lib\/filter\.c$/) {
@@ -96,11 +108,14 @@ foreach (@ARGV) {
         elsif ($file =~ /lib\/ns\.c$/) {
             $protocol = "VTYSH_ZEBRA";
         }
+       elsif ($file =~ /lib\/nexthop_group\.c$/) {
+           $protocol = "VTYSH_PBRD";
+       }
         elsif ($file =~ /lib\/plist\.c$/) {
             if ($defun_array[1] =~ m/ipv6/) {
-                $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_BABELD";
+                $protocol = "VTYSH_RIPNGD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD";
             } else {
-                $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD";
+                $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD|VTYSH_ZEBRA|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_BABELD|VTYSH_ISISD|VTYSH_FABRICD";
             }
         }
         elsif ($file =~ /lib\/distribute\.c$/) {
@@ -123,6 +138,9 @@ foreach (@ARGV) {
         elsif ($file =~ /librfp\/.*\.c$/ || $file =~ /rfapi\/.*\.c$/) {
            $protocol = "VTYSH_BGPD";
         }
+        elsif ($fabricd) {
+           $protocol = "VTYSH_FABRICD";
+        }
         else {
            ($protocol) = ($file =~ /^.*\/([a-z0-9]+)\/[a-zA-Z0-9_\-]+\.c$/);
            $protocol = "VTYSH_" . uc $protocol;
@@ -161,6 +179,10 @@ foreach (@ARGV) {
         $ecmd =~ s/^\s+//g;
         $ecmd =~ s/\s+$//g;
 
+        if ($fabricd) {
+            $ecmd = "fabricd_" . $ecmd;
+        }
+
         # Register $ecmd
         if (defined ($cmd2str{$ecmd})) {
             my ($key);
@@ -178,6 +200,24 @@ foreach (@ARGV) {
     }
 }
 
+foreach (@ARGV) {
+    if (/\/isisd\//) {
+        # We scan all the IS-IS files twice, once for isisd,
+        # once for fabricd. Exceptions are made for the files
+        # that are not shared between the two.
+        if (/isis_vty_isisd.c/) {
+            scan_file($_, 0);
+        } elsif (/isis_vty_fabricd.c/) {
+            scan_file($_, 1);
+        } else {
+            scan_file($_, 0);
+            scan_file($_, 1);
+        }
+    } else {
+        scan_file($_, 0);
+    }
+}
+
 # When we have cli commands that map to the same function name, we
 # can introduce subtle bugs due to code not being called when
 # we think it is.