blob: 78cbfe2b6f4c9636cb5876593a481db3c8a23263 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Community attribute related functions.
2 Copyright (C) 1998 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
paul00d252c2005-05-23 14:19:54 +000021#ifndef _QUAGGA_BGP_COMMUNITY_H
22#define _QUAGGA_BGP_COMMUNITY_H
23
paul718e3742002-12-13 20:15:29 +000024/* Communities attribute. */
25struct community
26{
27 /* Reference count of communities value. */
28 unsigned long refcnt;
29
30 /* Communities value size. */
31 int size;
32
33 /* Communities value. */
34 u_int32_t *val;
35
36 /* String of community attribute. This sring is used by vty output
37 and expanded community-list for regular expression match. */
38 char *str;
39};
40
41/* Well-known communities value. */
42#define COMMUNITY_INTERNET 0x0
43#define COMMUNITY_NO_EXPORT 0xFFFFFF01
44#define COMMUNITY_NO_ADVERTISE 0xFFFFFF02
45#define COMMUNITY_NO_EXPORT_SUBCONFED 0xFFFFFF03
46#define COMMUNITY_LOCAL_AS 0xFFFFFF03
47
48/* Macros of community attribute. */
49#define com_length(X) ((X)->size * 4)
50#define com_lastval(X) ((X)->val + (X)->size - 1)
51#define com_nthval(X,n) ((X)->val + (n))
52
53/* Prototypes of communities attribute functions. */
paul94f2b392005-06-28 12:44:16 +000054extern void community_init (void);
Chris Caputo228da422009-07-18 05:44:03 +000055extern void community_finish (void);
paul94f2b392005-06-28 12:44:16 +000056extern void community_free (struct community *);
57extern struct community *community_uniq_sort (struct community *);
58extern struct community *community_parse (u_int32_t *, u_short);
59extern struct community *community_intern (struct community *);
60extern void community_unintern (struct community *);
61extern char *community_str (struct community *);
62extern unsigned int community_hash_make (struct community *);
63extern struct community *community_str2com (const char *);
64extern int community_match (const struct community *, const struct community *);
65extern int community_cmp (const struct community *, const struct community *);
66extern struct community *community_merge (struct community *, struct community *);
67extern struct community *community_delete (struct community *, struct community *);
68extern struct community *community_dup (struct community *);
69extern int community_include (struct community *, u_int32_t);
70extern void community_del_val (struct community *, u_int32_t *);
71extern unsigned long community_count (void);
72extern struct hash *community_hash (void);
Michael Lambert2c9fd7e2010-07-24 12:44:07 -040073extern struct community *community_lookup (struct community *);
paul00d252c2005-05-23 14:19:54 +000074
75#endif /* _QUAGGA_BGP_COMMUNITY_H */