]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripngd/ripng_zebra.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ripngd / ripng_zebra.c
index fa61d69caae5863a16c63961928982dfdc843cc2..b126a15b5bf177abfc3181c743237d09bf758b87 100644 (file)
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * RIPngd and zebra interface.
  * Copyright (C) 1998, 1999 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -46,12 +31,13 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
        struct listnode *listnode = NULL;
        struct ripng_info *rinfo = NULL;
        int count = 0;
+       const struct prefix *p = agg_node_get_prefix(rp);
 
        memset(&api, 0, sizeof(api));
        api.vrf_id = ripng->vrf->vrf_id;
        api.type = ZEBRA_ROUTE_RIPNG;
        api.safi = SAFI_UNICAST;
-       api.prefix = rp->p;
+       api.prefix = *p;
 
        SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
        for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
@@ -85,18 +71,17 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
 
        if (IS_RIPNG_DEBUG_ZEBRA) {
                if (ripng->ecmp)
-                       zlog_debug("%s: %s/%d nexthops %d",
+                       zlog_debug("%s: %pRN nexthops %d",
                                   (cmd == ZEBRA_ROUTE_ADD)
                                           ? "Install into zebra"
                                           : "Delete from zebra",
-                                  inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen,
-                                  count);
+                                  rp, count);
                else
-                       zlog_debug(
-                               "%s: %s/%d",
-                               (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra"
-                                                        : "Delete from zebra",
-                               inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen);
+                       zlog_debug("%s: %pRN",
+                                  (cmd == ZEBRA_ROUTE_ADD)
+                                          ? "Install into zebra"
+                                          : "Delete from zebra",
+                                  rp);
        }
 }
 
@@ -152,8 +137,8 @@ static int ripng_zebra_read_route(ZAPI_CALLBACK_ARGS)
 
 void ripng_redistribute_conf_update(struct ripng *ripng, int type)
 {
-       zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0,
-                            ripng->vrf->vrf_id);
+       zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6,
+                               type, 0, ripng->vrf->vrf_id);
 }
 
 void ripng_redistribute_conf_delete(struct ripng *ripng, int type)
@@ -234,19 +219,23 @@ static void ripng_zebra_connected(struct zclient *zclient)
        zclient_send_reg_requests(zclient, VRF_DEFAULT);
 }
 
+static zclient_handler *const ripng_handlers[] = {
+       [ZEBRA_INTERFACE_ADDRESS_ADD] = ripng_interface_address_add,
+       [ZEBRA_INTERFACE_ADDRESS_DELETE] = ripng_interface_address_delete,
+       [ZEBRA_INTERFACE_VRF_UPDATE] = ripng_interface_vrf_update,
+       [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = ripng_zebra_read_route,
+       [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ripng_zebra_read_route,
+};
+
 /* Initialize zebra structure and it's commands. */
 void zebra_init(struct thread_master *master)
 {
        /* Allocate zebra structure. */
-       zclient = zclient_new(master, &zclient_options_default);
+       zclient = zclient_new(master, &zclient_options_default, ripng_handlers,
+                             array_size(ripng_handlers));
        zclient_init(zclient, ZEBRA_ROUTE_RIPNG, 0, &ripngd_privs);
 
        zclient->zebra_connected = ripng_zebra_connected;
-       zclient->interface_address_add = ripng_interface_address_add;
-       zclient->interface_address_delete = ripng_interface_address_delete;
-       zclient->interface_vrf_update = ripng_interface_vrf_update;
-       zclient->redistribute_route_add = ripng_zebra_read_route;
-       zclient->redistribute_route_del = ripng_zebra_read_route;
 }
 
 void ripng_zebra_stop(void)