bgp_clist.h 5.3 KB

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