]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_advertise.h
Merge pull request #3370 from pguibert6WIND/default_vrf_initialization
[mirror_frr.git] / bgpd / bgp_advertise.h
CommitLineData
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
26struct update_subgroup;
27
718e3744 28/* BGP advertise FIFO. */
d62a17ae 29struct 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 36struct 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 47struct 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 69struct bgp_adj_out {
70 /* Lined list pointer. */
71 struct bgp_adj_out *next;
72 struct bgp_adj_out *prev;
718e3744 73
d62a17ae 74 /* Advertised subgroup. */
75 struct update_subgroup *subgroup;
3f9c7369 76
d62a17ae 77 /* Threading that makes the adj part of subgroup's adj queue */
78 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
3f9c7369 79
d62a17ae 80 /* Prefix information. */
81 struct bgp_node *rn;
718e3744 82
d7c0a89a 83 uint32_t addpath_tx_id;
adbac85e 84
d62a17ae 85 /* Advertised attribute. */
86 struct attr *attr;
718e3744 87
d62a17ae 88 /* Advertisement information. */
89 struct bgp_advertise *adv;
718e3744 90};
91
92/* BGP adjacency in. */
d62a17ae 93struct bgp_adj_in {
94 /* Linked list pointer. */
95 struct bgp_adj_in *next;
96 struct bgp_adj_in *prev;
718e3744 97
d62a17ae 98 /* Received peer. */
99 struct peer *peer;
718e3744 100
d62a17ae 101 /* Received attribute. */
102 struct attr *attr;
43143c8f 103
d62a17ae 104 /* Addpath identifier */
d7c0a89a 105 uint32_t addpath_rx_id;
718e3744 106};
107
108/* BGP advertisement list. */
d62a17ae 109struct bgp_synchronize {
110 struct bgp_advertise_fifo update;
111 struct bgp_advertise_fifo withdraw;
112 struct bgp_advertise_fifo withdraw_low;
718e3744 113};
114
718e3744 115/* BGP adjacency linked list. */
1defdda8 116#define BGP_PATH_INFO_ADD(N, A, TYPE) \
d62a17ae 117 do { \
118 (A)->prev = NULL; \
119 (A)->next = (N)->TYPE; \
120 if ((N)->TYPE) \
121 (N)->TYPE->prev = (A); \
122 (N)->TYPE = (A); \
123 } while (0)
124
1defdda8 125#define BGP_PATH_INFO_DEL(N, A, TYPE) \
d62a17ae 126 do { \
127 if ((A)->next) \
128 (A)->next->prev = (A)->prev; \
129 if ((A)->prev) \
130 (A)->prev->next = (A)->next; \
131 else \
132 (N)->TYPE = (A)->next; \
133 } while (0)
718e3744 134
1defdda8
DS
135#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
136#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
137#define BGP_ADJ_OUT_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_out)
138#define BGP_ADJ_OUT_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_out)
718e3744 139
d62a17ae 140#define BGP_ADV_FIFO_ADD(F, N) \
141 do { \
142 FIFO_ADD((F), (N)); \
143 (F)->count++; \
144 } while (0)
cdabb8b6 145
d62a17ae 146#define BGP_ADV_FIFO_DEL(F, N) \
147 do { \
148 FIFO_DEL((N)); \
149 (F)->count--; \
150 } while (0)
cdabb8b6 151
d62a17ae 152#define BGP_ADV_FIFO_INIT(F) \
153 do { \
154 FIFO_INIT((F)); \
155 (F)->count = 0; \
156 } while (0)
cdabb8b6 157
d62a17ae 158#define BGP_ADV_FIFO_COUNT(F) (F)->count
d889623f 159
d62a17ae 160#define BGP_ADV_FIFO_EMPTY(F) \
161 (((struct bgp_advertise_fifo *)(F))->next \
162 == (struct bgp_advertise *)(F))
3f9c7369 163
d62a17ae 164#define BGP_ADV_FIFO_HEAD(F) \
165 ((((struct bgp_advertise_fifo *)(F))->next \
166 == (struct bgp_advertise *)(F)) \
167 ? NULL \
168 : (F)->next)
3f9c7369 169
718e3744 170/* Prototypes. */
d7c0a89a 171extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
d62a17ae 172extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
d7c0a89a
QY
173 uint32_t);
174extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
d62a17ae 175extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
176
177extern void bgp_sync_init(struct peer *);
178extern void bgp_sync_delete(struct peer *);
179extern unsigned int baa_hash_key(void *p);
74df8d6d 180extern bool baa_hash_cmp(const void *p1, const void *p2);
d62a17ae 181extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
182 struct bgp_advertise *adv);
183extern struct bgp_advertise *bgp_advertise_new(void);
184extern void bgp_advertise_free(struct bgp_advertise *adv);
185extern struct bgp_advertise_attr *bgp_advertise_intern(struct hash *hash,
186 struct attr *attr);
187extern struct bgp_advertise_attr *baa_new(void);
188extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
189 struct bgp_advertise *adv);
190extern void bgp_advertise_unintern(struct hash *hash,
191 struct bgp_advertise_attr *baa);
00d252cb 192
193#endif /* _QUAGGA_BGP_ADVERTISE_H */