added files
[bcm963xx.git] / userapps / opensource / zebra / bgpd / bgp_ecommunity.h
1 /* BGP Extended Communities Attribute.
2    Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
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 /* High-order octet of the Extended Communities type field.  */
22 #define ECOMMUNITY_ENCODE_AS       0x00
23 #define ECOMMUNITY_ENCODE_IP       0x01
24
25 /* Low-order octet of the Extended Communityes type field.  */
26 #define ECOMMUNITY_ROUTE_TARGET    0x02
27 #define ECOMMUNITY_SITE_ORIGIN     0x03
28
29 /* Extended communities attribute string format.  */
30 #define ECOMMUNITY_FORMAT_ROUTE_MAP            0
31 #define ECOMMUNITY_FORMAT_COMMUNITY_LIST       1
32 #define ECOMMUNITY_FORMAT_DISPLAY              2
33
34 /* BGP routing distinguisher size.  */
35 #ifndef BGP_RD_SIZE
36 #define BGP_RD_SIZE                8
37 #endif /* BGP_RD_SIZE */
38
39 /* Extended Communities attribute.  */
40 struct ecommunity
41 {
42   unsigned long refcnt;
43   int size;
44   u_char *val;
45   char *str;
46 };
47
48 #define ecom_length(X)    ((X)->size * 8)
49
50 void ecommunity_init (void);
51 void ecommunity_free (struct ecommunity *);
52 struct ecommunity *ecommunity_new (void);
53 struct ecommunity *ecommunity_parse (char *, u_short);
54 struct ecommunity *ecommunity_dup (struct ecommunity *);
55 struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
56 struct ecommunity *ecommunity_intern (struct ecommunity *);
57 int ecommunity_cmp (struct ecommunity *, struct ecommunity *);
58 void ecommunity_unintern (struct ecommunity *);
59 unsigned int ecommunity_hash_make (struct ecommunity *);
60
61 void ecommunity_rd2com (struct bgp_rd *, u_char);
62 struct ecommunity *ecommunity_str2com (char *, int, int);
63 void ecommunity_vty_out (struct vty *, struct ecommunity *);
64 char *ecommunity_ecom2str (struct ecommunity *, int);