paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Community attribute related functions. |
| 2 | Copyright (C) 1998 Kunihiro Ishiguro |
| 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 | /* Communities attribute. */ |
| 22 | struct community |
| 23 | { |
| 24 | /* Reference count of communities value. */ |
| 25 | unsigned long refcnt; |
| 26 | |
| 27 | /* Communities value size. */ |
| 28 | int size; |
| 29 | |
| 30 | /* Communities value. */ |
| 31 | u_int32_t *val; |
| 32 | |
| 33 | /* String of community attribute. This sring is used by vty output |
| 34 | and expanded community-list for regular expression match. */ |
| 35 | char *str; |
| 36 | }; |
| 37 | |
| 38 | /* Well-known communities value. */ |
| 39 | #define COMMUNITY_INTERNET 0x0 |
| 40 | #define COMMUNITY_NO_EXPORT 0xFFFFFF01 |
| 41 | #define COMMUNITY_NO_ADVERTISE 0xFFFFFF02 |
| 42 | #define COMMUNITY_NO_EXPORT_SUBCONFED 0xFFFFFF03 |
| 43 | #define COMMUNITY_LOCAL_AS 0xFFFFFF03 |
| 44 | |
| 45 | /* Macros of community attribute. */ |
| 46 | #define com_length(X) ((X)->size * 4) |
| 47 | #define com_lastval(X) ((X)->val + (X)->size - 1) |
| 48 | #define com_nthval(X,n) ((X)->val + (n)) |
| 49 | |
| 50 | /* Prototypes of communities attribute functions. */ |
| 51 | void community_init (); |
| 52 | void community_free (struct community *); |
| 53 | struct community *community_uniq_sort (struct community *); |
| 54 | struct community *community_parse (char *, u_short); |
| 55 | struct community *community_intern (struct community *); |
| 56 | void community_unintern (struct community *); |
| 57 | char *community_str (struct community *); |
| 58 | unsigned int community_hash_make (struct community *); |
| 59 | struct community *community_str2com (char *); |
| 60 | int community_match (struct community *, struct community *); |
| 61 | int community_cmp (struct community *, struct community *); |
| 62 | struct community *community_merge (struct community *, struct community *); |
| 63 | struct community *community_delete (struct community *, struct community *); |
| 64 | struct community *community_dup (struct community *); |
| 65 | int community_include (struct community *, u_int32_t); |
| 66 | void community_del_val (struct community *, u_int32_t *); |
| 67 | unsigned long community_count (); |
| 68 | struct hash *community_hash (); |