]>
git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_dump.c
3 * Copyright (C) 1999-2002 Yasuhiro Ohara
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 /* Include other stuffs */
28 #include "ospf6_dump.h"
37 struct cmd_element cmd
[CMD_MAX
];
43 struct ospf6_dump
*ospf6_dump
[DUMP_MAX
];
44 unsigned int dump_size
= 0;
47 ospf6_dump_index (struct cmd_element
*cmd
, int command
)
51 for (i
= 0; i
< DUMP_MAX
; i
++)
53 if (cmd
!= &ospf6_dump
[i
]->cmd
[command
])
64 ospf6_dump_is_on (int index
)
66 if (ospf6_dump
[index
] == NULL
)
69 return ospf6_dump
[index
]->config
;
73 ospf6_dump_show (struct cmd_element
*cmd
,
74 struct vty
*vty
, int argc
, char **argv
)
78 index
= ospf6_dump_index (cmd
, CMD_SHOW
);
81 vty_out (vty
, " %-16s: %s%s", ospf6_dump
[index
]->name
,
82 (ospf6_dump
[index
]->config
? "on" : "off"),
88 ospf6_dump_enable (struct cmd_element
*cmd
,
89 struct vty
*vty
, int argc
, char **argv
)
93 index
= ospf6_dump_index (cmd
, CMD_ENABLE
);
96 ospf6_dump
[index
]->config
= 1;
101 ospf6_dump_disable (struct cmd_element
*cmd
,
102 struct vty
*vty
, int argc
, char **argv
)
106 index
= ospf6_dump_index (cmd
, CMD_DISABLE
);
107 assert (index
!= -1);
109 ospf6_dump
[index
]->config
= 0;
114 ospf6_dump_install (char *name
, char *help
)
116 struct cmd_element
*cmd
;
118 char helpstring
[256];
120 if (dump_size
+ 1 >= DUMP_MAX
)
123 ospf6_dump
[dump_size
] = malloc (sizeof (struct ospf6_dump
));
124 if (ospf6_dump
[dump_size
] == NULL
)
126 memset (ospf6_dump
[dump_size
], 0, sizeof (struct ospf6_dump
));
128 ospf6_dump
[dump_size
]->name
= strdup (name
);
130 cmd
= &ospf6_dump
[dump_size
]->cmd
[CMD_SHOW
];
131 snprintf (string
, sizeof (string
), "show debugging ospf6 %s", name
);
132 snprintf (helpstring
, sizeof (helpstring
), "%s%s%s%s",
133 SHOW_STR
, DEBUG_STR
, OSPF6_STR
, help
);
134 memset (cmd
, 0, sizeof (struct cmd_element
));
135 cmd
->string
= strdup (string
);
136 cmd
->func
= ospf6_dump_show
;
137 cmd
->doc
= strdup (helpstring
);
138 install_element (VIEW_NODE
, cmd
);
139 install_element (ENABLE_NODE
, cmd
);
141 cmd
= &ospf6_dump
[dump_size
]->cmd
[CMD_ENABLE
];
142 snprintf (string
, sizeof (string
), "debug ospf6 %s", name
);
143 snprintf (helpstring
, sizeof (helpstring
), "%s%s%s",
144 DEBUG_STR
, OSPF6_STR
, help
);
145 memset (cmd
, 0, sizeof (struct cmd_element
));
146 cmd
->string
= strdup (string
);
147 cmd
->func
= ospf6_dump_enable
;
148 cmd
->doc
= strdup (helpstring
);
149 install_element (CONFIG_NODE
, cmd
);
151 cmd
= &ospf6_dump
[dump_size
]->cmd
[CMD_DISABLE
];
152 snprintf (string
, sizeof (string
), "no debug ospf6 %s", name
);
153 snprintf (helpstring
, sizeof (helpstring
), "%s%s%s%s",
154 NO_STR
, DEBUG_STR
, OSPF6_STR
, help
);
155 memset (cmd
, 0, sizeof (struct cmd_element
));
156 cmd
->string
= strdup (string
);
157 cmd
->func
= ospf6_dump_disable
;
158 cmd
->doc
= strdup (helpstring
);
159 install_element (CONFIG_NODE
, cmd
);
164 DEFUN(show_debug_ospf6
,
165 show_debug_ospf6_cmd
,
166 "show debugging ospf6",
173 vty_out (vty
, "OSPF6 debugging status:%s", VTY_NEWLINE
);
175 for (i
= 0; i
< DUMP_MAX
; i
++)
177 if (ospf6_dump
[i
] == NULL
)
179 ospf6_dump_show (&ospf6_dump
[i
]->cmd
[CMD_SHOW
], vty
, 0, NULL
);
185 DEFUN (debug_ospf6_all
,
190 "Turn on ALL OSPFv3 debugging\n")
194 for (i
= 0; i
< DUMP_MAX
; i
++)
196 if (ospf6_dump
[i
] == NULL
)
198 ospf6_dump_enable (&ospf6_dump
[i
]->cmd
[CMD_ENABLE
], vty
, 0, NULL
);
204 DEFUN (no_debug_ospf6_all
,
205 no_debug_ospf6_all_cmd
,
206 "no debug ospf6 all",
210 "Turn off ALL OSPFv3 debugging\n")
214 for (i
= 0; i
< DUMP_MAX
; i
++)
216 if (ospf6_dump
[i
] == NULL
)
218 ospf6_dump_disable (&ospf6_dump
[i
]->cmd
[CMD_DISABLE
], vty
, 0, NULL
);
224 struct cmd_node debug_node
=
232 ospf6_dump_config_write (struct vty
*vty
)
236 for (i
= 0; i
< dump_size
; i
++)
238 if (ospf6_dump
[i
] == NULL
)
241 if (ospf6_dump
[i
]->config
== 0)
244 vty_out (vty
, "debug ospf6 %s%s", ospf6_dump
[i
]->name
, VTY_NEWLINE
);
247 vty_out (vty
, "!%s", VTY_NEWLINE
);
251 char dump_index
[OSPF6_DUMP_MAX
];
256 memset (ospf6_dump
, 0, sizeof (ospf6_dump
));
258 install_node (&debug_node
, ospf6_dump_config_write
);
260 install_element (VIEW_NODE
, &show_debug_ospf6_cmd
);
261 install_element (ENABLE_NODE
, &show_debug_ospf6_cmd
);
263 install_element (CONFIG_NODE
, &debug_ospf6_all_cmd
);
264 install_element (CONFIG_NODE
, &no_debug_ospf6_all_cmd
);
266 /* bellow is for backward compatibility
267 should be moved to each modules */
269 #define MESSAGE_STR "OSPFv3 Messages\n"
271 dump_index
[OSPF6_DUMP_HELLO
] =
272 ospf6_dump_install ("message hello",
273 MESSAGE_STR
"Hello\n");
274 dump_index
[OSPF6_DUMP_DBDESC
] =
275 ospf6_dump_install ("message dbdesc",
276 MESSAGE_STR
"Database Description\n");
277 dump_index
[OSPF6_DUMP_LSREQ
] =
278 ospf6_dump_install ("message lsreq",
279 MESSAGE_STR
"Link State Request\n");
280 dump_index
[OSPF6_DUMP_LSUPDATE
] =
281 ospf6_dump_install ("message lsupdate",
282 MESSAGE_STR
"Link State Update\n");
283 dump_index
[OSPF6_DUMP_LSACK
] =
284 ospf6_dump_install ("message lsack",
285 MESSAGE_STR
"Link State Acknowledge\n");
286 dump_index
[OSPF6_DUMP_NEIGHBOR
] =
287 ospf6_dump_install ("neighbor", "Neighbors\n");
288 dump_index
[OSPF6_DUMP_INTERFACE
] =
289 ospf6_dump_install ("interface", "Interfaces\n");
290 dump_index
[OSPF6_DUMP_LSA
] =
291 ospf6_dump_install ("lsa", "Link State Advertisement\n");
292 dump_index
[OSPF6_DUMP_ZEBRA
] =
293 ospf6_dump_install ("zebra", "Communication with zebra\n");
294 dump_index
[OSPF6_DUMP_CONFIG
] =
295 ospf6_dump_install ("config", "Configuration Changes\n");
296 dump_index
[OSPF6_DUMP_DBEX
] =
297 ospf6_dump_install ("dbex", "Database Exchange/Flooding\n");
298 dump_index
[OSPF6_DUMP_SPF
] =
299 ospf6_dump_install ("spf", "SPF Calculation\n");
300 dump_index
[OSPF6_DUMP_ROUTE
] =
301 ospf6_dump_install ("route", "Route Calculation\n");
302 dump_index
[OSPF6_DUMP_LSDB
] =
303 ospf6_dump_install ("lsdb", "Link State Database\n");
304 dump_index
[OSPF6_DUMP_REDISTRIBUTE
] =
305 ospf6_dump_install ("redistribute",
306 "Route Exchange with other protocols\n");
307 dump_index
[OSPF6_DUMP_HOOK
] =
308 ospf6_dump_install ("hook", "Hooks\n");
309 dump_index
[OSPF6_DUMP_ASBR
] =
310 ospf6_dump_install ("asbr", "AS Boundary Router function\n");
311 dump_index
[OSPF6_DUMP_PREFIX
] =
312 ospf6_dump_install ("prefix", "Prefix\n");