blob: 0b06d0ec5153618cc3158be1fe844f3ad3965070 [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 }
60 if (PIM_DEBUG_PIM_TRACE) {
61 vty_out(vty, "debug pim trace%s", VTY_NEWLINE);
62 ++writes;
63 }
64
65 if (PIM_DEBUG_ZEBRA) {
66 vty_out(vty, "debug pim zebra%s", VTY_NEWLINE);
67 ++writes;
68 }
69
Everton Marques824adbe2009-10-08 09:16:27 -030070 if (PIM_DEBUG_SSMPINGD) {
71 vty_out(vty, "debug ssmpingd%s", VTY_NEWLINE);
72 ++writes;
73 }
74
Everton Marques871dbcf2009-08-11 15:43:05 -030075 return writes;
76}
77
78int pim_global_config_write(struct vty *vty)
79{
80 int writes = 0;
81
82 if (PIM_MROUTE_IS_ENABLED) {
83 vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE);
84 ++writes;
85 }
86
Everton Marques824adbe2009-10-08 09:16:27 -030087 if (qpim_ssmpingd_list) {
88 struct listnode *node;
89 struct ssmpingd_sock *ss;
90 vty_out(vty, "!%s", VTY_NEWLINE);
91 ++writes;
92 for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
93 char source_str[100];
94 pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
95 vty_out(vty, "ip ssmpingd %s%s", source_str, VTY_NEWLINE);
96 ++writes;
97 }
98 }
99
Everton Marques871dbcf2009-08-11 15:43:05 -0300100 return writes;
101}
102
103int pim_interface_config_write(struct vty *vty)
104{
105 int writes = 0;
106 struct listnode *node;
107 struct interface *ifp;
108
109 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
110
111 /* IF name */
112 vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300113 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300114
115 if (ifp->info) {
116 struct pim_interface *pim_ifp = ifp->info;
117
118 /* IF ip pim ssm */
119 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
120 vty_out(vty, " ip pim ssm%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300121 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300122 }
123
124 /* IF ip igmp */
125 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
126 vty_out(vty, " ip igmp%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300127 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300128 }
129
130 /* IF ip igmp query-interval */
131 vty_out(vty, " %s %d%s",
132 PIM_CMD_IP_IGMP_QUERY_INTERVAL,
133 pim_ifp->igmp_default_query_interval,
134 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300135 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300136
137 /* IF ip igmp query-max-response-time */
138 vty_out(vty, " %s %d%s",
139 PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
140 pim_ifp->igmp_query_max_response_time_dsec,
141 VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300142 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300143
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);
Everton Marques824adbe2009-10-08 09:16:27 -0300156 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300157 }
158 }
159 }
160 vty_out(vty, "!%s", VTY_NEWLINE);
Everton Marques824adbe2009-10-08 09:16:27 -0300161 ++writes;
Everton Marques871dbcf2009-08-11 15:43:05 -0300162 }
163
164 return writes;
165}