diff options
Diffstat (limited to 'zebra/debug.c')
| -rw-r--r-- | zebra/debug.c | 109 |
1 files changed, 46 insertions, 63 deletions
diff --git a/zebra/debug.c b/zebra/debug.c index 93cd4dd9c6..98770371d8 100644 --- a/zebra/debug.c +++ b/zebra/debug.c @@ -14,10 +14,9 @@ * 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 GNU Zebra; see the file COPYING. If not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * 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> @@ -124,52 +123,31 @@ DEFUN (debug_zebra_mpls, DEFUN (debug_zebra_packet, debug_zebra_packet_cmd, - "debug zebra packet", - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n") -{ - zebra_debug_packet = ZEBRA_DEBUG_PACKET; - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - return CMD_SUCCESS; -} - -DEFUN (debug_zebra_packet_direct, - debug_zebra_packet_direct_cmd, - "debug zebra packet (recv|send|detail)", + "debug zebra packet [<recv|send>] [detail]", DEBUG_STR "Zebra configuration\n" "Debug option set for zebra packet\n" "Debug option set for receive packet\n" - "Debug option set for send packet\n") + "Debug option set for send packet\n" + "Debug option set for detailed info\n") { + int idx = 0; zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + + if (argv_find (argv, argc, "send", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + idx = 0; + if (argv_find (argv, argc, "recv", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - if (strncmp ("detail", argv[0], strlen (argv[0])) == 0) + idx = 0; + if (argv_find (argv, argc, "detail", &idx)) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); - return CMD_SUCCESS; -} -DEFUN (debug_zebra_packet_detail, - debug_zebra_packet_detail_cmd, - "debug zebra packet (recv|send) detail", - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n" - "Debug option set for receive packet\n" - "Debug option set for send packet\n" - "Debug option set detailed information\n") -{ - zebra_debug_packet = ZEBRA_DEBUG_PACKET; - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + if (!(zebra_debug_packet & ZEBRA_DEBUG_SEND & ZEBRA_DEBUG_RECV)) + { SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); - SET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_DETAIL); + } return CMD_SUCCESS; } @@ -186,7 +164,7 @@ DEFUN (debug_zebra_kernel, DEFUN (debug_zebra_kernel_msgdump, debug_zebra_kernel_msgdump_cmd, - "debug zebra kernel msgdump {recv|send}", + "debug zebra kernel msgdump [<recv|send>]", DEBUG_STR "Zebra configuration\n" "Debug option set for zebra between kernel interface\n" @@ -194,10 +172,12 @@ DEFUN (debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0)) + int idx = 0; + if (argc == 4 || argv_find (argv, argc, "recv", &idx)) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0)) + if (argc == 4 || argv_find (argv, argc, "send", &idx)) SET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); + return CMD_SUCCESS; } @@ -273,19 +253,7 @@ DEFUN (no_debug_zebra_mpls, DEFUN (no_debug_zebra_packet, no_debug_zebra_packet_cmd, - "no debug zebra packet", - NO_STR - DEBUG_STR - "Zebra configuration\n" - "Debug option set for zebra packet\n") -{ - zebra_debug_packet = 0; - return CMD_SUCCESS; -} - -DEFUN (no_debug_zebra_packet_direct, - no_debug_zebra_packet_direct_cmd, - "no debug zebra packet (recv|send)", + "no debug zebra packet [<recv|send>]", NO_STR DEBUG_STR "Zebra configuration\n" @@ -293,9 +261,10 @@ DEFUN (no_debug_zebra_packet_direct, "Debug option set for receive packet\n" "Debug option set for send packet\n") { - if (strncmp ("send", argv[0], strlen (argv[0])) == 0) + int idx = 0; + if (argc == 4 || argv_find (argv, argc, "send", &idx)) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_SEND); - if (strncmp ("recv", argv[0], strlen (argv[0])) == 0) + if (argc == 4 || argv_find (argv, argc, "recv", &idx)) UNSET_FLAG(zebra_debug_packet, ZEBRA_DEBUG_RECV); return CMD_SUCCESS; } @@ -314,7 +283,8 @@ DEFUN (no_debug_zebra_kernel, DEFUN (no_debug_zebra_kernel_msgdump, no_debug_zebra_kernel_msgdump_cmd, - "no debug zebra kernel msgdump {recv|send}", + "no debug zebra kernel msgdump [<recv|send>]", + NO_STR DEBUG_STR "Zebra configuration\n" "Debug option set for zebra between kernel interface\n" @@ -322,10 +292,12 @@ DEFUN (no_debug_zebra_kernel_msgdump, "Dump raw netlink messages received\n" "Dump raw netlink messages sent\n") { - if (!argv[1] || (argv[0] && strncmp(argv[0], "recv", strlen(argv[0])) == 0)) + int idx = 0; + if (argc == 5 || argv_find (argv, argc, "recv", &idx)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV); - if (!argv[0] || (argv[1] && strncmp(argv[1], "send", strlen(argv[1])) == 0)) + if (argc == 5 || argv_find (argv, argc, "send", &idx)) UNSET_FLAG(zebra_debug_kernel, ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND); + return CMD_SUCCESS; } @@ -411,6 +383,16 @@ config_write_debug (struct vty *vty) vty_out (vty, "debug zebra kernel%s", VTY_NEWLINE); write++; } + if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_RECV) + { + vty_out (vty, "debug zebra kernel msgdump recv%s", VTY_NEWLINE); + write++; + } + if (IS_ZEBRA_DEBUG_KERNEL_MSGDUMP_SEND) + { + vty_out (vty, "debug zebra kernel msgdump send%s", VTY_NEWLINE); + write++; + } /* Check here using flags as the 'macro' does an OR */ if (CHECK_FLAG (zebra_debug_rib, ZEBRA_DEBUG_RIB)) { @@ -427,6 +409,11 @@ config_write_debug (struct vty *vty) vty_out (vty, "debug zebra fpm%s", VTY_NEWLINE); write++; } + if (IS_ZEBRA_DEBUG_NHT) + { + vty_out (vty, "debug zebra nht%s", VTY_NEWLINE); + write++; + } if (IS_ZEBRA_DEBUG_MPLS) { vty_out (vty, "debug zebra mpls%s", VTY_NEWLINE); @@ -453,8 +440,6 @@ zebra_debug_init (void) install_element (ENABLE_NODE, &debug_zebra_nht_cmd); install_element (ENABLE_NODE, &debug_zebra_mpls_cmd); install_element (ENABLE_NODE, &debug_zebra_packet_cmd); - install_element (ENABLE_NODE, &debug_zebra_packet_direct_cmd); - install_element (ENABLE_NODE, &debug_zebra_packet_detail_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_cmd); install_element (ENABLE_NODE, &debug_zebra_kernel_msgdump_cmd); install_element (ENABLE_NODE, &debug_zebra_rib_cmd); @@ -474,8 +459,6 @@ zebra_debug_init (void) install_element (CONFIG_NODE, &debug_zebra_nht_cmd); install_element (CONFIG_NODE, &debug_zebra_mpls_cmd); install_element (CONFIG_NODE, &debug_zebra_packet_cmd); - install_element (CONFIG_NODE, &debug_zebra_packet_direct_cmd); - install_element (CONFIG_NODE, &debug_zebra_packet_detail_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_cmd); install_element (CONFIG_NODE, &debug_zebra_kernel_msgdump_cmd); install_element (CONFIG_NODE, &debug_zebra_rib_cmd); |
