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