]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_advertise.h
BGP: support for addpath TX
[mirror_frr.git] / bgpd / bgp_advertise.h
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
21 #ifndef _QUAGGA_BGP_ADVERTISE_H
22 #define _QUAGGA_BGP_ADVERTISE_H
23
24 struct update_subgroup;
25
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
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. */
50 struct bgp_advertise_fifo fifo;
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 subgroup. */
77 struct update_subgroup *subgroup;
78
79 /* Threading that makes the adj part of subgroup's adj queue */
80 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
81
82 /* Prefix information. */
83 struct bgp_node *rn;
84
85 u_int32_t addpath_tx_id;
86
87 /* Advertised attribute. */
88 struct attr *attr;
89
90 /* Advertisement information. */
91 struct bgp_advertise *adv;
92 };
93
94 /* BGP adjacency in. */
95 struct bgp_adj_in
96 {
97 /* Linked list pointer. */
98 struct bgp_adj_in *next;
99 struct bgp_adj_in *prev;
100
101 /* Received peer. */
102 struct peer *peer;
103
104 /* Received attribute. */
105 struct attr *attr;
106
107 /* Addpath identifier */
108 u_int32_t addpath_rx_id;
109 };
110
111 /* BGP advertisement list. */
112 struct bgp_synchronize
113 {
114 struct bgp_advertise_fifo update;
115 struct bgp_advertise_fifo withdraw;
116 struct bgp_advertise_fifo withdraw_low;
117 };
118
119 /* BGP adjacency linked list. */
120 #define BGP_INFO_ADD(N,A,TYPE) \
121 do { \
122 (A)->prev = NULL; \
123 (A)->next = (N)->TYPE; \
124 if ((N)->TYPE) \
125 (N)->TYPE->prev = (A); \
126 (N)->TYPE = (A); \
127 } while (0)
128
129 #define BGP_INFO_DEL(N,A,TYPE) \
130 do { \
131 if ((A)->next) \
132 (A)->next->prev = (A)->prev; \
133 if ((A)->prev) \
134 (A)->prev->next = (A)->next; \
135 else \
136 (N)->TYPE = (A)->next; \
137 } while (0)
138
139 #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in)
140 #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in)
141 #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
142 #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
143
144 #define BGP_ADV_FIFO_ADD(F, N) \
145 do { \
146 FIFO_ADD((F), (N)); \
147 (F)->count++; \
148 } while (0)
149
150 #define BGP_ADV_FIFO_DEL(F, N) \
151 do { \
152 FIFO_DEL((N)); \
153 (F)->count--; \
154 } while (0)
155
156 #define BGP_ADV_FIFO_INIT(F) \
157 do { \
158 FIFO_INIT((F)); \
159 (F)->count = 0; \
160 } while (0)
161
162 #define BGP_ADV_FIFO_COUNT(F) \
163 (F)->count
164
165 #define BGP_ADV_FIFO_EMPTY(F) \
166 (((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F))
167
168 #define BGP_ADV_FIFO_HEAD(F) \
169 ((((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F)) \
170 ? NULL : (F)->next)
171
172 /* Prototypes. */
173 extern int bgp_adj_out_lookup (struct peer *, struct bgp_node *, u_int32_t);
174 extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *, u_int32_t);
175 extern void bgp_adj_in_unset (struct bgp_node *, struct peer *, u_int32_t);
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);
181 extern int baa_hash_cmp (const void *p1, const void *p2);
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 *
187 bgp_advertise_intern (struct hash *hash, struct attr *attr);
188 extern struct bgp_advertise_attr *baa_new (void);
189 extern void
190 bgp_advertise_delete (struct bgp_advertise_attr *baa,
191 struct bgp_advertise *adv);
192 extern void
193 bgp_advertise_unintern (struct hash *hash, struct bgp_advertise_attr *baa);
194
195 #endif /* _QUAGGA_BGP_ADVERTISE_H */