]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_ecommunity.h
bgpd: enhance reception of bgp ext. community default gateway
[mirror_frr.git] / bgpd / bgp_ecommunity.h
CommitLineData
718e3744 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
00d252cb 21#ifndef _QUAGGA_BGP_ECOMMUNITY_H
22#define _QUAGGA_BGP_ECOMMUNITY_H
23
718e3744 24/* High-order octet of the Extended Communities type field. */
25#define ECOMMUNITY_ENCODE_AS 0x00
26#define ECOMMUNITY_ENCODE_IP 0x01
0b2aa3a0 27#define ECOMMUNITY_ENCODE_AS4 0x02
0014c301 28#define ECOMMUNITY_ENCODE_OPAQUE 0x03
718e3744 29
0014c301 30/* Low-order octet of the Extended Communities type field. */
718e3744 31#define ECOMMUNITY_ROUTE_TARGET 0x02
32#define ECOMMUNITY_SITE_ORIGIN 0x03
33
1e27ef50
PG
34#define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY 0x00
35#define ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL 0x01
36#define ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT 0x02
37#define ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC 0x03
38#define ECOMMUNITY_EVPN_SUBTYPE_DEF_GW 0x0d
39
0014c301
LB
40/* Low-order octet of the Extended Communities type field for OPAQUE types */
41#define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c
42
718e3744 43/* Extended communities attribute string format. */
44#define ECOMMUNITY_FORMAT_ROUTE_MAP 0
45#define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1
46#define ECOMMUNITY_FORMAT_DISPLAY 2
47
48/* Extended Communities value is eight octet long. */
49#define ECOMMUNITY_SIZE 8
50
4372df71 51/* Extended Communities type flag. */
52#define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40
53
718e3744 54/* Extended Communities attribute. */
55struct ecommunity
56{
57 /* Reference counter. */
58 unsigned long refcnt;
59
60 /* Size of Extended Communities attribute. */
61 int size;
62
63 /* Extended Communities value. */
5228ad27 64 u_int8_t *val;
718e3744 65
66 /* Human readable format string. */
67 char *str;
68};
69
70/* Extended community value is eight octet. */
71struct ecommunity_val
72{
73 char val[ECOMMUNITY_SIZE];
74};
75
76#define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE)
77
94f2b392 78extern void ecommunity_init (void);
228da428 79extern void ecommunity_finish (void);
f6f434b2 80extern void ecommunity_free (struct ecommunity **);
94f2b392 81extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short);
82extern struct ecommunity *ecommunity_dup (struct ecommunity *);
83extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
0b597ef0 84extern struct ecommunity *ecommunity_uniq_sort (struct ecommunity *);
94f2b392 85extern struct ecommunity *ecommunity_intern (struct ecommunity *);
ffe11cfb 86extern int ecommunity_cmp (const void *, const void *);
f6f434b2 87extern void ecommunity_unintern (struct ecommunity **);
0b2aa3a0 88extern unsigned int ecommunity_hash_make (void *);
94f2b392 89extern struct ecommunity *ecommunity_str2com (const char *, int, int);
90extern char *ecommunity_ecom2str (struct ecommunity *, int);
91extern int ecommunity_match (const struct ecommunity *, const struct ecommunity *);
92extern char *ecommunity_str (struct ecommunity *);
1e27ef50 93extern struct ecommunity_val *ecommunity_lookup (const struct ecommunity *, uint8_t, uint8_t );
00d252cb 94
65efcfce
LB
95/* for vpn */
96extern struct ecommunity *ecommunity_new (void);
97extern int ecommunity_add_val (struct ecommunity *, struct ecommunity_val *);
1e27ef50
PG
98extern int ecommunity_strip (struct ecommunity *ecom, uint8_t type, uint8_t subtype);
99extern struct ecommunity *ecommunity_new (void);
00d252cb 100#endif /* _QUAGGA_BGP_ECOMMUNITY_H */