]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_clist.h
2004-10-13 Paul Jakma <paul@dishone.st>
[mirror_frr.git] / bgpd / bgp_clist.h
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
21 /* Community-list deny and permit. */
22 #define COMMUNITY_DENY 0
23 #define COMMUNITY_PERMIT 1
24
25 /* Number and string based community-list name. */
26 #define COMMUNITY_LIST_STRING 0
27 #define COMMUNITY_LIST_NUMBER 1
28
29 /* Community-list entry types. */
30 #define COMMUNITY_LIST_STANDARD 0 /* Standard community-list. */
31 #define COMMUNITY_LIST_EXPANDED 1 /* Expanded community-list. */
32 #define COMMUNITY_LIST_AUTO 2 /* Automatically detected. */
33 #define EXTCOMMUNITY_LIST_STANDARD 3 /* Standard extcommunity-list. */
34 #define EXTCOMMUNITY_LIST_EXPANDED 4 /* Expanded extcommunity-list. */
35 #define EXTCOMMUNITY_LIST_AUTO 5 /* Automatically detected. */
36
37 /* Community-list. */
38 struct community_list
39 {
40 /* Name of the community-list. */
41 char *name;
42
43 /* String or number. */
44 int sort;
45
46 /* Link to upper list. */
47 struct community_list_list *parent;
48
49 /* Linked list for other community-list. */
50 struct community_list *next;
51 struct community_list *prev;
52
53 /* Community-list entry in this community-list. */
54 struct community_entry *head;
55 struct community_entry *tail;
56 };
57
58 /* Each entry in community-list. */
59 struct community_entry
60 {
61 struct community_entry *next;
62 struct community_entry *prev;
63
64 /* Permit or deny. */
65 u_char direct;
66
67 /* Standard or expanded. */
68 u_char style;
69
70 /* Any match. */
71 u_char any;
72
73 /* Community structure. */
74 union
75 {
76 struct community *com;
77 struct ecommunity *ecom;
78 } u;
79
80 /* Configuration string. */
81 char *config;
82
83 /* Expanded community-list regular expression. */
84 regex_t *reg;
85 };
86
87 /* Linked list of community-list. */
88 struct community_list_list
89 {
90 struct community_list *head;
91 struct community_list *tail;
92 };
93
94 /* Master structure of community-list and extcommunity-list. */
95 struct community_list_master
96 {
97 struct community_list_list num;
98 struct community_list_list str;
99 };
100
101 /* Community-list handler. community_list_init() returns this
102 structure as handler. */
103 struct community_list_handler
104 {
105 /* Community-list. */
106 struct community_list_master community_list;
107
108 /* Exteded community-list. */
109 struct community_list_master extcommunity_list;
110 };
111
112 /* Error code of community-list. */
113 #define COMMUNITY_LIST_ERR_CANT_FIND_LIST -1
114 #define COMMUNITY_LIST_ERR_MALFORMED_VAL -2
115 #define COMMUNITY_LIST_ERR_STANDARD_CONFLICT -3
116 #define COMMUNITY_LIST_ERR_EXPANDED_CONFLICT -4
117
118 /* Handler. */
119 extern struct community_list_handler *bgp_clist;
120
121 /* Prototypes. */
122 struct community_list_handler *community_list_init ();
123
124 int community_list_set (struct community_list_handler *ch, const char *name,
125 const char *str, int direct, int style);
126 int community_list_unset (struct community_list_handler *ch, const char *name,
127 const char *str, int direct, int style);
128 int extcommunity_list_set (struct community_list_handler *ch, const char *name,
129 const char *str, int direct, int style);
130 int extcommunity_list_unset (struct community_list_handler *ch,
131 const char *name, const char *str,
132 int direct, int style);
133
134 struct community_list_master *
135 community_list_master_lookup (struct community_list_handler *, int);
136
137 struct community_list *
138 community_list_lookup (struct community_list_handler *, const char *, int);
139
140 int community_list_match (struct community *, struct community_list *);
141 int ecommunity_list_match (struct ecommunity *, struct community_list *);
142 int community_list_exact_match (struct community *, struct community_list *);
143 struct community *
144 community_list_match_delete (struct community *,
145 struct community_list *);