bgp_community.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Community attribute related functions.
  2. Copyright (C) 1998 Kunihiro Ishiguro
  3. This file is part of GNU Zebra.
  4. GNU Zebra is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by the
  6. Free Software Foundation; either version 2, or (at your option) any
  7. later version.
  8. GNU Zebra is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Zebra; see the file COPYING. If not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. 02111-1307, USA. */
  16. #ifndef _QUAGGA_BGP_COMMUNITY_H
  17. #define _QUAGGA_BGP_COMMUNITY_H
  18. /* Communities attribute. */
  19. struct community
  20. {
  21. /* Reference count of communities value. */
  22. unsigned long refcnt;
  23. /* Communities value size. */
  24. int size;
  25. /* Communities value. */
  26. u_int32_t *val;
  27. /* String of community attribute. This sring is used by vty output
  28. and expanded community-list for regular expression match. */
  29. char *str;
  30. };
  31. /* Well-known communities value. */
  32. #define COMMUNITY_INTERNET 0x0
  33. #define COMMUNITY_NO_EXPORT 0xFFFFFF01
  34. #define COMMUNITY_NO_ADVERTISE 0xFFFFFF02
  35. #define COMMUNITY_NO_EXPORT_SUBCONFED 0xFFFFFF03
  36. #define COMMUNITY_LOCAL_AS 0xFFFFFF03
  37. /* Macros of community attribute. */
  38. #define com_length(X) ((X)->size * 4)
  39. #define com_lastval(X) ((X)->val + (X)->size - 1)
  40. #define com_nthval(X,n) ((X)->val + (n))
  41. /* Prototypes of communities attribute functions. */
  42. extern void community_init (void);
  43. extern void community_finish (void);
  44. extern void community_free (struct community *);
  45. extern struct community *community_uniq_sort (struct community *);
  46. extern struct community *community_parse (u_int32_t *, u_short);
  47. extern struct community *community_intern (struct community *);
  48. extern void community_unintern (struct community **);
  49. extern char *community_str (struct community *);
  50. extern unsigned int community_hash_make (struct community *);
  51. extern struct community *community_str2com (const char *);
  52. extern int community_match (const struct community *, const struct community *);
  53. extern int community_cmp (const struct community *, const struct community *);
  54. extern struct community *community_merge (struct community *, struct community *);
  55. extern struct community *community_delete (struct community *, struct community *);
  56. extern struct community *community_dup (struct community *);
  57. extern int community_include (struct community *, u_int32_t);
  58. extern void community_del_val (struct community *, u_int32_t *);
  59. extern unsigned long community_count (void);
  60. extern struct hash *community_hash (void);
  61. extern u_int32_t community_val_get (struct community *com, int i);
  62. #endif /* _QUAGGA_BGP_COMMUNITY_H */