]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_zebra.c
Merge branch 'master' of https://github.com/frrouting/frr into pmsi-parse-display
[mirror_frr.git] / ospf6d / ospf6_zebra.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
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 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
19 */
20
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"
30 #include "lib/bfd.h"
31
32 #include "ospf6_proto.h"
33 #include "ospf6_top.h"
34 #include "ospf6_interface.h"
35 #include "ospf6_route.h"
36 #include "ospf6_lsa.h"
37 #include "ospf6_lsdb.h"
38 #include "ospf6_asbr.h"
39 #include "ospf6_zebra.h"
40 #include "ospf6d.h"
41
42 DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance")
43
44 unsigned char conf_debug_ospf6_zebra = 0;
45
46 /* information about zebra. */
47 struct zclient *zclient = NULL;
48
49 /* Router-id update message from zebra. */
50 static int ospf6_router_id_update_zebra(int command, struct zclient *zclient,
51 zebra_size_t length, vrf_id_t vrf_id)
52 {
53 struct prefix router_id;
54 struct ospf6 *o = ospf6;
55
56 zebra_router_id_update_read(zclient->ibuf, &router_id);
57
58 om6->zebra_router_id = router_id.u.prefix4.s_addr;
59
60 if (o == NULL)
61 return 0;
62
63 o->router_id_zebra = router_id.u.prefix4;
64 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
65 char buf[INET_ADDRSTRLEN];
66
67 zlog_debug("%s: zebra router-id %s update",
68 __PRETTY_FUNCTION__,
69 inet_ntop(AF_INET, &router_id.u.prefix4,
70 buf, INET_ADDRSTRLEN));
71 }
72
73 ospf6_router_id_update();
74
75 return 0;
76 }
77
78 /* redistribute function */
79 void ospf6_zebra_redistribute(int type)
80 {
81 if (vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
82 return;
83 vrf_bitmap_set(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
84
85 if (zclient->sock > 0)
86 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
87 AFI_IP6, type, 0, VRF_DEFAULT);
88 }
89
90 void ospf6_zebra_no_redistribute(int type)
91 {
92 if (!vrf_bitmap_check(zclient->redist[AFI_IP6][type], VRF_DEFAULT))
93 return;
94 vrf_bitmap_unset(zclient->redist[AFI_IP6][type], VRF_DEFAULT);
95 if (zclient->sock > 0)
96 zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
97 AFI_IP6, type, 0, VRF_DEFAULT);
98 }
99
100 /* Inteface addition message from zebra. */
101 static int ospf6_zebra_if_add(int command, struct zclient *zclient,
102 zebra_size_t length, vrf_id_t vrf_id)
103 {
104 struct interface *ifp;
105
106 ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
107 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
108 zlog_debug("Zebra Interface add: %s index %d mtu %d", ifp->name,
109 ifp->ifindex, ifp->mtu6);
110 ospf6_interface_if_add(ifp);
111 return 0;
112 }
113
114 static int ospf6_zebra_if_del(int command, struct zclient *zclient,
115 zebra_size_t length, vrf_id_t vrf_id)
116 {
117 struct interface *ifp;
118
119 if (!(ifp = zebra_interface_state_read(zclient->ibuf, vrf_id)))
120 return 0;
121
122 if (if_is_up(ifp))
123 zlog_warn("Zebra: got delete of %s, but interface is still up",
124 ifp->name);
125
126 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
127 zlog_debug("Zebra Interface delete: %s index %d mtu %d",
128 ifp->name, ifp->ifindex, ifp->mtu6);
129
130 #if 0
131 /* XXX: ospf6_interface_if_del is not the right way to handle this,
132 * because among other thinkable issues, it will also clear all
133 * settings as they are contained in the struct ospf6_interface. */
134 ospf6_interface_if_del (ifp);
135 #endif /*0*/
136
137 if_set_index(ifp, IFINDEX_INTERNAL);
138 return 0;
139 }
140
141 static int ospf6_zebra_if_state_update(int command, struct zclient *zclient,
142 zebra_size_t length, vrf_id_t vrf_id)
143 {
144 struct interface *ifp;
145
146 ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
147 if (ifp == NULL)
148 return 0;
149
150 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
151 zlog_debug(
152 "Zebra Interface state change: "
153 "%s index %d flags %llx metric %d mtu %d bandwidth %d",
154 ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
155 ifp->metric, ifp->mtu6, ifp->bandwidth);
156
157 ospf6_interface_state_update(ifp);
158 return 0;
159 }
160
161 static int ospf6_zebra_if_address_update_add(int command,
162 struct zclient *zclient,
163 zebra_size_t length,
164 vrf_id_t vrf_id)
165 {
166 struct connected *c;
167 char buf[128];
168
169 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD,
170 zclient->ibuf, vrf_id);
171 if (c == NULL)
172 return 0;
173
174 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
175 zlog_debug("Zebra Interface address add: %s %5s %s/%d",
176 c->ifp->name, prefix_family_str(c->address),
177 inet_ntop(c->address->family, &c->address->u.prefix,
178 buf, sizeof(buf)),
179 c->address->prefixlen);
180
181 if (c->address->family == AF_INET6) {
182 ospf6_interface_state_update(c->ifp);
183 ospf6_interface_connected_route_update(c->ifp);
184 }
185 return 0;
186 }
187
188 static int ospf6_zebra_if_address_update_delete(int command,
189 struct zclient *zclient,
190 zebra_size_t length,
191 vrf_id_t vrf_id)
192 {
193 struct connected *c;
194 char buf[128];
195
196 c = zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE,
197 zclient->ibuf, vrf_id);
198 if (c == NULL)
199 return 0;
200
201 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
202 zlog_debug("Zebra Interface address delete: %s %5s %s/%d",
203 c->ifp->name, prefix_family_str(c->address),
204 inet_ntop(c->address->family, &c->address->u.prefix,
205 buf, sizeof(buf)),
206 c->address->prefixlen);
207
208 if (c->address->family == AF_INET6) {
209 ospf6_interface_connected_route_update(c->ifp);
210 ospf6_interface_state_update(c->ifp);
211 }
212
213 connected_free(c);
214
215 return 0;
216 }
217
218 static int ospf6_zebra_read_route(int command, struct zclient *zclient,
219 zebra_size_t length, vrf_id_t vrf_id)
220 {
221 struct zapi_route api;
222 unsigned long ifindex;
223 struct in6_addr *nexthop;
224
225 if (ospf6 == NULL)
226 return 0;
227
228 if (zapi_route_decode(zclient->ibuf, &api) < 0)
229 return -1;
230
231 /* we completely ignore srcdest routes for now. */
232 if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
233 return 0;
234
235 ifindex = api.nexthops[0].ifindex;
236 nexthop = &api.nexthops[0].gate.ipv6;
237
238 if (IS_OSPF6_DEBUG_ZEBRA(RECV)) {
239 char prefixstr[PREFIX2STR_BUFFER], nexthopstr[128];
240 prefix2str((struct prefix *)&api.prefix, prefixstr,
241 sizeof(prefixstr));
242 inet_ntop(AF_INET6, nexthop, nexthopstr, sizeof(nexthopstr));
243
244 zlog_debug(
245 "Zebra Receive route %s: %s %s nexthop %s ifindex %ld tag %" ROUTE_TAG_PRI,
246 (command == ZEBRA_REDISTRIBUTE_ROUTE_ADD ? "add"
247 : "delete"),
248 zebra_route_string(api.type), prefixstr, nexthopstr,
249 ifindex, api.tag);
250 }
251
252 if (command == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
253 ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
254 api.nexthop_num, nexthop, api.tag);
255 else
256 ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix);
257
258 return 0;
259 }
260
261 DEFUN (show_zebra,
262 show_ospf6_zebra_cmd,
263 "show ipv6 ospf6 zebra",
264 SHOW_STR
265 IPV6_STR
266 OSPF6_STR
267 ZEBRA_STR)
268 {
269 int i;
270 if (zclient == NULL) {
271 vty_out(vty, "Not connected to zebra\n");
272 return CMD_SUCCESS;
273 }
274
275 vty_out(vty, "Zebra Infomation\n");
276 vty_out(vty, " fail: %d\n", zclient->fail);
277 vty_out(vty, " redistribute default: %d\n",
278 vrf_bitmap_check(zclient->default_information, VRF_DEFAULT));
279 vty_out(vty, " redistribute:");
280 for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
281 if (vrf_bitmap_check(zclient->redist[AFI_IP6][i], VRF_DEFAULT))
282 vty_out(vty, " %s", zebra_route_string(i));
283 }
284 vty_out(vty, "\n");
285 return CMD_SUCCESS;
286 }
287
288 #define ADD 0
289 #define REM 1
290 static void ospf6_zebra_route_update(int type, struct ospf6_route *request)
291 {
292 struct zapi_route api;
293 char buf[PREFIX2STR_BUFFER];
294 int nhcount;
295 int ret = 0;
296 struct prefix *dest;
297
298 if (IS_OSPF6_DEBUG_ZEBRA(SEND)) {
299 prefix2str(&request->prefix, buf, sizeof(buf));
300 zlog_debug("Send %s route: %s",
301 (type == REM ? "remove" : "add"), buf);
302 }
303
304 if (zclient->sock < 0) {
305 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
306 zlog_debug(" Not connected to Zebra");
307 return;
308 }
309
310 if (request->path.origin.adv_router == ospf6->router_id
311 && (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1
312 || request->path.type == OSPF6_PATH_TYPE_EXTERNAL2)) {
313 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
314 zlog_debug(" Ignore self-originated external route");
315 return;
316 }
317
318 /* If removing is the best path and if there's another path,
319 treat this request as add the secondary path */
320 if (type == REM && ospf6_route_is_best(request) && request->next
321 && ospf6_route_is_same(request, request->next)) {
322 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
323 zlog_debug(
324 " Best-path removal resulted Sencondary addition");
325 type = ADD;
326 request = request->next;
327 }
328
329 /* Only the best path will be sent to zebra. */
330 if (!ospf6_route_is_best(request)) {
331 /* this is not preferred best route, ignore */
332 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
333 zlog_debug(" Ignore non-best route");
334 return;
335 }
336
337 nhcount = ospf6_route_num_nexthops(request);
338 if (nhcount == 0) {
339 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
340 zlog_debug(" No nexthop, ignore");
341 return;
342 }
343
344 dest = &request->prefix;
345
346 memset(&api, 0, sizeof(api));
347 api.vrf_id = VRF_DEFAULT;
348 api.type = ZEBRA_ROUTE_OSPF6;
349 api.safi = SAFI_UNICAST;
350 api.prefix = *dest;
351 SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
352 api.nexthop_num = MIN(nhcount, MULTIPATH_NUM);
353 ospf6_route_zebra_copy_nexthops(request, api.nexthops, api.nexthop_num);
354 SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
355 api.metric = (request->path.metric_type == 2 ? request->path.u.cost_e2
356 : request->path.cost);
357 if (request->path.tag) {
358 SET_FLAG(api.message, ZAPI_MESSAGE_TAG);
359 api.tag = request->path.tag;
360 }
361
362 SET_FLAG(api.message, ZAPI_MESSAGE_DISTANCE);
363 api.distance =
364 ospf6_distance_apply((struct prefix_ipv6 *)dest, request);
365
366 if (type == REM)
367 ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
368 else
369 ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
370
371 if (ret < 0)
372 zlog_err("zclient_route_send() %s failed: %s",
373 (type == REM ? "delete" : "add"),
374 safe_strerror(errno));
375
376 return;
377 }
378
379 void ospf6_zebra_route_update_add(struct ospf6_route *request)
380 {
381 ospf6_zebra_route_update(ADD, request);
382 }
383
384 void ospf6_zebra_route_update_remove(struct ospf6_route *request)
385 {
386 ospf6_zebra_route_update(REM, request);
387 }
388
389 void ospf6_zebra_add_discard(struct ospf6_route *request)
390 {
391 struct zapi_route api;
392 char buf[INET6_ADDRSTRLEN];
393 struct prefix *dest = &request->prefix;
394
395 if (!CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
396 memset(&api, 0, sizeof(api));
397 api.vrf_id = VRF_DEFAULT;
398 api.type = ZEBRA_ROUTE_OSPF6;
399 api.safi = SAFI_UNICAST;
400 api.prefix = *dest;
401 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
402
403 zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
404
405 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
406 zlog_debug("Zebra: Route add discard %s/%d",
407 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
408 INET6_ADDRSTRLEN),
409 dest->prefixlen);
410
411 SET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
412 } else {
413 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
414 zlog_debug(
415 "Zebra: Blackhole route present already %s/%d",
416 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
417 INET6_ADDRSTRLEN),
418 dest->prefixlen);
419 }
420 }
421
422 void ospf6_zebra_delete_discard(struct ospf6_route *request)
423 {
424 struct zapi_route api;
425 char buf[INET6_ADDRSTRLEN];
426 struct prefix *dest = &request->prefix;
427
428 if (CHECK_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED)) {
429 memset(&api, 0, sizeof(api));
430 api.vrf_id = VRF_DEFAULT;
431 api.type = ZEBRA_ROUTE_OSPF6;
432 api.safi = SAFI_UNICAST;
433 api.prefix = *dest;
434 zapi_route_set_blackhole(&api, BLACKHOLE_NULL);
435
436 zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
437
438 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
439 zlog_debug("Zebra: Route delete discard %s/%d",
440 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
441 INET6_ADDRSTRLEN),
442 dest->prefixlen);
443
444 UNSET_FLAG(request->flag, OSPF6_ROUTE_BLACKHOLE_ADDED);
445 } else {
446 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
447 zlog_debug(
448 "Zebra: Blackhole route already deleted %s/%d",
449 inet_ntop(AF_INET6, &dest->u.prefix6, buf,
450 INET6_ADDRSTRLEN),
451 dest->prefixlen);
452 }
453 }
454
455 static struct ospf6_distance *ospf6_distance_new(void)
456 {
457 return XCALLOC(MTYPE_OSPF6_DISTANCE, sizeof(struct ospf6_distance));
458 }
459
460 static void ospf6_distance_free(struct ospf6_distance *odistance)
461 {
462 XFREE(MTYPE_OSPF6_DISTANCE, odistance);
463 }
464
465 int ospf6_distance_set(struct vty *vty, struct ospf6 *o,
466 const char *distance_str, const char *ip_str,
467 const char *access_list_str)
468 {
469 int ret;
470 struct prefix_ipv6 p;
471 u_char distance;
472 struct route_node *rn;
473 struct ospf6_distance *odistance;
474
475 ret = str2prefix_ipv6(ip_str, &p);
476 if (ret == 0) {
477 vty_out(vty, "Malformed prefix\n");
478 return CMD_WARNING_CONFIG_FAILED;
479 }
480
481 distance = atoi(distance_str);
482
483 /* Get OSPF6 distance node. */
484 rn = route_node_get(o->distance_table, (struct prefix *)&p);
485 if (rn->info) {
486 odistance = rn->info;
487 route_unlock_node(rn);
488 } else {
489 odistance = ospf6_distance_new();
490 rn->info = odistance;
491 }
492
493 /* Set distance value. */
494 odistance->distance = distance;
495
496 /* Reset access-list configuration. */
497 if (odistance->access_list) {
498 free(odistance->access_list);
499 odistance->access_list = NULL;
500 }
501 if (access_list_str)
502 odistance->access_list = strdup(access_list_str);
503
504 return CMD_SUCCESS;
505 }
506
507 int ospf6_distance_unset(struct vty *vty, struct ospf6 *o,
508 const char *distance_str, const char *ip_str,
509 const char *access_list_str)
510 {
511 int ret;
512 struct prefix_ipv6 p;
513 struct route_node *rn;
514 struct ospf6_distance *odistance;
515
516 ret = str2prefix_ipv6(ip_str, &p);
517 if (ret == 0) {
518 vty_out(vty, "Malformed prefix\n");
519 return CMD_WARNING_CONFIG_FAILED;
520 }
521
522 rn = route_node_lookup(o->distance_table, (struct prefix *)&p);
523 if (!rn) {
524 vty_out(vty, "Cant't find specified prefix\n");
525 return CMD_WARNING_CONFIG_FAILED;
526 }
527
528 odistance = rn->info;
529
530 if (odistance->access_list)
531 free(odistance->access_list);
532 ospf6_distance_free(odistance);
533
534 rn->info = NULL;
535 route_unlock_node(rn);
536 route_unlock_node(rn);
537
538 return CMD_SUCCESS;
539 }
540
541 void ospf6_distance_reset(struct ospf6 *o)
542 {
543 struct route_node *rn;
544 struct ospf6_distance *odistance;
545
546 for (rn = route_top(o->distance_table); rn; rn = route_next(rn))
547 if ((odistance = rn->info) != NULL) {
548 if (odistance->access_list)
549 free(odistance->access_list);
550 ospf6_distance_free(odistance);
551 rn->info = NULL;
552 route_unlock_node(rn);
553 }
554 }
555
556 u_char ospf6_distance_apply(struct prefix_ipv6 *p, struct ospf6_route * or)
557 {
558 struct ospf6 *o;
559
560 o = ospf6;
561 if (o == NULL)
562 return 0;
563
564 if (o->distance_intra)
565 if (or->path.type == OSPF6_PATH_TYPE_INTRA)
566 return o->distance_intra;
567
568 if (o->distance_inter)
569 if (or->path.type == OSPF6_PATH_TYPE_INTER)
570 return o->distance_inter;
571
572 if (o->distance_external)
573 if (or->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
574 or->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
575 return o->distance_external;
576
577 if (o->distance_all)
578 return o->distance_all;
579
580 return 0;
581 }
582
583 static void ospf6_zebra_connected(struct zclient *zclient)
584 {
585 /* Send the client registration */
586 bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
587
588 zclient_send_reg_requests(zclient, VRF_DEFAULT);
589 }
590
591 void ospf6_zebra_init(struct thread_master *master)
592 {
593 /* Allocate zebra structure. */
594 zclient = zclient_new_notify(master, &zclient_options_default);
595 zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs);
596 zclient->zebra_connected = ospf6_zebra_connected;
597 zclient->router_id_update = ospf6_router_id_update_zebra;
598 zclient->interface_add = ospf6_zebra_if_add;
599 zclient->interface_delete = ospf6_zebra_if_del;
600 zclient->interface_up = ospf6_zebra_if_state_update;
601 zclient->interface_down = ospf6_zebra_if_state_update;
602 zclient->interface_address_add = ospf6_zebra_if_address_update_add;
603 zclient->interface_address_delete =
604 ospf6_zebra_if_address_update_delete;
605 zclient->redistribute_route_add = ospf6_zebra_read_route;
606 zclient->redistribute_route_del = ospf6_zebra_read_route;
607
608 /* Install command element for zebra node. */
609 install_element(VIEW_NODE, &show_ospf6_zebra_cmd);
610 }
611
612 /* Debug */
613
614 DEFUN (debug_ospf6_zebra_sendrecv,
615 debug_ospf6_zebra_sendrecv_cmd,
616 "debug ospf6 zebra [<send|recv>]",
617 DEBUG_STR
618 OSPF6_STR
619 "Debug connection between zebra\n"
620 "Debug Sending zebra\n"
621 "Debug Receiving zebra\n"
622 )
623 {
624 int idx_send_recv = 3;
625 unsigned char level = 0;
626
627 if (argc == 4) {
628 if (strmatch(argv[idx_send_recv]->text, "send"))
629 level = OSPF6_DEBUG_ZEBRA_SEND;
630 else if (strmatch(argv[idx_send_recv]->text, "recv"))
631 level = OSPF6_DEBUG_ZEBRA_RECV;
632 } else
633 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
634
635 OSPF6_DEBUG_ZEBRA_ON(level);
636 return CMD_SUCCESS;
637 }
638
639 DEFUN (no_debug_ospf6_zebra_sendrecv,
640 no_debug_ospf6_zebra_sendrecv_cmd,
641 "no debug ospf6 zebra [<send|recv>]",
642 NO_STR
643 DEBUG_STR
644 OSPF6_STR
645 "Debug connection between zebra\n"
646 "Debug Sending zebra\n"
647 "Debug Receiving zebra\n"
648 )
649 {
650 int idx_send_recv = 4;
651 unsigned char level = 0;
652
653 if (argc == 5) {
654 if (strmatch(argv[idx_send_recv]->text, "send"))
655 level = OSPF6_DEBUG_ZEBRA_SEND;
656 else if (strmatch(argv[idx_send_recv]->text, "recv"))
657 level = OSPF6_DEBUG_ZEBRA_RECV;
658 } else
659 level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
660
661 OSPF6_DEBUG_ZEBRA_OFF(level);
662 return CMD_SUCCESS;
663 }
664
665
666 int config_write_ospf6_debug_zebra(struct vty *vty)
667 {
668 if (IS_OSPF6_DEBUG_ZEBRA(SEND) && IS_OSPF6_DEBUG_ZEBRA(RECV))
669 vty_out(vty, "debug ospf6 zebra\n");
670 else {
671 if (IS_OSPF6_DEBUG_ZEBRA(SEND))
672 vty_out(vty, "debug ospf6 zebra send\n");
673 if (IS_OSPF6_DEBUG_ZEBRA(RECV))
674 vty_out(vty, "debug ospf6 zebra recv\n");
675 }
676 return 0;
677 }
678
679 void install_element_ospf6_debug_zebra(void)
680 {
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_sendrecv_cmd);
684 install_element(CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
685 }