]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_community.h
eigrpd: eigrp usage of uint32_t to struct in_addr for router_id data
[mirror_frr.git] / bgpd / bgp_community.h
1 /* Community attribute related functions.
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 */
20
21 #ifndef _QUAGGA_BGP_COMMUNITY_H
22 #define _QUAGGA_BGP_COMMUNITY_H
23
24 #include "lib/json.h"
25
26 /* Communities attribute. */
27 struct community {
28 /* Reference count of communities value. */
29 unsigned long refcnt;
30
31 /* Communities value size. */
32 int size;
33
34 /* Communities value. */
35 uint32_t *val;
36
37 /* Communities as a json object */
38 json_object *json;
39
40 /* String of community attribute. This sring is used by vty output
41 and expanded community-list for regular expression match. */
42 char *str;
43 };
44
45 /* Well-known communities value. */
46 #define COMMUNITY_INTERNET 0x0
47 #define COMMUNITY_GSHUT 0xFFFF0000
48 #define COMMUNITY_ACCEPT_OWN 0xFFFF0001
49 #define COMMUNITY_ROUTE_FILTER_TRANSLATED_v4 0xFFFF0002
50 #define COMMUNITY_ROUTE_FILTER_v4 0xFFFF0003
51 #define COMMUNITY_ROUTE_FILTER_TRANSLATED_v6 0xFFFF0004
52 #define COMMUNITY_ROUTE_FILTER_v6 0xFFFF0005
53 #define COMMUNITY_LLGR_STALE 0xFFFF0006
54 #define COMMUNITY_NO_LLGR 0xFFFF0007
55 #define COMMUNITY_ACCEPT_OWN_NEXTHOP 0xFFFF0008
56 #define COMMUNITY_BLACKHOLE 0xFFFF029A
57 #define COMMUNITY_NO_EXPORT 0xFFFFFF01
58 #define COMMUNITY_NO_ADVERTISE 0xFFFFFF02
59 #define COMMUNITY_NO_EXPORT_SUBCONFED 0xFFFFFF03
60 #define COMMUNITY_LOCAL_AS 0xFFFFFF03
61 #define COMMUNITY_NO_PEER 0xFFFFFF04
62
63 /* Macros of community attribute. */
64 #define com_length(X) ((X)->size * 4)
65 #define com_lastval(X) ((X)->val + (X)->size - 1)
66 #define com_nthval(X,n) ((X)->val + (n))
67
68 /* Prototypes of communities attribute functions. */
69 extern void community_init(void);
70 extern void community_finish(void);
71 extern void community_free(struct community **comm);
72 extern struct community *community_uniq_sort(struct community *);
73 extern struct community *community_parse(uint32_t *, unsigned short);
74 extern struct community *community_intern(struct community *);
75 extern void community_unintern(struct community **);
76 extern char *community_str(struct community *, bool make_json);
77 extern unsigned int community_hash_make(struct community *);
78 extern struct community *community_str2com(const char *);
79 extern int community_match(const struct community *, const struct community *);
80 extern bool community_cmp(const struct community *c1,
81 const struct community *c2);
82 extern struct community *community_merge(struct community *,
83 struct community *);
84 extern struct community *community_delete(struct community *,
85 struct community *);
86 extern struct community *community_dup(struct community *);
87 extern int community_include(struct community *, uint32_t);
88 extern void community_del_val(struct community *, uint32_t *);
89 extern unsigned long community_count(void);
90 extern struct hash *community_hash(void);
91 extern uint32_t community_val_get(struct community *com, int i);
92
93 #endif /* _QUAGGA_BGP_COMMUNITY_H */