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 | |
| 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 | /* Extended Communities value is eight octet long. */ |
| 35 | #define ECOMMUNITY_SIZE 8 |
| 36 | |
hasso | 4372df7 | 2004-05-20 10:20:02 +0000 | [diff] [blame] | 37 | /* Extended Communities type flag. */ |
| 38 | #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40 |
| 39 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | /* Extended Communities attribute. */ |
| 41 | struct ecommunity |
| 42 | { |
| 43 | /* Reference counter. */ |
| 44 | unsigned long refcnt; |
| 45 | |
| 46 | /* Size of Extended Communities attribute. */ |
| 47 | int size; |
| 48 | |
| 49 | /* Extended Communities value. */ |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 50 | u_int8_t *val; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | |
| 52 | /* Human readable format string. */ |
| 53 | char *str; |
| 54 | }; |
| 55 | |
| 56 | /* Extended community value is eight octet. */ |
| 57 | struct ecommunity_val |
| 58 | { |
| 59 | char val[ECOMMUNITY_SIZE]; |
| 60 | }; |
| 61 | |
| 62 | #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE) |
| 63 | |
| 64 | void ecommunity_init (void); |
| 65 | void ecommunity_free (struct ecommunity *); |
| 66 | struct ecommunity *ecommunity_new (void); |
paul | 5228ad2 | 2004-06-04 17:58:18 +0000 | [diff] [blame] | 67 | struct ecommunity *ecommunity_parse (u_int8_t *, u_short); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | struct ecommunity *ecommunity_dup (struct ecommunity *); |
| 69 | struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *); |
| 70 | struct ecommunity *ecommunity_intern (struct ecommunity *); |
| 71 | int ecommunity_cmp (struct ecommunity *, struct ecommunity *); |
| 72 | void ecommunity_unintern (struct ecommunity *); |
| 73 | unsigned int ecommunity_hash_make (struct ecommunity *); |
| 74 | struct ecommunity *ecommunity_str2com (char *, int, int); |
| 75 | char *ecommunity_ecom2str (struct ecommunity *, int); |
hasso | 4372df7 | 2004-05-20 10:20:02 +0000 | [diff] [blame] | 76 | int ecommunity_match (struct ecommunity *, struct ecommunity *); |
| 77 | char *ecommunity_str (struct ecommunity *); |