bgp_clist.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* BGP Community list.
  2. Copyright (C) 1999 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_CLIST_H
  17. #define _QUAGGA_BGP_CLIST_H
  18. /* Master Community-list. */
  19. #define COMMUNITY_LIST_MASTER 0
  20. #define EXTCOMMUNITY_LIST_MASTER 1
  21. /* Community-list deny and permit. */
  22. #define COMMUNITY_DENY 0
  23. #define COMMUNITY_PERMIT 1
  24. /* Number and string based community-list name. */
  25. #define COMMUNITY_LIST_STRING 0
  26. #define COMMUNITY_LIST_NUMBER 1
  27. /* Community-list entry types. */
  28. #define COMMUNITY_LIST_STANDARD 0 /* Standard community-list. */
  29. #define COMMUNITY_LIST_EXPANDED 1 /* Expanded community-list. */
  30. #define EXTCOMMUNITY_LIST_STANDARD 2 /* Standard extcommunity-list. */
  31. #define EXTCOMMUNITY_LIST_EXPANDED 3 /* Expanded extcommunity-list. */
  32. /* Community-list. */
  33. struct community_list
  34. {
  35. /* Name of the community-list. */
  36. char *name;
  37. /* String or number. */
  38. int sort;
  39. /* Link to upper list. */
  40. struct community_list_list *parent;
  41. /* Linked list for other community-list. */
  42. struct community_list *next;
  43. struct community_list *prev;
  44. /* Community-list entry in this community-list. */
  45. struct community_entry *head;
  46. struct community_entry *tail;
  47. };
  48. /* Each entry in community-list. */
  49. struct community_entry
  50. {
  51. struct community_entry *next;
  52. struct community_entry *prev;
  53. /* Permit or deny. */
  54. u_char direct;
  55. /* Standard or expanded. */
  56. u_char style;
  57. /* Any match. */
  58. u_char any;
  59. /* Community structure. */
  60. union
  61. {
  62. struct community *com;
  63. struct ecommunity *ecom;
  64. } u;
  65. /* Configuration string. */
  66. char *config;
  67. /* Expanded community-list regular expression. */
  68. regex_t *reg;
  69. };
  70. /* Linked list of community-list. */
  71. struct community_list_list
  72. {
  73. struct community_list *head;
  74. struct community_list *tail;
  75. };
  76. /* Master structure of community-list and extcommunity-list. */
  77. struct community_list_master
  78. {
  79. struct community_list_list num;
  80. struct community_list_list str;
  81. };
  82. /* Community-list handler. community_list_init() returns this
  83. structure as handler. */
  84. struct community_list_handler
  85. {
  86. /* Community-list. */
  87. struct community_list_master community_list;
  88. /* Exteded community-list. */
  89. struct community_list_master extcommunity_list;
  90. };
  91. /* Error code of community-list. */
  92. #define COMMUNITY_LIST_ERR_CANT_FIND_LIST -1
  93. #define COMMUNITY_LIST_ERR_MALFORMED_VAL -2
  94. #define COMMUNITY_LIST_ERR_STANDARD_CONFLICT -3
  95. #define COMMUNITY_LIST_ERR_EXPANDED_CONFLICT -4
  96. /* Handler. */
  97. extern struct community_list_handler *bgp_clist;
  98. /* Prototypes. */
  99. extern struct community_list_handler *community_list_init (void);
  100. extern int community_list_set (struct community_list_handler *ch,
  101. const char *name, const char *str, int direct,
  102. int style);
  103. extern int community_list_unset (struct community_list_handler *ch,
  104. const char *name, const char *str,
  105. int direct, int style);
  106. extern int extcommunity_list_set (struct community_list_handler *ch,
  107. const char *name, const char *str,
  108. int direct, int style);
  109. extern int extcommunity_list_unset (struct community_list_handler *ch,
  110. const char *name, const char *str,
  111. int direct, int style);
  112. extern struct community_list_master *
  113. community_list_master_lookup (struct community_list_handler *, int);
  114. extern struct community_list *
  115. community_list_lookup (struct community_list_handler *, const char *, int);
  116. extern int community_list_match (struct community *, struct community_list *);
  117. extern int ecommunity_list_match (struct ecommunity *, struct community_list *);
  118. extern int community_list_exact_match (struct community *,
  119. struct community_list *);
  120. extern struct community *
  121. community_list_match_delete (struct community *, struct community_list *);
  122. #endif /* _QUAGGA_BGP_CLIST_H */