paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP advertisement and adjacency |
| 2 | Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | under the terms of the GNU General Public License as published by the |
| 8 | Free Software Foundation; either version 2, or (at your option) any |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 21 | #ifndef _QUAGGA_BGP_ADVERTISE_H |
| 22 | #define _QUAGGA_BGP_ADVERTISE_H |
| 23 | |
Donald Sharp | b0d0288 | 2016-01-08 07:37:14 -0500 | [diff] [blame] | 24 | #include <lib/fifo.h> |
| 25 | |
Pradosh Mohapatra | af309fa | 2015-11-09 20:21:47 -0500 | [diff] [blame] | 26 | /* BGP advertise FIFO. */ |
| 27 | struct bgp_advertise_fifo |
| 28 | { |
| 29 | struct bgp_advertise *next; |
| 30 | struct bgp_advertise *prev; |
| 31 | u_int32_t count; |
| 32 | }; |
| 33 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 34 | /* BGP advertise attribute. */ |
| 35 | struct bgp_advertise_attr |
| 36 | { |
| 37 | /* Head of advertisement pointer. */ |
| 38 | struct bgp_advertise *adv; |
| 39 | |
| 40 | /* Reference counter. */ |
| 41 | unsigned long refcnt; |
| 42 | |
| 43 | /* Attribute pointer to be announced. */ |
| 44 | struct attr *attr; |
| 45 | }; |
| 46 | |
| 47 | struct bgp_advertise |
| 48 | { |
| 49 | /* FIFO for advertisement. */ |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 50 | struct fifo fifo; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | |
| 52 | /* Link list for same attribute advertise. */ |
| 53 | struct bgp_advertise *next; |
| 54 | struct bgp_advertise *prev; |
| 55 | |
| 56 | /* Prefix information. */ |
| 57 | struct bgp_node *rn; |
| 58 | |
| 59 | /* Reference pointer. */ |
| 60 | struct bgp_adj_out *adj; |
| 61 | |
| 62 | /* Advertisement attribute. */ |
| 63 | struct bgp_advertise_attr *baa; |
| 64 | |
| 65 | /* BGP info. */ |
| 66 | struct bgp_info *binfo; |
| 67 | }; |
| 68 | |
| 69 | /* BGP adjacency out. */ |
| 70 | struct bgp_adj_out |
| 71 | { |
| 72 | /* Lined list pointer. */ |
| 73 | struct bgp_adj_out *next; |
| 74 | struct bgp_adj_out *prev; |
| 75 | |
| 76 | /* Advertised peer. */ |
| 77 | struct peer *peer; |
| 78 | |
| 79 | /* Advertised attribute. */ |
| 80 | struct attr *attr; |
| 81 | |
| 82 | /* Advertisement information. */ |
| 83 | struct bgp_advertise *adv; |
| 84 | }; |
| 85 | |
| 86 | /* BGP adjacency in. */ |
| 87 | struct bgp_adj_in |
| 88 | { |
| 89 | /* Linked list pointer. */ |
| 90 | struct bgp_adj_in *next; |
| 91 | struct bgp_adj_in *prev; |
| 92 | |
| 93 | /* Received peer. */ |
| 94 | struct peer *peer; |
| 95 | |
| 96 | /* Received attribute. */ |
| 97 | struct attr *attr; |
| 98 | }; |
| 99 | |
| 100 | /* BGP advertisement list. */ |
| 101 | struct bgp_synchronize |
| 102 | { |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 103 | struct fifo update; |
| 104 | struct fifo withdraw; |
| 105 | struct fifo withdraw_low; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 108 | #define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F)) |
| 109 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 110 | /* BGP adjacency linked list. */ |
| 111 | #define BGP_INFO_ADD(N,A,TYPE) \ |
| 112 | do { \ |
| 113 | (A)->prev = NULL; \ |
| 114 | (A)->next = (N)->TYPE; \ |
| 115 | if ((N)->TYPE) \ |
| 116 | (N)->TYPE->prev = (A); \ |
| 117 | (N)->TYPE = (A); \ |
| 118 | } while (0) |
| 119 | |
| 120 | #define BGP_INFO_DEL(N,A,TYPE) \ |
| 121 | do { \ |
| 122 | if ((A)->next) \ |
| 123 | (A)->next->prev = (A)->prev; \ |
| 124 | if ((A)->prev) \ |
| 125 | (A)->prev->next = (A)->next; \ |
| 126 | else \ |
| 127 | (N)->TYPE = (A)->next; \ |
| 128 | } while (0) |
| 129 | |
| 130 | #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in) |
| 131 | #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in) |
| 132 | #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out) |
| 133 | #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out) |
| 134 | |
Pradosh Mohapatra | af309fa | 2015-11-09 20:21:47 -0500 | [diff] [blame] | 135 | #define BGP_ADV_FIFO_ADD(F, N) \ |
| 136 | do { \ |
| 137 | FIFO_ADD((F), (N)); \ |
| 138 | (F)->count++; \ |
| 139 | } while (0) |
| 140 | |
| 141 | #define BGP_ADV_FIFO_DEL(F, N) \ |
| 142 | do { \ |
| 143 | FIFO_DEL((N)); \ |
| 144 | (F)->count--; \ |
| 145 | } while (0) |
| 146 | |
| 147 | #define BGP_ADV_FIFO_INIT(F) \ |
| 148 | do { \ |
| 149 | FIFO_INIT((F)); \ |
| 150 | (F)->count = 0; \ |
| 151 | } while (0) |
| 152 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 153 | /* Prototypes. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 154 | extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 155 | struct attr *, afi_t, safi_t, struct bgp_info *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 156 | extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 157 | afi_t, safi_t); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 158 | extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | struct peer *, afi_t, safi_t); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 160 | extern int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 161 | struct bgp_node *); |
| 162 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 163 | extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *); |
David Lamparter | 4584c23 | 2015-04-13 09:50:00 +0200 | [diff] [blame] | 164 | extern int bgp_adj_in_unset (struct bgp_node *, struct peer *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 165 | extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 166 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 167 | extern struct bgp_advertise * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 168 | bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t); |
| 169 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 170 | extern void bgp_sync_init (struct peer *); |
| 171 | extern void bgp_sync_delete (struct peer *); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 172 | |
| 173 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |