bgp_ecommunity.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* BGP Extended Communities Attribute.
  2. Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
  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_ECOMMUNITY_H
  17. #define _QUAGGA_BGP_ECOMMUNITY_H
  18. /* High-order octet of the Extended Communities type field. */
  19. #define ECOMMUNITY_ENCODE_AS 0x00
  20. #define ECOMMUNITY_ENCODE_IP 0x01
  21. #define ECOMMUNITY_ENCODE_AS4 0x02
  22. #define ECOMMUNITY_ENCODE_OPAQUE 0x03
  23. /* Low-order octet of the Extended Communities type field. */
  24. #define ECOMMUNITY_ROUTE_TARGET 0x02
  25. #define ECOMMUNITY_SITE_ORIGIN 0x03
  26. /* Low-order octet of the Extended Communities type field for OPAQUE types */
  27. #define ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP 0x0c
  28. /* Extended communities attribute string format. */
  29. #define ECOMMUNITY_FORMAT_ROUTE_MAP 0
  30. #define ECOMMUNITY_FORMAT_COMMUNITY_LIST 1
  31. #define ECOMMUNITY_FORMAT_DISPLAY 2
  32. /* Extended Communities value is eight octet long. */
  33. #define ECOMMUNITY_SIZE 8
  34. /* Extended Communities type flag. */
  35. #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40
  36. /* Extended Communities attribute. */
  37. struct ecommunity
  38. {
  39. /* Reference counter. */
  40. unsigned long refcnt;
  41. /* Size of Extended Communities attribute. */
  42. int size;
  43. /* Extended Communities value. */
  44. u_int8_t *val;
  45. /* Human readable format string. */
  46. char *str;
  47. };
  48. /* Extended community value is eight octet. */
  49. struct ecommunity_val
  50. {
  51. char val[ECOMMUNITY_SIZE];
  52. };
  53. #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE)
  54. extern void ecommunity_init (void);
  55. extern void ecommunity_finish (void);
  56. extern void ecommunity_free (struct ecommunity **);
  57. extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short);
  58. extern struct ecommunity *ecommunity_dup (struct ecommunity *);
  59. extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
  60. extern struct ecommunity *ecommunity_uniq_sort (struct ecommunity *);
  61. extern struct ecommunity *ecommunity_intern (struct ecommunity *);
  62. extern int ecommunity_cmp (const void *, const void *);
  63. extern void ecommunity_unintern (struct ecommunity **);
  64. extern unsigned int ecommunity_hash_make (void *);
  65. extern struct ecommunity *ecommunity_str2com (const char *, int, int);
  66. extern char *ecommunity_ecom2str (struct ecommunity *, int);
  67. extern int ecommunity_match (const struct ecommunity *, const struct ecommunity *);
  68. extern char *ecommunity_str (struct ecommunity *);
  69. #endif /* _QUAGGA_BGP_ECOMMUNITY_H */