jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_zebra.c |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 24 | |
| 25 | #include "thread.h" |
| 26 | #include "command.h" |
| 27 | #include "memory.h" |
| 28 | #include "log.h" |
| 29 | #include "if.h" |
| 30 | #include "network.h" |
| 31 | #include "prefix.h" |
| 32 | #include "zclient.h" |
| 33 | #include "stream.h" |
| 34 | #include "linklist.h" |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 35 | #include "vrf.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 36 | |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 37 | #include "isisd/dict.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 38 | #include "isisd/isis_constants.h" |
| 39 | #include "isisd/isis_common.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 40 | #include "isisd/isis_flags.h" |
| 41 | #include "isisd/isis_misc.h" |
| 42 | #include "isisd/isis_circuit.h" |
| 43 | #include "isisd/isis_tlv.h" |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 44 | #include "isisd/isisd.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 45 | #include "isisd/isis_circuit.h" |
| 46 | #include "isisd/isis_csm.h" |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 47 | #include "isisd/isis_lsp.h" |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 48 | #include "isisd/isis_route.h" |
| 49 | #include "isisd/isis_zebra.h" |
| 50 | |
| 51 | struct zclient *zclient = NULL; |
| 52 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 53 | /* Router-id update message from zebra. */ |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 54 | static int |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 55 | isis_router_id_update_zebra (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 56 | zebra_size_t length, vrf_id_t vrf_id) |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 57 | { |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 58 | struct isis_area *area; |
| 59 | struct listnode *node; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 60 | struct prefix router_id; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 61 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 62 | zebra_router_id_update_read (zclient->ibuf, &router_id); |
| 63 | if (isis->router_id == router_id.u.prefix4.s_addr) |
| 64 | return 0; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 65 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 66 | isis->router_id = router_id.u.prefix4.s_addr; |
| 67 | for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area)) |
| 68 | if (listcount (area->area_addrs) > 0) |
| 69 | lsp_regenerate_schedule (area, area->is_type, 0); |
| 70 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 71 | return 0; |
| 72 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 73 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 74 | static int |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 75 | isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length, |
| 76 | vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 77 | { |
| 78 | struct interface *ifp; |
| 79 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 80 | ifp = zebra_interface_add_read (zclient->ibuf, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 81 | |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 82 | if (isis->debugs & DEBUG_ZEBRA) |
| 83 | zlog_debug ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d", |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 84 | ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 85 | |
hasso | b30c5e6 | 2004-12-29 20:06:41 +0000 | [diff] [blame] | 86 | if (if_is_operative (ifp)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 87 | isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 88 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 92 | static int |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 93 | isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length, |
| 94 | vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 95 | { |
| 96 | struct interface *ifp; |
| 97 | struct stream *s; |
| 98 | |
| 99 | s = zclient->ibuf; |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 100 | ifp = zebra_interface_state_read (s, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 101 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 102 | if (!ifp) |
| 103 | return 0; |
| 104 | |
hasso | b30c5e6 | 2004-12-29 20:06:41 +0000 | [diff] [blame] | 105 | if (if_is_operative (ifp)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 106 | zlog_warn ("Zebra: got delete of %s, but interface is still up", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 107 | ifp->name); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 108 | |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 109 | if (isis->debugs & DEBUG_ZEBRA) |
| 110 | zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d", |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 111 | ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 112 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 113 | isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 114 | |
| 115 | /* Cannot call if_delete because we should retain the pseudo interface |
| 116 | in case there is configuration info attached to it. */ |
| 117 | if_delete_retain(ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 118 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 119 | ifp->ifindex = IFINDEX_INTERNAL; |
| 120 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 121 | return 0; |
| 122 | } |
| 123 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 124 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 125 | isis_zebra_if_state_up (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 126 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 127 | { |
| 128 | struct interface *ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 129 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 130 | ifp = zebra_interface_state_read (zclient->ibuf, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 131 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 132 | if (ifp == NULL) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 133 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 134 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 135 | isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 136 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 137 | return 0; |
| 138 | } |
| 139 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 140 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 141 | isis_zebra_if_state_down (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 142 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 143 | { |
| 144 | struct interface *ifp; |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 145 | struct isis_circuit *circuit; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 146 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 147 | ifp = zebra_interface_state_read (zclient->ibuf, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 148 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 149 | if (ifp == NULL) |
| 150 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 151 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 152 | circuit = isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), |
| 153 | ifp); |
| 154 | if (circuit) |
| 155 | SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 156 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 157 | return 0; |
| 158 | } |
| 159 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 160 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 161 | isis_zebra_if_address_add (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 162 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 163 | { |
| 164 | struct connected *c; |
| 165 | struct prefix *p; |
hasso | f7c43dc | 2004-09-26 16:24:14 +0000 | [diff] [blame] | 166 | char buf[BUFSIZ]; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 167 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 168 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 169 | zclient->ibuf, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 170 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 171 | if (c == NULL) |
| 172 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 173 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 174 | p = c->address; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 175 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 176 | prefix2str (p, buf, BUFSIZ); |
| 177 | #ifdef EXTREME_DEBUG |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 178 | if (p->family == AF_INET) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 179 | zlog_debug ("connected IP address %s", buf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 180 | #ifdef HAVE_IPV6 |
| 181 | if (p->family == AF_INET6) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 182 | zlog_debug ("connected IPv6 address %s", buf); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 183 | #endif /* HAVE_IPV6 */ |
| 184 | #endif /* EXTREME_DEBUG */ |
hasso | b30c5e6 | 2004-12-29 20:06:41 +0000 | [diff] [blame] | 185 | if (if_is_operative (c->ifp)) |
| 186 | isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 191 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 192 | isis_zebra_if_address_del (int command, struct zclient *client, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 193 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 194 | { |
| 195 | struct connected *c; |
| 196 | struct interface *ifp; |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 197 | #ifdef EXTREME_DEBUG |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 198 | struct prefix *p; |
| 199 | u_char buf[BUFSIZ]; |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 200 | #endif /* EXTREME_DEBUG */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 201 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 202 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 203 | zclient->ibuf, vrf_id); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 204 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 205 | if (c == NULL) |
| 206 | return 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 207 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 208 | ifp = c->ifp; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 209 | |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 210 | #ifdef EXTREME_DEBUG |
| 211 | p = c->address; |
| 212 | prefix2str (p, buf, BUFSIZ); |
| 213 | |
| 214 | if (p->family == AF_INET) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 215 | zlog_debug ("disconnected IP address %s", buf); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 216 | #ifdef HAVE_IPV6 |
| 217 | if (p->family == AF_INET6) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 218 | zlog_debug ("disconnected IPv6 address %s", buf); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 219 | #endif /* HAVE_IPV6 */ |
| 220 | #endif /* EXTREME_DEBUG */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 221 | |
hasso | b30c5e6 | 2004-12-29 20:06:41 +0000 | [diff] [blame] | 222 | if (if_is_operative (ifp)) |
| 223 | isis_circuit_del_addr (circuit_scan_by_ifp (ifp), c); |
hasso | f891f44 | 2004-09-14 13:54:30 +0000 | [diff] [blame] | 224 | connected_free (c); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 225 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 226 | return 0; |
| 227 | } |
| 228 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 229 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 230 | isis_zebra_route_add_ipv4 (struct prefix *prefix, |
| 231 | struct isis_route_info *route_info) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 232 | { |
| 233 | u_char message, flags; |
| 234 | int psize; |
| 235 | struct stream *stream; |
| 236 | struct isis_nexthop *nexthop; |
| 237 | struct listnode *node; |
| 238 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 239 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 240 | return; |
| 241 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 242 | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_ISIS], VRF_DEFAULT)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 243 | { |
| 244 | message = 0; |
| 245 | flags = 0; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 246 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 247 | SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP); |
| 248 | SET_FLAG (message, ZAPI_MESSAGE_METRIC); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 249 | #if 0 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 250 | SET_FLAG (message, ZAPI_MESSAGE_DISTANCE); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 251 | #endif |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 252 | |
| 253 | stream = zclient->obuf; |
| 254 | stream_reset (stream); |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 255 | zclient_create_header (stream, ZEBRA_IPV4_ROUTE_ADD, VRF_DEFAULT); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 256 | /* type */ |
| 257 | stream_putc (stream, ZEBRA_ROUTE_ISIS); |
| 258 | /* flags */ |
| 259 | stream_putc (stream, flags); |
| 260 | /* message */ |
| 261 | stream_putc (stream, message); |
Avneesh Sachdev | aa3b264 | 2012-04-11 23:56:03 -0700 | [diff] [blame] | 262 | /* SAFI */ |
| 263 | stream_putw (stream, SAFI_UNICAST); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 264 | /* prefix information */ |
| 265 | psize = PSIZE (prefix->prefixlen); |
| 266 | stream_putc (stream, prefix->prefixlen); |
| 267 | stream_write (stream, (u_char *) & prefix->u.prefix4, psize); |
| 268 | |
| 269 | stream_putc (stream, listcount (route_info->nexthops)); |
| 270 | |
| 271 | /* Nexthop, ifindex, distance and metric information */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 272 | for (ALL_LIST_ELEMENTS_RO (route_info->nexthops, node, nexthop)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 273 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 274 | /* FIXME: can it be ? */ |
| 275 | if (nexthop->ip.s_addr != INADDR_ANY) |
| 276 | { |
| 277 | stream_putc (stream, ZEBRA_NEXTHOP_IPV4); |
| 278 | stream_put_in_addr (stream, &nexthop->ip); |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX); |
| 283 | stream_putl (stream, nexthop->ifindex); |
| 284 | } |
| 285 | } |
| 286 | #if 0 |
| 287 | if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) |
| 288 | stream_putc (stream, route_info->depth); |
| 289 | #endif |
| 290 | if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) |
| 291 | stream_putl (stream, route_info->cost); |
| 292 | |
| 293 | stream_putw_at (stream, 0, stream_get_endp (stream)); |
ajs | 634f9ea | 2005-04-11 15:51:40 +0000 | [diff] [blame] | 294 | zclient_send_message(zclient); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 295 | SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
| 296 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 297 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 298 | } |
| 299 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 300 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 301 | isis_zebra_route_del_ipv4 (struct prefix *prefix, |
| 302 | struct isis_route_info *route_info) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 303 | { |
| 304 | struct zapi_ipv4 api; |
| 305 | struct prefix_ipv4 prefix4; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 306 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 307 | if (vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_ISIS], VRF_DEFAULT)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 308 | { |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 309 | api.vrf_id = VRF_DEFAULT; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 310 | api.type = ZEBRA_ROUTE_ISIS; |
| 311 | api.flags = 0; |
| 312 | api.message = 0; |
Avneesh Sachdev | aa3b264 | 2012-04-11 23:56:03 -0700 | [diff] [blame] | 313 | api.safi = SAFI_UNICAST; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 314 | prefix4.family = AF_INET; |
| 315 | prefix4.prefixlen = prefix->prefixlen; |
| 316 | prefix4.prefix = prefix->u.prefix4; |
| 317 | zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api); |
| 318 | } |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 319 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 320 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 321 | return; |
| 322 | } |
| 323 | |
| 324 | #ifdef HAVE_IPV6 |
David Lamparter | f50ee93 | 2015-03-04 07:13:38 +0100 | [diff] [blame] | 325 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 326 | isis_zebra_route_add_ipv6 (struct prefix *prefix, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 327 | struct isis_route_info *route_info) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 328 | { |
| 329 | struct zapi_ipv6 api; |
| 330 | struct in6_addr **nexthop_list; |
| 331 | unsigned int *ifindex_list; |
| 332 | struct isis_nexthop6 *nexthop6; |
| 333 | int i, size; |
| 334 | struct listnode *node; |
| 335 | struct prefix_ipv6 prefix6; |
| 336 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 337 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 338 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 339 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 340 | api.vrf_id = VRF_DEFAULT; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 341 | api.type = ZEBRA_ROUTE_ISIS; |
| 342 | api.flags = 0; |
| 343 | api.message = 0; |
Avneesh Sachdev | aa3b264 | 2012-04-11 23:56:03 -0700 | [diff] [blame] | 344 | api.safi = SAFI_UNICAST; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 345 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 346 | SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); |
| 347 | SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); |
| 348 | api.metric = route_info->cost; |
| 349 | #if 0 |
| 350 | SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE); |
| 351 | api.distance = route_info->depth; |
| 352 | #endif |
| 353 | api.nexthop_num = listcount (route_info->nexthops6); |
| 354 | api.ifindex_num = listcount (route_info->nexthops6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 355 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 356 | /* allocate memory for nexthop_list */ |
| 357 | size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6); |
| 358 | nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 359 | if (!nexthop_list) |
| 360 | { |
| 361 | zlog_err ("isis_zebra_add_route_ipv6: out of memory!"); |
| 362 | return; |
| 363 | } |
| 364 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 365 | /* allocate memory for ifindex_list */ |
| 366 | size = sizeof (unsigned int) * listcount (route_info->nexthops6); |
| 367 | ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 368 | if (!ifindex_list) |
| 369 | { |
| 370 | zlog_err ("isis_zebra_add_route_ipv6: out of memory!"); |
| 371 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 372 | return; |
| 373 | } |
| 374 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 375 | /* for each nexthop */ |
| 376 | i = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 377 | for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 378 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 379 | if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) && |
| 380 | !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) |
| 381 | { |
| 382 | api.nexthop_num--; |
| 383 | api.ifindex_num--; |
| 384 | continue; |
| 385 | } |
| 386 | |
| 387 | nexthop_list[i] = &nexthop6->ip6; |
| 388 | ifindex_list[i] = nexthop6->ifindex; |
| 389 | i++; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 390 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 391 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 392 | api.nexthop = nexthop_list; |
| 393 | api.ifindex = ifindex_list; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 394 | |
| 395 | if (api.nexthop_num && api.ifindex_num) |
| 396 | { |
| 397 | prefix6.family = AF_INET6; |
| 398 | prefix6.prefixlen = prefix->prefixlen; |
| 399 | memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr)); |
| 400 | zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, &api); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 401 | SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
| 402 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 403 | } |
| 404 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 405 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 406 | XFREE (MTYPE_ISIS_TMP, ifindex_list); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 407 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 408 | return; |
| 409 | } |
| 410 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 411 | static void |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 412 | isis_zebra_route_del_ipv6 (struct prefix *prefix, |
| 413 | struct isis_route_info *route_info) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 414 | { |
| 415 | struct zapi_ipv6 api; |
| 416 | struct in6_addr **nexthop_list; |
| 417 | unsigned int *ifindex_list; |
| 418 | struct isis_nexthop6 *nexthop6; |
| 419 | int i, size; |
| 420 | struct listnode *node; |
| 421 | struct prefix_ipv6 prefix6; |
| 422 | |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 423 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 424 | return; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 425 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 426 | api.vrf_id = VRF_DEFAULT; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 427 | api.type = ZEBRA_ROUTE_ISIS; |
| 428 | api.flags = 0; |
| 429 | api.message = 0; |
Avneesh Sachdev | aa3b264 | 2012-04-11 23:56:03 -0700 | [diff] [blame] | 430 | api.safi = SAFI_UNICAST; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 431 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 432 | SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); |
| 433 | api.nexthop_num = listcount (route_info->nexthops6); |
| 434 | api.ifindex_num = listcount (route_info->nexthops6); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 435 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 436 | /* allocate memory for nexthop_list */ |
| 437 | size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6); |
| 438 | nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 439 | if (!nexthop_list) |
| 440 | { |
| 441 | zlog_err ("isis_zebra_route_del_ipv6: out of memory!"); |
| 442 | return; |
| 443 | } |
| 444 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 445 | /* allocate memory for ifindex_list */ |
| 446 | size = sizeof (unsigned int) * listcount (route_info->nexthops6); |
| 447 | ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 448 | if (!ifindex_list) |
| 449 | { |
| 450 | zlog_err ("isis_zebra_route_del_ipv6: out of memory!"); |
| 451 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 452 | return; |
| 453 | } |
| 454 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 455 | /* for each nexthop */ |
| 456 | i = 0; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 457 | for (ALL_LIST_ELEMENTS_RO (route_info->nexthops6, node, nexthop6)) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 458 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 459 | if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) && |
| 460 | !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) |
| 461 | { |
| 462 | api.nexthop_num--; |
| 463 | api.ifindex_num--; |
| 464 | continue; |
| 465 | } |
| 466 | |
| 467 | nexthop_list[i] = &nexthop6->ip6; |
| 468 | ifindex_list[i] = nexthop6->ifindex; |
| 469 | i++; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 470 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 471 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 472 | api.nexthop = nexthop_list; |
| 473 | api.ifindex = ifindex_list; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 474 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 475 | if (api.nexthop_num && api.ifindex_num) |
| 476 | { |
| 477 | prefix6.family = AF_INET6; |
| 478 | prefix6.prefixlen = prefix->prefixlen; |
| 479 | memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr)); |
| 480 | zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, &api); |
Josh Bailey | 3f045a0 | 2012-03-24 08:35:20 -0700 | [diff] [blame] | 481 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 485 | XFREE (MTYPE_ISIS_TMP, ifindex_list); |
| 486 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 487 | |
| 488 | #endif /* HAVE_IPV6 */ |
| 489 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 490 | void |
| 491 | isis_zebra_route_update (struct prefix *prefix, |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 492 | struct isis_route_info *route_info) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 493 | { |
| 494 | if (zclient->sock < 0) |
| 495 | return; |
| 496 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 497 | if (!vrf_bitmap_check (zclient->redist[ZEBRA_ROUTE_ISIS], VRF_DEFAULT)) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 498 | return; |
| 499 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 500 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) |
| 501 | { |
| 502 | if (prefix->family == AF_INET) |
| 503 | isis_zebra_route_add_ipv4 (prefix, route_info); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 504 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 505 | else if (prefix->family == AF_INET6) |
| 506 | isis_zebra_route_add_ipv6 (prefix, route_info); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 507 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 508 | } |
| 509 | else |
| 510 | { |
| 511 | if (prefix->family == AF_INET) |
| 512 | isis_zebra_route_del_ipv4 (prefix, route_info); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 513 | #ifdef HAVE_IPV6 |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 514 | else if (prefix->family == AF_INET6) |
| 515 | isis_zebra_route_del_ipv6 (prefix, route_info); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 516 | #endif /* HAVE_IPV6 */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 517 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 518 | return; |
| 519 | } |
| 520 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 521 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 522 | isis_zebra_read_ipv4 (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 523 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 524 | { |
| 525 | struct stream *stream; |
| 526 | struct zapi_ipv4 api; |
| 527 | struct prefix_ipv4 p; |
David Lamparter | f50ee93 | 2015-03-04 07:13:38 +0100 | [diff] [blame] | 528 | unsigned long ifindex __attribute__ ((unused)); |
| 529 | struct in_addr nexthop __attribute__ ((unused)); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 530 | |
| 531 | stream = zclient->ibuf; |
| 532 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 533 | ifindex = 0; |
| 534 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 535 | api.type = stream_getc (stream); |
| 536 | api.flags = stream_getc (stream); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 537 | api.message = stream_getc (stream); |
| 538 | |
| 539 | p.family = AF_INET; |
| 540 | p.prefixlen = stream_getc (stream); |
| 541 | stream_get (&p.prefix, stream, PSIZE (p.prefixlen)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 542 | |
| 543 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) |
| 544 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 545 | api.nexthop_num = stream_getc (stream); |
| 546 | nexthop.s_addr = stream_get_ipv4 (stream); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 547 | } |
| 548 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) |
| 549 | { |
| 550 | api.ifindex_num = stream_getc (stream); |
| 551 | ifindex = stream_getl (stream); |
| 552 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 553 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) |
| 554 | api.distance = stream_getc (stream); |
| 555 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) |
| 556 | api.metric = stream_getl (stream); |
| 557 | else |
| 558 | api.metric = 0; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 559 | |
| 560 | if (command == ZEBRA_IPV4_ROUTE_ADD) |
| 561 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 562 | if (isis->debugs & DEBUG_ZEBRA) |
| 563 | zlog_debug ("IPv4 Route add from Z"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 564 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 565 | |
| 566 | return 0; |
| 567 | } |
| 568 | |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 569 | #ifdef HAVE_IPV6 |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 570 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 571 | isis_zebra_read_ipv6 (int command, struct zclient *zclient, |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 572 | zebra_size_t length, vrf_id_t vrf_id) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 573 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 574 | return 0; |
| 575 | } |
Paul Jakma | 41b36e9 | 2006-12-08 01:09:50 +0000 | [diff] [blame] | 576 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 577 | |
| 578 | #define ISIS_TYPE_IS_REDISTRIBUTED(T) \ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 579 | T == ZEBRA_ROUTE_MAX ? \ |
| 580 | vrf_bitmap_check (zclient->default_information, VRF_DEFAULT) : \ |
| 581 | vrf_bitmap_check (zclient->redist[type], VRF_DEFAULT) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 582 | |
| 583 | int |
| 584 | isis_distribute_list_update (int routetype) |
| 585 | { |
| 586 | return 0; |
| 587 | } |
| 588 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 589 | #if 0 /* Not yet. */ |
| 590 | static int |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 591 | isis_redistribute_default_set (int routetype, int metric_type, |
| 592 | int metric_value) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 593 | { |
| 594 | return 0; |
| 595 | } |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 596 | #endif /* 0 */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 597 | |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 598 | static void |
| 599 | isis_zebra_connected (struct zclient *zclient) |
| 600 | { |
| 601 | zclient_send_requests (zclient, VRF_DEFAULT); |
| 602 | } |
| 603 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 604 | void |
| 605 | isis_zebra_init () |
| 606 | { |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 607 | zclient = zclient_new (); |
| 608 | zclient_init (zclient, ZEBRA_ROUTE_ISIS); |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 609 | zclient->zebra_connected = isis_zebra_connected; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 610 | zclient->router_id_update = isis_router_id_update_zebra; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 611 | zclient->interface_add = isis_zebra_if_add; |
| 612 | zclient->interface_delete = isis_zebra_if_del; |
| 613 | zclient->interface_up = isis_zebra_if_state_up; |
| 614 | zclient->interface_down = isis_zebra_if_state_down; |
| 615 | zclient->interface_address_add = isis_zebra_if_address_add; |
| 616 | zclient->interface_address_delete = isis_zebra_if_address_del; |
| 617 | zclient->ipv4_route_add = isis_zebra_read_ipv4; |
| 618 | zclient->ipv4_route_delete = isis_zebra_read_ipv4; |
| 619 | #ifdef HAVE_IPV6 |
| 620 | zclient->ipv6_route_add = isis_zebra_read_ipv6; |
| 621 | zclient->ipv6_route_delete = isis_zebra_read_ipv6; |
| 622 | #endif /* HAVE_IPV6 */ |
| 623 | |
| 624 | return; |
| 625 | } |