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