]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP Extended Communities Attribute. |
896014f4 DL |
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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 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 |
e82202b7 | 29 | #define ECOMMUNITY_ENCODE_EVPN 0x06 |
718e3744 | 30 | |
0014c301 | 31 | /* Low-order octet of the Extended Communities type field. */ |
718e3744 | 32 | #define ECOMMUNITY_ROUTE_TARGET 0x02 |
33 | #define ECOMMUNITY_SITE_ORIGIN 0x03 | |
34 | ||
1e27ef50 PG |
35 | #define ECOMMUNITY_EVPN_SUBTYPE_MACMOBILITY 0x00 |
36 | #define ECOMMUNITY_EVPN_SUBTYPE_ESI_LABEL 0x01 | |
37 | #define ECOMMUNITY_EVPN_SUBTYPE_ES_IMPORT_RT 0x02 | |
38 | #define ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC 0x03 | |
39 | #define ECOMMUNITY_EVPN_SUBTYPE_DEF_GW 0x0d | |
40 | ||
0014c301 LB |
41 | /* Low-order octet of the Extended Communities type field for OPAQUE types */ |
42 | #define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c | |
43 | ||
718e3744 | 44 | /* Extended communities attribute string format. */ |
45 | #define ECOMMUNITY_FORMAT_ROUTE_MAP 0 | |
46 | #define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1 | |
47 | #define ECOMMUNITY_FORMAT_DISPLAY 2 | |
48 | ||
49 | /* Extended Communities value is eight octet long. */ | |
50 | #define ECOMMUNITY_SIZE 8 | |
51 | ||
4372df71 | 52 | /* Extended Communities type flag. */ |
53 | #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40 | |
54 | ||
718e3744 | 55 | /* Extended Communities attribute. */ |
56 | struct ecommunity | |
57 | { | |
58 | /* Reference counter. */ | |
59 | unsigned long refcnt; | |
60 | ||
61 | /* Size of Extended Communities attribute. */ | |
62 | int size; | |
63 | ||
64 | /* Extended Communities value. */ | |
5228ad27 | 65 | u_int8_t *val; |
718e3744 | 66 | |
67 | /* Human readable format string. */ | |
68 | char *str; | |
69 | }; | |
70 | ||
71 | /* Extended community value is eight octet. */ | |
72 | struct ecommunity_val | |
73 | { | |
74 | char val[ECOMMUNITY_SIZE]; | |
75 | }; | |
76 | ||
77 | #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE) | |
78 | ||
94f2b392 | 79 | extern void ecommunity_init (void); |
228da428 | 80 | extern void ecommunity_finish (void); |
f6f434b2 | 81 | extern void ecommunity_free (struct ecommunity **); |
94f2b392 | 82 | extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short); |
83 | extern struct ecommunity *ecommunity_dup (struct ecommunity *); | |
84 | extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *); | |
0b597ef0 | 85 | extern struct ecommunity *ecommunity_uniq_sort (struct ecommunity *); |
94f2b392 | 86 | extern struct ecommunity *ecommunity_intern (struct ecommunity *); |
ffe11cfb | 87 | extern int ecommunity_cmp (const void *, const void *); |
f6f434b2 | 88 | extern void ecommunity_unintern (struct ecommunity **); |
0b2aa3a0 | 89 | extern unsigned int ecommunity_hash_make (void *); |
94f2b392 | 90 | extern struct ecommunity *ecommunity_str2com (const char *, int, int); |
e82202b7 | 91 | extern char *ecommunity_ecom2str (struct ecommunity *, int, int); |
94f2b392 | 92 | extern int ecommunity_match (const struct ecommunity *, const struct ecommunity *); |
93 | extern char *ecommunity_str (struct ecommunity *); | |
1e27ef50 | 94 | extern struct ecommunity_val *ecommunity_lookup (const struct ecommunity *, uint8_t, uint8_t ); |
e82202b7 | 95 | extern int ecommunity_add_val (struct ecommunity *ecom, struct ecommunity_val *eval); |
00d252cb | 96 | |
65efcfce LB |
97 | /* for vpn */ |
98 | extern struct ecommunity *ecommunity_new (void); | |
99 | extern int ecommunity_add_val (struct ecommunity *, struct ecommunity_val *); | |
1e27ef50 PG |
100 | extern int ecommunity_strip (struct ecommunity *ecom, uint8_t type, uint8_t subtype); |
101 | extern struct ecommunity *ecommunity_new (void); | |
00d252cb | 102 | #endif /* _QUAGGA_BGP_ECOMMUNITY_H */ |