]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_zebra.c
[cleanup] functions taking no args should be declared with void args
[mirror_frr.git] / ospf6d / ospf6_zebra.c
CommitLineData
718e3744 1/*
508e53e2 2 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
508e53e2 22#include <zebra.h>
23
24#include "log.h"
25#include "vty.h"
26#include "command.h"
27#include "prefix.h"
28#include "stream.h"
29#include "zclient.h"
30#include "memory.h"
718e3744 31
508e53e2 32#include "ospf6_proto.h"
33#include "ospf6_top.h"
718e3744 34#include "ospf6_interface.h"
508e53e2 35#include "ospf6_route.h"
36#include "ospf6_lsa.h"
049207c3 37#include "ospf6_lsdb.h"
718e3744 38#include "ospf6_asbr.h"
508e53e2 39#include "ospf6_zebra.h"
049207c3 40#include "ospf6d.h"
718e3744 41
508e53e2 42unsigned char conf_debug_ospf6_zebra = 0;
718e3744 43
44/* information about zebra. */
45struct zclient *zclient = NULL;
46
18a6dce6 47struct in_addr router_id_zebra;
48
49/* Router-id update message from zebra. */
6ac29a51 50static int
18a6dce6 51ospf6_router_id_update_zebra (int command, struct zclient *zclient,
52 zebra_size_t length)
53{
54 struct prefix router_id;
55 struct ospf6 *o = ospf6;
56
57 zebra_router_id_update_read(zclient->ibuf,&router_id);
58 router_id_zebra = router_id.u.prefix4;
59
c1ba9e8a 60 if (o == NULL)
61 return 0;
62
18a6dce6 63 if (o->router_id == 0)
64 o->router_id = (u_int32_t) router_id_zebra.s_addr;
65
66 return 0;
67}
68
718e3744 69/* redistribute function */
70void
71ospf6_zebra_redistribute (int type)
72{
718e3744 73 if (zclient->redist[type])
74 return;
718e3744 75 zclient->redist[type] = 1;
718e3744 76 if (zclient->sock > 0)
634f9ea2 77 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
718e3744 78}
79
80void
81ospf6_zebra_no_redistribute (int type)
82{
508e53e2 83 if (! zclient->redist[type])
718e3744 84 return;
718e3744 85 zclient->redist[type] = 0;
718e3744 86 if (zclient->sock > 0)
634f9ea2 87 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
718e3744 88}
89
718e3744 90/* Inteface addition message from zebra. */
6ac29a51 91static int
718e3744 92ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)
93{
94 struct interface *ifp;
95
96 ifp = zebra_interface_add_read (zclient->ibuf);
508e53e2 97 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
c6487d61 98 zlog_debug ("Zebra Interface add: %s index %d mtu %d",
99 ifp->name, ifp->ifindex, ifp->mtu6);
718e3744 100 ospf6_interface_if_add (ifp);
718e3744 101 return 0;
102}
103
6ac29a51 104static int
718e3744 105ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)
106{
508e53e2 107 struct interface *ifp;
718e3744 108
d2fc8896 109 if (!(ifp = zebra_interface_state_read(zclient->ibuf)))
110 return 0;
111
112 if (if_is_up (ifp))
113 zlog_warn ("Zebra: got delete of %s, but interface is still up", ifp->name);
114
508e53e2 115 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
c6487d61 116 zlog_debug ("Zebra Interface delete: %s index %d mtu %d",
117 ifp->name, ifp->ifindex, ifp->mtu6);
718e3744 118
d2fc8896 119#if 0
120 /* Why is this commented out? */
718e3744 121 ospf6_interface_if_del (ifp);
508e53e2 122#endif /*0*/
d2fc8896 123
124 ifp->ifindex = IFINDEX_INTERNAL;
718e3744 125 return 0;
126}
127
6ac29a51 128static int
718e3744 129ospf6_zebra_if_state_update (int command, struct zclient *zclient,
130 zebra_size_t length)
131{
132 struct interface *ifp;
133
134 ifp = zebra_interface_state_read (zclient->ibuf);
508e53e2 135 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
c6487d61 136 zlog_debug ("Zebra Interface state change: "
137 "%s index %d flags %ld metric %d mtu %d",
138 ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6);
718e3744 139
140 ospf6_interface_state_update (ifp);
141 return 0;
142}
143
6ac29a51 144static int
718e3744 145ospf6_zebra_if_address_update_add (int command, struct zclient *zclient,
508e53e2 146 zebra_size_t length)
718e3744 147{
148 struct connected *c;
149 char buf[128];
150
0a589359 151 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf);
718e3744 152 if (c == NULL)
153 return 0;
154
508e53e2 155 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
c6487d61 156 zlog_debug ("Zebra Interface address add: %s %5s %s/%d",
157 c->ifp->name, prefix_family_str (c->address),
158 inet_ntop (c->address->family, &c->address->u.prefix,
159 buf, sizeof (buf)), c->address->prefixlen);
718e3744 160
161 if (c->address->family == AF_INET6)
508e53e2 162 ospf6_interface_connected_route_update (c->ifp);
718e3744 163
164 return 0;
165}
166
6ac29a51 167static int
718e3744 168ospf6_zebra_if_address_update_delete (int command, struct zclient *zclient,
169 zebra_size_t length)
170{
171 struct connected *c;
172 char buf[128];
173
0a589359 174 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf);
718e3744 175 if (c == NULL)
176 return 0;
177
508e53e2 178 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
c6487d61 179 zlog_debug ("Zebra Interface address delete: %s %5s %s/%d",
180 c->ifp->name, prefix_family_str (c->address),
181 inet_ntop (c->address->family, &c->address->u.prefix,
182 buf, sizeof (buf)), c->address->prefixlen);
718e3744 183
184 if (c->address->family == AF_INET6)
508e53e2 185 ospf6_interface_connected_route_update (c->ifp);
718e3744 186
187 return 0;
188}
189
6ac29a51 190static int
718e3744 191ospf6_zebra_read_ipv6 (int command, struct zclient *zclient,
192 zebra_size_t length)
193{
194 struct stream *s;
195 struct zapi_ipv6 api;
196 unsigned long ifindex;
197 struct prefix_ipv6 p;
198 struct in6_addr *nexthop;
718e3744 199
200 s = zclient->ibuf;
201 ifindex = 0;
202 nexthop = NULL;
203 memset (&api, 0, sizeof (api));
204
205 /* Type, flags, message. */
206 api.type = stream_getc (s);
207 api.flags = stream_getc (s);
208 api.message = stream_getc (s);
209
210 /* IPv6 prefix. */
211 memset (&p, 0, sizeof (struct prefix_ipv6));
212 p.family = AF_INET6;
213 p.prefixlen = stream_getc (s);
214 stream_get (&p.prefix, s, PSIZE (p.prefixlen));
215
216 /* Nexthop, ifindex, distance, metric. */
217 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
218 {
219 api.nexthop_num = stream_getc (s);
220 nexthop = (struct in6_addr *)
221 malloc (api.nexthop_num * sizeof (struct in6_addr));
222 stream_get (nexthop, s, api.nexthop_num * sizeof (struct in6_addr));
223 }
224 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
225 {
226 api.ifindex_num = stream_getc (s);
227 ifindex = stream_getl (s);
228 }
229 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
230 api.distance = stream_getc (s);
231 else
232 api.distance = 0;
233 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
234 api.metric = stream_getl (s);
235 else
236 api.metric = 0;
237
508e53e2 238 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
718e3744 239 {
508e53e2 240 char prefixstr[128], nexthopstr[128];
718e3744 241 prefix2str ((struct prefix *)&p, prefixstr, sizeof (prefixstr));
508e53e2 242 if (nexthop)
243 inet_ntop (AF_INET6, nexthop, nexthopstr, sizeof (nexthopstr));
718e3744 244 else
508e53e2 245 snprintf (nexthopstr, sizeof (nexthopstr), "::");
246
c6487d61 247 zlog_debug ("Zebra Receive route %s: %s %s nexthop %s ifindex %ld",
248 (command == ZEBRA_IPV6_ROUTE_ADD ? "add" : "delete"),
f52d13cb 249 zebra_route_string(api.type), prefixstr, nexthopstr, ifindex);
718e3744 250 }
251
252 if (command == ZEBRA_IPV6_ROUTE_ADD)
508e53e2 253 ospf6_asbr_redistribute_add (api.type, ifindex, (struct prefix *) &p,
254 api.nexthop_num, nexthop);
718e3744 255 else
508e53e2 256 ospf6_asbr_redistribute_remove (api.type, ifindex, (struct prefix *) &p);
718e3744 257
258 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
259 free (nexthop);
260
261 return 0;
262}
263
508e53e2 264
265
718e3744 266\f
267DEFUN (show_zebra,
268 show_zebra_cmd,
269 "show zebra",
270 SHOW_STR
271 "Zebra information\n")
272{
273 int i;
508e53e2 274 if (zclient == NULL)
275 {
049207c3 276 vty_out (vty, "Not connected to zebra%s", VNL);
508e53e2 277 return CMD_SUCCESS;
278 }
718e3744 279
049207c3 280 vty_out (vty, "Zebra Infomation%s", VNL);
508e53e2 281 vty_out (vty, " enable: %d fail: %d%s",
049207c3 282 zclient->enable, zclient->fail, VNL);
718e3744 283 vty_out (vty, " redistribute default: %d%s", zclient->redist_default,
049207c3 284 VNL);
508e53e2 285 vty_out (vty, " redistribute:");
718e3744 286 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
508e53e2 287 {
288 if (zclient->redist[i])
f52d13cb 289 vty_out (vty, " %s", zebra_route_string(i));
508e53e2 290 }
049207c3 291 vty_out (vty, "%s", VNL);
718e3744 292 return CMD_SUCCESS;
293}
294
295DEFUN (router_zebra,
296 router_zebra_cmd,
297 "router zebra",
298 "Enable a routing process\n"
299 "Make connection to zebra daemon\n")
300{
718e3744 301 vty->node = ZEBRA_NODE;
302 zclient->enable = 1;
303 zclient_start (zclient);
304 return CMD_SUCCESS;
305}
306
307DEFUN (no_router_zebra,
308 no_router_zebra_cmd,
309 "no router zebra",
310 NO_STR
311 "Configure routing process\n"
312 "Disable connection to zebra daemon\n")
313{
718e3744 314 zclient->enable = 0;
315 zclient_stop (zclient);
316 return CMD_SUCCESS;
317}
318
319/* Zebra configuration write function. */
6ac29a51 320static int
508e53e2 321config_write_ospf6_zebra (struct vty *vty)
718e3744 322{
323 if (! zclient->enable)
324 {
049207c3 325 vty_out (vty, "no router zebra%s", VNL);
326 vty_out (vty, "!%s", VNL);
718e3744 327 }
328 else if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
329 {
049207c3 330 vty_out (vty, "router zebra%s", VNL);
331 vty_out (vty, " no redistribute ospf6%s", VNL);
332 vty_out (vty, "!%s", VNL);
718e3744 333 }
334 return 0;
335}
336
337/* Zebra node structure. */
338struct cmd_node zebra_node =
339{
340 ZEBRA_NODE,
341 "%s(config-zebra)# ",
342};
343
344#define ADD 0
508e53e2 345#define REM 1
718e3744 346static void
508e53e2 347ospf6_zebra_route_update (int type, struct ospf6_route *request)
718e3744 348{
718e3744 349 struct zapi_ipv6 api;
d2fc8896 350 char buf[64];
508e53e2 351 int nhcount;
718e3744 352 struct in6_addr **nexthops;
353 unsigned int *ifindexes;
718e3744 354 int i, ret = 0;
508e53e2 355 struct prefix_ipv6 *dest;
718e3744 356
508e53e2 357 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
718e3744 358 {
508e53e2 359 prefix2str (&request->prefix, buf, sizeof (buf));
c6487d61 360 zlog_debug ("Send %s route: %s",
361 (type == REM ? "remove" : "add"), buf);
718e3744 362 }
363
364 if (zclient->sock < 0)
365 {
508e53e2 366 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
c6487d61 367 zlog_debug (" Not connected to Zebra");
718e3744 368 return;
369 }
370
371 if (request->path.origin.adv_router == ospf6->router_id &&
372 (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
373 request->path.type == OSPF6_PATH_TYPE_EXTERNAL2))
374 {
508e53e2 375 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
c6487d61 376 zlog_debug (" Ignore self-originated external route");
718e3744 377 return;
378 }
379
508e53e2 380 /* If removing is the best path and if there's another path,
381 treat this request as add the secondary path */
382 if (type == REM && ospf6_route_is_best (request) &&
383 request->next && ospf6_route_is_same (request, request->next))
718e3744 384 {
508e53e2 385 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
c6487d61 386 zlog_debug (" Best-path removal resulted Sencondary addition");
508e53e2 387 type = ADD;
388 request = request->next;
718e3744 389 }
390
508e53e2 391 /* Only the best path will be sent to zebra. */
392 if (! ospf6_route_is_best (request))
718e3744 393 {
508e53e2 394 /* this is not preferred best route, ignore */
395 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
c6487d61 396 zlog_debug (" Ignore non-best route");
508e53e2 397 return;
718e3744 398 }
399
508e53e2 400 nhcount = 0;
401 for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
402 if (ospf6_nexthop_is_set (&request->nexthop[i]))
403 nhcount++;
718e3744 404
508e53e2 405 if (nhcount == 0)
718e3744 406 {
508e53e2 407 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
c6487d61 408 zlog_debug (" No nexthop, ignore");
718e3744 409 return;
410 }
411
412 /* allocate memory for nexthop_list */
413 nexthops = XCALLOC (MTYPE_OSPF6_OTHER,
508e53e2 414 nhcount * sizeof (struct in6_addr *));
415 if (nexthops == NULL)
718e3744 416 {
508e53e2 417 zlog_warn ("Can't send route to zebra: malloc failed");
718e3744 418 return;
419 }
420
421 /* allocate memory for ifindex_list */
422 ifindexes = XCALLOC (MTYPE_OSPF6_OTHER,
508e53e2 423 nhcount * sizeof (unsigned int));
424 if (ifindexes == NULL)
718e3744 425 {
508e53e2 426 zlog_warn ("Can't send route to zebra: malloc failed");
718e3744 427 XFREE (MTYPE_OSPF6_OTHER, nexthops);
428 return;
429 }
430
508e53e2 431 for (i = 0; i < nhcount; i++)
718e3744 432 {
508e53e2 433 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
d2fc8896 434 {
435 char ifname[IFNAMSIZ];
436 inet_ntop (AF_INET6, &request->nexthop[i].address,
437 buf, sizeof (buf));
438 if (!if_indextoname(request->nexthop[i].ifindex, ifname))
439 strlcpy(ifname, "unknown", sizeof(ifname));
440 zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname,
c6487d61 441 request->nexthop[i].ifindex);
d2fc8896 442 }
508e53e2 443 nexthops[i] = &request->nexthop[i].address;
444 ifindexes[i] = request->nexthop[i].ifindex;
718e3744 445 }
446
447 api.type = ZEBRA_ROUTE_OSPF6;
448 api.flags = 0;
449 api.message = 0;
450 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
508e53e2 451 api.nexthop_num = nhcount;
718e3744 452 api.nexthop = nexthops;
508e53e2 453 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
454 api.ifindex_num = nhcount;
718e3744 455 api.ifindex = ifindexes;
508e53e2 456 SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
457 api.metric = (request->path.metric_type == 2 ?
458 request->path.cost_e2 : request->path.cost);
718e3744 459
508e53e2 460 dest = (struct prefix_ipv6 *) &request->prefix;
461 if (type == REM)
462 ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, &api);
718e3744 463 else
508e53e2 464 ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api);
718e3744 465
466 if (ret < 0)
508e53e2 467 zlog_err ("zapi_ipv6_route() %s failed: %s",
6099b3b5 468 (type == REM ? "delete" : "add"), safe_strerror (errno));
718e3744 469
718e3744 470 XFREE (MTYPE_OSPF6_OTHER, nexthops);
471 XFREE (MTYPE_OSPF6_OTHER, ifindexes);
472
473 return;
474}
475
476void
508e53e2 477ospf6_zebra_route_update_add (struct ospf6_route *request)
718e3744 478{
508e53e2 479 if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
718e3744 480 {
508e53e2 481 ospf6->route_table->hook_add = NULL;
482 ospf6->route_table->hook_remove = NULL;
483 return;
718e3744 484 }
508e53e2 485 ospf6_zebra_route_update (ADD, request);
718e3744 486}
487
508e53e2 488void
489ospf6_zebra_route_update_remove (struct ospf6_route *request)
718e3744 490{
508e53e2 491 if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
718e3744 492 {
508e53e2 493 ospf6->route_table->hook_add = NULL;
494 ospf6->route_table->hook_remove = NULL;
495 return;
718e3744 496 }
508e53e2 497 ospf6_zebra_route_update (REM, request);
718e3744 498}
499
718e3744 500DEFUN (redistribute_ospf6,
501 redistribute_ospf6_cmd,
502 "redistribute ospf6",
503 "Redistribute control\n"
504 "OSPF6 route\n")
505{
508e53e2 506 struct ospf6_route *route;
507
508 if (zclient->redist[ZEBRA_ROUTE_OSPF6])
509 return CMD_SUCCESS;
718e3744 510
511 zclient->redist[ZEBRA_ROUTE_OSPF6] = 1;
512
508e53e2 513 if (ospf6 == NULL)
514 return CMD_SUCCESS;
515
516 /* send ospf6 route to zebra route table */
517 for (route = ospf6_route_head (ospf6->route_table); route;
518 route = ospf6_route_next (route))
519 ospf6_zebra_route_update_add (route);
520
521 ospf6->route_table->hook_add = ospf6_zebra_route_update_add;
522 ospf6->route_table->hook_remove = ospf6_zebra_route_update_remove;
718e3744 523
524 return CMD_SUCCESS;
525}
526
527DEFUN (no_redistribute_ospf6,
528 no_redistribute_ospf6_cmd,
529 "no redistribute ospf6",
530 NO_STR
531 "Redistribute control\n"
532 "OSPF6 route\n")
533{
508e53e2 534 struct ospf6_route *route;
535
536 if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
537 return CMD_SUCCESS;
718e3744 538
539 zclient->redist[ZEBRA_ROUTE_OSPF6] = 0;
540
508e53e2 541 if (ospf6 == NULL)
718e3744 542 return CMD_SUCCESS;
543
508e53e2 544 ospf6->route_table->hook_add = NULL;
545 ospf6->route_table->hook_remove = NULL;
718e3744 546
508e53e2 547 /* withdraw ospf6 route from zebra route table */
548 for (route = ospf6_route_head (ospf6->route_table); route;
549 route = ospf6_route_next (route))
550 ospf6_zebra_route_update_remove (route);
718e3744 551
552 return CMD_SUCCESS;
553}
554
555void
6ac29a51 556ospf6_zebra_init (void)
718e3744 557{
558 /* Allocate zebra structure. */
559 zclient = zclient_new ();
560 zclient_init (zclient, ZEBRA_ROUTE_OSPF6);
18a6dce6 561 zclient->router_id_update = ospf6_router_id_update_zebra;
718e3744 562 zclient->interface_add = ospf6_zebra_if_add;
563 zclient->interface_delete = ospf6_zebra_if_del;
564 zclient->interface_up = ospf6_zebra_if_state_update;
565 zclient->interface_down = ospf6_zebra_if_state_update;
566 zclient->interface_address_add = ospf6_zebra_if_address_update_add;
567 zclient->interface_address_delete = ospf6_zebra_if_address_update_delete;
568 zclient->ipv4_route_add = NULL;
569 zclient->ipv4_route_delete = NULL;
570 zclient->ipv6_route_add = ospf6_zebra_read_ipv6;
571 zclient->ipv6_route_delete = ospf6_zebra_read_ipv6;
572
573 /* redistribute connected route by default */
574 /* ospf6_zebra_redistribute (ZEBRA_ROUTE_CONNECT); */
575
576 /* Install zebra node. */
508e53e2 577 install_node (&zebra_node, config_write_ospf6_zebra);
718e3744 578
579 /* Install command element for zebra node. */
580 install_element (VIEW_NODE, &show_zebra_cmd);
581 install_element (ENABLE_NODE, &show_zebra_cmd);
582 install_element (CONFIG_NODE, &router_zebra_cmd);
583 install_element (CONFIG_NODE, &no_router_zebra_cmd);
508e53e2 584
718e3744 585 install_default (ZEBRA_NODE);
586 install_element (ZEBRA_NODE, &redistribute_ospf6_cmd);
587 install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd);
588
718e3744 589 return;
590}
591
508e53e2 592/* Debug */
593\f
594DEFUN (debug_ospf6_zebra_sendrecv,
595 debug_ospf6_zebra_sendrecv_cmd,
596 "debug ospf6 zebra (send|recv)",
597 DEBUG_STR
598 OSPF6_STR
599 "Debug connection between zebra\n"
600 "Debug Sending zebra\n"
601 "Debug Receiving zebra\n"
602 )
603{
604 unsigned char level = 0;
605
606 if (argc)
607 {
608 if (! strncmp (argv[0], "s", 1))
609 level = OSPF6_DEBUG_ZEBRA_SEND;
610 else if (! strncmp (argv[0], "r", 1))
611 level = OSPF6_DEBUG_ZEBRA_RECV;
612 }
613 else
614 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
615
616 OSPF6_DEBUG_ZEBRA_ON (level);
617 return CMD_SUCCESS;
618}
619
620ALIAS (debug_ospf6_zebra_sendrecv,
621 debug_ospf6_zebra_cmd,
622 "debug ospf6 zebra",
623 DEBUG_STR
624 OSPF6_STR
625 "Debug connection between zebra\n"
6ac29a51 626 )
508e53e2 627
628
629DEFUN (no_debug_ospf6_zebra_sendrecv,
630 no_debug_ospf6_zebra_sendrecv_cmd,
631 "no debug ospf6 zebra (send|recv)",
632 NO_STR
633 DEBUG_STR
634 OSPF6_STR
635 "Debug connection between zebra\n"
636 "Debug Sending zebra\n"
637 "Debug Receiving zebra\n"
638 )
639{
640 unsigned char level = 0;
641
642 if (argc)
643 {
644 if (! strncmp (argv[0], "s", 1))
645 level = OSPF6_DEBUG_ZEBRA_SEND;
646 else if (! strncmp (argv[0], "r", 1))
647 level = OSPF6_DEBUG_ZEBRA_RECV;
648 }
649 else
650 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
651
652 OSPF6_DEBUG_ZEBRA_OFF (level);
653 return CMD_SUCCESS;
654}
655
656ALIAS (no_debug_ospf6_zebra_sendrecv,
657 no_debug_ospf6_zebra_cmd,
658 "no debug ospf6 zebra",
659 NO_STR
660 DEBUG_STR
661 OSPF6_STR
662 "Debug connection between zebra\n"
6ac29a51 663 )
508e53e2 664
665int
666config_write_ospf6_debug_zebra (struct vty *vty)
667{
668 if (IS_OSPF6_DEBUG_ZEBRA (SEND) && IS_OSPF6_DEBUG_ZEBRA (RECV))
049207c3 669 vty_out (vty, "debug ospf6 zebra%s", VNL);
508e53e2 670 else
671 {
672 if (IS_OSPF6_DEBUG_ZEBRA (SEND))
049207c3 673 vty_out (vty, "debug ospf6 zebra send%s", VNL);
508e53e2 674 if (IS_OSPF6_DEBUG_ZEBRA (RECV))
049207c3 675 vty_out (vty, "debug ospf6 zebra recv%s", VNL);
508e53e2 676 }
677 return 0;
678}
679
718e3744 680void
6ac29a51 681install_element_ospf6_debug_zebra (void)
718e3744 682{
508e53e2 683 install_element (ENABLE_NODE, &debug_ospf6_zebra_cmd);
684 install_element (ENABLE_NODE, &no_debug_ospf6_zebra_cmd);
685 install_element (ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd);
686 install_element (ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
687 install_element (CONFIG_NODE, &debug_ospf6_zebra_cmd);
688 install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd);
689 install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd);
690 install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
718e3744 691}
692
508e53e2 693