Browse Source

[pim] pim commands added to vtysh

Leonard Herve 10 years ago
parent
commit
596470f2a4
7 changed files with 207 additions and 153 deletions
  1. 151 151
      pimd/pim_cmd.c
  2. 25 0
      pimd/pim_main.c
  3. 13 0
      pimd/pim_mroute.c
  4. 13 0
      pimd/pim_sock.c
  5. 1 0
      vtysh/Makefile.am
  6. 2 0
      vtysh/vtysh.c
  7. 2 2
      vtysh/vtysh.h

+ 151 - 151
pimd/pim_cmd.c

@@ -54,9 +54,9 @@ static struct cmd_node pim_global_node = {
   1 /* vtysh ? yes */
 };
 
-static struct cmd_node pim_interface_node = {
+static struct cmd_node interface_node = {
   INTERFACE_NODE,
-  "%s(config-if-pim)# ",
+  "%s(config-if)# ",
   1 /* vtysh ? yes */
 };
 
@@ -3767,157 +3767,157 @@ DEFUN (test_pim_receive_upcall,
 
 void pim_cmd_init()
 {
-  install_node(&pim_global_node, pim_global_config_write);       /* PIM_NODE */
-  install_node(&pim_interface_node, pim_interface_config_write); /* INTERFACE_NODE */
+  install_node (&pim_global_node, pim_global_config_write);       /* PIM_NODE */
+  install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
 
-  install_element(CONFIG_NODE, &ip_multicast_routing_cmd);
-  install_element(CONFIG_NODE, &no_ip_multicast_routing_cmd);
+  install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
+  install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
 #if 0
-  install_element(CONFIG_NODE, &interface_cmd); /* from if.h */
+  install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
 #else
-  install_element(CONFIG_NODE, &pim_interface_cmd);
+  install_element (CONFIG_NODE, &pim_interface_cmd);
 #endif
-  install_element(CONFIG_NODE, &no_interface_cmd); /* from if.h */
-
-  install_default(INTERFACE_NODE);
-  install_element(INTERFACE_NODE, &interface_ip_igmp_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_igmp_cmd); 
-  install_element(INTERFACE_NODE, &interface_ip_igmp_join_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_igmp_join_cmd); 
-  install_element(INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd); 
-  install_element(INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd); 
-  install_element(INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd); 
-  install_element(INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
-  install_element(INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd); 
-
-  install_element(VIEW_NODE, &show_ip_igmp_interface_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_parameters_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_groups_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_sources_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
-  install_element(VIEW_NODE, &show_ip_igmp_querier_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_assert_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_assert_internal_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_assert_metric_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_dr_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_hello_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_interface_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_join_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_local_membership_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_neighbor_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_rpf_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_secondary_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_upstream_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
-  install_element(VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
-  install_element(VIEW_NODE, &show_ip_multicast_cmd);
-  install_element(VIEW_NODE, &show_ip_mroute_cmd);
-  install_element(VIEW_NODE, &show_ip_mroute_count_cmd);
-  install_element(VIEW_NODE, &show_ip_route_cmd);
-  install_element(VIEW_NODE, &show_debugging_cmd);
-
-  install_element(ENABLE_NODE, &clear_ip_interfaces_cmd);
-  install_element(ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
-  install_element(ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
-
-  install_element(ENABLE_NODE, &show_ip_igmp_interface_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_parameters_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_groups_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_sources_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
-  install_element(ENABLE_NODE, &show_ip_igmp_querier_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_address_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_assert_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_dr_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_hello_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_interface_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_join_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_local_membership_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_neighbor_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_rpf_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_secondary_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_upstream_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
-  install_element(ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
-  install_element(ENABLE_NODE, &show_ip_multicast_cmd);
-  install_element(ENABLE_NODE, &show_ip_mroute_cmd);
-  install_element(ENABLE_NODE, &show_ip_mroute_count_cmd);
-  install_element(ENABLE_NODE, &show_ip_route_cmd);
-  install_element(ENABLE_NODE, &show_debugging_cmd);
-
-  install_element(ENABLE_NODE, &test_igmp_receive_report_cmd);
-  install_element(ENABLE_NODE, &test_pim_receive_assert_cmd);
-  install_element(ENABLE_NODE, &test_pim_receive_hello_cmd);
-  install_element(ENABLE_NODE, &test_pim_receive_join_cmd);
-  install_element(ENABLE_NODE, &test_pim_receive_prune_cmd);
-  install_element(ENABLE_NODE, &test_pim_receive_upcall_cmd);
-
-  install_element(ENABLE_NODE, &debug_igmp_cmd);
-  install_element(ENABLE_NODE, &no_debug_igmp_cmd);
-  install_element(ENABLE_NODE, &undebug_igmp_cmd);
-  install_element(ENABLE_NODE, &debug_igmp_events_cmd);
-  install_element(ENABLE_NODE, &no_debug_igmp_events_cmd);
-  install_element(ENABLE_NODE, &undebug_igmp_events_cmd);
-  install_element(ENABLE_NODE, &debug_igmp_packets_cmd);
-  install_element(ENABLE_NODE, &no_debug_igmp_packets_cmd);
-  install_element(ENABLE_NODE, &undebug_igmp_packets_cmd);
-  install_element(ENABLE_NODE, &debug_igmp_trace_cmd);
-  install_element(ENABLE_NODE, &no_debug_igmp_trace_cmd);
-  install_element(ENABLE_NODE, &undebug_igmp_trace_cmd);
-  install_element(ENABLE_NODE, &debug_pim_cmd);
-  install_element(ENABLE_NODE, &no_debug_pim_cmd);
-  install_element(ENABLE_NODE, &undebug_pim_cmd);
-  install_element(ENABLE_NODE, &debug_pim_events_cmd);
-  install_element(ENABLE_NODE, &no_debug_pim_events_cmd);
-  install_element(ENABLE_NODE, &undebug_pim_events_cmd);
-  install_element(ENABLE_NODE, &debug_pim_packets_cmd);
-  install_element(ENABLE_NODE, &no_debug_pim_packets_cmd);
-  install_element(ENABLE_NODE, &undebug_pim_packets_cmd);
-  install_element(ENABLE_NODE, &debug_pim_trace_cmd);
-  install_element(ENABLE_NODE, &no_debug_pim_trace_cmd);
-  install_element(ENABLE_NODE, &undebug_pim_trace_cmd);
-  install_element(ENABLE_NODE, &debug_pim_zebra_cmd);
-  install_element(ENABLE_NODE, &no_debug_pim_zebra_cmd);
-  install_element(ENABLE_NODE, &undebug_pim_zebra_cmd);
-
-  install_element(CONFIG_NODE, &debug_igmp_cmd);
-  install_element(CONFIG_NODE, &no_debug_igmp_cmd);
-  install_element(CONFIG_NODE, &undebug_igmp_cmd);
-  install_element(CONFIG_NODE, &debug_igmp_events_cmd);
-  install_element(CONFIG_NODE, &no_debug_igmp_events_cmd);
-  install_element(CONFIG_NODE, &undebug_igmp_events_cmd);
-  install_element(CONFIG_NODE, &debug_igmp_packets_cmd);
-  install_element(CONFIG_NODE, &no_debug_igmp_packets_cmd);
-  install_element(CONFIG_NODE, &undebug_igmp_packets_cmd);
-  install_element(CONFIG_NODE, &debug_igmp_trace_cmd);
-  install_element(CONFIG_NODE, &no_debug_igmp_trace_cmd);
-  install_element(CONFIG_NODE, &undebug_igmp_trace_cmd);
-  install_element(CONFIG_NODE, &debug_pim_cmd);
-  install_element(CONFIG_NODE, &no_debug_pim_cmd);
-  install_element(CONFIG_NODE, &undebug_pim_cmd);
-  install_element(CONFIG_NODE, &debug_pim_events_cmd);
-  install_element(CONFIG_NODE, &no_debug_pim_events_cmd);
-  install_element(CONFIG_NODE, &undebug_pim_events_cmd);
-  install_element(CONFIG_NODE, &debug_pim_packets_cmd);
-  install_element(CONFIG_NODE, &no_debug_pim_packets_cmd);
-  install_element(CONFIG_NODE, &undebug_pim_packets_cmd);
-  install_element(CONFIG_NODE, &debug_pim_trace_cmd);
-  install_element(CONFIG_NODE, &no_debug_pim_trace_cmd);
-  install_element(CONFIG_NODE, &undebug_pim_trace_cmd);
-  install_element(CONFIG_NODE, &debug_pim_zebra_cmd);
-  install_element(CONFIG_NODE, &no_debug_pim_zebra_cmd);
-  install_element(CONFIG_NODE, &undebug_pim_zebra_cmd);
+  install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
+
+  install_default (INTERFACE_NODE);
+  install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd); 
+  install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd); 
+  install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd); 
+  install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd); 
+  install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd); 
+  install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
+  install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd); 
+
+  install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
+  install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_join_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
+  install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
+  install_element (VIEW_NODE, &show_ip_multicast_cmd);
+  install_element (VIEW_NODE, &show_ip_mroute_cmd);
+  install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
+  install_element (VIEW_NODE, &show_ip_route_cmd);
+  install_element (VIEW_NODE, &show_debugging_cmd);
+
+  install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
+  install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
+  install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
+
+  install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
+  install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
+  install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
+  install_element (ENABLE_NODE, &show_ip_multicast_cmd);
+  install_element (ENABLE_NODE, &show_ip_mroute_cmd);
+  install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
+  install_element (ENABLE_NODE, &show_ip_route_cmd);
+  install_element (ENABLE_NODE, &show_debugging_cmd);
+
+  install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
+  install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
+  install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
+  install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
+  install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
+  install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
+
+  install_element (ENABLE_NODE, &debug_igmp_cmd);
+  install_element (ENABLE_NODE, &no_debug_igmp_cmd);
+  install_element (ENABLE_NODE, &undebug_igmp_cmd);
+  install_element (ENABLE_NODE, &debug_igmp_events_cmd);
+  install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
+  install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
+  install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
+  install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
+  install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
+  install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
+  install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
+  install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
+  install_element (ENABLE_NODE, &debug_pim_cmd);
+  install_element (ENABLE_NODE, &no_debug_pim_cmd);
+  install_element (ENABLE_NODE, &undebug_pim_cmd);
+  install_element (ENABLE_NODE, &debug_pim_events_cmd);
+  install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
+  install_element (ENABLE_NODE, &undebug_pim_events_cmd);
+  install_element (ENABLE_NODE, &debug_pim_packets_cmd);
+  install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
+  install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
+  install_element (ENABLE_NODE, &debug_pim_trace_cmd);
+  install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
+  install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
+  install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
+  install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
+  install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
+
+  install_element (CONFIG_NODE, &debug_igmp_cmd);
+  install_element (CONFIG_NODE, &no_debug_igmp_cmd);
+  install_element (CONFIG_NODE, &undebug_igmp_cmd);
+  install_element (CONFIG_NODE, &debug_igmp_events_cmd);
+  install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
+  install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
+  install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
+  install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
+  install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
+  install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
+  install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
+  install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
+  install_element (CONFIG_NODE, &debug_pim_cmd);
+  install_element (CONFIG_NODE, &no_debug_pim_cmd);
+  install_element (CONFIG_NODE, &undebug_pim_cmd);
+  install_element (CONFIG_NODE, &debug_pim_events_cmd);
+  install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
+  install_element (CONFIG_NODE, &undebug_pim_events_cmd);
+  install_element (CONFIG_NODE, &debug_pim_packets_cmd);
+  install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
+  install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
+  install_element (CONFIG_NODE, &debug_pim_trace_cmd);
+  install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
+  install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
+  install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
+  install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
+  install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
 }

+ 25 - 0
pimd/pim_main.c

@@ -23,6 +23,7 @@
 #include <zebra.h>
 
 #include "log.h"
+#include "privs.h" 
 #include "version.h"
 #include <getopt.h>
 #include "command.h"
@@ -61,6 +62,29 @@ struct option longopts[] = {
   { 0 }
 };
 
+/* pimd privileges */
+zebra_capabilities_t _caps_p [] = 
+{
+  ZCAP_NET_ADMIN,
+  ZCAP_SYS_ADMIN,
+  ZCAP_NET_RAW,
+};
+
+/* pimd privileges to run with */
+struct zebra_privs_t pimd_privs =
+{
+#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP)
+  .user = QUAGGA_USER,
+  .group = QUAGGA_GROUP,
+#endif
+#ifdef VTY_GROUP
+  .vty_group = VTY_GROUP,
+#endif
+  .caps_p = _caps_p,
+  .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
+  .cap_num_i = 0
+};
+
 char* progname;
 const char *pid_file = PATH_PIMD_PID;
 
@@ -170,6 +194,7 @@ int main(int argc, char** argv, char** envp) {
   /* 
    * Initializations
    */
+  zprivs_init (&pimd_privs);
   pim_signals_init();
   cmd_init(1);
   vty_init(master);

+ 13 - 0
pimd/pim_mroute.c

@@ -22,6 +22,7 @@
 
 #include <zebra.h>
 #include "log.h"
+#include "privs.h"
 
 #include "pimd.h"
 #include "pim_mroute.h"
@@ -30,6 +31,9 @@
 #include "pim_iface.h"
 #include "pim_macro.h"
 
+/* GLOBAL VARS */
+extern struct zebra_privs_t pimd_privs;
+
 static void mroute_read_on(void);
 
 static int pim_mroute_set(int fd, int enable)
@@ -259,7 +263,16 @@ int pim_mroute_socket_enable()
   if (PIM_MROUTE_IS_ENABLED)
     return -1;
 
+  if ( pimd_privs.change (ZPRIVS_RAISE) )
+    zlog_err ("pim_mroute_socket_enable: could not raise privs, %s",
+              safe_strerror (errno) );
+
   fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP);
+
+  if ( pimd_privs.change (ZPRIVS_LOWER) )
+    zlog_err ("pim_mroute_socket_enable: could not lower privs, %s",
+	      safe_strerror (errno) );
+
   if (fd < 0) {
     zlog_warn("Could not create mroute socket: errno=%d: %s",
 	      errno, strerror(errno));

+ 13 - 0
pimd/pim_sock.c

@@ -33,11 +33,15 @@
 
 #include <zebra.h>
 #include "log.h"
+#include "privs.h"
 
 #include "pimd.h"
 #include "pim_sock.h"
 #include "pim_str.h"
 
+/* GLOBAL VARS */
+extern struct zebra_privs_t pimd_privs;
+
 #ifndef MCAST_JOIN_SOURCE_GROUP
 #define MCAST_JOIN_SOURCE_GROUP 46
 struct group_source_req
@@ -52,7 +56,16 @@ int pim_socket_raw(int protocol)
 {
   int fd;
 
+  if ( pimd_privs.change (ZPRIVS_RAISE) )
+       zlog_err ("pim_sockek_raw: could not raise privs, %s",
+                 safe_strerror (errno) );
+
   fd = socket(AF_INET, SOCK_RAW, protocol);
+
+  if ( pimd_privs.change (ZPRIVS_LOWER) )
+       zlog_err ("pim_socket_raw: could not lower privs, %s",
+                 safe_strerror (errno) );
+
   if (fd < 0) {
     zlog_warn("Could not create raw socket: errno=%d: %s",
 	      errno, strerror(errno));

+ 1 - 0
vtysh/Makefile.am

@@ -25,6 +25,7 @@ vtysh_cmd_FILES = $(top_srcdir)/bgpd/*.c $(top_srcdir)/isisd/*.c \
 		  $(top_srcdir)/ospfd/*.c $(top_srcdir)/ospf6d/*.c \
 		  $(top_srcdir)/ripd/*.c $(top_srcdir)/ripngd/*.c \
 		  $(top_srcdir)/babeld/*.c \
+		  $(top_srcdir)/pimd/pim_cmd.c \
 		  $(top_srcdir)/lib/keychain.c $(top_srcdir)/lib/routemap.c \
 		  $(top_srcdir)/lib/filter.c $(top_srcdir)/lib/plist.c \
 		  $(top_srcdir)/lib/distribute.c $(top_srcdir)/lib/if_rmap.c \

+ 2 - 0
vtysh/vtysh.c

@@ -59,6 +59,8 @@ struct vtysh_client
   { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH},
   { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH},
   { .fd = -1, .name = "babeld", .flag = VTYSH_BABELD, .path = BABEL_VTYSH_PATH},
+  { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH},
+>>>>>>> [pim] pim commands added to vtysh
 };
 
 

+ 2 - 2
vtysh/vtysh.h

@@ -30,9 +30,9 @@
 #define VTYSH_BGPD   0x20
 #define VTYSH_ISISD  0x40
 #define VTYSH_BABELD  0x80
-#define VTYSH_ALL	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_BABELD
+#define VTYSH_ALL	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_BABELD|VTYSH_PIMD
 #define VTYSH_RMAP	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_BABELD
-#define VTYSH_INTERFACE	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_BABELD
+#define VTYSH_INTERFACE	  VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_ISISD|VTYSH_BABELD|VTYSH_PIMD
 
 /* vtysh local configuration file. */
 #define VTYSH_DEFAULT_CONFIG "vtysh.conf"