paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Interface related function for RIP. |
| 2 | * Copyright (C) 1997, 98 Kunihiro Ishiguro <kunihiro@zebra.org> |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | * 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "command.h" |
| 25 | #include "if.h" |
| 26 | #include "sockunion.h" |
| 27 | #include "prefix.h" |
| 28 | #include "memory.h" |
| 29 | #include "network.h" |
| 30 | #include "table.h" |
| 31 | #include "log.h" |
| 32 | #include "stream.h" |
| 33 | #include "thread.h" |
| 34 | #include "zclient.h" |
| 35 | #include "filter.h" |
| 36 | #include "sockopt.h" |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 37 | #include "privs.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | |
| 39 | #include "zebra/connected.h" |
| 40 | |
| 41 | #include "ripd/ripd.h" |
| 42 | #include "ripd/rip_debug.h" |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 43 | #include "ripd/rip_interface.h" |
| 44 | |
| 45 | /* static prototypes */ |
| 46 | static void rip_enable_apply (struct interface *); |
| 47 | static void rip_passive_interface_apply (struct interface *); |
| 48 | static int rip_if_down(struct interface *ifp); |
| 49 | static int rip_enable_if_lookup (const char *ifname); |
| 50 | static int rip_enable_network_lookup2 (struct connected *connected); |
| 51 | static void rip_enable_apply_all (void); |
| 52 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 53 | struct message ri_version_msg[] = |
| 54 | { |
| 55 | {RI_RIP_VERSION_1, "1"}, |
| 56 | {RI_RIP_VERSION_2, "2"}, |
| 57 | {RI_RIP_VERSION_1_AND_2, "1 2"}, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
paul | edd7c24 | 2003-06-04 13:59:38 +0000 | [diff] [blame] | 60 | extern struct zebra_privs_t ripd_privs; |
| 61 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | /* RIP enabled network vector. */ |
| 63 | vector rip_enable_interface; |
| 64 | |
| 65 | /* RIP enabled interface table. */ |
| 66 | struct route_table *rip_enable_network; |
| 67 | |
| 68 | /* Vector to store passive-interface name. */ |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 69 | static int passive_default; /* are we in passive-interface default mode? */ |
| 70 | vector Vrip_passive_nondefault; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 71 | |
| 72 | /* Join to the RIP version 2 multicast group. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 73 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 74 | ipv4_multicast_join (int sock, |
| 75 | struct in_addr group, |
| 76 | struct in_addr ifa, |
| 77 | unsigned int ifindex) |
| 78 | { |
| 79 | int ret; |
| 80 | |
| 81 | ret = setsockopt_multicast_ipv4 (sock, |
| 82 | IP_ADD_MEMBERSHIP, |
| 83 | ifa, |
| 84 | group.s_addr, |
| 85 | ifindex); |
| 86 | |
| 87 | if (ret < 0) |
| 88 | zlog (NULL, LOG_INFO, "can't setsockopt IP_ADD_MEMBERSHIP %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 89 | safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | |
| 91 | return ret; |
| 92 | } |
| 93 | |
| 94 | /* Leave from the RIP version 2 multicast group. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 95 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 96 | ipv4_multicast_leave (int sock, |
| 97 | struct in_addr group, |
| 98 | struct in_addr ifa, |
| 99 | unsigned int ifindex) |
| 100 | { |
| 101 | int ret; |
| 102 | |
| 103 | ret = setsockopt_multicast_ipv4 (sock, |
| 104 | IP_DROP_MEMBERSHIP, |
| 105 | ifa, |
| 106 | group.s_addr, |
| 107 | ifindex); |
| 108 | |
| 109 | if (ret < 0) |
| 110 | zlog (NULL, LOG_INFO, "can't setsockopt IP_DROP_MEMBERSHIP"); |
| 111 | |
| 112 | return ret; |
| 113 | } |
| 114 | |
| 115 | /* Allocate new RIP's interface configuration. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 116 | static struct rip_interface * |
| 117 | rip_interface_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 118 | { |
| 119 | struct rip_interface *ri; |
| 120 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 121 | ri = XCALLOC (MTYPE_RIP_INTERFACE, sizeof (struct rip_interface)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | |
| 123 | /* Default authentication type is simple password for Cisco |
| 124 | compatibility. */ |
paul | 7755a8c | 2005-06-02 08:20:53 +0000 | [diff] [blame] | 125 | ri->auth_type = RIP_NO_AUTH; |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 126 | ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | |
| 128 | /* Set default split-horizon behavior. If the interface is Frame |
| 129 | Relay or SMDS is enabled, the default value for split-horizon is |
| 130 | off. But currently Zebra does detect Frame Relay or SMDS |
| 131 | interface. So all interface is set to split horizon. */ |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 132 | ri->split_horizon_default = RIP_SPLIT_HORIZON; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | ri->split_horizon = ri->split_horizon_default; |
| 134 | |
| 135 | return ri; |
| 136 | } |
| 137 | |
| 138 | void |
paul | 1a51786 | 2004-08-19 04:03:08 +0000 | [diff] [blame] | 139 | rip_interface_multicast_set (int sock, struct connected *connected) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | { |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 141 | struct in_addr addr; |
paul | c49ad8f | 2004-10-22 10:27:28 +0000 | [diff] [blame] | 142 | |
| 143 | assert (connected != NULL); |
| 144 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 145 | addr = CONNECTED_ID(connected)->u.prefix4; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | |
paul | 1a51786 | 2004-08-19 04:03:08 +0000 | [diff] [blame] | 147 | if (setsockopt_multicast_ipv4 (sock, IP_MULTICAST_IF, addr, 0, |
| 148 | connected->ifp->ifindex) < 0) |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 149 | { |
| 150 | zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to " |
| 151 | "source address %s for interface %s", |
| 152 | sock, inet_ntoa(addr), |
paul | c49ad8f | 2004-10-22 10:27:28 +0000 | [diff] [blame] | 153 | connected->ifp->name); |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 154 | } |
paul | 2c61ae3 | 2005-08-16 15:22:14 +0000 | [diff] [blame] | 155 | |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 156 | return; |
| 157 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
| 159 | /* Send RIP request packet to specified interface. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 160 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | rip_request_interface_send (struct interface *ifp, u_char version) |
| 162 | { |
| 163 | struct sockaddr_in to; |
| 164 | |
| 165 | /* RIPv2 support multicast. */ |
| 166 | if (version == RIPv2 && if_is_multicast (ifp)) |
| 167 | { |
| 168 | |
| 169 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 170 | zlog_debug ("multicast request on %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | |
paul | 931cd54 | 2004-01-23 15:31:42 +0000 | [diff] [blame] | 172 | rip_request_send (NULL, ifp, version, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 173 | return; |
| 174 | } |
| 175 | |
| 176 | /* RIPv1 and non multicast interface. */ |
| 177 | if (if_is_pointopoint (ifp) || if_is_broadcast (ifp)) |
| 178 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 179 | struct listnode *cnode, *cnnode; |
| 180 | struct connected *connected; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 181 | |
| 182 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 183 | zlog_debug ("broadcast request to %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 185 | for (ALL_LIST_ELEMENTS (ifp->connected, cnode, cnnode, connected)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 186 | { |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 187 | if (connected->address->family == AF_INET) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 188 | { |
| 189 | memset (&to, 0, sizeof (struct sockaddr_in)); |
| 190 | to.sin_port = htons (RIP_PORT_DEFAULT); |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 191 | if (connected->destination) |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 192 | /* use specified broadcast or peer destination addr */ |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 193 | to.sin_addr = connected->destination->u.prefix4; |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 194 | else if (connected->address->prefixlen < IPV4_MAX_PREFIXLEN) |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 195 | /* calculate the appropriate broadcast address */ |
| 196 | to.sin_addr.s_addr = |
| 197 | ipv4_broadcast_addr(connected->address->u.prefix4.s_addr, |
| 198 | connected->address->prefixlen); |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 199 | else |
| 200 | /* do not know where to send the packet */ |
| 201 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 204 | zlog_debug ("SEND request to %s", inet_ntoa (to.sin_addr)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | |
paul | 931cd54 | 2004-01-23 15:31:42 +0000 | [diff] [blame] | 206 | rip_request_send (&to, ifp, version, connected); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /* This will be executed when interface goes up. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 213 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 214 | rip_request_interface (struct interface *ifp) |
| 215 | { |
| 216 | struct rip_interface *ri; |
| 217 | |
| 218 | /* In default ripd doesn't send RIP_REQUEST to the loopback interface. */ |
| 219 | if (if_is_loopback (ifp)) |
| 220 | return; |
| 221 | |
| 222 | /* If interface is down, don't send RIP packet. */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 223 | if (! if_is_operative (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 224 | return; |
| 225 | |
| 226 | /* Fetch RIP interface information. */ |
| 227 | ri = ifp->info; |
| 228 | |
| 229 | |
| 230 | /* If there is no version configuration in the interface, |
| 231 | use rip's version setting. */ |
paul | f38a471 | 2003-06-07 01:10:00 +0000 | [diff] [blame] | 232 | { |
| 233 | int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? |
| 234 | rip->version_send : ri->ri_send); |
| 235 | if (vsend & RIPv1) |
| 236 | rip_request_interface_send (ifp, RIPv1); |
| 237 | if (vsend & RIPv2) |
| 238 | rip_request_interface_send (ifp, RIPv2); |
| 239 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | /* Send RIP request to the neighbor. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 243 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 244 | rip_request_neighbor (struct in_addr addr) |
| 245 | { |
| 246 | struct sockaddr_in to; |
| 247 | |
| 248 | memset (&to, 0, sizeof (struct sockaddr_in)); |
| 249 | to.sin_port = htons (RIP_PORT_DEFAULT); |
| 250 | to.sin_addr = addr; |
| 251 | |
paul | 931cd54 | 2004-01-23 15:31:42 +0000 | [diff] [blame] | 252 | rip_request_send (&to, NULL, rip->version_send, NULL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /* Request routes at all interfaces. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 256 | static void |
| 257 | rip_request_neighbor_all (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 258 | { |
| 259 | struct route_node *rp; |
| 260 | |
| 261 | if (! rip) |
| 262 | return; |
| 263 | |
| 264 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 265 | zlog_debug ("request to the all neighbor"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 266 | |
| 267 | /* Send request to all neighbor. */ |
| 268 | for (rp = route_top (rip->neighbor); rp; rp = route_next (rp)) |
| 269 | if (rp->info) |
| 270 | rip_request_neighbor (rp->p.u.prefix4); |
| 271 | } |
| 272 | |
| 273 | /* Multicast packet receive socket. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 274 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 275 | rip_multicast_join (struct interface *ifp, int sock) |
| 276 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 277 | struct listnode *cnode; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 278 | struct connected *ifc; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 280 | if (if_is_operative (ifp) && if_is_multicast (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 281 | { |
| 282 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 283 | zlog_debug ("multicast join at %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 284 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 285 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, ifc)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 286 | { |
| 287 | struct prefix_ipv4 *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 288 | struct in_addr group; |
| 289 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 290 | p = (struct prefix_ipv4 *) ifc->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 291 | |
| 292 | if (p->family != AF_INET) |
| 293 | continue; |
| 294 | |
| 295 | group.s_addr = htonl (INADDR_RIP_GROUP); |
| 296 | if (ipv4_multicast_join (sock, group, p->prefix, ifp->ifindex) < 0) |
| 297 | return -1; |
| 298 | else |
| 299 | return 0; |
| 300 | } |
| 301 | } |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | /* Leave from multicast group. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 306 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 307 | rip_multicast_leave (struct interface *ifp, int sock) |
| 308 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 309 | struct listnode *cnode; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 310 | struct connected *connected; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 311 | |
| 312 | if (if_is_up (ifp) && if_is_multicast (ifp)) |
| 313 | { |
| 314 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 315 | zlog_debug ("multicast leave from %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 316 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 317 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 318 | { |
| 319 | struct prefix_ipv4 *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 320 | struct in_addr group; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 321 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 322 | p = (struct prefix_ipv4 *) connected->address; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 323 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 324 | if (p->family != AF_INET) |
| 325 | continue; |
| 326 | |
| 327 | group.s_addr = htonl (INADDR_RIP_GROUP); |
| 328 | if (ipv4_multicast_leave (sock, group, p->prefix, ifp->ifindex) == 0) |
| 329 | return; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | /* Is there and address on interface that I could use ? */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 335 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 336 | rip_if_ipv4_address_check (struct interface *ifp) |
| 337 | { |
| 338 | struct listnode *nn; |
| 339 | struct connected *connected; |
| 340 | int count = 0; |
| 341 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 342 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, connected)) |
| 343 | { |
| 344 | struct prefix *p; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 346 | p = connected->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 348 | if (p->family == AF_INET) |
| 349 | count++; |
| 350 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 351 | |
| 352 | return count; |
| 353 | } |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | /* Does this address belongs to me ? */ |
| 359 | int |
| 360 | if_check_address (struct in_addr addr) |
| 361 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 362 | struct listnode *node; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 363 | struct interface *ifp; |
| 364 | |
| 365 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 366 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 367 | struct listnode *cnode; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 368 | struct connected *connected; |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 369 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 370 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected)) |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 371 | { |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 372 | struct prefix_ipv4 *p; |
| 373 | |
paul | 31a476c | 2003-09-29 19:54:53 +0000 | [diff] [blame] | 374 | p = (struct prefix_ipv4 *) connected->address; |
| 375 | |
| 376 | if (p->family != AF_INET) |
| 377 | continue; |
| 378 | |
| 379 | if (IPV4_ADDR_CMP (&p->prefix, &addr) == 0) |
| 380 | return 1; |
| 381 | } |
| 382 | } |
| 383 | return 0; |
| 384 | } |
| 385 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 386 | /* Inteface link down message processing. */ |
| 387 | int |
| 388 | rip_interface_down (int command, struct zclient *zclient, zebra_size_t length) |
| 389 | { |
| 390 | struct interface *ifp; |
| 391 | struct stream *s; |
| 392 | |
| 393 | s = zclient->ibuf; |
| 394 | |
| 395 | /* zebra_interface_state_read() updates interface structure in |
| 396 | iflist. */ |
| 397 | ifp = zebra_interface_state_read(s); |
| 398 | |
| 399 | if (ifp == NULL) |
| 400 | return 0; |
| 401 | |
| 402 | rip_if_down(ifp); |
| 403 | |
| 404 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 405 | zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is down", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 406 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 407 | |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* Inteface link up message processing */ |
| 412 | int |
| 413 | rip_interface_up (int command, struct zclient *zclient, zebra_size_t length) |
| 414 | { |
| 415 | struct interface *ifp; |
| 416 | |
| 417 | /* zebra_interface_state_read () updates interface structure in |
| 418 | iflist. */ |
| 419 | ifp = zebra_interface_state_read (zclient->ibuf); |
| 420 | |
| 421 | if (ifp == NULL) |
| 422 | return 0; |
| 423 | |
| 424 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 425 | zlog_debug ("interface %s index %d flags %ld metric %d mtu %d is up", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 427 | |
| 428 | /* Check if this interface is RIP enabled or not.*/ |
| 429 | rip_enable_apply (ifp); |
| 430 | |
| 431 | /* Check for a passive interface */ |
| 432 | rip_passive_interface_apply (ifp); |
| 433 | |
| 434 | /* Apply distribute list to the all interface. */ |
| 435 | rip_distribute_update_interface (ifp); |
| 436 | |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | /* Inteface addition message from zebra. */ |
| 441 | int |
| 442 | rip_interface_add (int command, struct zclient *zclient, zebra_size_t length) |
| 443 | { |
| 444 | struct interface *ifp; |
| 445 | |
| 446 | ifp = zebra_interface_add_read (zclient->ibuf); |
| 447 | |
| 448 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 449 | zlog_debug ("interface add %s index %d flags %ld metric %d mtu %d", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 450 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 451 | |
| 452 | /* Check if this interface is RIP enabled or not.*/ |
| 453 | rip_enable_apply (ifp); |
ajs | d4e4728 | 2005-05-11 15:56:21 +0000 | [diff] [blame] | 454 | |
| 455 | /* Check for a passive interface */ |
| 456 | rip_passive_interface_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 457 | |
| 458 | /* Apply distribute list to the all interface. */ |
| 459 | rip_distribute_update_interface (ifp); |
| 460 | |
| 461 | /* rip_request_neighbor_all (); */ |
| 462 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 463 | /* Check interface routemap. */ |
| 464 | rip_if_rmap_update_interface (ifp); |
| 465 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | int |
| 470 | rip_interface_delete (int command, struct zclient *zclient, |
| 471 | zebra_size_t length) |
| 472 | { |
| 473 | struct interface *ifp; |
| 474 | struct stream *s; |
| 475 | |
| 476 | |
| 477 | s = zclient->ibuf; |
| 478 | /* zebra_interface_state_read() updates interface structure in iflist */ |
| 479 | ifp = zebra_interface_state_read(s); |
| 480 | |
| 481 | if (ifp == NULL) |
| 482 | return 0; |
| 483 | |
| 484 | if (if_is_up (ifp)) { |
| 485 | rip_if_down(ifp); |
| 486 | } |
| 487 | |
| 488 | zlog_info("interface delete %s index %d flags %ld metric %d mtu %d", |
| 489 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
| 490 | |
| 491 | /* To support pseudo interface do not free interface structure. */ |
| 492 | /* if_delete(ifp); */ |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 493 | ifp->ifindex = IFINDEX_INTERNAL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 494 | |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | void |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 499 | rip_interface_clean (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 500 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 501 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 502 | struct interface *ifp; |
| 503 | struct rip_interface *ri; |
| 504 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 505 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 506 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 507 | ri = ifp->info; |
| 508 | |
| 509 | ri->enable_network = 0; |
| 510 | ri->enable_interface = 0; |
| 511 | ri->running = 0; |
| 512 | |
| 513 | if (ri->t_wakeup) |
| 514 | { |
| 515 | thread_cancel (ri->t_wakeup); |
| 516 | ri->t_wakeup = NULL; |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | void |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 522 | rip_interface_reset (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 524 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 525 | struct interface *ifp; |
| 526 | struct rip_interface *ri; |
| 527 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 528 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 529 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 530 | ri = ifp->info; |
| 531 | |
| 532 | ri->enable_network = 0; |
| 533 | ri->enable_interface = 0; |
| 534 | ri->running = 0; |
| 535 | |
| 536 | ri->ri_send = RI_RIP_UNSPEC; |
| 537 | ri->ri_receive = RI_RIP_UNSPEC; |
| 538 | |
paul | 7755a8c | 2005-06-02 08:20:53 +0000 | [diff] [blame] | 539 | ri->auth_type = RIP_NO_AUTH; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 540 | |
| 541 | if (ri->auth_str) |
| 542 | { |
| 543 | free (ri->auth_str); |
| 544 | ri->auth_str = NULL; |
| 545 | } |
| 546 | if (ri->key_chain) |
| 547 | { |
| 548 | free (ri->key_chain); |
| 549 | ri->key_chain = NULL; |
| 550 | } |
| 551 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 552 | ri->split_horizon = RIP_NO_SPLIT_HORIZON; |
| 553 | ri->split_horizon_default = RIP_NO_SPLIT_HORIZON; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 554 | |
| 555 | ri->list[RIP_FILTER_IN] = NULL; |
| 556 | ri->list[RIP_FILTER_OUT] = NULL; |
| 557 | |
| 558 | ri->prefix[RIP_FILTER_IN] = NULL; |
| 559 | ri->prefix[RIP_FILTER_OUT] = NULL; |
| 560 | |
| 561 | if (ri->t_wakeup) |
| 562 | { |
| 563 | thread_cancel (ri->t_wakeup); |
| 564 | ri->t_wakeup = NULL; |
| 565 | } |
| 566 | |
| 567 | ri->recv_badpackets = 0; |
| 568 | ri->recv_badroutes = 0; |
| 569 | ri->sent_updates = 0; |
| 570 | |
| 571 | ri->passive = 0; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | int |
| 576 | rip_if_down(struct interface *ifp) |
| 577 | { |
| 578 | struct route_node *rp; |
| 579 | struct rip_info *rinfo; |
| 580 | struct rip_interface *ri = NULL; |
| 581 | if (rip) |
| 582 | { |
| 583 | for (rp = route_top (rip->table); rp; rp = route_next (rp)) |
| 584 | if ((rinfo = rp->info) != NULL) |
| 585 | { |
| 586 | /* Routes got through this interface. */ |
| 587 | if (rinfo->ifindex == ifp->ifindex && |
| 588 | rinfo->type == ZEBRA_ROUTE_RIP && |
| 589 | rinfo->sub_type == RIP_ROUTE_RTE) |
| 590 | { |
| 591 | rip_zebra_ipv4_delete ((struct prefix_ipv4 *) &rp->p, |
| 592 | &rinfo->nexthop, |
Krisztian Kovacs | c5a89ff | 2009-06-02 18:09:48 +0100 | [diff] [blame] | 593 | rinfo->metric); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 594 | |
| 595 | rip_redistribute_delete (rinfo->type,rinfo->sub_type, |
| 596 | (struct prefix_ipv4 *)&rp->p, |
| 597 | rinfo->ifindex); |
| 598 | } |
| 599 | else |
| 600 | { |
| 601 | /* All redistributed routes but static and system */ |
| 602 | if ((rinfo->ifindex == ifp->ifindex) && |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 603 | /* (rinfo->type != ZEBRA_ROUTE_STATIC) && */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | (rinfo->type != ZEBRA_ROUTE_SYSTEM)) |
| 605 | rip_redistribute_delete (rinfo->type,rinfo->sub_type, |
| 606 | (struct prefix_ipv4 *)&rp->p, |
| 607 | rinfo->ifindex); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | ri = ifp->info; |
| 613 | |
| 614 | if (ri->running) |
| 615 | { |
| 616 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 617 | zlog_debug ("turn off %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 618 | |
| 619 | /* Leave from multicast group. */ |
| 620 | rip_multicast_leave (ifp, rip->sock); |
| 621 | |
| 622 | ri->running = 0; |
| 623 | } |
| 624 | |
| 625 | return 0; |
| 626 | } |
| 627 | |
| 628 | /* Needed for stop RIP process. */ |
| 629 | void |
| 630 | rip_if_down_all () |
| 631 | { |
| 632 | struct interface *ifp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 633 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 634 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 635 | for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) |
| 636 | rip_if_down (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 637 | } |
| 638 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 639 | static void |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 640 | rip_apply_address_add (struct connected *ifc) |
| 641 | { |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 642 | struct prefix_ipv4 address; |
| 643 | struct prefix *p; |
| 644 | |
| 645 | if (!rip) |
| 646 | return; |
| 647 | |
| 648 | if (! if_is_up(ifc->ifp)) |
| 649 | return; |
| 650 | |
| 651 | p = ifc->address; |
| 652 | |
| 653 | memset (&address, 0, sizeof (address)); |
| 654 | address.family = p->family; |
| 655 | address.prefix = p->u.prefix4; |
| 656 | address.prefixlen = p->prefixlen; |
| 657 | apply_mask_ipv4(&address); |
| 658 | |
| 659 | /* Check if this interface is RIP enabled or not |
| 660 | or Check if this address's prefix is RIP enabled */ |
| 661 | if ((rip_enable_if_lookup(ifc->ifp->name) >= 0) || |
| 662 | (rip_enable_network_lookup2(ifc) >= 0)) |
| 663 | rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, |
vincent | fbf5d03 | 2005-09-29 11:25:50 +0000 | [diff] [blame] | 664 | &address, ifc->ifp->ifindex, NULL, 0, 0); |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 665 | |
| 666 | } |
| 667 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 668 | int |
| 669 | rip_interface_address_add (int command, struct zclient *zclient, |
| 670 | zebra_size_t length) |
| 671 | { |
| 672 | struct connected *ifc; |
| 673 | struct prefix *p; |
| 674 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 675 | ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, |
| 676 | zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 677 | |
| 678 | if (ifc == NULL) |
| 679 | return 0; |
| 680 | |
| 681 | p = ifc->address; |
| 682 | |
| 683 | if (p->family == AF_INET) |
| 684 | { |
| 685 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 686 | zlog_debug ("connected address %s/%d is added", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 687 | inet_ntoa (p->u.prefix4), p->prefixlen); |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 688 | |
paul | 878ef2e | 2003-09-23 23:41:50 +0000 | [diff] [blame] | 689 | rip_enable_apply(ifc->ifp); |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 690 | /* Check if this prefix needs to be redistributed */ |
| 691 | rip_apply_address_add(ifc); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 692 | |
| 693 | #ifdef HAVE_SNMP |
| 694 | rip_ifaddr_add (ifc->ifp, ifc); |
| 695 | #endif /* HAVE_SNMP */ |
| 696 | } |
| 697 | |
| 698 | return 0; |
| 699 | } |
| 700 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 701 | static void |
| 702 | rip_apply_address_del (struct connected *ifc) { |
| 703 | struct prefix_ipv4 address; |
| 704 | struct prefix *p; |
| 705 | |
| 706 | if (!rip) |
| 707 | return; |
| 708 | |
| 709 | if (! if_is_up(ifc->ifp)) |
| 710 | return; |
| 711 | |
| 712 | p = ifc->address; |
| 713 | |
| 714 | memset (&address, 0, sizeof (address)); |
| 715 | address.family = p->family; |
| 716 | address.prefix = p->u.prefix4; |
| 717 | address.prefixlen = p->prefixlen; |
| 718 | apply_mask_ipv4(&address); |
| 719 | |
| 720 | rip_redistribute_delete(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, |
| 721 | &address, ifc->ifp->ifindex); |
| 722 | } |
| 723 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 724 | int |
| 725 | rip_interface_address_delete (int command, struct zclient *zclient, |
| 726 | zebra_size_t length) |
| 727 | { |
| 728 | struct connected *ifc; |
| 729 | struct prefix *p; |
| 730 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 731 | ifc = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, |
| 732 | zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 733 | |
| 734 | if (ifc) |
| 735 | { |
| 736 | p = ifc->address; |
| 737 | if (p->family == AF_INET) |
| 738 | { |
| 739 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 740 | zlog_debug ("connected address %s/%d is deleted", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 741 | inet_ntoa (p->u.prefix4), p->prefixlen); |
| 742 | |
| 743 | #ifdef HAVE_SNMP |
| 744 | rip_ifaddr_delete (ifc->ifp, ifc); |
| 745 | #endif /* HAVE_SNMP */ |
| 746 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 747 | /* Chech wether this prefix needs to be removed */ |
| 748 | rip_apply_address_del(ifc); |
| 749 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | connected_free (ifc); |
| 753 | |
| 754 | } |
| 755 | |
| 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | /* Check interface is enabled by network statement. */ |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 760 | /* Check wether the interface has at least a connected prefix that |
| 761 | * is within the ripng_enable_network table. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 762 | static int |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 763 | rip_enable_network_lookup_if (struct interface *ifp) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 764 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 765 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 766 | struct connected *connected; |
| 767 | struct prefix_ipv4 address; |
| 768 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 769 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) |
| 770 | { |
| 771 | struct prefix *p; |
| 772 | struct route_node *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 773 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 774 | p = connected->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 775 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 776 | if (p->family == AF_INET) |
| 777 | { |
| 778 | address.family = AF_INET; |
| 779 | address.prefix = p->u.prefix4; |
| 780 | address.prefixlen = IPV4_MAX_BITLEN; |
| 781 | |
| 782 | node = route_node_match (rip_enable_network, |
| 783 | (struct prefix *)&address); |
| 784 | if (node) |
| 785 | { |
| 786 | route_unlock_node (node); |
| 787 | return 1; |
| 788 | } |
| 789 | } |
| 790 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 791 | return -1; |
| 792 | } |
| 793 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 794 | /* Check wether connected is within the ripng_enable_network table. */ |
| 795 | int |
| 796 | rip_enable_network_lookup2 (struct connected *connected) |
| 797 | { |
| 798 | struct prefix_ipv4 address; |
| 799 | struct prefix *p; |
| 800 | |
| 801 | p = connected->address; |
| 802 | |
| 803 | if (p->family == AF_INET) { |
| 804 | struct route_node *node; |
| 805 | |
| 806 | address.family = p->family; |
| 807 | address.prefix = p->u.prefix4; |
| 808 | address.prefixlen = IPV4_MAX_BITLEN; |
| 809 | |
| 810 | /* LPM on p->family, p->u.prefix4/IPV4_MAX_BITLEN within rip_enable_network */ |
| 811 | node = route_node_match (rip_enable_network, |
| 812 | (struct prefix *)&address); |
| 813 | |
| 814 | if (node) { |
| 815 | route_unlock_node (node); |
| 816 | return 1; |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | return -1; |
| 821 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 822 | /* Add RIP enable network. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 823 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 824 | rip_enable_network_add (struct prefix *p) |
| 825 | { |
| 826 | struct route_node *node; |
| 827 | |
| 828 | node = route_node_get (rip_enable_network, p); |
| 829 | |
| 830 | if (node->info) |
| 831 | { |
| 832 | route_unlock_node (node); |
| 833 | return -1; |
| 834 | } |
| 835 | else |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 836 | node->info = (char *) "enabled"; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 837 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 838 | /* XXX: One should find a better solution than a generic one */ |
| 839 | rip_enable_apply_all(); |
| 840 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 841 | return 1; |
| 842 | } |
| 843 | |
| 844 | /* Delete RIP enable network. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 845 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 846 | rip_enable_network_delete (struct prefix *p) |
| 847 | { |
| 848 | struct route_node *node; |
| 849 | |
| 850 | node = route_node_lookup (rip_enable_network, p); |
| 851 | if (node) |
| 852 | { |
| 853 | node->info = NULL; |
| 854 | |
| 855 | /* Unlock info lock. */ |
| 856 | route_unlock_node (node); |
| 857 | |
| 858 | /* Unlock lookup lock. */ |
| 859 | route_unlock_node (node); |
| 860 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 861 | /* XXX: One should find a better solution than a generic one */ |
| 862 | rip_enable_apply_all (); |
| 863 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 864 | return 1; |
| 865 | } |
| 866 | return -1; |
| 867 | } |
| 868 | |
| 869 | /* Check interface is enabled by ifname statement. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 870 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 871 | rip_enable_if_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 872 | { |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 873 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | char *str; |
| 875 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 876 | for (i = 0; i < vector_active (rip_enable_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | if ((str = vector_slot (rip_enable_interface, i)) != NULL) |
| 878 | if (strcmp (str, ifname) == 0) |
| 879 | return i; |
| 880 | return -1; |
| 881 | } |
| 882 | |
| 883 | /* Add interface to rip_enable_if. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 884 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 885 | rip_enable_if_add (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 886 | { |
| 887 | int ret; |
| 888 | |
| 889 | ret = rip_enable_if_lookup (ifname); |
| 890 | if (ret >= 0) |
| 891 | return -1; |
| 892 | |
| 893 | vector_set (rip_enable_interface, strdup (ifname)); |
| 894 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 895 | rip_enable_apply_all(); /* TODOVJ */ |
| 896 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 897 | return 1; |
| 898 | } |
| 899 | |
| 900 | /* Delete interface from rip_enable_if. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 901 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 902 | rip_enable_if_delete (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 903 | { |
| 904 | int index; |
| 905 | char *str; |
| 906 | |
| 907 | index = rip_enable_if_lookup (ifname); |
| 908 | if (index < 0) |
| 909 | return -1; |
| 910 | |
| 911 | str = vector_slot (rip_enable_interface, index); |
| 912 | free (str); |
| 913 | vector_unset (rip_enable_interface, index); |
| 914 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 915 | rip_enable_apply_all(); /* TODOVJ */ |
| 916 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | return 1; |
| 918 | } |
| 919 | |
| 920 | /* Join to multicast group and send request to the interface. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 921 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 922 | rip_interface_wakeup (struct thread *t) |
| 923 | { |
| 924 | struct interface *ifp; |
| 925 | struct rip_interface *ri; |
| 926 | |
| 927 | /* Get interface. */ |
| 928 | ifp = THREAD_ARG (t); |
| 929 | |
| 930 | ri = ifp->info; |
| 931 | ri->t_wakeup = NULL; |
| 932 | |
| 933 | /* Join to multicast group. */ |
| 934 | if (rip_multicast_join (ifp, rip->sock) < 0) |
| 935 | { |
| 936 | zlog_err ("multicast join failed, interface %s not running", ifp->name); |
| 937 | return 0; |
| 938 | } |
| 939 | |
| 940 | /* Set running flag. */ |
| 941 | ri->running = 1; |
| 942 | |
| 943 | /* Send RIP request to the interface. */ |
| 944 | rip_request_interface (ifp); |
| 945 | |
| 946 | return 0; |
| 947 | } |
| 948 | |
| 949 | int rip_redistribute_check (int); |
| 950 | |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 951 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | rip_connect_set (struct interface *ifp, int set) |
| 953 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 954 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 955 | struct connected *connected; |
| 956 | struct prefix_ipv4 address; |
| 957 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 958 | for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, connected)) |
| 959 | { |
| 960 | struct prefix *p; |
| 961 | p = connected->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 962 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 963 | if (p->family != AF_INET) |
| 964 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 965 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 966 | address.family = AF_INET; |
| 967 | address.prefix = p->u.prefix4; |
| 968 | address.prefixlen = p->prefixlen; |
| 969 | apply_mask_ipv4 (&address); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 970 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 971 | if (set) { |
| 972 | /* Check once more wether this prefix is within a "network IF_OR_PREF" one */ |
| 973 | if ((rip_enable_if_lookup(connected->ifp->name) >= 0) || |
| 974 | (rip_enable_network_lookup2(connected) >= 0)) |
| 975 | rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, |
vincent | fbf5d03 | 2005-09-29 11:25:50 +0000 | [diff] [blame] | 976 | &address, connected->ifp->ifindex, |
| 977 | NULL, 0, 0); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 978 | } else |
| 979 | { |
| 980 | rip_redistribute_delete (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE, |
| 981 | &address, connected->ifp->ifindex); |
| 982 | if (rip_redistribute_check (ZEBRA_ROUTE_CONNECT)) |
| 983 | rip_redistribute_add (ZEBRA_ROUTE_CONNECT, RIP_ROUTE_REDISTRIBUTE, |
vincent | fbf5d03 | 2005-09-29 11:25:50 +0000 | [diff] [blame] | 984 | &address, connected->ifp->ifindex, |
| 985 | NULL, 0, 0); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 986 | } |
| 987 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | /* Update interface status. */ |
| 991 | void |
| 992 | rip_enable_apply (struct interface *ifp) |
| 993 | { |
| 994 | int ret; |
| 995 | struct rip_interface *ri = NULL; |
| 996 | |
| 997 | /* Check interface. */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 998 | if (! if_is_operative (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 999 | return; |
| 1000 | |
| 1001 | ri = ifp->info; |
| 1002 | |
| 1003 | /* Check network configuration. */ |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1004 | ret = rip_enable_network_lookup_if (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | |
| 1006 | /* If the interface is matched. */ |
| 1007 | if (ret > 0) |
| 1008 | ri->enable_network = 1; |
| 1009 | else |
| 1010 | ri->enable_network = 0; |
| 1011 | |
| 1012 | /* Check interface name configuration. */ |
| 1013 | ret = rip_enable_if_lookup (ifp->name); |
| 1014 | if (ret >= 0) |
| 1015 | ri->enable_interface = 1; |
| 1016 | else |
| 1017 | ri->enable_interface = 0; |
| 1018 | |
| 1019 | /* any interface MUST have an IPv4 address */ |
| 1020 | if ( ! rip_if_ipv4_address_check (ifp) ) |
| 1021 | { |
| 1022 | ri->enable_network = 0; |
| 1023 | ri->enable_interface = 0; |
| 1024 | } |
| 1025 | |
| 1026 | /* Update running status of the interface. */ |
| 1027 | if (ri->enable_network || ri->enable_interface) |
| 1028 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1029 | { |
| 1030 | if (IS_RIP_DEBUG_EVENT) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 1031 | zlog_debug ("turn on %s", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1032 | |
| 1033 | /* Add interface wake up thread. */ |
| 1034 | if (! ri->t_wakeup) |
| 1035 | ri->t_wakeup = thread_add_timer (master, rip_interface_wakeup, |
| 1036 | ifp, 1); |
| 1037 | rip_connect_set (ifp, 1); |
| 1038 | } |
| 1039 | } |
| 1040 | else |
| 1041 | { |
| 1042 | if (ri->running) |
| 1043 | { |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1044 | /* Might as well clean up the route table as well |
| 1045 | * rip_if_down sets to 0 ri->running, and displays "turn off %s" |
| 1046 | **/ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1047 | rip_if_down(ifp); |
| 1048 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1049 | rip_connect_set (ifp, 0); |
| 1050 | } |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | /* Apply network configuration to all interface. */ |
| 1055 | void |
| 1056 | rip_enable_apply_all () |
| 1057 | { |
| 1058 | struct interface *ifp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1059 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1060 | |
| 1061 | /* Check each interface. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1062 | for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) |
| 1063 | rip_enable_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | int |
| 1067 | rip_neighbor_lookup (struct sockaddr_in *from) |
| 1068 | { |
| 1069 | struct prefix_ipv4 p; |
| 1070 | struct route_node *node; |
| 1071 | |
| 1072 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 1073 | p.family = AF_INET; |
| 1074 | p.prefix = from->sin_addr; |
| 1075 | p.prefixlen = IPV4_MAX_BITLEN; |
| 1076 | |
| 1077 | node = route_node_lookup (rip->neighbor, (struct prefix *) &p); |
| 1078 | if (node) |
| 1079 | { |
| 1080 | route_unlock_node (node); |
| 1081 | return 1; |
| 1082 | } |
| 1083 | return 0; |
| 1084 | } |
| 1085 | |
| 1086 | /* Add new RIP neighbor to the neighbor tree. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1087 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1088 | rip_neighbor_add (struct prefix_ipv4 *p) |
| 1089 | { |
| 1090 | struct route_node *node; |
| 1091 | |
| 1092 | node = route_node_get (rip->neighbor, (struct prefix *) p); |
| 1093 | |
| 1094 | if (node->info) |
| 1095 | return -1; |
| 1096 | |
| 1097 | node->info = rip->neighbor; |
| 1098 | |
| 1099 | return 0; |
| 1100 | } |
| 1101 | |
| 1102 | /* Delete RIP neighbor from the neighbor tree. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1103 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | rip_neighbor_delete (struct prefix_ipv4 *p) |
| 1105 | { |
| 1106 | struct route_node *node; |
| 1107 | |
| 1108 | /* Lock for look up. */ |
| 1109 | node = route_node_lookup (rip->neighbor, (struct prefix *) p); |
| 1110 | if (! node) |
| 1111 | return -1; |
| 1112 | |
| 1113 | node->info = NULL; |
| 1114 | |
| 1115 | /* Unlock lookup lock. */ |
| 1116 | route_unlock_node (node); |
| 1117 | |
| 1118 | /* Unlock real neighbor information lock. */ |
| 1119 | route_unlock_node (node); |
| 1120 | |
| 1121 | return 0; |
| 1122 | } |
| 1123 | |
| 1124 | /* Clear all network and neighbor configuration. */ |
| 1125 | void |
| 1126 | rip_clean_network () |
| 1127 | { |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 1128 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1129 | char *str; |
| 1130 | struct route_node *rn; |
| 1131 | |
| 1132 | /* rip_enable_network. */ |
| 1133 | for (rn = route_top (rip_enable_network); rn; rn = route_next (rn)) |
| 1134 | if (rn->info) |
| 1135 | { |
| 1136 | rn->info = NULL; |
| 1137 | route_unlock_node (rn); |
| 1138 | } |
| 1139 | |
| 1140 | /* rip_enable_interface. */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 1141 | for (i = 0; i < vector_active (rip_enable_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1142 | if ((str = vector_slot (rip_enable_interface, i)) != NULL) |
| 1143 | { |
| 1144 | free (str); |
| 1145 | vector_slot (rip_enable_interface, i) = NULL; |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | /* Utility function for looking up passive interface settings. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1150 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 1151 | rip_passive_nondefault_lookup (const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1152 | { |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 1153 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1154 | char *str; |
| 1155 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 1156 | for (i = 0; i < vector_active (Vrip_passive_nondefault); i++) |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1157 | if ((str = vector_slot (Vrip_passive_nondefault, i)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1158 | if (strcmp (str, ifname) == 0) |
| 1159 | return i; |
| 1160 | return -1; |
| 1161 | } |
| 1162 | |
| 1163 | void |
| 1164 | rip_passive_interface_apply (struct interface *ifp) |
| 1165 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1166 | struct rip_interface *ri; |
| 1167 | |
| 1168 | ri = ifp->info; |
| 1169 | |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1170 | ri->passive = ((rip_passive_nondefault_lookup (ifp->name) < 0) ? |
| 1171 | passive_default : !passive_default); |
| 1172 | |
| 1173 | if (IS_RIP_DEBUG_ZEBRA) |
ajs | 5d6c377 | 2004-12-08 19:24:06 +0000 | [diff] [blame] | 1174 | zlog_debug ("interface %s: passive = %d",ifp->name,ri->passive); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1175 | } |
| 1176 | |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1177 | static void |
| 1178 | rip_passive_interface_apply_all (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1179 | { |
| 1180 | struct interface *ifp; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1181 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1182 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1183 | for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) |
| 1184 | rip_passive_interface_apply (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | /* Passive interface. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1188 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 1189 | rip_passive_nondefault_set (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1190 | { |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1191 | if (rip_passive_nondefault_lookup (ifname) >= 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1192 | return CMD_WARNING; |
| 1193 | |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1194 | vector_set (Vrip_passive_nondefault, strdup (ifname)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1195 | |
| 1196 | rip_passive_interface_apply_all (); |
| 1197 | |
| 1198 | return CMD_SUCCESS; |
| 1199 | } |
| 1200 | |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1201 | static int |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 1202 | rip_passive_nondefault_unset (struct vty *vty, const char *ifname) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1203 | { |
| 1204 | int i; |
| 1205 | char *str; |
| 1206 | |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1207 | i = rip_passive_nondefault_lookup (ifname); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1208 | if (i < 0) |
| 1209 | return CMD_WARNING; |
| 1210 | |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1211 | str = vector_slot (Vrip_passive_nondefault, i); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1212 | free (str); |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1213 | vector_unset (Vrip_passive_nondefault, i); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | |
| 1215 | rip_passive_interface_apply_all (); |
| 1216 | |
| 1217 | return CMD_SUCCESS; |
| 1218 | } |
| 1219 | |
| 1220 | /* Free all configured RIP passive-interface settings. */ |
| 1221 | void |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1222 | rip_passive_nondefault_clean (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1223 | { |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 1224 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1225 | char *str; |
| 1226 | |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 1227 | for (i = 0; i < vector_active (Vrip_passive_nondefault); i++) |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1228 | if ((str = vector_slot (Vrip_passive_nondefault, i)) != NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1229 | { |
| 1230 | free (str); |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1231 | vector_slot (Vrip_passive_nondefault, i) = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1232 | } |
| 1233 | rip_passive_interface_apply_all (); |
| 1234 | } |
| 1235 | |
| 1236 | /* RIP enable network or interface configuration. */ |
| 1237 | DEFUN (rip_network, |
| 1238 | rip_network_cmd, |
| 1239 | "network (A.B.C.D/M|WORD)", |
| 1240 | "Enable routing on an IP network\n" |
| 1241 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1242 | "Interface name\n") |
| 1243 | { |
| 1244 | int ret; |
| 1245 | struct prefix_ipv4 p; |
| 1246 | |
| 1247 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1248 | |
| 1249 | if (ret) |
| 1250 | ret = rip_enable_network_add ((struct prefix *) &p); |
| 1251 | else |
| 1252 | ret = rip_enable_if_add (argv[0]); |
| 1253 | |
| 1254 | if (ret < 0) |
| 1255 | { |
| 1256 | vty_out (vty, "There is a same network configuration %s%s", argv[0], |
| 1257 | VTY_NEWLINE); |
| 1258 | return CMD_WARNING; |
| 1259 | } |
| 1260 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1261 | return CMD_SUCCESS; |
| 1262 | } |
| 1263 | |
| 1264 | /* RIP enable network or interface configuration. */ |
| 1265 | DEFUN (no_rip_network, |
| 1266 | no_rip_network_cmd, |
| 1267 | "no network (A.B.C.D/M|WORD)", |
| 1268 | NO_STR |
| 1269 | "Enable routing on an IP network\n" |
| 1270 | "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n" |
| 1271 | "Interface name\n") |
| 1272 | { |
| 1273 | int ret; |
| 1274 | struct prefix_ipv4 p; |
| 1275 | |
| 1276 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1277 | |
| 1278 | if (ret) |
| 1279 | ret = rip_enable_network_delete ((struct prefix *) &p); |
| 1280 | else |
| 1281 | ret = rip_enable_if_delete (argv[0]); |
| 1282 | |
| 1283 | if (ret < 0) |
| 1284 | { |
| 1285 | vty_out (vty, "Can't find network configuration %s%s", argv[0], |
| 1286 | VTY_NEWLINE); |
| 1287 | return CMD_WARNING; |
| 1288 | } |
| 1289 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1290 | return CMD_SUCCESS; |
| 1291 | } |
| 1292 | |
| 1293 | /* RIP neighbor configuration set. */ |
| 1294 | DEFUN (rip_neighbor, |
| 1295 | rip_neighbor_cmd, |
| 1296 | "neighbor A.B.C.D", |
| 1297 | "Specify a neighbor router\n" |
| 1298 | "Neighbor address\n") |
| 1299 | { |
| 1300 | int ret; |
| 1301 | struct prefix_ipv4 p; |
| 1302 | |
| 1303 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1304 | |
| 1305 | if (ret <= 0) |
| 1306 | { |
| 1307 | vty_out (vty, "Please specify address by A.B.C.D%s", VTY_NEWLINE); |
| 1308 | return CMD_WARNING; |
| 1309 | } |
| 1310 | |
| 1311 | rip_neighbor_add (&p); |
| 1312 | |
| 1313 | return CMD_SUCCESS; |
| 1314 | } |
| 1315 | |
| 1316 | /* RIP neighbor configuration unset. */ |
| 1317 | DEFUN (no_rip_neighbor, |
| 1318 | no_rip_neighbor_cmd, |
| 1319 | "no neighbor A.B.C.D", |
| 1320 | NO_STR |
| 1321 | "Specify a neighbor router\n" |
| 1322 | "Neighbor address\n") |
| 1323 | { |
| 1324 | int ret; |
| 1325 | struct prefix_ipv4 p; |
| 1326 | |
| 1327 | ret = str2prefix_ipv4 (argv[0], &p); |
| 1328 | |
| 1329 | if (ret <= 0) |
| 1330 | { |
| 1331 | vty_out (vty, "Please specify address by A.B.C.D%s", VTY_NEWLINE); |
| 1332 | return CMD_WARNING; |
| 1333 | } |
| 1334 | |
| 1335 | rip_neighbor_delete (&p); |
| 1336 | |
| 1337 | return CMD_SUCCESS; |
| 1338 | } |
| 1339 | |
| 1340 | DEFUN (ip_rip_receive_version, |
| 1341 | ip_rip_receive_version_cmd, |
| 1342 | "ip rip receive version (1|2)", |
| 1343 | IP_STR |
| 1344 | "Routing Information Protocol\n" |
| 1345 | "Advertisement reception\n" |
| 1346 | "Version control\n" |
| 1347 | "RIP version 1\n" |
| 1348 | "RIP version 2\n") |
| 1349 | { |
| 1350 | struct interface *ifp; |
| 1351 | struct rip_interface *ri; |
| 1352 | |
| 1353 | ifp = (struct interface *)vty->index; |
| 1354 | ri = ifp->info; |
| 1355 | |
| 1356 | /* Version 1. */ |
| 1357 | if (atoi (argv[0]) == 1) |
| 1358 | { |
| 1359 | ri->ri_receive = RI_RIP_VERSION_1; |
| 1360 | return CMD_SUCCESS; |
| 1361 | } |
| 1362 | if (atoi (argv[0]) == 2) |
| 1363 | { |
| 1364 | ri->ri_receive = RI_RIP_VERSION_2; |
| 1365 | return CMD_SUCCESS; |
| 1366 | } |
| 1367 | return CMD_WARNING; |
| 1368 | } |
| 1369 | |
| 1370 | DEFUN (ip_rip_receive_version_1, |
| 1371 | ip_rip_receive_version_1_cmd, |
| 1372 | "ip rip receive version 1 2", |
| 1373 | IP_STR |
| 1374 | "Routing Information Protocol\n" |
| 1375 | "Advertisement reception\n" |
| 1376 | "Version control\n" |
| 1377 | "RIP version 1\n" |
| 1378 | "RIP version 2\n") |
| 1379 | { |
| 1380 | struct interface *ifp; |
| 1381 | struct rip_interface *ri; |
| 1382 | |
| 1383 | ifp = (struct interface *)vty->index; |
| 1384 | ri = ifp->info; |
| 1385 | |
| 1386 | /* Version 1 and 2. */ |
| 1387 | ri->ri_receive = RI_RIP_VERSION_1_AND_2; |
| 1388 | return CMD_SUCCESS; |
| 1389 | } |
| 1390 | |
| 1391 | DEFUN (ip_rip_receive_version_2, |
| 1392 | ip_rip_receive_version_2_cmd, |
| 1393 | "ip rip receive version 2 1", |
| 1394 | IP_STR |
| 1395 | "Routing Information Protocol\n" |
| 1396 | "Advertisement reception\n" |
| 1397 | "Version control\n" |
| 1398 | "RIP version 2\n" |
| 1399 | "RIP version 1\n") |
| 1400 | { |
| 1401 | struct interface *ifp; |
| 1402 | struct rip_interface *ri; |
| 1403 | |
| 1404 | ifp = (struct interface *)vty->index; |
| 1405 | ri = ifp->info; |
| 1406 | |
| 1407 | /* Version 1 and 2. */ |
| 1408 | ri->ri_receive = RI_RIP_VERSION_1_AND_2; |
| 1409 | return CMD_SUCCESS; |
| 1410 | } |
| 1411 | |
| 1412 | DEFUN (no_ip_rip_receive_version, |
| 1413 | no_ip_rip_receive_version_cmd, |
| 1414 | "no ip rip receive version", |
| 1415 | NO_STR |
| 1416 | IP_STR |
| 1417 | "Routing Information Protocol\n" |
| 1418 | "Advertisement reception\n" |
| 1419 | "Version control\n") |
| 1420 | { |
| 1421 | struct interface *ifp; |
| 1422 | struct rip_interface *ri; |
| 1423 | |
| 1424 | ifp = (struct interface *)vty->index; |
| 1425 | ri = ifp->info; |
| 1426 | |
| 1427 | ri->ri_receive = RI_RIP_UNSPEC; |
| 1428 | return CMD_SUCCESS; |
| 1429 | } |
| 1430 | |
| 1431 | ALIAS (no_ip_rip_receive_version, |
| 1432 | no_ip_rip_receive_version_num_cmd, |
| 1433 | "no ip rip receive version (1|2)", |
| 1434 | NO_STR |
| 1435 | IP_STR |
| 1436 | "Routing Information Protocol\n" |
| 1437 | "Advertisement reception\n" |
| 1438 | "Version control\n" |
| 1439 | "Version 1\n" |
| 1440 | "Version 2\n") |
| 1441 | |
| 1442 | DEFUN (ip_rip_send_version, |
| 1443 | ip_rip_send_version_cmd, |
| 1444 | "ip rip send version (1|2)", |
| 1445 | IP_STR |
| 1446 | "Routing Information Protocol\n" |
| 1447 | "Advertisement transmission\n" |
| 1448 | "Version control\n" |
| 1449 | "RIP version 1\n" |
| 1450 | "RIP version 2\n") |
| 1451 | { |
| 1452 | struct interface *ifp; |
| 1453 | struct rip_interface *ri; |
| 1454 | |
| 1455 | ifp = (struct interface *)vty->index; |
| 1456 | ri = ifp->info; |
| 1457 | |
| 1458 | /* Version 1. */ |
| 1459 | if (atoi (argv[0]) == 1) |
| 1460 | { |
| 1461 | ri->ri_send = RI_RIP_VERSION_1; |
| 1462 | return CMD_SUCCESS; |
| 1463 | } |
| 1464 | if (atoi (argv[0]) == 2) |
| 1465 | { |
| 1466 | ri->ri_send = RI_RIP_VERSION_2; |
| 1467 | return CMD_SUCCESS; |
| 1468 | } |
| 1469 | return CMD_WARNING; |
| 1470 | } |
| 1471 | |
| 1472 | DEFUN (ip_rip_send_version_1, |
| 1473 | ip_rip_send_version_1_cmd, |
| 1474 | "ip rip send version 1 2", |
| 1475 | IP_STR |
| 1476 | "Routing Information Protocol\n" |
| 1477 | "Advertisement transmission\n" |
| 1478 | "Version control\n" |
| 1479 | "RIP version 1\n" |
| 1480 | "RIP version 2\n") |
| 1481 | { |
| 1482 | struct interface *ifp; |
| 1483 | struct rip_interface *ri; |
| 1484 | |
| 1485 | ifp = (struct interface *)vty->index; |
| 1486 | ri = ifp->info; |
| 1487 | |
| 1488 | /* Version 1 and 2. */ |
| 1489 | ri->ri_send = RI_RIP_VERSION_1_AND_2; |
| 1490 | return CMD_SUCCESS; |
| 1491 | } |
| 1492 | |
| 1493 | DEFUN (ip_rip_send_version_2, |
| 1494 | ip_rip_send_version_2_cmd, |
| 1495 | "ip rip send version 2 1", |
| 1496 | IP_STR |
| 1497 | "Routing Information Protocol\n" |
| 1498 | "Advertisement transmission\n" |
| 1499 | "Version control\n" |
| 1500 | "RIP version 2\n" |
| 1501 | "RIP version 1\n") |
| 1502 | { |
| 1503 | struct interface *ifp; |
| 1504 | struct rip_interface *ri; |
| 1505 | |
| 1506 | ifp = (struct interface *)vty->index; |
| 1507 | ri = ifp->info; |
| 1508 | |
| 1509 | /* Version 1 and 2. */ |
| 1510 | ri->ri_send = RI_RIP_VERSION_1_AND_2; |
| 1511 | return CMD_SUCCESS; |
| 1512 | } |
| 1513 | |
| 1514 | DEFUN (no_ip_rip_send_version, |
| 1515 | no_ip_rip_send_version_cmd, |
| 1516 | "no ip rip send version", |
| 1517 | NO_STR |
| 1518 | IP_STR |
| 1519 | "Routing Information Protocol\n" |
| 1520 | "Advertisement transmission\n" |
| 1521 | "Version control\n") |
| 1522 | { |
| 1523 | struct interface *ifp; |
| 1524 | struct rip_interface *ri; |
| 1525 | |
| 1526 | ifp = (struct interface *)vty->index; |
| 1527 | ri = ifp->info; |
| 1528 | |
| 1529 | ri->ri_send = RI_RIP_UNSPEC; |
| 1530 | return CMD_SUCCESS; |
| 1531 | } |
| 1532 | |
| 1533 | ALIAS (no_ip_rip_send_version, |
| 1534 | no_ip_rip_send_version_num_cmd, |
| 1535 | "no ip rip send version (1|2)", |
| 1536 | NO_STR |
| 1537 | IP_STR |
| 1538 | "Routing Information Protocol\n" |
| 1539 | "Advertisement transmission\n" |
| 1540 | "Version control\n" |
| 1541 | "Version 1\n" |
| 1542 | "Version 2\n") |
| 1543 | |
| 1544 | DEFUN (ip_rip_authentication_mode, |
| 1545 | ip_rip_authentication_mode_cmd, |
| 1546 | "ip rip authentication mode (md5|text)", |
| 1547 | IP_STR |
| 1548 | "Routing Information Protocol\n" |
| 1549 | "Authentication control\n" |
| 1550 | "Authentication mode\n" |
| 1551 | "Keyed message digest\n" |
| 1552 | "Clear text authentication\n") |
| 1553 | { |
| 1554 | struct interface *ifp; |
| 1555 | struct rip_interface *ri; |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1556 | int auth_type; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1557 | |
| 1558 | ifp = (struct interface *)vty->index; |
| 1559 | ri = ifp->info; |
| 1560 | |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1561 | if ( (argc < 1) || (argc > 2) ) |
| 1562 | { |
| 1563 | vty_out (vty, "incorrect argument count%s", VTY_NEWLINE); |
| 1564 | return CMD_WARNING; |
| 1565 | } |
| 1566 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1567 | if (strncmp ("md5", argv[0], strlen (argv[0])) == 0) |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1568 | auth_type = RIP_AUTH_MD5; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1569 | else if (strncmp ("text", argv[0], strlen (argv[0])) == 0) |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1570 | auth_type = RIP_AUTH_SIMPLE_PASSWORD; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1571 | else |
| 1572 | { |
| 1573 | vty_out (vty, "mode should be md5 or text%s", VTY_NEWLINE); |
| 1574 | return CMD_WARNING; |
| 1575 | } |
| 1576 | |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1577 | if (argc == 1) |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1578 | { |
| 1579 | ri->auth_type = auth_type; |
| 1580 | return CMD_SUCCESS; |
| 1581 | } |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1582 | |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1583 | if ( (argc == 2) && (auth_type != RIP_AUTH_MD5) ) |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1584 | { |
| 1585 | vty_out (vty, "auth length argument only valid for md5%s", VTY_NEWLINE); |
| 1586 | return CMD_WARNING; |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1587 | } |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1588 | |
| 1589 | if (strncmp ("r", argv[1], 1) == 0) |
| 1590 | ri->md5_auth_len = RIP_AUTH_MD5_SIZE; |
| 1591 | else if (strncmp ("o", argv[1], 1) == 0) |
| 1592 | ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; |
| 1593 | else |
| 1594 | return CMD_WARNING; |
Paul Jakma | 15a2b08 | 2006-05-04 07:36:34 +0000 | [diff] [blame] | 1595 | |
| 1596 | ri->auth_type = auth_type; |
| 1597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1598 | return CMD_SUCCESS; |
| 1599 | } |
| 1600 | |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1601 | ALIAS (ip_rip_authentication_mode, |
| 1602 | ip_rip_authentication_mode_authlen_cmd, |
| 1603 | "ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)", |
| 1604 | IP_STR |
| 1605 | "Routing Information Protocol\n" |
| 1606 | "Authentication control\n" |
| 1607 | "Authentication mode\n" |
| 1608 | "Keyed message digest\n" |
| 1609 | "Clear text authentication\n" |
| 1610 | "MD5 authentication data length\n" |
| 1611 | "RFC compatible\n" |
| 1612 | "Old ripd compatible\n") |
| 1613 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1614 | DEFUN (no_ip_rip_authentication_mode, |
| 1615 | no_ip_rip_authentication_mode_cmd, |
| 1616 | "no ip rip authentication mode", |
| 1617 | NO_STR |
| 1618 | IP_STR |
| 1619 | "Routing Information Protocol\n" |
| 1620 | "Authentication control\n" |
| 1621 | "Authentication mode\n") |
| 1622 | { |
| 1623 | struct interface *ifp; |
| 1624 | struct rip_interface *ri; |
| 1625 | |
| 1626 | ifp = (struct interface *)vty->index; |
| 1627 | ri = ifp->info; |
| 1628 | |
paul | 7755a8c | 2005-06-02 08:20:53 +0000 | [diff] [blame] | 1629 | ri->auth_type = RIP_NO_AUTH; |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1630 | ri->md5_auth_len = RIP_AUTH_MD5_COMPAT_SIZE; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | |
| 1632 | return CMD_SUCCESS; |
| 1633 | } |
| 1634 | |
| 1635 | ALIAS (no_ip_rip_authentication_mode, |
| 1636 | no_ip_rip_authentication_mode_type_cmd, |
| 1637 | "no ip rip authentication mode (md5|text)", |
| 1638 | NO_STR |
| 1639 | IP_STR |
| 1640 | "Routing Information Protocol\n" |
| 1641 | "Authentication control\n" |
| 1642 | "Authentication mode\n" |
| 1643 | "Keyed message digest\n" |
| 1644 | "Clear text authentication\n") |
| 1645 | |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1646 | ALIAS (no_ip_rip_authentication_mode, |
| 1647 | no_ip_rip_authentication_mode_type_authlen_cmd, |
| 1648 | "no ip rip authentication mode (md5|text) auth-length (rfc|old-ripd)", |
| 1649 | NO_STR |
| 1650 | IP_STR |
| 1651 | "Routing Information Protocol\n" |
| 1652 | "Authentication control\n" |
| 1653 | "Authentication mode\n" |
| 1654 | "Keyed message digest\n" |
| 1655 | "Clear text authentication\n" |
| 1656 | "MD5 authentication data length\n" |
| 1657 | "RFC compatible\n" |
| 1658 | "Old ripd compatible\n") |
| 1659 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1660 | DEFUN (ip_rip_authentication_string, |
| 1661 | ip_rip_authentication_string_cmd, |
| 1662 | "ip rip authentication string LINE", |
| 1663 | IP_STR |
| 1664 | "Routing Information Protocol\n" |
| 1665 | "Authentication control\n" |
| 1666 | "Authentication string\n" |
| 1667 | "Authentication string\n") |
| 1668 | { |
| 1669 | struct interface *ifp; |
| 1670 | struct rip_interface *ri; |
| 1671 | |
| 1672 | ifp = (struct interface *)vty->index; |
| 1673 | ri = ifp->info; |
| 1674 | |
| 1675 | if (strlen (argv[0]) > 16) |
| 1676 | { |
| 1677 | vty_out (vty, "%% RIPv2 authentication string must be shorter than 16%s", |
| 1678 | VTY_NEWLINE); |
| 1679 | return CMD_WARNING; |
| 1680 | } |
| 1681 | |
| 1682 | if (ri->key_chain) |
| 1683 | { |
| 1684 | vty_out (vty, "%% key-chain configuration exists%s", VTY_NEWLINE); |
| 1685 | return CMD_WARNING; |
| 1686 | } |
| 1687 | |
| 1688 | if (ri->auth_str) |
| 1689 | free (ri->auth_str); |
| 1690 | |
| 1691 | ri->auth_str = strdup (argv[0]); |
| 1692 | |
| 1693 | return CMD_SUCCESS; |
| 1694 | } |
| 1695 | |
| 1696 | DEFUN (no_ip_rip_authentication_string, |
| 1697 | no_ip_rip_authentication_string_cmd, |
| 1698 | "no ip rip authentication string", |
| 1699 | NO_STR |
| 1700 | IP_STR |
| 1701 | "Routing Information Protocol\n" |
| 1702 | "Authentication control\n" |
| 1703 | "Authentication string\n") |
| 1704 | { |
| 1705 | struct interface *ifp; |
| 1706 | struct rip_interface *ri; |
| 1707 | |
| 1708 | ifp = (struct interface *)vty->index; |
| 1709 | ri = ifp->info; |
| 1710 | |
| 1711 | if (ri->auth_str) |
| 1712 | free (ri->auth_str); |
| 1713 | |
| 1714 | ri->auth_str = NULL; |
| 1715 | |
| 1716 | return CMD_SUCCESS; |
| 1717 | } |
| 1718 | |
| 1719 | ALIAS (no_ip_rip_authentication_string, |
| 1720 | no_ip_rip_authentication_string2_cmd, |
| 1721 | "no ip rip authentication string LINE", |
| 1722 | NO_STR |
| 1723 | IP_STR |
| 1724 | "Routing Information Protocol\n" |
| 1725 | "Authentication control\n" |
| 1726 | "Authentication string\n" |
| 1727 | "Authentication string\n") |
| 1728 | |
| 1729 | DEFUN (ip_rip_authentication_key_chain, |
| 1730 | ip_rip_authentication_key_chain_cmd, |
| 1731 | "ip rip authentication key-chain LINE", |
| 1732 | IP_STR |
| 1733 | "Routing Information Protocol\n" |
| 1734 | "Authentication control\n" |
| 1735 | "Authentication key-chain\n" |
| 1736 | "name of key-chain\n") |
| 1737 | { |
| 1738 | struct interface *ifp; |
| 1739 | struct rip_interface *ri; |
| 1740 | |
| 1741 | ifp = (struct interface *) vty->index; |
| 1742 | ri = ifp->info; |
| 1743 | |
| 1744 | if (ri->auth_str) |
| 1745 | { |
| 1746 | vty_out (vty, "%% authentication string configuration exists%s", |
| 1747 | VTY_NEWLINE); |
| 1748 | return CMD_WARNING; |
| 1749 | } |
| 1750 | |
| 1751 | if (ri->key_chain) |
| 1752 | free (ri->key_chain); |
| 1753 | |
| 1754 | ri->key_chain = strdup (argv[0]); |
| 1755 | |
| 1756 | return CMD_SUCCESS; |
| 1757 | } |
| 1758 | |
| 1759 | DEFUN (no_ip_rip_authentication_key_chain, |
| 1760 | no_ip_rip_authentication_key_chain_cmd, |
| 1761 | "no ip rip authentication key-chain", |
| 1762 | NO_STR |
| 1763 | IP_STR |
| 1764 | "Routing Information Protocol\n" |
| 1765 | "Authentication control\n" |
| 1766 | "Authentication key-chain\n") |
| 1767 | { |
| 1768 | struct interface *ifp; |
| 1769 | struct rip_interface *ri; |
| 1770 | |
| 1771 | ifp = (struct interface *) vty->index; |
| 1772 | ri = ifp->info; |
| 1773 | |
| 1774 | if (ri->key_chain) |
| 1775 | free (ri->key_chain); |
| 1776 | |
| 1777 | ri->key_chain = NULL; |
| 1778 | |
| 1779 | return CMD_SUCCESS; |
| 1780 | } |
| 1781 | |
| 1782 | ALIAS (no_ip_rip_authentication_key_chain, |
| 1783 | no_ip_rip_authentication_key_chain2_cmd, |
| 1784 | "no ip rip authentication key-chain LINE", |
| 1785 | NO_STR |
| 1786 | IP_STR |
| 1787 | "Routing Information Protocol\n" |
| 1788 | "Authentication control\n" |
| 1789 | "Authentication key-chain\n" |
| 1790 | "name of key-chain\n") |
| 1791 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1792 | /* CHANGED: ip rip split-horizon |
| 1793 | Cisco and Zebra's command is |
| 1794 | ip split-horizon |
| 1795 | */ |
| 1796 | DEFUN (ip_rip_split_horizon, |
| 1797 | ip_rip_split_horizon_cmd, |
| 1798 | "ip rip split-horizon", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1799 | IP_STR |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1800 | "Routing Information Protocol\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | "Perform split horizon\n") |
| 1802 | { |
| 1803 | struct interface *ifp; |
| 1804 | struct rip_interface *ri; |
| 1805 | |
| 1806 | ifp = vty->index; |
| 1807 | ri = ifp->info; |
| 1808 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1809 | ri->split_horizon = RIP_SPLIT_HORIZON; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1810 | return CMD_SUCCESS; |
| 1811 | } |
| 1812 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1813 | DEFUN (ip_rip_split_horizon_poisoned_reverse, |
| 1814 | ip_rip_split_horizon_poisoned_reverse_cmd, |
| 1815 | "ip rip split-horizon poisoned-reverse", |
| 1816 | IP_STR |
| 1817 | "Routing Information Protocol\n" |
| 1818 | "Perform split horizon\n" |
| 1819 | "With poisoned-reverse\n") |
| 1820 | { |
| 1821 | struct interface *ifp; |
| 1822 | struct rip_interface *ri; |
| 1823 | |
| 1824 | ifp = vty->index; |
| 1825 | ri = ifp->info; |
| 1826 | |
| 1827 | ri->split_horizon = RIP_SPLIT_HORIZON_POISONED_REVERSE; |
| 1828 | return CMD_SUCCESS; |
| 1829 | } |
| 1830 | |
| 1831 | /* CHANGED: no ip rip split-horizon |
| 1832 | Cisco and Zebra's command is |
| 1833 | no ip split-horizon |
| 1834 | */ |
| 1835 | DEFUN (no_ip_rip_split_horizon, |
| 1836 | no_ip_rip_split_horizon_cmd, |
| 1837 | "no ip rip split-horizon", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1838 | NO_STR |
| 1839 | IP_STR |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1840 | "Routing Information Protocol\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1841 | "Perform split horizon\n") |
| 1842 | { |
| 1843 | struct interface *ifp; |
| 1844 | struct rip_interface *ri; |
| 1845 | |
| 1846 | ifp = vty->index; |
| 1847 | ri = ifp->info; |
| 1848 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1849 | ri->split_horizon = RIP_NO_SPLIT_HORIZON; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1850 | return CMD_SUCCESS; |
| 1851 | } |
| 1852 | |
vincent | fac3e84 | 2005-10-06 07:45:43 +0000 | [diff] [blame] | 1853 | DEFUN (no_ip_rip_split_horizon_poisoned_reverse, |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1854 | no_ip_rip_split_horizon_poisoned_reverse_cmd, |
| 1855 | "no ip rip split-horizon poisoned-reverse", |
| 1856 | NO_STR |
| 1857 | IP_STR |
| 1858 | "Routing Information Protocol\n" |
| 1859 | "Perform split horizon\n" |
| 1860 | "With poisoned-reverse\n") |
vincent | fac3e84 | 2005-10-06 07:45:43 +0000 | [diff] [blame] | 1861 | { |
| 1862 | struct interface *ifp; |
| 1863 | struct rip_interface *ri; |
| 1864 | |
| 1865 | ifp = vty->index; |
| 1866 | ri = ifp->info; |
| 1867 | |
| 1868 | switch( ri->split_horizon ) |
| 1869 | { |
| 1870 | case RIP_SPLIT_HORIZON_POISONED_REVERSE: |
| 1871 | ri->split_horizon = RIP_SPLIT_HORIZON; |
| 1872 | default: |
| 1873 | break; |
| 1874 | } |
| 1875 | |
| 1876 | return CMD_SUCCESS; |
| 1877 | } |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1878 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1879 | DEFUN (rip_passive_interface, |
| 1880 | rip_passive_interface_cmd, |
paul | 56e475c | 2003-06-20 00:23:27 +0000 | [diff] [blame] | 1881 | "passive-interface (IFNAME|default)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1882 | "Suppress routing updates on an interface\n" |
paul | 56e475c | 2003-06-20 00:23:27 +0000 | [diff] [blame] | 1883 | "Interface name\n" |
| 1884 | "default for all interfaces\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1885 | { |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 1886 | const char *ifname = argv[0]; |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1887 | |
| 1888 | if (!strcmp(ifname,"default")) { |
| 1889 | passive_default = 1; |
| 1890 | rip_passive_nondefault_clean(); |
| 1891 | return CMD_SUCCESS; |
| 1892 | } |
| 1893 | if (passive_default) |
| 1894 | return rip_passive_nondefault_unset (vty, ifname); |
| 1895 | else |
| 1896 | return rip_passive_nondefault_set (vty, ifname); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1897 | } |
| 1898 | |
| 1899 | DEFUN (no_rip_passive_interface, |
| 1900 | no_rip_passive_interface_cmd, |
paul | 56e475c | 2003-06-20 00:23:27 +0000 | [diff] [blame] | 1901 | "no passive-interface (IFNAME|default)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | NO_STR |
| 1903 | "Suppress routing updates on an interface\n" |
paul | 56e475c | 2003-06-20 00:23:27 +0000 | [diff] [blame] | 1904 | "Interface name\n" |
| 1905 | "default for all interfaces\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1906 | { |
hasso | 98b718a | 2004-10-11 12:57:57 +0000 | [diff] [blame] | 1907 | const char *ifname = argv[0]; |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 1908 | |
| 1909 | if (!strcmp(ifname,"default")) { |
| 1910 | passive_default = 0; |
| 1911 | rip_passive_nondefault_clean(); |
| 1912 | return CMD_SUCCESS; |
| 1913 | } |
| 1914 | if (passive_default) |
| 1915 | return rip_passive_nondefault_set (vty, ifname); |
| 1916 | else |
| 1917 | return rip_passive_nondefault_unset (vty, ifname); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | /* Write rip configuration of each interface. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 1921 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1922 | rip_interface_config_write (struct vty *vty) |
| 1923 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1924 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1925 | struct interface *ifp; |
| 1926 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1927 | for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1928 | { |
| 1929 | struct rip_interface *ri; |
| 1930 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1931 | ri = ifp->info; |
| 1932 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1933 | /* Do not display the interface if there is no |
| 1934 | * configuration about it. |
| 1935 | **/ |
| 1936 | if ((!ifp->desc) && |
| 1937 | (ri->split_horizon == ri->split_horizon_default) && |
| 1938 | (ri->ri_send == RI_RIP_UNSPEC) && |
| 1939 | (ri->ri_receive == RI_RIP_UNSPEC) && |
| 1940 | (ri->auth_type != RIP_AUTH_MD5) && |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1941 | (ri->md5_auth_len != RIP_AUTH_MD5_SIZE) && |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1942 | (!ri->auth_str) && |
| 1943 | (!ri->key_chain) ) |
| 1944 | continue; |
| 1945 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1946 | vty_out (vty, "interface %s%s", ifp->name, |
| 1947 | VTY_NEWLINE); |
| 1948 | |
| 1949 | if (ifp->desc) |
| 1950 | vty_out (vty, " description %s%s", ifp->desc, |
| 1951 | VTY_NEWLINE); |
| 1952 | |
| 1953 | /* Split horizon. */ |
| 1954 | if (ri->split_horizon != ri->split_horizon_default) |
| 1955 | { |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 1956 | switch (ri->split_horizon) { |
| 1957 | case RIP_SPLIT_HORIZON: |
| 1958 | vty_out (vty, " ip rip split-horizon%s", VTY_NEWLINE); |
| 1959 | break; |
| 1960 | case RIP_SPLIT_HORIZON_POISONED_REVERSE: |
| 1961 | vty_out (vty, " ip rip split-horizon poisoned-reverse%s", |
| 1962 | VTY_NEWLINE); |
| 1963 | break; |
| 1964 | case RIP_NO_SPLIT_HORIZON: |
| 1965 | default: |
| 1966 | vty_out (vty, " no ip rip split-horizon%s", VTY_NEWLINE); |
| 1967 | break; |
| 1968 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1969 | } |
| 1970 | |
| 1971 | /* RIP version setting. */ |
| 1972 | if (ri->ri_send != RI_RIP_UNSPEC) |
| 1973 | vty_out (vty, " ip rip send version %s%s", |
| 1974 | lookup (ri_version_msg, ri->ri_send), |
| 1975 | VTY_NEWLINE); |
| 1976 | |
| 1977 | if (ri->ri_receive != RI_RIP_UNSPEC) |
| 1978 | vty_out (vty, " ip rip receive version %s%s", |
| 1979 | lookup (ri_version_msg, ri->ri_receive), |
| 1980 | VTY_NEWLINE); |
| 1981 | |
| 1982 | /* RIP authentication. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1983 | if (ri->auth_type == RIP_AUTH_SIMPLE_PASSWORD) |
| 1984 | vty_out (vty, " ip rip authentication mode text%s", VTY_NEWLINE); |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1985 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1986 | if (ri->auth_type == RIP_AUTH_MD5) |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 1987 | { |
| 1988 | vty_out (vty, " ip rip authentication mode md5"); |
| 1989 | if (ri->md5_auth_len == RIP_AUTH_MD5_COMPAT_SIZE) |
| 1990 | vty_out (vty, " auth-length old-ripd"); |
| 1991 | else |
| 1992 | vty_out (vty, " auth-length rfc"); |
| 1993 | vty_out (vty, "%s", VTY_NEWLINE); |
| 1994 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1995 | |
| 1996 | if (ri->auth_str) |
| 1997 | vty_out (vty, " ip rip authentication string %s%s", |
| 1998 | ri->auth_str, VTY_NEWLINE); |
| 1999 | |
| 2000 | if (ri->key_chain) |
| 2001 | vty_out (vty, " ip rip authentication key-chain %s%s", |
| 2002 | ri->key_chain, VTY_NEWLINE); |
| 2003 | |
| 2004 | vty_out (vty, "!%s", VTY_NEWLINE); |
| 2005 | } |
| 2006 | return 0; |
| 2007 | } |
| 2008 | |
| 2009 | int |
| 2010 | config_write_rip_network (struct vty *vty, int config_mode) |
| 2011 | { |
hasso | 8a676be | 2004-10-08 06:36:38 +0000 | [diff] [blame] | 2012 | unsigned int i; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2013 | char *ifname; |
| 2014 | struct route_node *node; |
| 2015 | |
| 2016 | /* Network type RIP enable interface statement. */ |
| 2017 | for (node = route_top (rip_enable_network); node; node = route_next (node)) |
| 2018 | if (node->info) |
| 2019 | vty_out (vty, "%s%s/%d%s", |
| 2020 | config_mode ? " network " : " ", |
| 2021 | inet_ntoa (node->p.u.prefix4), |
| 2022 | node->p.prefixlen, |
| 2023 | VTY_NEWLINE); |
| 2024 | |
| 2025 | /* Interface name RIP enable statement. */ |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 2026 | for (i = 0; i < vector_active (rip_enable_interface); i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2027 | if ((ifname = vector_slot (rip_enable_interface, i)) != NULL) |
| 2028 | vty_out (vty, "%s%s%s", |
| 2029 | config_mode ? " network " : " ", |
| 2030 | ifname, |
| 2031 | VTY_NEWLINE); |
| 2032 | |
| 2033 | /* RIP neighbors listing. */ |
| 2034 | for (node = route_top (rip->neighbor); node; node = route_next (node)) |
| 2035 | if (node->info) |
| 2036 | vty_out (vty, "%s%s%s", |
| 2037 | config_mode ? " neighbor " : " ", |
| 2038 | inet_ntoa (node->p.u.prefix4), |
| 2039 | VTY_NEWLINE); |
| 2040 | |
| 2041 | /* RIP passive interface listing. */ |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 2042 | if (config_mode) { |
| 2043 | if (passive_default) |
paul | 01d0908 | 2003-06-08 21:22:18 +0000 | [diff] [blame] | 2044 | vty_out (vty, " passive-interface default%s", VTY_NEWLINE); |
paul | 55468c8 | 2005-03-14 20:19:01 +0000 | [diff] [blame] | 2045 | for (i = 0; i < vector_active (Vrip_passive_nondefault); i++) |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 2046 | if ((ifname = vector_slot (Vrip_passive_nondefault, i)) != NULL) |
| 2047 | vty_out (vty, " %spassive-interface %s%s", |
| 2048 | (passive_default ? "no " : ""), ifname, VTY_NEWLINE); |
| 2049 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2050 | |
| 2051 | return 0; |
| 2052 | } |
| 2053 | |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 2054 | static struct cmd_node interface_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2055 | { |
| 2056 | INTERFACE_NODE, |
| 2057 | "%s(config-if)# ", |
| 2058 | 1, |
| 2059 | }; |
| 2060 | |
| 2061 | /* Called when interface structure allocated. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 2062 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2063 | rip_interface_new_hook (struct interface *ifp) |
| 2064 | { |
| 2065 | ifp->info = rip_interface_new (); |
| 2066 | return 0; |
| 2067 | } |
| 2068 | |
| 2069 | /* Called when interface structure deleted. */ |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 2070 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2071 | rip_interface_delete_hook (struct interface *ifp) |
| 2072 | { |
| 2073 | XFREE (MTYPE_RIP_INTERFACE, ifp->info); |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 2074 | ifp->info = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2075 | return 0; |
| 2076 | } |
| 2077 | |
| 2078 | /* Allocate and initialize interface vector. */ |
| 2079 | void |
paul | dc63bfd | 2005-10-25 23:31:05 +0000 | [diff] [blame] | 2080 | rip_if_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2081 | { |
| 2082 | /* Default initial size of interface vector. */ |
| 2083 | if_init(); |
| 2084 | if_add_hook (IF_NEW_HOOK, rip_interface_new_hook); |
| 2085 | if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook); |
| 2086 | |
| 2087 | /* RIP network init. */ |
| 2088 | rip_enable_interface = vector_init (1); |
| 2089 | rip_enable_network = route_table_init (); |
| 2090 | |
| 2091 | /* RIP passive interface. */ |
paul | 4aaff3f | 2003-06-07 01:04:45 +0000 | [diff] [blame] | 2092 | Vrip_passive_nondefault = vector_init (1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2093 | |
| 2094 | /* Install interface node. */ |
| 2095 | install_node (&interface_node, rip_interface_config_write); |
| 2096 | |
| 2097 | /* Install commands. */ |
| 2098 | install_element (CONFIG_NODE, &interface_cmd); |
hasso | 034489d | 2003-05-24 07:59:25 +0000 | [diff] [blame] | 2099 | install_element (CONFIG_NODE, &no_interface_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2100 | install_default (INTERFACE_NODE); |
| 2101 | install_element (INTERFACE_NODE, &interface_desc_cmd); |
| 2102 | install_element (INTERFACE_NODE, &no_interface_desc_cmd); |
| 2103 | install_element (RIP_NODE, &rip_network_cmd); |
| 2104 | install_element (RIP_NODE, &no_rip_network_cmd); |
| 2105 | install_element (RIP_NODE, &rip_neighbor_cmd); |
| 2106 | install_element (RIP_NODE, &no_rip_neighbor_cmd); |
| 2107 | |
| 2108 | install_element (RIP_NODE, &rip_passive_interface_cmd); |
| 2109 | install_element (RIP_NODE, &no_rip_passive_interface_cmd); |
| 2110 | |
| 2111 | install_element (INTERFACE_NODE, &ip_rip_send_version_cmd); |
| 2112 | install_element (INTERFACE_NODE, &ip_rip_send_version_1_cmd); |
| 2113 | install_element (INTERFACE_NODE, &ip_rip_send_version_2_cmd); |
| 2114 | install_element (INTERFACE_NODE, &no_ip_rip_send_version_cmd); |
| 2115 | install_element (INTERFACE_NODE, &no_ip_rip_send_version_num_cmd); |
| 2116 | |
| 2117 | install_element (INTERFACE_NODE, &ip_rip_receive_version_cmd); |
| 2118 | install_element (INTERFACE_NODE, &ip_rip_receive_version_1_cmd); |
| 2119 | install_element (INTERFACE_NODE, &ip_rip_receive_version_2_cmd); |
| 2120 | install_element (INTERFACE_NODE, &no_ip_rip_receive_version_cmd); |
| 2121 | install_element (INTERFACE_NODE, &no_ip_rip_receive_version_num_cmd); |
| 2122 | |
| 2123 | install_element (INTERFACE_NODE, &ip_rip_authentication_mode_cmd); |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 2124 | install_element (INTERFACE_NODE, &ip_rip_authentication_mode_authlen_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2125 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_cmd); |
| 2126 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_cmd); |
paul | ca5e516 | 2004-06-06 22:06:33 +0000 | [diff] [blame] | 2127 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_mode_type_authlen_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | |
| 2129 | install_element (INTERFACE_NODE, &ip_rip_authentication_key_chain_cmd); |
| 2130 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain_cmd); |
| 2131 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_key_chain2_cmd); |
| 2132 | |
| 2133 | install_element (INTERFACE_NODE, &ip_rip_authentication_string_cmd); |
| 2134 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_string_cmd); |
| 2135 | install_element (INTERFACE_NODE, &no_ip_rip_authentication_string2_cmd); |
| 2136 | |
hasso | 1670513 | 2003-05-25 14:49:19 +0000 | [diff] [blame] | 2137 | install_element (INTERFACE_NODE, &ip_rip_split_horizon_cmd); |
| 2138 | install_element (INTERFACE_NODE, &ip_rip_split_horizon_poisoned_reverse_cmd); |
| 2139 | install_element (INTERFACE_NODE, &no_ip_rip_split_horizon_cmd); |
| 2140 | install_element (INTERFACE_NODE, &no_ip_rip_split_horizon_poisoned_reverse_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2141 | } |