paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Zebra connect library for OSPFd |
| 3 | * Copyright (C) 1997, 98, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | * Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "thread.h" |
| 26 | #include "command.h" |
| 27 | #include "network.h" |
| 28 | #include "prefix.h" |
| 29 | #include "routemap.h" |
| 30 | #include "table.h" |
| 31 | #include "stream.h" |
| 32 | #include "memory.h" |
| 33 | #include "zclient.h" |
| 34 | #include "filter.h" |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 35 | #include "plist.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 36 | #include "log.h" |
| 37 | |
| 38 | #include "ospfd/ospfd.h" |
| 39 | #include "ospfd/ospf_interface.h" |
| 40 | #include "ospfd/ospf_ism.h" |
| 41 | #include "ospfd/ospf_asbr.h" |
| 42 | #include "ospfd/ospf_asbr.h" |
| 43 | #include "ospfd/ospf_abr.h" |
| 44 | #include "ospfd/ospf_lsa.h" |
| 45 | #include "ospfd/ospf_dump.h" |
| 46 | #include "ospfd/ospf_route.h" |
| 47 | #include "ospfd/ospf_zebra.h" |
| 48 | #ifdef HAVE_SNMP |
| 49 | #include "ospfd/ospf_snmp.h" |
| 50 | #endif /* HAVE_SNMP */ |
| 51 | |
| 52 | /* Zebra structure to hold current status. */ |
| 53 | struct zclient *zclient = NULL; |
| 54 | |
| 55 | /* For registering threads. */ |
| 56 | extern struct thread_master *master; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 57 | struct in_addr router_id_zebra; |
| 58 | |
| 59 | /* Router-id update message from zebra. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 60 | static int |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 61 | ospf_router_id_update_zebra (int command, struct zclient *zclient, |
| 62 | zebra_size_t length) |
| 63 | { |
| 64 | struct ospf *ospf; |
| 65 | struct prefix router_id; |
| 66 | zebra_router_id_update_read(zclient->ibuf,&router_id); |
| 67 | |
| 68 | router_id_zebra = router_id.u.prefix4; |
| 69 | |
| 70 | ospf = ospf_lookup (); |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 71 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 72 | if (ospf != NULL) |
paul | b29800a | 2005-11-20 14:50:45 +0000 | [diff] [blame] | 73 | ospf_router_id_update (ospf); |
| 74 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 75 | return 0; |
| 76 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 77 | |
| 78 | /* Inteface addition message from zebra. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 79 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 80 | ospf_interface_add (int command, struct zclient *zclient, zebra_size_t length) |
| 81 | { |
| 82 | struct interface *ifp; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 83 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | |
| 85 | ifp = zebra_interface_add_read (zclient->ibuf); |
| 86 | |
| 87 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 88 | zlog_debug ("Zebra: interface add %s index %d flags %ld metric %d mtu %d", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 89 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 91 | assert (ifp->info); |
paul | f2c8065 | 2002-12-13 21:44:27 +0000 | [diff] [blame] | 92 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 93 | if (!OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), type)) |
| 94 | { |
| 95 | SET_IF_PARAM (IF_DEF_PARAMS (ifp), type); |
ajs | bc18d61 | 2004-12-15 15:07:19 +0000 | [diff] [blame] | 96 | IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 97 | } |
| 98 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 99 | ospf = ospf_lookup (); |
| 100 | if (ospf != NULL) |
| 101 | ospf_if_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | |
| 103 | #ifdef HAVE_SNMP |
| 104 | ospf_snmp_if_update (ifp); |
| 105 | #endif /* HAVE_SNMP */ |
| 106 | |
| 107 | return 0; |
| 108 | } |
| 109 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 110 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 111 | ospf_interface_delete (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 112 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 113 | { |
| 114 | struct interface *ifp; |
| 115 | struct stream *s; |
| 116 | struct route_node *rn; |
| 117 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 118 | s = zclient->ibuf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 119 | /* zebra_interface_state_read() updates interface structure in iflist */ |
| 120 | ifp = zebra_interface_state_read (s); |
| 121 | |
| 122 | if (ifp == NULL) |
| 123 | return 0; |
| 124 | |
| 125 | if (if_is_up (ifp)) |
| 126 | zlog_warn ("Zebra: got delete of %s, but interface is still up", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 127 | ifp->name); |
| 128 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 130 | zlog_debug |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 131 | ("Zebra: interface delete %s index %d flags %ld metric %d mtu %d", |
| 132 | ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 133 | |
| 134 | #ifdef HAVE_SNMP |
| 135 | ospf_snmp_if_delete (ifp); |
| 136 | #endif /* HAVE_SNMP */ |
| 137 | |
| 138 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
| 139 | if (rn->info) |
| 140 | ospf_if_free ((struct ospf_interface *) rn->info); |
| 141 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 142 | ifp->ifindex = IFINDEX_INTERNAL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 146 | static struct interface * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 147 | zebra_interface_if_lookup (struct stream *s) |
| 148 | { |
ajs | 21fefa9 | 2005-04-02 23:16:41 +0000 | [diff] [blame] | 149 | char ifname_tmp[INTERFACE_NAMSIZ]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | |
| 151 | /* Read interface name. */ |
| 152 | stream_get (ifname_tmp, s, INTERFACE_NAMSIZ); |
| 153 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 154 | /* And look it up. */ |
ajs | 21fefa9 | 2005-04-02 23:16:41 +0000 | [diff] [blame] | 155 | return if_lookup_by_name_len(ifname_tmp, |
| 156 | strnlen(ifname_tmp, INTERFACE_NAMSIZ)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | } |
| 158 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 159 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 160 | ospf_interface_state_up (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 161 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 162 | { |
| 163 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 164 | struct ospf_interface *oi; |
| 165 | struct route_node *rn; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 166 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 167 | ifp = zebra_interface_if_lookup (zclient->ibuf); |
| 168 | |
| 169 | if (ifp == NULL) |
| 170 | return 0; |
| 171 | |
| 172 | /* Interface is already up. */ |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 173 | if (if_is_operative (ifp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 174 | { |
| 175 | /* Temporarily keep ifp values. */ |
ajs | a608bbf | 2005-03-29 17:03:49 +0000 | [diff] [blame] | 176 | struct interface if_tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 177 | memcpy (&if_tmp, ifp, sizeof (struct interface)); |
| 178 | |
| 179 | zebra_interface_if_set_value (zclient->ibuf, ifp); |
| 180 | |
| 181 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 182 | zlog_debug ("Zebra: Interface[%s] state update.", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 183 | |
| 184 | if (if_tmp.bandwidth != ifp->bandwidth) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 185 | { |
| 186 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 187 | zlog_debug ("Zebra: Interface[%s] bandwidth change %d -> %d.", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 188 | ifp->name, if_tmp.bandwidth, ifp->bandwidth); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 190 | ospf_if_recalculate_output_cost (ifp); |
| 191 | } |
ajs | a608bbf | 2005-03-29 17:03:49 +0000 | [diff] [blame] | 192 | |
| 193 | if (if_tmp.mtu != ifp->mtu) |
| 194 | { |
| 195 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
| 196 | zlog_debug ("Zebra: Interface[%s] MTU change %u -> %u.", |
| 197 | ifp->name, if_tmp.mtu, ifp->mtu); |
| 198 | |
| 199 | /* Must reset the interface (simulate down/up) when MTU changes. */ |
| 200 | ospf_if_reset(ifp); |
| 201 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 202 | return 0; |
| 203 | } |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 204 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | zebra_interface_if_set_value (zclient->ibuf, ifp); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 206 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 208 | zlog_debug ("Zebra: Interface[%s] state change to up.", ifp->name); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 209 | |
| 210 | for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 211 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 212 | if ((oi = rn->info) == NULL) |
| 213 | continue; |
| 214 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 215 | ospf_if_up (oi); |
| 216 | } |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 217 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 218 | return 0; |
| 219 | } |
| 220 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 221 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 222 | ospf_interface_state_down (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 223 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 224 | { |
| 225 | struct interface *ifp; |
| 226 | struct ospf_interface *oi; |
| 227 | struct route_node *node; |
| 228 | |
| 229 | ifp = zebra_interface_state_read (zclient->ibuf); |
| 230 | |
| 231 | if (ifp == NULL) |
| 232 | return 0; |
| 233 | |
| 234 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 235 | zlog_debug ("Zebra: Interface[%s] state change to down.", ifp->name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 236 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 237 | for (node = route_top (IF_OIFS (ifp)); node; node = route_next (node)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 239 | if ((oi = node->info) == NULL) |
| 240 | continue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 241 | ospf_if_down (oi); |
| 242 | } |
| 243 | |
| 244 | return 0; |
| 245 | } |
| 246 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 247 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | ospf_interface_address_add (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 249 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 250 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 251 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 252 | struct connected *c; |
| 253 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 254 | c = zebra_interface_address_read (command, zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | |
| 256 | if (c == NULL) |
| 257 | return 0; |
| 258 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 259 | ospf = ospf_lookup (); |
| 260 | if (ospf != NULL) |
| 261 | ospf_if_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 262 | |
| 263 | #ifdef HAVE_SNMP |
| 264 | ospf_snmp_if_update (c->ifp); |
| 265 | #endif /* HAVE_SNMP */ |
| 266 | |
| 267 | return 0; |
| 268 | } |
| 269 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 270 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 271 | ospf_interface_address_delete (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 272 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 273 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 274 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 275 | struct connected *c; |
| 276 | struct interface *ifp; |
| 277 | struct ospf_interface *oi; |
| 278 | struct route_node *rn; |
| 279 | struct prefix p; |
| 280 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 281 | c = zebra_interface_address_read (command, zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 282 | |
| 283 | if (c == NULL) |
| 284 | return 0; |
| 285 | |
| 286 | ifp = c->ifp; |
| 287 | p = *c->address; |
| 288 | p.prefixlen = IPV4_MAX_PREFIXLEN; |
| 289 | |
| 290 | rn = route_node_lookup (IF_OIFS (ifp), &p); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 291 | if (!rn) |
paul | 98429f6 | 2006-01-10 22:11:54 +0000 | [diff] [blame] | 292 | { |
| 293 | connected_free (c); |
| 294 | return 0; |
| 295 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | |
| 297 | assert (rn->info); |
| 298 | oi = rn->info; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 299 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 300 | /* Call interface hook functions to clean up */ |
| 301 | ospf_if_free (oi); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 302 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 303 | #ifdef HAVE_SNMP |
| 304 | ospf_snmp_if_update (c->ifp); |
| 305 | #endif /* HAVE_SNMP */ |
| 306 | |
| 307 | connected_free (c); |
| 308 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 309 | ospf = ospf_lookup (); |
| 310 | if (ospf != NULL) |
| 311 | ospf_if_update (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 312 | |
| 313 | return 0; |
| 314 | } |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 315 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 316 | void |
| 317 | ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or) |
| 318 | { |
| 319 | u_char message; |
| 320 | u_char distance; |
| 321 | u_char flags; |
| 322 | int psize; |
| 323 | struct stream *s; |
| 324 | struct ospf_path *path; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 325 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 326 | |
| 327 | if (zclient->redist[ZEBRA_ROUTE_OSPF]) |
| 328 | { |
| 329 | message = 0; |
| 330 | flags = 0; |
| 331 | |
| 332 | /* OSPF pass nexthop and metric */ |
| 333 | SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP); |
| 334 | SET_FLAG (message, ZAPI_MESSAGE_METRIC); |
| 335 | |
| 336 | /* Distance value. */ |
| 337 | distance = ospf_distance_apply (p, or); |
| 338 | if (distance) |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 339 | SET_FLAG (message, ZAPI_MESSAGE_DISTANCE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | |
| 341 | /* Make packet. */ |
| 342 | s = zclient->obuf; |
| 343 | stream_reset (s); |
| 344 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 345 | /* Put command, type, flags, message. */ |
paul | c637171 | 2006-01-17 17:49:53 +0000 | [diff] [blame] | 346 | zclient_create_header (s, ZEBRA_IPV4_ROUTE_ADD); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | stream_putc (s, ZEBRA_ROUTE_OSPF); |
| 348 | stream_putc (s, flags); |
| 349 | stream_putc (s, message); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 350 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 351 | /* Put prefix information. */ |
| 352 | psize = PSIZE (p->prefixlen); |
| 353 | stream_putc (s, p->prefixlen); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 354 | stream_write (s, (u_char *) & p->prefix, psize); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 355 | |
| 356 | /* Nexthop count. */ |
paul | 96735ee | 2003-08-10 02:51:22 +0000 | [diff] [blame] | 357 | stream_putc (s, or->paths->count); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 358 | |
| 359 | /* Nexthop, ifindex, distance and metric information. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 360 | for (ALL_LIST_ELEMENTS_RO (or->paths, node, path)) |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 361 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 362 | if (path->nexthop.s_addr != INADDR_ANY) |
| 363 | { |
| 364 | stream_putc (s, ZEBRA_NEXTHOP_IPV4); |
| 365 | stream_put_in_addr (s, &path->nexthop); |
| 366 | } |
| 367 | else |
| 368 | { |
| 369 | stream_putc (s, ZEBRA_NEXTHOP_IFINDEX); |
| 370 | if (path->oi) |
| 371 | stream_putl (s, path->oi->ifp->ifindex); |
| 372 | else |
| 373 | stream_putl (s, 0); |
| 374 | } |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 375 | |
| 376 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
| 377 | { |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 378 | zlog_debug ("Zebra: Route add %s/%d nexthop %s", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 379 | inet_ntoa (p->prefix), |
| 380 | p->prefixlen, inet_ntoa (path->nexthop)); |
| 381 | } |
| 382 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 383 | |
| 384 | if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE)) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 385 | stream_putc (s, distance); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 386 | if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC)) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 387 | { |
| 388 | if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL) |
| 389 | stream_putl (s, or->cost + or->u.ext.type2_cost); |
| 390 | else if (or->path_type == OSPF_PATH_TYPE2_EXTERNAL) |
| 391 | stream_putl (s, or->u.ext.type2_cost); |
| 392 | else |
| 393 | stream_putl (s, or->cost); |
| 394 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 395 | |
| 396 | stream_putw_at (s, 0, stream_get_endp (s)); |
| 397 | |
ajs | 634f9ea | 2005-04-11 15:51:40 +0000 | [diff] [blame] | 398 | zclient_send_message(zclient); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
| 402 | void |
| 403 | ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or) |
| 404 | { |
| 405 | struct zapi_ipv4 api; |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 406 | struct ospf_path *path; |
| 407 | struct in_addr *nexthop; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 408 | struct listnode *node, *nnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 409 | |
| 410 | if (zclient->redist[ZEBRA_ROUTE_OSPF]) |
| 411 | { |
| 412 | api.type = ZEBRA_ROUTE_OSPF; |
| 413 | api.flags = 0; |
| 414 | api.message = 0; |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 415 | api.ifindex_num = 0; |
| 416 | api.nexthop_num = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 418 | for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path)) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 419 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 420 | if (path->nexthop.s_addr != INADDR_ANY) |
| 421 | { |
paul | d8e1d6b | 2003-08-10 04:04:41 +0000 | [diff] [blame] | 422 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 423 | api.nexthop_num = 1; |
| 424 | nexthop = &path->nexthop; |
| 425 | api.nexthop = &nexthop; |
| 426 | } |
hasso | 2db3d05 | 2004-02-11 21:52:13 +0000 | [diff] [blame] | 427 | else if (ospf_if_exists(path->oi) && (path->oi->ifp)) |
paul | bb8ff1e | 2003-08-12 06:00:30 +0000 | [diff] [blame] | 428 | { |
| 429 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 430 | api.ifindex_num = 1; |
| 431 | api.ifindex = &path->oi->ifp->ifindex; |
| 432 | } |
| 433 | else if ( IS_DEBUG_OSPF(zebra,ZEBRA_REDISTRIBUTE) ) |
| 434 | { |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 435 | zlog_debug("Zebra: no ifp %s %d", |
paul | bb8ff1e | 2003-08-12 06:00:30 +0000 | [diff] [blame] | 436 | inet_ntoa(p->prefix), |
| 437 | p->prefixlen); |
| 438 | } |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 439 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 440 | zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api); |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 441 | |
| 442 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.nexthop_num) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 443 | { |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 444 | zlog_debug ("Zebra: Route delete %s/%d nexthop %s", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 445 | inet_ntoa (p->prefix), |
| 446 | p->prefixlen, inet_ntoa (**api.nexthop)); |
| 447 | } |
paul | bb8ff1e | 2003-08-12 06:00:30 +0000 | [diff] [blame] | 448 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE) && api.ifindex_num) |
| 449 | { |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 450 | zlog_debug ("Zebra: Route delete %s/%d ifindex %d", |
paul | bb8ff1e | 2003-08-12 06:00:30 +0000 | [diff] [blame] | 451 | inet_ntoa (p->prefix), |
| 452 | p->prefixlen, *api.ifindex); |
| 453 | } |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 454 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | |
| 458 | void |
| 459 | ospf_zebra_add_discard (struct prefix_ipv4 *p) |
| 460 | { |
| 461 | struct zapi_ipv4 api; |
| 462 | |
| 463 | if (zclient->redist[ZEBRA_ROUTE_OSPF]) |
| 464 | { |
| 465 | api.type = ZEBRA_ROUTE_OSPF; |
| 466 | api.flags = ZEBRA_FLAG_BLACKHOLE; |
| 467 | api.message = 0; |
| 468 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 469 | api.nexthop_num = 0; |
| 470 | api.ifindex_num = 0; |
| 471 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 472 | zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient, p, &api); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 473 | } |
| 474 | } |
| 475 | |
| 476 | void |
| 477 | ospf_zebra_delete_discard (struct prefix_ipv4 *p) |
| 478 | { |
| 479 | struct zapi_ipv4 api; |
| 480 | |
| 481 | if (zclient->redist[ZEBRA_ROUTE_OSPF]) |
| 482 | { |
| 483 | api.type = ZEBRA_ROUTE_OSPF; |
| 484 | api.flags = ZEBRA_FLAG_BLACKHOLE; |
| 485 | api.message = 0; |
| 486 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
| 487 | api.nexthop_num = 0; |
| 488 | api.ifindex_num = 0; |
| 489 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 490 | zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, p, &api); |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 491 | |
| 492 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 493 | zlog_debug ("Zebra: Route delete discard %s/%d", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 494 | inet_ntoa (p->prefix), p->prefixlen); |
paul | 72357f2 | 2003-06-19 02:11:23 +0000 | [diff] [blame] | 495 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | |
| 499 | int |
| 500 | ospf_is_type_redistributed (int type) |
| 501 | { |
| 502 | return (DEFAULT_ROUTE_TYPE (type)) ? |
| 503 | zclient->default_information : zclient->redist[type]; |
| 504 | } |
| 505 | |
| 506 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 507 | ospf_redistribute_set (struct ospf *ospf, int type, int mtype, int mvalue) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 508 | { |
| 509 | int force = 0; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 510 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | if (ospf_is_type_redistributed (type)) |
| 512 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 513 | if (mtype != ospf->dmetric[type].type) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 514 | { |
| 515 | ospf->dmetric[type].type = mtype; |
| 516 | force = LSA_REFRESH_FORCE; |
| 517 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 518 | if (mvalue != ospf->dmetric[type].value) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 519 | { |
| 520 | ospf->dmetric[type].value = mvalue; |
| 521 | force = LSA_REFRESH_FORCE; |
| 522 | } |
| 523 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 524 | ospf_external_lsa_refresh_type (ospf, type, force); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 525 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 526 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 527 | zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 528 | ospf_redist_string(type), |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 529 | metric_type (ospf, type), metric_value (ospf, type)); |
| 530 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 531 | return CMD_SUCCESS; |
| 532 | } |
| 533 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 534 | ospf->dmetric[type].type = mtype; |
| 535 | ospf->dmetric[type].value = mvalue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 536 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 537 | zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | |
| 539 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 540 | zlog_debug ("Redistribute[%s]: Start Type[%d], Metric[%d]", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 541 | ospf_redist_string(type), |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 542 | metric_type (ospf, type), metric_value (ospf, type)); |
| 543 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 544 | ospf_asbr_status_update (ospf, ++ospf->redistribute); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 545 | |
| 546 | return CMD_SUCCESS; |
| 547 | } |
| 548 | |
| 549 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 550 | ospf_redistribute_unset (struct ospf *ospf, int type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 551 | { |
| 552 | if (type == zclient->redist_default) |
| 553 | return CMD_SUCCESS; |
| 554 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 555 | if (!ospf_is_type_redistributed (type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 556 | return CMD_SUCCESS; |
| 557 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 558 | zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 559 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 560 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 561 | zlog_debug ("Redistribute[%s]: Stop", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 562 | ospf_redist_string(type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 564 | ospf->dmetric[type].type = -1; |
| 565 | ospf->dmetric[type].value = -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | |
| 567 | /* Remove the routes from OSPF table. */ |
| 568 | ospf_redistribute_withdraw (type); |
| 569 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 570 | ospf_asbr_status_update (ospf, --ospf->redistribute); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 571 | |
| 572 | return CMD_SUCCESS; |
| 573 | } |
| 574 | |
| 575 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 576 | ospf_redistribute_default_set (struct ospf *ospf, int originate, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 577 | int mtype, int mvalue) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 578 | { |
| 579 | int force = 0; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 580 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 581 | if (ospf_is_type_redistributed (DEFAULT_ROUTE)) |
| 582 | { |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 583 | if (mtype != ospf->dmetric[DEFAULT_ROUTE].type) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 584 | { |
| 585 | ospf->dmetric[DEFAULT_ROUTE].type = mtype; |
| 586 | force = 1; |
| 587 | } |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 588 | if (mvalue != ospf->dmetric[DEFAULT_ROUTE].value) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 589 | { |
| 590 | force = 1; |
| 591 | ospf->dmetric[DEFAULT_ROUTE].value = mvalue; |
| 592 | } |
| 593 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 594 | ospf_external_lsa_refresh_default (ospf); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 595 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 596 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 597 | zlog_debug ("Redistribute[%s]: Refresh Type[%d], Metric[%d]", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 598 | ospf_redist_string(DEFAULT_ROUTE), |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 599 | metric_type (ospf, DEFAULT_ROUTE), |
| 600 | metric_value (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 601 | return CMD_SUCCESS; |
| 602 | } |
| 603 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 604 | ospf->default_originate = originate; |
| 605 | ospf->dmetric[DEFAULT_ROUTE].type = mtype; |
| 606 | ospf->dmetric[DEFAULT_ROUTE].value = mvalue; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 607 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 608 | zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_ADD, zclient); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 609 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 610 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 611 | zlog_debug ("Redistribute[DEFAULT]: Start Type[%d], Metric[%d]", |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 612 | metric_type (ospf, DEFAULT_ROUTE), |
| 613 | metric_value (ospf, DEFAULT_ROUTE)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 615 | if (ospf->router_id.s_addr == 0) |
| 616 | ospf->external_origin |= (1 << DEFAULT_ROUTE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 617 | else |
Paul Jakma | 4021b60 | 2006-05-12 22:55:41 +0000 | [diff] [blame] | 618 | thread_add_timer (master, ospf_default_originate_timer, ospf, 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 620 | ospf_asbr_status_update (ospf, ++ospf->redistribute); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 621 | |
| 622 | return CMD_SUCCESS; |
| 623 | } |
| 624 | |
| 625 | int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 626 | ospf_redistribute_default_unset (struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | { |
| 628 | if (!ospf_is_type_redistributed (DEFAULT_ROUTE)) |
| 629 | return CMD_SUCCESS; |
| 630 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 631 | ospf->default_originate = DEFAULT_ORIGINATE_NONE; |
| 632 | ospf->dmetric[DEFAULT_ROUTE].type = -1; |
| 633 | ospf->dmetric[DEFAULT_ROUTE].value = -1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 634 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 635 | zclient_redistribute_default (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, zclient); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 636 | |
| 637 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 638 | zlog_debug ("Redistribute[DEFAULT]: Stop"); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 639 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 640 | ospf_asbr_status_update (ospf, --ospf->redistribute); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 641 | |
| 642 | return CMD_SUCCESS; |
| 643 | } |
| 644 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 645 | static int |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 646 | ospf_external_lsa_originate_check (struct ospf *ospf, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 647 | struct external_info *ei) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 648 | { |
| 649 | /* If prefix is multicast, then do not originate LSA. */ |
| 650 | if (IN_MULTICAST (htonl (ei->p.prefix.s_addr))) |
| 651 | { |
| 652 | zlog_info ("LSA[Type5:%s]: Not originate AS-external-LSA, " |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 653 | "Prefix belongs multicast", inet_ntoa (ei->p.prefix)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | return 0; |
| 655 | } |
| 656 | |
| 657 | /* Take care of default-originate. */ |
| 658 | if (is_prefix_default (&ei->p)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 659 | if (ospf->default_originate == DEFAULT_ORIGINATE_NONE) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 660 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 661 | zlog_info ("LSA[Type5:0.0.0.0]: Not originate AS-exntenal-LSA " |
| 662 | "for default"); |
| 663 | return 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | return 1; |
| 667 | } |
| 668 | |
| 669 | /* If connected prefix is OSPF enable interface, then do not announce. */ |
| 670 | int |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 671 | ospf_distribute_check_connected (struct ospf *ospf, struct external_info *ei) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 672 | { |
| 673 | struct route_node *rn; |
| 674 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 675 | for (rn = route_top (ospf->networks); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 676 | if (rn->info != NULL) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 677 | if (prefix_match (&rn->p, (struct prefix *) &ei->p)) |
| 678 | { |
| 679 | route_unlock_node (rn); |
| 680 | return 0; |
| 681 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 682 | |
| 683 | return 1; |
| 684 | } |
| 685 | |
| 686 | /* return 1 if external LSA must be originated, 0 otherwise */ |
| 687 | int |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 688 | ospf_redistribute_check (struct ospf *ospf, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 689 | struct external_info *ei, int *changed) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 690 | { |
| 691 | struct route_map_set_values save_values; |
| 692 | struct prefix_ipv4 *p = &ei->p; |
| 693 | u_char type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 694 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | if (changed) |
| 696 | *changed = 0; |
| 697 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 698 | if (!ospf_external_lsa_originate_check (ospf, ei)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 699 | return 0; |
| 700 | |
| 701 | /* Take care connected route. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 702 | if (type == ZEBRA_ROUTE_CONNECT && |
| 703 | !ospf_distribute_check_connected (ospf, ei)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 704 | return 0; |
| 705 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 706 | if (!DEFAULT_ROUTE_TYPE (type) && DISTRIBUTE_NAME (ospf, type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 707 | /* distirbute-list exists, but access-list may not? */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 708 | if (DISTRIBUTE_LIST (ospf, type)) |
| 709 | if (access_list_apply (DISTRIBUTE_LIST (ospf, type), p) == FILTER_DENY) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 710 | { |
| 711 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 712 | zlog_debug ("Redistribute[%s]: %s/%d filtered by ditribute-list.", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 713 | ospf_redist_string(type), |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 714 | inet_ntoa (p->prefix), p->prefixlen); |
| 715 | return 0; |
| 716 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 717 | |
| 718 | save_values = ei->route_map_set; |
| 719 | ospf_reset_route_map_set_values (&ei->route_map_set); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 720 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 721 | /* apply route-map if needed */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 722 | if (ROUTEMAP_NAME (ospf, type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 723 | { |
| 724 | int ret; |
| 725 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 726 | ret = route_map_apply (ROUTEMAP (ospf, type), (struct prefix *) p, |
| 727 | RMAP_OSPF, ei); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 728 | |
| 729 | if (ret == RMAP_DENYMATCH) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 730 | { |
| 731 | ei->route_map_set = save_values; |
| 732 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
ajs | 9b0e25c | 2004-12-08 19:06:51 +0000 | [diff] [blame] | 733 | zlog_debug ("Redistribute[%s]: %s/%d filtered by route-map.", |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 734 | ospf_redist_string(type), |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 735 | inet_ntoa (p->prefix), p->prefixlen); |
| 736 | return 0; |
| 737 | } |
| 738 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 739 | /* check if 'route-map set' changed something */ |
| 740 | if (changed) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 741 | *changed = !ospf_route_map_set_compare (&ei->route_map_set, |
| 742 | &save_values); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | return 1; |
| 746 | } |
| 747 | |
| 748 | /* OSPF route-map set for redistribution */ |
| 749 | void |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 750 | ospf_routemap_set (struct ospf *ospf, int type, const char *name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 751 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 752 | if (ROUTEMAP_NAME (ospf, type)) |
| 753 | free (ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 754 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 755 | ROUTEMAP_NAME (ospf, type) = strdup (name); |
| 756 | ROUTEMAP (ospf, type) = route_map_lookup_by_name (name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | void |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 760 | ospf_routemap_unset (struct ospf *ospf, int type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 761 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 762 | if (ROUTEMAP_NAME (ospf, type)) |
| 763 | free (ROUTEMAP_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 764 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 765 | ROUTEMAP_NAME (ospf, type) = NULL; |
| 766 | ROUTEMAP (ospf, type) = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /* Zebra route add and delete treatment. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 770 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | ospf_zebra_read_ipv4 (int command, struct zclient *zclient, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 772 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 773 | { |
| 774 | struct stream *s; |
| 775 | struct zapi_ipv4 api; |
| 776 | unsigned long ifindex; |
| 777 | struct in_addr nexthop; |
| 778 | struct prefix_ipv4 p; |
| 779 | struct external_info *ei; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 780 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 781 | |
| 782 | s = zclient->ibuf; |
| 783 | ifindex = 0; |
| 784 | nexthop.s_addr = 0; |
| 785 | |
| 786 | /* Type, flags, message. */ |
| 787 | api.type = stream_getc (s); |
| 788 | api.flags = stream_getc (s); |
| 789 | api.message = stream_getc (s); |
| 790 | |
| 791 | /* IPv4 prefix. */ |
| 792 | memset (&p, 0, sizeof (struct prefix_ipv4)); |
| 793 | p.family = AF_INET; |
| 794 | p.prefixlen = stream_getc (s); |
| 795 | stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
| 796 | |
hasso | 8585d4e | 2004-04-20 17:25:12 +0000 | [diff] [blame] | 797 | if (IPV4_NET127(ntohl(p.prefix.s_addr))) |
| 798 | return 0; |
| 799 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 800 | /* Nexthop, ifindex, distance, metric. */ |
| 801 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) |
| 802 | { |
| 803 | api.nexthop_num = stream_getc (s); |
| 804 | nexthop.s_addr = stream_get_ipv4 (s); |
| 805 | } |
| 806 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) |
| 807 | { |
| 808 | api.ifindex_num = stream_getc (s); |
gdt | 6a8da85 | 2004-02-13 17:40:51 +0000 | [diff] [blame] | 809 | /* XXX assert(api.ifindex_num == 1); */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 810 | ifindex = stream_getl (s); |
| 811 | } |
| 812 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) |
| 813 | api.distance = stream_getc (s); |
| 814 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) |
| 815 | api.metric = stream_getl (s); |
| 816 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 817 | ospf = ospf_lookup (); |
| 818 | if (ospf == NULL) |
| 819 | return 0; |
| 820 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 821 | if (command == ZEBRA_IPV4_ROUTE_ADD) |
| 822 | { |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 823 | /* XXX|HACK|TODO|FIXME: |
hasso | a0a3976 | 2004-04-23 08:51:10 +0000 | [diff] [blame] | 824 | * Maybe we should ignore reject/blackhole routes? Testing shows that |
| 825 | * there is no problems though and this is only way to "summarize" |
| 826 | * routes in ASBR at the moment. Maybe we need just a better generalised |
| 827 | * solution for these types? |
| 828 | * |
| 829 | * if ( CHECK_FLAG (api.flags, ZEBRA_FLAG_BLACKHOLE) |
| 830 | * || CHECK_FLAG (api.flags, ZEBRA_FLAG_REJECT)) |
| 831 | * return 0; |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 832 | */ |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 833 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 834 | ei = ospf_external_info_add (api.type, p, ifindex, nexthop); |
| 835 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 836 | if (ospf->router_id.s_addr == 0) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 837 | /* Set flags to generate AS-external-LSA originate event |
| 838 | for each redistributed protocols later. */ |
| 839 | ospf->external_origin |= (1 << api.type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 840 | else |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 841 | { |
| 842 | if (ei) |
| 843 | { |
| 844 | if (is_prefix_default (&p)) |
| 845 | ospf_external_lsa_refresh_default (ospf); |
| 846 | else |
| 847 | { |
| 848 | struct ospf_lsa *current; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 849 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 850 | current = ospf_external_info_find_lsa (ospf, &ei->p); |
| 851 | if (!current) |
| 852 | ospf_external_lsa_originate (ospf, ei); |
| 853 | else if (IS_LSA_MAXAGE (current)) |
| 854 | ospf_external_lsa_refresh (ospf, current, |
| 855 | ei, LSA_REFRESH_FORCE); |
| 856 | else |
| 857 | zlog_warn ("ospf_zebra_read_ipv4() : %s already exists", |
| 858 | inet_ntoa (p.prefix)); |
| 859 | } |
| 860 | } |
| 861 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 862 | } |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 863 | else /* if (command == ZEBRA_IPV4_ROUTE_DELETE) */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 864 | { |
| 865 | ospf_external_info_delete (api.type, p); |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 866 | if (is_prefix_default (&p)) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 867 | ospf_external_lsa_refresh_default (ospf); |
paul | 7021c42 | 2003-07-15 12:52:22 +0000 | [diff] [blame] | 868 | else |
ajs | 5339cfd | 2005-09-19 13:28:05 +0000 | [diff] [blame] | 869 | ospf_external_lsa_flush (ospf, api.type, &p, ifindex /*, nexthop */); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | return 0; |
| 873 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 874 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 875 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 876 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 877 | ospf_distribute_list_out_set (struct ospf *ospf, int type, const char *name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 878 | { |
| 879 | /* Lookup access-list for distribute-list. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 880 | DISTRIBUTE_LIST (ospf, type) = access_list_lookup (AFI_IP, name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | |
| 882 | /* Clear previous distribute-name. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 883 | if (DISTRIBUTE_NAME (ospf, type)) |
| 884 | free (DISTRIBUTE_NAME (ospf, type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 885 | |
| 886 | /* Set distribute-name. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 887 | DISTRIBUTE_NAME (ospf, type) = strdup (name); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 888 | |
| 889 | /* If access-list have been set, schedule update timer. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 890 | if (DISTRIBUTE_LIST (ospf, type)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 891 | ospf_distribute_list_update (ospf, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 892 | |
| 893 | return CMD_SUCCESS; |
| 894 | } |
| 895 | |
| 896 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 897 | ospf_distribute_list_out_unset (struct ospf *ospf, int type, const char *name) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 898 | { |
| 899 | /* Schedule update timer. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 900 | if (DISTRIBUTE_LIST (ospf, type)) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 901 | ospf_distribute_list_update (ospf, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 902 | |
| 903 | /* Unset distribute-list. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 904 | DISTRIBUTE_LIST (ospf, type) = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 905 | |
| 906 | /* Clear distribute-name. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 907 | if (DISTRIBUTE_NAME (ospf, type)) |
| 908 | free (DISTRIBUTE_NAME (ospf, type)); |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 909 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 910 | DISTRIBUTE_NAME (ospf, type) = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 911 | |
| 912 | return CMD_SUCCESS; |
| 913 | } |
| 914 | |
| 915 | /* distribute-list update timer. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 916 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 917 | ospf_distribute_list_update_timer (struct thread *thread) |
| 918 | { |
| 919 | struct route_node *rn; |
| 920 | struct external_info *ei; |
| 921 | struct route_table *rt; |
| 922 | struct ospf_lsa *lsa; |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 923 | intptr_t type; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 924 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 926 | type = (intptr_t)THREAD_ARG (thread); |
hasso | 01018ce | 2005-08-05 07:40:15 +0000 | [diff] [blame] | 927 | assert (type <= ZEBRA_ROUTE_MAX); |
paul | 64511f3 | 2004-10-31 18:01:13 +0000 | [diff] [blame] | 928 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 929 | rt = EXTERNAL_INFO (type); |
| 930 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 931 | ospf = ospf_lookup (); |
| 932 | if (ospf == NULL) |
| 933 | return 0; |
| 934 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 935 | ospf->t_distribute_update = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 936 | |
| 937 | zlog_info ("Zebra[Redistribute]: distribute-list update timer fired!"); |
| 938 | |
| 939 | /* foreach all external info. */ |
| 940 | if (rt) |
| 941 | for (rn = route_top (rt); rn; rn = route_next (rn)) |
| 942 | if ((ei = rn->info) != NULL) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 943 | { |
| 944 | if (is_prefix_default (&ei->p)) |
| 945 | ospf_external_lsa_refresh_default (ospf); |
| 946 | else if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p))) |
| 947 | ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_IF_CHANGED); |
| 948 | else |
| 949 | ospf_external_lsa_originate (ospf, ei); |
| 950 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 951 | return 0; |
| 952 | } |
| 953 | |
| 954 | #define OSPF_DISTRIBUTE_UPDATE_DELAY 5 |
| 955 | |
| 956 | /* Update distribute-list and set timer to apply access-list. */ |
| 957 | void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 958 | ospf_distribute_list_update (struct ospf *ospf, int type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 959 | { |
| 960 | struct route_table *rt; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 961 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 962 | /* External info does not exist. */ |
| 963 | if (!(rt = EXTERNAL_INFO (type))) |
| 964 | return; |
| 965 | |
| 966 | /* If exists previously invoked thread, then cancel it. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 967 | if (ospf->t_distribute_update) |
| 968 | OSPF_TIMER_OFF (ospf->t_distribute_update); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 969 | |
| 970 | /* Set timer. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 971 | ospf->t_distribute_update = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 972 | thread_add_timer (master, ospf_distribute_list_update_timer, |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 973 | (void *) type, OSPF_DISTRIBUTE_UPDATE_DELAY); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | /* If access-list is updated, apply some check. */ |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 977 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 978 | ospf_filter_update (struct access_list *access) |
| 979 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 980 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 981 | int type; |
| 982 | int abr_inv = 0; |
| 983 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 984 | struct listnode *node; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 985 | |
| 986 | /* If OSPF instatnce does not exist, return right now. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 987 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 988 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 989 | return; |
| 990 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 991 | /* Update distribute-list, and apply filter. */ |
hasso | 01018ce | 2005-08-05 07:40:15 +0000 | [diff] [blame] | 992 | for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 993 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 994 | if (ROUTEMAP (ospf, type) != NULL) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 995 | { |
| 996 | /* if route-map is not NULL it may be using this access list */ |
| 997 | ospf_distribute_list_update (ospf, type); |
| 998 | continue; |
| 999 | } |
| 1000 | |
hasso | 01018ce | 2005-08-05 07:40:15 +0000 | [diff] [blame] | 1001 | /* There is place for route-map for default-information (ZEBRA_ROUTE_MAX), |
| 1002 | * but no distribute list. */ |
| 1003 | if (type == ZEBRA_ROUTE_MAX) |
| 1004 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1005 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 1006 | if (DISTRIBUTE_NAME (ospf, type)) |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1007 | { |
| 1008 | /* Keep old access-list for distribute-list. */ |
| 1009 | struct access_list *old = DISTRIBUTE_LIST (ospf, type); |
| 1010 | |
| 1011 | /* Update access-list for distribute-list. */ |
| 1012 | DISTRIBUTE_LIST (ospf, type) = |
| 1013 | access_list_lookup (AFI_IP, DISTRIBUTE_NAME (ospf, type)); |
| 1014 | |
| 1015 | /* No update for this distribute type. */ |
| 1016 | if (old == NULL && DISTRIBUTE_LIST (ospf, type) == NULL) |
| 1017 | continue; |
| 1018 | |
| 1019 | /* Schedule distribute-list update timer. */ |
| 1020 | if (DISTRIBUTE_LIST (ospf, type) == NULL || |
| 1021 | strcmp (DISTRIBUTE_NAME (ospf, type), access->name) == 0) |
| 1022 | ospf_distribute_list_update (ospf, type); |
| 1023 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | /* Update Area access-list. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1027 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
| 1028 | { |
| 1029 | if (EXPORT_NAME (area)) |
| 1030 | { |
| 1031 | EXPORT_LIST (area) = NULL; |
| 1032 | abr_inv++; |
| 1033 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1034 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1035 | if (IMPORT_NAME (area)) |
| 1036 | { |
| 1037 | IMPORT_LIST (area) = NULL; |
| 1038 | abr_inv++; |
| 1039 | } |
| 1040 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1041 | |
| 1042 | /* Schedule ABR tasks -- this will be changed -- takada. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 1043 | if (IS_OSPF_ABR (ospf) && abr_inv) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1044 | ospf_schedule_abr_task (ospf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1045 | } |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1046 | |
| 1047 | /* If prefix-list is updated, do some updates. */ |
| 1048 | void |
| 1049 | ospf_prefix_list_update (struct prefix_list *plist) |
| 1050 | { |
| 1051 | struct ospf *ospf; |
| 1052 | int type; |
| 1053 | int abr_inv = 0; |
| 1054 | struct ospf_area *area; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 1055 | struct listnode *node; |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1056 | |
| 1057 | /* If OSPF instatnce does not exist, return right now. */ |
| 1058 | ospf = ospf_lookup (); |
| 1059 | if (ospf == NULL) |
| 1060 | return; |
| 1061 | |
| 1062 | /* Update all route-maps which are used as redistribution filters. |
| 1063 | * They might use prefix-list. |
| 1064 | */ |
hasso | 01018ce | 2005-08-05 07:40:15 +0000 | [diff] [blame] | 1065 | for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1066 | { |
| 1067 | if (ROUTEMAP (ospf, type) != NULL) |
| 1068 | { |
| 1069 | /* If route-map is not NULL it may be using this prefix list */ |
| 1070 | ospf_distribute_list_update (ospf, type); |
| 1071 | continue; |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | /* Update area filter-lists. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1076 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
| 1077 | { |
| 1078 | /* Update filter-list in. */ |
| 1079 | if (PREFIX_NAME_IN (area)) |
| 1080 | if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0) |
| 1081 | { |
| 1082 | PREFIX_LIST_IN (area) = |
| 1083 | prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area)); |
| 1084 | abr_inv++; |
| 1085 | } |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1086 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 1087 | /* Update filter-list out. */ |
| 1088 | if (PREFIX_NAME_OUT (area)) |
| 1089 | if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0) |
| 1090 | { |
| 1091 | PREFIX_LIST_IN (area) = |
| 1092 | prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area)); |
| 1093 | abr_inv++; |
| 1094 | } |
| 1095 | } |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1096 | |
| 1097 | /* Schedule ABR task. */ |
| 1098 | if (IS_OSPF_ABR (ospf) && abr_inv) |
| 1099 | ospf_schedule_abr_task (ospf); |
| 1100 | } |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1101 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1102 | static struct ospf_distance * |
| 1103 | ospf_distance_new (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1104 | { |
| 1105 | struct ospf_distance *new; |
| 1106 | new = XMALLOC (MTYPE_OSPF_DISTANCE, sizeof (struct ospf_distance)); |
| 1107 | memset (new, 0, sizeof (struct ospf_distance)); |
| 1108 | return new; |
| 1109 | } |
| 1110 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1111 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1112 | ospf_distance_free (struct ospf_distance *odistance) |
| 1113 | { |
| 1114 | XFREE (MTYPE_OSPF_DISTANCE, odistance); |
| 1115 | } |
| 1116 | |
| 1117 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1118 | ospf_distance_set (struct vty *vty, struct ospf *ospf, |
| 1119 | const char *distance_str, |
| 1120 | const char *ip_str, |
| 1121 | const char *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1122 | { |
| 1123 | int ret; |
| 1124 | struct prefix_ipv4 p; |
| 1125 | u_char distance; |
| 1126 | struct route_node *rn; |
| 1127 | struct ospf_distance *odistance; |
| 1128 | |
| 1129 | ret = str2prefix_ipv4 (ip_str, &p); |
| 1130 | if (ret == 0) |
| 1131 | { |
| 1132 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 1133 | return CMD_WARNING; |
| 1134 | } |
| 1135 | |
| 1136 | distance = atoi (distance_str); |
| 1137 | |
| 1138 | /* Get OSPF distance node. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1139 | rn = route_node_get (ospf->distance_table, (struct prefix *) &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1140 | if (rn->info) |
| 1141 | { |
| 1142 | odistance = rn->info; |
| 1143 | route_unlock_node (rn); |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | odistance = ospf_distance_new (); |
| 1148 | rn->info = odistance; |
| 1149 | } |
| 1150 | |
| 1151 | /* Set distance value. */ |
| 1152 | odistance->distance = distance; |
| 1153 | |
| 1154 | /* Reset access-list configuration. */ |
| 1155 | if (odistance->access_list) |
| 1156 | { |
| 1157 | free (odistance->access_list); |
| 1158 | odistance->access_list = NULL; |
| 1159 | } |
| 1160 | if (access_list_str) |
| 1161 | odistance->access_list = strdup (access_list_str); |
| 1162 | |
| 1163 | return CMD_SUCCESS; |
| 1164 | } |
| 1165 | |
| 1166 | int |
paul | 6c83567 | 2004-10-11 11:00:30 +0000 | [diff] [blame] | 1167 | ospf_distance_unset (struct vty *vty, struct ospf *ospf, |
| 1168 | const char *distance_str, |
| 1169 | const char *ip_str, char |
| 1170 | const *access_list_str) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1171 | { |
| 1172 | int ret; |
| 1173 | struct prefix_ipv4 p; |
| 1174 | u_char distance; |
| 1175 | struct route_node *rn; |
| 1176 | struct ospf_distance *odistance; |
| 1177 | |
| 1178 | ret = str2prefix_ipv4 (ip_str, &p); |
| 1179 | if (ret == 0) |
| 1180 | { |
| 1181 | vty_out (vty, "Malformed prefix%s", VTY_NEWLINE); |
| 1182 | return CMD_WARNING; |
| 1183 | } |
| 1184 | |
| 1185 | distance = atoi (distance_str); |
| 1186 | |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1187 | rn = route_node_lookup (ospf->distance_table, (struct prefix *) &p); |
| 1188 | if (!rn) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1189 | { |
| 1190 | vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE); |
| 1191 | return CMD_WARNING; |
| 1192 | } |
| 1193 | |
| 1194 | odistance = rn->info; |
| 1195 | |
| 1196 | if (odistance->access_list) |
| 1197 | free (odistance->access_list); |
| 1198 | ospf_distance_free (odistance); |
| 1199 | |
| 1200 | rn->info = NULL; |
| 1201 | route_unlock_node (rn); |
| 1202 | route_unlock_node (rn); |
| 1203 | |
| 1204 | return CMD_SUCCESS; |
| 1205 | } |
| 1206 | |
| 1207 | void |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1208 | ospf_distance_reset (struct ospf *ospf) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1209 | { |
| 1210 | struct route_node *rn; |
| 1211 | struct ospf_distance *odistance; |
| 1212 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1213 | for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1214 | if ((odistance = rn->info) != NULL) |
| 1215 | { |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1216 | if (odistance->access_list) |
| 1217 | free (odistance->access_list); |
| 1218 | ospf_distance_free (odistance); |
| 1219 | rn->info = NULL; |
| 1220 | route_unlock_node (rn); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | u_char |
| 1225 | ospf_distance_apply (struct prefix_ipv4 *p, struct ospf_route *or) |
| 1226 | { |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 1227 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1228 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 1229 | ospf = ospf_lookup (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1230 | if (ospf == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1231 | return 0; |
| 1232 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1233 | if (ospf->distance_intra) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1234 | if (or->path_type == OSPF_PATH_INTRA_AREA) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1235 | return ospf->distance_intra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1236 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1237 | if (ospf->distance_inter) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1238 | if (or->path_type == OSPF_PATH_INTER_AREA) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1239 | return ospf->distance_inter; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1240 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1241 | if (ospf->distance_external) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1242 | if (or->path_type == OSPF_PATH_TYPE1_EXTERNAL |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1243 | || or->path_type == OSPF_PATH_TYPE2_EXTERNAL) |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1244 | return ospf->distance_external; |
paul | cf795c5 | 2003-06-19 02:13:25 +0000 | [diff] [blame] | 1245 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 1246 | if (ospf->distance_all) |
| 1247 | return ospf->distance_all; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1248 | |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | void |
| 1253 | ospf_zebra_init () |
| 1254 | { |
| 1255 | /* Allocate zebra structure. */ |
| 1256 | zclient = zclient_new (); |
| 1257 | zclient_init (zclient, ZEBRA_ROUTE_OSPF); |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 1258 | zclient->router_id_update = ospf_router_id_update_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1259 | zclient->interface_add = ospf_interface_add; |
| 1260 | zclient->interface_delete = ospf_interface_delete; |
| 1261 | zclient->interface_up = ospf_interface_state_up; |
| 1262 | zclient->interface_down = ospf_interface_state_down; |
| 1263 | zclient->interface_address_add = ospf_interface_address_add; |
| 1264 | zclient->interface_address_delete = ospf_interface_address_delete; |
| 1265 | zclient->ipv4_route_add = ospf_zebra_read_ipv4; |
| 1266 | zclient->ipv4_route_delete = ospf_zebra_read_ipv4; |
| 1267 | |
| 1268 | access_list_add_hook (ospf_filter_update); |
| 1269 | access_list_delete_hook (ospf_filter_update); |
hasso | dd669bb | 2004-05-10 07:43:59 +0000 | [diff] [blame] | 1270 | prefix_list_add_hook (ospf_prefix_list_update); |
| 1271 | prefix_list_delete_hook (ospf_prefix_list_update); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1272 | } |