pim_vty.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. int pim_debug_config_write(struct vty *vty)
  29. {
  30. int writes = 0;
  31. if (PIM_DEBUG_IGMP_EVENTS) {
  32. vty_out(vty, "debug igmp events%s", VTY_NEWLINE);
  33. ++writes;
  34. }
  35. if (PIM_DEBUG_IGMP_PACKETS) {
  36. vty_out(vty, "debug igmp packets%s", VTY_NEWLINE);
  37. ++writes;
  38. }
  39. if (PIM_DEBUG_IGMP_TRACE) {
  40. vty_out(vty, "debug igmp trace%s", VTY_NEWLINE);
  41. ++writes;
  42. }
  43. if (PIM_DEBUG_MROUTE) {
  44. vty_out(vty, "debug mroute%s", VTY_NEWLINE);
  45. ++writes;
  46. }
  47. if (PIM_DEBUG_PIM_EVENTS) {
  48. vty_out(vty, "debug pim events%s", VTY_NEWLINE);
  49. ++writes;
  50. }
  51. if (PIM_DEBUG_PIM_PACKETS) {
  52. vty_out(vty, "debug pim packets%s", VTY_NEWLINE);
  53. ++writes;
  54. }
  55. if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
  56. vty_out(vty, "debug pim packet-dump send%s", VTY_NEWLINE);
  57. ++writes;
  58. }
  59. if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
  60. vty_out(vty, "debug pim packet-dump receive%s", VTY_NEWLINE);
  61. ++writes;
  62. }
  63. if (PIM_DEBUG_PIM_TRACE) {
  64. vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
  65. ++writes;
  66. }
  67. if (PIM_DEBUG_ZEBRA) {
  68. vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
  69. ++writes;
  70. }
  71. if (PIM_DEBUG_SSMPINGD) {
  72. vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
  73. ++writes;
  74. }
  75. return writes;
  76. }
  77. int pim_global_config_write(struct vty *vty)
  78. {
  79. int writes = 0;
  80. if (PIM_MROUTE_IS_ENABLED) {
  81. vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
  82. ++writes;
  83. }
  84. if (qpim_ssmpingd_list) {
  85. struct listnode *node;
  86. struct ssmpingd_sock *ss;
  87. vty_out(vty, "!%s", VTY_NEWLINE);
  88. ++writes;
  89. for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
  90. char source_str[100];
  91. pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
  92. vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
  93. ++writes;
  94. }
  95. }
  96. return writes;
  97. }
  98. int pim_interface_config_write(struct vty *vty)
  99. {
  100. int writes = 0;
  101. struct listnode *node;
  102. struct interface *ifp;
  103. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  104. /* IF name */
  105. vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
  106. ++writes;
  107. if (ifp->info) {
  108. struct pim_interface *pim_ifp = ifp->info;
  109. /* IF ip pim ssm */
  110. if (PIM_IF_TEST_PIM(pim_ifp->options)) {
  111. vty_out(vty, " ip pim ssm%s", VTY_NEWLINE);
  112. ++writes;
  113. }
  114. /* IF ip pim drpriority */
  115. if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
  116. vty_out(vty, " ip pim drpriority %d%s", pim_ifp->pim_dr_priority,
  117. VTY_NEWLINE);
  118. ++writes;
  119. }
  120. /* IF ip pim hello */
  121. if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
  122. vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period);
  123. if (pim_ifp->pim_default_holdtime != -1)
  124. vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
  125. vty_out(vty, "%s", VTY_NEWLINE);
  126. }
  127. /* IF ip igmp */
  128. if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
  129. vty_out(vty, " ip igmp%s", VTY_NEWLINE);
  130. ++writes;
  131. }
  132. /* IF ip igmp query-interval */
  133. vty_out(vty, " %s %d%s",
  134. PIM_CMD_IP_IGMP_QUERY_INTERVAL,
  135. pim_ifp->igmp_default_query_interval,
  136. VTY_NEWLINE);
  137. ++writes;
  138. /* IF ip igmp query-max-response-time */
  139. vty_out(vty, " %s %d%s",
  140. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
  141. pim_ifp->igmp_query_max_response_time_dsec,
  142. VTY_NEWLINE);
  143. ++writes;
  144. /* IF ip igmp join */
  145. if (pim_ifp->igmp_join_list) {
  146. struct listnode *node;
  147. struct igmp_join *ij;
  148. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, node, ij)) {
  149. char group_str[100];
  150. char source_str[100];
  151. pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
  152. pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
  153. vty_out(vty, " ip igmp join %s %s%s",
  154. group_str, source_str,
  155. VTY_NEWLINE);
  156. ++writes;
  157. }
  158. }
  159. }
  160. vty_out(vty, "!%s", VTY_NEWLINE);
  161. ++writes;
  162. }
  163. return writes;
  164. }