1/* BGP Extended Communities Attribute.
2   Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
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
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.  */
40struct 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
50void ecommunity_init (void);
51void ecommunity_free (struct ecommunity *);
52struct ecommunity *ecommunity_new (void);
53struct ecommunity *ecommunity_parse (char *, u_short);
54struct ecommunity *ecommunity_dup (struct ecommunity *);
55struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
56struct ecommunity *ecommunity_intern (struct ecommunity *);
57int ecommunity_cmp (struct ecommunity *, struct ecommunity *);
58void ecommunity_unintern (struct ecommunity *);
59unsigned int ecommunity_hash_make (struct ecommunity *);
60
61void ecommunity_rd2com (struct bgp_rd *, u_char);
62struct ecommunity *ecommunity_str2com (char *, int, int);
63void ecommunity_vty_out (struct vty *, struct ecommunity *);
64char *ecommunity_ecom2str (struct ecommunity *, int);
65