pim_vty.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. PIM for Quagga
  3. Copyright (C) 2008 Everton da Silva Marques
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  15. MA 02110-1301 USA
  16. $QuaggaId: $Format:%an, %ai, %h$ $
  17. */
  18. #include <zebra.h>
  19. #include "if.h"
  20. #include "linklist.h"
  21. #include "pimd.h"
  22. #include "pim_vty.h"
  23. #include "pim_iface.h"
  24. #include "pim_cmd.h"
  25. #include "pim_str.h"
  26. #include "pim_ssmpingd.h"
  27. #include "pim_pim.h"
  28. #include "pim_static.h"
  29. int pim_debug_config_write(struct vty *vty)
  30. {
  31. int writes = 0;
  32. if (PIM_DEBUG_IGMP_EVENTS) {
  33. vty_out(vty, "debug igmp events%s", VTY_NEWLINE);
  34. ++writes;
  35. }
  36. if (PIM_DEBUG_IGMP_PACKETS) {
  37. vty_out(vty, "debug igmp packets%s", VTY_NEWLINE);
  38. ++writes;
  39. }
  40. if (PIM_DEBUG_IGMP_TRACE) {
  41. vty_out(vty, "debug igmp trace%s", VTY_NEWLINE);
  42. ++writes;
  43. }
  44. if (PIM_DEBUG_MROUTE) {
  45. vty_out(vty, "debug mroute%s", VTY_NEWLINE);
  46. ++writes;
  47. }
  48. if (PIM_DEBUG_PIM_EVENTS) {
  49. vty_out(vty, "debug pim events%s", VTY_NEWLINE);
  50. ++writes;
  51. }
  52. if (PIM_DEBUG_PIM_PACKETS) {
  53. vty_out(vty, "debug pim packets%s", VTY_NEWLINE);
  54. ++writes;
  55. }
  56. if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
  57. vty_out(vty, "debug pim packet-dump send%s", VTY_NEWLINE);
  58. ++writes;
  59. }
  60. if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
  61. vty_out(vty, "debug pim packet-dump receive%s", VTY_NEWLINE);
  62. ++writes;
  63. }
  64. if (PIM_DEBUG_PIM_TRACE) {
  65. vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
  66. ++writes;
  67. }
  68. if (PIM_DEBUG_ZEBRA) {
  69. vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
  70. ++writes;
  71. }
  72. if (PIM_DEBUG_SSMPINGD) {
  73. vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
  74. ++writes;
  75. }
  76. return writes;
  77. }
  78. int pim_global_config_write(struct vty *vty)
  79. {
  80. int writes = 0;
  81. if (PIM_MROUTE_IS_ENABLED) {
  82. vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
  83. ++writes;
  84. }
  85. if (qpim_ssmpingd_list) {
  86. struct listnode *node;
  87. struct ssmpingd_sock *ss;
  88. vty_out(vty, "!%s", VTY_NEWLINE);
  89. ++writes;
  90. for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
  91. char source_str[100];
  92. pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
  93. vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
  94. ++writes;
  95. }
  96. }
  97. return writes;
  98. }
  99. int pim_interface_config_write(struct vty *vty)
  100. {
  101. int writes = 0;
  102. struct listnode *node;
  103. struct interface *ifp;
  104. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  105. /* IF name */
  106. vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
  107. ++writes;
  108. if (ifp->info) {
  109. struct pim_interface *pim_ifp = ifp->info;
  110. /* IF ip pim ssm */
  111. if (PIM_IF_TEST_PIM(pim_ifp->options)) {
  112. vty_out(vty, " ip pim ssm%s", VTY_NEWLINE);
  113. ++writes;
  114. }
  115. /* IF ip pim drpriority */
  116. if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
  117. vty_out(vty, " ip pim drpriority %d%s", pim_ifp->pim_dr_priority,
  118. VTY_NEWLINE);
  119. ++writes;
  120. }
  121. /* IF ip pim hello */
  122. if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
  123. vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period);
  124. if (pim_ifp->pim_default_holdtime != -1)
  125. vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
  126. vty_out(vty, "%s", VTY_NEWLINE);
  127. }
  128. /* IF ip igmp */
  129. if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
  130. vty_out(vty, " ip igmp%s", VTY_NEWLINE);
  131. ++writes;
  132. }
  133. /* IF ip igmp query-interval */
  134. if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL)
  135. {
  136. vty_out(vty, " %s %d%s",
  137. PIM_CMD_IP_IGMP_QUERY_INTERVAL,
  138. pim_ifp->igmp_default_query_interval,
  139. VTY_NEWLINE);
  140. ++writes;
  141. }
  142. /* IF ip igmp query-max-response-time */
  143. if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC)
  144. {
  145. vty_out(vty, " %s %d%s",
  146. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
  147. pim_ifp->igmp_query_max_response_time_dsec,
  148. VTY_NEWLINE);
  149. ++writes;
  150. }
  151. /* IF ip igmp join */
  152. if (pim_ifp->igmp_join_list) {
  153. struct listnode *node;
  154. struct igmp_join *ij;
  155. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, node, ij)) {
  156. char group_str[100];
  157. char source_str[100];
  158. pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
  159. pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
  160. vty_out(vty, " ip igmp join %s %s%s",
  161. group_str, source_str,
  162. VTY_NEWLINE);
  163. ++writes;
  164. }
  165. }
  166. writes += pim_static_write_mroute (vty, ifp);
  167. }
  168. vty_out(vty, "!%s", VTY_NEWLINE);
  169. ++writes;
  170. }
  171. return writes;
  172. }