blob: ad5a0507f0350ce653c0a5fd281240c25fa8a166 [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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>
jardineb5d44e2003-12-23 08:09:43 +000024
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"
35
36#include "isisd/isis_constants.h"
37#include "isisd/isis_common.h"
38#include "isisd/isis_circuit.h"
39#include "isisd/isis_csm.h"
40#include "isisd/isis_route.h"
41#include "isisd/isis_zebra.h"
42
43struct zclient *zclient = NULL;
44
45extern struct thread_master *master;
46
hassof390d2c2004-09-10 20:48:21 +000047int
jardineb5d44e2003-12-23 08:09:43 +000048isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)
49{
50 struct interface *ifp;
51
52 ifp = zebra_interface_add_read (zclient->ibuf);
hassof390d2c2004-09-10 20:48:21 +000053
jardineb5d44e2003-12-23 08:09:43 +000054
55 zlog_info ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
56 ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
hassof390d2c2004-09-10 20:48:21 +000057
jardineb5d44e2003-12-23 08:09:43 +000058 if (if_is_up (ifp))
59 isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
hassof390d2c2004-09-10 20:48:21 +000060
jardineb5d44e2003-12-23 08:09:43 +000061 return 0;
62}
63
64int
65isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)
66{
67 struct interface *ifp;
68 struct stream *s;
69
70 s = zclient->ibuf;
71 ifp = zebra_interface_state_read (s);
hassof390d2c2004-09-10 20:48:21 +000072
jardineb5d44e2003-12-23 08:09:43 +000073 if (!ifp)
74 return 0;
75
76 if (if_is_up (ifp))
77 zlog_warn ("Zebra: got delete of %s, but interface is still up",
hassof390d2c2004-09-10 20:48:21 +000078 ifp->name);
jardineb5d44e2003-12-23 08:09:43 +000079
80 zlog_info ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
81 ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
82
83 if_delete (ifp);
hassof390d2c2004-09-10 20:48:21 +000084
jardineb5d44e2003-12-23 08:09:43 +000085 isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
86
87 return 0;
88}
89
90struct interface *
91zebra_interface_if_lookup (struct stream *s)
92{
93 struct interface *ifp;
94 u_char ifname_tmp[INTERFACE_NAMSIZ];
95
96 /* Read interface name. */
97 stream_get (ifname_tmp, s, INTERFACE_NAMSIZ);
98
99 /* Lookup this by interface index. */
100 ifp = if_lookup_by_name (ifname_tmp);
101
102 /* If such interface does not exist, indicate an error */
103 if (!ifp)
104 return NULL;
105
106 return ifp;
107}
108
109void
110zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
111{
112 /* Read interface's index. */
113 ifp->ifindex = stream_getl (s);
114
115 /* Read interface's value. */
116 ifp->flags = stream_getl (s);
117 ifp->metric = stream_getl (s);
118 ifp->mtu = stream_getl (s);
119 ifp->bandwidth = stream_getl (s);
120}
121
122int
hassof390d2c2004-09-10 20:48:21 +0000123isis_zebra_if_state_up (int command, struct zclient *zclient,
jardineb5d44e2003-12-23 08:09:43 +0000124 zebra_size_t length)
125{
126 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +0000127
jardineb5d44e2003-12-23 08:09:43 +0000128 ifp = zebra_interface_if_lookup (zclient->ibuf);
hassof390d2c2004-09-10 20:48:21 +0000129
jardineb5d44e2003-12-23 08:09:43 +0000130 if (!ifp)
131 return 0;
hassof390d2c2004-09-10 20:48:21 +0000132
133 if (if_is_up (ifp))
134 {
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
jardineb5d44e2003-12-23 08:09:43 +0000140 zebra_interface_if_set_value (zclient->ibuf, ifp);
141 isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
hassof390d2c2004-09-10 20:48:21 +0000142
jardineb5d44e2003-12-23 08:09:43 +0000143 return 0;
144}
145
jardineb5d44e2003-12-23 08:09:43 +0000146int
hassof390d2c2004-09-10 20:48:21 +0000147isis_zebra_if_state_down (int command, struct zclient *zclient,
jardineb5d44e2003-12-23 08:09:43 +0000148 zebra_size_t length)
149{
150 struct interface *ifp;
hassof390d2c2004-09-10 20:48:21 +0000151
jardineb5d44e2003-12-23 08:09:43 +0000152 ifp = zebra_interface_if_lookup (zclient->ibuf);
hassof390d2c2004-09-10 20:48:21 +0000153
jardineb5d44e2003-12-23 08:09:43 +0000154 if (ifp == NULL)
155 return 0;
hassof390d2c2004-09-10 20:48:21 +0000156
157 if (if_is_up (ifp))
158 {
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
jardineb5d44e2003-12-23 08:09:43 +0000163 return 0;
164}
165
166int
hassof390d2c2004-09-10 20:48:21 +0000167isis_zebra_if_address_add (int command, struct zclient *zclient,
168 zebra_size_t length)
jardineb5d44e2003-12-23 08:09:43 +0000169{
170 struct connected *c;
171 struct prefix *p;
172 u_char buf[BUFSIZ];
173
hassof390d2c2004-09-10 20:48:21 +0000174 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
175 zclient->ibuf);
176
jardineb5d44e2003-12-23 08:09:43 +0000177 if (c == NULL)
178 return 0;
hassof390d2c2004-09-10 20:48:21 +0000179
jardineb5d44e2003-12-23 08:09:43 +0000180 p = c->address;
hassof390d2c2004-09-10 20:48:21 +0000181
jardineb5d44e2003-12-23 08:09:43 +0000182 prefix2str (p, buf, BUFSIZ);
183#ifdef EXTREME_DEBUG
hassof390d2c2004-09-10 20:48:21 +0000184 if (p->family == AF_INET)
jardineb5d44e2003-12-23 08:09:43 +0000185 zlog_info ("connected IP address %s", buf);
186#ifdef HAVE_IPV6
187 if (p->family == AF_INET6)
188 zlog_info ("connected IPv6 address %s", buf);
189#endif /* HAVE_IPV6 */
190#endif /* EXTREME_DEBUG */
hassof390d2c2004-09-10 20:48:21 +0000191 isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c);
jardineb5d44e2003-12-23 08:09:43 +0000192
193 return 0;
194}
195
196int
hassof390d2c2004-09-10 20:48:21 +0000197isis_zebra_if_address_del (int command, struct zclient *client,
198 zebra_size_t length)
jardineb5d44e2003-12-23 08:09:43 +0000199{
200 struct connected *c;
201 struct interface *ifp;
202
hassof390d2c2004-09-10 20:48:21 +0000203 c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
204 zclient->ibuf);
205
jardineb5d44e2003-12-23 08:09:43 +0000206 if (c == NULL)
207 return 0;
hassof390d2c2004-09-10 20:48:21 +0000208
jardineb5d44e2003-12-23 08:09:43 +0000209 ifp = c->ifp;
hassof390d2c2004-09-10 20:48:21 +0000210
jardineb5d44e2003-12-23 08:09:43 +0000211 connected_free (c);
hassof390d2c2004-09-10 20:48:21 +0000212
jardineb5d44e2003-12-23 08:09:43 +0000213 isis_circuit_del_addr (circuit_scan_by_ifp (ifp), c);
hassof390d2c2004-09-10 20:48:21 +0000214
jardineb5d44e2003-12-23 08:09:43 +0000215 return 0;
216}
217
218void
hassof390d2c2004-09-10 20:48:21 +0000219isis_zebra_route_add_ipv4 (struct prefix *prefix,
220 struct isis_route_info *route_info)
jardineb5d44e2003-12-23 08:09:43 +0000221{
222 u_char message, flags;
223 int psize;
224 struct stream *stream;
225 struct isis_nexthop *nexthop;
226 struct listnode *node;
227
228 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
229 return;
230
hassof390d2c2004-09-10 20:48:21 +0000231 if (zclient->redist[ZEBRA_ROUTE_ISIS])
232 {
233 message = 0;
234 flags = 0;
jardineb5d44e2003-12-23 08:09:43 +0000235
hassof390d2c2004-09-10 20:48:21 +0000236 SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
237 SET_FLAG (message, ZAPI_MESSAGE_METRIC);
hasso2097cd82003-12-23 11:51:08 +0000238#if 0
hassof390d2c2004-09-10 20:48:21 +0000239 SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
hasso2097cd82003-12-23 11:51:08 +0000240#endif
hassof390d2c2004-09-10 20:48:21 +0000241
242 stream = zclient->obuf;
243 stream_reset (stream);
244 /* Length place holder. */
245 stream_putw (stream, 0);
246 /* command */
247 stream_putc (stream, ZEBRA_IPV4_ROUTE_ADD);
248 /* type */
249 stream_putc (stream, ZEBRA_ROUTE_ISIS);
250 /* flags */
251 stream_putc (stream, flags);
252 /* message */
253 stream_putc (stream, message);
254 /* prefix information */
255 psize = PSIZE (prefix->prefixlen);
256 stream_putc (stream, prefix->prefixlen);
257 stream_write (stream, (u_char *) & prefix->u.prefix4, psize);
258
259 stream_putc (stream, listcount (route_info->nexthops));
260
261 /* Nexthop, ifindex, distance and metric information */
262 for (node = listhead (route_info->nexthops); node; nextnode (node))
263 {
264 nexthop = getdata (node);
265 /* FIXME: can it be ? */
266 if (nexthop->ip.s_addr != INADDR_ANY)
267 {
268 stream_putc (stream, ZEBRA_NEXTHOP_IPV4);
269 stream_put_in_addr (stream, &nexthop->ip);
270 }
271 else
272 {
273 stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX);
274 stream_putl (stream, nexthop->ifindex);
275 }
276 }
277#if 0
278 if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
279 stream_putc (stream, route_info->depth);
280#endif
281 if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
282 stream_putl (stream, route_info->cost);
283
284 stream_putw_at (stream, 0, stream_get_endp (stream));
285 writen (zclient->sock, stream->data, stream_get_endp (stream));
286 }
jardineb5d44e2003-12-23 08:09:43 +0000287}
288
289void
hassof390d2c2004-09-10 20:48:21 +0000290isis_zebra_route_del_ipv4 (struct prefix *prefix,
291 struct isis_route_info *route_info)
jardineb5d44e2003-12-23 08:09:43 +0000292{
293 struct zapi_ipv4 api;
294 struct prefix_ipv4 prefix4;
hassof390d2c2004-09-10 20:48:21 +0000295
296 if (zclient->redist[ZEBRA_ROUTE_ISIS])
297 {
298 api.type = ZEBRA_ROUTE_ISIS;
299 api.flags = 0;
300 api.message = 0;
301 prefix4.family = AF_INET;
302 prefix4.prefixlen = prefix->prefixlen;
303 prefix4.prefix = prefix->u.prefix4;
304 zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api);
305 }
306
jardineb5d44e2003-12-23 08:09:43 +0000307 return;
308}
309
310#ifdef HAVE_IPV6
311void
312isis_zebra_route_add_ipv6 (struct prefix *prefix,
hassof390d2c2004-09-10 20:48:21 +0000313 struct isis_route_info *route_info)
jardineb5d44e2003-12-23 08:09:43 +0000314{
315 struct zapi_ipv6 api;
316 struct in6_addr **nexthop_list;
317 unsigned int *ifindex_list;
318 struct isis_nexthop6 *nexthop6;
319 int i, size;
320 struct listnode *node;
321 struct prefix_ipv6 prefix6;
322
323 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
324 return;
hassof390d2c2004-09-10 20:48:21 +0000325
jardineb5d44e2003-12-23 08:09:43 +0000326 api.type = ZEBRA_ROUTE_ISIS;
327 api.flags = 0;
328 api.message = 0;
329 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
330 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
331 SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
332 api.metric = route_info->cost;
333#if 0
334 SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
335 api.distance = route_info->depth;
336#endif
337 api.nexthop_num = listcount (route_info->nexthops6);
338 api.ifindex_num = listcount (route_info->nexthops6);
hassof390d2c2004-09-10 20:48:21 +0000339
jardineb5d44e2003-12-23 08:09:43 +0000340 /* allocate memory for nexthop_list */
341 size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
342 nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
hassof390d2c2004-09-10 20:48:21 +0000343 if (!nexthop_list)
344 {
345 zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
346 return;
347 }
348
jardineb5d44e2003-12-23 08:09:43 +0000349 /* allocate memory for ifindex_list */
350 size = sizeof (unsigned int) * listcount (route_info->nexthops6);
351 ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size);
hassof390d2c2004-09-10 20:48:21 +0000352 if (!ifindex_list)
353 {
354 zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
355 XFREE (MTYPE_ISIS_TMP, nexthop_list);
356 return;
357 }
358
jardineb5d44e2003-12-23 08:09:43 +0000359 /* for each nexthop */
360 i = 0;
hassof390d2c2004-09-10 20:48:21 +0000361 for (node = listhead (route_info->nexthops6); node; nextnode (node))
362 {
363 nexthop6 = getdata (node);
364
365 if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
366 !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
367 {
368 api.nexthop_num--;
369 api.ifindex_num--;
370 continue;
371 }
372
373 nexthop_list[i] = &nexthop6->ip6;
374 ifindex_list[i] = nexthop6->ifindex;
375 i++;
jardineb5d44e2003-12-23 08:09:43 +0000376 }
hassof390d2c2004-09-10 20:48:21 +0000377
jardineb5d44e2003-12-23 08:09:43 +0000378 api.nexthop = nexthop_list;
379 api.ifindex = ifindex_list;
hassof390d2c2004-09-10 20:48:21 +0000380
381 if (api.nexthop_num && api.ifindex_num)
382 {
383 prefix6.family = AF_INET6;
384 prefix6.prefixlen = prefix->prefixlen;
385 memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
386 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, &api);
387 SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
388 }
389
jardineb5d44e2003-12-23 08:09:43 +0000390 XFREE (MTYPE_ISIS_TMP, nexthop_list);
391 XFREE (MTYPE_ISIS_TMP, ifindex_list);
hassof390d2c2004-09-10 20:48:21 +0000392
jardineb5d44e2003-12-23 08:09:43 +0000393 return;
394}
395
396void
hassof390d2c2004-09-10 20:48:21 +0000397isis_zebra_route_del_ipv6 (struct prefix *prefix,
398 struct isis_route_info *route_info)
jardineb5d44e2003-12-23 08:09:43 +0000399{
400 struct zapi_ipv6 api;
401 struct in6_addr **nexthop_list;
402 unsigned int *ifindex_list;
403 struct isis_nexthop6 *nexthop6;
404 int i, size;
405 struct listnode *node;
406 struct prefix_ipv6 prefix6;
407
408 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
409 return;
hassof390d2c2004-09-10 20:48:21 +0000410
jardineb5d44e2003-12-23 08:09:43 +0000411 api.type = ZEBRA_ROUTE_ISIS;
412 api.flags = 0;
413 api.message = 0;
414 SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
415 SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
416 api.nexthop_num = listcount (route_info->nexthops6);
417 api.ifindex_num = listcount (route_info->nexthops6);
hassof390d2c2004-09-10 20:48:21 +0000418
jardineb5d44e2003-12-23 08:09:43 +0000419 /* allocate memory for nexthop_list */
420 size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
421 nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
hassof390d2c2004-09-10 20:48:21 +0000422 if (!nexthop_list)
423 {
424 zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
425 return;
426 }
427
jardineb5d44e2003-12-23 08:09:43 +0000428 /* allocate memory for ifindex_list */
429 size = sizeof (unsigned int) * listcount (route_info->nexthops6);
430 ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size);
hassof390d2c2004-09-10 20:48:21 +0000431 if (!ifindex_list)
432 {
433 zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
434 XFREE (MTYPE_ISIS_TMP, nexthop_list);
435 return;
436 }
437
jardineb5d44e2003-12-23 08:09:43 +0000438 /* for each nexthop */
439 i = 0;
hassof390d2c2004-09-10 20:48:21 +0000440 for (node = listhead (route_info->nexthops6); node; nextnode (node))
441 {
442 nexthop6 = getdata (node);
443
444 if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
445 !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
446 {
447 api.nexthop_num--;
448 api.ifindex_num--;
449 continue;
450 }
451
452 nexthop_list[i] = &nexthop6->ip6;
453 ifindex_list[i] = nexthop6->ifindex;
454 i++;
jardineb5d44e2003-12-23 08:09:43 +0000455 }
hassof390d2c2004-09-10 20:48:21 +0000456
jardineb5d44e2003-12-23 08:09:43 +0000457 api.nexthop = nexthop_list;
458 api.ifindex = ifindex_list;
jardineb5d44e2003-12-23 08:09:43 +0000459
hassof390d2c2004-09-10 20:48:21 +0000460 if (api.nexthop_num && api.ifindex_num)
461 {
462 prefix6.family = AF_INET6;
463 prefix6.prefixlen = prefix->prefixlen;
464 memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
465 zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, &api);
466 UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
467 }
468
469 XFREE (MTYPE_ISIS_TMP, nexthop_list);
470 XFREE (MTYPE_ISIS_TMP, ifindex_list);
471}
jardineb5d44e2003-12-23 08:09:43 +0000472
473#endif /* HAVE_IPV6 */
474
jardineb5d44e2003-12-23 08:09:43 +0000475void
476isis_zebra_route_update (struct prefix *prefix,
hassof390d2c2004-09-10 20:48:21 +0000477 struct isis_route_info *route_info)
jardineb5d44e2003-12-23 08:09:43 +0000478{
479 if (zclient->sock < 0)
480 return;
481
482 if (!zclient->redist[ZEBRA_ROUTE_ISIS])
483 return;
484
hassof390d2c2004-09-10 20:48:21 +0000485 if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
486 {
487 if (prefix->family == AF_INET)
488 isis_zebra_route_add_ipv4 (prefix, route_info);
jardineb5d44e2003-12-23 08:09:43 +0000489#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000490 else if (prefix->family == AF_INET6)
491 isis_zebra_route_add_ipv6 (prefix, route_info);
jardineb5d44e2003-12-23 08:09:43 +0000492#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000493 }
494 else
495 {
496 if (prefix->family == AF_INET)
497 isis_zebra_route_del_ipv4 (prefix, route_info);
jardineb5d44e2003-12-23 08:09:43 +0000498#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000499 else if (prefix->family == AF_INET6)
500 isis_zebra_route_del_ipv6 (prefix, route_info);
jardineb5d44e2003-12-23 08:09:43 +0000501#endif /* HAVE_IPV6 */
hassof390d2c2004-09-10 20:48:21 +0000502 }
jardineb5d44e2003-12-23 08:09:43 +0000503 return;
504}
505
jardineb5d44e2003-12-23 08:09:43 +0000506int
hassof390d2c2004-09-10 20:48:21 +0000507isis_zebra_read_ipv4 (int command, struct zclient *zclient,
jardineb5d44e2003-12-23 08:09:43 +0000508 zebra_size_t length)
509{
510 struct stream *stream;
511 struct zapi_ipv4 api;
512 struct prefix_ipv4 p;
513 unsigned long ifindex;
514 struct in_addr nexthop;
515
516 stream = zclient->ibuf;
517 memset (&p, 0, sizeof (struct prefix_ipv4));
518 ifindex = 0;
519
hassof390d2c2004-09-10 20:48:21 +0000520 api.type = stream_getc (stream);
521 api.flags = stream_getc (stream);
jardineb5d44e2003-12-23 08:09:43 +0000522 api.message = stream_getc (stream);
523
524 p.family = AF_INET;
525 p.prefixlen = stream_getc (stream);
526 stream_get (&p.prefix, stream, PSIZE (p.prefixlen));
hassof390d2c2004-09-10 20:48:21 +0000527
528 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
529 {
jardineb5d44e2003-12-23 08:09:43 +0000530 api.nexthop_num = stream_getc (stream);
531 nexthop.s_addr = stream_get_ipv4 (stream);
hassof390d2c2004-09-10 20:48:21 +0000532 }
533 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
534 {
535 api.ifindex_num = stream_getc (stream);
536 ifindex = stream_getl (stream);
537 }
jardineb5d44e2003-12-23 08:09:43 +0000538 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
539 api.distance = stream_getc (stream);
540 if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
541 api.metric = stream_getl (stream);
542 else
543 api.metric = 0;
hassof390d2c2004-09-10 20:48:21 +0000544
545 if (command == ZEBRA_IPV4_ROUTE_ADD)
546 {
547 zlog_info ("IPv4 Route add from Z");
548 }
jardineb5d44e2003-12-23 08:09:43 +0000549
550 return 0;
551}
552
hassof390d2c2004-09-10 20:48:21 +0000553int
554isis_zebra_read_ipv6 (int command, struct zclient *zclient,
jardineb5d44e2003-12-23 08:09:43 +0000555 zebra_size_t length)
556{
jardineb5d44e2003-12-23 08:09:43 +0000557 return 0;
558}
559
560#define ISIS_TYPE_IS_REDISTRIBUTED(T) \
561T == ZEBRA_ROUTE_MAX ? zclient->default_information : zclient->redist[type]
562
563int
564isis_distribute_list_update (int routetype)
565{
566 return 0;
567}
568
569int
hassof390d2c2004-09-10 20:48:21 +0000570isis_redistribute_default_set (int routetype, int metric_type,
571 int metric_value)
jardineb5d44e2003-12-23 08:09:43 +0000572{
573 return 0;
574}
575
jardineb5d44e2003-12-23 08:09:43 +0000576void
577isis_zebra_init ()
578{
jardineb5d44e2003-12-23 08:09:43 +0000579 zclient = zclient_new ();
580 zclient_init (zclient, ZEBRA_ROUTE_ISIS);
581 zclient->interface_add = isis_zebra_if_add;
582 zclient->interface_delete = isis_zebra_if_del;
583 zclient->interface_up = isis_zebra_if_state_up;
584 zclient->interface_down = isis_zebra_if_state_down;
585 zclient->interface_address_add = isis_zebra_if_address_add;
586 zclient->interface_address_delete = isis_zebra_if_address_del;
587 zclient->ipv4_route_add = isis_zebra_read_ipv4;
588 zclient->ipv4_route_delete = isis_zebra_read_ipv4;
589#ifdef HAVE_IPV6
590 zclient->ipv6_route_add = isis_zebra_read_ipv6;
591 zclient->ipv6_route_delete = isis_zebra_read_ipv6;
592#endif /* HAVE_IPV6 */
593
594 return;
595}
596
597void
598isis_zebra_finish ()
599{
jardineb5d44e2003-12-23 08:09:43 +0000600 zclient_stop (zclient);
601 zclient_free (zclient);
602 zclient = (struct zclient *) NULL;
603
604 return;
605}