]>
Commit | Line | Data |
---|---|---|
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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef _QUAGGA_BGP_CLIST_H | |
22 | #define _QUAGGA_BGP_CLIST_H | |
23 | ||
24 | /* Master Community-list. */ | |
25 | #define COMMUNITY_LIST_MASTER 0 | |
26 | #define EXTCOMMUNITY_LIST_MASTER 1 | |
27 | #define LARGE_COMMUNITY_LIST_MASTER 2 | |
28 | ||
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. */ | |
40 | #define EXTCOMMUNITY_LIST_STANDARD 2 /* Standard extcommunity-list. */ | |
41 | #define EXTCOMMUNITY_LIST_EXPANDED 3 /* Expanded extcommunity-list. */ | |
42 | #define LARGE_COMMUNITY_LIST_STANDARD 4 /* Standard Large community-list. */ | |
43 | #define LARGE_COMMUNITY_LIST_EXPANDED 5 /* Expanded Large community-list. */ | |
44 | ||
45 | /* Community-list. */ | |
46 | struct community_list { | |
47 | /* Name of the community-list. */ | |
48 | char *name; | |
49 | ||
50 | /* String or number. */ | |
51 | int sort; | |
52 | ||
53 | /* Link to upper list. */ | |
54 | struct community_list_list *parent; | |
55 | ||
56 | /* Linked list for other community-list. */ | |
57 | struct community_list *next; | |
58 | struct community_list *prev; | |
59 | ||
60 | /* Community-list entry in this community-list. */ | |
61 | struct community_entry *head; | |
62 | struct community_entry *tail; | |
63 | }; | |
64 | ||
65 | /* Each entry in community-list. */ | |
66 | struct community_entry { | |
67 | struct community_entry *next; | |
68 | struct community_entry *prev; | |
69 | ||
70 | /* Permit or deny. */ | |
71 | uint8_t direct; | |
72 | ||
73 | /* Standard or expanded. */ | |
74 | uint8_t style; | |
75 | ||
76 | /* Any match. */ | |
77 | uint8_t any; | |
78 | ||
79 | /* Community structure. */ | |
80 | union { | |
81 | struct community *com; | |
82 | struct ecommunity *ecom; | |
83 | struct lcommunity *lcom; | |
84 | } u; | |
85 | ||
86 | /* Configuration string. */ | |
87 | char *config; | |
88 | ||
89 | /* Expanded community-list regular expression. */ | |
90 | regex_t *reg; | |
91 | }; | |
92 | ||
93 | /* Linked list of community-list. */ | |
94 | struct community_list_list { | |
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 | struct community_list_list num; | |
102 | struct community_list_list str; | |
103 | }; | |
104 | ||
105 | /* Community-list handler. community_list_init() returns this | |
106 | structure as handler. */ | |
107 | struct community_list_handler { | |
108 | /* Community-list. */ | |
109 | struct community_list_master community_list; | |
110 | ||
111 | /* Exteded community-list. */ | |
112 | struct community_list_master extcommunity_list; | |
113 | ||
114 | /* Large community-list. */ | |
115 | struct community_list_master lcommunity_list; | |
116 | }; | |
117 | ||
118 | /* Error code of community-list. */ | |
119 | #define COMMUNITY_LIST_ERR_CANT_FIND_LIST -1 | |
120 | #define COMMUNITY_LIST_ERR_MALFORMED_VAL -2 | |
121 | #define COMMUNITY_LIST_ERR_STANDARD_CONFLICT -3 | |
122 | #define COMMUNITY_LIST_ERR_EXPANDED_CONFLICT -4 | |
123 | ||
124 | /* Handler. */ | |
125 | extern struct community_list_handler *bgp_clist; | |
126 | ||
127 | /* Prototypes. */ | |
128 | extern struct community_list_handler *community_list_init(void); | |
129 | extern void community_list_terminate(struct community_list_handler *); | |
130 | ||
131 | extern int community_list_set(struct community_list_handler *ch, | |
132 | const char *name, const char *str, int direct, | |
133 | int style); | |
134 | extern int community_list_unset(struct community_list_handler *ch, | |
135 | const char *name, const char *str, int direct, | |
136 | int style); | |
137 | extern int extcommunity_list_set(struct community_list_handler *ch, | |
138 | const char *name, const char *str, int direct, | |
139 | int style); | |
140 | extern int extcommunity_list_unset(struct community_list_handler *ch, | |
141 | const char *name, const char *str, | |
142 | int direct, int style); | |
143 | extern int lcommunity_list_set(struct community_list_handler *ch, | |
144 | const char *name, const char *str, int direct, | |
145 | int style); | |
146 | extern int lcommunity_list_unset(struct community_list_handler *ch, | |
147 | const char *name, const char *str, int direct, | |
148 | int style); | |
149 | ||
150 | extern struct community_list_master * | |
151 | community_list_master_lookup(struct community_list_handler *, int); | |
152 | ||
153 | extern struct community_list * | |
154 | community_list_lookup(struct community_list_handler *, const char *, int); | |
155 | ||
156 | extern int community_list_match(struct community *, struct community_list *); | |
157 | extern int ecommunity_list_match(struct ecommunity *, struct community_list *); | |
158 | extern int lcommunity_list_match(struct lcommunity *, struct community_list *); | |
159 | extern int community_list_exact_match(struct community *, | |
160 | struct community_list *); | |
161 | extern struct community *community_list_match_delete(struct community *, | |
162 | struct community_list *); | |
163 | extern struct lcommunity * | |
164 | lcommunity_list_match_delete(struct lcommunity *lcom, | |
165 | struct community_list *list); | |
166 | #endif /* _QUAGGA_BGP_CLIST_H */ |