blob: 56de83c8bc590b8fe1bef75d27d68ecb0ea91da9 [file] [log] [blame]
Everton Marques871dbcf2009-08-11 15:43:05 -03001/*
2 PIM for Quagga
3 Copyright (C) 2008 Everton da Silva Marques
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING; if not, write to the
17 Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
18 MA 02110-1301 USA
19
20 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#include <zebra.h>
24
25#include "if.h"
26#include "linklist.h"
27
28#include "pimd.h"
29#include "pim_vty.h"
30#include "pim_iface.h"
31#include "pim_cmd.h"
32#include "pim_str.h"
Everton Marques824adbe2009-10-08 09:16:27 -030033#include "pim_ssmpingd.h"
Donald Sharp6ae80e02015-06-18 18:14:20 -070034#include "pim_pim.h"
Donald Sharp18343ee2016-06-02 02:30:46 -040035#include "pim_static.h"
Everton Marques871dbcf2009-08-11 15:43:05 -030036
37int pim_debug_config_write(struct vty *vty)
38{
39 int writes = 0;
40
41 if (PIM_DEBUG_IGMP_EVENTS) {
42 vty_out(vty, "debug igmp events%s", VTY_NEWLINE);
43 ++writes;
44 }
45 if (PIM_DEBUG_IGMP_PACKETS) {
46 vty_out(vty, "debug igmp packets%s", VTY_NEWLINE);
47 ++writes;
48 }
49 if (PIM_DEBUG_IGMP_TRACE) {
50 vty_out(vty, "debug igmp trace%s", VTY_NEWLINE);
51 ++writes;
52 }
53
Everton Marques67faabc2010-02-23 12:11:11 -030054 if (PIM_DEBUG_MROUTE) {
55 vty_out(vty, "debug mroute%s", VTY_NEWLINE);
56 ++writes;
57 }
58
Everton Marques871dbcf2009-08-11 15:43:05 -030059 if (PIM_DEBUG_PIM_EVENTS) {
60 vty_out(vty, "debug pim events%s", VTY_NEWLINE);
61 ++writes;
62 }
63 if (PIM_DEBUG_PIM_PACKETS) {
64 vty_out(vty, "debug pim packets%s", VTY_NEWLINE);
65 ++writes;
66 }
Everton Marques62738042009-11-18 10:44:13 -020067 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
68 vty_out(vty, "debug pim packet-dump send%s", VTY_NEWLINE);
69 ++writes;
70 }
71 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
72 vty_out(vty, "debug pim packet-dump receive%s", VTY_NEWLINE);
73 ++writes;
74 }
Everton Marques871dbcf2009-08-11 15:43:05 -030075 if (PIM_DEBUG_PIM_TRACE) {
76 vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
77 ++writes;
78 }
79
80 if (PIM_DEBUG_ZEBRA) {
81 vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
82 ++writes;
83 }
84
Everton Marques824adbe2009-10-08 09:16:27 -030085 if (PIM_DEBUG_SSMPINGD) {
86 vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
87 ++writes;
88 }
89
Everton Marques871dbcf2009-08-11 15:43:05 -030090 return writes;
91}
92
93int pim_global_config_write(struct vty *vty)
94{
95 int writes = 0;
96
97 if (PIM_MROUTE_IS_ENABLED) {
98 vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
99 ++writes;
100 }
101
Everton Marques824adbe2009-10-08 09:16:27 -0300102 if (qpim_ssmpingd_list) {
103 struct listnode *node;
104 struct ssmpingd_sock *ss;
105 vty_out(vty, "!%s", VTY_NEWLINE);
106 ++writes;
107 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
108 char source_str[100];
109 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
110 vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
111 ++writes;
112 }
113 }
114
Everton Marques871dbcf2009-08-11 15:43:05 -0300115 return writes;
116}
117
118int pim_interface_config_write(struct vty *vty)
119{
120 int writes = 0;
121 struct listnode *node;
122 struct interface *ifp;
123
124 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
125
126 /* IF name */
127 vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300128 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300129
130 if (ifp->info) {
131 struct pim_interface *pim_ifp = ifp->info;
132
133 /* IF ip pim ssm */
134 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
135 vty_out(vty, " ip pim ssm%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300136 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300137 }
138
Donald Sharp6ae80e02015-06-18 18:14:20 -0700139 /* IF ip pim drpriority */
140 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
141 vty_out(vty, " ip pim drpriority %d%s", pim_ifp->pim_dr_priority,
142 VTY_NEWLINE);
143 ++writes;
144 }
145
Donald Sharp22e02242015-08-21 19:35:27 -0400146 /* IF ip pim hello */
147 if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
148 vty_out(vty, " ip pim hello %d", pim_ifp->pim_hello_period);
149 if (pim_ifp->pim_default_holdtime != -1)
150 vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
151 vty_out(vty, "%s", VTY_NEWLINE);
152 }
153
Everton Marques871dbcf2009-08-11 15:43:05 -0300154 /* IF ip igmp */
155 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
156 vty_out(vty, " ip igmp%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300157 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300158 }
159
160 /* IF ip igmp query-interval */
Donald Sharp0cee0382015-09-30 09:10:12 -0400161 if (pim_ifp->igmp_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL)
162 {
163 vty_out(vty, " %s %d%s",
164 PIM_CMD_IP_IGMP_QUERY_INTERVAL,
165 pim_ifp->igmp_default_query_interval,
166 VTY_NEWLINE);
167 ++writes;
168 }
Everton Marques871dbcf2009-08-11 15:43:05 -0300169
170 /* IF ip igmp query-max-response-time */
Donald Sharp0cee0382015-09-30 09:10:12 -0400171 if (pim_ifp->igmp_query_max_response_time_dsec != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC)
172 {
173 vty_out(vty, " %s %d%s",
174 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
175 pim_ifp->igmp_query_max_response_time_dsec,
176 VTY_NEWLINE);
177 ++writes;
178 }
Everton Marques871dbcf2009-08-11 15:43:05 -0300179
180 /* IF ip igmp join */
181 if (pim_ifp->igmp_join_list) {
182 struct listnode *node;
183 struct igmp_join *ij;
184 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, node, ij)) {
185 char group_str[100];
186 char source_str[100];
187 pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
188 pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
189 vty_out(vty, " ip igmp join %s %s%s",
190 group_str, source_str,
191 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300192 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300193 }
194 }
Donald Sharp18343ee2016-06-02 02:30:46 -0400195
196 writes += pim_static_write_mroute (vty, ifp);
Everton Marques871dbcf2009-08-11 15:43:05 -0300197 }
198 vty_out(vty, "!%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300199 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300200 }
201
202 return writes;
203}