frr/ripd/rip_zebra.c

735 lines
19 KiB
C
Raw Normal View History

2002-12-13 21:15:29 +01:00
/* RIPd and zebra interface.
* Copyright (C) 1997, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
*
* 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 GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <zebra.h>
#include "command.h"
#include "prefix.h"
#include "stream.h"
#include "routemap.h"
#include "zclient.h"
#include "log.h"
#include "ripd/ripd.h"
#include "ripd/rip_debug.h"
/* All information about zebra. */
struct zclient *zclient = NULL;
/* Callback prototypes for zebra client service. */
int rip_interface_add (int, struct zclient *, zebra_size_t);
int rip_interface_delete (int, struct zclient *, zebra_size_t);
int rip_interface_address_add (int, struct zclient *, zebra_size_t);
int rip_interface_address_delete (int, struct zclient *, zebra_size_t);
int rip_interface_up (int, struct zclient *, zebra_size_t);
int rip_interface_down (int, struct zclient *, zebra_size_t);
/* RIPd to zebra command interface. */
void
rip_zebra_ipv4_add (struct prefix_ipv4 *p, struct in_addr *nexthop,
u_int32_t metric, u_char distance)
{
struct zapi_ipv4 api;
if (zclient->redist[ZEBRA_ROUTE_RIP])
{
api.type = ZEBRA_ROUTE_RIP;
api.flags = 0;
api.message = 0;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1;
api.nexthop = &nexthop;
api.ifindex_num = 0;
SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
api.metric = metric;
if (distance && distance != ZEBRA_RIP_DISTANCE_DEFAULT)
{
SET_FLAG (api.message, ZAPI_MESSAGE_DISTANCE);
api.distance = distance;
}
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api);
2002-12-13 21:15:29 +01:00
rip_global_route_changes++;
}
}
void
rip_zebra_ipv4_delete (struct prefix_ipv4 *p, struct in_addr *nexthop,
u_int32_t metric)
{
struct zapi_ipv4 api;
if (zclient->redist[ZEBRA_ROUTE_RIP])
{
api.type = ZEBRA_ROUTE_RIP;
api.flags = 0;
api.message = 0;
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
api.nexthop_num = 1;
api.nexthop = &nexthop;
api.ifindex_num = 0;
SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
api.metric = metric;
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api);
2002-12-13 21:15:29 +01:00
rip_global_route_changes++;
}
}
/* Zebra route add and delete treatment. */
int
rip_zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length)
{
struct stream *s;
struct zapi_ipv4 api;
unsigned long ifindex;
struct in_addr nexthop;
struct prefix_ipv4 p;
s = zclient->ibuf;
ifindex = 0;
nexthop.s_addr = 0;
/* Type, flags, message. */
api.type = stream_getc (s);
api.flags = stream_getc (s);
api.message = stream_getc (s);
/* IPv4 prefix. */
memset (&p, 0, sizeof (struct prefix_ipv4));
p.family = AF_INET;
p.prefixlen = stream_getc (s);
stream_get (&p.prefix, s, PSIZE (p.prefixlen));
/* Nexthop, ifindex, distance, metric. */
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
{
api.nexthop_num = stream_getc (s);
nexthop.s_addr = stream_get_ipv4 (s);
}
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
{
api.ifindex_num = stream_getc (s);
ifindex = stream_getl (s);
}
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
api.distance = stream_getc (s);
else
api.distance = 255;
2002-12-13 21:15:29 +01:00
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
api.metric = stream_getl (s);
else
api.metric = 0;
2002-12-13 21:15:29 +01:00
/* Then fetch IPv4 prefixes. */
if (command == ZEBRA_IPV4_ROUTE_ADD)
rip_redistribute_add (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex,
&nexthop, api.metric, api.distance);
2002-12-13 21:15:29 +01:00
else
rip_redistribute_delete (api.type, RIP_ROUTE_REDISTRIBUTE, &p, ifindex);
return 0;
}
void
rip_zclient_reset ()
{
zclient_reset (zclient);
}
/* RIP route-map set for redistribution */
void
rip_routemap_set (int type, const char *name)
2002-12-13 21:15:29 +01:00
{
if (rip->route_map[type].name)
free(rip->route_map[type].name);
rip->route_map[type].name = strdup (name);
rip->route_map[type].map = route_map_lookup_by_name (name);
}
void
2004-10-08 08:36:38 +02:00
rip_redistribute_metric_set (int type, unsigned int metric)
2002-12-13 21:15:29 +01:00
{
rip->route_map[type].metric_config = 1;
rip->route_map[type].metric = metric;
}
int
2004-10-08 08:36:38 +02:00
rip_metric_unset (int type, unsigned int metric)
2002-12-13 21:15:29 +01:00
{
#define DONT_CARE_METRIC_RIP 17
if (metric != DONT_CARE_METRIC_RIP &&
rip->route_map[type].metric != metric)
return 1;
rip->route_map[type].metric_config = 0;
rip->route_map[type].metric = 0;
return 0;
}
/* RIP route-map unset for redistribution */
int
rip_routemap_unset (int type, const char *name)
2002-12-13 21:15:29 +01:00
{
if (! rip->route_map[type].name ||
(name != NULL && strcmp(rip->route_map[type].name,name)))
return 1;
free (rip->route_map[type].name);
rip->route_map[type].name = NULL;
rip->route_map[type].map = NULL;
return 0;
}
/* Redistribution types */
static struct {
int type;
int str_min_len;
2004-10-08 08:36:38 +02:00
const char *str;
2002-12-13 21:15:29 +01:00
} redist_type[] = {
{ZEBRA_ROUTE_KERNEL, 1, "kernel"},
{ZEBRA_ROUTE_CONNECT, 1, "connected"},
{ZEBRA_ROUTE_STATIC, 1, "static"},
{ZEBRA_ROUTE_OSPF, 1, "ospf"},
{ZEBRA_ROUTE_BGP, 1, "bgp"},
{0, 0, NULL}
};
DEFUN (router_zebra,
router_zebra_cmd,
"router zebra",
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
vty->node = ZEBRA_NODE;
zclient->enable = 1;
zclient_start (zclient);
return CMD_SUCCESS;
}
DEFUN (no_router_zebra,
no_router_zebra_cmd,
"no router zebra",
NO_STR
"Enable a routing process\n"
"Make connection to zebra daemon\n")
{
zclient->enable = 0;
zclient_stop (zclient);
return CMD_SUCCESS;
}
int
rip_redistribute_set (int type)
{
if (zclient->redist[type])
return CMD_SUCCESS;
zclient->redist[type] = 1;
if (zclient->sock > 0)
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu> Implement non-blocking zclient I/O with buffering. * zclient.h (struct zclient): Add two fields to support non-blocking I/O: struct buffer *wb, and struct thread *t_write. (zclient_free): Remove function. (zebra_redistribute_send): Change 2nd arg from socket fd to struct zclient * (needed to support non-blocking I/O and buffering). (zclient_send_message): New function to send an arbitrary message with non-blocking I/O. * zclient.c (zclient_new): Create write buffer. (zclient_free): Remove unused function. (zclient_stop): Must cancel new t_write thread. Also, reset all buffers: ibuf, obuf, and wb. (zclient_failed): New helper function for typical error handling. (zclient_flush_data): New thread to flush queued data. (zclient_send_message): New function to send the message in zclient->obuf to zebra using non-blocking I/O and buffering. (zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use new zclient_send_message function instead of calling writen. (zclient_start): Set socket non-blocking. Also, change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. (zebra_redistribute_send): Change 2nd arg to struct zclient *. Can now use zclient->obuf to assemble the message instead of allocating a temporary stream. And call zclient_send_message to send the message instead of writen. (zclient_read): Convert to support non-blocking I/O by using stream_read_try instead of deprecated stream_read. (zclient_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead of writen. * rip_zebra.c (rip_redistribute_set, rip_redistribute_unset, rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset): The 2nd arg to zebra_redistribute_send is now zclient instead of zclient->sock. * isis_zebra.h (isis_zebra_finish): Remove declaration of unused function. * isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message to send the message to zebra instead of calling writen directly, since zclient_send_message understands non-blocking I/O and will manage the buffer queue appropriately. (isis_zebra_finish): Remove unused function, particularly since the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type);
2002-12-13 21:15:29 +01:00
return CMD_SUCCESS;
}
int
rip_redistribute_unset (int type)
{
if (! zclient->redist[type])
return CMD_SUCCESS;
zclient->redist[type] = 0;
if (zclient->sock > 0)
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu> Implement non-blocking zclient I/O with buffering. * zclient.h (struct zclient): Add two fields to support non-blocking I/O: struct buffer *wb, and struct thread *t_write. (zclient_free): Remove function. (zebra_redistribute_send): Change 2nd arg from socket fd to struct zclient * (needed to support non-blocking I/O and buffering). (zclient_send_message): New function to send an arbitrary message with non-blocking I/O. * zclient.c (zclient_new): Create write buffer. (zclient_free): Remove unused function. (zclient_stop): Must cancel new t_write thread. Also, reset all buffers: ibuf, obuf, and wb. (zclient_failed): New helper function for typical error handling. (zclient_flush_data): New thread to flush queued data. (zclient_send_message): New function to send the message in zclient->obuf to zebra using non-blocking I/O and buffering. (zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use new zclient_send_message function instead of calling writen. (zclient_start): Set socket non-blocking. Also, change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. (zebra_redistribute_send): Change 2nd arg to struct zclient *. Can now use zclient->obuf to assemble the message instead of allocating a temporary stream. And call zclient_send_message to send the message instead of writen. (zclient_read): Convert to support non-blocking I/O by using stream_read_try instead of deprecated stream_read. (zclient_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead of writen. * rip_zebra.c (rip_redistribute_set, rip_redistribute_unset, rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset): The 2nd arg to zebra_redistribute_send is now zclient instead of zclient->sock. * isis_zebra.h (isis_zebra_finish): Remove declaration of unused function. * isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message to send the message to zebra instead of calling writen directly, since zclient_send_message understands non-blocking I/O and will manage the buffer queue appropriately. (isis_zebra_finish): Remove unused function, particularly since the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
2002-12-13 21:15:29 +01:00
/* Remove the routes from RIP table. */
rip_redistribute_withdraw (type);
return CMD_SUCCESS;
}
int
rip_redistribute_check (int type)
{
return (zclient->redist[type]);
}
void
rip_redistribute_clean ()
{
int i;
for (i = 0; redist_type[i].str; i++)
{
if (zclient->redist[redist_type[i].type])
{
if (zclient->sock > 0)
zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE,
2005-04-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu> Implement non-blocking zclient I/O with buffering. * zclient.h (struct zclient): Add two fields to support non-blocking I/O: struct buffer *wb, and struct thread *t_write. (zclient_free): Remove function. (zebra_redistribute_send): Change 2nd arg from socket fd to struct zclient * (needed to support non-blocking I/O and buffering). (zclient_send_message): New function to send an arbitrary message with non-blocking I/O. * zclient.c (zclient_new): Create write buffer. (zclient_free): Remove unused function. (zclient_stop): Must cancel new t_write thread. Also, reset all buffers: ibuf, obuf, and wb. (zclient_failed): New helper function for typical error handling. (zclient_flush_data): New thread to flush queued data. (zclient_send_message): New function to send the message in zclient->obuf to zebra using non-blocking I/O and buffering. (zebra_message_send, zapi_ipv4_route, zapi_ipv6_route): Use new zclient_send_message function instead of calling writen. (zclient_start): Set socket non-blocking. Also, change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. (zebra_redistribute_send): Change 2nd arg to struct zclient *. Can now use zclient->obuf to assemble the message instead of allocating a temporary stream. And call zclient_send_message to send the message instead of writen. (zclient_read): Convert to support non-blocking I/O by using stream_read_try instead of deprecated stream_read. (zclient_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf6_zebra.c (ospf6_zebra_redistribute, ospf6_zebra_no_redistribute): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ospf_zebra.c (ospf_zebra_add): Call zclient_send_message instead of writen. * rip_zebra.c (rip_redistribute_set, rip_redistribute_unset, rip_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * ripng_zebra.c (ripng_redistribute_unset, ripng_redistribute_clean): Change 2nd arg to zebra_redistribute_send from zclient->sock to zclient. * bgp_zebra.c (bgp_redistribute_set, bgp_redistribute_unset): The 2nd arg to zebra_redistribute_send is now zclient instead of zclient->sock. * isis_zebra.h (isis_zebra_finish): Remove declaration of unused function. * isis_zebra.c (isis_zebra_route_add_ipv4): Call zclient_send_message to send the message to zebra instead of calling writen directly, since zclient_send_message understands non-blocking I/O and will manage the buffer queue appropriately. (isis_zebra_finish): Remove unused function, particularly since the zclient_free function has been removed.
2005-04-11 17:51:40 +02:00
zclient, redist_type[i].type);
2002-12-13 21:15:29 +01:00
zclient->redist[redist_type[i].type] = 0;
/* Remove the routes from RIP table. */
rip_redistribute_withdraw (redist_type[i].type);
}
}
}
DEFUN (rip_redistribute_rip,
rip_redistribute_rip_cmd,
"redistribute rip",
"Redistribute information from another routing protocol\n"
"Routing Information Protocol (RIP)\n")
{
zclient->redist[ZEBRA_ROUTE_RIP] = 1;
return CMD_SUCCESS;
}
DEFUN (no_rip_redistribute_rip,
no_rip_redistribute_rip_cmd,
"no redistribute rip",
NO_STR
"Redistribute information from another routing protocol\n"
"Routing Information Protocol (RIP)\n")
{
zclient->redist[ZEBRA_ROUTE_RIP] = 0;
return CMD_SUCCESS;
}
DEFUN (rip_redistribute_type,
rip_redistribute_type_cmd,
"redistribute (kernel|connected|static|ospf|bgp)",
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n")
{
int i;
for(i = 0; redist_type[i].str; i++)
{
if (strncmp (redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient,
redist_type[i].type);
2002-12-13 21:15:29 +01:00
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (no_rip_redistribute_type,
no_rip_redistribute_type_cmd,
"no redistribute (kernel|connected|static|ospf|bgp)",
NO_STR
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n")
{
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
rip_metric_unset (redist_type[i].type, DONT_CARE_METRIC_RIP);
rip_routemap_unset (redist_type[i].type,NULL);
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (rip_redistribute_type_routemap,
rip_redistribute_type_routemap_cmd,
"redistribute (kernel|connected|static|ospf|bgp) route-map WORD",
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
int i;
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
rip_routemap_set (redist_type[i].type, argv[1]);
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
2002-12-13 21:15:29 +01:00
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (no_rip_redistribute_type_routemap,
no_rip_redistribute_type_routemap_cmd,
"no redistribute (kernel|connected|static|ospf|bgp) route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
if (rip_routemap_unset (redist_type[i].type,argv[1]))
return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (rip_redistribute_type_metric,
rip_redistribute_type_metric_cmd,
"redistribute (kernel|connected|static|ospf|bgp) metric <0-16>",
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n"
"Metric value\n")
{
int i;
int metric;
metric = atoi (argv[1]);
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
rip_redistribute_metric_set (redist_type[i].type, metric);
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
2002-12-13 21:15:29 +01:00
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
DEFUN (no_rip_redistribute_type_metric,
no_rip_redistribute_type_metric_cmd,
"no redistribute (kernel|connected|static|ospf|bgp) metric <0-16>",
NO_STR
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n"
"Metric value\n")
{
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
return CMD_WARNING;
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
2003-05-25 16:49:19 +02:00
DEFUN (rip_redistribute_type_metric_routemap,
rip_redistribute_type_metric_routemap_cmd,
"redistribute (kernel|connected|static|ospf|bgp) metric <0-16> route-map WORD",
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n"
"Metric value\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
int i;
int metric;
metric = atoi (argv[1]);
for (i = 0; redist_type[i].str; i++) {
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
rip_redistribute_metric_set (redist_type[i].type, metric);
rip_routemap_set (redist_type[i].type, argv[2]);
2004-05-08 Paul Jakma <paul@dishone.st> * bgp_zebra.c: (bgp_interface_address_add) sync to zclient changes (bgp_interface_address_delete) ditto. (bgp_zebra_announce) ditto. (bgp_zebra_withdraw) ditto. * isis_zebra.c: Sync with zclient changes. * zclient.c (zapi_ipv4_route) Follow Sowmini's lead and describe message format. * ospf6_zebra.c: Sync to zclient changes * ospf_zebra.c: Sync with lib/zclient changes * rip_zebra.c: sync with zclient changes. * rip_interface.c: ditto. * ripng_{interface,zebra}.c: sync with zclient changes 2004-05-08 Sowmini Varadhan <sowmini.varadhan@sun.com> * zclient.c: (zapi_ipv4_add) collapsed into zapi_ipv4_route (zapi_ipv4_delete) ditto. (zapi_ipv4_route) add/delete a route by way of cmd arg. (zapi_ipv6_add) collapsed into zapi_ipv6_route. (zapi_ipv6_delete) ditto. (zapi_ipv6_route) add/delete a route by way of cmd arg. (zebra_interface_address_delete_read) collapsed into zebra_interface_address_read. (zebra_interface_address_delete_read) ditto. (zebra_interface_address_read) read address add/delete messages by way of type argument. Describe command message format. (zebra_interface_add_read) Unconditionally read new ifmtu6 field. Describe command message format. (zebra_interface_state_read) Unconditionally read new ifmtu6 field. (zclient_redistribute_set) Collapsed into zclient_redistribute (zclient_redistribute_unset) ditto (zclient_redistribute) set/unset redistribution. (zclient_redistribute_default_set) Collapsed into zclient_redistribute_default. (zclient_redistribute_default_unset) ditto. (zclient_redistribute_default) Redistribute default set/unset. * zclient.h: delete zapi_ipv{4,6}_add, zapi_ipv{4,6}_delete. Add zapi_ipv{4,6}_route. delete zclient_redistribute_set/unset. Add zclient_redistribute. Ditto for zclient_redistribute_default_{set/unset}.
2004-05-08 13:48:26 +02:00
zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, redist_type[i].type);
2003-05-25 16:49:19 +02:00
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
2002-12-13 21:15:29 +01:00
DEFUN (no_rip_redistribute_type_metric_routemap,
no_rip_redistribute_type_metric_routemap_cmd,
"no redistribute (kernel|connected|static|ospf|bgp) metric <0-16> route-map WORD",
NO_STR
"Redistribute information from another routing protocol\n"
"Kernel routes\n"
"Connected\n"
"Static routes\n"
"Open Shortest Path First (OSPF)\n"
"Border Gateway Protocol (BGP)\n"
"Metric\n"
"Metric value\n"
"Route map reference\n"
"Pointer to route-map entries\n")
{
int i;
for (i = 0; redist_type[i].str; i++)
{
if (strncmp(redist_type[i].str, argv[0],
redist_type[i].str_min_len) == 0)
{
if (rip_metric_unset (redist_type[i].type, atoi(argv[1])))
return CMD_WARNING;
if (rip_routemap_unset (redist_type[i].type, argv[2]))
{
rip_redistribute_metric_set(redist_type[i].type, atoi(argv[1]));
return CMD_WARNING;
}
rip_redistribute_unset (redist_type[i].type);
return CMD_SUCCESS;
}
}
vty_out(vty, "Invalid type %s%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
/* Default information originate. */
DEFUN (rip_default_information_originate,
rip_default_information_originate_cmd,
"default-information originate",
"Control distribution of default route\n"
"Distribute a default route\n")
{
struct prefix_ipv4 p;
if (! rip->default_information)
{
memset (&p, 0, sizeof (struct prefix_ipv4));
p.family = AF_INET;
rip->default_information = 1;
rip_redistribute_add (ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0,
NULL, 0, 0);
2002-12-13 21:15:29 +01:00
}
return CMD_SUCCESS;
}
DEFUN (no_rip_default_information_originate,
no_rip_default_information_originate_cmd,
"no default-information originate",
NO_STR
"Control distribution of default route\n"
"Distribute a default route\n")
{
struct prefix_ipv4 p;
if (rip->default_information)
{
memset (&p, 0, sizeof (struct prefix_ipv4));
p.family = AF_INET;
rip->default_information = 0;
2003-05-25 16:49:19 +02:00
rip_redistribute_delete (ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0);
2002-12-13 21:15:29 +01:00
}
return CMD_SUCCESS;
}
/* RIP configuration write function. */
int
config_write_zebra (struct vty *vty)
{
if (! zclient->enable)
{
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
return 1;
}
else if (! zclient->redist[ZEBRA_ROUTE_RIP])
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute rip%s", VTY_NEWLINE);
return 1;
}
return 0;
}
int
config_write_rip_redistribute (struct vty *vty, int config_mode)
{
int i;
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (i != zclient->redist_default && zclient->redist[i])
{
if (config_mode)
{
if (rip->route_map[i].metric_config)
{
if (rip->route_map[i].name)
vty_out (vty, " redistribute %s metric %d route-map %s%s",
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-10-01 19:38:06 +02:00
zebra_route_string(i), rip->route_map[i].metric,
2002-12-13 21:15:29 +01:00
rip->route_map[i].name,
VTY_NEWLINE);
else
vty_out (vty, " redistribute %s metric %d%s",
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-10-01 19:38:06 +02:00
zebra_route_string(i), rip->route_map[i].metric,
2002-12-13 21:15:29 +01:00
VTY_NEWLINE);
}
else
{
if (rip->route_map[i].name)
vty_out (vty, " redistribute %s route-map %s%s",
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-10-01 19:38:06 +02:00
zebra_route_string(i), rip->route_map[i].name,
2002-12-13 21:15:29 +01:00
VTY_NEWLINE);
else
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-10-01 19:38:06 +02:00
vty_out (vty, " redistribute %s%s", zebra_route_string(i),
2002-12-13 21:15:29 +01:00
VTY_NEWLINE);
}
}
else
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-10-01 19:38:06 +02:00
vty_out (vty, " %s", zebra_route_string(i));
2002-12-13 21:15:29 +01:00
}
return 0;
}
/* Zebra node structure. */
struct cmd_node zebra_node =
{
ZEBRA_NODE,
"%s(config-router)# ",
};
void
rip_zclient_init ()
{
/* Set default value to the zebra client structure. */
zclient = zclient_new ();
zclient_init (zclient, ZEBRA_ROUTE_RIP);
zclient->interface_add = rip_interface_add;
zclient->interface_delete = rip_interface_delete;
zclient->interface_address_add = rip_interface_address_add;
zclient->interface_address_delete = rip_interface_address_delete;
zclient->ipv4_route_add = rip_zebra_read_ipv4;
zclient->ipv4_route_delete = rip_zebra_read_ipv4;
zclient->interface_up = rip_interface_up;
zclient->interface_down = rip_interface_down;
/* Install zebra node. */
install_node (&zebra_node, config_write_zebra);
/* Install command elements to zebra node. */
install_element (CONFIG_NODE, &router_zebra_cmd);
install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd);
install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd);
/* Install command elements to rip node. */
install_element (RIP_NODE, &rip_redistribute_type_cmd);
install_element (RIP_NODE, &rip_redistribute_type_routemap_cmd);
install_element (RIP_NODE, &rip_redistribute_type_metric_cmd);
2003-05-25 16:49:19 +02:00
install_element (RIP_NODE, &rip_redistribute_type_metric_routemap_cmd);
2002-12-13 21:15:29 +01:00
install_element (RIP_NODE, &no_rip_redistribute_type_cmd);
install_element (RIP_NODE, &no_rip_redistribute_type_routemap_cmd);
install_element (RIP_NODE, &no_rip_redistribute_type_metric_cmd);
install_element (RIP_NODE, &no_rip_redistribute_type_metric_routemap_cmd);
install_element (RIP_NODE, &rip_default_information_originate_cmd);
install_element (RIP_NODE, &no_rip_default_information_originate_cmd);
}