]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* Community attribute related functions. |
896014f4 DL |
2 | * Copyright (C) 1998 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 | */ | |
718e3744 | 20 | |
00d252cb | 21 | #ifndef _QUAGGA_BGP_COMMUNITY_H |
22 | #define _QUAGGA_BGP_COMMUNITY_H | |
23 | ||
f1aa5d8a | 24 | #include "lib/json.h" |
c0d7a6cc | 25 | #include "bgpd/bgp_route.h" |
f1aa5d8a | 26 | |
718e3744 | 27 | /* Communities attribute. */ |
d62a17ae | 28 | struct community { |
29 | /* Reference count of communities value. */ | |
30 | unsigned long refcnt; | |
718e3744 | 31 | |
d62a17ae | 32 | /* Communities value size. */ |
33 | int size; | |
718e3744 | 34 | |
d62a17ae | 35 | /* Communities value. */ |
d7c0a89a | 36 | uint32_t *val; |
718e3744 | 37 | |
d62a17ae | 38 | /* Communities as a json object */ |
39 | json_object *json; | |
f1aa5d8a | 40 | |
d62a17ae | 41 | /* String of community attribute. This sring is used by vty output |
42 | and expanded community-list for regular expression match. */ | |
43 | char *str; | |
718e3744 | 44 | }; |
45 | ||
46 | /* Well-known communities value. */ | |
aa861c10 C |
47 | #define COMMUNITY_INTERNET 0x0 |
48 | #define COMMUNITY_GSHUT 0xFFFF0000 | |
49 | #define COMMUNITY_ACCEPT_OWN 0xFFFF0001 | |
50 | #define COMMUNITY_ROUTE_FILTER_TRANSLATED_v4 0xFFFF0002 | |
51 | #define COMMUNITY_ROUTE_FILTER_v4 0xFFFF0003 | |
52 | #define COMMUNITY_ROUTE_FILTER_TRANSLATED_v6 0xFFFF0004 | |
53 | #define COMMUNITY_ROUTE_FILTER_v6 0xFFFF0005 | |
54 | #define COMMUNITY_LLGR_STALE 0xFFFF0006 | |
55 | #define COMMUNITY_NO_LLGR 0xFFFF0007 | |
56 | #define COMMUNITY_ACCEPT_OWN_NEXTHOP 0xFFFF0008 | |
57 | #define COMMUNITY_BLACKHOLE 0xFFFF029A | |
58 | #define COMMUNITY_NO_EXPORT 0xFFFFFF01 | |
59 | #define COMMUNITY_NO_ADVERTISE 0xFFFFFF02 | |
60 | #define COMMUNITY_NO_EXPORT_SUBCONFED 0xFFFFFF03 | |
61 | #define COMMUNITY_LOCAL_AS 0xFFFFFF03 | |
62 | #define COMMUNITY_NO_PEER 0xFFFFFF04 | |
718e3744 | 63 | |
11400e73 DA |
64 | #define COMMUNITY_SIZE 4 |
65 | ||
718e3744 | 66 | /* Macros of community attribute. */ |
11400e73 | 67 | #define com_length(X) ((X)->size * COMMUNITY_SIZE) |
718e3744 | 68 | #define com_lastval(X) ((X)->val + (X)->size - 1) |
69 | #define com_nthval(X,n) ((X)->val + (n)) | |
70 | ||
71 | /* Prototypes of communities attribute functions. */ | |
d62a17ae | 72 | extern void community_init(void); |
73 | extern void community_finish(void); | |
3c1f53de | 74 | extern void community_free(struct community **comm); |
d62a17ae | 75 | extern struct community *community_uniq_sort(struct community *); |
d7c0a89a | 76 | extern struct community *community_parse(uint32_t *, unsigned short); |
d62a17ae | 77 | extern struct community *community_intern(struct community *); |
78 | extern void community_unintern(struct community **); | |
a69ea8ae | 79 | extern char *community_str(struct community *, bool make_json); |
d8b87afe | 80 | extern unsigned int community_hash_make(const struct community *); |
d62a17ae | 81 | extern struct community *community_str2com(const char *); |
3dc339cd | 82 | extern bool community_match(const struct community *, const struct community *); |
74df8d6d DS |
83 | extern bool community_cmp(const struct community *c1, |
84 | const struct community *c2); | |
d62a17ae | 85 | extern struct community *community_merge(struct community *, |
86 | struct community *); | |
87 | extern struct community *community_delete(struct community *, | |
88 | struct community *); | |
89 | extern struct community *community_dup(struct community *); | |
3dc339cd | 90 | extern bool community_include(struct community *, uint32_t); |
2721dd61 | 91 | extern void community_add_val(struct community *com, uint32_t val); |
d7c0a89a | 92 | extern void community_del_val(struct community *, uint32_t *); |
d62a17ae | 93 | extern unsigned long community_count(void); |
94 | extern struct hash *community_hash(void); | |
d7c0a89a | 95 | extern uint32_t community_val_get(struct community *com, int i); |
c0d7a6cc NT |
96 | extern void bgp_compute_aggregate_community(struct bgp_aggregate *aggregate, |
97 | struct community *community); | |
21fec674 | 98 | |
99 | extern void bgp_compute_aggregate_community_val( | |
100 | struct bgp_aggregate *aggregate); | |
101 | extern void bgp_compute_aggregate_community_hash( | |
102 | struct bgp_aggregate *aggregate, | |
103 | struct community *community); | |
c0d7a6cc NT |
104 | extern void bgp_remove_community_from_aggregate(struct bgp_aggregate *aggregate, |
105 | struct community *community); | |
21fec674 | 106 | extern void bgp_remove_comm_from_aggregate_hash(struct bgp_aggregate *aggregate, |
107 | struct community *community); | |
c0d7a6cc | 108 | extern void bgp_aggr_community_remove(void *arg); |
00d252cb | 109 | |
110 | #endif /* _QUAGGA_BGP_COMMUNITY_H */ |