summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_routemap.c
diff options
context:
space:
mode:
authorpaul <paul>2003-01-17 13:20:40 +0000
committerpaul <paul>2003-01-17 13:20:40 +0000
commit47e64cb1fb3ba81f535654fc3bfc9d10c6726d62 (patch)
treea23914917215395ba4ef5f562146bb16f9380eca /bgpd/bgp_routemap.c
parent01f6e536df19cf94358db09612ba945dbf8833cc (diff)
downloadquagga-zebra.org.20030117.tar.bz2
quagga-zebra.org.20030117.tar.xz
Import of Zebra CVS 20020117-13:15zebra.org.20030117
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r--bgpd/bgp_routemap.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 498a6005..b5494d52 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -518,6 +518,52 @@ struct route_map_rule_cmd route_match_community_cmd =
route_match_community_free
};
+/* Match function for extcommunity match. */
+route_map_result_t
+route_match_ecommunity (void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ struct community_list *list;
+ struct bgp_info *bgp_info;
+
+ if (type == RMAP_BGP)
+ {
+ bgp_info = object;
+
+ list = community_list_lookup (bgp_clist, (char *) rule,
+ EXTCOMMUNITY_LIST_AUTO);
+ if (! list)
+ return RMAP_NOMATCH;
+
+ if (ecommunity_list_match (bgp_info->attr->ecommunity, list))
+ return RMAP_MATCH;
+ }
+ return RMAP_NOMATCH;
+}
+
+/* Compile function for extcommunity match. */
+void *
+route_match_ecommunity_compile (char *arg)
+{
+ return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+/* Compile function for extcommunity match. */
+void
+route_match_ecommunity_free (void *rule)
+{
+ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+/* Route map commands for community matching. */
+struct route_map_rule_cmd route_match_ecommunity_cmd =
+{
+ "extcommunity",
+ route_match_ecommunity,
+ route_match_ecommunity_compile,
+ route_match_ecommunity_free
+};
+
/* `match nlri` and `set nlri` are replaced by `address-family ipv4`
and `address-family vpnv4'. */
@@ -2222,6 +2268,38 @@ ALIAS (no_match_community,
"Community-list name\n"
"Do exact matching of communities\n")
+DEFUN (match_ecommunity,
+ match_ecommunity_cmd,
+ "match extcommunity (<1-99>|<100-199>|WORD)",
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
+{
+ return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0]);
+}
+
+DEFUN (no_match_ecommunity,
+ no_match_ecommunity_cmd,
+ "no match extcommunity",
+ NO_STR
+ MATCH_STR
+ "Match BGP/VPN extended community list\n")
+{
+ return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL);
+}
+
+ALIAS (no_match_ecommunity,
+ no_match_ecommunity_val_cmd,
+ "no match extcommunity (<1-99>|<100-199>|WORD)",
+ NO_STR
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
+
DEFUN (match_aspath,
match_aspath_cmd,
"match as-path WORD",
@@ -3093,6 +3171,7 @@ bgp_route_map_init ()
route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
route_map_install_match (&route_match_aspath_cmd);
route_map_install_match (&route_match_community_cmd);
+ route_map_install_match (&route_match_ecommunity_cmd);
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_origin_cmd);
@@ -3136,6 +3215,9 @@ bgp_route_map_init ()
install_element (RMAP_NODE, &no_match_community_cmd);
install_element (RMAP_NODE, &no_match_community_val_cmd);
install_element (RMAP_NODE, &no_match_community_exact_cmd);
+ install_element (RMAP_NODE, &match_ecommunity_cmd);
+ install_element (RMAP_NODE, &no_match_ecommunity_cmd);
+ install_element (RMAP_NODE, &no_match_ecommunity_val_cmd);
install_element (RMAP_NODE, &match_origin_cmd);
install_element (RMAP_NODE, &no_match_origin_cmd);
install_element (RMAP_NODE, &no_match_origin_val_cmd);