]>
Commit | Line | Data |
---|---|---|
718e3744 | 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 | ||
00d252cb | 21 | #ifndef _QUAGGA_BGP_ADVERTISE_H |
22 | #define _QUAGGA_BGP_ADVERTISE_H | |
23 | ||
718e3744 | 24 | /* BGP advertise FIFO. */ |
25 | struct bgp_advertise_fifo | |
26 | { | |
27 | struct bgp_advertise *next; | |
28 | struct bgp_advertise *prev; | |
cdabb8b6 | 29 | u_int32_t count; |
718e3744 | 30 | }; |
31 | ||
32 | /* BGP advertise attribute. */ | |
33 | struct bgp_advertise_attr | |
34 | { | |
35 | /* Head of advertisement pointer. */ | |
36 | struct bgp_advertise *adv; | |
37 | ||
38 | /* Reference counter. */ | |
39 | unsigned long refcnt; | |
40 | ||
41 | /* Attribute pointer to be announced. */ | |
42 | struct attr *attr; | |
43 | }; | |
44 | ||
45 | struct bgp_advertise | |
46 | { | |
47 | /* FIFO for advertisement. */ | |
48 | struct bgp_advertise_fifo fifo; | |
49 | ||
50 | /* Link list for same attribute advertise. */ | |
51 | struct bgp_advertise *next; | |
52 | struct bgp_advertise *prev; | |
53 | ||
54 | /* Prefix information. */ | |
55 | struct bgp_node *rn; | |
56 | ||
57 | /* Reference pointer. */ | |
58 | struct bgp_adj_out *adj; | |
59 | ||
60 | /* Advertisement attribute. */ | |
61 | struct bgp_advertise_attr *baa; | |
62 | ||
63 | /* BGP info. */ | |
64 | struct bgp_info *binfo; | |
65 | }; | |
66 | ||
67 | /* BGP adjacency out. */ | |
68 | struct bgp_adj_out | |
69 | { | |
70 | /* Lined list pointer. */ | |
71 | struct bgp_adj_out *next; | |
72 | struct bgp_adj_out *prev; | |
73 | ||
74 | /* Advertised peer. */ | |
75 | struct peer *peer; | |
76 | ||
77 | /* Advertised attribute. */ | |
78 | struct attr *attr; | |
79 | ||
80 | /* Advertisement information. */ | |
81 | struct bgp_advertise *adv; | |
82 | }; | |
83 | ||
84 | /* BGP adjacency in. */ | |
85 | struct bgp_adj_in | |
86 | { | |
87 | /* Linked list pointer. */ | |
88 | struct bgp_adj_in *next; | |
89 | struct bgp_adj_in *prev; | |
90 | ||
91 | /* Received peer. */ | |
92 | struct peer *peer; | |
93 | ||
94 | /* Received attribute. */ | |
95 | struct attr *attr; | |
96 | }; | |
97 | ||
98 | /* BGP advertisement list. */ | |
99 | struct bgp_synchronize | |
100 | { | |
101 | struct bgp_advertise_fifo update; | |
102 | struct bgp_advertise_fifo withdraw; | |
103 | struct bgp_advertise_fifo withdraw_low; | |
104 | }; | |
105 | ||
718e3744 | 106 | /* BGP adjacency linked list. */ |
107 | #define BGP_INFO_ADD(N,A,TYPE) \ | |
108 | do { \ | |
109 | (A)->prev = NULL; \ | |
110 | (A)->next = (N)->TYPE; \ | |
111 | if ((N)->TYPE) \ | |
112 | (N)->TYPE->prev = (A); \ | |
113 | (N)->TYPE = (A); \ | |
114 | } while (0) | |
115 | ||
116 | #define BGP_INFO_DEL(N,A,TYPE) \ | |
117 | do { \ | |
118 | if ((A)->next) \ | |
119 | (A)->next->prev = (A)->prev; \ | |
120 | if ((A)->prev) \ | |
121 | (A)->prev->next = (A)->next; \ | |
122 | else \ | |
123 | (N)->TYPE = (A)->next; \ | |
124 | } while (0) | |
125 | ||
126 | #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in) | |
127 | #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in) | |
128 | #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out) | |
129 | #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out) | |
130 | ||
cdabb8b6 DS |
131 | #define BGP_ADV_FIFO_ADD(F, N) \ |
132 | do { \ | |
133 | FIFO_ADD((F), (N)); \ | |
134 | (F)->count++; \ | |
135 | } while (0) | |
136 | ||
137 | #define BGP_ADV_FIFO_DEL(F, N) \ | |
138 | do { \ | |
139 | FIFO_DEL((N)); \ | |
140 | (F)->count--; \ | |
141 | } while (0) | |
142 | ||
143 | #define BGP_ADV_FIFO_INIT(F) \ | |
144 | do { \ | |
145 | FIFO_INIT((F)); \ | |
146 | (F)->count = 0; \ | |
147 | } while (0) | |
148 | ||
718e3744 | 149 | /* Prototypes. */ |
94f2b392 | 150 | extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *, |
718e3744 | 151 | struct attr *, afi_t, safi_t, struct bgp_info *); |
94f2b392 | 152 | extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *, |
718e3744 | 153 | afi_t, safi_t); |
94f2b392 | 154 | extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *, |
718e3744 | 155 | struct peer *, afi_t, safi_t); |
94f2b392 | 156 | extern int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t, |
718e3744 | 157 | struct bgp_node *); |
158 | ||
94f2b392 | 159 | extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *); |
160 | extern void bgp_adj_in_unset (struct bgp_node *, struct peer *); | |
161 | extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *); | |
718e3744 | 162 | |
94f2b392 | 163 | extern struct bgp_advertise * |
718e3744 | 164 | bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t); |
165 | ||
94f2b392 | 166 | extern void bgp_sync_init (struct peer *); |
167 | extern void bgp_sync_delete (struct peer *); | |
00d252cb | 168 | |
169 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |