]>
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 | ||
ea863ec6 DS |
24 | #include <lib/fifo.h> |
25 | ||
3f9c7369 DS |
26 | struct update_subgroup; |
27 | ||
718e3744 | 28 | /* BGP advertise FIFO. */ |
29 | struct bgp_advertise_fifo | |
30 | { | |
31 | struct bgp_advertise *next; | |
32 | struct bgp_advertise *prev; | |
cdabb8b6 | 33 | u_int32_t count; |
718e3744 | 34 | }; |
35 | ||
36 | /* BGP advertise attribute. */ | |
37 | struct bgp_advertise_attr | |
38 | { | |
39 | /* Head of advertisement pointer. */ | |
40 | struct bgp_advertise *adv; | |
41 | ||
42 | /* Reference counter. */ | |
43 | unsigned long refcnt; | |
44 | ||
45 | /* Attribute pointer to be announced. */ | |
46 | struct attr *attr; | |
47 | }; | |
48 | ||
49 | struct bgp_advertise | |
50 | { | |
51 | /* FIFO for advertisement. */ | |
52 | struct bgp_advertise_fifo fifo; | |
53 | ||
54 | /* Link list for same attribute advertise. */ | |
55 | struct bgp_advertise *next; | |
56 | struct bgp_advertise *prev; | |
57 | ||
58 | /* Prefix information. */ | |
59 | struct bgp_node *rn; | |
60 | ||
61 | /* Reference pointer. */ | |
62 | struct bgp_adj_out *adj; | |
63 | ||
64 | /* Advertisement attribute. */ | |
65 | struct bgp_advertise_attr *baa; | |
66 | ||
67 | /* BGP info. */ | |
68 | struct bgp_info *binfo; | |
69 | }; | |
70 | ||
71 | /* BGP adjacency out. */ | |
72 | struct bgp_adj_out | |
73 | { | |
74 | /* Lined list pointer. */ | |
75 | struct bgp_adj_out *next; | |
76 | struct bgp_adj_out *prev; | |
77 | ||
3f9c7369 DS |
78 | /* Advertised subgroup. */ |
79 | struct update_subgroup *subgroup; | |
80 | ||
81 | /* Threading that makes the adj part of subgroup's adj queue */ | |
82 | TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train; | |
83 | ||
84 | /* Prefix information. */ | |
85 | struct bgp_node *rn; | |
718e3744 | 86 | |
adbac85e DW |
87 | u_int32_t addpath_tx_id; |
88 | ||
718e3744 | 89 | /* Advertised attribute. */ |
90 | struct attr *attr; | |
91 | ||
92 | /* Advertisement information. */ | |
93 | struct bgp_advertise *adv; | |
94 | }; | |
95 | ||
96 | /* BGP adjacency in. */ | |
97 | struct bgp_adj_in | |
98 | { | |
99 | /* Linked list pointer. */ | |
100 | struct bgp_adj_in *next; | |
101 | struct bgp_adj_in *prev; | |
102 | ||
103 | /* Received peer. */ | |
104 | struct peer *peer; | |
105 | ||
106 | /* Received attribute. */ | |
107 | struct attr *attr; | |
43143c8f DS |
108 | |
109 | /* Addpath identifier */ | |
110 | u_int32_t addpath_rx_id; | |
718e3744 | 111 | }; |
112 | ||
113 | /* BGP advertisement list. */ | |
114 | struct bgp_synchronize | |
115 | { | |
116 | struct bgp_advertise_fifo update; | |
117 | struct bgp_advertise_fifo withdraw; | |
118 | struct bgp_advertise_fifo withdraw_low; | |
119 | }; | |
120 | ||
718e3744 | 121 | /* BGP adjacency linked list. */ |
122 | #define BGP_INFO_ADD(N,A,TYPE) \ | |
123 | do { \ | |
124 | (A)->prev = NULL; \ | |
125 | (A)->next = (N)->TYPE; \ | |
126 | if ((N)->TYPE) \ | |
127 | (N)->TYPE->prev = (A); \ | |
128 | (N)->TYPE = (A); \ | |
129 | } while (0) | |
130 | ||
131 | #define BGP_INFO_DEL(N,A,TYPE) \ | |
132 | do { \ | |
133 | if ((A)->next) \ | |
134 | (A)->next->prev = (A)->prev; \ | |
135 | if ((A)->prev) \ | |
136 | (A)->prev->next = (A)->next; \ | |
137 | else \ | |
138 | (N)->TYPE = (A)->next; \ | |
139 | } while (0) | |
140 | ||
141 | #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in) | |
142 | #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in) | |
143 | #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out) | |
144 | #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out) | |
145 | ||
cdabb8b6 DS |
146 | #define BGP_ADV_FIFO_ADD(F, N) \ |
147 | do { \ | |
148 | FIFO_ADD((F), (N)); \ | |
149 | (F)->count++; \ | |
150 | } while (0) | |
151 | ||
152 | #define BGP_ADV_FIFO_DEL(F, N) \ | |
153 | do { \ | |
154 | FIFO_DEL((N)); \ | |
155 | (F)->count--; \ | |
156 | } while (0) | |
157 | ||
158 | #define BGP_ADV_FIFO_INIT(F) \ | |
159 | do { \ | |
160 | FIFO_INIT((F)); \ | |
161 | (F)->count = 0; \ | |
162 | } while (0) | |
163 | ||
d889623f DS |
164 | #define BGP_ADV_FIFO_COUNT(F) \ |
165 | (F)->count | |
166 | ||
3f9c7369 DS |
167 | #define BGP_ADV_FIFO_EMPTY(F) \ |
168 | (((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F)) | |
169 | ||
170 | #define BGP_ADV_FIFO_HEAD(F) \ | |
171 | ((((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F)) \ | |
172 | ? NULL : (F)->next) | |
173 | ||
718e3744 | 174 | /* Prototypes. */ |
adbac85e | 175 | extern int bgp_adj_out_lookup (struct peer *, struct bgp_node *, u_int32_t); |
43143c8f | 176 | extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *, u_int32_t); |
6b87f736 | 177 | extern int bgp_adj_in_unset (struct bgp_node *, struct peer *, u_int32_t); |
94f2b392 | 178 | extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *); |
718e3744 | 179 | |
94f2b392 | 180 | extern void bgp_sync_init (struct peer *); |
181 | extern void bgp_sync_delete (struct peer *); | |
3f9c7369 DS |
182 | extern unsigned int baa_hash_key (void *p); |
183 | extern int baa_hash_cmp (const void *p1, const void *p2); | |
184 | extern void bgp_advertise_add (struct bgp_advertise_attr *baa, | |
185 | struct bgp_advertise *adv); | |
186 | extern struct bgp_advertise *bgp_advertise_new (void); | |
187 | extern void bgp_advertise_free (struct bgp_advertise *adv); | |
188 | extern struct bgp_advertise_attr * | |
189 | bgp_advertise_intern (struct hash *hash, struct attr *attr); | |
190 | extern struct bgp_advertise_attr *baa_new (void); | |
191 | extern void | |
192 | bgp_advertise_delete (struct bgp_advertise_attr *baa, | |
193 | struct bgp_advertise *adv); | |
194 | extern void | |
195 | bgp_advertise_unintern (struct hash *hash, struct bgp_advertise_attr *baa); | |
00d252cb | 196 | |
197 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |