]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_zebra.c
*: Do not cast to the same type
[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 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
718e3744 19 */
20
508e53e2 21#include <zebra.h>
22
23#include "log.h"
24#include "vty.h"
25#include "command.h"
26#include "prefix.h"
27#include "stream.h"
28#include "zclient.h"
29#include "memory.h"
2376c3f2 30#include "lib/bfd.h"
4ba03be5 31#include "lib_errors.h"
718e3744 32
508e53e2 33#include "ospf6_proto.h"
34#include "ospf6_top.h"
718e3744 35#include "ospf6_interface.h"
508e53e2 36#include "ospf6_route.h"
37#include "ospf6_lsa.h"
049207c3 38#include "ospf6_lsdb.h"
718e3744 39#include "ospf6_asbr.h"
508e53e2 40#include "ospf6_zebra.h"
049207c3 41#include "ospf6d.h"
718e3744 42
d62a17ae 43DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance")
baff583e 44
508e53e2 45unsigned char conf_debug_ospf6_zebra = 0;
718e3744 46
47/* information about zebra. */
48struct zclient *zclient = NULL;
49
18a6dce6 50/* Router-id update message from zebra. */
121f9dee 51static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS)
18a6dce6 52{
d62a17ae 53 struct prefix router_id;
54 struct ospf6 *o = ospf6;
18a6dce6 55
d62a17ae 56 zebra_router_id_update_read(zclient->ibuf, &router_id);
18a6dce6 57
78c6ba61
CS
58 om6->zebra_router_id = router_id.u.prefix4.s_addr;
59
d62a17ae 60 if (o == NULL)
61 return 0;
c1ba9e8a 62
d6927cf3 63 o->router_id_zebra = router_id.u.prefix4;
78c6ba61
CS
64 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
65 char buf[INET_ADDRSTRLEN];
66
15569c58
DA
67 zlog_debug("%s: zebra router-id %s update", __func__,
68 inet_ntop(AF_INET, &router_id.u.prefix4, buf,
69 INET_ADDRSTRLEN));
78c6ba61 70 }
d6927cf3 71
78c6ba61 72 ospf6_router_id_update();
18a6dce6 73
d62a17ae 74 return 0;
18a6dce6 75}
76
718e3744 77/* redistribute function */
d62a17ae 78void ospf6_zebra_redistribute(int type)
718e3744 79{
d62a17ae 80 if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
81 return;
82 vrf_bitmap_set(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
7076bb2f 83
d62a17ae 84 if (zclient->sock > 0)
85 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
86 AFI_IP6, type, 0, VRF_DEFAULT);
718e3744 87}
88
d62a17ae 89void ospf6_zebra_no_redistribute(int type)
718e3744 90{
d62a17ae 91 if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
92 return;
93 vrf_bitmap_unset(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
94 if (zclient->sock > 0)
95 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
96 AFI_IP6, type, 0, VRF_DEFAULT);
718e3744 97}
98
121f9dee 99static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
718e3744 100{
d62a17ae 101 struct connected *c;
102 char buf[128];
103
104 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
105 zclient->ibuf, vrf_id);
106 if (c == NULL)
107 return 0;
108
109 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
110 zlog_debug("Zebra Interface address add: %s %5s %s/%d",
111 c->ifp->name, prefix_family_str(c->address),
112 inet_ntop(c->address->family, &c->address->u.prefix,
113 buf, sizeof(buf)),
114 c->address->prefixlen);
115
116 if (c->address->family == AF_INET6) {
117 ospf6_interface_state_update(c->ifp);
118 ospf6_interface_connected_route_update(c->ifp);
119 }
120 return 0;
718e3744 121}
122
121f9dee 123static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
718e3744 124{
d62a17ae 125 struct connected *c;
126 char buf[128];
127
128 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
129 zclient->ibuf, vrf_id);
130 if (c == NULL)
131 return 0;
132
133 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
134 zlog_debug("Zebra Interface address delete: %s %5s %s/%d",
135 c->ifp->name, prefix_family_str(c->address),
136 inet_ntop(c->address->family, &c->address->u.prefix,
137 buf, sizeof(buf)),
138 c->address->prefixlen);
139
140 if (c->address->family == AF_INET6) {
141 ospf6_interface_connected_route_update(c->ifp);
142 ospf6_interface_state_update(c->ifp);
143 }
718e3744 144
721c0857 145 connected_free(&c);
718e3744 146
d62a17ae 147 return 0;
148}
718e3744 149
121f9dee 150static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
d62a17ae 151{
74489921 152 struct zapi_route api;
d62a17ae 153 unsigned long ifindex;
d62a17ae 154 struct in6_addr *nexthop;
155
156 if (ospf6 == NULL)
157 return 0;
158
74489921
RW
159 if (zapi_route_decode(zclient->ibuf, &api) < 0)
160 return -1;
d62a17ae 161
74489921
RW
162 /* we completely ignore srcdest routes for now. */
163 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
d62a17ae 164 return 0;
165
9fb2b879
DS
166 if (IN6_IS_ADDR_LINKLOCAL(&api.prefix.u.prefix6))
167 return 0;
168
74489921
RW
169 ifindex = api.nexthops[0].ifindex;
170 nexthop = &api.nexthops[0].gate.ipv6;
d62a17ae 171
172 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
173 char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
c4efd0f4
DA
174
175 prefix2str(&api.prefix, prefixstr, sizeof(prefixstr));
0af35d90 176 inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));
d62a17ae 177
178 zlog_debug(
179 "Zebra Receive route %s: %s %s nexthop %s ifindex %ld tag %" ROUTE_TAG_PRI,
121f9dee
QY
180 (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD ? "add"
181 : "delete"),
d62a17ae 182 zebra_route_string(api.type), prefixstr, nexthopstr,
183 ifindex, api.tag);
184 }
718e3744 185
121f9dee 186 if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
74489921 187 ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
d62a17ae 188 api.nexthop_num, nexthop, api.tag);
189 else
74489921 190 ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix);
718e3744 191
d62a17ae 192 return 0;
718e3744 193}
194
718e3744 195DEFUN (show_zebra,
eefe02da
DS
196 show_ospf6_zebra_cmd,
197 "show ipv6 ospf6 zebra",
718e3744 198 SHOW_STR
eefe02da
DS
199 IPV6_STR
200 OSPF6_STR
41e7fb80 201 ZEBRA_STR)
718e3744 202{
d62a17ae 203 int i;
204 if (zclient == NULL) {
205 vty_out(vty, "Not connected to zebra\n");
206 return CMD_SUCCESS;
207 }
208
f79f7a7b 209 vty_out(vty, "Zebra Information\n");
34b054ba 210 vty_out(vty, " fail: %d\n", zclient->fail);
d62a17ae 211 vty_out(vty, " redistribute default: %d\n",
49db7a7b
RW
212 vrf_bitmap_check(zclient->default_information[AFI_IP6],
213 VRF_DEFAULT));
d62a17ae 214 vty_out(vty, " redistribute:");
215 for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
216 if (vrf_bitmap_check(zclient->redist[AFI_IP6][i], VRF_DEFAULT))
217 vty_out(vty, " %s", zebra_route_string(i));
218 }
219 vty_out(vty, "\n");
220 return CMD_SUCCESS;
718e3744 221}
222
718e3744 223#define ADD 0
508e53e2 224#define REM 1
d62a17ae 225static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
718e3744 226{
5afa1c6b 227 struct zapi_route api;
d62a17ae 228 char buf[PREFIX2STR_BUFFER];
229 int nhcount;
d62a17ae 230 int ret = 0;
5afa1c6b 231 struct prefix *dest;
d62a17ae 232
233 if (IS_OSPF6_DEBUG_ZEBRA(SEND)) {
234 prefix2str(&request->prefix, buf, sizeof(buf));
235 zlog_debug("Send %s route: %s",
236 (type == REM ? "remove" : "add"), buf);
237 }
238
239 if (zclient->sock < 0) {
240 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
241 zlog_debug(" Not connected to Zebra");
242 return;
243 }
244
245 if (request->path.origin.adv_router == ospf6->router_id
246 && (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1
247 || request->path.type == OSPF6_PATH_TYPE_EXTERNAL2)) {
248 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
249 zlog_debug(" Ignore self-originated external route");
250 return;
251 }
252
253 /* If removing is the best path and if there's another path,
254 treat this request as add the secondary path */
255 if (type == REM && ospf6_route_is_best(request) && request->next
256 && ospf6_route_is_same(request, request->next)) {
257 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
258 zlog_debug(
84b7a388 259 " Best-path removal resulted Secondary addition");
d62a17ae 260 type = ADD;
261 request = request->next;
262 }
263
264 /* Only the best path will be sent to zebra. */
265 if (!ospf6_route_is_best(request)) {
266 /* this is not preferred best route, ignore */
267 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
268 zlog_debug(" Ignore non-best route");
269 return;
270 }
271
272 nhcount = ospf6_route_num_nexthops(request);
273 if (nhcount == 0) {
274 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
275 zlog_debug(" No nexthop, ignore");
276 return;
277 }
278
5afa1c6b 279 dest = &request->prefix;
d62a17ae 280
5afa1c6b 281 memset(&api, 0, sizeof(api));
d62a17ae 282 api.vrf_id = VRF_DEFAULT;
283 api.type = ZEBRA_ROUTE_OSPF6;
d62a17ae 284 api.safi = SAFI_UNICAST;
5afa1c6b 285 api.prefix = *dest;
d62a17ae 286 SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
a74e593b
RW
287 api.nexthop_num = MIN(nhcount, MULTIPATH_NUM);
288 ospf6_route_zebra_copy_nexthops(request, api.nexthops, api.nexthop_num);
d62a17ae 289 SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
290 api.metric = (request->path.metric_type == 2 ? request->path.u.cost_e2
291 : request->path.cost);
292 if (request->path.tag) {
293 SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
294 api.tag = request->path.tag;
295 }
296
d62a17ae 297 SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
5afa1c6b
RW
298 api.distance =
299 ospf6_distance_apply((struct prefix_ipv6 *)dest, request);
d62a17ae 300
301 if (type == REM)
5afa1c6b 302 ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
d62a17ae 303 else
5afa1c6b 304 ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
d62a17ae 305
306 if (ret < 0)
450971aa 307 flog_err(EC_LIB_ZAPI_SOCKET,
1c50c1c0
QY
308 "zclient_route_send() %s failed: %s",
309 (type == REM ? "delete" : "add"),
310 safe_strerror(errno));
d62a17ae 311
d62a17ae 312 return;
718e3744 313}
314
d62a17ae 315void ospf6_zebra_route_update_add(struct ospf6_route *request)
718e3744 316{
d62a17ae 317 ospf6_zebra_route_update(ADD, request);
718e3744 318}
319
d62a17ae 320void ospf6_zebra_route_update_remove(struct ospf6_route *request)
718e3744 321{
d62a17ae 322 ospf6_zebra_route_update(REM, request);
718e3744 323}
324
d62a17ae 325void ospf6_zebra_add_discard(struct ospf6_route *request)
c3c0ac83 326{
5afa1c6b 327 struct zapi_route api;
d62a17ae 328 char buf[INET6_ADDRSTRLEN];
5afa1c6b 329 struct prefix *dest = &request->prefix;
d62a17ae 330
d00061ea 331 if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
5afa1c6b 332 memset(&api, 0, sizeof(api));
d00061ea
RW
333 api.vrf_id = VRF_DEFAULT;
334 api.type = ZEBRA_ROUTE_OSPF6;
d00061ea 335 api.safi = SAFI_UNICAST;
5afa1c6b 336 api.prefix = *dest;
09a484dd 337 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
d00061ea 338
5afa1c6b 339 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
d00061ea
RW
340
341 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
342 zlog_debug("Zebra: Route add discard %s/%d",
5afa1c6b 343 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
d00061ea
RW
344 INET6_ADDRSTRLEN),
345 dest->prefixlen);
346
347 SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
348 } else {
d00061ea
RW
349 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
350 zlog_debug(
351 "Zebra: Blackhole route present already %s/%d",
5afa1c6b 352 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
d00061ea
RW
353 INET6_ADDRSTRLEN),
354 dest->prefixlen);
c3c0ac83 355 }
c3c0ac83
DS
356}
357
d62a17ae 358void ospf6_zebra_delete_discard(struct ospf6_route *request)
c3c0ac83 359{
5afa1c6b 360 struct zapi_route api;
d62a17ae 361 char buf[INET6_ADDRSTRLEN];
5afa1c6b 362 struct prefix *dest = &request->prefix;
d62a17ae 363
d00061ea 364 if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
5afa1c6b 365 memset(&api, 0, sizeof(api));
d00061ea
RW
366 api.vrf_id = VRF_DEFAULT;
367 api.type = ZEBRA_ROUTE_OSPF6;
d00061ea 368 api.safi = SAFI_UNICAST;
5afa1c6b 369 api.prefix = *dest;
09a484dd 370 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
d00061ea 371
5afa1c6b 372 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
d00061ea
RW
373
374 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
375 zlog_debug("Zebra: Route delete discard %s/%d",
5afa1c6b 376 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
d00061ea
RW
377 INET6_ADDRSTRLEN),
378 dest->prefixlen);
379
380 UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
381 } else {
d00061ea
RW
382 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
383 zlog_debug(
384 "Zebra: Blackhole route already deleted %s/%d",
5afa1c6b 385 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
d00061ea
RW
386 INET6_ADDRSTRLEN),
387 dest->prefixlen);
c3c0ac83 388 }
c3c0ac83
DS
389}
390
d62a17ae 391static struct ospf6_distance *ospf6_distance_new(void)
baff583e 392{
d62a17ae 393 return XCALLOC(MTYPE_OSPF6_DISTANCE, sizeof(struct ospf6_distance));
baff583e
MZ
394}
395
d62a17ae 396static void ospf6_distance_free(struct ospf6_distance *odistance)
baff583e 397{
d62a17ae 398 XFREE(MTYPE_OSPF6_DISTANCE, odistance);
baff583e
MZ
399}
400
d62a17ae 401int ospf6_distance_set(struct vty *vty, struct ospf6 *o,
402 const char *distance_str, const char *ip_str,
403 const char *access_list_str)
baff583e 404{
d62a17ae 405 int ret;
406 struct prefix_ipv6 p;
d7c0a89a 407 uint8_t distance;
d62a17ae 408 struct route_node *rn;
409 struct ospf6_distance *odistance;
410
411 ret = str2prefix_ipv6(ip_str, &p);
412 if (ret == 0) {
413 vty_out(vty, "Malformed prefix\n");
414 return CMD_WARNING_CONFIG_FAILED;
415 }
416
417 distance = atoi(distance_str);
418
419 /* Get OSPF6 distance node. */
420 rn = route_node_get(o->distance_table, (struct prefix *)&p);
421 if (rn->info) {
422 odistance = rn->info;
423 route_unlock_node(rn);
424 } else {
425 odistance = ospf6_distance_new();
426 rn->info = odistance;
427 }
428
429 /* Set distance value. */
430 odistance->distance = distance;
431
432 /* Reset access-list configuration. */
433 if (odistance->access_list) {
434 free(odistance->access_list);
435 odistance->access_list = NULL;
436 }
437 if (access_list_str)
438 odistance->access_list = strdup(access_list_str);
439
440 return CMD_SUCCESS;
baff583e
MZ
441}
442
d62a17ae 443int ospf6_distance_unset(struct vty *vty, struct ospf6 *o,
444 const char *distance_str, const char *ip_str,
445 const char *access_list_str)
baff583e 446{
d62a17ae 447 int ret;
448 struct prefix_ipv6 p;
449 struct route_node *rn;
450 struct ospf6_distance *odistance;
451
452 ret = str2prefix_ipv6(ip_str, &p);
453 if (ret == 0) {
454 vty_out(vty, "Malformed prefix\n");
455 return CMD_WARNING_CONFIG_FAILED;
456 }
457
458 rn = route_node_lookup(o->distance_table, (struct prefix *)&p);
459 if (!rn) {
460 vty_out(vty, "Cant't find specified prefix\n");
461 return CMD_WARNING_CONFIG_FAILED;
462 }
463
464 odistance = rn->info;
465
466 if (odistance->access_list)
467 free(odistance->access_list);
468 ospf6_distance_free(odistance);
469
470 rn->info = NULL;
471 route_unlock_node(rn);
472 route_unlock_node(rn);
473
474 return CMD_SUCCESS;
baff583e
MZ
475}
476
d62a17ae 477void ospf6_distance_reset(struct ospf6 *o)
baff583e 478{
d62a17ae 479 struct route_node *rn;
480 struct ospf6_distance *odistance;
481
482 for (rn = route_top(o->distance_table); rn; rn = route_next(rn))
483 if ((odistance = rn->info) != NULL) {
484 if (odistance->access_list)
485 free(odistance->access_list);
486 ospf6_distance_free(odistance);
487 rn->info = NULL;
488 route_unlock_node(rn);
489 }
baff583e
MZ
490}
491
d7c0a89a 492uint8_t ospf6_distance_apply(struct prefix_ipv6 *p, struct ospf6_route * or)
baff583e 493{
d62a17ae 494 struct ospf6 *o;
baff583e 495
d62a17ae 496 o = ospf6;
497 if (o == NULL)
498 return 0;
baff583e 499
d62a17ae 500 if (o->distance_intra)
501 if (or->path.type == OSPF6_PATH_TYPE_INTRA)
502 return o->distance_intra;
baff583e 503
d62a17ae 504 if (o->distance_inter)
505 if (or->path.type == OSPF6_PATH_TYPE_INTER)
506 return o->distance_inter;
baff583e 507
d62a17ae 508 if (o->distance_external)
509 if (or->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
510 or->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
511 return o->distance_external;
baff583e 512
d62a17ae 513 if (o->distance_all)
514 return o->distance_all;
baff583e 515
d62a17ae 516 return 0;
baff583e
MZ
517}
518
d62a17ae 519static void ospf6_zebra_connected(struct zclient *zclient)
7076bb2f 520{
d62a17ae 521 /* Send the client registration */
0945d5ed 522 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
2376c3f2 523
d62a17ae 524 zclient_send_reg_requests(zclient, VRF_DEFAULT);
7076bb2f
FL
525}
526
d62a17ae 527void ospf6_zebra_init(struct thread_master *master)
718e3744 528{
d62a17ae 529 /* Allocate zebra structure. */
26f63a1e 530 zclient = zclient_new(master, &zclient_options_default);
342213ea 531 zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
d62a17ae 532 zclient->zebra_connected = ospf6_zebra_connected;
533 zclient->router_id_update = ospf6_router_id_update_zebra;
d62a17ae 534 zclient->interface_address_add = ospf6_zebra_if_address_update_add;
535 zclient->interface_address_delete =
536 ospf6_zebra_if_address_update_delete;
74489921
RW
537 zclient->redistribute_route_add = ospf6_zebra_read_route;
538 zclient->redistribute_route_del = ospf6_zebra_read_route;
d62a17ae 539
d62a17ae 540 /* Install command element for zebra node. */
541 install_element(VIEW_NODE, &show_ospf6_zebra_cmd);
718e3744 542}
543
508e53e2 544/* Debug */
6b0655a2 545
508e53e2 546DEFUN (debug_ospf6_zebra_sendrecv,
547 debug_ospf6_zebra_sendrecv_cmd,
1d68dbfe 548 "debug ospf6 zebra [<send|recv>]",
508e53e2 549 DEBUG_STR
550 OSPF6_STR
551 "Debug connection between zebra\n"
552 "Debug Sending zebra\n"
553 "Debug Receiving zebra\n"
554 )
555{
d62a17ae 556 int idx_send_recv = 3;
557 unsigned char level = 0;
558
559 if (argc == 4) {
560 if (strmatch(argv[idx_send_recv]->text, "send"))
561 level = OSPF6_DEBUG_ZEBRA_SEND;
562 else if (strmatch(argv[idx_send_recv]->text, "recv"))
563 level = OSPF6_DEBUG_ZEBRA_RECV;
564 } else
565 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
566
567 OSPF6_DEBUG_ZEBRA_ON(level);
568 return CMD_SUCCESS;
508e53e2 569}
570
508e53e2 571DEFUN (no_debug_ospf6_zebra_sendrecv,
572 no_debug_ospf6_zebra_sendrecv_cmd,
1d68dbfe 573 "no debug ospf6 zebra [<send|recv>]",
508e53e2 574 NO_STR
575 DEBUG_STR
576 OSPF6_STR
577 "Debug connection between zebra\n"
578 "Debug Sending zebra\n"
579 "Debug Receiving zebra\n"
580 )
581{
d62a17ae 582 int idx_send_recv = 4;
583 unsigned char level = 0;
584
585 if (argc == 5) {
586 if (strmatch(argv[idx_send_recv]->text, "send"))
587 level = OSPF6_DEBUG_ZEBRA_SEND;
588 else if (strmatch(argv[idx_send_recv]->text, "recv"))
589 level = OSPF6_DEBUG_ZEBRA_RECV;
590 } else
591 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
592
593 OSPF6_DEBUG_ZEBRA_OFF(level);
594 return CMD_SUCCESS;
508e53e2 595}
596
508e53e2 597
d62a17ae 598int config_write_ospf6_debug_zebra(struct vty *vty)
508e53e2 599{
d62a17ae 600 if (IS_OSPF6_DEBUG_ZEBRA(SEND) && IS_OSPF6_DEBUG_ZEBRA(RECV))
601 vty_out(vty, "debug ospf6 zebra\n");
602 else {
603 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
604 vty_out(vty, "debug ospf6 zebra send\n");
605 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
606 vty_out(vty, "debug ospf6 zebra recv\n");
607 }
608 return 0;
508e53e2 609}
610
d62a17ae 611void install_element_ospf6_debug_zebra(void)
718e3744 612{
d62a17ae 613 install_element(ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd);
614 install_element(ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
615 install_element(CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd);
616 install_element(CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
718e3744 617}