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