]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_advertise.h
Merge pull request #3045 from opensourcerouting/atoms
[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 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 */
20
21 #ifndef _QUAGGA_BGP_ADVERTISE_H
22 #define _QUAGGA_BGP_ADVERTISE_H
23
24 #include "lib/typesafe.h"
25
26 PREDECL_LIST(bgp_adv_fifo)
27
28 struct update_subgroup;
29
30 /* BGP advertise attribute. */
31 struct bgp_advertise_attr {
32 /* Head of advertisement pointer. */
33 struct bgp_advertise *adv;
34
35 /* Reference counter. */
36 unsigned long refcnt;
37
38 /* Attribute pointer to be announced. */
39 struct attr *attr;
40 };
41
42 struct bgp_advertise {
43 /* FIFO for advertisement. */
44 struct bgp_adv_fifo_item fifo;
45
46 /* Link list for same attribute advertise. */
47 struct bgp_advertise *next;
48 struct bgp_advertise *prev;
49
50 /* Prefix information. */
51 struct bgp_node *rn;
52
53 /* Reference pointer. */
54 struct bgp_adj_out *adj;
55
56 /* Advertisement attribute. */
57 struct bgp_advertise_attr *baa;
58
59 /* BGP info. */
60 struct bgp_path_info *pathi;
61 };
62
63 DECLARE_LIST(bgp_adv_fifo, struct bgp_advertise, fifo)
64
65 /* BGP adjacency out. */
66 struct bgp_adj_out {
67 /* RB Tree of adjacency entries */
68 RB_ENTRY(bgp_adj_out) adj_entry;
69
70 /* Advertised subgroup. */
71 struct update_subgroup *subgroup;
72
73 /* Threading that makes the adj part of subgroup's adj queue */
74 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
75
76 /* Prefix information. */
77 struct bgp_node *rn;
78
79 uint32_t addpath_tx_id;
80
81 /* Advertised attribute. */
82 struct attr *attr;
83
84 /* Advertisement information. */
85 struct bgp_advertise *adv;
86 };
87
88 RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
89 RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
90 bgp_adj_out_compare);
91
92 /* BGP adjacency in. */
93 struct bgp_adj_in {
94 /* Linked list pointer. */
95 struct bgp_adj_in *next;
96 struct bgp_adj_in *prev;
97
98 /* Received peer. */
99 struct peer *peer;
100
101 /* Received attribute. */
102 struct attr *attr;
103
104 /* Addpath identifier */
105 uint32_t addpath_rx_id;
106 };
107
108 /* BGP advertisement list. */
109 struct bgp_synchronize {
110 struct bgp_adv_fifo_head update;
111 struct bgp_adv_fifo_head withdraw;
112 struct bgp_adv_fifo_head withdraw_low;
113 };
114
115 /* BGP adjacency linked list. */
116 #define BGP_PATH_INFO_ADD(N, A, TYPE) \
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
125 #define BGP_PATH_INFO_DEL(N, A, TYPE) \
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)
134
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
138 /* Prototypes. */
139 extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
140 extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
141 uint32_t);
142 extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
143 extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
144
145 extern void bgp_sync_init(struct peer *);
146 extern void bgp_sync_delete(struct peer *);
147 extern unsigned int baa_hash_key(void *p);
148 extern bool baa_hash_cmp(const void *p1, const void *p2);
149 extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
150 struct bgp_advertise *adv);
151 extern struct bgp_advertise *bgp_advertise_new(void);
152 extern void bgp_advertise_free(struct bgp_advertise *adv);
153 extern struct bgp_advertise_attr *bgp_advertise_intern(struct hash *hash,
154 struct attr *attr);
155 extern struct bgp_advertise_attr *baa_new(void);
156 extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
157 struct bgp_advertise *adv);
158 extern void bgp_advertise_unintern(struct hash *hash,
159 struct bgp_advertise_attr *baa);
160
161 #endif /* _QUAGGA_BGP_ADVERTISE_H */