paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "vty.h" |
| 26 | #include "command.h" |
| 27 | #include "prefix.h" |
| 28 | #include "stream.h" |
| 29 | #include "zclient.h" |
| 30 | #include "memory.h" |
| 31 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 32 | #include "ospf6_proto.h" |
| 33 | #include "ospf6_top.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 34 | #include "ospf6_interface.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 35 | #include "ospf6_route.h" |
| 36 | #include "ospf6_lsa.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 37 | #include "ospf6_lsdb.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 38 | #include "ospf6_asbr.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 39 | #include "ospf6_zebra.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 40 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 41 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 42 | unsigned char conf_debug_ospf6_zebra = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 43 | |
| 44 | /* information about zebra. */ |
| 45 | struct zclient *zclient = NULL; |
| 46 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 47 | struct in_addr router_id_zebra; |
| 48 | |
| 49 | /* Router-id update message from zebra. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 50 | static int |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 51 | ospf6_router_id_update_zebra (int command, struct zclient *zclient, |
| 52 | zebra_size_t length) |
| 53 | { |
| 54 | struct prefix router_id; |
| 55 | struct ospf6 *o = ospf6; |
| 56 | |
| 57 | zebra_router_id_update_read(zclient->ibuf,&router_id); |
| 58 | router_id_zebra = router_id.u.prefix4; |
| 59 | |
jardin | c1ba9e8 | 2005-03-02 22:43:26 +0000 | [diff] [blame] | 60 | if (o == NULL) |
| 61 | return 0; |
| 62 | |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 63 | if (o->router_id == 0) |
| 64 | o->router_id = (u_int32_t) router_id_zebra.s_addr; |
| 65 | |
| 66 | return 0; |
| 67 | } |
| 68 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | /* redistribute function */ |
| 70 | void |
| 71 | ospf6_zebra_redistribute (int type) |
| 72 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 73 | if (zclient->redist[type]) |
| 74 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 75 | zclient->redist[type] = 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | if (zclient->sock > 0) |
ajs | 634f9ea | 2005-04-11 15:51:40 +0000 | [diff] [blame] | 77 | zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | void |
| 81 | ospf6_zebra_no_redistribute (int type) |
| 82 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 83 | if (! zclient->redist[type]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | zclient->redist[type] = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 86 | if (zclient->sock > 0) |
ajs | 634f9ea | 2005-04-11 15:51:40 +0000 | [diff] [blame] | 87 | zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 88 | } |
| 89 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | /* Inteface addition message from zebra. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 91 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 92 | ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length) |
| 93 | { |
| 94 | struct interface *ifp; |
| 95 | |
| 96 | ifp = zebra_interface_add_read (zclient->ibuf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 97 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 98 | zlog_debug ("Zebra Interface add: %s index %d mtu %d", |
| 99 | ifp->name, ifp->ifindex, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | ospf6_interface_if_add (ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | return 0; |
| 102 | } |
| 103 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 104 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 105 | ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length) |
| 106 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 107 | struct interface *ifp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 109 | if (!(ifp = zebra_interface_state_read(zclient->ibuf))) |
| 110 | return 0; |
| 111 | |
| 112 | if (if_is_up (ifp)) |
| 113 | zlog_warn ("Zebra: got delete of %s, but interface is still up", ifp->name); |
| 114 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 115 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 116 | zlog_debug ("Zebra Interface delete: %s index %d mtu %d", |
| 117 | ifp->name, ifp->ifindex, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 118 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 119 | #if 0 |
| 120 | /* Why is this commented out? */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 121 | ospf6_interface_if_del (ifp); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 122 | #endif /*0*/ |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 123 | |
| 124 | ifp->ifindex = IFINDEX_INTERNAL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 125 | return 0; |
| 126 | } |
| 127 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 128 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | ospf6_zebra_if_state_update (int command, struct zclient *zclient, |
| 130 | zebra_size_t length) |
| 131 | { |
| 132 | struct interface *ifp; |
| 133 | |
| 134 | ifp = zebra_interface_state_read (zclient->ibuf); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 135 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 136 | zlog_debug ("Zebra Interface state change: " |
Stephen Hemminger | 30d2059 | 2009-07-28 11:58:51 +0100 | [diff] [blame] | 137 | "%s index %d flags %llx metric %d mtu %d", |
| 138 | ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, |
| 139 | ifp->metric, ifp->mtu6); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | |
| 141 | ospf6_interface_state_update (ifp); |
| 142 | return 0; |
| 143 | } |
| 144 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 145 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | ospf6_zebra_if_address_update_add (int command, struct zclient *zclient, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 147 | zebra_size_t length) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 148 | { |
| 149 | struct connected *c; |
| 150 | char buf[128]; |
| 151 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 152 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 153 | if (c == NULL) |
| 154 | return 0; |
| 155 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 156 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 157 | zlog_debug ("Zebra Interface address add: %s %5s %s/%d", |
| 158 | c->ifp->name, prefix_family_str (c->address), |
| 159 | inet_ntop (c->address->family, &c->address->u.prefix, |
| 160 | buf, sizeof (buf)), c->address->prefixlen); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
| 162 | if (c->address->family == AF_INET6) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 163 | ospf6_interface_connected_route_update (c->ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 164 | |
| 165 | return 0; |
| 166 | } |
| 167 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 168 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | ospf6_zebra_if_address_update_delete (int command, struct zclient *zclient, |
| 170 | zebra_size_t length) |
| 171 | { |
| 172 | struct connected *c; |
| 173 | char buf[128]; |
| 174 | |
paul | 0a58935 | 2004-05-08 11:48:26 +0000 | [diff] [blame] | 175 | c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 176 | if (c == NULL) |
| 177 | return 0; |
| 178 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 179 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 180 | zlog_debug ("Zebra Interface address delete: %s %5s %s/%d", |
| 181 | c->ifp->name, prefix_family_str (c->address), |
| 182 | inet_ntop (c->address->family, &c->address->u.prefix, |
| 183 | buf, sizeof (buf)), c->address->prefixlen); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | |
| 185 | if (c->address->family == AF_INET6) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 186 | ospf6_interface_connected_route_update (c->ifp); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 191 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 192 | ospf6_zebra_read_ipv6 (int command, struct zclient *zclient, |
| 193 | zebra_size_t length) |
| 194 | { |
| 195 | struct stream *s; |
| 196 | struct zapi_ipv6 api; |
| 197 | unsigned long ifindex; |
| 198 | struct prefix_ipv6 p; |
| 199 | struct in6_addr *nexthop; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | |
| 201 | s = zclient->ibuf; |
| 202 | ifindex = 0; |
| 203 | nexthop = NULL; |
| 204 | memset (&api, 0, sizeof (api)); |
| 205 | |
| 206 | /* Type, flags, message. */ |
| 207 | api.type = stream_getc (s); |
| 208 | api.flags = stream_getc (s); |
| 209 | api.message = stream_getc (s); |
| 210 | |
| 211 | /* IPv6 prefix. */ |
| 212 | memset (&p, 0, sizeof (struct prefix_ipv6)); |
| 213 | p.family = AF_INET6; |
| 214 | p.prefixlen = stream_getc (s); |
| 215 | stream_get (&p.prefix, s, PSIZE (p.prefixlen)); |
| 216 | |
| 217 | /* Nexthop, ifindex, distance, metric. */ |
| 218 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) |
| 219 | { |
| 220 | api.nexthop_num = stream_getc (s); |
| 221 | nexthop = (struct in6_addr *) |
| 222 | malloc (api.nexthop_num * sizeof (struct in6_addr)); |
| 223 | stream_get (nexthop, s, api.nexthop_num * sizeof (struct in6_addr)); |
| 224 | } |
| 225 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) |
| 226 | { |
| 227 | api.ifindex_num = stream_getc (s); |
| 228 | ifindex = stream_getl (s); |
| 229 | } |
| 230 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE)) |
| 231 | api.distance = stream_getc (s); |
| 232 | else |
| 233 | api.distance = 0; |
| 234 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC)) |
| 235 | api.metric = stream_getl (s); |
| 236 | else |
| 237 | api.metric = 0; |
| 238 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 239 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 240 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 241 | char prefixstr[128], nexthopstr[128]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 242 | prefix2str ((struct prefix *)&p, prefixstr, sizeof (prefixstr)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 243 | if (nexthop) |
| 244 | inet_ntop (AF_INET6, nexthop, nexthopstr, sizeof (nexthopstr)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 245 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 246 | snprintf (nexthopstr, sizeof (nexthopstr), "::"); |
| 247 | |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 248 | zlog_debug ("Zebra Receive route %s: %s %s nexthop %s ifindex %ld", |
| 249 | (command == ZEBRA_IPV6_ROUTE_ADD ? "add" : "delete"), |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 250 | zebra_route_string(api.type), prefixstr, nexthopstr, ifindex); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | if (command == ZEBRA_IPV6_ROUTE_ADD) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 254 | ospf6_asbr_redistribute_add (api.type, ifindex, (struct prefix *) &p, |
| 255 | api.nexthop_num, nexthop); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 256 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 257 | ospf6_asbr_redistribute_remove (api.type, ifindex, (struct prefix *) &p); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 258 | |
| 259 | if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) |
| 260 | free (nexthop); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 265 | |
| 266 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 267 | |
| 268 | DEFUN (show_zebra, |
| 269 | show_zebra_cmd, |
| 270 | "show zebra", |
| 271 | SHOW_STR |
| 272 | "Zebra information\n") |
| 273 | { |
| 274 | int i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 275 | if (zclient == NULL) |
| 276 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 277 | vty_out (vty, "Not connected to zebra%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 278 | return CMD_SUCCESS; |
| 279 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 280 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 281 | vty_out (vty, "Zebra Infomation%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 282 | vty_out (vty, " enable: %d fail: %d%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 283 | zclient->enable, zclient->fail, VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 284 | vty_out (vty, " redistribute default: %d%s", zclient->redist_default, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 285 | VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 286 | vty_out (vty, " redistribute:"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 287 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 288 | { |
| 289 | if (zclient->redist[i]) |
ajs | f52d13c | 2005-10-01 17:38:06 +0000 | [diff] [blame] | 290 | vty_out (vty, " %s", zebra_route_string(i)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 291 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 292 | vty_out (vty, "%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 293 | return CMD_SUCCESS; |
| 294 | } |
| 295 | |
| 296 | DEFUN (router_zebra, |
| 297 | router_zebra_cmd, |
| 298 | "router zebra", |
| 299 | "Enable a routing process\n" |
| 300 | "Make connection to zebra daemon\n") |
| 301 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 302 | vty->node = ZEBRA_NODE; |
| 303 | zclient->enable = 1; |
| 304 | zclient_start (zclient); |
| 305 | return CMD_SUCCESS; |
| 306 | } |
| 307 | |
| 308 | DEFUN (no_router_zebra, |
| 309 | no_router_zebra_cmd, |
| 310 | "no router zebra", |
| 311 | NO_STR |
| 312 | "Configure routing process\n" |
| 313 | "Disable connection to zebra daemon\n") |
| 314 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 315 | zclient->enable = 0; |
| 316 | zclient_stop (zclient); |
| 317 | return CMD_SUCCESS; |
| 318 | } |
| 319 | |
| 320 | /* Zebra configuration write function. */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 321 | static int |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 322 | config_write_ospf6_zebra (struct vty *vty) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 323 | { |
| 324 | if (! zclient->enable) |
| 325 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 326 | vty_out (vty, "no router zebra%s", VNL); |
| 327 | vty_out (vty, "!%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 328 | } |
| 329 | else if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) |
| 330 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 331 | vty_out (vty, "router zebra%s", VNL); |
| 332 | vty_out (vty, " no redistribute ospf6%s", VNL); |
| 333 | vty_out (vty, "!%s", VNL); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 334 | } |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | /* Zebra node structure. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 339 | static struct cmd_node zebra_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 340 | { |
| 341 | ZEBRA_NODE, |
| 342 | "%s(config-zebra)# ", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 343 | }; |
| 344 | |
| 345 | #define ADD 0 |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 346 | #define REM 1 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 347 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 348 | ospf6_zebra_route_update (int type, struct ospf6_route *request) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 349 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 350 | struct zapi_ipv6 api; |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 351 | char buf[64]; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 352 | int nhcount; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 353 | struct in6_addr **nexthops; |
| 354 | unsigned int *ifindexes; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 355 | int i, ret = 0; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 356 | struct prefix_ipv6 *dest; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 357 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 358 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 359 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 360 | prefix2str (&request->prefix, buf, sizeof (buf)); |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 361 | zlog_debug ("Send %s route: %s", |
| 362 | (type == REM ? "remove" : "add"), buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | if (zclient->sock < 0) |
| 366 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 367 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 368 | zlog_debug (" Not connected to Zebra"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 369 | return; |
| 370 | } |
| 371 | |
| 372 | if (request->path.origin.adv_router == ospf6->router_id && |
| 373 | (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1 || |
| 374 | request->path.type == OSPF6_PATH_TYPE_EXTERNAL2)) |
| 375 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 376 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 377 | zlog_debug (" Ignore self-originated external route"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 378 | return; |
| 379 | } |
| 380 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 381 | /* If removing is the best path and if there's another path, |
| 382 | treat this request as add the secondary path */ |
| 383 | if (type == REM && ospf6_route_is_best (request) && |
| 384 | request->next && ospf6_route_is_same (request, request->next)) |
| 385 | { |
| 386 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 387 | zlog_debug (" Best-path removal resulted Sencondary addition"); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 388 | type = ADD; |
| 389 | request = request->next; |
| 390 | } |
| 391 | |
| 392 | /* Only the best path will be sent to zebra. */ |
| 393 | if (! ospf6_route_is_best (request)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 394 | { |
| 395 | /* this is not preferred best route, ignore */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 396 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 397 | zlog_debug (" Ignore non-best route"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 398 | return; |
| 399 | } |
| 400 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 401 | nhcount = 0; |
| 402 | for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 403 | if (ospf6_nexthop_is_set (&request->nexthop[i])) |
| 404 | nhcount++; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 405 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 406 | if (nhcount == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 407 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 408 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 409 | zlog_debug (" No nexthop, ignore"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 410 | return; |
| 411 | } |
| 412 | |
| 413 | /* allocate memory for nexthop_list */ |
| 414 | nexthops = XCALLOC (MTYPE_OSPF6_OTHER, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 415 | nhcount * sizeof (struct in6_addr *)); |
| 416 | if (nexthops == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 417 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 418 | zlog_warn ("Can't send route to zebra: malloc failed"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 419 | return; |
| 420 | } |
| 421 | |
| 422 | /* allocate memory for ifindex_list */ |
| 423 | ifindexes = XCALLOC (MTYPE_OSPF6_OTHER, |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 424 | nhcount * sizeof (unsigned int)); |
| 425 | if (ifindexes == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 427 | zlog_warn ("Can't send route to zebra: malloc failed"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 428 | XFREE (MTYPE_OSPF6_OTHER, nexthops); |
| 429 | return; |
| 430 | } |
| 431 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 432 | for (i = 0; i < nhcount; i++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 433 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 434 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 435 | { |
| 436 | char ifname[IFNAMSIZ]; |
| 437 | inet_ntop (AF_INET6, &request->nexthop[i].address, |
| 438 | buf, sizeof (buf)); |
| 439 | if (!if_indextoname(request->nexthop[i].ifindex, ifname)) |
| 440 | strlcpy(ifname, "unknown", sizeof(ifname)); |
| 441 | zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname, |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 442 | request->nexthop[i].ifindex); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 443 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 444 | nexthops[i] = &request->nexthop[i].address; |
| 445 | ifindexes[i] = request->nexthop[i].ifindex; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | api.type = ZEBRA_ROUTE_OSPF6; |
| 449 | api.flags = 0; |
| 450 | api.message = 0; |
| 451 | SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 452 | api.nexthop_num = nhcount; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 453 | api.nexthop = nexthops; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 454 | SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX); |
| 455 | api.ifindex_num = nhcount; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 456 | api.ifindex = ifindexes; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 457 | SET_FLAG (api.message, ZAPI_MESSAGE_METRIC); |
| 458 | api.metric = (request->path.metric_type == 2 ? |
| 459 | request->path.cost_e2 : request->path.cost); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 460 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 461 | dest = (struct prefix_ipv6 *) &request->prefix; |
| 462 | if (type == REM) |
| 463 | ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, &api); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 464 | else |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 465 | ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 466 | |
| 467 | if (ret < 0) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 468 | zlog_err ("zapi_ipv6_route() %s failed: %s", |
ajs | 6099b3b | 2004-11-20 02:06:59 +0000 | [diff] [blame] | 469 | (type == REM ? "delete" : "add"), safe_strerror (errno)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 470 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 471 | XFREE (MTYPE_OSPF6_OTHER, nexthops); |
| 472 | XFREE (MTYPE_OSPF6_OTHER, ifindexes); |
| 473 | |
| 474 | return; |
| 475 | } |
| 476 | |
| 477 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 478 | ospf6_zebra_route_update_add (struct ospf6_route *request) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 479 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 480 | if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) |
| 481 | { |
| 482 | ospf6->route_table->hook_add = NULL; |
| 483 | ospf6->route_table->hook_remove = NULL; |
| 484 | return; |
| 485 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 486 | ospf6_zebra_route_update (ADD, request); |
| 487 | } |
| 488 | |
| 489 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 490 | ospf6_zebra_route_update_remove (struct ospf6_route *request) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 491 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 492 | if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 493 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 494 | ospf6->route_table->hook_add = NULL; |
| 495 | ospf6->route_table->hook_remove = NULL; |
| 496 | return; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 497 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 498 | ospf6_zebra_route_update (REM, request); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 499 | } |
| 500 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 501 | DEFUN (redistribute_ospf6, |
| 502 | redistribute_ospf6_cmd, |
| 503 | "redistribute ospf6", |
| 504 | "Redistribute control\n" |
| 505 | "OSPF6 route\n") |
| 506 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 507 | struct ospf6_route *route; |
| 508 | |
| 509 | if (zclient->redist[ZEBRA_ROUTE_OSPF6]) |
| 510 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 511 | |
| 512 | zclient->redist[ZEBRA_ROUTE_OSPF6] = 1; |
| 513 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 514 | if (ospf6 == NULL) |
| 515 | return CMD_SUCCESS; |
| 516 | |
| 517 | /* send ospf6 route to zebra route table */ |
| 518 | for (route = ospf6_route_head (ospf6->route_table); route; |
| 519 | route = ospf6_route_next (route)) |
| 520 | ospf6_zebra_route_update_add (route); |
| 521 | |
| 522 | ospf6->route_table->hook_add = ospf6_zebra_route_update_add; |
| 523 | ospf6->route_table->hook_remove = ospf6_zebra_route_update_remove; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 524 | |
| 525 | return CMD_SUCCESS; |
| 526 | } |
| 527 | |
| 528 | DEFUN (no_redistribute_ospf6, |
| 529 | no_redistribute_ospf6_cmd, |
| 530 | "no redistribute ospf6", |
| 531 | NO_STR |
| 532 | "Redistribute control\n" |
| 533 | "OSPF6 route\n") |
| 534 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 535 | struct ospf6_route *route; |
| 536 | |
| 537 | if (! zclient->redist[ZEBRA_ROUTE_OSPF6]) |
| 538 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 539 | |
| 540 | zclient->redist[ZEBRA_ROUTE_OSPF6] = 0; |
| 541 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 542 | if (ospf6 == NULL) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 543 | return CMD_SUCCESS; |
| 544 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 545 | ospf6->route_table->hook_add = NULL; |
| 546 | ospf6->route_table->hook_remove = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 548 | /* withdraw ospf6 route from zebra route table */ |
| 549 | for (route = ospf6_route_head (ospf6->route_table); route; |
| 550 | route = ospf6_route_next (route)) |
| 551 | ospf6_zebra_route_update_remove (route); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 552 | |
| 553 | return CMD_SUCCESS; |
| 554 | } |
| 555 | |
| 556 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 557 | ospf6_zebra_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 558 | { |
| 559 | /* Allocate zebra structure. */ |
| 560 | zclient = zclient_new (); |
| 561 | zclient_init (zclient, ZEBRA_ROUTE_OSPF6); |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 562 | zclient->router_id_update = ospf6_router_id_update_zebra; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | zclient->interface_add = ospf6_zebra_if_add; |
| 564 | zclient->interface_delete = ospf6_zebra_if_del; |
| 565 | zclient->interface_up = ospf6_zebra_if_state_update; |
| 566 | zclient->interface_down = ospf6_zebra_if_state_update; |
| 567 | zclient->interface_address_add = ospf6_zebra_if_address_update_add; |
| 568 | zclient->interface_address_delete = ospf6_zebra_if_address_update_delete; |
| 569 | zclient->ipv4_route_add = NULL; |
| 570 | zclient->ipv4_route_delete = NULL; |
| 571 | zclient->ipv6_route_add = ospf6_zebra_read_ipv6; |
| 572 | zclient->ipv6_route_delete = ospf6_zebra_read_ipv6; |
| 573 | |
| 574 | /* redistribute connected route by default */ |
| 575 | /* ospf6_zebra_redistribute (ZEBRA_ROUTE_CONNECT); */ |
| 576 | |
| 577 | /* Install zebra node. */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 578 | install_node (&zebra_node, config_write_ospf6_zebra); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 579 | |
| 580 | /* Install command element for zebra node. */ |
| 581 | install_element (VIEW_NODE, &show_zebra_cmd); |
| 582 | install_element (ENABLE_NODE, &show_zebra_cmd); |
| 583 | install_element (CONFIG_NODE, &router_zebra_cmd); |
| 584 | install_element (CONFIG_NODE, &no_router_zebra_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 585 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 586 | install_default (ZEBRA_NODE); |
| 587 | install_element (ZEBRA_NODE, &redistribute_ospf6_cmd); |
| 588 | install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd); |
| 589 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 590 | return; |
| 591 | } |
| 592 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 593 | /* Debug */ |
| 594 | |
| 595 | DEFUN (debug_ospf6_zebra_sendrecv, |
| 596 | debug_ospf6_zebra_sendrecv_cmd, |
| 597 | "debug ospf6 zebra (send|recv)", |
| 598 | DEBUG_STR |
| 599 | OSPF6_STR |
| 600 | "Debug connection between zebra\n" |
| 601 | "Debug Sending zebra\n" |
| 602 | "Debug Receiving zebra\n" |
| 603 | ) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 605 | unsigned char level = 0; |
| 606 | |
| 607 | if (argc) |
| 608 | { |
| 609 | if (! strncmp (argv[0], "s", 1)) |
| 610 | level = OSPF6_DEBUG_ZEBRA_SEND; |
| 611 | else if (! strncmp (argv[0], "r", 1)) |
| 612 | level = OSPF6_DEBUG_ZEBRA_RECV; |
| 613 | } |
| 614 | else |
| 615 | level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV; |
| 616 | |
| 617 | OSPF6_DEBUG_ZEBRA_ON (level); |
| 618 | return CMD_SUCCESS; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 619 | } |
| 620 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 621 | ALIAS (debug_ospf6_zebra_sendrecv, |
| 622 | debug_ospf6_zebra_cmd, |
| 623 | "debug ospf6 zebra", |
| 624 | DEBUG_STR |
| 625 | OSPF6_STR |
| 626 | "Debug connection between zebra\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 627 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 628 | |
| 629 | |
| 630 | DEFUN (no_debug_ospf6_zebra_sendrecv, |
| 631 | no_debug_ospf6_zebra_sendrecv_cmd, |
| 632 | "no debug ospf6 zebra (send|recv)", |
| 633 | NO_STR |
| 634 | DEBUG_STR |
| 635 | OSPF6_STR |
| 636 | "Debug connection between zebra\n" |
| 637 | "Debug Sending zebra\n" |
| 638 | "Debug Receiving zebra\n" |
| 639 | ) |
| 640 | { |
| 641 | unsigned char level = 0; |
| 642 | |
| 643 | if (argc) |
| 644 | { |
| 645 | if (! strncmp (argv[0], "s", 1)) |
| 646 | level = OSPF6_DEBUG_ZEBRA_SEND; |
| 647 | else if (! strncmp (argv[0], "r", 1)) |
| 648 | level = OSPF6_DEBUG_ZEBRA_RECV; |
| 649 | } |
| 650 | else |
| 651 | level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV; |
| 652 | |
| 653 | OSPF6_DEBUG_ZEBRA_OFF (level); |
| 654 | return CMD_SUCCESS; |
| 655 | } |
| 656 | |
| 657 | ALIAS (no_debug_ospf6_zebra_sendrecv, |
| 658 | no_debug_ospf6_zebra_cmd, |
| 659 | "no debug ospf6 zebra", |
| 660 | NO_STR |
| 661 | DEBUG_STR |
| 662 | OSPF6_STR |
| 663 | "Debug connection between zebra\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 664 | ) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 665 | |
| 666 | int |
| 667 | config_write_ospf6_debug_zebra (struct vty *vty) |
| 668 | { |
| 669 | if (IS_OSPF6_DEBUG_ZEBRA (SEND) && IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 670 | vty_out (vty, "debug ospf6 zebra%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 671 | else |
| 672 | { |
| 673 | if (IS_OSPF6_DEBUG_ZEBRA (SEND)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 674 | vty_out (vty, "debug ospf6 zebra send%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 675 | if (IS_OSPF6_DEBUG_ZEBRA (RECV)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 676 | vty_out (vty, "debug ospf6 zebra recv%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 677 | } |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 682 | install_element_ospf6_debug_zebra (void) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 683 | { |
| 684 | install_element (ENABLE_NODE, &debug_ospf6_zebra_cmd); |
| 685 | install_element (ENABLE_NODE, &no_debug_ospf6_zebra_cmd); |
| 686 | install_element (ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd); |
| 687 | install_element (ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd); |
| 688 | install_element (CONFIG_NODE, &debug_ospf6_zebra_cmd); |
| 689 | install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd); |
| 690 | install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd); |
| 691 | install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd); |
| 692 | } |
| 693 | |
| 694 | |