bgp_advertise.h 4.3 KB

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