bgp_advertise.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* BGP advertisement and adjacency
  2. Copyright (C) 1996, 97, 98, 99, 2000 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_ADVERTISE_H
  17. #define _QUAGGA_BGP_ADVERTISE_H
  18. #include <lib/fifo.h>
  19. /* BGP advertise FIFO. */
  20. struct bgp_advertise_fifo
  21. {
  22. struct bgp_advertise *next;
  23. struct bgp_advertise *prev;
  24. u_int32_t count;
  25. };
  26. /* BGP advertise attribute. */
  27. struct bgp_advertise_attr
  28. {
  29. /* Head of advertisement pointer. */
  30. struct bgp_advertise *adv;
  31. /* Reference counter. */
  32. unsigned long refcnt;
  33. /* Attribute pointer to be announced. */
  34. struct attr *attr;
  35. };
  36. struct bgp_advertise
  37. {
  38. /* FIFO for advertisement. */
  39. struct fifo fifo;
  40. /* Link list for same attribute advertise. */
  41. struct bgp_advertise *next;
  42. struct bgp_advertise *prev;
  43. /* Prefix information. */
  44. struct bgp_node *rn;
  45. /* Reference pointer. */
  46. struct bgp_adj_out *adj;
  47. /* Advertisement attribute. */
  48. struct bgp_advertise_attr *baa;
  49. /* BGP info. */
  50. struct bgp_info *binfo;
  51. };
  52. /* BGP adjacency out. */
  53. struct bgp_adj_out
  54. {
  55. /* Lined list pointer. */
  56. struct bgp_adj_out *next;
  57. struct bgp_adj_out *prev;
  58. /* Advertised peer. */
  59. struct peer *peer;
  60. /* Advertised attribute. */
  61. struct attr *attr;
  62. /* Advertisement information. */
  63. struct bgp_advertise *adv;
  64. };
  65. /* BGP adjacency in. */
  66. struct bgp_adj_in
  67. {
  68. /* Linked list pointer. */
  69. struct bgp_adj_in *next;
  70. struct bgp_adj_in *prev;
  71. /* Received peer. */
  72. struct peer *peer;
  73. /* Received attribute. */
  74. struct attr *attr;
  75. };
  76. /* BGP advertisement list. */
  77. struct bgp_synchronize
  78. {
  79. struct fifo update;
  80. struct fifo withdraw;
  81. struct fifo withdraw_low;
  82. };
  83. #define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F))
  84. /* BGP adjacency linked list. */
  85. #define BGP_INFO_ADD(N,A,TYPE) \
  86. do { \
  87. (A)->prev = NULL; \
  88. (A)->next = (N)->TYPE; \
  89. if ((N)->TYPE) \
  90. (N)->TYPE->prev = (A); \
  91. (N)->TYPE = (A); \
  92. } while (0)
  93. #define BGP_INFO_DEL(N,A,TYPE) \
  94. do { \
  95. if ((A)->next) \
  96. (A)->next->prev = (A)->prev; \
  97. if ((A)->prev) \
  98. (A)->prev->next = (A)->next; \
  99. else \
  100. (N)->TYPE = (A)->next; \
  101. } while (0)
  102. #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in)
  103. #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in)
  104. #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
  105. #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
  106. #define BGP_ADV_FIFO_ADD(F, N) \
  107. do { \
  108. FIFO_ADD((F), (N)); \
  109. (F)->count++; \
  110. } while (0)
  111. #define BGP_ADV_FIFO_DEL(F, N) \
  112. do { \
  113. FIFO_DEL((N)); \
  114. (F)->count--; \
  115. } while (0)
  116. #define BGP_ADV_FIFO_INIT(F) \
  117. do { \
  118. FIFO_INIT((F)); \
  119. (F)->count = 0; \
  120. } while (0)
  121. /* Prototypes. */
  122. extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *,
  123. struct attr *, afi_t, safi_t, struct bgp_info *);
  124. extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *,
  125. afi_t, safi_t);
  126. extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *,
  127. struct peer *, afi_t, safi_t);
  128. extern int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t,
  129. struct bgp_node *);
  130. extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *);
  131. extern int bgp_adj_in_unset (struct bgp_node *, struct peer *);
  132. extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *);
  133. extern struct bgp_advertise *
  134. bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t);
  135. extern void bgp_sync_init (struct peer *);
  136. extern void bgp_sync_delete (struct peer *);
  137. #endif /* _QUAGGA_BGP_ADVERTISE_H */