pim_vty.c 4.3 KB

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