blob: c931a291796f9d478619e2c668a0ea573e257827 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * RIPngd and zebra interface.
3 * Copyright (C) 1998, 1999 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
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 Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
24
25#include "command.h"
26#include "prefix.h"
27#include "stream.h"
28#include "routemap.h"
29#include "zclient.h"
30#include "log.h"
31
32#include "ripngd/ripngd.h"
33
34/* All information about zebra. */
35struct zclient *zclient = NULL;
36
37/* Callback prototypes for zebra client service. */
38int ripng_interface_up (int, struct zclient *, zebra_size_t);
39int ripng_interface_down (int, struct zclient *, zebra_size_t);
40int ripng_interface_add (int, struct zclient *, zebra_size_t);
41int ripng_interface_delete (int, struct zclient *, zebra_size_t);
42int ripng_interface_address_add (int, struct zclient *, zebra_size_t);
43int ripng_interface_address_delete (int, struct zclient *, zebra_size_t);
44
45void
46ripng_zebra_ipv6_add (struct prefix_ipv6 *p, struct in6_addr *nexthop,
hassodeba3552005-08-27 06:19:39 +000047 unsigned int ifindex, u_char metric)
paul718e3742002-12-13 20:15:29 +000048{
49 struct zapi_ipv6 api;
50
51 if (zclient->redist[ZEBRA_ROUTE_RIPNG])
52 {
53 api.type = ZEBRA_ROUTE_RIPNG;
54 api.flags = 0;
55 api.message = 0;
Denis Ovsienkob4e45f62011-12-05 16:35:14 +040056 api.safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +000057 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
58 api.nexthop_num = 1;
59 api.nexthop = &nexthop;
60 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
61 api.ifindex_num = 1;
62 api.ifindex = &ifindex;
hassodeba3552005-08-27 06:19:39 +000063 SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
64 api.metric = metric;
65
paul0a589352004-05-08 11:48:26 +000066 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, p, &api);
paul718e3742002-12-13 20:15:29 +000067 }
68}
69
70void
71ripng_zebra_ipv6_delete (struct prefix_ipv6 *p, struct in6_addr *nexthop,
72 unsigned int ifindex)
73{
74 struct zapi_ipv6 api;
75
76 if (zclient->redist[ZEBRA_ROUTE_RIPNG])
77 {
78 api.type = ZEBRA_ROUTE_RIPNG;
79 api.flags = 0;
80 api.message = 0;
Denis Ovsienkob4e45f62011-12-05 16:35:14 +040081 api.safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +000082 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
83 api.nexthop_num = 1;
84 api.nexthop = &nexthop;
85 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
86 api.ifindex_num = 1;
87 api.ifindex = &ifindex;
88
paul0a589352004-05-08 11:48:26 +000089 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, p, &api);
paul718e3742002-12-13 20:15:29 +000090 }
91}
92
93/* Zebra route add and delete treatment. */
Paul Jakma6ac29a52008-08-15 13:45:30 +010094static int
paul718e3742002-12-13 20:15:29 +000095ripng_zebra_read_ipv6 (int command, struct zclient *zclient,
96 zebra_size_t length)
97{
98 struct stream *s;
99 struct zapi_ipv6 api;
100 unsigned long ifindex;
101 struct in6_addr nexthop;
102 struct prefix_ipv6 p;
103
104 s = zclient->ibuf;
105 ifindex = 0;
106 memset (&nexthop, 0, sizeof (struct in6_addr));
107
108 /* Type, flags, message. */
109 api.type = stream_getc (s);
110 api.flags = stream_getc (s);
111 api.message = stream_getc (s);
112
113 /* IPv6 prefix. */
114 memset (&p, 0, sizeof (struct prefix_ipv6));
115 p.family = AF_INET6;
116 p.prefixlen = stream_getc (s);
117 stream_get (&p.prefix, s, PSIZE (p.prefixlen));
118
119 /* Nexthop, ifindex, distance, metric. */
120 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
121 {
122 api.nexthop_num = stream_getc (s);
123 stream_get (&nexthop, s, 16);
124 }
125 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
126 {
127 api.ifindex_num = stream_getc (s);
128 ifindex = stream_getl (s);
129 }
130 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
131 api.distance = stream_getc (s);
132 else
133 api.distance = 0;
134 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
135 api.metric = stream_getl (s);
136 else
137 api.metric = 0;
138
139 if (command == ZEBRA_IPV6_ROUTE_ADD)
hassoa94434b2003-05-25 17:10:12 +0000140 ripng_redistribute_add (api.type, RIPNG_ROUTE_REDISTRIBUTE, &p, ifindex, &nexthop);
paul718e3742002-12-13 20:15:29 +0000141 else
hassoa94434b2003-05-25 17:10:12 +0000142 ripng_redistribute_delete (api.type, RIPNG_ROUTE_REDISTRIBUTE, &p, ifindex);
paul718e3742002-12-13 20:15:29 +0000143
144 return 0;
145}
146
hassoa94434b2003-05-25 17:10:12 +0000147void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100148ripng_zclient_reset (void)
hassoa94434b2003-05-25 17:10:12 +0000149{
150 zclient_reset (zclient);
151}
152
Paul Jakma6ac29a52008-08-15 13:45:30 +0100153static int
paul718e3742002-12-13 20:15:29 +0000154ripng_redistribute_unset (int type)
155{
156 if (! zclient->redist[type])
157 return CMD_SUCCESS;
158
159 zclient->redist[type] = 0;
160
161 if (zclient->sock > 0)
ajs634f9ea2005-04-11 15:51:40 +0000162 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
paul718e3742002-12-13 20:15:29 +0000163
164 ripng_redistribute_withdraw (type);
165
166 return CMD_SUCCESS;
167}
168
hassoa94434b2003-05-25 17:10:12 +0000169int
170ripng_redistribute_check (int type)
171{
172 return (zclient->redist[type]);
173}
174
Paul Jakma6ac29a52008-08-15 13:45:30 +0100175static void
paul718e3742002-12-13 20:15:29 +0000176ripng_redistribute_metric_set (int type, int metric)
177{
178 ripng->route_map[type].metric_config = 1;
179 ripng->route_map[type].metric = metric;
180}
181
Paul Jakma6ac29a52008-08-15 13:45:30 +0100182static int
paul718e3742002-12-13 20:15:29 +0000183ripng_redistribute_metric_unset (int type)
184{
185 ripng->route_map[type].metric_config = 0;
186 ripng->route_map[type].metric = 0;
hassoa94434b2003-05-25 17:10:12 +0000187 return 0;
paul718e3742002-12-13 20:15:29 +0000188}
189
Paul Jakma6ac29a52008-08-15 13:45:30 +0100190static void
hasso98b718a2004-10-11 12:57:57 +0000191ripng_redistribute_routemap_set (int type, const char *name)
paul718e3742002-12-13 20:15:29 +0000192{
193 if (ripng->route_map[type].name)
194 free (ripng->route_map[type].name);
195
196 ripng->route_map[type].name = strdup (name);
197 ripng->route_map[type].map = route_map_lookup_by_name (name);
198}
199
Paul Jakma6ac29a52008-08-15 13:45:30 +0100200static void
paul718e3742002-12-13 20:15:29 +0000201ripng_redistribute_routemap_unset (int type)
202{
203 if (ripng->route_map[type].name)
204 free (ripng->route_map[type].name);
205
206 ripng->route_map[type].name = NULL;
207 ripng->route_map[type].map = NULL;
208}
paul718e3742002-12-13 20:15:29 +0000209
hassoa94434b2003-05-25 17:10:12 +0000210/* Redistribution types */
211static struct {
212 int type;
213 int str_min_len;
hasso7a1d5832004-10-08 06:32:23 +0000214 const char *str;
hassoa94434b2003-05-25 17:10:12 +0000215} redist_type[] = {
216 {ZEBRA_ROUTE_KERNEL, 1, "kernel"},
217 {ZEBRA_ROUTE_CONNECT, 1, "connected"},
218 {ZEBRA_ROUTE_STATIC, 1, "static"},
219 {ZEBRA_ROUTE_OSPF6, 1, "ospf6"},
220 {ZEBRA_ROUTE_BGP, 1, "bgp"},
221 {0, 0, NULL}
222};
223
224void
225ripng_redistribute_clean ()
226{
227 int i;
228
229 for (i = 0; redist_type[i].str; i++)
230 {
231 if (zclient->redist[redist_type[i].type])
232 {
233 if (zclient->sock > 0)
234 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
ajs634f9ea2005-04-11 15:51:40 +0000235 zclient, redist_type[i].type);
hassoa94434b2003-05-25 17:10:12 +0000236
237 zclient->redist[redist_type[i].type] = 0;
238
239 /* Remove the routes from RIPng table. */
240 ripng_redistribute_withdraw (redist_type[i].type);
241 }
242 }
243}
244
paul718e3742002-12-13 20:15:29 +0000245DEFUN (router_zebra,
246 router_zebra_cmd,
247 "router zebra",
248 "Enable a routing process\n"
249 "Make connection to zebra daemon\n")
250{
251 vty->node = ZEBRA_NODE;
252 zclient->enable = 1;
253 zclient_start (zclient);
254 return CMD_SUCCESS;
255}
256
257DEFUN (no_router_zebra,
258 no_router_zebra_cmd,
259 "no router zebra",
260 NO_STR
261 "Disable a routing process\n"
262 "Stop connection to zebra daemon\n")
263{
264 zclient->enable = 0;
265 zclient_stop (zclient);
266 return CMD_SUCCESS;
267}
268
269DEFUN (ripng_redistribute_ripng,
270 ripng_redistribute_ripng_cmd,
271 "redistribute ripng",
272 "Redistribute information from another routing protocol\n"
273 "RIPng route\n")
274{
275 zclient->redist[ZEBRA_ROUTE_RIPNG] = 1;
276 return CMD_SUCCESS;
277}
278
279DEFUN (no_ripng_redistribute_ripng,
280 no_ripng_redistribute_ripng_cmd,
281 "no redistribute ripng",
282 NO_STR
283 "Redistribute information from another routing protocol\n"
284 "RIPng route\n")
285{
286 zclient->redist[ZEBRA_ROUTE_RIPNG] = 0;
287 return CMD_SUCCESS;
288}
289
hassoa94434b2003-05-25 17:10:12 +0000290DEFUN (ripng_redistribute_type,
291 ripng_redistribute_type_cmd,
292 "redistribute (kernel|connected|static|ospf6|bgp)",
paul718e3742002-12-13 20:15:29 +0000293 "Redistribute information from another routing protocol\n"
hassoa94434b2003-05-25 17:10:12 +0000294 "Kernel routes\n"
295 "Connected\n"
296 "Static routes\n"
297 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000298 "Border Gateway Protocol (BGP)\n")
299{
hassoa94434b2003-05-25 17:10:12 +0000300 int i;
301
302 for(i = 0; redist_type[i].str; i++)
303 {
304 if (strncmp (redist_type[i].str, argv[0],
305 redist_type[i].str_min_len) == 0)
306 {
paul0a589352004-05-08 11:48:26 +0000307 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
hassoa94434b2003-05-25 17:10:12 +0000308 return CMD_SUCCESS;
309 }
310 }
311
312 vty_out(vty, "Invalid type %s%s", argv[0],
313 VTY_NEWLINE);
314
315 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000316}
317
hassoa94434b2003-05-25 17:10:12 +0000318DEFUN (no_ripng_redistribute_type,
319 no_ripng_redistribute_type_cmd,
320 "no redistribute (kernel|connected|static|ospf6|bgp)",
paul718e3742002-12-13 20:15:29 +0000321 NO_STR
322 "Redistribute information from another routing protocol\n"
hassoa94434b2003-05-25 17:10:12 +0000323 "Kernel routes\n"
324 "Connected\n"
325 "Static routes\n"
326 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000327 "Border Gateway Protocol (BGP)\n")
328{
hassoa94434b2003-05-25 17:10:12 +0000329 int i;
330
331 for (i = 0; redist_type[i].str; i++)
332 {
333 if (strncmp(redist_type[i].str, argv[0],
334 redist_type[i].str_min_len) == 0)
335 {
336 ripng_redistribute_metric_unset (redist_type[i].type);
337 ripng_redistribute_routemap_unset (redist_type[i].type);
338 return ripng_redistribute_unset (redist_type[i].type);
339 }
340 }
341
342 vty_out(vty, "Invalid type %s%s", argv[0],
343 VTY_NEWLINE);
344
345 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000346}
347
paul718e3742002-12-13 20:15:29 +0000348
hassoa94434b2003-05-25 17:10:12 +0000349DEFUN (ripng_redistribute_type_metric,
350 ripng_redistribute_type_metric_cmd,
351 "redistribute (kernel|connected|static|ospf6|bgp) metric <0-16>",
paul718e3742002-12-13 20:15:29 +0000352 "Redistribute information from another routing protocol\n"
353 "Kernel routes\n"
paul718e3742002-12-13 20:15:29 +0000354 "Connected\n"
paul718e3742002-12-13 20:15:29 +0000355 "Static routes\n"
hassoa94434b2003-05-25 17:10:12 +0000356 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000357 "Border Gateway Protocol (BGP)\n"
358 "Metric\n"
359 "Metric value\n")
360{
hassoa94434b2003-05-25 17:10:12 +0000361 int i;
362 int metric;
363
364 metric = atoi (argv[1]);
365
366 for (i = 0; redist_type[i].str; i++) {
367 if (strncmp(redist_type[i].str, argv[0],
368 redist_type[i].str_min_len) == 0)
369 {
370 ripng_redistribute_metric_set (redist_type[i].type, metric);
paul0a589352004-05-08 11:48:26 +0000371 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
hassoa94434b2003-05-25 17:10:12 +0000372 return CMD_SUCCESS;
373 }
374 }
375
376 vty_out(vty, "Invalid type %s%s", argv[0],
377 VTY_NEWLINE);
378
379 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000380}
381
hassoa94434b2003-05-25 17:10:12 +0000382ALIAS (no_ripng_redistribute_type,
383 no_ripng_redistribute_type_metric_cmd,
384 "no redistribute (kernel|connected|static|ospf6|bgp) metric <0-16>",
paul718e3742002-12-13 20:15:29 +0000385 NO_STR
386 "Redistribute information from another routing protocol\n"
hassoa94434b2003-05-25 17:10:12 +0000387 "Kernel routes\n"
388 "Connected\n"
389 "Static routes\n"
390 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000391 "Border Gateway Protocol (BGP)\n"
392 "Metric\n"
393 "Metric value\n")
394
hassoa94434b2003-05-25 17:10:12 +0000395DEFUN (ripng_redistribute_type_routemap,
396 ripng_redistribute_type_routemap_cmd,
397 "redistribute (kernel|connected|static|ospf6|bgp) route-map WORD",
paul718e3742002-12-13 20:15:29 +0000398 "Redistribute information from another routing protocol\n"
399 "Kernel routes\n"
paul718e3742002-12-13 20:15:29 +0000400 "Connected\n"
paul718e3742002-12-13 20:15:29 +0000401 "Static routes\n"
hassoa94434b2003-05-25 17:10:12 +0000402 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000403 "Border Gateway Protocol (BGP)\n"
404 "Route map reference\n"
405 "Pointer to route-map entries\n")
406{
hassoa94434b2003-05-25 17:10:12 +0000407 int i;
408
409 for (i = 0; redist_type[i].str; i++) {
410 if (strncmp(redist_type[i].str, argv[0],
411 redist_type[i].str_min_len) == 0)
412 {
413 ripng_redistribute_routemap_set (redist_type[i].type, argv[1]);
paul0a589352004-05-08 11:48:26 +0000414 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
hassoa94434b2003-05-25 17:10:12 +0000415 return CMD_SUCCESS;
416 }
417 }
418
419 vty_out(vty, "Invalid type %s%s", argv[0],
420 VTY_NEWLINE);
421
422 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000423}
424
hassoa94434b2003-05-25 17:10:12 +0000425ALIAS (no_ripng_redistribute_type,
426 no_ripng_redistribute_type_routemap_cmd,
427 "no redistribute (kernel|connected|static|ospf6|bgp) route-map WORD",
paul718e3742002-12-13 20:15:29 +0000428 NO_STR
429 "Redistribute information from another routing protocol\n"
hassoa94434b2003-05-25 17:10:12 +0000430 "Kernel routes\n"
431 "Connected\n"
432 "Static routes\n"
433 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000434 "Border Gateway Protocol (BGP)\n"
435 "Route map reference\n"
436 "Pointer to route-map entries\n")
437
hassoa94434b2003-05-25 17:10:12 +0000438DEFUN (ripng_redistribute_type_metric_routemap,
439 ripng_redistribute_type_metric_routemap_cmd,
440 "redistribute (kernel|connected|static|ospf6|bgp) metric <0-16> route-map WORD",
paul718e3742002-12-13 20:15:29 +0000441 "Redistribute information from another routing protocol\n"
442 "Kernel routes\n"
paul718e3742002-12-13 20:15:29 +0000443 "Connected\n"
paul718e3742002-12-13 20:15:29 +0000444 "Static routes\n"
hassoa94434b2003-05-25 17:10:12 +0000445 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000446 "Border Gateway Protocol (BGP)\n"
447 "Metric\n"
448 "Metric value\n"
449 "Route map reference\n"
450 "Pointer to route-map entries\n")
451{
hassoa94434b2003-05-25 17:10:12 +0000452 int i;
453 int metric;
454
455 metric = atoi (argv[1]);
456
457 for (i = 0; redist_type[i].str; i++) {
458 if (strncmp(redist_type[i].str, argv[0],
459 redist_type[i].str_min_len) == 0)
460 {
461 ripng_redistribute_metric_set (redist_type[i].type, metric);
462 ripng_redistribute_routemap_set (redist_type[i].type, argv[2]);
paul0a589352004-05-08 11:48:26 +0000463 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
hassoa94434b2003-05-25 17:10:12 +0000464 return CMD_SUCCESS;
465 }
466 }
467
468 vty_out(vty, "Invalid type %s%s", argv[0],
469 VTY_NEWLINE);
470
471 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +0000472}
473
hassoa94434b2003-05-25 17:10:12 +0000474ALIAS (no_ripng_redistribute_type,
475 no_ripng_redistribute_type_metric_routemap_cmd,
476 "no redistribute (kernel|connected|static|ospf6|bgp) metric <0-16> route-map WORD",
paul718e3742002-12-13 20:15:29 +0000477 NO_STR
478 "Redistribute information from another routing protocol\n"
hassoa94434b2003-05-25 17:10:12 +0000479 "Kernel routes\n"
480 "Connected\n"
481 "Static routes\n"
482 "Open Shortest Path First (OSPFv3)\n"
paul718e3742002-12-13 20:15:29 +0000483 "Border Gateway Protocol (BGP)\n"
paul718e3742002-12-13 20:15:29 +0000484 "Route map reference\n"
485 "Pointer to route-map entries\n")
486
487void
hassoa94434b2003-05-25 17:10:12 +0000488ripng_redistribute_write (struct vty *vty, int config_mode)
paul718e3742002-12-13 20:15:29 +0000489{
490 int i;
paul718e3742002-12-13 20:15:29 +0000491
492 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
493 if (i != zclient->redist_default && zclient->redist[i])
494 {
hassoa94434b2003-05-25 17:10:12 +0000495 if (config_mode)
496 {
497 if (ripng->route_map[i].metric_config)
498 {
499 if (ripng->route_map[i].name)
500 vty_out (vty, " redistribute %s metric %d route-map %s%s",
ajsf52d13c2005-10-01 17:38:06 +0000501 zebra_route_string(i), ripng->route_map[i].metric,
hassoa94434b2003-05-25 17:10:12 +0000502 ripng->route_map[i].name, VTY_NEWLINE);
503 else
504 vty_out (vty, " redistribute %s metric %d%s",
ajsf52d13c2005-10-01 17:38:06 +0000505 zebra_route_string(i), ripng->route_map[i].metric,
506 VTY_NEWLINE);
hassoa94434b2003-05-25 17:10:12 +0000507 }
508 else
509 {
510 if (ripng->route_map[i].name)
511 vty_out (vty, " redistribute %s route-map %s%s",
ajsf52d13c2005-10-01 17:38:06 +0000512 zebra_route_string(i), ripng->route_map[i].name,
513 VTY_NEWLINE);
hassoa94434b2003-05-25 17:10:12 +0000514 else
ajsf52d13c2005-10-01 17:38:06 +0000515 vty_out (vty, " redistribute %s%s", zebra_route_string(i),
516 VTY_NEWLINE);
hassoa94434b2003-05-25 17:10:12 +0000517 }
518 }
519 else
ajsf52d13c2005-10-01 17:38:06 +0000520 vty_out (vty, " %s", zebra_route_string(i));
paul718e3742002-12-13 20:15:29 +0000521 }
522}
523
524/* RIPng configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100525static int
paul718e3742002-12-13 20:15:29 +0000526zebra_config_write (struct vty *vty)
527{
528 if (! zclient->enable)
529 {
530 vty_out (vty, "no router zebra%s", VTY_NEWLINE);
531 return 1;
532 }
533 else if (! zclient->redist[ZEBRA_ROUTE_RIPNG])
534 {
535 vty_out (vty, "router zebra%s", VTY_NEWLINE);
536 vty_out (vty, " no redistribute ripng%s", VTY_NEWLINE);
537 return 1;
538 }
539 return 0;
540}
541
542/* Zebra node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -0800543static struct cmd_node zebra_node =
paul718e3742002-12-13 20:15:29 +0000544{
545 ZEBRA_NODE,
546 "%s(config-router)# ",
547};
548
549/* Initialize zebra structure and it's commands. */
550void
551zebra_init ()
552{
553 /* Allocate zebra structure. */
554 zclient = zclient_new ();
555 zclient_init (zclient, ZEBRA_ROUTE_RIPNG);
556
557 zclient->interface_up = ripng_interface_up;
558 zclient->interface_down = ripng_interface_down;
559 zclient->interface_add = ripng_interface_add;
560 zclient->interface_delete = ripng_interface_delete;
561 zclient->interface_address_add = ripng_interface_address_add;
562 zclient->interface_address_delete = ripng_interface_address_delete;
563 zclient->ipv6_route_add = ripng_zebra_read_ipv6;
564 zclient->ipv6_route_delete = ripng_zebra_read_ipv6;
565
566 /* Install zebra node. */
567 install_node (&zebra_node, zebra_config_write);
568
569 /* Install command element for zebra node. */
570 install_element (CONFIG_NODE, &router_zebra_cmd);
571 install_element (CONFIG_NODE, &no_router_zebra_cmd);
572 install_default (ZEBRA_NODE);
573 install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd);
574 install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd);
hassoa94434b2003-05-25 17:10:12 +0000575
576 /* Install command elements to ripng node */
577 install_element (RIPNG_NODE, &ripng_redistribute_type_cmd);
578 install_element (RIPNG_NODE, &ripng_redistribute_type_routemap_cmd);
579 install_element (RIPNG_NODE, &ripng_redistribute_type_metric_cmd);
580 install_element (RIPNG_NODE, &ripng_redistribute_type_metric_routemap_cmd);
581 install_element (RIPNG_NODE, &no_ripng_redistribute_type_cmd);
582 install_element (RIPNG_NODE, &no_ripng_redistribute_type_routemap_cmd);
583 install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_cmd);
584 install_element (RIPNG_NODE, &no_ripng_redistribute_type_metric_routemap_cmd);
paul718e3742002-12-13 20:15:29 +0000585}