blob: 69014237d7fdeabb3d4b442302994cbd07eebb22 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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
paul00d252c2005-05-23 14:19:54 +000021#ifndef _QUAGGA_BGP_ECOMMUNITY_H
22#define _QUAGGA_BGP_ECOMMUNITY_H
23
paul718e3742002-12-13 20:15:29 +000024/* High-order octet of the Extended Communities type field. */
25#define ECOMMUNITY_ENCODE_AS 0x00
26#define ECOMMUNITY_ENCODE_IP 0x01
Paul Jakma0b2aa3a2007-10-14 22:32:21 +000027#define ECOMMUNITY_ENCODE_AS4 0x02
paul718e3742002-12-13 20:15:29 +000028
29/* Low-order octet of the Extended Communityes type field. */
30#define ECOMMUNITY_ROUTE_TARGET 0x02
31#define ECOMMUNITY_SITE_ORIGIN 0x03
32
33/* Extended communities attribute string format. */
34#define ECOMMUNITY_FORMAT_ROUTE_MAP 0
35#define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1
36#define ECOMMUNITY_FORMAT_DISPLAY 2
37
38/* Extended Communities value is eight octet long. */
39#define ECOMMUNITY_SIZE 8
40
hasso4372df72004-05-20 10:20:02 +000041/* Extended Communities type flag. */
42#define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40
43
paul718e3742002-12-13 20:15:29 +000044/* Extended Communities attribute. */
45struct ecommunity
46{
47 /* Reference counter. */
48 unsigned long refcnt;
49
50 /* Size of Extended Communities attribute. */
51 int size;
52
53 /* Extended Communities value. */
paul5228ad22004-06-04 17:58:18 +000054 u_int8_t *val;
paul718e3742002-12-13 20:15:29 +000055
56 /* Human readable format string. */
57 char *str;
58};
59
60/* Extended community value is eight octet. */
61struct ecommunity_val
62{
63 char val[ECOMMUNITY_SIZE];
64};
65
66#define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE)
67
paul94f2b392005-06-28 12:44:16 +000068extern void ecommunity_init (void);
69extern void ecommunity_free (struct ecommunity *);
70extern struct ecommunity *ecommunity_new (void);
71extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short);
72extern struct ecommunity *ecommunity_dup (struct ecommunity *);
73extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
74extern struct ecommunity *ecommunity_intern (struct ecommunity *);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +000075extern int ecommunity_cmp (void *, void *);
paul94f2b392005-06-28 12:44:16 +000076extern void ecommunity_unintern (struct ecommunity *);
Paul Jakma0b2aa3a2007-10-14 22:32:21 +000077extern unsigned int ecommunity_hash_make (void *);
paul94f2b392005-06-28 12:44:16 +000078extern struct ecommunity *ecommunity_str2com (const char *, int, int);
79extern char *ecommunity_ecom2str (struct ecommunity *, int);
80extern int ecommunity_match (const struct ecommunity *, const struct ecommunity *);
81extern char *ecommunity_str (struct ecommunity *);
paul00d252c2005-05-23 14:19:54 +000082
83#endif /* _QUAGGA_BGP_ECOMMUNITY_H */