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> |
| 24 | #include <net/ethernet.h> |
| 25 | |
| 26 | #include "thread.h" |
| 27 | #include "command.h" |
| 28 | #include "memory.h" |
| 29 | #include "log.h" |
| 30 | #include "if.h" |
| 31 | #include "network.h" |
| 32 | #include "prefix.h" |
| 33 | #include "zclient.h" |
| 34 | #include "stream.h" |
| 35 | #include "linklist.h" |
| 36 | |
| 37 | #include "isisd/isis_constants.h" |
| 38 | #include "isisd/isis_common.h" |
| 39 | #include "isisd/isis_circuit.h" |
| 40 | #include "isisd/isis_csm.h" |
| 41 | #include "isisd/isis_route.h" |
| 42 | #include "isisd/isis_zebra.h" |
| 43 | |
| 44 | struct zclient *zclient = NULL; |
| 45 | |
| 46 | extern struct thread_master *master; |
| 47 | |
| 48 | int |
| 49 | isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length) |
| 50 | { |
| 51 | struct interface *ifp; |
| 52 | |
| 53 | ifp = zebra_interface_add_read (zclient->ibuf); |
| 54 | |
| 55 | |
| 56 | zlog_info ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d", |
| 57 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 58 | |
| 59 | if (if_is_up (ifp)) |
| 60 | isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | int |
| 66 | isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length) |
| 67 | { |
| 68 | struct interface *ifp; |
| 69 | struct stream *s; |
| 70 | |
| 71 | s = zclient->ibuf; |
| 72 | ifp = zebra_interface_state_read (s); |
| 73 | |
| 74 | if (!ifp) |
| 75 | return 0; |
| 76 | |
| 77 | if (if_is_up (ifp)) |
| 78 | zlog_warn ("Zebra: got delete of %s, but interface is still up", |
| 79 | ifp->name); |
| 80 | |
| 81 | zlog_info ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d", |
| 82 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 83 | |
| 84 | if_delete (ifp); |
| 85 | |
| 86 | isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | struct interface * |
| 92 | zebra_interface_if_lookup (struct stream *s) |
| 93 | { |
| 94 | struct interface *ifp; |
| 95 | u_char ifname_tmp[INTERFACE_NAMSIZ]; |
| 96 | |
| 97 | /* Read interface name. */ |
| 98 | stream_get (ifname_tmp, s, INTERFACE_NAMSIZ); |
| 99 | |
| 100 | /* Lookup this by interface index. */ |
| 101 | ifp = if_lookup_by_name (ifname_tmp); |
| 102 | |
| 103 | /* If such interface does not exist, indicate an error */ |
| 104 | if (!ifp) |
| 105 | return NULL; |
| 106 | |
| 107 | return ifp; |
| 108 | } |
| 109 | |
| 110 | void |
| 111 | zebra_interface_if_set_value (struct stream *s, struct interface *ifp) |
| 112 | { |
| 113 | /* Read interface's index. */ |
| 114 | ifp->ifindex = stream_getl (s); |
| 115 | |
| 116 | /* Read interface's value. */ |
| 117 | ifp->flags = stream_getl (s); |
| 118 | ifp->metric = stream_getl (s); |
| 119 | ifp->mtu = stream_getl (s); |
| 120 | ifp->bandwidth = stream_getl (s); |
| 121 | } |
| 122 | |
| 123 | int |
| 124 | isis_zebra_if_state_up (int command, struct zclient *zclient, |
| 125 | zebra_size_t length) |
| 126 | { |
| 127 | struct interface *ifp; |
| 128 | |
| 129 | ifp = zebra_interface_if_lookup (zclient->ibuf); |
| 130 | |
| 131 | if (!ifp) |
| 132 | return 0; |
| 133 | |
| 134 | if (if_is_up (ifp)) { |
| 135 | zebra_interface_if_set_value (zclient->ibuf, ifp); |
| 136 | isis_circuit_update_params (circuit_scan_by_ifp (ifp), ifp); |
| 137 | return 0; |
| 138 | } |
| 139 | |
| 140 | zebra_interface_if_set_value (zclient->ibuf, ifp); |
| 141 | isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | |
| 147 | int |
| 148 | isis_zebra_if_state_down (int command, struct zclient *zclient, |
| 149 | zebra_size_t length) |
| 150 | { |
| 151 | struct interface *ifp; |
| 152 | |
| 153 | ifp = zebra_interface_if_lookup (zclient->ibuf); |
| 154 | |
| 155 | if (ifp == NULL) |
| 156 | return 0; |
| 157 | |
| 158 | if (if_is_up (ifp)) { |
| 159 | zebra_interface_if_set_value (zclient->ibuf, ifp); |
| 160 | isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp); |
| 161 | } |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | int |
| 167 | isis_zebra_if_address_add (int command, struct zclient *zclient, |
| 168 | zebra_size_t length) |
| 169 | { |
| 170 | struct connected *c; |
| 171 | struct prefix *p; |
| 172 | u_char buf[BUFSIZ]; |
| 173 | |
| 174 | c = zebra_interface_address_add_read (zclient->ibuf); |
| 175 | |
| 176 | if (c == NULL) |
| 177 | return 0; |
| 178 | |
| 179 | p = c->address; |
| 180 | |
| 181 | prefix2str (p, buf, BUFSIZ); |
| 182 | #ifdef EXTREME_DEBUG |
| 183 | if (p->family == AF_INET) |
| 184 | zlog_info ("connected IP address %s", buf); |
| 185 | #ifdef HAVE_IPV6 |
| 186 | if (p->family == AF_INET6) |
| 187 | zlog_info ("connected IPv6 address %s", buf); |
| 188 | #endif /* HAVE_IPV6 */ |
| 189 | #endif /* EXTREME_DEBUG */ |
| 190 | isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | int |
| 196 | isis_zebra_if_address_del (int command, struct zclient *client, |
| 197 | zebra_size_t length) |
| 198 | { |
| 199 | struct connected *c; |
| 200 | struct interface *ifp; |
| 201 | |
| 202 | c = zebra_interface_address_delete_read (zclient->ibuf); |
| 203 | |
| 204 | if (c == NULL) |
| 205 | return 0; |
| 206 | |
| 207 | ifp = c->ifp; |
| 208 | |
| 209 | connected_free (c); |
| 210 | |
| 211 | isis_circuit_del_addr (circuit_scan_by_ifp (ifp), c); |
| 212 | |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | void |
| 217 | isis_zebra_route_add_ipv4 (struct prefix *prefix, |
| 218 | struct isis_route_info *route_info) |
| 219 | { |
| 220 | u_char message, flags; |
| 221 | int psize; |
| 222 | struct stream *stream; |
| 223 | struct isis_nexthop *nexthop; |
| 224 | struct listnode *node; |
| 225 | |
| 226 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC)) |
| 227 | return; |
| 228 | |
| 229 | if (zclient->redist[ZEBRA_ROUTE_ISIS]) { |
| 230 | message = 0; |
| 231 | flags = 0; |
| 232 | |
| 233 | SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP); |
| 234 | SET_FLAG (message, ZAPI_MESSAGE_METRIC); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 235 | #if 0 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 236 | SET_FLAG (message, ZAPI_MESSAGE_DISTANCE); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 237 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 238 | |
| 239 | stream = zclient->obuf; |
| 240 | stream_reset (stream); |
| 241 | /* Length place holder. */ |
| 242 | stream_putw (stream, 0); |
| 243 | /* command */ |
| 244 | stream_putc (stream, ZEBRA_IPV4_ROUTE_ADD); |
| 245 | /* type */ |
| 246 | stream_putc (stream, ZEBRA_ROUTE_ISIS); |
| 247 | /* flags */ |
| 248 | stream_putc (stream, flags); |
| 249 | /* message */ |
| 250 | stream_putc (stream, message); |
| 251 | /* prefix information */ |
| 252 | psize = PSIZE (prefix->prefixlen); |
| 253 | stream_putc (stream, prefix->prefixlen); |
| 254 | stream_write (stream, (u_char *)&prefix->u.prefix4, psize); |
| 255 | |
| 256 | stream_putc (stream, listcount (route_info->nexthops)); |
| 257 | |
| 258 | /* Nexthop, ifindex, distance and metric information */ |
| 259 | for (node = listhead (route_info->nexthops); node; nextnode (node)) { |
| 260 | nexthop = getdata (node); |
| 261 | /* FIXME: can it be ? */ |
| 262 | if (nexthop->ip.s_addr != INADDR_ANY) { |
| 263 | stream_putc (stream, ZEBRA_NEXTHOP_IPV4); |
| 264 | stream_put_in_addr (stream, &nexthop->ip); |
| 265 | } else { |
| 266 | stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX); |
| 267 | stream_putl (stream, nexthop->ifindex); |
| 268 | } |
| 269 | } |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 270 | #if 0 |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 271 | if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) |
| 272 | stream_putc (stream, route_info->depth); |
hasso | 2097cd8 | 2003-12-23 11:51:08 +0000 | [diff] [blame] | 273 | #endif |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 274 | if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) |
| 275 | stream_putl (stream, route_info->cost); |
| 276 | |
| 277 | stream_putw_at (stream, 0, stream_get_endp (stream)); |
| 278 | writen (zclient->sock, stream->data, stream_get_endp (stream)); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | void |
| 283 | isis_zebra_route_del_ipv4 (struct prefix *prefix, |
| 284 | struct isis_route_info *route_info) |
| 285 | { |
| 286 | struct zapi_ipv4 api; |
| 287 | struct prefix_ipv4 prefix4; |
| 288 | |
| 289 | if (zclient->redist[ZEBRA_ROUTE_ISIS]) { |
| 290 | api.type = ZEBRA_ROUTE_ISIS; |
| 291 | api.flags = 0; |
| 292 | api.message = 0; |
| 293 | prefix4.family = AF_INET; |
| 294 | prefix4.prefixlen = prefix->prefixlen; |
| 295 | prefix4.prefix = prefix->u.prefix4; |
| 296 | zapi_ipv4_delete (zclient, &prefix4, &api); |
| 297 | } |
| 298 | |
| 299 | return; |
| 300 | } |
| 301 | |
| 302 | #ifdef HAVE_IPV6 |
| 303 | void |
| 304 | isis_zebra_route_add_ipv6 (struct prefix *prefix, |
| 305 | struct isis_route_info *route_info) |
| 306 | { |
| 307 | struct zapi_ipv6 api; |
| 308 | struct in6_addr **nexthop_list; |
| 309 | unsigned int *ifindex_list; |
| 310 | struct isis_nexthop6 *nexthop6; |
| 311 | int i, size; |
| 312 | struct listnode *node; |
| 313 | struct prefix_ipv6 prefix6; |
| 314 | |
| 315 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC)) |
| 316 | return; |
| 317 | |
| 318 | api.type = ZEBRA_ROUTE_ISIS; |
| 319 | api.flags = 0; |
| 320 | api.message = 0; |
| 321 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 322 | SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); |
| 323 | SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); |
| 324 | api.metric = route_info->cost; |
| 325 | #if 0 |
| 326 | SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE); |
| 327 | api.distance = route_info->depth; |
| 328 | #endif |
| 329 | api.nexthop_num = listcount (route_info->nexthops6); |
| 330 | api.ifindex_num = listcount (route_info->nexthops6); |
| 331 | |
| 332 | /* allocate memory for nexthop_list */ |
| 333 | size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6); |
| 334 | nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size); |
| 335 | if (!nexthop_list) { |
| 336 | zlog_err ("isis_zebra_add_route_ipv6: out of memory!"); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | /* allocate memory for ifindex_list */ |
| 341 | size = sizeof (unsigned int) * listcount (route_info->nexthops6); |
| 342 | ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size); |
| 343 | if (!ifindex_list) { |
| 344 | zlog_err ("isis_zebra_add_route_ipv6: out of memory!"); |
| 345 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | /* for each nexthop */ |
| 350 | i = 0; |
| 351 | for (node = listhead (route_info->nexthops6); node; nextnode (node)) { |
| 352 | nexthop6 = getdata (node); |
| 353 | |
| 354 | if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) && |
| 355 | !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) { |
| 356 | api.nexthop_num--; |
| 357 | api.ifindex_num--; |
| 358 | continue; |
| 359 | } |
| 360 | |
| 361 | nexthop_list[i] = &nexthop6->ip6; |
| 362 | ifindex_list[i] = nexthop6->ifindex; |
| 363 | i++; |
| 364 | } |
| 365 | |
| 366 | api.nexthop = nexthop_list; |
| 367 | api.ifindex = ifindex_list; |
| 368 | |
| 369 | if (api.nexthop_num && api.ifindex_num) { |
| 370 | prefix6.family = AF_INET6; |
| 371 | prefix6.prefixlen = prefix->prefixlen; |
| 372 | memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr)); |
| 373 | zapi_ipv6_add (zclient, &prefix6, &api); |
| 374 | SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC); |
| 375 | } |
| 376 | |
| 377 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 378 | XFREE (MTYPE_ISIS_TMP, ifindex_list); |
| 379 | |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | void |
| 384 | isis_zebra_route_del_ipv6 (struct prefix *prefix, |
| 385 | struct isis_route_info *route_info) |
| 386 | { |
| 387 | struct zapi_ipv6 api; |
| 388 | struct in6_addr **nexthop_list; |
| 389 | unsigned int *ifindex_list; |
| 390 | struct isis_nexthop6 *nexthop6; |
| 391 | int i, size; |
| 392 | struct listnode *node; |
| 393 | struct prefix_ipv6 prefix6; |
| 394 | |
| 395 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC)) |
| 396 | return; |
| 397 | |
| 398 | api.type = ZEBRA_ROUTE_ISIS; |
| 399 | api.flags = 0; |
| 400 | api.message = 0; |
| 401 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 402 | SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); |
| 403 | api.nexthop_num = listcount (route_info->nexthops6); |
| 404 | api.ifindex_num = listcount (route_info->nexthops6); |
| 405 | |
| 406 | /* allocate memory for nexthop_list */ |
| 407 | size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6); |
| 408 | nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size); |
| 409 | if (!nexthop_list) { |
| 410 | zlog_err ("isis_zebra_route_del_ipv6: out of memory!"); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | /* allocate memory for ifindex_list */ |
| 415 | size = sizeof (unsigned int) * listcount (route_info->nexthops6); |
| 416 | ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size); |
| 417 | if (!ifindex_list) { |
| 418 | zlog_err ("isis_zebra_route_del_ipv6: out of memory!"); |
| 419 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | /* for each nexthop */ |
| 424 | i = 0; |
| 425 | for (node = listhead (route_info->nexthops6); node; nextnode (node)) { |
| 426 | nexthop6 = getdata (node); |
| 427 | |
| 428 | if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) && |
| 429 | !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) { |
| 430 | api.nexthop_num--; |
| 431 | api.ifindex_num--; |
| 432 | continue; |
| 433 | } |
| 434 | |
| 435 | nexthop_list[i] = &nexthop6->ip6; |
| 436 | ifindex_list[i] = nexthop6->ifindex; |
| 437 | i++; |
| 438 | } |
| 439 | |
| 440 | api.nexthop = nexthop_list; |
| 441 | api.ifindex = ifindex_list; |
| 442 | |
| 443 | if (api.nexthop_num && api.ifindex_num) { |
| 444 | prefix6.family = AF_INET6; |
| 445 | prefix6.prefixlen = prefix->prefixlen; |
| 446 | memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr)); |
| 447 | zapi_ipv6_delete (zclient, &prefix6, &api); |
| 448 | UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC); |
| 449 | } |
| 450 | |
| 451 | XFREE (MTYPE_ISIS_TMP, nexthop_list); |
| 452 | XFREE (MTYPE_ISIS_TMP, ifindex_list); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | #endif /* HAVE_IPV6 */ |
| 457 | |
| 458 | |
| 459 | |
| 460 | void |
| 461 | isis_zebra_route_update (struct prefix *prefix, |
| 462 | struct isis_route_info *route_info) |
| 463 | { |
| 464 | if (zclient->sock < 0) |
| 465 | return; |
| 466 | |
| 467 | if (!zclient->redist[ZEBRA_ROUTE_ISIS]) |
| 468 | return; |
| 469 | |
| 470 | if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) { |
| 471 | if (prefix->family == AF_INET) |
| 472 | isis_zebra_route_add_ipv4 (prefix, route_info); |
| 473 | #ifdef HAVE_IPV6 |
| 474 | else if (prefix->family == AF_INET6) |
| 475 | isis_zebra_route_add_ipv6 (prefix, route_info); |
| 476 | #endif /* HAVE_IPV6 */ |
| 477 | } else { |
| 478 | if (prefix->family == AF_INET) |
| 479 | isis_zebra_route_del_ipv4 (prefix, route_info); |
| 480 | #ifdef HAVE_IPV6 |
| 481 | else if (prefix->family == AF_INET6) |
| 482 | isis_zebra_route_del_ipv6 (prefix, route_info); |
| 483 | #endif /* HAVE_IPV6 */ |
| 484 | } |
| 485 | return; |
| 486 | } |
| 487 | |
| 488 | |
| 489 | int |
| 490 | isis_zebra_read_ipv4 (int command, struct zclient *zclient, |
| 491 | zebra_size_t length) |
| 492 | { |
| 493 | struct stream *stream; |
| 494 | struct zapi_ipv4 api; |
| 495 | struct prefix_ipv4 p; |
| 496 | unsigned long ifindex; |
| 497 | struct in_addr nexthop; |
| 498 | |
| 499 | stream = zclient->ibuf; |
| 500 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 501 | ifindex = 0; |
| 502 | |
| 503 | api.type = stream_getc (stream); |
| 504 | api.flags = stream_getc (stream); |
| 505 | api.message = stream_getc (stream); |
| 506 | |
| 507 | p.family = AF_INET; |
| 508 | p.prefixlen = stream_getc (stream); |
| 509 | stream_get (&p.prefix, stream, PSIZE (p.prefixlen)); |
| 510 | |
| 511 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) { |
| 512 | api.nexthop_num = stream_getc (stream); |
| 513 | nexthop.s_addr = stream_get_ipv4 (stream); |
| 514 | } |
| 515 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) { |
| 516 | api.ifindex_num = stream_getc (stream); |
| 517 | ifindex = stream_getl (stream); |
| 518 | } |
| 519 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) |
| 520 | api.distance = stream_getc (stream); |
| 521 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) |
| 522 | api.metric = stream_getl (stream); |
| 523 | else |
| 524 | api.metric = 0; |
| 525 | |
| 526 | if (command == ZEBRA_IPV4_ROUTE_ADD) { |
| 527 | zlog_info ("IPv4 Route add from Z"); |
| 528 | } |
| 529 | |
| 530 | return 0; |
| 531 | } |
| 532 | |
| 533 | |
| 534 | int |
| 535 | isis_zebra_read_ipv6 (int command, struct zclient *zclient, |
| 536 | zebra_size_t length) |
| 537 | { |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | #define ISIS_TYPE_IS_REDISTRIBUTED(T) \ |
| 543 | T == ZEBRA_ROUTE_MAX ? zclient->default_information : zclient->redist[type] |
| 544 | |
| 545 | int |
| 546 | isis_distribute_list_update (int routetype) |
| 547 | { |
| 548 | return 0; |
| 549 | } |
| 550 | |
| 551 | int |
| 552 | isis_redistribute_default_set(int routetype, int metric_type, int metric_value) |
| 553 | { |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | |
| 558 | void |
| 559 | isis_zebra_init () |
| 560 | { |
| 561 | |
| 562 | zclient = zclient_new (); |
| 563 | zclient_init (zclient, ZEBRA_ROUTE_ISIS); |
| 564 | zclient->interface_add = isis_zebra_if_add; |
| 565 | zclient->interface_delete = isis_zebra_if_del; |
| 566 | zclient->interface_up = isis_zebra_if_state_up; |
| 567 | zclient->interface_down = isis_zebra_if_state_down; |
| 568 | zclient->interface_address_add = isis_zebra_if_address_add; |
| 569 | zclient->interface_address_delete = isis_zebra_if_address_del; |
| 570 | zclient->ipv4_route_add = isis_zebra_read_ipv4; |
| 571 | zclient->ipv4_route_delete = isis_zebra_read_ipv4; |
| 572 | #ifdef HAVE_IPV6 |
| 573 | zclient->ipv6_route_add = isis_zebra_read_ipv6; |
| 574 | zclient->ipv6_route_delete = isis_zebra_read_ipv6; |
| 575 | #endif /* HAVE_IPV6 */ |
| 576 | |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | void |
| 581 | isis_zebra_finish () |
| 582 | { |
| 583 | |
| 584 | zclient_stop (zclient); |
| 585 | zclient_free (zclient); |
| 586 | zclient = (struct zclient *) NULL; |
| 587 | |
| 588 | return; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | |