]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP advertisement and adjacency |
896014f4 DL |
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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 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. */ |
d62a17ae | 29 | struct bgp_advertise_fifo { |
30 | struct bgp_advertise *next; | |
31 | struct bgp_advertise *prev; | |
d7c0a89a | 32 | uint32_t count; |
718e3744 | 33 | }; |
34 | ||
35 | /* BGP advertise attribute. */ | |
d62a17ae | 36 | struct bgp_advertise_attr { |
37 | /* Head of advertisement pointer. */ | |
38 | struct bgp_advertise *adv; | |
718e3744 | 39 | |
d62a17ae | 40 | /* Reference counter. */ |
41 | unsigned long refcnt; | |
718e3744 | 42 | |
d62a17ae | 43 | /* Attribute pointer to be announced. */ |
44 | struct attr *attr; | |
718e3744 | 45 | }; |
46 | ||
d62a17ae | 47 | struct bgp_advertise { |
48 | /* FIFO for advertisement. */ | |
49 | struct bgp_advertise_fifo fifo; | |
718e3744 | 50 | |
d62a17ae | 51 | /* Link list for same attribute advertise. */ |
52 | struct bgp_advertise *next; | |
53 | struct bgp_advertise *prev; | |
718e3744 | 54 | |
d62a17ae | 55 | /* Prefix information. */ |
56 | struct bgp_node *rn; | |
718e3744 | 57 | |
d62a17ae | 58 | /* Reference pointer. */ |
59 | struct bgp_adj_out *adj; | |
718e3744 | 60 | |
d62a17ae | 61 | /* Advertisement attribute. */ |
62 | struct bgp_advertise_attr *baa; | |
718e3744 | 63 | |
d62a17ae | 64 | /* BGP info. */ |
9b6d8fcf | 65 | struct bgp_path_info *pathi; |
718e3744 | 66 | }; |
67 | ||
68 | /* BGP adjacency out. */ | |
d62a17ae | 69 | struct bgp_adj_out { |
a79c04e7 DS |
70 | /* RB Tree of adjacency entries */ |
71 | RB_ENTRY(bgp_adj_out) adj_entry; | |
718e3744 | 72 | |
d62a17ae | 73 | /* Advertised subgroup. */ |
74 | struct update_subgroup *subgroup; | |
3f9c7369 | 75 | |
d62a17ae | 76 | /* Threading that makes the adj part of subgroup's adj queue */ |
77 | TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train; | |
3f9c7369 | 78 | |
d62a17ae | 79 | /* Prefix information. */ |
80 | struct bgp_node *rn; | |
718e3744 | 81 | |
d7c0a89a | 82 | uint32_t addpath_tx_id; |
adbac85e | 83 | |
d62a17ae | 84 | /* Advertised attribute. */ |
85 | struct attr *attr; | |
718e3744 | 86 | |
d62a17ae | 87 | /* Advertisement information. */ |
88 | struct bgp_advertise *adv; | |
718e3744 | 89 | }; |
90 | ||
a79c04e7 DS |
91 | RB_HEAD(bgp_adj_out_rb, bgp_adj_out); |
92 | RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry, | |
93 | bgp_adj_out_compare); | |
94 | ||
718e3744 | 95 | /* BGP adjacency in. */ |
d62a17ae | 96 | struct bgp_adj_in { |
97 | /* Linked list pointer. */ | |
98 | struct bgp_adj_in *next; | |
99 | struct bgp_adj_in *prev; | |
718e3744 | 100 | |
d62a17ae | 101 | /* Received peer. */ |
102 | struct peer *peer; | |
718e3744 | 103 | |
d62a17ae | 104 | /* Received attribute. */ |
105 | struct attr *attr; | |
43143c8f | 106 | |
d62a17ae | 107 | /* Addpath identifier */ |
d7c0a89a | 108 | uint32_t addpath_rx_id; |
718e3744 | 109 | }; |
110 | ||
111 | /* BGP advertisement list. */ | |
d62a17ae | 112 | struct bgp_synchronize { |
113 | struct bgp_advertise_fifo update; | |
114 | struct bgp_advertise_fifo withdraw; | |
115 | struct bgp_advertise_fifo withdraw_low; | |
718e3744 | 116 | }; |
117 | ||
718e3744 | 118 | /* BGP adjacency linked list. */ |
1defdda8 | 119 | #define BGP_PATH_INFO_ADD(N, A, TYPE) \ |
d62a17ae | 120 | do { \ |
121 | (A)->prev = NULL; \ | |
122 | (A)->next = (N)->TYPE; \ | |
123 | if ((N)->TYPE) \ | |
124 | (N)->TYPE->prev = (A); \ | |
125 | (N)->TYPE = (A); \ | |
126 | } while (0) | |
127 | ||
1defdda8 | 128 | #define BGP_PATH_INFO_DEL(N, A, TYPE) \ |
d62a17ae | 129 | do { \ |
130 | if ((A)->next) \ | |
131 | (A)->next->prev = (A)->prev; \ | |
132 | if ((A)->prev) \ | |
133 | (A)->prev->next = (A)->next; \ | |
134 | else \ | |
135 | (N)->TYPE = (A)->next; \ | |
136 | } while (0) | |
718e3744 | 137 | |
1defdda8 DS |
138 | #define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in) |
139 | #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in) | |
718e3744 | 140 | |
d62a17ae | 141 | #define BGP_ADV_FIFO_ADD(F, N) \ |
142 | do { \ | |
143 | FIFO_ADD((F), (N)); \ | |
144 | (F)->count++; \ | |
145 | } while (0) | |
cdabb8b6 | 146 | |
d62a17ae | 147 | #define BGP_ADV_FIFO_DEL(F, N) \ |
148 | do { \ | |
149 | FIFO_DEL((N)); \ | |
150 | (F)->count--; \ | |
151 | } while (0) | |
cdabb8b6 | 152 | |
d62a17ae | 153 | #define BGP_ADV_FIFO_INIT(F) \ |
154 | do { \ | |
155 | FIFO_INIT((F)); \ | |
156 | (F)->count = 0; \ | |
157 | } while (0) | |
cdabb8b6 | 158 | |
d62a17ae | 159 | #define BGP_ADV_FIFO_COUNT(F) (F)->count |
d889623f | 160 | |
d62a17ae | 161 | #define BGP_ADV_FIFO_EMPTY(F) \ |
162 | (((struct bgp_advertise_fifo *)(F))->next \ | |
163 | == (struct bgp_advertise *)(F)) | |
3f9c7369 | 164 | |
d62a17ae | 165 | #define BGP_ADV_FIFO_HEAD(F) \ |
166 | ((((struct bgp_advertise_fifo *)(F))->next \ | |
167 | == (struct bgp_advertise *)(F)) \ | |
168 | ? NULL \ | |
169 | : (F)->next) | |
3f9c7369 | 170 | |
718e3744 | 171 | /* Prototypes. */ |
d7c0a89a | 172 | extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t); |
d62a17ae | 173 | extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *, |
d7c0a89a QY |
174 | uint32_t); |
175 | extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t); | |
d62a17ae | 176 | extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *); |
177 | ||
178 | extern void bgp_sync_init(struct peer *); | |
179 | extern void bgp_sync_delete(struct peer *); | |
180 | extern unsigned int baa_hash_key(void *p); | |
74df8d6d | 181 | extern bool baa_hash_cmp(const void *p1, const void *p2); |
d62a17ae | 182 | extern void bgp_advertise_add(struct bgp_advertise_attr *baa, |
183 | struct bgp_advertise *adv); | |
184 | extern struct bgp_advertise *bgp_advertise_new(void); | |
185 | extern void bgp_advertise_free(struct bgp_advertise *adv); | |
186 | extern struct bgp_advertise_attr *bgp_advertise_intern(struct hash *hash, | |
187 | struct attr *attr); | |
188 | extern struct bgp_advertise_attr *baa_new(void); | |
189 | extern void bgp_advertise_delete(struct bgp_advertise_attr *baa, | |
190 | struct bgp_advertise *adv); | |
191 | extern void bgp_advertise_unintern(struct hash *hash, | |
192 | struct bgp_advertise_attr *baa); | |
00d252cb | 193 | |
194 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |