paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Route map function of bgpd. |
| 2 | Copyright (C) 1998, 1999 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
| 21 | #include <zebra.h> |
| 22 | |
| 23 | #include "prefix.h" |
| 24 | #include "filter.h" |
| 25 | #include "routemap.h" |
| 26 | #include "command.h" |
| 27 | #include "linklist.h" |
| 28 | #include "plist.h" |
| 29 | #include "memory.h" |
| 30 | #include "log.h" |
Jeremy Jackson | 25f4588 | 2009-01-12 16:06:12 -0500 | [diff] [blame] | 31 | #ifdef HAVE_LIBPCREPOSIX |
| 32 | # include <pcreposix.h> |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 33 | #else |
Jeremy Jackson | 25f4588 | 2009-01-12 16:06:12 -0500 | [diff] [blame] | 34 | # ifdef HAVE_GNU_REGEX |
| 35 | # include <regex.h> |
| 36 | # else |
| 37 | # include "regex-gnu.h" |
| 38 | # endif /* HAVE_GNU_REGEX */ |
| 39 | #endif /* HAVE_LIBPCREPOSIX */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | #include "buffer.h" |
| 41 | #include "sockunion.h" |
| 42 | |
| 43 | #include "bgpd/bgpd.h" |
| 44 | #include "bgpd/bgp_table.h" |
| 45 | #include "bgpd/bgp_attr.h" |
| 46 | #include "bgpd/bgp_aspath.h" |
| 47 | #include "bgpd/bgp_route.h" |
| 48 | #include "bgpd/bgp_regex.h" |
| 49 | #include "bgpd/bgp_community.h" |
| 50 | #include "bgpd/bgp_clist.h" |
| 51 | #include "bgpd/bgp_filter.h" |
| 52 | #include "bgpd/bgp_mplsvpn.h" |
| 53 | #include "bgpd/bgp_ecommunity.h" |
Paul Jakma | 320da87 | 2008-07-02 13:40:33 +0000 | [diff] [blame] | 54 | #include "bgpd/bgp_vty.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 55 | |
| 56 | /* Memo of route-map commands. |
| 57 | |
| 58 | o Cisco route-map |
| 59 | |
| 60 | match as-path : Done |
| 61 | community : Done |
| 62 | interface : Not yet |
| 63 | ip address : Done |
| 64 | ip next-hop : Done |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 65 | ip route-source : Done |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 66 | ip prefix-list : Done |
| 67 | ipv6 address : Done |
| 68 | ipv6 next-hop : Done |
| 69 | ipv6 route-source: (This will not be implemented by bgpd) |
| 70 | ipv6 prefix-list : Done |
| 71 | length : (This will not be implemented by bgpd) |
| 72 | metric : Done |
| 73 | route-type : (This will not be implemented by bgpd) |
| 74 | tag : (This will not be implemented by bgpd) |
| 75 | |
| 76 | set as-path prepend : Done |
| 77 | as-path tag : Not yet |
| 78 | automatic-tag : (This will not be implemented by bgpd) |
| 79 | community : Done |
| 80 | comm-list : Not yet |
| 81 | dampning : Not yet |
| 82 | default : (This will not be implemented by bgpd) |
| 83 | interface : (This will not be implemented by bgpd) |
| 84 | ip default : (This will not be implemented by bgpd) |
| 85 | ip next-hop : Done |
| 86 | ip precedence : (This will not be implemented by bgpd) |
| 87 | ip tos : (This will not be implemented by bgpd) |
| 88 | level : (This will not be implemented by bgpd) |
| 89 | local-preference : Done |
| 90 | metric : Done |
| 91 | metric-type : Not yet |
| 92 | origin : Done |
| 93 | tag : (This will not be implemented by bgpd) |
| 94 | weight : Done |
| 95 | |
| 96 | o Local extention |
| 97 | |
| 98 | set ipv6 next-hop global: Done |
| 99 | set ipv6 next-hop local : Done |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 100 | set as-path exclude : Done |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | |
| 102 | */ |
| 103 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 104 | /* 'match peer (A.B.C.D|X:X::X:X)' */ |
| 105 | |
| 106 | /* Compares the peer specified in the 'match peer' clause with the peer |
| 107 | received in bgp_info->peer. If it is the same, or if the peer structure |
| 108 | received is a peer_group containing it, returns RMAP_MATCH. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 109 | static route_map_result_t |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 110 | route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type, |
| 111 | void *object) |
| 112 | { |
| 113 | union sockunion *su; |
| 114 | union sockunion *su2; |
| 115 | struct peer_group *group; |
| 116 | struct peer *peer; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 117 | struct listnode *node, *nnode; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 118 | |
| 119 | if (type == RMAP_BGP) |
| 120 | { |
| 121 | su = rule; |
| 122 | peer = ((struct bgp_info *) object)->peer; |
| 123 | |
| 124 | if ( ! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT) && |
| 125 | ! CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_EXPORT) ) |
| 126 | return RMAP_NOMATCH; |
| 127 | |
| 128 | /* If su='0.0.0.0' (command 'match peer local'), and it's a NETWORK, |
| 129 | REDISTRIBUTE or DEFAULT_GENERATED route => return RMAP_MATCH */ |
| 130 | su2 = sockunion_str2su ("0.0.0.0"); |
| 131 | if ( sockunion_same (su, su2) ) |
| 132 | { |
paul | 22db9de | 2005-05-19 01:50:11 +0000 | [diff] [blame] | 133 | int ret; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 134 | if ( CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_NETWORK) || |
| 135 | CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE) || |
| 136 | CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_DEFAULT)) |
paul | 22db9de | 2005-05-19 01:50:11 +0000 | [diff] [blame] | 137 | ret = RMAP_MATCH; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 138 | else |
paul | 22db9de | 2005-05-19 01:50:11 +0000 | [diff] [blame] | 139 | ret = RMAP_NOMATCH; |
| 140 | |
| 141 | sockunion_free (su2); |
| 142 | return ret; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 143 | } |
paul | 22db9de | 2005-05-19 01:50:11 +0000 | [diff] [blame] | 144 | sockunion_free (su2); |
| 145 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 146 | if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
| 147 | { |
| 148 | if (sockunion_same (su, &peer->su)) |
| 149 | return RMAP_MATCH; |
| 150 | |
| 151 | return RMAP_NOMATCH; |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | group = peer->group; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 156 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 157 | { |
| 158 | if (sockunion_same (su, &peer->su)) |
| 159 | return RMAP_MATCH; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 160 | } |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 161 | return RMAP_NOMATCH; |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | return RMAP_NOMATCH; |
| 165 | } |
| 166 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 167 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 168 | route_match_peer_compile (const char *arg) |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 169 | { |
| 170 | union sockunion *su; |
| 171 | int ret; |
| 172 | |
| 173 | su = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union sockunion)); |
| 174 | |
| 175 | ret = str2sockunion ( (arg)? arg : "0.0.0.0", su); |
| 176 | if (ret < 0) { |
| 177 | XFREE (MTYPE_ROUTE_MAP_COMPILED, su); |
| 178 | return NULL; |
| 179 | } |
| 180 | |
| 181 | return su; |
| 182 | } |
| 183 | |
| 184 | /* Free route map's compiled `ip address' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 185 | static void |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 186 | route_match_peer_free (void *rule) |
| 187 | { |
| 188 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 189 | } |
| 190 | |
| 191 | /* Route map commands for ip address matching. */ |
| 192 | struct route_map_rule_cmd route_match_peer_cmd = |
| 193 | { |
| 194 | "peer", |
| 195 | route_match_peer, |
| 196 | route_match_peer_compile, |
| 197 | route_match_peer_free |
| 198 | }; |
| 199 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | /* `match ip address IP_ACCESS_LIST' */ |
| 201 | |
| 202 | /* Match function should return 1 if match is success else return |
| 203 | zero. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 204 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | route_match_ip_address (void *rule, struct prefix *prefix, |
| 206 | route_map_object_t type, void *object) |
| 207 | { |
| 208 | struct access_list *alist; |
| 209 | /* struct prefix_ipv4 match; */ |
| 210 | |
| 211 | if (type == RMAP_BGP) |
| 212 | { |
| 213 | alist = access_list_lookup (AFI_IP, (char *) rule); |
| 214 | if (alist == NULL) |
| 215 | return RMAP_NOMATCH; |
| 216 | |
| 217 | return (access_list_apply (alist, prefix) == FILTER_DENY ? |
| 218 | RMAP_NOMATCH : RMAP_MATCH); |
| 219 | } |
| 220 | return RMAP_NOMATCH; |
| 221 | } |
| 222 | |
| 223 | /* Route map `ip address' match statement. `arg' should be |
| 224 | access-list name. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 225 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 226 | route_match_ip_address_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | { |
| 228 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 229 | } |
| 230 | |
| 231 | /* Free route map's compiled `ip address' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 232 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 233 | route_match_ip_address_free (void *rule) |
| 234 | { |
| 235 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 236 | } |
| 237 | |
| 238 | /* Route map commands for ip address matching. */ |
| 239 | struct route_map_rule_cmd route_match_ip_address_cmd = |
| 240 | { |
| 241 | "ip address", |
| 242 | route_match_ip_address, |
| 243 | route_match_ip_address_compile, |
| 244 | route_match_ip_address_free |
| 245 | }; |
| 246 | |
| 247 | /* `match ip next-hop IP_ADDRESS' */ |
| 248 | |
| 249 | /* Match function return 1 if match is success else return zero. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 250 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 251 | route_match_ip_next_hop (void *rule, struct prefix *prefix, |
| 252 | route_map_object_t type, void *object) |
| 253 | { |
| 254 | struct access_list *alist; |
| 255 | struct bgp_info *bgp_info; |
| 256 | struct prefix_ipv4 p; |
| 257 | |
| 258 | if (type == RMAP_BGP) |
| 259 | { |
| 260 | bgp_info = object; |
| 261 | p.family = AF_INET; |
| 262 | p.prefix = bgp_info->attr->nexthop; |
| 263 | p.prefixlen = IPV4_MAX_BITLEN; |
| 264 | |
| 265 | alist = access_list_lookup (AFI_IP, (char *) rule); |
| 266 | if (alist == NULL) |
| 267 | return RMAP_NOMATCH; |
| 268 | |
| 269 | return (access_list_apply (alist, &p) == FILTER_DENY ? |
| 270 | RMAP_NOMATCH : RMAP_MATCH); |
| 271 | } |
| 272 | return RMAP_NOMATCH; |
| 273 | } |
| 274 | |
| 275 | /* Route map `ip next-hop' match statement. `arg' is |
| 276 | access-list name. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 277 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 278 | route_match_ip_next_hop_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 279 | { |
| 280 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 281 | } |
| 282 | |
| 283 | /* Free route map's compiled `ip address' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 284 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 285 | route_match_ip_next_hop_free (void *rule) |
| 286 | { |
| 287 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 288 | } |
| 289 | |
| 290 | /* Route map commands for ip next-hop matching. */ |
| 291 | struct route_map_rule_cmd route_match_ip_next_hop_cmd = |
| 292 | { |
| 293 | "ip next-hop", |
| 294 | route_match_ip_next_hop, |
| 295 | route_match_ip_next_hop_compile, |
| 296 | route_match_ip_next_hop_free |
| 297 | }; |
| 298 | |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 299 | /* `match ip route-source ACCESS-LIST' */ |
| 300 | |
| 301 | /* Match function return 1 if match is success else return zero. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 302 | static route_map_result_t |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 303 | route_match_ip_route_source (void *rule, struct prefix *prefix, |
| 304 | route_map_object_t type, void *object) |
| 305 | { |
| 306 | struct access_list *alist; |
| 307 | struct bgp_info *bgp_info; |
| 308 | struct peer *peer; |
| 309 | struct prefix_ipv4 p; |
| 310 | |
| 311 | if (type == RMAP_BGP) |
| 312 | { |
| 313 | bgp_info = object; |
| 314 | peer = bgp_info->peer; |
| 315 | |
| 316 | if (! peer || sockunion_family (&peer->su) != AF_INET) |
| 317 | return RMAP_NOMATCH; |
| 318 | |
| 319 | p.family = AF_INET; |
| 320 | p.prefix = peer->su.sin.sin_addr; |
| 321 | p.prefixlen = IPV4_MAX_BITLEN; |
| 322 | |
| 323 | alist = access_list_lookup (AFI_IP, (char *) rule); |
| 324 | if (alist == NULL) |
| 325 | return RMAP_NOMATCH; |
| 326 | |
| 327 | return (access_list_apply (alist, &p) == FILTER_DENY ? |
| 328 | RMAP_NOMATCH : RMAP_MATCH); |
| 329 | } |
| 330 | return RMAP_NOMATCH; |
| 331 | } |
| 332 | |
| 333 | /* Route map `ip route-source' match statement. `arg' is |
| 334 | access-list name. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 335 | static void * |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 336 | route_match_ip_route_source_compile (const char *arg) |
| 337 | { |
| 338 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 339 | } |
| 340 | |
| 341 | /* Free route map's compiled `ip address' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 342 | static void |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 343 | route_match_ip_route_source_free (void *rule) |
| 344 | { |
| 345 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 346 | } |
| 347 | |
| 348 | /* Route map commands for ip route-source matching. */ |
| 349 | struct route_map_rule_cmd route_match_ip_route_source_cmd = |
| 350 | { |
| 351 | "ip route-source", |
| 352 | route_match_ip_route_source, |
| 353 | route_match_ip_route_source_compile, |
| 354 | route_match_ip_route_source_free |
| 355 | }; |
| 356 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 357 | /* `match ip address prefix-list PREFIX_LIST' */ |
| 358 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 359 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 360 | route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, |
| 361 | route_map_object_t type, void *object) |
| 362 | { |
| 363 | struct prefix_list *plist; |
| 364 | |
| 365 | if (type == RMAP_BGP) |
| 366 | { |
| 367 | plist = prefix_list_lookup (AFI_IP, (char *) rule); |
| 368 | if (plist == NULL) |
| 369 | return RMAP_NOMATCH; |
| 370 | |
| 371 | return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? |
| 372 | RMAP_NOMATCH : RMAP_MATCH); |
| 373 | } |
| 374 | return RMAP_NOMATCH; |
| 375 | } |
| 376 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 377 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 378 | route_match_ip_address_prefix_list_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 379 | { |
| 380 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 381 | } |
| 382 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 383 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | route_match_ip_address_prefix_list_free (void *rule) |
| 385 | { |
| 386 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 387 | } |
| 388 | |
| 389 | struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = |
| 390 | { |
| 391 | "ip address prefix-list", |
| 392 | route_match_ip_address_prefix_list, |
| 393 | route_match_ip_address_prefix_list_compile, |
| 394 | route_match_ip_address_prefix_list_free |
| 395 | }; |
| 396 | |
| 397 | /* `match ip next-hop prefix-list PREFIX_LIST' */ |
| 398 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 399 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 400 | route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix, |
| 401 | route_map_object_t type, void *object) |
| 402 | { |
| 403 | struct prefix_list *plist; |
| 404 | struct bgp_info *bgp_info; |
| 405 | struct prefix_ipv4 p; |
| 406 | |
| 407 | if (type == RMAP_BGP) |
| 408 | { |
| 409 | bgp_info = object; |
| 410 | p.family = AF_INET; |
| 411 | p.prefix = bgp_info->attr->nexthop; |
| 412 | p.prefixlen = IPV4_MAX_BITLEN; |
| 413 | |
| 414 | plist = prefix_list_lookup (AFI_IP, (char *) rule); |
| 415 | if (plist == NULL) |
| 416 | return RMAP_NOMATCH; |
| 417 | |
| 418 | return (prefix_list_apply (plist, &p) == PREFIX_DENY ? |
| 419 | RMAP_NOMATCH : RMAP_MATCH); |
| 420 | } |
| 421 | return RMAP_NOMATCH; |
| 422 | } |
| 423 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 424 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 425 | route_match_ip_next_hop_prefix_list_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 426 | { |
| 427 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 428 | } |
| 429 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 430 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 431 | route_match_ip_next_hop_prefix_list_free (void *rule) |
| 432 | { |
| 433 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 434 | } |
| 435 | |
| 436 | struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = |
| 437 | { |
| 438 | "ip next-hop prefix-list", |
| 439 | route_match_ip_next_hop_prefix_list, |
| 440 | route_match_ip_next_hop_prefix_list_compile, |
| 441 | route_match_ip_next_hop_prefix_list_free |
| 442 | }; |
| 443 | |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 444 | /* `match ip route-source prefix-list PREFIX_LIST' */ |
| 445 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 446 | static route_map_result_t |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 447 | route_match_ip_route_source_prefix_list (void *rule, struct prefix *prefix, |
| 448 | route_map_object_t type, void *object) |
| 449 | { |
| 450 | struct prefix_list *plist; |
| 451 | struct bgp_info *bgp_info; |
| 452 | struct peer *peer; |
| 453 | struct prefix_ipv4 p; |
| 454 | |
| 455 | if (type == RMAP_BGP) |
| 456 | { |
| 457 | bgp_info = object; |
| 458 | peer = bgp_info->peer; |
| 459 | |
| 460 | if (! peer || sockunion_family (&peer->su) != AF_INET) |
| 461 | return RMAP_NOMATCH; |
| 462 | |
| 463 | p.family = AF_INET; |
| 464 | p.prefix = peer->su.sin.sin_addr; |
| 465 | p.prefixlen = IPV4_MAX_BITLEN; |
| 466 | |
| 467 | plist = prefix_list_lookup (AFI_IP, (char *) rule); |
| 468 | if (plist == NULL) |
| 469 | return RMAP_NOMATCH; |
| 470 | |
| 471 | return (prefix_list_apply (plist, &p) == PREFIX_DENY ? |
| 472 | RMAP_NOMATCH : RMAP_MATCH); |
| 473 | } |
| 474 | return RMAP_NOMATCH; |
| 475 | } |
| 476 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 477 | static void * |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 478 | route_match_ip_route_source_prefix_list_compile (const char *arg) |
| 479 | { |
| 480 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 481 | } |
| 482 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 483 | static void |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 484 | route_match_ip_route_source_prefix_list_free (void *rule) |
| 485 | { |
| 486 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 487 | } |
| 488 | |
| 489 | struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd = |
| 490 | { |
| 491 | "ip route-source prefix-list", |
| 492 | route_match_ip_route_source_prefix_list, |
| 493 | route_match_ip_route_source_prefix_list_compile, |
| 494 | route_match_ip_route_source_prefix_list_free |
| 495 | }; |
| 496 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 497 | /* `match metric METRIC' */ |
| 498 | |
| 499 | /* Match function return 1 if match is success else return zero. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 500 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 501 | route_match_metric (void *rule, struct prefix *prefix, |
| 502 | route_map_object_t type, void *object) |
| 503 | { |
| 504 | u_int32_t *med; |
| 505 | struct bgp_info *bgp_info; |
| 506 | |
| 507 | if (type == RMAP_BGP) |
| 508 | { |
| 509 | med = rule; |
| 510 | bgp_info = object; |
| 511 | |
| 512 | if (bgp_info->attr->med == *med) |
| 513 | return RMAP_MATCH; |
| 514 | else |
| 515 | return RMAP_NOMATCH; |
| 516 | } |
| 517 | return RMAP_NOMATCH; |
| 518 | } |
| 519 | |
| 520 | /* Route map `match metric' match statement. `arg' is MED value */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 521 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 522 | route_match_metric_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | { |
| 524 | u_int32_t *med; |
| 525 | char *endptr = NULL; |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 526 | unsigned long tmpval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 528 | tmpval = strtoul (arg, &endptr, 10); |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 529 | if (*endptr != '\0' || tmpval == ULONG_MAX || tmpval > UINT32_MAX) |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 530 | return NULL; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 531 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 533 | |
| 534 | if (!med) |
| 535 | return med; |
| 536 | |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 537 | *med = tmpval; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 538 | return med; |
| 539 | } |
| 540 | |
| 541 | /* Free route map's compiled `match metric' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 542 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 543 | route_match_metric_free (void *rule) |
| 544 | { |
| 545 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 546 | } |
| 547 | |
| 548 | /* Route map commands for metric matching. */ |
| 549 | struct route_map_rule_cmd route_match_metric_cmd = |
| 550 | { |
| 551 | "metric", |
| 552 | route_match_metric, |
| 553 | route_match_metric_compile, |
| 554 | route_match_metric_free |
| 555 | }; |
| 556 | |
| 557 | /* `match as-path ASPATH' */ |
| 558 | |
| 559 | /* Match function for as-path match. I assume given object is */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 560 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 561 | route_match_aspath (void *rule, struct prefix *prefix, |
| 562 | route_map_object_t type, void *object) |
| 563 | { |
| 564 | |
| 565 | struct as_list *as_list; |
| 566 | struct bgp_info *bgp_info; |
| 567 | |
| 568 | if (type == RMAP_BGP) |
| 569 | { |
| 570 | as_list = as_list_lookup ((char *) rule); |
| 571 | if (as_list == NULL) |
| 572 | return RMAP_NOMATCH; |
| 573 | |
| 574 | bgp_info = object; |
| 575 | |
| 576 | /* Perform match. */ |
| 577 | return ((as_list_apply (as_list, bgp_info->attr->aspath) == AS_FILTER_DENY) ? RMAP_NOMATCH : RMAP_MATCH); |
| 578 | } |
| 579 | return RMAP_NOMATCH; |
| 580 | } |
| 581 | |
| 582 | /* Compile function for as-path match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 583 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 584 | route_match_aspath_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 585 | { |
| 586 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 587 | } |
| 588 | |
| 589 | /* Compile function for as-path match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 590 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 591 | route_match_aspath_free (void *rule) |
| 592 | { |
| 593 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 594 | } |
| 595 | |
| 596 | /* Route map commands for aspath matching. */ |
| 597 | struct route_map_rule_cmd route_match_aspath_cmd = |
| 598 | { |
| 599 | "as-path", |
| 600 | route_match_aspath, |
| 601 | route_match_aspath_compile, |
| 602 | route_match_aspath_free |
| 603 | }; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 604 | |
| 605 | /* `match community COMMUNIY' */ |
| 606 | struct rmap_community |
| 607 | { |
| 608 | char *name; |
| 609 | int exact; |
| 610 | }; |
| 611 | |
| 612 | /* Match function for community match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 613 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 614 | route_match_community (void *rule, struct prefix *prefix, |
| 615 | route_map_object_t type, void *object) |
| 616 | { |
| 617 | struct community_list *list; |
| 618 | struct bgp_info *bgp_info; |
| 619 | struct rmap_community *rcom; |
| 620 | |
| 621 | if (type == RMAP_BGP) |
| 622 | { |
| 623 | bgp_info = object; |
| 624 | rcom = rule; |
| 625 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 626 | list = community_list_lookup (bgp_clist, rcom->name, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | if (! list) |
| 628 | return RMAP_NOMATCH; |
| 629 | |
| 630 | if (rcom->exact) |
| 631 | { |
| 632 | if (community_list_exact_match (bgp_info->attr->community, list)) |
| 633 | return RMAP_MATCH; |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | if (community_list_match (bgp_info->attr->community, list)) |
| 638 | return RMAP_MATCH; |
| 639 | } |
| 640 | } |
| 641 | return RMAP_NOMATCH; |
| 642 | } |
| 643 | |
| 644 | /* Compile function for community match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 645 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 646 | route_match_community_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 647 | { |
| 648 | struct rmap_community *rcom; |
| 649 | int len; |
| 650 | char *p; |
| 651 | |
| 652 | rcom = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_community)); |
| 653 | |
| 654 | p = strchr (arg, ' '); |
| 655 | if (p) |
| 656 | { |
| 657 | len = p - arg; |
| 658 | rcom->name = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1); |
| 659 | memcpy (rcom->name, arg, len); |
| 660 | rcom->exact = 1; |
| 661 | } |
| 662 | else |
| 663 | { |
| 664 | rcom->name = XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 665 | rcom->exact = 0; |
| 666 | } |
| 667 | return rcom; |
| 668 | } |
| 669 | |
| 670 | /* Compile function for community match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 671 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 672 | route_match_community_free (void *rule) |
| 673 | { |
| 674 | struct rmap_community *rcom = rule; |
| 675 | |
| 676 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name); |
| 677 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom); |
| 678 | } |
| 679 | |
| 680 | /* Route map commands for community matching. */ |
| 681 | struct route_map_rule_cmd route_match_community_cmd = |
| 682 | { |
| 683 | "community", |
| 684 | route_match_community, |
| 685 | route_match_community_compile, |
| 686 | route_match_community_free |
| 687 | }; |
| 688 | |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 689 | /* Match function for extcommunity match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 690 | static route_map_result_t |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 691 | route_match_ecommunity (void *rule, struct prefix *prefix, |
| 692 | route_map_object_t type, void *object) |
| 693 | { |
| 694 | struct community_list *list; |
| 695 | struct bgp_info *bgp_info; |
| 696 | |
| 697 | if (type == RMAP_BGP) |
| 698 | { |
| 699 | bgp_info = object; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 700 | |
| 701 | if (!bgp_info->attr->extra) |
| 702 | return RMAP_NOMATCH; |
| 703 | |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 704 | list = community_list_lookup (bgp_clist, (char *) rule, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 705 | EXTCOMMUNITY_LIST_MASTER); |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 706 | if (! list) |
| 707 | return RMAP_NOMATCH; |
| 708 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 709 | if (ecommunity_list_match (bgp_info->attr->extra->ecommunity, list)) |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 710 | return RMAP_MATCH; |
| 711 | } |
| 712 | return RMAP_NOMATCH; |
| 713 | } |
| 714 | |
| 715 | /* Compile function for extcommunity match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 716 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 717 | route_match_ecommunity_compile (const char *arg) |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 718 | { |
| 719 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 720 | } |
| 721 | |
| 722 | /* Compile function for extcommunity match. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 723 | static void |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 724 | route_match_ecommunity_free (void *rule) |
| 725 | { |
| 726 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 727 | } |
| 728 | |
| 729 | /* Route map commands for community matching. */ |
| 730 | struct route_map_rule_cmd route_match_ecommunity_cmd = |
| 731 | { |
| 732 | "extcommunity", |
| 733 | route_match_ecommunity, |
| 734 | route_match_ecommunity_compile, |
| 735 | route_match_ecommunity_free |
| 736 | }; |
| 737 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 738 | /* `match nlri` and `set nlri` are replaced by `address-family ipv4` |
| 739 | and `address-family vpnv4'. */ |
| 740 | |
| 741 | /* `match origin' */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 742 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 743 | route_match_origin (void *rule, struct prefix *prefix, |
| 744 | route_map_object_t type, void *object) |
| 745 | { |
| 746 | u_char *origin; |
| 747 | struct bgp_info *bgp_info; |
| 748 | |
| 749 | if (type == RMAP_BGP) |
| 750 | { |
| 751 | origin = rule; |
| 752 | bgp_info = object; |
| 753 | |
| 754 | if (bgp_info->attr->origin == *origin) |
| 755 | return RMAP_MATCH; |
| 756 | } |
| 757 | |
| 758 | return RMAP_NOMATCH; |
| 759 | } |
| 760 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 761 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 762 | route_match_origin_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 763 | { |
| 764 | u_char *origin; |
| 765 | |
| 766 | origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char)); |
| 767 | |
| 768 | if (strcmp (arg, "igp") == 0) |
| 769 | *origin = 0; |
| 770 | else if (strcmp (arg, "egp") == 0) |
| 771 | *origin = 1; |
| 772 | else |
| 773 | *origin = 2; |
| 774 | |
| 775 | return origin; |
| 776 | } |
| 777 | |
| 778 | /* Free route map's compiled `ip address' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 779 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 780 | route_match_origin_free (void *rule) |
| 781 | { |
| 782 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 783 | } |
| 784 | |
| 785 | /* Route map commands for origin matching. */ |
| 786 | struct route_map_rule_cmd route_match_origin_cmd = |
| 787 | { |
| 788 | "origin", |
| 789 | route_match_origin, |
| 790 | route_match_origin_compile, |
| 791 | route_match_origin_free |
| 792 | }; |
| 793 | /* `set ip next-hop IP_ADDRESS' */ |
| 794 | |
| 795 | /* Set nexthop to object. ojbect must be pointer to struct attr. */ |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 796 | struct rmap_ip_nexthop_set |
| 797 | { |
| 798 | struct in_addr *address; |
| 799 | int peer_address; |
| 800 | }; |
| 801 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 802 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 803 | route_set_ip_nexthop (void *rule, struct prefix *prefix, |
| 804 | route_map_object_t type, void *object) |
| 805 | { |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 806 | struct rmap_ip_nexthop_set *rins = rule; |
| 807 | struct in_addr peer_address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 808 | struct bgp_info *bgp_info; |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 809 | struct peer *peer; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 810 | |
| 811 | if (type == RMAP_BGP) |
| 812 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 813 | bgp_info = object; |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 814 | peer = bgp_info->peer; |
| 815 | |
| 816 | if (rins->peer_address) |
| 817 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 818 | if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) || |
| 819 | CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 820 | && peer->su_remote |
| 821 | && sockunion_family (peer->su_remote) == AF_INET) |
| 822 | { |
| 823 | inet_aton (sockunion_su2str (peer->su_remote), &peer_address); |
| 824 | bgp_info->attr->nexthop = peer_address; |
| 825 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
| 826 | } |
| 827 | else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT) |
| 828 | && peer->su_local |
| 829 | && sockunion_family (peer->su_local) == AF_INET) |
| 830 | { |
| 831 | inet_aton (sockunion_su2str (peer->su_local), &peer_address); |
| 832 | bgp_info->attr->nexthop = peer_address; |
| 833 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
| 834 | } |
| 835 | } |
| 836 | else |
| 837 | { |
| 838 | /* Set next hop value. */ |
| 839 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); |
| 840 | bgp_info->attr->nexthop = *rins->address; |
| 841 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | return RMAP_OKAY; |
| 845 | } |
| 846 | |
| 847 | /* Route map `ip nexthop' compile function. Given string is converted |
| 848 | to struct in_addr structure. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 849 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 850 | route_set_ip_nexthop_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 851 | { |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 852 | struct rmap_ip_nexthop_set *rins; |
| 853 | struct in_addr *address = NULL; |
| 854 | int peer_address = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 855 | int ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 856 | |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 857 | if (strcmp (arg, "peer-address") == 0) |
| 858 | peer_address = 1; |
| 859 | else |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 860 | { |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 861 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); |
| 862 | ret = inet_aton (arg, address); |
| 863 | |
| 864 | if (ret == 0) |
| 865 | { |
| 866 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 867 | return NULL; |
| 868 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 869 | } |
| 870 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 871 | rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_ip_nexthop_set)); |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 872 | |
| 873 | rins->address = address; |
| 874 | rins->peer_address = peer_address; |
| 875 | |
| 876 | return rins; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | /* Free route map's compiled `ip nexthop' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 880 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 881 | route_set_ip_nexthop_free (void *rule) |
| 882 | { |
paul | ac41b2a | 2003-08-12 05:32:27 +0000 | [diff] [blame] | 883 | struct rmap_ip_nexthop_set *rins = rule; |
| 884 | |
| 885 | if (rins->address) |
| 886 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rins->address); |
| 887 | |
| 888 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rins); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | /* Route map commands for ip nexthop set. */ |
| 892 | struct route_map_rule_cmd route_set_ip_nexthop_cmd = |
| 893 | { |
| 894 | "ip next-hop", |
| 895 | route_set_ip_nexthop, |
| 896 | route_set_ip_nexthop_compile, |
| 897 | route_set_ip_nexthop_free |
| 898 | }; |
| 899 | |
| 900 | /* `set local-preference LOCAL_PREF' */ |
| 901 | |
| 902 | /* Set local preference. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 903 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | route_set_local_pref (void *rule, struct prefix *prefix, |
| 905 | route_map_object_t type, void *object) |
| 906 | { |
| 907 | u_int32_t *local_pref; |
| 908 | struct bgp_info *bgp_info; |
| 909 | |
| 910 | if (type == RMAP_BGP) |
| 911 | { |
| 912 | /* Fetch routemap's rule information. */ |
| 913 | local_pref = rule; |
| 914 | bgp_info = object; |
| 915 | |
| 916 | /* Set local preference value. */ |
| 917 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); |
| 918 | bgp_info->attr->local_pref = *local_pref; |
| 919 | } |
| 920 | |
| 921 | return RMAP_OKAY; |
| 922 | } |
| 923 | |
| 924 | /* set local preference compilation. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 925 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 926 | route_set_local_pref_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 927 | { |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 928 | unsigned long tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 929 | u_int32_t *local_pref; |
| 930 | char *endptr = NULL; |
| 931 | |
| 932 | /* Local preference value shoud be integer. */ |
| 933 | if (! all_digit (arg)) |
| 934 | return NULL; |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 935 | |
| 936 | tmp = strtoul (arg, &endptr, 10); |
| 937 | if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX) |
| 938 | return NULL; |
| 939 | |
| 940 | local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); |
| 941 | |
| 942 | if (!local_pref) |
| 943 | return local_pref; |
| 944 | |
| 945 | *local_pref = tmp; |
| 946 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 947 | return local_pref; |
| 948 | } |
| 949 | |
| 950 | /* Free route map's local preference value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 951 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 952 | route_set_local_pref_free (void *rule) |
| 953 | { |
| 954 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 955 | } |
| 956 | |
| 957 | /* Set local preference rule structure. */ |
| 958 | struct route_map_rule_cmd route_set_local_pref_cmd = |
| 959 | { |
| 960 | "local-preference", |
| 961 | route_set_local_pref, |
| 962 | route_set_local_pref_compile, |
| 963 | route_set_local_pref_free, |
| 964 | }; |
| 965 | |
| 966 | /* `set weight WEIGHT' */ |
| 967 | |
| 968 | /* Set weight. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 969 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 970 | route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, |
| 971 | void *object) |
| 972 | { |
| 973 | u_int32_t *weight; |
| 974 | struct bgp_info *bgp_info; |
| 975 | |
| 976 | if (type == RMAP_BGP) |
| 977 | { |
| 978 | /* Fetch routemap's rule information. */ |
| 979 | weight = rule; |
| 980 | bgp_info = object; |
| 981 | |
| 982 | /* Set weight value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 983 | if (*weight) |
| 984 | (bgp_attr_extra_get (bgp_info->attr))->weight = *weight; |
| 985 | else if (bgp_info->attr->extra) |
| 986 | bgp_info->attr->extra->weight = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | return RMAP_OKAY; |
| 990 | } |
| 991 | |
| 992 | /* set local preference compilation. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 993 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 994 | route_set_weight_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 995 | { |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 996 | unsigned long tmp; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 997 | u_int32_t *weight; |
| 998 | char *endptr = NULL; |
| 999 | |
| 1000 | /* Local preference value shoud be integer. */ |
| 1001 | if (! all_digit (arg)) |
| 1002 | return NULL; |
| 1003 | |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1004 | |
| 1005 | tmp = strtoul (arg, &endptr, 10); |
| 1006 | if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX) |
| 1007 | return NULL; |
| 1008 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1009 | weight = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1010 | |
| 1011 | if (weight == NULL) |
| 1012 | return weight; |
| 1013 | |
| 1014 | *weight = tmp; |
| 1015 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1016 | return weight; |
| 1017 | } |
| 1018 | |
| 1019 | /* Free route map's local preference value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1020 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1021 | route_set_weight_free (void *rule) |
| 1022 | { |
| 1023 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1024 | } |
| 1025 | |
| 1026 | /* Set local preference rule structure. */ |
| 1027 | struct route_map_rule_cmd route_set_weight_cmd = |
| 1028 | { |
| 1029 | "weight", |
| 1030 | route_set_weight, |
| 1031 | route_set_weight_compile, |
| 1032 | route_set_weight_free, |
| 1033 | }; |
| 1034 | |
| 1035 | /* `set metric METRIC' */ |
| 1036 | |
| 1037 | /* Set metric to attribute. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1038 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1039 | route_set_metric (void *rule, struct prefix *prefix, |
| 1040 | route_map_object_t type, void *object) |
| 1041 | { |
| 1042 | char *metric; |
| 1043 | u_int32_t metric_val; |
| 1044 | struct bgp_info *bgp_info; |
| 1045 | |
| 1046 | if (type == RMAP_BGP) |
| 1047 | { |
| 1048 | /* Fetch routemap's rule information. */ |
| 1049 | metric = rule; |
| 1050 | bgp_info = object; |
| 1051 | |
| 1052 | if (! (bgp_info->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))) |
| 1053 | bgp_info->attr->med = 0; |
| 1054 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); |
| 1055 | |
| 1056 | if (all_digit (metric)) |
| 1057 | { |
| 1058 | metric_val = strtoul (metric, (char **)NULL, 10); |
| 1059 | bgp_info->attr->med = metric_val; |
| 1060 | } |
| 1061 | else |
| 1062 | { |
| 1063 | metric_val = strtoul (metric+1, (char **)NULL, 10); |
| 1064 | |
| 1065 | if (strncmp (metric, "+", 1) == 0) |
| 1066 | { |
paul | 3b42497 | 2003-10-13 09:47:32 +0000 | [diff] [blame] | 1067 | if (bgp_info->attr->med/2 + metric_val/2 > BGP_MED_MAX/2) |
| 1068 | bgp_info->attr->med = BGP_MED_MAX - 1; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1069 | else |
paul | 537d8ea | 2003-08-27 06:45:32 +0000 | [diff] [blame] | 1070 | bgp_info->attr->med += metric_val; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1071 | } |
| 1072 | else if (strncmp (metric, "-", 1) == 0) |
| 1073 | { |
paul | 537d8ea | 2003-08-27 06:45:32 +0000 | [diff] [blame] | 1074 | if (bgp_info->attr->med <= metric_val) |
| 1075 | bgp_info->attr->med = 0; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1076 | else |
paul | 537d8ea | 2003-08-27 06:45:32 +0000 | [diff] [blame] | 1077 | bgp_info->attr->med -= metric_val; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1078 | } |
| 1079 | } |
| 1080 | } |
| 1081 | return RMAP_OKAY; |
| 1082 | } |
| 1083 | |
| 1084 | /* set metric compilation. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1085 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1086 | route_set_metric_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1087 | { |
| 1088 | u_int32_t metric; |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1089 | unsigned long larg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1090 | char *endptr = NULL; |
| 1091 | |
| 1092 | if (all_digit (arg)) |
| 1093 | { |
| 1094 | /* set metric value check*/ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1095 | larg = strtoul (arg, &endptr, 10); |
| 1096 | if (*endptr != '\0' || larg == ULONG_MAX || larg > UINT32_MAX) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1097 | return NULL; |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1098 | metric = larg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1099 | } |
| 1100 | else |
| 1101 | { |
| 1102 | /* set metric +/-value check */ |
| 1103 | if ((strncmp (arg, "+", 1) != 0 |
| 1104 | && strncmp (arg, "-", 1) != 0) |
| 1105 | || (! all_digit (arg+1))) |
| 1106 | return NULL; |
| 1107 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1108 | larg = strtoul (arg+1, &endptr, 10); |
| 1109 | if (*endptr != '\0' || larg == ULONG_MAX || larg > UINT32_MAX) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1110 | return NULL; |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1111 | metric = larg; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 1115 | } |
| 1116 | |
| 1117 | /* Free route map's compiled `set metric' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1118 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1119 | route_set_metric_free (void *rule) |
| 1120 | { |
| 1121 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1122 | } |
| 1123 | |
| 1124 | /* Set metric rule structure. */ |
| 1125 | struct route_map_rule_cmd route_set_metric_cmd = |
| 1126 | { |
| 1127 | "metric", |
| 1128 | route_set_metric, |
| 1129 | route_set_metric_compile, |
| 1130 | route_set_metric_free, |
| 1131 | }; |
| 1132 | |
| 1133 | /* `set as-path prepend ASPATH' */ |
| 1134 | |
| 1135 | /* For AS path prepend mechanism. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1136 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1137 | route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t type, void *object) |
| 1138 | { |
| 1139 | struct aspath *aspath; |
| 1140 | struct aspath *new; |
| 1141 | struct bgp_info *binfo; |
| 1142 | |
| 1143 | if (type == RMAP_BGP) |
| 1144 | { |
| 1145 | aspath = rule; |
| 1146 | binfo = object; |
| 1147 | |
| 1148 | if (binfo->attr->aspath->refcnt) |
| 1149 | new = aspath_dup (binfo->attr->aspath); |
| 1150 | else |
| 1151 | new = binfo->attr->aspath; |
| 1152 | |
| 1153 | aspath_prepend (aspath, new); |
| 1154 | binfo->attr->aspath = new; |
| 1155 | } |
| 1156 | |
| 1157 | return RMAP_OKAY; |
| 1158 | } |
| 1159 | |
| 1160 | /* Compile function for as-path prepend. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1161 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1162 | route_set_aspath_prepend_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1163 | { |
| 1164 | struct aspath *aspath; |
| 1165 | |
| 1166 | aspath = aspath_str2aspath (arg); |
| 1167 | if (! aspath) |
| 1168 | return NULL; |
| 1169 | return aspath; |
| 1170 | } |
| 1171 | |
| 1172 | /* Compile function for as-path prepend. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1173 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1174 | route_set_aspath_prepend_free (void *rule) |
| 1175 | { |
| 1176 | struct aspath *aspath = rule; |
| 1177 | aspath_free (aspath); |
| 1178 | } |
| 1179 | |
| 1180 | /* Set metric rule structure. */ |
| 1181 | struct route_map_rule_cmd route_set_aspath_prepend_cmd = |
| 1182 | { |
| 1183 | "as-path prepend", |
| 1184 | route_set_aspath_prepend, |
| 1185 | route_set_aspath_prepend_compile, |
| 1186 | route_set_aspath_prepend_free, |
| 1187 | }; |
| 1188 | |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 1189 | /* `set as-path exclude ASn' */ |
| 1190 | |
| 1191 | /* For ASN exclude mechanism. |
| 1192 | * Iterate over ASns requested and filter them from the given AS_PATH one by one. |
| 1193 | * Make a deep copy of existing AS_PATH, but for the first ASn only. |
| 1194 | */ |
| 1195 | static route_map_result_t |
| 1196 | route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t type, void *object) |
| 1197 | { |
| 1198 | struct aspath * new_path, * exclude_path; |
| 1199 | struct bgp_info *binfo; |
| 1200 | |
| 1201 | if (type == RMAP_BGP) |
| 1202 | { |
| 1203 | exclude_path = rule; |
| 1204 | binfo = object; |
| 1205 | if (binfo->attr->aspath->refcnt) |
| 1206 | new_path = aspath_dup (binfo->attr->aspath); |
| 1207 | else |
| 1208 | new_path = binfo->attr->aspath; |
| 1209 | binfo->attr->aspath = aspath_filter_exclude (new_path, exclude_path); |
| 1210 | } |
| 1211 | return RMAP_OKAY; |
| 1212 | } |
| 1213 | |
| 1214 | /* FIXME: consider using route_set_aspath_prepend_compile() and |
| 1215 | * route_set_aspath_prepend_free(), which two below function are |
| 1216 | * exact clones of. |
| 1217 | */ |
| 1218 | |
| 1219 | /* Compile function for as-path exclude. */ |
| 1220 | static void * |
| 1221 | route_set_aspath_exclude_compile (const char *arg) |
| 1222 | { |
| 1223 | struct aspath *aspath; |
| 1224 | |
| 1225 | aspath = aspath_str2aspath (arg); |
| 1226 | if (! aspath) |
| 1227 | return NULL; |
| 1228 | return aspath; |
| 1229 | } |
| 1230 | |
| 1231 | static void |
| 1232 | route_set_aspath_exclude_free (void *rule) |
| 1233 | { |
| 1234 | struct aspath *aspath = rule; |
| 1235 | aspath_free (aspath); |
| 1236 | } |
| 1237 | |
| 1238 | /* Set ASn exlude rule structure. */ |
| 1239 | struct route_map_rule_cmd route_set_aspath_exclude_cmd = |
| 1240 | { |
| 1241 | "as-path exclude", |
| 1242 | route_set_aspath_exclude, |
| 1243 | route_set_aspath_exclude_compile, |
| 1244 | route_set_aspath_exclude_free, |
| 1245 | }; |
| 1246 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1247 | /* `set community COMMUNITY' */ |
| 1248 | struct rmap_com_set |
| 1249 | { |
| 1250 | struct community *com; |
| 1251 | int additive; |
| 1252 | int none; |
| 1253 | }; |
| 1254 | |
| 1255 | /* For community set mechanism. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1256 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1257 | route_set_community (void *rule, struct prefix *prefix, |
| 1258 | route_map_object_t type, void *object) |
| 1259 | { |
| 1260 | struct rmap_com_set *rcs; |
| 1261 | struct bgp_info *binfo; |
| 1262 | struct attr *attr; |
| 1263 | struct community *new = NULL; |
| 1264 | struct community *old; |
| 1265 | struct community *merge; |
Paul Jakma | aa94ca8 | 2006-02-18 10:49:04 +0000 | [diff] [blame] | 1266 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1267 | if (type == RMAP_BGP) |
| 1268 | { |
| 1269 | rcs = rule; |
| 1270 | binfo = object; |
| 1271 | attr = binfo->attr; |
| 1272 | old = attr->community; |
| 1273 | |
| 1274 | /* "none" case. */ |
| 1275 | if (rcs->none) |
| 1276 | { |
| 1277 | attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)); |
| 1278 | attr->community = NULL; |
| 1279 | return RMAP_OKAY; |
| 1280 | } |
| 1281 | |
| 1282 | /* "additive" case. */ |
| 1283 | if (rcs->additive && old) |
| 1284 | { |
| 1285 | merge = community_merge (community_dup (old), rcs->com); |
Paul Jakma | aa94ca8 | 2006-02-18 10:49:04 +0000 | [diff] [blame] | 1286 | |
| 1287 | /* HACK: if the old community is not intern'd, |
| 1288 | * we should free it here, or all reference to it may be lost. |
| 1289 | * Really need to cleanup attribute caching sometime. |
| 1290 | */ |
| 1291 | if (old->refcnt == 0) |
| 1292 | community_free (old); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1293 | new = community_uniq_sort (merge); |
| 1294 | community_free (merge); |
| 1295 | } |
| 1296 | else |
| 1297 | new = community_dup (rcs->com); |
Paul Jakma | aa94ca8 | 2006-02-18 10:49:04 +0000 | [diff] [blame] | 1298 | |
| 1299 | /* will be interned by caller if required */ |
Michael Lambert | 2c9fd7e | 2010-07-24 12:44:07 -0400 | [diff] [blame] | 1300 | attr->community = community_intern (new); |
hasso | 70601e0 | 2005-05-27 03:26:57 +0000 | [diff] [blame] | 1301 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1302 | attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES); |
| 1303 | } |
| 1304 | |
| 1305 | return RMAP_OKAY; |
| 1306 | } |
| 1307 | |
| 1308 | /* Compile function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1309 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1310 | route_set_community_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1311 | { |
| 1312 | struct rmap_com_set *rcs; |
| 1313 | struct community *com = NULL; |
Michael Lambert | 2c9fd7e | 2010-07-24 12:44:07 -0400 | [diff] [blame] | 1314 | struct community *comint; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1315 | char *sp; |
| 1316 | int additive = 0; |
| 1317 | int none = 0; |
| 1318 | |
| 1319 | if (strcmp (arg, "none") == 0) |
| 1320 | none = 1; |
| 1321 | else |
| 1322 | { |
| 1323 | sp = strstr (arg, "additive"); |
| 1324 | |
| 1325 | if (sp && sp > arg) |
| 1326 | { |
| 1327 | /* "additive" keyworkd is included. */ |
| 1328 | additive = 1; |
| 1329 | *(sp - 1) = '\0'; |
| 1330 | } |
| 1331 | |
| 1332 | com = community_str2com (arg); |
| 1333 | |
| 1334 | if (additive) |
| 1335 | *(sp - 1) = ' '; |
| 1336 | |
| 1337 | if (! com) |
| 1338 | return NULL; |
| 1339 | } |
| 1340 | |
Michael Lambert | 2c9fd7e | 2010-07-24 12:44:07 -0400 | [diff] [blame] | 1341 | comint = community_intern (com); |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 1342 | rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set)); |
Michael Lambert | 2c9fd7e | 2010-07-24 12:44:07 -0400 | [diff] [blame] | 1343 | rcs->com = comint; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1344 | rcs->additive = additive; |
| 1345 | rcs->none = none; |
| 1346 | |
| 1347 | return rcs; |
| 1348 | } |
| 1349 | |
| 1350 | /* Free function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1351 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1352 | route_set_community_free (void *rule) |
| 1353 | { |
| 1354 | struct rmap_com_set *rcs = rule; |
| 1355 | |
| 1356 | if (rcs->com) |
| 1357 | community_free (rcs->com); |
| 1358 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rcs); |
| 1359 | } |
| 1360 | |
| 1361 | /* Set community rule structure. */ |
| 1362 | struct route_map_rule_cmd route_set_community_cmd = |
| 1363 | { |
| 1364 | "community", |
| 1365 | route_set_community, |
| 1366 | route_set_community_compile, |
| 1367 | route_set_community_free, |
| 1368 | }; |
| 1369 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 1370 | /* `set comm-list (<1-99>|<100-500>|WORD) delete' */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1371 | |
| 1372 | /* For community set mechanism. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1373 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1374 | route_set_community_delete (void *rule, struct prefix *prefix, |
| 1375 | route_map_object_t type, void *object) |
| 1376 | { |
| 1377 | struct community_list *list; |
| 1378 | struct community *merge; |
| 1379 | struct community *new; |
| 1380 | struct community *old; |
| 1381 | struct bgp_info *binfo; |
| 1382 | |
| 1383 | if (type == RMAP_BGP) |
| 1384 | { |
| 1385 | if (! rule) |
| 1386 | return RMAP_OKAY; |
| 1387 | |
| 1388 | binfo = object; |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 1389 | list = community_list_lookup (bgp_clist, rule, COMMUNITY_LIST_MASTER); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1390 | old = binfo->attr->community; |
| 1391 | |
| 1392 | if (list && old) |
| 1393 | { |
| 1394 | merge = community_list_match_delete (community_dup (old), list); |
| 1395 | new = community_uniq_sort (merge); |
| 1396 | community_free (merge); |
| 1397 | |
| 1398 | if (new->size == 0) |
| 1399 | { |
| 1400 | binfo->attr->community = NULL; |
| 1401 | binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES); |
| 1402 | community_free (new); |
| 1403 | } |
| 1404 | else |
| 1405 | { |
Michael Lambert | 2c9fd7e | 2010-07-24 12:44:07 -0400 | [diff] [blame] | 1406 | binfo->attr->community = community_intern (new); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1407 | binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES); |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | return RMAP_OKAY; |
| 1413 | } |
| 1414 | |
| 1415 | /* Compile function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1416 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1417 | route_set_community_delete_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1418 | { |
| 1419 | char *p; |
| 1420 | char *str; |
| 1421 | int len; |
| 1422 | |
| 1423 | p = strchr (arg, ' '); |
| 1424 | if (p) |
| 1425 | { |
| 1426 | len = p - arg; |
| 1427 | str = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, len + 1); |
| 1428 | memcpy (str, arg, len); |
| 1429 | } |
| 1430 | else |
| 1431 | str = NULL; |
| 1432 | |
| 1433 | return str; |
| 1434 | } |
| 1435 | |
| 1436 | /* Free function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1437 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1438 | route_set_community_delete_free (void *rule) |
| 1439 | { |
| 1440 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1441 | } |
| 1442 | |
| 1443 | /* Set community rule structure. */ |
| 1444 | struct route_map_rule_cmd route_set_community_delete_cmd = |
| 1445 | { |
| 1446 | "comm-list", |
| 1447 | route_set_community_delete, |
| 1448 | route_set_community_delete_compile, |
| 1449 | route_set_community_delete_free, |
| 1450 | }; |
| 1451 | |
| 1452 | /* `set extcommunity rt COMMUNITY' */ |
| 1453 | |
| 1454 | /* For community set mechanism. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1455 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1456 | route_set_ecommunity_rt (void *rule, struct prefix *prefix, |
| 1457 | route_map_object_t type, void *object) |
| 1458 | { |
| 1459 | struct ecommunity *ecom; |
| 1460 | struct ecommunity *new_ecom; |
| 1461 | struct ecommunity *old_ecom; |
| 1462 | struct bgp_info *bgp_info; |
| 1463 | |
| 1464 | if (type == RMAP_BGP) |
| 1465 | { |
| 1466 | ecom = rule; |
| 1467 | bgp_info = object; |
| 1468 | |
| 1469 | if (! ecom) |
| 1470 | return RMAP_OKAY; |
| 1471 | |
| 1472 | /* We assume additive for Extended Community. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1473 | old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1474 | |
| 1475 | if (old_ecom) |
| 1476 | new_ecom = ecommunity_merge (ecommunity_dup (old_ecom), ecom); |
| 1477 | else |
| 1478 | new_ecom = ecommunity_dup (ecom); |
| 1479 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1480 | bgp_info->attr->extra->ecommunity = new_ecom; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1481 | |
hasso | 70601e0 | 2005-05-27 03:26:57 +0000 | [diff] [blame] | 1482 | if (old_ecom) |
| 1483 | ecommunity_free (old_ecom); |
| 1484 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1485 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); |
| 1486 | } |
| 1487 | return RMAP_OKAY; |
| 1488 | } |
| 1489 | |
| 1490 | /* Compile function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1491 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1492 | route_set_ecommunity_rt_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1493 | { |
| 1494 | struct ecommunity *ecom; |
| 1495 | |
| 1496 | ecom = ecommunity_str2com (arg, ECOMMUNITY_ROUTE_TARGET, 0); |
| 1497 | if (! ecom) |
| 1498 | return NULL; |
| 1499 | return ecom; |
| 1500 | } |
| 1501 | |
| 1502 | /* Free function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1503 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1504 | route_set_ecommunity_rt_free (void *rule) |
| 1505 | { |
| 1506 | struct ecommunity *ecom = rule; |
| 1507 | ecommunity_free (ecom); |
| 1508 | } |
| 1509 | |
| 1510 | /* Set community rule structure. */ |
| 1511 | struct route_map_rule_cmd route_set_ecommunity_rt_cmd = |
| 1512 | { |
| 1513 | "extcommunity rt", |
| 1514 | route_set_ecommunity_rt, |
| 1515 | route_set_ecommunity_rt_compile, |
| 1516 | route_set_ecommunity_rt_free, |
| 1517 | }; |
| 1518 | |
| 1519 | /* `set extcommunity soo COMMUNITY' */ |
| 1520 | |
| 1521 | /* For community set mechanism. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1522 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1523 | route_set_ecommunity_soo (void *rule, struct prefix *prefix, |
| 1524 | route_map_object_t type, void *object) |
| 1525 | { |
| 1526 | struct ecommunity *ecom; |
| 1527 | struct bgp_info *bgp_info; |
| 1528 | |
| 1529 | if (type == RMAP_BGP) |
| 1530 | { |
| 1531 | ecom = rule; |
| 1532 | bgp_info = object; |
| 1533 | |
| 1534 | if (! ecom) |
| 1535 | return RMAP_OKAY; |
| 1536 | |
| 1537 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1538 | (bgp_attr_extra_get (bgp_info->attr))->ecommunity = ecommunity_dup (ecom); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1539 | } |
| 1540 | return RMAP_OKAY; |
| 1541 | } |
| 1542 | |
| 1543 | /* Compile function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1544 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1545 | route_set_ecommunity_soo_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1546 | { |
| 1547 | struct ecommunity *ecom; |
| 1548 | |
| 1549 | ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0); |
| 1550 | if (! ecom) |
| 1551 | return NULL; |
| 1552 | |
| 1553 | return ecom; |
| 1554 | } |
| 1555 | |
| 1556 | /* Free function for set community. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1557 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1558 | route_set_ecommunity_soo_free (void *rule) |
| 1559 | { |
| 1560 | struct ecommunity *ecom = rule; |
| 1561 | ecommunity_free (ecom); |
| 1562 | } |
| 1563 | |
| 1564 | /* Set community rule structure. */ |
| 1565 | struct route_map_rule_cmd route_set_ecommunity_soo_cmd = |
| 1566 | { |
| 1567 | "extcommunity soo", |
| 1568 | route_set_ecommunity_soo, |
| 1569 | route_set_ecommunity_soo_compile, |
| 1570 | route_set_ecommunity_soo_free, |
| 1571 | }; |
| 1572 | |
| 1573 | /* `set origin ORIGIN' */ |
| 1574 | |
| 1575 | /* For origin set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1576 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1577 | route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, void *object) |
| 1578 | { |
| 1579 | u_char *origin; |
| 1580 | struct bgp_info *bgp_info; |
| 1581 | |
| 1582 | if (type == RMAP_BGP) |
| 1583 | { |
| 1584 | origin = rule; |
| 1585 | bgp_info = object; |
| 1586 | |
| 1587 | bgp_info->attr->origin = *origin; |
| 1588 | } |
| 1589 | |
| 1590 | return RMAP_OKAY; |
| 1591 | } |
| 1592 | |
| 1593 | /* Compile function for origin set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1594 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1595 | route_set_origin_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1596 | { |
| 1597 | u_char *origin; |
| 1598 | |
| 1599 | origin = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_char)); |
| 1600 | |
| 1601 | if (strcmp (arg, "igp") == 0) |
| 1602 | *origin = 0; |
| 1603 | else if (strcmp (arg, "egp") == 0) |
| 1604 | *origin = 1; |
| 1605 | else |
| 1606 | *origin = 2; |
| 1607 | |
| 1608 | return origin; |
| 1609 | } |
| 1610 | |
| 1611 | /* Compile function for origin set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1612 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1613 | route_set_origin_free (void *rule) |
| 1614 | { |
| 1615 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1616 | } |
| 1617 | |
| 1618 | /* Set metric rule structure. */ |
| 1619 | struct route_map_rule_cmd route_set_origin_cmd = |
| 1620 | { |
| 1621 | "origin", |
| 1622 | route_set_origin, |
| 1623 | route_set_origin_compile, |
| 1624 | route_set_origin_free, |
| 1625 | }; |
| 1626 | |
| 1627 | /* `set atomic-aggregate' */ |
| 1628 | |
| 1629 | /* For atomic aggregate set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1630 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1631 | route_set_atomic_aggregate (void *rule, struct prefix *prefix, |
| 1632 | route_map_object_t type, void *object) |
| 1633 | { |
| 1634 | struct bgp_info *bgp_info; |
| 1635 | |
| 1636 | if (type == RMAP_BGP) |
| 1637 | { |
| 1638 | bgp_info = object; |
| 1639 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); |
| 1640 | } |
| 1641 | |
| 1642 | return RMAP_OKAY; |
| 1643 | } |
| 1644 | |
| 1645 | /* Compile function for atomic aggregate. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1646 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1647 | route_set_atomic_aggregate_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1648 | { |
| 1649 | return (void *)1; |
| 1650 | } |
| 1651 | |
| 1652 | /* Compile function for atomic aggregate. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1653 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1654 | route_set_atomic_aggregate_free (void *rule) |
| 1655 | { |
| 1656 | return; |
| 1657 | } |
| 1658 | |
| 1659 | /* Set atomic aggregate rule structure. */ |
| 1660 | struct route_map_rule_cmd route_set_atomic_aggregate_cmd = |
| 1661 | { |
| 1662 | "atomic-aggregate", |
| 1663 | route_set_atomic_aggregate, |
| 1664 | route_set_atomic_aggregate_compile, |
| 1665 | route_set_atomic_aggregate_free, |
| 1666 | }; |
| 1667 | |
| 1668 | /* `set aggregator as AS A.B.C.D' */ |
| 1669 | struct aggregator |
| 1670 | { |
| 1671 | as_t as; |
| 1672 | struct in_addr address; |
| 1673 | }; |
| 1674 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1675 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1676 | route_set_aggregator_as (void *rule, struct prefix *prefix, |
| 1677 | route_map_object_t type, void *object) |
| 1678 | { |
| 1679 | struct bgp_info *bgp_info; |
| 1680 | struct aggregator *aggregator; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1681 | struct attr_extra *ae; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1682 | |
| 1683 | if (type == RMAP_BGP) |
| 1684 | { |
| 1685 | bgp_info = object; |
| 1686 | aggregator = rule; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1687 | ae = bgp_attr_extra_get (bgp_info->attr); |
| 1688 | |
| 1689 | ae->aggregator_as = aggregator->as; |
| 1690 | ae->aggregator_addr = aggregator->address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1691 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); |
| 1692 | } |
| 1693 | |
| 1694 | return RMAP_OKAY; |
| 1695 | } |
| 1696 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1697 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1698 | route_set_aggregator_as_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1699 | { |
| 1700 | struct aggregator *aggregator; |
| 1701 | char as[10]; |
| 1702 | char address[20]; |
| 1703 | |
Stephen Hemminger | 393deb9 | 2008-08-18 14:13:29 -0700 | [diff] [blame] | 1704 | aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1705 | sscanf (arg, "%s %s", as, address); |
| 1706 | |
| 1707 | aggregator->as = strtoul (as, NULL, 10); |
| 1708 | inet_aton (address, &aggregator->address); |
| 1709 | |
| 1710 | return aggregator; |
| 1711 | } |
| 1712 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1713 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1714 | route_set_aggregator_as_free (void *rule) |
| 1715 | { |
| 1716 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1717 | } |
| 1718 | |
| 1719 | struct route_map_rule_cmd route_set_aggregator_as_cmd = |
| 1720 | { |
| 1721 | "aggregator as", |
| 1722 | route_set_aggregator_as, |
| 1723 | route_set_aggregator_as_compile, |
| 1724 | route_set_aggregator_as_free, |
| 1725 | }; |
| 1726 | |
| 1727 | #ifdef HAVE_IPV6 |
| 1728 | /* `match ipv6 address IP_ACCESS_LIST' */ |
| 1729 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1730 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1731 | route_match_ipv6_address (void *rule, struct prefix *prefix, |
| 1732 | route_map_object_t type, void *object) |
| 1733 | { |
| 1734 | struct access_list *alist; |
| 1735 | |
| 1736 | if (type == RMAP_BGP) |
| 1737 | { |
| 1738 | alist = access_list_lookup (AFI_IP6, (char *) rule); |
| 1739 | if (alist == NULL) |
| 1740 | return RMAP_NOMATCH; |
| 1741 | |
| 1742 | return (access_list_apply (alist, prefix) == FILTER_DENY ? |
| 1743 | RMAP_NOMATCH : RMAP_MATCH); |
| 1744 | } |
| 1745 | return RMAP_NOMATCH; |
| 1746 | } |
| 1747 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1748 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1749 | route_match_ipv6_address_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1750 | { |
| 1751 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 1752 | } |
| 1753 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1754 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1755 | route_match_ipv6_address_free (void *rule) |
| 1756 | { |
| 1757 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1758 | } |
| 1759 | |
| 1760 | /* Route map commands for ip address matching. */ |
| 1761 | struct route_map_rule_cmd route_match_ipv6_address_cmd = |
| 1762 | { |
| 1763 | "ipv6 address", |
| 1764 | route_match_ipv6_address, |
| 1765 | route_match_ipv6_address_compile, |
| 1766 | route_match_ipv6_address_free |
| 1767 | }; |
| 1768 | |
| 1769 | /* `match ipv6 next-hop IP_ADDRESS' */ |
| 1770 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1771 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1772 | route_match_ipv6_next_hop (void *rule, struct prefix *prefix, |
| 1773 | route_map_object_t type, void *object) |
| 1774 | { |
| 1775 | struct in6_addr *addr; |
| 1776 | struct bgp_info *bgp_info; |
| 1777 | |
| 1778 | if (type == RMAP_BGP) |
| 1779 | { |
| 1780 | addr = rule; |
| 1781 | bgp_info = object; |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1782 | |
| 1783 | if (!bgp_info->attr->extra) |
| 1784 | return RMAP_NOMATCH; |
| 1785 | |
| 1786 | if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1787 | return RMAP_MATCH; |
| 1788 | |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1789 | if (bgp_info->attr->extra->mp_nexthop_len == 32 && |
| 1790 | IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_local, rule)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1791 | return RMAP_MATCH; |
| 1792 | |
| 1793 | return RMAP_NOMATCH; |
| 1794 | } |
| 1795 | |
| 1796 | return RMAP_NOMATCH; |
| 1797 | } |
| 1798 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1799 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1800 | route_match_ipv6_next_hop_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1801 | { |
| 1802 | struct in6_addr *address; |
| 1803 | int ret; |
| 1804 | |
| 1805 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr)); |
| 1806 | |
| 1807 | ret = inet_pton (AF_INET6, arg, address); |
| 1808 | if (!ret) |
| 1809 | { |
| 1810 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 1811 | return NULL; |
| 1812 | } |
| 1813 | |
| 1814 | return address; |
| 1815 | } |
| 1816 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1817 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1818 | route_match_ipv6_next_hop_free (void *rule) |
| 1819 | { |
| 1820 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1821 | } |
| 1822 | |
| 1823 | struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = |
| 1824 | { |
| 1825 | "ipv6 next-hop", |
| 1826 | route_match_ipv6_next_hop, |
| 1827 | route_match_ipv6_next_hop_compile, |
| 1828 | route_match_ipv6_next_hop_free |
| 1829 | }; |
| 1830 | |
| 1831 | /* `match ipv6 address prefix-list PREFIX_LIST' */ |
| 1832 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1833 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1834 | route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, |
| 1835 | route_map_object_t type, void *object) |
| 1836 | { |
| 1837 | struct prefix_list *plist; |
| 1838 | |
| 1839 | if (type == RMAP_BGP) |
| 1840 | { |
| 1841 | plist = prefix_list_lookup (AFI_IP6, (char *) rule); |
| 1842 | if (plist == NULL) |
| 1843 | return RMAP_NOMATCH; |
| 1844 | |
| 1845 | return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? |
| 1846 | RMAP_NOMATCH : RMAP_MATCH); |
| 1847 | } |
| 1848 | return RMAP_NOMATCH; |
| 1849 | } |
| 1850 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1851 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1852 | route_match_ipv6_address_prefix_list_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1853 | { |
| 1854 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); |
| 1855 | } |
| 1856 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1857 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1858 | route_match_ipv6_address_prefix_list_free (void *rule) |
| 1859 | { |
| 1860 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1861 | } |
| 1862 | |
| 1863 | struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = |
| 1864 | { |
| 1865 | "ipv6 address prefix-list", |
| 1866 | route_match_ipv6_address_prefix_list, |
| 1867 | route_match_ipv6_address_prefix_list_compile, |
| 1868 | route_match_ipv6_address_prefix_list_free |
| 1869 | }; |
| 1870 | |
| 1871 | /* `set ipv6 nexthop global IP_ADDRESS' */ |
| 1872 | |
| 1873 | /* Set nexthop to object. ojbect must be pointer to struct attr. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1874 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1875 | route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, |
| 1876 | route_map_object_t type, void *object) |
| 1877 | { |
| 1878 | struct in6_addr *address; |
| 1879 | struct bgp_info *bgp_info; |
| 1880 | |
| 1881 | if (type == RMAP_BGP) |
| 1882 | { |
| 1883 | /* Fetch routemap's rule information. */ |
| 1884 | address = rule; |
| 1885 | bgp_info = object; |
| 1886 | |
| 1887 | /* Set next hop value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1888 | (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1889 | |
| 1890 | /* Set nexthop length. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1891 | if (bgp_info->attr->extra->mp_nexthop_len == 0) |
| 1892 | bgp_info->attr->extra->mp_nexthop_len = 16; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1893 | } |
| 1894 | |
| 1895 | return RMAP_OKAY; |
| 1896 | } |
| 1897 | |
| 1898 | /* Route map `ip next-hop' compile function. Given string is converted |
| 1899 | to struct in_addr structure. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1900 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1901 | route_set_ipv6_nexthop_global_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1902 | { |
| 1903 | int ret; |
| 1904 | struct in6_addr *address; |
| 1905 | |
| 1906 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr)); |
| 1907 | |
| 1908 | ret = inet_pton (AF_INET6, arg, address); |
| 1909 | |
| 1910 | if (ret == 0) |
| 1911 | { |
| 1912 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 1913 | return NULL; |
| 1914 | } |
| 1915 | |
| 1916 | return address; |
| 1917 | } |
| 1918 | |
| 1919 | /* Free route map's compiled `ip next-hop' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1920 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1921 | route_set_ipv6_nexthop_global_free (void *rule) |
| 1922 | { |
| 1923 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1924 | } |
| 1925 | |
| 1926 | /* Route map commands for ip nexthop set. */ |
| 1927 | struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd = |
| 1928 | { |
| 1929 | "ipv6 next-hop global", |
| 1930 | route_set_ipv6_nexthop_global, |
| 1931 | route_set_ipv6_nexthop_global_compile, |
| 1932 | route_set_ipv6_nexthop_global_free |
| 1933 | }; |
| 1934 | |
| 1935 | /* `set ipv6 nexthop local IP_ADDRESS' */ |
| 1936 | |
| 1937 | /* Set nexthop to object. ojbect must be pointer to struct attr. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1938 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1939 | route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, |
| 1940 | route_map_object_t type, void *object) |
| 1941 | { |
| 1942 | struct in6_addr *address; |
| 1943 | struct bgp_info *bgp_info; |
| 1944 | |
| 1945 | if (type == RMAP_BGP) |
| 1946 | { |
| 1947 | /* Fetch routemap's rule information. */ |
| 1948 | address = rule; |
| 1949 | bgp_info = object; |
| 1950 | |
| 1951 | /* Set next hop value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1952 | (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1953 | |
| 1954 | /* Set nexthop length. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 1955 | if (bgp_info->attr->extra->mp_nexthop_len != 32) |
| 1956 | bgp_info->attr->extra->mp_nexthop_len = 32; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1957 | } |
| 1958 | |
| 1959 | return RMAP_OKAY; |
| 1960 | } |
| 1961 | |
| 1962 | /* Route map `ip nexthop' compile function. Given string is converted |
| 1963 | to struct in_addr structure. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1964 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 1965 | route_set_ipv6_nexthop_local_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1966 | { |
| 1967 | int ret; |
| 1968 | struct in6_addr *address; |
| 1969 | |
| 1970 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr)); |
| 1971 | |
| 1972 | ret = inet_pton (AF_INET6, arg, address); |
| 1973 | |
| 1974 | if (ret == 0) |
| 1975 | { |
| 1976 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 1977 | return NULL; |
| 1978 | } |
| 1979 | |
| 1980 | return address; |
| 1981 | } |
| 1982 | |
| 1983 | /* Free route map's compiled `ip nexthop' value. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 1984 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1985 | route_set_ipv6_nexthop_local_free (void *rule) |
| 1986 | { |
| 1987 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 1988 | } |
| 1989 | |
| 1990 | /* Route map commands for ip nexthop set. */ |
| 1991 | struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = |
| 1992 | { |
| 1993 | "ipv6 next-hop local", |
| 1994 | route_set_ipv6_nexthop_local, |
| 1995 | route_set_ipv6_nexthop_local_compile, |
| 1996 | route_set_ipv6_nexthop_local_free |
| 1997 | }; |
| 1998 | #endif /* HAVE_IPV6 */ |
| 1999 | |
| 2000 | /* `set vpnv4 nexthop A.B.C.D' */ |
| 2001 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2002 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2003 | route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, |
| 2004 | route_map_object_t type, void *object) |
| 2005 | { |
| 2006 | struct in_addr *address; |
| 2007 | struct bgp_info *bgp_info; |
| 2008 | |
| 2009 | if (type == RMAP_BGP) |
| 2010 | { |
| 2011 | /* Fetch routemap's rule information. */ |
| 2012 | address = rule; |
| 2013 | bgp_info = object; |
| 2014 | |
| 2015 | /* Set next hop value. */ |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2016 | (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | return RMAP_OKAY; |
| 2020 | } |
| 2021 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2022 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2023 | route_set_vpnv4_nexthop_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2024 | { |
| 2025 | int ret; |
| 2026 | struct in_addr *address; |
| 2027 | |
| 2028 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); |
| 2029 | |
| 2030 | ret = inet_aton (arg, address); |
| 2031 | |
| 2032 | if (ret == 0) |
| 2033 | { |
| 2034 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 2035 | return NULL; |
| 2036 | } |
| 2037 | |
| 2038 | return address; |
| 2039 | } |
| 2040 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2041 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2042 | route_set_vpnv4_nexthop_free (void *rule) |
| 2043 | { |
| 2044 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 2045 | } |
| 2046 | |
| 2047 | /* Route map commands for ip nexthop set. */ |
| 2048 | struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = |
| 2049 | { |
| 2050 | "vpnv4 next-hop", |
| 2051 | route_set_vpnv4_nexthop, |
| 2052 | route_set_vpnv4_nexthop_compile, |
| 2053 | route_set_vpnv4_nexthop_free |
| 2054 | }; |
| 2055 | |
| 2056 | /* `set originator-id' */ |
| 2057 | |
| 2058 | /* For origin set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2059 | static route_map_result_t |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2060 | route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t type, void *object) |
| 2061 | { |
| 2062 | struct in_addr *address; |
| 2063 | struct bgp_info *bgp_info; |
| 2064 | |
| 2065 | if (type == RMAP_BGP) |
| 2066 | { |
| 2067 | address = rule; |
| 2068 | bgp_info = object; |
| 2069 | |
| 2070 | bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); |
Paul Jakma | fb982c2 | 2007-05-04 20:15:47 +0000 | [diff] [blame] | 2071 | (bgp_attr_extra_get (bgp_info->attr))->originator_id = *address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2072 | } |
| 2073 | |
| 2074 | return RMAP_OKAY; |
| 2075 | } |
| 2076 | |
| 2077 | /* Compile function for originator-id set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2078 | static void * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2079 | route_set_originator_id_compile (const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2080 | { |
| 2081 | int ret; |
| 2082 | struct in_addr *address; |
| 2083 | |
| 2084 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); |
| 2085 | |
| 2086 | ret = inet_aton (arg, address); |
| 2087 | |
| 2088 | if (ret == 0) |
| 2089 | { |
| 2090 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
| 2091 | return NULL; |
| 2092 | } |
| 2093 | |
| 2094 | return address; |
| 2095 | } |
| 2096 | |
| 2097 | /* Compile function for originator_id set. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2098 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2099 | route_set_originator_id_free (void *rule) |
| 2100 | { |
| 2101 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
| 2102 | } |
| 2103 | |
| 2104 | /* Set metric rule structure. */ |
| 2105 | struct route_map_rule_cmd route_set_originator_id_cmd = |
| 2106 | { |
| 2107 | "originator-id", |
| 2108 | route_set_originator_id, |
| 2109 | route_set_originator_id_compile, |
| 2110 | route_set_originator_id_free, |
| 2111 | }; |
| 2112 | |
| 2113 | /* Add bgp route map rule. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2114 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2115 | bgp_route_match_add (struct vty *vty, struct route_map_index *index, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2116 | const char *command, const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2117 | { |
| 2118 | int ret; |
| 2119 | |
| 2120 | ret = route_map_add_match (index, command, arg); |
| 2121 | if (ret) |
| 2122 | { |
| 2123 | switch (ret) |
| 2124 | { |
| 2125 | case RMAP_RULE_MISSING: |
| 2126 | vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); |
| 2127 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2128 | case RMAP_COMPILE_ERROR: |
| 2129 | vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); |
| 2130 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2131 | } |
| 2132 | } |
| 2133 | return CMD_SUCCESS; |
| 2134 | } |
| 2135 | |
| 2136 | /* Delete bgp route map rule. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2137 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2138 | bgp_route_match_delete (struct vty *vty, struct route_map_index *index, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2139 | const char *command, const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2140 | { |
| 2141 | int ret; |
| 2142 | |
| 2143 | ret = route_map_delete_match (index, command, arg); |
| 2144 | if (ret) |
| 2145 | { |
| 2146 | switch (ret) |
| 2147 | { |
| 2148 | case RMAP_RULE_MISSING: |
| 2149 | vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); |
| 2150 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2151 | case RMAP_COMPILE_ERROR: |
| 2152 | vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); |
| 2153 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2154 | } |
| 2155 | } |
| 2156 | return CMD_SUCCESS; |
| 2157 | } |
| 2158 | |
| 2159 | /* Add bgp route map rule. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2160 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2161 | bgp_route_set_add (struct vty *vty, struct route_map_index *index, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2162 | const char *command, const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2163 | { |
| 2164 | int ret; |
| 2165 | |
| 2166 | ret = route_map_add_set (index, command, arg); |
| 2167 | if (ret) |
| 2168 | { |
| 2169 | switch (ret) |
| 2170 | { |
| 2171 | case RMAP_RULE_MISSING: |
| 2172 | vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); |
| 2173 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2174 | case RMAP_COMPILE_ERROR: |
| 2175 | vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); |
| 2176 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2177 | } |
| 2178 | } |
| 2179 | return CMD_SUCCESS; |
| 2180 | } |
| 2181 | |
| 2182 | /* Delete bgp route map rule. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2183 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2184 | bgp_route_set_delete (struct vty *vty, struct route_map_index *index, |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2185 | const char *command, const char *arg) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2186 | { |
| 2187 | int ret; |
| 2188 | |
| 2189 | ret = route_map_delete_set (index, command, arg); |
| 2190 | if (ret) |
| 2191 | { |
| 2192 | switch (ret) |
| 2193 | { |
| 2194 | case RMAP_RULE_MISSING: |
| 2195 | vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); |
| 2196 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2197 | case RMAP_COMPILE_ERROR: |
| 2198 | vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); |
| 2199 | return CMD_WARNING; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2200 | } |
| 2201 | } |
| 2202 | return CMD_SUCCESS; |
| 2203 | } |
| 2204 | |
| 2205 | /* Hook function for updating route_map assignment. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2206 | static void |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 2207 | bgp_route_map_update (const char *unused) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2208 | { |
| 2209 | int i; |
| 2210 | afi_t afi; |
| 2211 | safi_t safi; |
| 2212 | int direct; |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2213 | struct listnode *node, *nnode; |
| 2214 | struct listnode *mnode, *mnnode; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2215 | struct bgp *bgp; |
| 2216 | struct peer *peer; |
| 2217 | struct peer_group *group; |
| 2218 | struct bgp_filter *filter; |
| 2219 | struct bgp_node *bn; |
| 2220 | struct bgp_static *bgp_static; |
| 2221 | |
| 2222 | /* For neighbor route-map updates. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2223 | for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2224 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2225 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2226 | { |
| 2227 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2228 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2229 | { |
| 2230 | filter = &peer->filter[afi][safi]; |
| 2231 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2232 | for (direct = RMAP_IN; direct < RMAP_MAX; direct++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2233 | { |
| 2234 | if (filter->map[direct].name) |
| 2235 | filter->map[direct].map = |
| 2236 | route_map_lookup_by_name (filter->map[direct].name); |
| 2237 | else |
| 2238 | filter->map[direct].map = NULL; |
| 2239 | } |
| 2240 | |
| 2241 | if (filter->usmap.name) |
| 2242 | filter->usmap.map = route_map_lookup_by_name (filter->usmap.name); |
| 2243 | else |
| 2244 | filter->usmap.map = NULL; |
| 2245 | } |
| 2246 | } |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2247 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2248 | { |
| 2249 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2250 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2251 | { |
| 2252 | filter = &group->conf->filter[afi][safi]; |
| 2253 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2254 | for (direct = RMAP_IN; direct < RMAP_MAX; direct++) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2255 | { |
| 2256 | if (filter->map[direct].name) |
| 2257 | filter->map[direct].map = |
| 2258 | route_map_lookup_by_name (filter->map[direct].name); |
| 2259 | else |
| 2260 | filter->map[direct].map = NULL; |
| 2261 | } |
| 2262 | |
| 2263 | if (filter->usmap.name) |
| 2264 | filter->usmap.map = route_map_lookup_by_name (filter->usmap.name); |
| 2265 | else |
| 2266 | filter->usmap.map = NULL; |
| 2267 | } |
| 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | /* For default-originate route-map updates. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2272 | for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2273 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2274 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2275 | { |
| 2276 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2277 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2278 | { |
| 2279 | if (peer->default_rmap[afi][safi].name) |
| 2280 | peer->default_rmap[afi][safi].map = |
| 2281 | route_map_lookup_by_name (peer->default_rmap[afi][safi].name); |
| 2282 | else |
| 2283 | peer->default_rmap[afi][safi].map = NULL; |
| 2284 | } |
| 2285 | } |
| 2286 | } |
| 2287 | |
| 2288 | /* For network route-map updates. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2289 | for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2290 | { |
| 2291 | for (afi = AFI_IP; afi < AFI_MAX; afi++) |
| 2292 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) |
| 2293 | for (bn = bgp_table_top (bgp->route[afi][safi]); bn; |
| 2294 | bn = bgp_route_next (bn)) |
| 2295 | if ((bgp_static = bn->info) != NULL) |
| 2296 | { |
| 2297 | if (bgp_static->rmap.name) |
| 2298 | bgp_static->rmap.map = |
| 2299 | route_map_lookup_by_name (bgp_static->rmap.name); |
| 2300 | else |
| 2301 | bgp_static->rmap.map = NULL; |
| 2302 | } |
| 2303 | } |
| 2304 | |
| 2305 | /* For redistribute route-map updates. */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 2306 | for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2307 | { |
| 2308 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) |
| 2309 | { |
| 2310 | if (bgp->rmap[ZEBRA_FAMILY_IPV4][i].name) |
| 2311 | bgp->rmap[ZEBRA_FAMILY_IPV4][i].map = |
| 2312 | route_map_lookup_by_name (bgp->rmap[ZEBRA_FAMILY_IPV4][i].name); |
| 2313 | #ifdef HAVE_IPV6 |
| 2314 | if (bgp->rmap[ZEBRA_FAMILY_IPV6][i].name) |
| 2315 | bgp->rmap[ZEBRA_FAMILY_IPV6][i].map = |
| 2316 | route_map_lookup_by_name (bgp->rmap[ZEBRA_FAMILY_IPV6][i].name); |
| 2317 | #endif /* HAVE_IPV6 */ |
| 2318 | } |
| 2319 | } |
| 2320 | } |
| 2321 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 2322 | DEFUN (match_peer, |
| 2323 | match_peer_cmd, |
| 2324 | "match peer (A.B.C.D|X:X::X:X)", |
| 2325 | MATCH_STR |
| 2326 | "Match peer address\n" |
| 2327 | "IPv6 address of peer\n" |
| 2328 | "IP address of peer\n") |
| 2329 | { |
| 2330 | return bgp_route_match_add (vty, vty->index, "peer", argv[0]); |
| 2331 | } |
| 2332 | |
| 2333 | DEFUN (match_peer_local, |
| 2334 | match_peer_local_cmd, |
| 2335 | "match peer local", |
| 2336 | MATCH_STR |
| 2337 | "Match peer address\n" |
| 2338 | "Static or Redistributed routes\n") |
| 2339 | { |
| 2340 | return bgp_route_match_add (vty, vty->index, "peer", NULL); |
| 2341 | } |
| 2342 | |
| 2343 | DEFUN (no_match_peer, |
| 2344 | no_match_peer_cmd, |
| 2345 | "no match peer", |
| 2346 | NO_STR |
| 2347 | MATCH_STR |
| 2348 | "Match peer address\n") |
| 2349 | { |
| 2350 | if (argc == 0) |
| 2351 | return bgp_route_match_delete (vty, vty->index, "peer", NULL); |
| 2352 | |
| 2353 | return bgp_route_match_delete (vty, vty->index, "peer", argv[0]); |
| 2354 | } |
| 2355 | |
| 2356 | ALIAS (no_match_peer, |
| 2357 | no_match_peer_val_cmd, |
| 2358 | "no match peer (A.B.C.D|X:X::X:X)", |
| 2359 | NO_STR |
| 2360 | MATCH_STR |
| 2361 | "Match peer address\n" |
| 2362 | "IPv6 address of peer\n" |
| 2363 | "IP address of peer\n") |
| 2364 | |
| 2365 | ALIAS (no_match_peer, |
| 2366 | no_match_peer_local_cmd, |
| 2367 | "no match peer local", |
| 2368 | NO_STR |
| 2369 | MATCH_STR |
| 2370 | "Match peer address\n" |
| 2371 | "Static or Redistributed routes\n") |
| 2372 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2373 | DEFUN (match_ip_address, |
| 2374 | match_ip_address_cmd, |
| 2375 | "match ip address (<1-199>|<1300-2699>|WORD)", |
| 2376 | MATCH_STR |
| 2377 | IP_STR |
| 2378 | "Match address of route\n" |
| 2379 | "IP access-list number\n" |
| 2380 | "IP access-list number (expanded range)\n" |
| 2381 | "IP Access-list name\n") |
| 2382 | { |
| 2383 | return bgp_route_match_add (vty, vty->index, "ip address", argv[0]); |
| 2384 | } |
| 2385 | |
| 2386 | DEFUN (no_match_ip_address, |
| 2387 | no_match_ip_address_cmd, |
| 2388 | "no match ip address", |
| 2389 | NO_STR |
| 2390 | MATCH_STR |
| 2391 | IP_STR |
| 2392 | "Match address of route\n") |
| 2393 | { |
| 2394 | if (argc == 0) |
| 2395 | return bgp_route_match_delete (vty, vty->index, "ip address", NULL); |
| 2396 | |
| 2397 | return bgp_route_match_delete (vty, vty->index, "ip address", argv[0]); |
| 2398 | } |
| 2399 | |
| 2400 | ALIAS (no_match_ip_address, |
| 2401 | no_match_ip_address_val_cmd, |
| 2402 | "no match ip address (<1-199>|<1300-2699>|WORD)", |
| 2403 | NO_STR |
| 2404 | MATCH_STR |
| 2405 | IP_STR |
| 2406 | "Match address of route\n" |
| 2407 | "IP access-list number\n" |
| 2408 | "IP access-list number (expanded range)\n" |
| 2409 | "IP Access-list name\n") |
| 2410 | |
| 2411 | DEFUN (match_ip_next_hop, |
| 2412 | match_ip_next_hop_cmd, |
| 2413 | "match ip next-hop (<1-199>|<1300-2699>|WORD)", |
| 2414 | MATCH_STR |
| 2415 | IP_STR |
| 2416 | "Match next-hop address of route\n" |
| 2417 | "IP access-list number\n" |
| 2418 | "IP access-list number (expanded range)\n" |
| 2419 | "IP Access-list name\n") |
| 2420 | { |
| 2421 | return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[0]); |
| 2422 | } |
| 2423 | |
| 2424 | DEFUN (no_match_ip_next_hop, |
| 2425 | no_match_ip_next_hop_cmd, |
| 2426 | "no match ip next-hop", |
| 2427 | NO_STR |
| 2428 | MATCH_STR |
| 2429 | IP_STR |
| 2430 | "Match next-hop address of route\n") |
| 2431 | { |
| 2432 | if (argc == 0) |
| 2433 | return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL); |
| 2434 | |
| 2435 | return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[0]); |
| 2436 | } |
| 2437 | |
| 2438 | ALIAS (no_match_ip_next_hop, |
| 2439 | no_match_ip_next_hop_val_cmd, |
| 2440 | "no match ip next-hop (<1-199>|<1300-2699>|WORD)", |
| 2441 | NO_STR |
| 2442 | MATCH_STR |
| 2443 | IP_STR |
| 2444 | "Match next-hop address of route\n" |
| 2445 | "IP access-list number\n" |
| 2446 | "IP access-list number (expanded range)\n" |
| 2447 | "IP Access-list name\n") |
| 2448 | |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 2449 | DEFUN (match_ip_route_source, |
| 2450 | match_ip_route_source_cmd, |
| 2451 | "match ip route-source (<1-199>|<1300-2699>|WORD)", |
| 2452 | MATCH_STR |
| 2453 | IP_STR |
| 2454 | "Match advertising source address of route\n" |
| 2455 | "IP access-list number\n" |
| 2456 | "IP access-list number (expanded range)\n" |
| 2457 | "IP standard access-list name\n") |
| 2458 | { |
| 2459 | return bgp_route_match_add (vty, vty->index, "ip route-source", argv[0]); |
| 2460 | } |
| 2461 | |
| 2462 | DEFUN (no_match_ip_route_source, |
| 2463 | no_match_ip_route_source_cmd, |
| 2464 | "no match ip route-source", |
| 2465 | NO_STR |
| 2466 | MATCH_STR |
| 2467 | IP_STR |
| 2468 | "Match advertising source address of route\n") |
| 2469 | { |
| 2470 | if (argc == 0) |
| 2471 | return bgp_route_match_delete (vty, vty->index, "ip route-source", NULL); |
| 2472 | |
| 2473 | return bgp_route_match_delete (vty, vty->index, "ip route-source", argv[0]); |
| 2474 | } |
| 2475 | |
| 2476 | ALIAS (no_match_ip_route_source, |
| 2477 | no_match_ip_route_source_val_cmd, |
| 2478 | "no match ip route-source (<1-199>|<1300-2699>|WORD)", |
| 2479 | NO_STR |
| 2480 | MATCH_STR |
| 2481 | IP_STR |
| 2482 | "Match advertising source address of route\n" |
| 2483 | "IP access-list number\n" |
| 2484 | "IP access-list number (expanded range)\n" |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 2485 | "IP standard access-list name\n") |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 2486 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2487 | DEFUN (match_ip_address_prefix_list, |
| 2488 | match_ip_address_prefix_list_cmd, |
| 2489 | "match ip address prefix-list WORD", |
| 2490 | MATCH_STR |
| 2491 | IP_STR |
| 2492 | "Match address of route\n" |
| 2493 | "Match entries of prefix-lists\n" |
| 2494 | "IP prefix-list name\n") |
| 2495 | { |
| 2496 | return bgp_route_match_add (vty, vty->index, "ip address prefix-list", argv[0]); |
| 2497 | } |
| 2498 | |
| 2499 | DEFUN (no_match_ip_address_prefix_list, |
| 2500 | no_match_ip_address_prefix_list_cmd, |
| 2501 | "no match ip address prefix-list", |
| 2502 | NO_STR |
| 2503 | MATCH_STR |
| 2504 | IP_STR |
| 2505 | "Match address of route\n" |
| 2506 | "Match entries of prefix-lists\n") |
| 2507 | { |
| 2508 | if (argc == 0) |
| 2509 | return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", NULL); |
| 2510 | |
| 2511 | return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", argv[0]); |
| 2512 | } |
| 2513 | |
| 2514 | ALIAS (no_match_ip_address_prefix_list, |
| 2515 | no_match_ip_address_prefix_list_val_cmd, |
| 2516 | "no match ip address prefix-list WORD", |
| 2517 | NO_STR |
| 2518 | MATCH_STR |
| 2519 | IP_STR |
| 2520 | "Match address of route\n" |
| 2521 | "Match entries of prefix-lists\n" |
| 2522 | "IP prefix-list name\n") |
| 2523 | |
| 2524 | DEFUN (match_ip_next_hop_prefix_list, |
| 2525 | match_ip_next_hop_prefix_list_cmd, |
| 2526 | "match ip next-hop prefix-list WORD", |
| 2527 | MATCH_STR |
| 2528 | IP_STR |
| 2529 | "Match next-hop address of route\n" |
| 2530 | "Match entries of prefix-lists\n" |
| 2531 | "IP prefix-list name\n") |
| 2532 | { |
| 2533 | return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[0]); |
| 2534 | } |
| 2535 | |
| 2536 | DEFUN (no_match_ip_next_hop_prefix_list, |
| 2537 | no_match_ip_next_hop_prefix_list_cmd, |
| 2538 | "no match ip next-hop prefix-list", |
| 2539 | NO_STR |
| 2540 | MATCH_STR |
| 2541 | IP_STR |
| 2542 | "Match next-hop address of route\n" |
| 2543 | "Match entries of prefix-lists\n") |
| 2544 | { |
| 2545 | if (argc == 0) |
| 2546 | return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", NULL); |
| 2547 | |
| 2548 | return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", argv[0]); |
| 2549 | } |
| 2550 | |
| 2551 | ALIAS (no_match_ip_next_hop_prefix_list, |
| 2552 | no_match_ip_next_hop_prefix_list_val_cmd, |
| 2553 | "no match ip next-hop prefix-list WORD", |
| 2554 | NO_STR |
| 2555 | MATCH_STR |
| 2556 | IP_STR |
| 2557 | "Match next-hop address of route\n" |
| 2558 | "Match entries of prefix-lists\n" |
| 2559 | "IP prefix-list name\n") |
| 2560 | |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 2561 | DEFUN (match_ip_route_source_prefix_list, |
| 2562 | match_ip_route_source_prefix_list_cmd, |
| 2563 | "match ip route-source prefix-list WORD", |
| 2564 | MATCH_STR |
| 2565 | IP_STR |
| 2566 | "Match advertising source address of route\n" |
| 2567 | "Match entries of prefix-lists\n" |
| 2568 | "IP prefix-list name\n") |
| 2569 | { |
| 2570 | return bgp_route_match_add (vty, vty->index, "ip route-source prefix-list", argv[0]); |
| 2571 | } |
| 2572 | |
| 2573 | DEFUN (no_match_ip_route_source_prefix_list, |
| 2574 | no_match_ip_route_source_prefix_list_cmd, |
| 2575 | "no match ip route-source prefix-list", |
| 2576 | NO_STR |
| 2577 | MATCH_STR |
| 2578 | IP_STR |
| 2579 | "Match advertising source address of route\n" |
| 2580 | "Match entries of prefix-lists\n") |
| 2581 | { |
| 2582 | if (argc == 0) |
| 2583 | return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", NULL); |
| 2584 | |
| 2585 | return bgp_route_match_delete (vty, vty->index, "ip route-source prefix-list", argv[0]); |
| 2586 | } |
| 2587 | |
| 2588 | ALIAS (no_match_ip_route_source_prefix_list, |
| 2589 | no_match_ip_route_source_prefix_list_val_cmd, |
| 2590 | "no match ip route-source prefix-list WORD", |
| 2591 | NO_STR |
| 2592 | MATCH_STR |
| 2593 | IP_STR |
| 2594 | "Match advertising source address of route\n" |
| 2595 | "Match entries of prefix-lists\n" |
Paul Jakma | 30a2231 | 2008-08-15 14:05:22 +0100 | [diff] [blame] | 2596 | "IP prefix-list name\n") |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 2597 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2598 | DEFUN (match_metric, |
| 2599 | match_metric_cmd, |
| 2600 | "match metric <0-4294967295>", |
| 2601 | MATCH_STR |
| 2602 | "Match metric of route\n" |
| 2603 | "Metric value\n") |
| 2604 | { |
| 2605 | return bgp_route_match_add (vty, vty->index, "metric", argv[0]); |
| 2606 | } |
| 2607 | |
| 2608 | DEFUN (no_match_metric, |
| 2609 | no_match_metric_cmd, |
| 2610 | "no match metric", |
| 2611 | NO_STR |
| 2612 | MATCH_STR |
| 2613 | "Match metric of route\n") |
| 2614 | { |
| 2615 | if (argc == 0) |
| 2616 | return bgp_route_match_delete (vty, vty->index, "metric", NULL); |
| 2617 | |
| 2618 | return bgp_route_match_delete (vty, vty->index, "metric", argv[0]); |
| 2619 | } |
| 2620 | |
| 2621 | ALIAS (no_match_metric, |
| 2622 | no_match_metric_val_cmd, |
| 2623 | "no match metric <0-4294967295>", |
| 2624 | NO_STR |
| 2625 | MATCH_STR |
| 2626 | "Match metric of route\n" |
| 2627 | "Metric value\n") |
| 2628 | |
| 2629 | DEFUN (match_community, |
| 2630 | match_community_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2631 | "match community (<1-99>|<100-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2632 | MATCH_STR |
| 2633 | "Match BGP community list\n" |
| 2634 | "Community-list number (standard)\n" |
| 2635 | "Community-list number (expanded)\n" |
| 2636 | "Community-list name\n") |
| 2637 | { |
| 2638 | return bgp_route_match_add (vty, vty->index, "community", argv[0]); |
| 2639 | } |
| 2640 | |
| 2641 | DEFUN (match_community_exact, |
| 2642 | match_community_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2643 | "match community (<1-99>|<100-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2644 | MATCH_STR |
| 2645 | "Match BGP community list\n" |
| 2646 | "Community-list number (standard)\n" |
| 2647 | "Community-list number (expanded)\n" |
| 2648 | "Community-list name\n" |
| 2649 | "Do exact matching of communities\n") |
| 2650 | { |
| 2651 | int ret; |
| 2652 | char *argstr; |
| 2653 | |
| 2654 | argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, |
| 2655 | strlen (argv[0]) + strlen ("exact-match") + 2); |
| 2656 | |
| 2657 | sprintf (argstr, "%s exact-match", argv[0]); |
| 2658 | |
| 2659 | ret = bgp_route_match_add (vty, vty->index, "community", argstr); |
| 2660 | |
| 2661 | XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); |
| 2662 | |
| 2663 | return ret; |
| 2664 | } |
| 2665 | |
| 2666 | DEFUN (no_match_community, |
| 2667 | no_match_community_cmd, |
| 2668 | "no match community", |
| 2669 | NO_STR |
| 2670 | MATCH_STR |
| 2671 | "Match BGP community list\n") |
| 2672 | { |
| 2673 | return bgp_route_match_delete (vty, vty->index, "community", NULL); |
| 2674 | } |
| 2675 | |
| 2676 | ALIAS (no_match_community, |
| 2677 | no_match_community_val_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2678 | "no match community (<1-99>|<100-500>|WORD)", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2679 | NO_STR |
| 2680 | MATCH_STR |
| 2681 | "Match BGP community list\n" |
| 2682 | "Community-list number (standard)\n" |
| 2683 | "Community-list number (expanded)\n" |
| 2684 | "Community-list name\n") |
| 2685 | |
| 2686 | ALIAS (no_match_community, |
| 2687 | no_match_community_exact_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2688 | "no match community (<1-99>|<100-500>|WORD) exact-match", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2689 | NO_STR |
| 2690 | MATCH_STR |
| 2691 | "Match BGP community list\n" |
| 2692 | "Community-list number (standard)\n" |
| 2693 | "Community-list number (expanded)\n" |
| 2694 | "Community-list name\n" |
| 2695 | "Do exact matching of communities\n") |
| 2696 | |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2697 | DEFUN (match_ecommunity, |
| 2698 | match_ecommunity_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2699 | "match extcommunity (<1-99>|<100-500>|WORD)", |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2700 | MATCH_STR |
| 2701 | "Match BGP/VPN extended community list\n" |
| 2702 | "Extended community-list number (standard)\n" |
| 2703 | "Extended community-list number (expanded)\n" |
| 2704 | "Extended community-list name\n") |
| 2705 | { |
| 2706 | return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0]); |
| 2707 | } |
| 2708 | |
| 2709 | DEFUN (no_match_ecommunity, |
| 2710 | no_match_ecommunity_cmd, |
| 2711 | "no match extcommunity", |
| 2712 | NO_STR |
| 2713 | MATCH_STR |
| 2714 | "Match BGP/VPN extended community list\n") |
| 2715 | { |
| 2716 | return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL); |
| 2717 | } |
| 2718 | |
| 2719 | ALIAS (no_match_ecommunity, |
| 2720 | no_match_ecommunity_val_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 2721 | "no match extcommunity (<1-99>|<100-500>|WORD)", |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2722 | NO_STR |
| 2723 | MATCH_STR |
| 2724 | "Match BGP/VPN extended community list\n" |
| 2725 | "Extended community-list number (standard)\n" |
| 2726 | "Extended community-list number (expanded)\n" |
| 2727 | "Extended community-list name\n") |
| 2728 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2729 | DEFUN (match_aspath, |
| 2730 | match_aspath_cmd, |
| 2731 | "match as-path WORD", |
| 2732 | MATCH_STR |
| 2733 | "Match BGP AS path list\n" |
| 2734 | "AS path access-list name\n") |
| 2735 | { |
| 2736 | return bgp_route_match_add (vty, vty->index, "as-path", argv[0]); |
| 2737 | } |
| 2738 | |
| 2739 | DEFUN (no_match_aspath, |
| 2740 | no_match_aspath_cmd, |
| 2741 | "no match as-path", |
| 2742 | NO_STR |
| 2743 | MATCH_STR |
| 2744 | "Match BGP AS path list\n") |
| 2745 | { |
| 2746 | return bgp_route_match_delete (vty, vty->index, "as-path", NULL); |
| 2747 | } |
| 2748 | |
| 2749 | ALIAS (no_match_aspath, |
| 2750 | no_match_aspath_val_cmd, |
| 2751 | "no match as-path WORD", |
| 2752 | NO_STR |
| 2753 | MATCH_STR |
| 2754 | "Match BGP AS path list\n" |
| 2755 | "AS path access-list name\n") |
| 2756 | |
| 2757 | DEFUN (match_origin, |
| 2758 | match_origin_cmd, |
| 2759 | "match origin (egp|igp|incomplete)", |
| 2760 | MATCH_STR |
| 2761 | "BGP origin code\n" |
| 2762 | "remote EGP\n" |
| 2763 | "local IGP\n" |
| 2764 | "unknown heritage\n") |
| 2765 | { |
| 2766 | if (strncmp (argv[0], "igp", 2) == 0) |
| 2767 | return bgp_route_match_add (vty, vty->index, "origin", "igp"); |
| 2768 | if (strncmp (argv[0], "egp", 1) == 0) |
| 2769 | return bgp_route_match_add (vty, vty->index, "origin", "egp"); |
| 2770 | if (strncmp (argv[0], "incomplete", 2) == 0) |
| 2771 | return bgp_route_match_add (vty, vty->index, "origin", "incomplete"); |
| 2772 | |
| 2773 | return CMD_WARNING; |
| 2774 | } |
| 2775 | |
| 2776 | DEFUN (no_match_origin, |
| 2777 | no_match_origin_cmd, |
| 2778 | "no match origin", |
| 2779 | NO_STR |
| 2780 | MATCH_STR |
| 2781 | "BGP origin code\n") |
| 2782 | { |
| 2783 | return bgp_route_match_delete (vty, vty->index, "origin", NULL); |
| 2784 | } |
| 2785 | |
| 2786 | ALIAS (no_match_origin, |
| 2787 | no_match_origin_val_cmd, |
| 2788 | "no match origin (egp|igp|incomplete)", |
| 2789 | NO_STR |
| 2790 | MATCH_STR |
| 2791 | "BGP origin code\n" |
| 2792 | "remote EGP\n" |
| 2793 | "local IGP\n" |
| 2794 | "unknown heritage\n") |
| 2795 | |
| 2796 | DEFUN (set_ip_nexthop, |
| 2797 | set_ip_nexthop_cmd, |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2798 | "set ip next-hop A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2799 | SET_STR |
| 2800 | IP_STR |
| 2801 | "Next hop address\n" |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2802 | "IP address of next hop\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2803 | { |
| 2804 | union sockunion su; |
| 2805 | int ret; |
| 2806 | |
| 2807 | ret = str2sockunion (argv[0], &su); |
| 2808 | if (ret < 0) |
| 2809 | { |
| 2810 | vty_out (vty, "%% Malformed Next-hop address%s", VTY_NEWLINE); |
| 2811 | return CMD_WARNING; |
| 2812 | } |
| 2813 | |
| 2814 | return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[0]); |
| 2815 | } |
| 2816 | |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2817 | DEFUN (set_ip_nexthop_peer, |
| 2818 | set_ip_nexthop_peer_cmd, |
| 2819 | "set ip next-hop peer-address", |
| 2820 | SET_STR |
| 2821 | IP_STR |
| 2822 | "Next hop address\n" |
| 2823 | "Use peer address (for BGP only)\n") |
| 2824 | { |
| 2825 | return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address"); |
| 2826 | } |
| 2827 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 2828 | DEFUN_DEPRECATED (no_set_ip_nexthop_peer, |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2829 | no_set_ip_nexthop_peer_cmd, |
| 2830 | "no set ip next-hop peer-address", |
| 2831 | NO_STR |
| 2832 | SET_STR |
| 2833 | IP_STR |
| 2834 | "Next hop address\n" |
| 2835 | "Use peer address (for BGP only)\n") |
| 2836 | { |
| 2837 | return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL); |
| 2838 | } |
| 2839 | |
| 2840 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2841 | DEFUN (no_set_ip_nexthop, |
| 2842 | no_set_ip_nexthop_cmd, |
| 2843 | "no set ip next-hop", |
| 2844 | NO_STR |
| 2845 | SET_STR |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2846 | "Next hop address\n") |
| 2847 | { |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2848 | if (argc == 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2849 | return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL); |
| 2850 | |
| 2851 | return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[0]); |
| 2852 | } |
| 2853 | |
| 2854 | ALIAS (no_set_ip_nexthop, |
| 2855 | no_set_ip_nexthop_val_cmd, |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2856 | "no set ip next-hop A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2857 | NO_STR |
| 2858 | SET_STR |
| 2859 | IP_STR |
| 2860 | "Next hop address\n" |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 2861 | "IP address of next hop\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2862 | |
| 2863 | DEFUN (set_metric, |
| 2864 | set_metric_cmd, |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2865 | "set metric <0-4294967295>", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2866 | SET_STR |
| 2867 | "Metric value for destination routing protocol\n" |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2868 | "Metric value\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2869 | { |
| 2870 | return bgp_route_set_add (vty, vty->index, "metric", argv[0]); |
| 2871 | } |
| 2872 | |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2873 | ALIAS (set_metric, |
| 2874 | set_metric_addsub_cmd, |
| 2875 | "set metric <+/-metric>", |
| 2876 | SET_STR |
| 2877 | "Metric value for destination routing protocol\n" |
hasso | 033e861 | 2005-05-28 04:50:54 +0000 | [diff] [blame] | 2878 | "Add or subtract metric\n") |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 2879 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2880 | DEFUN (no_set_metric, |
| 2881 | no_set_metric_cmd, |
| 2882 | "no set metric", |
| 2883 | NO_STR |
| 2884 | SET_STR |
| 2885 | "Metric value for destination routing protocol\n") |
| 2886 | { |
| 2887 | if (argc == 0) |
| 2888 | return bgp_route_set_delete (vty, vty->index, "metric", NULL); |
| 2889 | |
| 2890 | return bgp_route_set_delete (vty, vty->index, "metric", argv[0]); |
| 2891 | } |
| 2892 | |
| 2893 | ALIAS (no_set_metric, |
| 2894 | no_set_metric_val_cmd, |
| 2895 | "no set metric <0-4294967295>", |
| 2896 | NO_STR |
| 2897 | SET_STR |
| 2898 | "Metric value for destination routing protocol\n" |
| 2899 | "Metric value\n") |
| 2900 | |
| 2901 | DEFUN (set_local_pref, |
| 2902 | set_local_pref_cmd, |
| 2903 | "set local-preference <0-4294967295>", |
| 2904 | SET_STR |
| 2905 | "BGP local preference path attribute\n" |
| 2906 | "Preference value\n") |
| 2907 | { |
| 2908 | return bgp_route_set_add (vty, vty->index, "local-preference", argv[0]); |
| 2909 | } |
| 2910 | |
| 2911 | DEFUN (no_set_local_pref, |
| 2912 | no_set_local_pref_cmd, |
| 2913 | "no set local-preference", |
| 2914 | NO_STR |
| 2915 | SET_STR |
| 2916 | "BGP local preference path attribute\n") |
| 2917 | { |
| 2918 | if (argc == 0) |
| 2919 | return bgp_route_set_delete (vty, vty->index, "local-preference", NULL); |
| 2920 | |
| 2921 | return bgp_route_set_delete (vty, vty->index, "local-preference", argv[0]); |
| 2922 | } |
| 2923 | |
| 2924 | ALIAS (no_set_local_pref, |
| 2925 | no_set_local_pref_val_cmd, |
| 2926 | "no set local-preference <0-4294967295>", |
| 2927 | NO_STR |
| 2928 | SET_STR |
| 2929 | "BGP local preference path attribute\n" |
| 2930 | "Preference value\n") |
| 2931 | |
| 2932 | DEFUN (set_weight, |
| 2933 | set_weight_cmd, |
| 2934 | "set weight <0-4294967295>", |
| 2935 | SET_STR |
| 2936 | "BGP weight for routing table\n" |
| 2937 | "Weight value\n") |
| 2938 | { |
| 2939 | return bgp_route_set_add (vty, vty->index, "weight", argv[0]); |
| 2940 | } |
| 2941 | |
| 2942 | DEFUN (no_set_weight, |
| 2943 | no_set_weight_cmd, |
| 2944 | "no set weight", |
| 2945 | NO_STR |
| 2946 | SET_STR |
| 2947 | "BGP weight for routing table\n") |
| 2948 | { |
| 2949 | if (argc == 0) |
| 2950 | return bgp_route_set_delete (vty, vty->index, "weight", NULL); |
| 2951 | |
| 2952 | return bgp_route_set_delete (vty, vty->index, "weight", argv[0]); |
| 2953 | } |
| 2954 | |
| 2955 | ALIAS (no_set_weight, |
| 2956 | no_set_weight_val_cmd, |
| 2957 | "no set weight <0-4294967295>", |
| 2958 | NO_STR |
| 2959 | SET_STR |
| 2960 | "BGP weight for routing table\n" |
| 2961 | "Weight value\n") |
| 2962 | |
| 2963 | DEFUN (set_aspath_prepend, |
| 2964 | set_aspath_prepend_cmd, |
Denis Ovsienko | 10819ec | 2009-06-09 15:15:33 +0400 | [diff] [blame] | 2965 | "set as-path prepend ." CMD_AS_RANGE, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2966 | SET_STR |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 2967 | "Transform BGP AS_PATH attribute\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2968 | "Prepend to the as-path\n" |
| 2969 | "AS number\n") |
| 2970 | { |
| 2971 | int ret; |
| 2972 | char *str; |
| 2973 | |
| 2974 | str = argv_concat (argv, argc, 0); |
| 2975 | ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str); |
| 2976 | XFREE (MTYPE_TMP, str); |
| 2977 | |
| 2978 | return ret; |
| 2979 | } |
| 2980 | |
| 2981 | DEFUN (no_set_aspath_prepend, |
| 2982 | no_set_aspath_prepend_cmd, |
| 2983 | "no set as-path prepend", |
| 2984 | NO_STR |
| 2985 | SET_STR |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 2986 | "Transform BGP AS_PATH attribute\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2987 | "Prepend to the as-path\n") |
| 2988 | { |
Denis Ovsienko | a7f93f3 | 2007-12-18 15:13:06 +0000 | [diff] [blame] | 2989 | int ret; |
| 2990 | char *str; |
| 2991 | |
| 2992 | if (argc == 0) |
| 2993 | return bgp_route_set_delete (vty, vty->index, "as-path prepend", NULL); |
| 2994 | |
| 2995 | str = argv_concat (argv, argc, 0); |
| 2996 | ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str); |
| 2997 | XFREE (MTYPE_TMP, str); |
| 2998 | return ret; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 2999 | } |
| 3000 | |
| 3001 | ALIAS (no_set_aspath_prepend, |
| 3002 | no_set_aspath_prepend_val_cmd, |
Denis Ovsienko | 10819ec | 2009-06-09 15:15:33 +0400 | [diff] [blame] | 3003 | "no set as-path prepend ." CMD_AS_RANGE, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3004 | NO_STR |
| 3005 | SET_STR |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3006 | "Transform BGP AS_PATH attribute\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3007 | "Prepend to the as-path\n" |
| 3008 | "AS number\n") |
| 3009 | |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3010 | DEFUN (set_aspath_exclude, |
| 3011 | set_aspath_exclude_cmd, |
Denis Ovsienko | 10819ec | 2009-06-09 15:15:33 +0400 | [diff] [blame] | 3012 | "set as-path exclude ." CMD_AS_RANGE, |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3013 | SET_STR |
| 3014 | "Transform BGP AS-path attribute\n" |
| 3015 | "Exclude from the as-path\n" |
| 3016 | "AS number\n") |
| 3017 | { |
| 3018 | int ret; |
| 3019 | char *str; |
| 3020 | |
| 3021 | str = argv_concat (argv, argc, 0); |
| 3022 | ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str); |
| 3023 | XFREE (MTYPE_TMP, str); |
| 3024 | return ret; |
| 3025 | } |
| 3026 | |
| 3027 | DEFUN (no_set_aspath_exclude, |
| 3028 | no_set_aspath_exclude_cmd, |
| 3029 | "no set as-path exclude", |
| 3030 | NO_STR |
| 3031 | SET_STR |
| 3032 | "Transform BGP AS_PATH attribute\n" |
| 3033 | "Exclude from the as-path\n") |
| 3034 | { |
| 3035 | int ret; |
| 3036 | char *str; |
| 3037 | |
| 3038 | if (argc == 0) |
| 3039 | return bgp_route_set_delete (vty, vty->index, "as-path exclude", NULL); |
| 3040 | |
| 3041 | str = argv_concat (argv, argc, 0); |
| 3042 | ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str); |
| 3043 | XFREE (MTYPE_TMP, str); |
| 3044 | return ret; |
| 3045 | } |
| 3046 | |
| 3047 | ALIAS (no_set_aspath_exclude, |
| 3048 | no_set_aspath_exclude_val_cmd, |
Denis Ovsienko | 10819ec | 2009-06-09 15:15:33 +0400 | [diff] [blame] | 3049 | "no set as-path exclude ." CMD_AS_RANGE, |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3050 | NO_STR |
| 3051 | SET_STR |
| 3052 | "Transform BGP AS_PATH attribute\n" |
| 3053 | "Exclude from the as-path\n" |
| 3054 | "AS number\n") |
| 3055 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3056 | DEFUN (set_community, |
| 3057 | set_community_cmd, |
| 3058 | "set community .AA:NN", |
| 3059 | SET_STR |
| 3060 | "BGP community attribute\n" |
| 3061 | "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n") |
| 3062 | { |
| 3063 | int i; |
| 3064 | int first = 0; |
| 3065 | int additive = 0; |
| 3066 | struct buffer *b; |
| 3067 | struct community *com = NULL; |
| 3068 | char *str; |
| 3069 | char *argstr; |
| 3070 | int ret; |
| 3071 | |
| 3072 | b = buffer_new (1024); |
| 3073 | |
| 3074 | for (i = 0; i < argc; i++) |
| 3075 | { |
| 3076 | if (strncmp (argv[i], "additive", strlen (argv[i])) == 0) |
| 3077 | { |
| 3078 | additive = 1; |
| 3079 | continue; |
| 3080 | } |
| 3081 | |
| 3082 | if (first) |
| 3083 | buffer_putc (b, ' '); |
| 3084 | else |
| 3085 | first = 1; |
| 3086 | |
| 3087 | if (strncmp (argv[i], "internet", strlen (argv[i])) == 0) |
| 3088 | { |
| 3089 | buffer_putstr (b, "internet"); |
| 3090 | continue; |
| 3091 | } |
| 3092 | if (strncmp (argv[i], "local-AS", strlen (argv[i])) == 0) |
| 3093 | { |
| 3094 | buffer_putstr (b, "local-AS"); |
| 3095 | continue; |
| 3096 | } |
| 3097 | if (strncmp (argv[i], "no-a", strlen ("no-a")) == 0 |
| 3098 | && strncmp (argv[i], "no-advertise", strlen (argv[i])) == 0) |
| 3099 | { |
| 3100 | buffer_putstr (b, "no-advertise"); |
| 3101 | continue; |
| 3102 | } |
| 3103 | if (strncmp (argv[i], "no-e", strlen ("no-e"))== 0 |
| 3104 | && strncmp (argv[i], "no-export", strlen (argv[i])) == 0) |
| 3105 | { |
| 3106 | buffer_putstr (b, "no-export"); |
| 3107 | continue; |
| 3108 | } |
| 3109 | buffer_putstr (b, argv[i]); |
| 3110 | } |
| 3111 | buffer_putc (b, '\0'); |
| 3112 | |
| 3113 | /* Fetch result string then compile it to communities attribute. */ |
| 3114 | str = buffer_getstr (b); |
| 3115 | buffer_free (b); |
| 3116 | |
| 3117 | if (str) |
| 3118 | { |
| 3119 | com = community_str2com (str); |
ajs | 3b8b185 | 2005-01-29 18:19:13 +0000 | [diff] [blame] | 3120 | XFREE (MTYPE_TMP, str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3121 | } |
| 3122 | |
| 3123 | /* Can't compile user input into communities attribute. */ |
| 3124 | if (! com) |
| 3125 | { |
| 3126 | vty_out (vty, "%% Malformed communities attribute%s", VTY_NEWLINE); |
| 3127 | return CMD_WARNING; |
| 3128 | } |
| 3129 | |
| 3130 | /* Set communites attribute string. */ |
| 3131 | str = community_str (com); |
| 3132 | |
| 3133 | if (additive) |
| 3134 | { |
| 3135 | argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1); |
| 3136 | strcpy (argstr, str); |
| 3137 | strcpy (argstr + strlen (str), " additive"); |
| 3138 | ret = bgp_route_set_add (vty, vty->index, "community", argstr); |
| 3139 | XFREE (MTYPE_TMP, argstr); |
| 3140 | } |
| 3141 | else |
| 3142 | ret = bgp_route_set_add (vty, vty->index, "community", str); |
| 3143 | |
| 3144 | community_free (com); |
| 3145 | |
| 3146 | return ret; |
| 3147 | } |
| 3148 | |
| 3149 | DEFUN (set_community_none, |
| 3150 | set_community_none_cmd, |
| 3151 | "set community none", |
| 3152 | SET_STR |
| 3153 | "BGP community attribute\n" |
| 3154 | "No community attribute\n") |
| 3155 | { |
| 3156 | return bgp_route_set_add (vty, vty->index, "community", "none"); |
| 3157 | } |
| 3158 | |
| 3159 | DEFUN (no_set_community, |
| 3160 | no_set_community_cmd, |
| 3161 | "no set community", |
| 3162 | NO_STR |
| 3163 | SET_STR |
| 3164 | "BGP community attribute\n") |
| 3165 | { |
| 3166 | return bgp_route_set_delete (vty, vty->index, "community", NULL); |
| 3167 | } |
| 3168 | |
| 3169 | ALIAS (no_set_community, |
| 3170 | no_set_community_val_cmd, |
| 3171 | "no set community .AA:NN", |
| 3172 | NO_STR |
| 3173 | SET_STR |
| 3174 | "BGP community attribute\n" |
| 3175 | "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n") |
| 3176 | |
| 3177 | ALIAS (no_set_community, |
| 3178 | no_set_community_none_cmd, |
| 3179 | "no set community none", |
| 3180 | NO_STR |
| 3181 | SET_STR |
| 3182 | "BGP community attribute\n" |
| 3183 | "No community attribute\n") |
| 3184 | |
| 3185 | DEFUN (set_community_delete, |
| 3186 | set_community_delete_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 3187 | "set comm-list (<1-99>|<100-500>|WORD) delete", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3188 | SET_STR |
| 3189 | "set BGP community list (for deletion)\n" |
| 3190 | "Community-list number (standard)\n" |
| 3191 | "Communitly-list number (expanded)\n" |
| 3192 | "Community-list name\n" |
| 3193 | "Delete matching communities\n") |
| 3194 | { |
| 3195 | char *str; |
| 3196 | |
| 3197 | str = XCALLOC (MTYPE_TMP, strlen (argv[0]) + strlen (" delete") + 1); |
| 3198 | strcpy (str, argv[0]); |
| 3199 | strcpy (str + strlen (argv[0]), " delete"); |
| 3200 | |
| 3201 | bgp_route_set_add (vty, vty->index, "comm-list", str); |
| 3202 | |
| 3203 | XFREE (MTYPE_TMP, str); |
| 3204 | return CMD_SUCCESS; |
| 3205 | } |
| 3206 | |
| 3207 | DEFUN (no_set_community_delete, |
| 3208 | no_set_community_delete_cmd, |
| 3209 | "no set comm-list", |
| 3210 | NO_STR |
| 3211 | SET_STR |
| 3212 | "set BGP community list (for deletion)\n") |
| 3213 | { |
| 3214 | return bgp_route_set_delete (vty, vty->index, "comm-list", NULL); |
| 3215 | } |
| 3216 | |
| 3217 | ALIAS (no_set_community_delete, |
| 3218 | no_set_community_delete_val_cmd, |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 3219 | "no set comm-list (<1-99>|<100-500>|WORD) delete", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3220 | NO_STR |
| 3221 | SET_STR |
| 3222 | "set BGP community list (for deletion)\n" |
| 3223 | "Community-list number (standard)\n" |
| 3224 | "Communitly-list number (expanded)\n" |
| 3225 | "Community-list name\n" |
| 3226 | "Delete matching communities\n") |
| 3227 | |
| 3228 | DEFUN (set_ecommunity_rt, |
| 3229 | set_ecommunity_rt_cmd, |
| 3230 | "set extcommunity rt .ASN:nn_or_IP-address:nn", |
| 3231 | SET_STR |
| 3232 | "BGP extended community attribute\n" |
Denis Ovsienko | e6b6a56 | 2009-06-01 20:20:36 +0400 | [diff] [blame] | 3233 | "Route Target extended community\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3234 | "VPN extended community\n") |
| 3235 | { |
| 3236 | int ret; |
| 3237 | char *str; |
| 3238 | |
| 3239 | str = argv_concat (argv, argc, 0); |
| 3240 | ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str); |
| 3241 | XFREE (MTYPE_TMP, str); |
| 3242 | |
| 3243 | return ret; |
| 3244 | } |
| 3245 | |
| 3246 | DEFUN (no_set_ecommunity_rt, |
| 3247 | no_set_ecommunity_rt_cmd, |
| 3248 | "no set extcommunity rt", |
| 3249 | NO_STR |
| 3250 | SET_STR |
| 3251 | "BGP extended community attribute\n" |
Denis Ovsienko | e6b6a56 | 2009-06-01 20:20:36 +0400 | [diff] [blame] | 3252 | "Route Target extended community\n") |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3253 | { |
| 3254 | return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL); |
| 3255 | } |
| 3256 | |
| 3257 | ALIAS (no_set_ecommunity_rt, |
| 3258 | no_set_ecommunity_rt_val_cmd, |
| 3259 | "no set extcommunity rt .ASN:nn_or_IP-address:nn", |
| 3260 | NO_STR |
| 3261 | SET_STR |
| 3262 | "BGP extended community attribute\n" |
Denis Ovsienko | e6b6a56 | 2009-06-01 20:20:36 +0400 | [diff] [blame] | 3263 | "Route Target extended community\n" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3264 | "VPN extended community\n") |
| 3265 | |
| 3266 | DEFUN (set_ecommunity_soo, |
| 3267 | set_ecommunity_soo_cmd, |
| 3268 | "set extcommunity soo .ASN:nn_or_IP-address:nn", |
| 3269 | SET_STR |
| 3270 | "BGP extended community attribute\n" |
| 3271 | "Site-of-Origin extended community\n" |
| 3272 | "VPN extended community\n") |
| 3273 | { |
| 3274 | int ret; |
| 3275 | char *str; |
| 3276 | |
| 3277 | str = argv_concat (argv, argc, 0); |
| 3278 | ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str); |
| 3279 | XFREE (MTYPE_TMP, str); |
| 3280 | return ret; |
| 3281 | } |
| 3282 | |
| 3283 | DEFUN (no_set_ecommunity_soo, |
| 3284 | no_set_ecommunity_soo_cmd, |
| 3285 | "no set extcommunity soo", |
| 3286 | NO_STR |
| 3287 | SET_STR |
| 3288 | "BGP extended community attribute\n" |
| 3289 | "Site-of-Origin extended community\n") |
| 3290 | { |
| 3291 | return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL); |
| 3292 | } |
| 3293 | |
| 3294 | ALIAS (no_set_ecommunity_soo, |
| 3295 | no_set_ecommunity_soo_val_cmd, |
| 3296 | "no set extcommunity soo .ASN:nn_or_IP-address:nn", |
| 3297 | NO_STR |
| 3298 | SET_STR |
| 3299 | "BGP extended community attribute\n" |
| 3300 | "Site-of-Origin extended community\n" |
| 3301 | "VPN extended community\n") |
| 3302 | |
| 3303 | DEFUN (set_origin, |
| 3304 | set_origin_cmd, |
| 3305 | "set origin (egp|igp|incomplete)", |
| 3306 | SET_STR |
| 3307 | "BGP origin code\n" |
| 3308 | "remote EGP\n" |
| 3309 | "local IGP\n" |
| 3310 | "unknown heritage\n") |
| 3311 | { |
| 3312 | if (strncmp (argv[0], "igp", 2) == 0) |
| 3313 | return bgp_route_set_add (vty, vty->index, "origin", "igp"); |
| 3314 | if (strncmp (argv[0], "egp", 1) == 0) |
| 3315 | return bgp_route_set_add (vty, vty->index, "origin", "egp"); |
| 3316 | if (strncmp (argv[0], "incomplete", 2) == 0) |
| 3317 | return bgp_route_set_add (vty, vty->index, "origin", "incomplete"); |
| 3318 | |
| 3319 | return CMD_WARNING; |
| 3320 | } |
| 3321 | |
| 3322 | DEFUN (no_set_origin, |
| 3323 | no_set_origin_cmd, |
| 3324 | "no set origin", |
| 3325 | NO_STR |
| 3326 | SET_STR |
| 3327 | "BGP origin code\n") |
| 3328 | { |
| 3329 | return bgp_route_set_delete (vty, vty->index, "origin", NULL); |
| 3330 | } |
| 3331 | |
| 3332 | ALIAS (no_set_origin, |
| 3333 | no_set_origin_val_cmd, |
| 3334 | "no set origin (egp|igp|incomplete)", |
| 3335 | NO_STR |
| 3336 | SET_STR |
| 3337 | "BGP origin code\n" |
| 3338 | "remote EGP\n" |
| 3339 | "local IGP\n" |
| 3340 | "unknown heritage\n") |
| 3341 | |
| 3342 | DEFUN (set_atomic_aggregate, |
| 3343 | set_atomic_aggregate_cmd, |
| 3344 | "set atomic-aggregate", |
| 3345 | SET_STR |
| 3346 | "BGP atomic aggregate attribute\n" ) |
| 3347 | { |
| 3348 | return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL); |
| 3349 | } |
| 3350 | |
| 3351 | DEFUN (no_set_atomic_aggregate, |
| 3352 | no_set_atomic_aggregate_cmd, |
| 3353 | "no set atomic-aggregate", |
| 3354 | NO_STR |
| 3355 | SET_STR |
| 3356 | "BGP atomic aggregate attribute\n" ) |
| 3357 | { |
| 3358 | return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL); |
| 3359 | } |
| 3360 | |
| 3361 | DEFUN (set_aggregator_as, |
| 3362 | set_aggregator_as_cmd, |
Paul Jakma | 320da87 | 2008-07-02 13:40:33 +0000 | [diff] [blame] | 3363 | "set aggregator as " CMD_AS_RANGE " A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3364 | SET_STR |
| 3365 | "BGP aggregator attribute\n" |
| 3366 | "AS number of aggregator\n" |
| 3367 | "AS number\n" |
| 3368 | "IP address of aggregator\n") |
| 3369 | { |
| 3370 | int ret; |
| 3371 | as_t as; |
| 3372 | struct in_addr address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3373 | char *argstr; |
| 3374 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 3375 | VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 3376 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3377 | ret = inet_aton (argv[1], &address); |
| 3378 | if (ret == 0) |
| 3379 | { |
| 3380 | vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); |
| 3381 | return CMD_WARNING; |
| 3382 | } |
| 3383 | |
| 3384 | argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, |
| 3385 | strlen (argv[0]) + strlen (argv[1]) + 2); |
| 3386 | |
| 3387 | sprintf (argstr, "%s %s", argv[0], argv[1]); |
| 3388 | |
| 3389 | ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr); |
| 3390 | |
| 3391 | XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); |
| 3392 | |
| 3393 | return ret; |
| 3394 | } |
| 3395 | |
| 3396 | DEFUN (no_set_aggregator_as, |
| 3397 | no_set_aggregator_as_cmd, |
| 3398 | "no set aggregator as", |
| 3399 | NO_STR |
| 3400 | SET_STR |
| 3401 | "BGP aggregator attribute\n" |
| 3402 | "AS number of aggregator\n") |
| 3403 | { |
| 3404 | int ret; |
| 3405 | as_t as; |
| 3406 | struct in_addr address; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3407 | char *argstr; |
| 3408 | |
| 3409 | if (argv == 0) |
| 3410 | return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL); |
| 3411 | |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 3412 | VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3413 | |
| 3414 | ret = inet_aton (argv[1], &address); |
| 3415 | if (ret == 0) |
| 3416 | { |
| 3417 | vty_out (vty, "Aggregator IP address is invalid%s", VTY_NEWLINE); |
| 3418 | return CMD_WARNING; |
| 3419 | } |
| 3420 | |
| 3421 | argstr = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, |
| 3422 | strlen (argv[0]) + strlen (argv[1]) + 2); |
| 3423 | |
| 3424 | sprintf (argstr, "%s %s", argv[0], argv[1]); |
| 3425 | |
| 3426 | ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr); |
| 3427 | |
| 3428 | XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); |
| 3429 | |
| 3430 | return ret; |
| 3431 | } |
| 3432 | |
| 3433 | ALIAS (no_set_aggregator_as, |
| 3434 | no_set_aggregator_as_val_cmd, |
Paul Jakma | 320da87 | 2008-07-02 13:40:33 +0000 | [diff] [blame] | 3435 | "no set aggregator as " CMD_AS_RANGE " A.B.C.D", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3436 | NO_STR |
| 3437 | SET_STR |
| 3438 | "BGP aggregator attribute\n" |
| 3439 | "AS number of aggregator\n" |
| 3440 | "AS number\n" |
| 3441 | "IP address of aggregator\n") |
| 3442 | |
| 3443 | |
| 3444 | #ifdef HAVE_IPV6 |
| 3445 | DEFUN (match_ipv6_address, |
| 3446 | match_ipv6_address_cmd, |
| 3447 | "match ipv6 address WORD", |
| 3448 | MATCH_STR |
| 3449 | IPV6_STR |
| 3450 | "Match IPv6 address of route\n" |
| 3451 | "IPv6 access-list name\n") |
| 3452 | { |
| 3453 | return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[0]); |
| 3454 | } |
| 3455 | |
| 3456 | DEFUN (no_match_ipv6_address, |
| 3457 | no_match_ipv6_address_cmd, |
| 3458 | "no match ipv6 address WORD", |
| 3459 | NO_STR |
| 3460 | MATCH_STR |
| 3461 | IPV6_STR |
| 3462 | "Match IPv6 address of route\n" |
| 3463 | "IPv6 access-list name\n") |
| 3464 | { |
| 3465 | return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[0]); |
| 3466 | } |
| 3467 | |
| 3468 | DEFUN (match_ipv6_next_hop, |
| 3469 | match_ipv6_next_hop_cmd, |
| 3470 | "match ipv6 next-hop X:X::X:X", |
| 3471 | MATCH_STR |
| 3472 | IPV6_STR |
| 3473 | "Match IPv6 next-hop address of route\n" |
| 3474 | "IPv6 address of next hop\n") |
| 3475 | { |
| 3476 | return bgp_route_match_add (vty, vty->index, "ipv6 next-hop", argv[0]); |
| 3477 | } |
| 3478 | |
| 3479 | DEFUN (no_match_ipv6_next_hop, |
| 3480 | no_match_ipv6_next_hop_cmd, |
| 3481 | "no match ipv6 next-hop X:X::X:X", |
| 3482 | NO_STR |
| 3483 | MATCH_STR |
| 3484 | IPV6_STR |
| 3485 | "Match IPv6 next-hop address of route\n" |
| 3486 | "IPv6 address of next hop\n") |
| 3487 | { |
| 3488 | return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[0]); |
| 3489 | } |
| 3490 | |
| 3491 | DEFUN (match_ipv6_address_prefix_list, |
| 3492 | match_ipv6_address_prefix_list_cmd, |
| 3493 | "match ipv6 address prefix-list WORD", |
| 3494 | MATCH_STR |
| 3495 | IPV6_STR |
| 3496 | "Match address of route\n" |
| 3497 | "Match entries of prefix-lists\n" |
| 3498 | "IP prefix-list name\n") |
| 3499 | { |
| 3500 | return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", argv[0]); |
| 3501 | } |
| 3502 | |
| 3503 | DEFUN (no_match_ipv6_address_prefix_list, |
| 3504 | no_match_ipv6_address_prefix_list_cmd, |
| 3505 | "no match ipv6 address prefix-list WORD", |
| 3506 | NO_STR |
| 3507 | MATCH_STR |
| 3508 | IPV6_STR |
| 3509 | "Match address of route\n" |
| 3510 | "Match entries of prefix-lists\n" |
| 3511 | "IP prefix-list name\n") |
| 3512 | { |
| 3513 | return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[0]); |
| 3514 | } |
| 3515 | |
| 3516 | DEFUN (set_ipv6_nexthop_global, |
| 3517 | set_ipv6_nexthop_global_cmd, |
| 3518 | "set ipv6 next-hop global X:X::X:X", |
| 3519 | SET_STR |
| 3520 | IPV6_STR |
| 3521 | "IPv6 next-hop address\n" |
| 3522 | "IPv6 global address\n" |
| 3523 | "IPv6 address of next hop\n") |
| 3524 | { |
| 3525 | return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[0]); |
| 3526 | } |
| 3527 | |
| 3528 | DEFUN (no_set_ipv6_nexthop_global, |
| 3529 | no_set_ipv6_nexthop_global_cmd, |
| 3530 | "no set ipv6 next-hop global", |
| 3531 | NO_STR |
| 3532 | SET_STR |
| 3533 | IPV6_STR |
| 3534 | "IPv6 next-hop address\n" |
| 3535 | "IPv6 global address\n") |
| 3536 | { |
| 3537 | if (argc == 0) |
| 3538 | return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL); |
| 3539 | |
| 3540 | return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[0]); |
| 3541 | } |
| 3542 | |
| 3543 | ALIAS (no_set_ipv6_nexthop_global, |
| 3544 | no_set_ipv6_nexthop_global_val_cmd, |
| 3545 | "no set ipv6 next-hop global X:X::X:X", |
| 3546 | NO_STR |
| 3547 | SET_STR |
| 3548 | IPV6_STR |
| 3549 | "IPv6 next-hop address\n" |
| 3550 | "IPv6 global address\n" |
| 3551 | "IPv6 address of next hop\n") |
| 3552 | |
| 3553 | DEFUN (set_ipv6_nexthop_local, |
| 3554 | set_ipv6_nexthop_local_cmd, |
| 3555 | "set ipv6 next-hop local X:X::X:X", |
| 3556 | SET_STR |
| 3557 | IPV6_STR |
| 3558 | "IPv6 next-hop address\n" |
| 3559 | "IPv6 local address\n" |
| 3560 | "IPv6 address of next hop\n") |
| 3561 | { |
| 3562 | return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[0]); |
| 3563 | } |
| 3564 | |
| 3565 | DEFUN (no_set_ipv6_nexthop_local, |
| 3566 | no_set_ipv6_nexthop_local_cmd, |
| 3567 | "no set ipv6 next-hop local", |
| 3568 | NO_STR |
| 3569 | SET_STR |
| 3570 | IPV6_STR |
| 3571 | "IPv6 next-hop address\n" |
| 3572 | "IPv6 local address\n") |
| 3573 | { |
| 3574 | if (argc == 0) |
| 3575 | return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL); |
| 3576 | |
| 3577 | return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]); |
| 3578 | } |
| 3579 | |
| 3580 | ALIAS (no_set_ipv6_nexthop_local, |
| 3581 | no_set_ipv6_nexthop_local_val_cmd, |
| 3582 | "no set ipv6 next-hop local X:X::X:X", |
| 3583 | NO_STR |
| 3584 | SET_STR |
| 3585 | IPV6_STR |
| 3586 | "IPv6 next-hop address\n" |
| 3587 | "IPv6 local address\n" |
| 3588 | "IPv6 address of next hop\n") |
| 3589 | #endif /* HAVE_IPV6 */ |
| 3590 | |
| 3591 | DEFUN (set_vpnv4_nexthop, |
| 3592 | set_vpnv4_nexthop_cmd, |
| 3593 | "set vpnv4 next-hop A.B.C.D", |
| 3594 | SET_STR |
| 3595 | "VPNv4 information\n" |
| 3596 | "VPNv4 next-hop address\n" |
| 3597 | "IP address of next hop\n") |
| 3598 | { |
| 3599 | return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]); |
| 3600 | } |
| 3601 | |
| 3602 | DEFUN (no_set_vpnv4_nexthop, |
| 3603 | no_set_vpnv4_nexthop_cmd, |
| 3604 | "no set vpnv4 next-hop", |
| 3605 | NO_STR |
| 3606 | SET_STR |
| 3607 | "VPNv4 information\n" |
| 3608 | "VPNv4 next-hop address\n") |
| 3609 | { |
| 3610 | if (argc == 0) |
| 3611 | return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); |
| 3612 | |
| 3613 | return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]); |
| 3614 | } |
| 3615 | |
| 3616 | ALIAS (no_set_vpnv4_nexthop, |
| 3617 | no_set_vpnv4_nexthop_val_cmd, |
| 3618 | "no set vpnv4 next-hop A.B.C.D", |
| 3619 | NO_STR |
| 3620 | SET_STR |
| 3621 | "VPNv4 information\n" |
| 3622 | "VPNv4 next-hop address\n" |
| 3623 | "IP address of next hop\n") |
| 3624 | |
| 3625 | DEFUN (set_originator_id, |
| 3626 | set_originator_id_cmd, |
| 3627 | "set originator-id A.B.C.D", |
| 3628 | SET_STR |
| 3629 | "BGP originator ID attribute\n" |
| 3630 | "IP address of originator\n") |
| 3631 | { |
| 3632 | return bgp_route_set_add (vty, vty->index, "originator-id", argv[0]); |
| 3633 | } |
| 3634 | |
| 3635 | DEFUN (no_set_originator_id, |
| 3636 | no_set_originator_id_cmd, |
| 3637 | "no set originator-id", |
| 3638 | NO_STR |
| 3639 | SET_STR |
| 3640 | "BGP originator ID attribute\n") |
| 3641 | { |
| 3642 | if (argc == 0) |
| 3643 | return bgp_route_set_delete (vty, vty->index, "originator-id", NULL); |
| 3644 | |
| 3645 | return bgp_route_set_delete (vty, vty->index, "originator-id", argv[0]); |
| 3646 | } |
| 3647 | |
| 3648 | ALIAS (no_set_originator_id, |
| 3649 | no_set_originator_id_val_cmd, |
| 3650 | "no set originator-id A.B.C.D", |
| 3651 | NO_STR |
| 3652 | SET_STR |
| 3653 | "BGP originator ID attribute\n" |
| 3654 | "IP address of originator\n") |
| 3655 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3656 | DEFUN_DEPRECATED (set_pathlimit_ttl, |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3657 | set_pathlimit_ttl_cmd, |
| 3658 | "set pathlimit ttl <1-255>", |
| 3659 | SET_STR |
| 3660 | "BGP AS-Pathlimit attribute\n" |
| 3661 | "Set AS-Path Hop-count TTL\n") |
| 3662 | { |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3663 | return CMD_SUCCESS; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3664 | } |
| 3665 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3666 | DEFUN_DEPRECATED (no_set_pathlimit_ttl, |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3667 | no_set_pathlimit_ttl_cmd, |
| 3668 | "no set pathlimit ttl", |
| 3669 | NO_STR |
| 3670 | SET_STR |
| 3671 | "BGP AS-Pathlimit attribute\n" |
| 3672 | "Set AS-Path Hop-count TTL\n") |
| 3673 | { |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3674 | return CMD_SUCCESS; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3675 | } |
| 3676 | |
| 3677 | ALIAS (no_set_pathlimit_ttl, |
| 3678 | no_set_pathlimit_ttl_val_cmd, |
| 3679 | "no set pathlimit ttl <1-255>", |
| 3680 | NO_STR |
| 3681 | MATCH_STR |
| 3682 | "BGP AS-Pathlimit attribute\n" |
| 3683 | "Set AS-Path Hop-count TTL\n") |
| 3684 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3685 | DEFUN_DEPRECATED (match_pathlimit_as, |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3686 | match_pathlimit_as_cmd, |
| 3687 | "match pathlimit as <1-65535>", |
| 3688 | MATCH_STR |
| 3689 | "BGP AS-Pathlimit attribute\n" |
| 3690 | "Match Pathlimit AS number\n") |
| 3691 | { |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3692 | return CMD_SUCCESS; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3693 | } |
| 3694 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3695 | DEFUN_DEPRECATED (no_match_pathlimit_as, |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3696 | no_match_pathlimit_as_cmd, |
| 3697 | "no match pathlimit as", |
| 3698 | NO_STR |
| 3699 | MATCH_STR |
| 3700 | "BGP AS-Pathlimit attribute\n" |
| 3701 | "Match Pathlimit AS number\n") |
| 3702 | { |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3703 | return CMD_SUCCESS; |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3704 | } |
| 3705 | |
| 3706 | ALIAS (no_match_pathlimit_as, |
| 3707 | no_match_pathlimit_as_val_cmd, |
| 3708 | "no match pathlimit as <1-65535>", |
| 3709 | NO_STR |
| 3710 | MATCH_STR |
| 3711 | "BGP AS-Pathlimit attribute\n" |
| 3712 | "Match Pathlimit ASN\n") |
| 3713 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3714 | |
| 3715 | /* Initialization of route map. */ |
| 3716 | void |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 3717 | bgp_route_map_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3718 | { |
| 3719 | route_map_init (); |
| 3720 | route_map_init_vty (); |
| 3721 | route_map_add_hook (bgp_route_map_update); |
| 3722 | route_map_delete_hook (bgp_route_map_update); |
| 3723 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3724 | route_map_install_match (&route_match_peer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3725 | route_map_install_match (&route_match_ip_address_cmd); |
| 3726 | route_map_install_match (&route_match_ip_next_hop_cmd); |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 3727 | route_map_install_match (&route_match_ip_route_source_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3728 | route_map_install_match (&route_match_ip_address_prefix_list_cmd); |
| 3729 | route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd); |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 3730 | route_map_install_match (&route_match_ip_route_source_prefix_list_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3731 | route_map_install_match (&route_match_aspath_cmd); |
| 3732 | route_map_install_match (&route_match_community_cmd); |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 3733 | route_map_install_match (&route_match_ecommunity_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3734 | route_map_install_match (&route_match_metric_cmd); |
| 3735 | route_map_install_match (&route_match_origin_cmd); |
| 3736 | |
| 3737 | route_map_install_set (&route_set_ip_nexthop_cmd); |
| 3738 | route_map_install_set (&route_set_local_pref_cmd); |
| 3739 | route_map_install_set (&route_set_weight_cmd); |
| 3740 | route_map_install_set (&route_set_metric_cmd); |
| 3741 | route_map_install_set (&route_set_aspath_prepend_cmd); |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3742 | route_map_install_set (&route_set_aspath_exclude_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3743 | route_map_install_set (&route_set_origin_cmd); |
| 3744 | route_map_install_set (&route_set_atomic_aggregate_cmd); |
| 3745 | route_map_install_set (&route_set_aggregator_as_cmd); |
| 3746 | route_map_install_set (&route_set_community_cmd); |
| 3747 | route_map_install_set (&route_set_community_delete_cmd); |
| 3748 | route_map_install_set (&route_set_vpnv4_nexthop_cmd); |
| 3749 | route_map_install_set (&route_set_originator_id_cmd); |
| 3750 | route_map_install_set (&route_set_ecommunity_rt_cmd); |
| 3751 | route_map_install_set (&route_set_ecommunity_soo_cmd); |
| 3752 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 3753 | install_element (RMAP_NODE, &match_peer_cmd); |
| 3754 | install_element (RMAP_NODE, &match_peer_local_cmd); |
| 3755 | install_element (RMAP_NODE, &no_match_peer_cmd); |
| 3756 | install_element (RMAP_NODE, &no_match_peer_val_cmd); |
| 3757 | install_element (RMAP_NODE, &no_match_peer_local_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3758 | install_element (RMAP_NODE, &match_ip_address_cmd); |
| 3759 | install_element (RMAP_NODE, &no_match_ip_address_cmd); |
| 3760 | install_element (RMAP_NODE, &no_match_ip_address_val_cmd); |
| 3761 | install_element (RMAP_NODE, &match_ip_next_hop_cmd); |
| 3762 | install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); |
| 3763 | install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd); |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 3764 | install_element (RMAP_NODE, &match_ip_route_source_cmd); |
| 3765 | install_element (RMAP_NODE, &no_match_ip_route_source_cmd); |
| 3766 | install_element (RMAP_NODE, &no_match_ip_route_source_val_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3767 | |
| 3768 | install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd); |
| 3769 | install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd); |
| 3770 | install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd); |
| 3771 | install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); |
| 3772 | install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); |
| 3773 | install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd); |
hasso | c1643bb | 2005-02-02 16:43:17 +0000 | [diff] [blame] | 3774 | install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd); |
| 3775 | install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd); |
| 3776 | install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_val_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3777 | |
| 3778 | install_element (RMAP_NODE, &match_aspath_cmd); |
| 3779 | install_element (RMAP_NODE, &no_match_aspath_cmd); |
| 3780 | install_element (RMAP_NODE, &no_match_aspath_val_cmd); |
| 3781 | install_element (RMAP_NODE, &match_metric_cmd); |
| 3782 | install_element (RMAP_NODE, &no_match_metric_cmd); |
| 3783 | install_element (RMAP_NODE, &no_match_metric_val_cmd); |
| 3784 | install_element (RMAP_NODE, &match_community_cmd); |
| 3785 | install_element (RMAP_NODE, &match_community_exact_cmd); |
| 3786 | install_element (RMAP_NODE, &no_match_community_cmd); |
| 3787 | install_element (RMAP_NODE, &no_match_community_val_cmd); |
| 3788 | install_element (RMAP_NODE, &no_match_community_exact_cmd); |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 3789 | install_element (RMAP_NODE, &match_ecommunity_cmd); |
| 3790 | install_element (RMAP_NODE, &no_match_ecommunity_cmd); |
| 3791 | install_element (RMAP_NODE, &no_match_ecommunity_val_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3792 | install_element (RMAP_NODE, &match_origin_cmd); |
| 3793 | install_element (RMAP_NODE, &no_match_origin_cmd); |
| 3794 | install_element (RMAP_NODE, &no_match_origin_val_cmd); |
| 3795 | |
| 3796 | install_element (RMAP_NODE, &set_ip_nexthop_cmd); |
paul | af5cd0a | 2003-11-02 07:24:40 +0000 | [diff] [blame] | 3797 | install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3798 | install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); |
| 3799 | install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd); |
| 3800 | install_element (RMAP_NODE, &set_local_pref_cmd); |
| 3801 | install_element (RMAP_NODE, &no_set_local_pref_cmd); |
| 3802 | install_element (RMAP_NODE, &no_set_local_pref_val_cmd); |
| 3803 | install_element (RMAP_NODE, &set_weight_cmd); |
| 3804 | install_element (RMAP_NODE, &no_set_weight_cmd); |
| 3805 | install_element (RMAP_NODE, &no_set_weight_val_cmd); |
| 3806 | install_element (RMAP_NODE, &set_metric_cmd); |
paul | 73ffb25 | 2003-04-19 15:49:49 +0000 | [diff] [blame] | 3807 | install_element (RMAP_NODE, &set_metric_addsub_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3808 | install_element (RMAP_NODE, &no_set_metric_cmd); |
| 3809 | install_element (RMAP_NODE, &no_set_metric_val_cmd); |
| 3810 | install_element (RMAP_NODE, &set_aspath_prepend_cmd); |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3811 | install_element (RMAP_NODE, &set_aspath_exclude_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3812 | install_element (RMAP_NODE, &no_set_aspath_prepend_cmd); |
| 3813 | install_element (RMAP_NODE, &no_set_aspath_prepend_val_cmd); |
Denis Ovsienko | 841f7a5 | 2008-04-10 11:47:45 +0000 | [diff] [blame] | 3814 | install_element (RMAP_NODE, &no_set_aspath_exclude_cmd); |
| 3815 | install_element (RMAP_NODE, &no_set_aspath_exclude_val_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3816 | install_element (RMAP_NODE, &set_origin_cmd); |
| 3817 | install_element (RMAP_NODE, &no_set_origin_cmd); |
| 3818 | install_element (RMAP_NODE, &no_set_origin_val_cmd); |
| 3819 | install_element (RMAP_NODE, &set_atomic_aggregate_cmd); |
| 3820 | install_element (RMAP_NODE, &no_set_atomic_aggregate_cmd); |
| 3821 | install_element (RMAP_NODE, &set_aggregator_as_cmd); |
| 3822 | install_element (RMAP_NODE, &no_set_aggregator_as_cmd); |
| 3823 | install_element (RMAP_NODE, &no_set_aggregator_as_val_cmd); |
| 3824 | install_element (RMAP_NODE, &set_community_cmd); |
| 3825 | install_element (RMAP_NODE, &set_community_none_cmd); |
| 3826 | install_element (RMAP_NODE, &no_set_community_cmd); |
| 3827 | install_element (RMAP_NODE, &no_set_community_val_cmd); |
| 3828 | install_element (RMAP_NODE, &no_set_community_none_cmd); |
| 3829 | install_element (RMAP_NODE, &set_community_delete_cmd); |
| 3830 | install_element (RMAP_NODE, &no_set_community_delete_cmd); |
| 3831 | install_element (RMAP_NODE, &no_set_community_delete_val_cmd); |
| 3832 | install_element (RMAP_NODE, &set_ecommunity_rt_cmd); |
| 3833 | install_element (RMAP_NODE, &no_set_ecommunity_rt_cmd); |
| 3834 | install_element (RMAP_NODE, &no_set_ecommunity_rt_val_cmd); |
| 3835 | install_element (RMAP_NODE, &set_ecommunity_soo_cmd); |
| 3836 | install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd); |
| 3837 | install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd); |
| 3838 | install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd); |
| 3839 | install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); |
| 3840 | install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd); |
| 3841 | install_element (RMAP_NODE, &set_originator_id_cmd); |
| 3842 | install_element (RMAP_NODE, &no_set_originator_id_cmd); |
| 3843 | install_element (RMAP_NODE, &no_set_originator_id_val_cmd); |
| 3844 | |
| 3845 | #ifdef HAVE_IPV6 |
| 3846 | route_map_install_match (&route_match_ipv6_address_cmd); |
| 3847 | route_map_install_match (&route_match_ipv6_next_hop_cmd); |
| 3848 | route_map_install_match (&route_match_ipv6_address_prefix_list_cmd); |
| 3849 | route_map_install_set (&route_set_ipv6_nexthop_global_cmd); |
| 3850 | route_map_install_set (&route_set_ipv6_nexthop_local_cmd); |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3851 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3852 | install_element (RMAP_NODE, &match_ipv6_address_cmd); |
| 3853 | install_element (RMAP_NODE, &no_match_ipv6_address_cmd); |
| 3854 | install_element (RMAP_NODE, &match_ipv6_next_hop_cmd); |
| 3855 | install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd); |
| 3856 | install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd); |
| 3857 | install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); |
| 3858 | install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd); |
| 3859 | install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd); |
| 3860 | install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd); |
| 3861 | install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); |
| 3862 | install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); |
| 3863 | install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd); |
| 3864 | #endif /* HAVE_IPV6 */ |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3865 | |
Paul Jakma | c8f3fe3 | 2010-12-05 20:28:02 +0000 | [diff] [blame] | 3866 | /* AS-Pathlimit: functionality removed, commands kept for |
| 3867 | * compatibility. |
| 3868 | */ |
Paul Jakma | 4136717 | 2007-08-06 15:24:51 +0000 | [diff] [blame] | 3869 | install_element (RMAP_NODE, &set_pathlimit_ttl_cmd); |
| 3870 | install_element (RMAP_NODE, &no_set_pathlimit_ttl_cmd); |
| 3871 | install_element (RMAP_NODE, &no_set_pathlimit_ttl_val_cmd); |
| 3872 | install_element (RMAP_NODE, &match_pathlimit_as_cmd); |
| 3873 | install_element (RMAP_NODE, &no_match_pathlimit_as_cmd); |
| 3874 | install_element (RMAP_NODE, &no_match_pathlimit_as_val_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3875 | } |