bgp_advertise.h 4.2 KB

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