paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP Community list. |
| 2 | Copyright (C) 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 | |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 21 | #ifndef _QUAGGA_BGP_CLIST_H |
| 22 | #define _QUAGGA_BGP_CLIST_H |
| 23 | |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 24 | /* Master Community-list. */ |
| 25 | #define COMMUNITY_LIST_MASTER 0 |
| 26 | #define EXTCOMMUNITY_LIST_MASTER 1 |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 27 | #define LARGE_COMMUNITY_LIST_MASTER 2 |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 28 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 29 | /* Community-list deny and permit. */ |
| 30 | #define COMMUNITY_DENY 0 |
| 31 | #define COMMUNITY_PERMIT 1 |
| 32 | |
| 33 | /* Number and string based community-list name. */ |
| 34 | #define COMMUNITY_LIST_STRING 0 |
| 35 | #define COMMUNITY_LIST_NUMBER 1 |
| 36 | |
| 37 | /* Community-list entry types. */ |
| 38 | #define COMMUNITY_LIST_STANDARD 0 /* Standard community-list. */ |
| 39 | #define COMMUNITY_LIST_EXPANDED 1 /* Expanded community-list. */ |
hasso | fee6e4e | 2005-02-02 16:29:31 +0000 | [diff] [blame] | 40 | #define EXTCOMMUNITY_LIST_STANDARD 2 /* Standard extcommunity-list. */ |
| 41 | #define EXTCOMMUNITY_LIST_EXPANDED 3 /* Expanded extcommunity-list. */ |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 42 | #define LARGE_COMMUNITY_LIST_STANDARD 4 /* Standard Large community-list. */ |
| 43 | #define LARGE_COMMUNITY_LIST_EXPANDED 5 /* Expanded Large community-list. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | |
| 45 | /* Community-list. */ |
| 46 | struct community_list |
| 47 | { |
| 48 | /* Name of the community-list. */ |
| 49 | char *name; |
| 50 | |
| 51 | /* String or number. */ |
| 52 | int sort; |
| 53 | |
| 54 | /* Link to upper list. */ |
| 55 | struct community_list_list *parent; |
| 56 | |
| 57 | /* Linked list for other community-list. */ |
| 58 | struct community_list *next; |
| 59 | struct community_list *prev; |
| 60 | |
| 61 | /* Community-list entry in this community-list. */ |
| 62 | struct community_entry *head; |
| 63 | struct community_entry *tail; |
| 64 | }; |
| 65 | |
| 66 | /* Each entry in community-list. */ |
| 67 | struct community_entry |
| 68 | { |
| 69 | struct community_entry *next; |
| 70 | struct community_entry *prev; |
| 71 | |
| 72 | /* Permit or deny. */ |
| 73 | u_char direct; |
| 74 | |
| 75 | /* Standard or expanded. */ |
| 76 | u_char style; |
| 77 | |
| 78 | /* Any match. */ |
| 79 | u_char any; |
| 80 | |
| 81 | /* Community structure. */ |
| 82 | union |
| 83 | { |
| 84 | struct community *com; |
| 85 | struct ecommunity *ecom; |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 86 | struct lcommunity *lcom; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 87 | } u; |
| 88 | |
| 89 | /* Configuration string. */ |
| 90 | char *config; |
| 91 | |
| 92 | /* Expanded community-list regular expression. */ |
| 93 | regex_t *reg; |
| 94 | }; |
| 95 | |
| 96 | /* Linked list of community-list. */ |
| 97 | struct community_list_list |
| 98 | { |
| 99 | struct community_list *head; |
| 100 | struct community_list *tail; |
| 101 | }; |
| 102 | |
| 103 | /* Master structure of community-list and extcommunity-list. */ |
| 104 | struct community_list_master |
| 105 | { |
| 106 | struct community_list_list num; |
| 107 | struct community_list_list str; |
| 108 | }; |
| 109 | |
| 110 | /* Community-list handler. community_list_init() returns this |
| 111 | structure as handler. */ |
| 112 | struct community_list_handler |
| 113 | { |
| 114 | /* Community-list. */ |
| 115 | struct community_list_master community_list; |
| 116 | |
| 117 | /* Exteded community-list. */ |
| 118 | struct community_list_master extcommunity_list; |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 119 | |
| 120 | /* Large community-list. */ |
| 121 | struct community_list_master lcommunity_list; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | /* Error code of community-list. */ |
| 125 | #define COMMUNITY_LIST_ERR_CANT_FIND_LIST -1 |
| 126 | #define COMMUNITY_LIST_ERR_MALFORMED_VAL -2 |
| 127 | #define COMMUNITY_LIST_ERR_STANDARD_CONFLICT -3 |
| 128 | #define COMMUNITY_LIST_ERR_EXPANDED_CONFLICT -4 |
| 129 | |
| 130 | /* Handler. */ |
| 131 | extern struct community_list_handler *bgp_clist; |
| 132 | |
| 133 | /* Prototypes. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 134 | extern struct community_list_handler *community_list_init (void); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 135 | extern void community_list_terminate (struct community_list_handler *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 136 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 137 | extern int community_list_set (struct community_list_handler *ch, |
| 138 | const char *name, const char *str, int direct, |
| 139 | int style); |
| 140 | extern int community_list_unset (struct community_list_handler *ch, |
| 141 | const char *name, const char *str, |
| 142 | int direct, int style); |
| 143 | extern int extcommunity_list_set (struct community_list_handler *ch, |
| 144 | const char *name, const char *str, |
| 145 | int direct, int style); |
| 146 | extern int extcommunity_list_unset (struct community_list_handler *ch, |
| 147 | const char *name, const char *str, |
| 148 | int direct, int style); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 149 | extern int lcommunity_list_set (struct community_list_handler *ch, |
| 150 | const char *name, const char *str, |
| 151 | int direct, int style); |
| 152 | extern int lcommunity_list_unset (struct community_list_handler *ch, |
| 153 | const char *name, const char *str, |
| 154 | int direct, int style); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 156 | extern struct community_list_master * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | community_list_master_lookup (struct community_list_handler *, int); |
| 158 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 159 | extern struct community_list * |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 160 | community_list_lookup (struct community_list_handler *, const char *, int); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 162 | extern int community_list_match (struct community *, struct community_list *); |
| 163 | extern int ecommunity_list_match (struct ecommunity *, struct community_list *); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 164 | extern int lcommunity_list_match (struct lcommunity *, struct community_list *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 165 | extern int community_list_exact_match (struct community *, |
| 166 | struct community_list *); |
| 167 | extern struct community * |
| 168 | community_list_match_delete (struct community *, struct community_list *); |
Job Snijders | 3334bab | 2017-01-20 14:47:12 +0000 | [diff] [blame] | 169 | extern struct lcommunity * |
| 170 | lcommunity_list_match_delete (struct lcommunity *lcom, |
| 171 | struct community_list *list); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 172 | #endif /* _QUAGGA_BGP_CLIST_H */ |