bgp_lcommunity.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* BGP Large Communities Attribute.
  2. Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
  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_LCOMMUNITY_H
  17. #define _QUAGGA_BGP_LCOMMUNITY_H
  18. /* Extended communities attribute string format. */
  19. #define LCOMMUNITY_FORMAT_ROUTE_MAP 0
  20. #define LCOMMUNITY_FORMAT_COMMUNITY_LIST 1
  21. #define LCOMMUNITY_FORMAT_DISPLAY 2
  22. /* Large Communities value is twelve octets long. */
  23. #define LCOMMUNITY_SIZE 12
  24. /* Large Communities attribute. */
  25. struct lcommunity
  26. {
  27. /* Reference counter. */
  28. unsigned long refcnt;
  29. /* Size of Extended Communities attribute. */
  30. int size;
  31. /* Extended Communities value. */
  32. u_int8_t *val;
  33. /* Human readable format string. */
  34. char *str;
  35. };
  36. /* Extended community value is eight octet. */
  37. struct lcommunity_val
  38. {
  39. char val[LCOMMUNITY_SIZE];
  40. };
  41. #define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE)
  42. extern void lcommunity_init (void);
  43. extern void lcommunity_finish (void);
  44. extern void lcommunity_free (struct lcommunity **);
  45. extern struct lcommunity *lcommunity_parse (u_int8_t *, u_short);
  46. extern struct lcommunity *lcommunity_dup (struct lcommunity *);
  47. extern struct lcommunity *lcommunity_merge (struct lcommunity *, struct lcommunity *);
  48. extern struct lcommunity *lcommunity_uniq_sort (struct lcommunity *);
  49. extern struct lcommunity *lcommunity_intern (struct lcommunity *);
  50. extern int lcommunity_cmp (const void *, const void *);
  51. extern void lcommunity_unintern (struct lcommunity **);
  52. extern unsigned int lcommunity_hash_make (void *);
  53. extern struct hash *lcommunity_hash (void);
  54. extern struct lcommunity *lcommunity_str2com (const char *);
  55. extern char *lcommunity_lcom2str (struct lcommunity *, int);
  56. extern int lcommunity_match (const struct lcommunity *, const struct lcommunity *);
  57. extern char *lcommunity_str (struct lcommunity *);
  58. extern int lcommunity_include (struct lcommunity *lcom, u_char *ptr);
  59. extern void lcommunity_del_val (struct lcommunity *lcom, u_char *ptr);
  60. #endif /* _QUAGGA_BGP_LCOMMUNITY_H */