paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 21 | #ifndef _QUAGGA_BGP_ECOMMUNITY_H |
| 22 | #define _QUAGGA_BGP_ECOMMUNITY_H |
| 23 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 24 | /* High-order octet of the Extended Communities type field. */ |
| 25 | #define ECOMMUNITY_ENCODE_AS 0x00 |
| 26 | #define ECOMMUNITY_ENCODE_IP 0x01 |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 27 | #define ECOMMUNITY_ENCODE_AS4 0x02 |
Lou Berger | 5a81fc9 | 2016-01-12 13:42:00 -0500 | [diff] [blame] | 28 | #define ECOMMUNITY_ENCODE_OPAQUE 0x03 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 29 | |
Lou Berger | 5a81fc9 | 2016-01-12 13:42:00 -0500 | [diff] [blame] | 30 | /* Low-order octet of the Extended Communities type field. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | #define ECOMMUNITY_ROUTE_TARGET 0x02 |
| 32 | #define ECOMMUNITY_SITE_ORIGIN 0x03 |
| 33 | |
Lou Berger | 5a81fc9 | 2016-01-12 13:42:00 -0500 | [diff] [blame] | 34 | /* Low-order octet of the Extended Communities type field for OPAQUE types */ |
| 35 | #define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c |
| 36 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 37 | /* Extended communities attribute string format. */ |
| 38 | #define ECOMMUNITY_FORMAT_ROUTE_MAP 0 |
| 39 | #define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1 |
| 40 | #define ECOMMUNITY_FORMAT_DISPLAY 2 |
| 41 | |
| 42 | /* Extended Communities value is eight octet long. */ |
| 43 | #define ECOMMUNITY_SIZE 8 |
| 44 | |
hasso | 4372df7 | 2004-05-20 10:20:02 +0000 | [diff] [blame] | 45 | /* Extended Communities type flag. */ |
| 46 | #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40 |
| 47 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 48 | /* Extended Communities attribute. */ |
| 49 | struct ecommunity |
| 50 | { |
| 51 | /* Reference counter. */ |
| 52 | unsigned long refcnt; |
| 53 | |
| 54 | /* Size of Extended Communities attribute. */ |
| 55 | int size; |
| 56 | |
| 57 | /* Extended Communities value. */ |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 58 | u_int8_t *val; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | |
| 60 | /* Human readable format string. */ |
| 61 | char *str; |
| 62 | }; |
| 63 | |
| 64 | /* Extended community value is eight octet. */ |
| 65 | struct ecommunity_val |
| 66 | { |
| 67 | char val[ECOMMUNITY_SIZE]; |
| 68 | }; |
| 69 | |
| 70 | #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE) |
| 71 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 72 | extern void ecommunity_init (void); |
Chris Caputo | 228da42 | 2009-07-18 05:44:03 +0000 | [diff] [blame] | 73 | extern void ecommunity_finish (void); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 74 | extern void ecommunity_free (struct ecommunity **); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 75 | extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short); |
| 76 | extern struct ecommunity *ecommunity_dup (struct ecommunity *); |
| 77 | extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *); |
Josh Bailey | 0b597ef | 2011-07-20 20:49:11 -0700 | [diff] [blame] | 78 | extern struct ecommunity *ecommunity_uniq_sort (struct ecommunity *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 79 | extern struct ecommunity *ecommunity_intern (struct ecommunity *); |
Stephen Hemminger | ffe11cf | 2008-08-14 16:25:25 +0100 | [diff] [blame] | 80 | extern int ecommunity_cmp (const void *, const void *); |
Paul Jakma | f6f434b | 2010-11-23 21:28:03 +0000 | [diff] [blame] | 81 | extern void ecommunity_unintern (struct ecommunity **); |
Paul Jakma | 0b2aa3a | 2007-10-14 22:32:21 +0000 | [diff] [blame] | 82 | extern unsigned int ecommunity_hash_make (void *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 83 | extern struct ecommunity *ecommunity_str2com (const char *, int, int); |
| 84 | extern char *ecommunity_ecom2str (struct ecommunity *, int); |
| 85 | extern int ecommunity_match (const struct ecommunity *, const struct ecommunity *); |
| 86 | extern char *ecommunity_str (struct ecommunity *); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 87 | |
| 88 | #endif /* _QUAGGA_BGP_ECOMMUNITY_H */ |