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 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 24 | /* BGP advertise attribute. */ |
| 25 | struct bgp_advertise_attr |
| 26 | { |
| 27 | /* Head of advertisement pointer. */ |
| 28 | struct bgp_advertise *adv; |
| 29 | |
| 30 | /* Reference counter. */ |
| 31 | unsigned long refcnt; |
| 32 | |
| 33 | /* Attribute pointer to be announced. */ |
| 34 | struct attr *attr; |
| 35 | }; |
| 36 | |
| 37 | struct bgp_advertise |
| 38 | { |
| 39 | /* FIFO for advertisement. */ |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 40 | struct fifo fifo; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 41 | |
| 42 | /* Link list for same attribute advertise. */ |
| 43 | struct bgp_advertise *next; |
| 44 | struct bgp_advertise *prev; |
| 45 | |
| 46 | /* Prefix information. */ |
| 47 | struct bgp_node *rn; |
| 48 | |
| 49 | /* Reference pointer. */ |
| 50 | struct bgp_adj_out *adj; |
| 51 | |
| 52 | /* Advertisement attribute. */ |
| 53 | struct bgp_advertise_attr *baa; |
| 54 | |
| 55 | /* BGP info. */ |
| 56 | struct bgp_info *binfo; |
| 57 | }; |
| 58 | |
| 59 | /* BGP adjacency out. */ |
| 60 | struct bgp_adj_out |
| 61 | { |
| 62 | /* Lined list pointer. */ |
| 63 | struct bgp_adj_out *next; |
| 64 | struct bgp_adj_out *prev; |
| 65 | |
| 66 | /* Advertised peer. */ |
| 67 | struct peer *peer; |
| 68 | |
| 69 | /* Advertised attribute. */ |
| 70 | struct attr *attr; |
| 71 | |
| 72 | /* Advertisement information. */ |
| 73 | struct bgp_advertise *adv; |
| 74 | }; |
| 75 | |
| 76 | /* BGP adjacency in. */ |
| 77 | struct bgp_adj_in |
| 78 | { |
| 79 | /* Linked list pointer. */ |
| 80 | struct bgp_adj_in *next; |
| 81 | struct bgp_adj_in *prev; |
| 82 | |
| 83 | /* Received peer. */ |
| 84 | struct peer *peer; |
| 85 | |
| 86 | /* Received attribute. */ |
| 87 | struct attr *attr; |
| 88 | }; |
| 89 | |
| 90 | /* BGP advertisement list. */ |
| 91 | struct bgp_synchronize |
| 92 | { |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 93 | struct fifo update; |
| 94 | struct fifo withdraw; |
| 95 | struct fifo withdraw_low; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
Paul Jakma | 7aa9dce | 2014-09-19 14:42:23 +0100 | [diff] [blame] | 98 | #define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F)) |
| 99 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 100 | /* BGP adjacency linked list. */ |
| 101 | #define BGP_INFO_ADD(N,A,TYPE) \ |
| 102 | do { \ |
| 103 | (A)->prev = NULL; \ |
| 104 | (A)->next = (N)->TYPE; \ |
| 105 | if ((N)->TYPE) \ |
| 106 | (N)->TYPE->prev = (A); \ |
| 107 | (N)->TYPE = (A); \ |
| 108 | } while (0) |
| 109 | |
| 110 | #define BGP_INFO_DEL(N,A,TYPE) \ |
| 111 | do { \ |
| 112 | if ((A)->next) \ |
| 113 | (A)->next->prev = (A)->prev; \ |
| 114 | if ((A)->prev) \ |
| 115 | (A)->prev->next = (A)->next; \ |
| 116 | else \ |
| 117 | (N)->TYPE = (A)->next; \ |
| 118 | } while (0) |
| 119 | |
| 120 | #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in) |
| 121 | #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in) |
| 122 | #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out) |
| 123 | #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out) |
| 124 | |
| 125 | /* Prototypes. */ |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 126 | extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 127 | struct attr *, afi_t, safi_t, struct bgp_info *); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 128 | extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | afi_t, safi_t); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 130 | extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | struct peer *, afi_t, safi_t); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 132 | 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] | 133 | struct bgp_node *); |
| 134 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 135 | extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *); |
| 136 | extern void bgp_adj_in_unset (struct bgp_node *, struct peer *); |
| 137 | extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 138 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 139 | extern struct bgp_advertise * |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t); |
| 141 | |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 142 | extern void bgp_sync_init (struct peer *); |
| 143 | extern void bgp_sync_delete (struct peer *); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 144 | |
| 145 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |