blob: 3a1abf1343b980e3b9d82027a407b484fbc08970 [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"
Everton Marques871dbcf2009-08-11 15:43:05 -030034
35int pim_debug_config_write(struct vty *vty)
36{
37 int writes = 0;
38
39 if (PIM_DEBUG_IGMP_EVENTS) {
40 vty_out(vty, "debug igmp events%s", VTY_NEWLINE);
41 ++writes;
42 }
43 if (PIM_DEBUG_IGMP_PACKETS) {
44 vty_out(vty, "debug igmp packets%s", VTY_NEWLINE);
45 ++writes;
46 }
47 if (PIM_DEBUG_IGMP_TRACE) {
48 vty_out(vty, "debug igmp trace%s", VTY_NEWLINE);
49 ++writes;
50 }
51
52 if (PIM_DEBUG_PIM_EVENTS) {
53 vty_out(vty, "debug pim events%s", VTY_NEWLINE);
54 ++writes;
55 }
56 if (PIM_DEBUG_PIM_PACKETS) {
57 vty_out(vty, "debug pim packets%s", VTY_NEWLINE);
58 ++writes;
59 }
Everton Marques62738042009-11-18 10:44:13 -020060 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
61 vty_out(vty, "debug pim packet-dump send%s", VTY_NEWLINE);
62 ++writes;
63 }
64 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
65 vty_out(vty, "debug pim packet-dump receive%s", VTY_NEWLINE);
66 ++writes;
67 }
Everton Marques871dbcf2009-08-11 15:43:05 -030068 if (PIM_DEBUG_PIM_TRACE) {
69 vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
70 ++writes;
71 }
72
73 if (PIM_DEBUG_ZEBRA) {
74 vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
75 ++writes;
76 }
77
Everton Marques824adbe2009-10-08 09:16:27 -030078 if (PIM_DEBUG_SSMPINGD) {
79 vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
80 ++writes;
81 }
82
Everton Marques871dbcf2009-08-11 15:43:05 -030083 return writes;
84}
85
86int pim_global_config_write(struct vty *vty)
87{
88 int writes = 0;
89
90 if (PIM_MROUTE_IS_ENABLED) {
91 vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
92 ++writes;
93 }
94
Everton Marques824adbe2009-10-08 09:16:27 -030095 if (qpim_ssmpingd_list) {
96 struct listnode *node;
97 struct ssmpingd_sock *ss;
98 vty_out(vty, "!%s", VTY_NEWLINE);
99 ++writes;
100 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
101 char source_str[100];
102 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
103 vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
104 ++writes;
105 }
106 }
107
Everton Marques871dbcf2009-08-11 15:43:05 -0300108 return writes;
109}
110
111int pim_interface_config_write(struct vty *vty)
112{
113 int writes = 0;
114 struct listnode *node;
115 struct interface *ifp;
116
117 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
118
119 /* IF name */
120 vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300121 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300122
123 if (ifp->info) {
124 struct pim_interface *pim_ifp = ifp->info;
125
126 /* IF ip pim ssm */
127 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
128 vty_out(vty, " ip pim ssm%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300129 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300130 }
131
132 /* IF ip igmp */
133 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
134 vty_out(vty, " ip igmp%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300135 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300136 }
137
138 /* IF ip igmp query-interval */
139 vty_out(vty, " %s %d%s",
140 PIM_CMD_IP_IGMP_QUERY_INTERVAL,
141 pim_ifp->igmp_default_query_interval,
142 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300143 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300144
145 /* IF ip igmp query-max-response-time */
146 vty_out(vty, " %s %d%s",
147 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
148 pim_ifp->igmp_query_max_response_time_dsec,
149 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300150 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300151
152 /* IF ip igmp join */
153 if (pim_ifp->igmp_join_list) {
154 struct listnode *node;
155 struct igmp_join *ij;
156 for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, node, ij)) {
157 char group_str[100];
158 char source_str[100];
159 pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
160 pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
161 vty_out(vty, " ip igmp join %s %s%s",
162 group_str, source_str,
163 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300164 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300165 }
166 }
167 }
168 vty_out(vty, "!%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300169 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300170 }
171
172 return writes;
173}