]> git.proxmox.com Git - mirror_frr.git/blob - ripd/rip_zebra.c
ospf6d: fix decimal area ID cli
[mirror_frr.git] / ripd / rip_zebra.c
1 /* RIPd and zebra interface.
2 * Copyright (C) 1997, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
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 Free
18 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 * 02111-1307, USA.
20 */
21
22 #include <zebra.h>
23
24 #include "command.h"
25 #include "prefix.h"
26 #include "table.h"
27 #include "stream.h"
28 #include "memory.h"
29 #include "routemap.h"
30 #include "zclient.h"
31 #include "log.h"
32 #include "vrf.h"
33 #include "ripd/ripd.h"
34 #include "ripd/rip_debug.h"
35 #include "ripd/rip_interface.h"
36
37 /* All information about zebra. */
38 struct zclient *zclient = NULL;
39
40 /* Send ECMP routes to zebra. */
41 static void
42 rip_zebra_ipv4_send (struct route_node *rp, u_char cmd)
43 {
44 static struct in_addr **nexthops = NULL;
45 static unsigned int nexthops_len = 0;
46
47 struct list *list = (struct list *)rp->info;
48 struct zapi_ipv4 api;
49 struct listnode *listnode = NULL;
50 struct rip_info *rinfo = NULL;
51 int count = 0;
52
53 if (vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT))
54 {
55 api.vrf_id = VRF_DEFAULT;
56 api.type = ZEBRA_ROUTE_RIP;
57 api.instance = 0;
58 api.flags = 0;
59 api.message = 0;
60 api.safi = SAFI_UNICAST;
61
62 if (nexthops_len < listcount (list))
63 {
64 nexthops_len = listcount (list);
65 nexthops = XREALLOC (MTYPE_TMP, nexthops,
66 nexthops_len * sizeof (struct in_addr *));
67 }
68
69 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
70 for (ALL_LIST_ELEMENTS_RO (list, listnode, rinfo))
71 {
72 nexthops[count++] = &rinfo->nexthop;
73 if (cmd == ZEBRA_IPV4_ROUTE_ADD)
74 SET_FLAG (rinfo->flags, RIP_RTF_FIB);
75 else
76 UNSET_FLAG (rinfo->flags, RIP_RTF_FIB);
77 }
78
79 api.nexthop = nexthops;
80 api.nexthop_num = count;
81 api.ifindex_num = 0;
82
83 rinfo = listgetdata (listhead (list));
84
85 SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
86 api.metric = rinfo->metric;
87
88 if (rinfo->distance && rinfo->distance != ZEBRA_RIP_DISTANCE_DEFAULT)
89 {
90 SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
91 api.distance = rinfo->distance;
92 }
93
94 if (rinfo->tag)
95 {
96 SET_FLAG (api.message, ZAPI_MESSAGE_TAG);
97 api.tag = rinfo->tag;
98 }
99
100 zapi_ipv4_route (cmd, zclient,
101 (struct prefix_ipv4 *)&rp->p, &api);
102
103 if (IS_RIP_DEBUG_ZEBRA)
104 {
105 if (rip->ecmp)
106 zlog_debug ("%s: %s/%d nexthops %d",
107 (cmd == ZEBRA_IPV4_ROUTE_ADD) ? \
108 "Install into zebra" : "Delete from zebra",
109 inet_ntoa (rp->p.u.prefix4), rp->p.prefixlen, count);
110 else
111 zlog_debug ("%s: %s/%d",
112 (cmd == ZEBRA_IPV4_ROUTE_ADD) ? \
113 "Install into zebra" : "Delete from zebra",
114 inet_ntoa (rp->p.u.prefix4), rp->p.prefixlen);
115 }
116
117 rip_global_route_changes++;
118 }
119 }
120
121 /* Add/update ECMP routes to zebra. */
122 void
123 rip_zebra_ipv4_add (struct route_node *rp)
124 {
125 rip_zebra_ipv4_send (rp, ZEBRA_IPV4_ROUTE_ADD);
126 }
127
128 /* Delete ECMP routes from zebra. */
129 void
130 rip_zebra_ipv4_delete (struct route_node *rp)
131 {
132 rip_zebra_ipv4_send (rp, ZEBRA_IPV4_ROUTE_DELETE);
133 }
134
135 /* Zebra route add and delete treatment. */
136 static int
137 rip_zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length,
138 vrf_id_t vrf_id)
139 {
140 struct stream *s;
141 struct zapi_ipv4 api;
142 unsigned long ifindex;
143 struct in_addr nexthop;
144 struct prefix_ipv4 p;
145
146 if (!rip)
147 return 0;
148
149 s = zclient->ibuf;
150 ifindex = 0;
151 nexthop.s_addr = 0;
152
153 /* Type, flags, message. */
154 api.type = stream_getc (s);
155 api.instance = stream_getw (s);
156 api.flags = stream_getl (s);
157 api.message = stream_getc (s);
158
159 /* IPv4 prefix. */
160 memset (&p, 0, sizeof (struct prefix_ipv4));
161 p.family = AF_INET;
162 p.prefixlen = MIN(IPV4_MAX_PREFIXLEN, stream_getc (s));
163 stream_get (&p.prefix, s, PSIZE (p.prefixlen));
164
165 /* Nexthop, ifindex, distance, metric. */
166 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
167 {
168 api.nexthop_num = stream_getc (s);
169 nexthop.s_addr = stream_get_ipv4 (s);
170 }
171 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
172 {
173 api.ifindex_num = stream_getc (s);
174 ifindex = stream_getl (s);
175 }
176 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
177 api.distance = stream_getc (s);
178 else
179 api.distance = 255;
180 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
181 api.metric = stream_getl (s);
182 else
183 api.metric = 0;
184
185 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_TAG))
186 api.tag = stream_getl (s);
187 else
188 api.tag = 0;
189
190 /* Then fetch IPv4 prefixes. */
191 if (command == ZEBRA_REDISTRIBUTE_IPV4_ADD)
192 rip_redistribute_add (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex,
193 &nexthop, api.metric, api.distance, api.tag);
194 else if (command == ZEBRA_REDISTRIBUTE_IPV4_DEL)
195 rip_redistribute_delete (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex);
196
197 return 0;
198 }
199
200 void
201 rip_zclient_reset (void)
202 {
203 zclient_reset (zclient);
204 }
205
206 /* RIP route-map set for redistribution */
207 static void
208 rip_routemap_set (int type, const char *name)
209 {
210 if (rip->route_map[type].name)
211 free(rip->route_map[type].name);
212
213 rip->route_map[type].name = strdup (name);
214 rip->route_map[type].map = route_map_lookup_by_name (name);
215 }
216
217 static void
218 rip_redistribute_metric_set (int type, unsigned int metric)
219 {
220 rip->route_map[type].metric_config = 1;
221 rip->route_map[type].metric = metric;
222 }
223
224 static int
225 rip_metric_unset (int type, unsigned int metric)
226 {
227 #define DONT_CARE_METRIC_RIP 17
228 if (metric != DONT_CARE_METRIC_RIP &&
229 rip->route_map[type].metric != metric)
230 return 1;
231 rip->route_map[type].metric_config = 0;
232 rip->route_map[type].metric = 0;
233 return 0;
234 }
235
236 /* RIP route-map unset for redistribution */
237 static int
238 rip_routemap_unset (int type, const char *name)
239 {
240 if (! rip->route_map[type].name ||
241 (name != NULL && strcmp(rip->route_map[type].name,name)))
242 return 1;
243
244 free (rip->route_map[type].name);
245 rip->route_map[type].name = NULL;
246 rip->route_map[type].map = NULL;
247
248 return 0;
249 }
250
251 /* Redistribution types */
252 static struct {
253 int type;
254 int str_min_len;
255 const char *str;
256 } redist_type[] = {
257 {ZEBRA_ROUTE_KERNEL, 1, "kernel"},
258 {ZEBRA_ROUTE_CONNECT, 1, "connected"},
259 {ZEBRA_ROUTE_STATIC, 1, "static"},
260 {ZEBRA_ROUTE_OSPF, 1, "ospf"},
261 {ZEBRA_ROUTE_BGP, 2, "bgp"},
262 {ZEBRA_ROUTE_VNC, 1, "vnc"},
263 {0, 0, NULL}
264 };
265
266 DEFUN (router_zebra,
267 router_zebra_cmd,
268 "router zebra",
269 "Enable a routing process\n"
270 "Make connection to zebra daemon\n")
271 {
272 vty->node = ZEBRA_NODE;
273 zclient->enable = 1;
274 zclient_start (zclient);
275 return CMD_SUCCESS;
276 }
277
278 DEFUN (no_router_zebra,
279 no_router_zebra_cmd,
280 "no router zebra",
281 NO_STR
282 "Enable a routing process\n"
283 "Make connection to zebra daemon\n")
284 {
285 zclient->enable = 0;
286 zclient_stop (zclient);
287 return CMD_SUCCESS;
288 }
289
290 #if 0
291 static int
292 rip_redistribute_set (int type)
293 {
294 if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT))
295 return CMD_SUCCESS;
296
297 vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT);
298
299 if (zclient->sock > 0)
300 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type);
301
302 return CMD_SUCCESS;
303 }
304 #endif
305
306 static int
307 rip_redistribute_unset (int type)
308 {
309 if (! vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT))
310 return CMD_SUCCESS;
311
312 vrf_bitmap_unset (zclient->redist[AFI_IP][type], VRF_DEFAULT);
313
314 if (zclient->sock > 0)
315 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
316
317 /* Remove the routes from RIP table. */
318 rip_redistribute_withdraw (type);
319
320 return CMD_SUCCESS;
321 }
322
323 int
324 rip_redistribute_check (int type)
325 {
326 return vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT);
327 }
328
329 void
330 rip_redistribute_clean (void)
331 {
332 int i;
333
334 for (i = 0; redist_type[i].str; i++)
335 {
336 if (vrf_bitmap_check (zclient->redist[AFI_IP][redist_type[i].type], VRF_DEFAULT))
337 {
338 if (zclient->sock > 0)
339 zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
340 zclient, AFI_IP, redist_type[i].type, 0,
341 VRF_DEFAULT);
342
343 vrf_bitmap_unset (zclient->redist[AFI_IP][redist_type[i].type], VRF_DEFAULT);
344
345 /* Remove the routes from RIP table. */
346 rip_redistribute_withdraw (redist_type[i].type);
347 }
348 }
349 }
350
351 DEFUN (rip_redistribute_rip,
352 rip_redistribute_rip_cmd,
353 "redistribute rip",
354 "Redistribute information from another routing protocol\n"
355 "Routing Information Protocol (RIP)\n")
356 {
357 vrf_bitmap_set (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT);
358 return CMD_SUCCESS;
359 }
360
361 DEFUN (no_rip_redistribute_rip,
362 no_rip_redistribute_rip_cmd,
363 "no redistribute rip",
364 NO_STR
365 "Redistribute information from another routing protocol\n"
366 "Routing Information Protocol (RIP)\n")
367 {
368 vrf_bitmap_unset (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT);
369 return CMD_SUCCESS;
370 }
371
372 DEFUN (rip_redistribute_type,
373 rip_redistribute_type_cmd,
374 "redistribute " FRR_REDIST_STR_RIPD,
375 REDIST_STR
376 FRR_REDIST_HELP_STR_RIPD)
377 {
378 int i;
379
380 for(i = 0; redist_type[i].str; i++)
381 {
382 if (strncmp (redist_type[i].str, argv[0],
383 redist_type[i].str_min_len) == 0)
384 {
385 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient,
386 AFI_IP, redist_type[i].type, 0, VRF_DEFAULT);
387 return CMD_SUCCESS;
388 }
389 }
390
391 vty_out(vty, "Invalid type %s%s", argv[0],
392 VTY_NEWLINE);
393
394 return CMD_WARNING;
395 }
396
397 DEFUN (no_rip_redistribute_type,
398 no_rip_redistribute_type_cmd,
399 "no redistribute " FRR_REDIST_STR_RIPD,
400 NO_STR
401 REDIST_STR
402 FRR_REDIST_HELP_STR_RIPD)
403 {
404 int i;
405
406 for (i = 0; redist_type[i].str; i++)
407 {
408 if (strncmp(redist_type[i].str, argv[0],
409 redist_type[i].str_min_len) == 0)
410 {
411 rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP);
412 rip_routemap_unset (redist_type[i].type,NULL);
413 rip_redistribute_unset (redist_type[i].type);
414 return CMD_SUCCESS;
415 }
416 }
417
418 vty_out(vty, "Invalid type %s%s", argv[0],
419 VTY_NEWLINE);
420
421 return CMD_WARNING;
422 }
423
424 DEFUN (rip_redistribute_type_routemap,
425 rip_redistribute_type_routemap_cmd,
426 "redistribute " FRR_REDIST_STR_RIPD " route-map WORD",
427 REDIST_STR
428 FRR_REDIST_HELP_STR_RIPD
429 "Route map reference\n"
430 "Pointer to route-map entries\n")
431 {
432 int i;
433
434 for (i = 0; redist_type[i].str; i++) {
435 if (strncmp(redist_type[i].str, argv[0],
436 redist_type[i].str_min_len) == 0)
437 {
438 rip_routemap_set (redist_type[i].type, argv[1]);
439 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
440 redist_type[i].type, 0, VRF_DEFAULT);
441 return CMD_SUCCESS;
442 }
443 }
444
445 vty_out(vty, "Invalid type %s%s", argv[0],
446 VTY_NEWLINE);
447
448 return CMD_WARNING;
449 }
450
451 DEFUN (no_rip_redistribute_type_routemap,
452 no_rip_redistribute_type_routemap_cmd,
453 "no redistribute " FRR_REDIST_STR_RIPD " route-map WORD",
454 NO_STR
455 REDIST_STR
456 FRR_REDIST_HELP_STR_RIPD
457 "Route map reference\n"
458 "Pointer to route-map entries\n")
459 {
460 int i;
461
462 for (i = 0; redist_type[i].str; i++)
463 {
464 if (strncmp(redist_type[i].str, argv[0],
465 redist_type[i].str_min_len) == 0)
466 {
467 if (rip_routemap_unset (redist_type[i].type,argv[1]))
468 return CMD_WARNING;
469 rip_redistribute_unset (redist_type[i].type);
470 return CMD_SUCCESS;
471 }
472 }
473
474 vty_out(vty, "Invalid type %s%s", argv[0],
475 VTY_NEWLINE);
476
477 return CMD_WARNING;
478 }
479
480 DEFUN (rip_redistribute_type_metric,
481 rip_redistribute_type_metric_cmd,
482 "redistribute " FRR_REDIST_STR_RIPD " metric <0-16>",
483 REDIST_STR
484 FRR_REDIST_HELP_STR_RIPD
485 "Metric\n"
486 "Metric value\n")
487 {
488 int i;
489 int metric;
490
491 metric = atoi (argv[1]);
492
493 for (i = 0; redist_type[i].str; i++) {
494 if (strncmp(redist_type[i].str, argv[0],
495 redist_type[i].str_min_len) == 0)
496 {
497 rip_redistribute_metric_set (redist_type[i].type, metric);
498 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
499 redist_type[i].type, 0, VRF_DEFAULT);
500 return CMD_SUCCESS;
501 }
502 }
503
504 vty_out(vty, "Invalid type %s%s", argv[0],
505 VTY_NEWLINE);
506
507 return CMD_WARNING;
508 }
509
510 DEFUN (no_rip_redistribute_type_metric,
511 no_rip_redistribute_type_metric_cmd,
512 "no redistribute " FRR_REDIST_STR_RIPD " metric <0-16>",
513 NO_STR
514 REDIST_STR
515 FRR_REDIST_HELP_STR_RIPD
516 "Metric\n"
517 "Metric value\n")
518 {
519 int i;
520
521 for (i = 0; redist_type[i].str; i++)
522 {
523 if (strncmp(redist_type[i].str, argv[0],
524 redist_type[i].str_min_len) == 0)
525 {
526 if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
527 return CMD_WARNING;
528 rip_redistribute_unset (redist_type[i].type);
529 return CMD_SUCCESS;
530 }
531 }
532
533 vty_out(vty, "Invalid type %s%s", argv[0],
534 VTY_NEWLINE);
535
536 return CMD_WARNING;
537 }
538
539 DEFUN (rip_redistribute_type_metric_routemap,
540 rip_redistribute_type_metric_routemap_cmd,
541 "redistribute " FRR_REDIST_STR_RIPD " metric <0-16> route-map WORD",
542 REDIST_STR
543 FRR_REDIST_HELP_STR_RIPD
544 "Metric\n"
545 "Metric value\n"
546 "Route map reference\n"
547 "Pointer to route-map entries\n")
548 {
549 int i;
550 int metric;
551
552 metric = atoi (argv[1]);
553
554 for (i = 0; redist_type[i].str; i++) {
555 if (strncmp(redist_type[i].str, argv[0],
556 redist_type[i].str_min_len) == 0)
557 {
558 rip_redistribute_metric_set (redist_type[i].type, metric);
559 rip_routemap_set (redist_type[i].type, argv[2]);
560 zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
561 redist_type[i].type, 0, VRF_DEFAULT);
562 return CMD_SUCCESS;
563 }
564 }
565
566 vty_out(vty, "Invalid type %s%s", argv[0],
567 VTY_NEWLINE);
568
569 return CMD_WARNING;
570 }
571
572
573 DEFUN (no_rip_redistribute_type_metric_routemap,
574 no_rip_redistribute_type_metric_routemap_cmd,
575 "no redistribute " FRR_REDIST_STR_RIPD
576 " metric <0-16> route-map WORD",
577 NO_STR
578 REDIST_STR
579 FRR_REDIST_HELP_STR_RIPD
580 "Metric\n"
581 "Metric value\n"
582 "Route map reference\n"
583 "Pointer to route-map entries\n")
584 {
585 int i;
586
587 for (i = 0; redist_type[i].str; i++)
588 {
589 if (strncmp(redist_type[i].str, argv[0],
590 redist_type[i].str_min_len) == 0)
591 {
592 if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
593 return CMD_WARNING;
594 if (rip_routemap_unset (redist_type[i].type, argv[2]))
595 {
596 rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1]));
597 return CMD_WARNING;
598 }
599 rip_redistribute_unset (redist_type[i].type);
600 return CMD_SUCCESS;
601 }
602 }
603
604 vty_out(vty, "Invalid type %s%s", argv[0],
605 VTY_NEWLINE);
606
607 return CMD_WARNING;
608 }
609
610 /* Default information originate. */
611
612 DEFUN (rip_default_information_originate,
613 rip_default_information_originate_cmd,
614 "default-information originate",
615 "Control distribution of default route\n"
616 "Distribute a default route\n")
617 {
618 struct prefix_ipv4 p;
619
620 if (! rip->default_information)
621 {
622 memset (&p, 0, sizeof (struct prefix_ipv4));
623 p.family = AF_INET;
624
625 rip->default_information = 1;
626
627 rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0,
628 NULL, 0, 0, 0);
629 }
630
631 return CMD_SUCCESS;
632 }
633
634 DEFUN (no_rip_default_information_originate,
635 no_rip_default_information_originate_cmd,
636 "no default-information originate",
637 NO_STR
638 "Control distribution of default route\n"
639 "Distribute a default route\n")
640 {
641 struct prefix_ipv4 p;
642
643 if (rip->default_information)
644 {
645 memset (&p, 0, sizeof (struct prefix_ipv4));
646 p.family = AF_INET;
647
648 rip->default_information = 0;
649
650 rip_redistribute_delete (ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0);
651 }
652
653 return CMD_SUCCESS;
654 }
655
656 /* RIP configuration write function. */
657 static int
658 config_write_zebra (struct vty *vty)
659 {
660 if (! zclient->enable)
661 {
662 vty_out (vty, "no router zebra%s", VTY_NEWLINE);
663 return 1;
664 }
665 else if (! vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_RIP], VRF_DEFAULT))
666 {
667 vty_out (vty, "router zebra%s", VTY_NEWLINE);
668 vty_out (vty, " no redistribute rip%s", VTY_NEWLINE);
669 return 1;
670 }
671 return 0;
672 }
673
674 int
675 config_write_rip_redistribute (struct vty *vty, int config_mode)
676 {
677 int i;
678
679 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
680 if (i != zclient->redist_default &&
681 vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT))
682 {
683 if (config_mode)
684 {
685 if (rip->route_map[i].metric_config)
686 {
687 if (rip->route_map[i].name)
688 vty_out (vty, " redistribute %s metric %d route-map %s%s",
689 zebra_route_string(i), rip->route_map[i].metric,
690 rip->route_map[i].name,
691 VTY_NEWLINE);
692 else
693 vty_out (vty, " redistribute %s metric %d%s",
694 zebra_route_string(i), rip->route_map[i].metric,
695 VTY_NEWLINE);
696 }
697 else
698 {
699 if (rip->route_map[i].name)
700 vty_out (vty, " redistribute %s route-map %s%s",
701 zebra_route_string(i), rip->route_map[i].name,
702 VTY_NEWLINE);
703 else
704 vty_out (vty, " redistribute %s%s", zebra_route_string(i),
705 VTY_NEWLINE);
706 }
707 }
708 else
709 vty_out (vty, " %s", zebra_route_string(i));
710 }
711 return 0;
712 }
713
714 /* Zebra node structure. */
715 static struct cmd_node zebra_node =
716 {
717 ZEBRA_NODE,
718 "%s(config-router)# ",
719 };
720
721 static void
722 rip_zebra_connected (struct zclient *zclient)
723 {
724 zclient_send_reg_requests (zclient, VRF_DEFAULT);
725 }
726
727 void
728 rip_zclient_init (struct thread_master *master)
729 {
730 /* Set default value to the zebra client structure. */
731 zclient = zclient_new(master);
732 zclient_init (zclient, ZEBRA_ROUTE_RIP, 0);
733 zclient->zebra_connected = rip_zebra_connected;
734 zclient->interface_add = rip_interface_add;
735 zclient->interface_delete = rip_interface_delete;
736 zclient->interface_address_add = rip_interface_address_add;
737 zclient->interface_address_delete = rip_interface_address_delete;
738 zclient->interface_up = rip_interface_up;
739 zclient->interface_down = rip_interface_down;
740 zclient->redistribute_route_ipv4_add = rip_zebra_read_ipv4;
741 zclient->redistribute_route_ipv4_del = rip_zebra_read_ipv4;
742
743 /* Install zebra node. */
744 install_node (&zebra_node, config_write_zebra);
745
746 /* Install command elements to zebra node. */
747 install_element (CONFIG_NODE, &router_zebra_cmd);
748 install_element (CONFIG_NODE, &no_router_zebra_cmd);
749 install_default (ZEBRA_NODE);
750 install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd);
751 install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd);
752
753 /* Install command elements to rip node. */
754 install_element (RIP_NODE, &rip_redistribute_type_cmd);
755 install_element (RIP_NODE, &rip_redistribute_type_routemap_cmd);
756 install_element (RIP_NODE, &rip_redistribute_type_metric_cmd);
757 install_element (RIP_NODE, &rip_redistribute_type_metric_routemap_cmd);
758 install_element (RIP_NODE, &no_rip_redistribute_type_cmd);
759 install_element (RIP_NODE, &no_rip_redistribute_type_routemap_cmd);
760 install_element (RIP_NODE, &no_rip_redistribute_type_metric_cmd);
761 install_element (RIP_NODE, &no_rip_redistribute_type_metric_routemap_cmd);
762 install_element (RIP_NODE, &rip_default_information_originate_cmd);
763 install_element (RIP_NODE, &no_rip_default_information_originate_cmd);
764 }