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