1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP advertisement and adjacency
3 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
6 #ifndef _QUAGGA_BGP_ADVERTISE_H
7 #define _QUAGGA_BGP_ADVERTISE_H
9 #include "lib/typesafe.h"
11 PREDECL_DLIST(bgp_adv_fifo
);
13 struct update_subgroup
;
15 /* BGP advertise attribute. */
16 struct bgp_advertise_attr
{
17 /* Head of advertisement pointer. */
18 struct bgp_advertise
*adv
;
20 /* Reference counter. */
23 /* Attribute pointer to be announced. */
27 struct bgp_advertise
{
28 /* FIFO for advertisement. */
29 struct bgp_adv_fifo_item fifo
;
31 /* Link list for same attribute advertise. */
32 struct bgp_advertise
*next
;
33 struct bgp_advertise
*prev
;
35 /* Prefix information. */
36 struct bgp_dest
*dest
;
38 /* Reference pointer. */
39 struct bgp_adj_out
*adj
;
41 /* Advertisement attribute. */
42 struct bgp_advertise_attr
*baa
;
45 struct bgp_path_info
*pathi
;
48 DECLARE_DLIST(bgp_adv_fifo
, struct bgp_advertise
, fifo
);
50 /* BGP adjacency out. */
52 /* RB Tree of adjacency entries */
53 RB_ENTRY(bgp_adj_out
) adj_entry
;
55 /* Advertised subgroup. */
56 struct update_subgroup
*subgroup
;
58 /* Threading that makes the adj part of subgroup's adj queue */
59 TAILQ_ENTRY(bgp_adj_out
) subgrp_adj_train
;
61 /* Prefix information. */
62 struct bgp_dest
*dest
;
64 uint32_t addpath_tx_id
;
66 /* Advertised attribute. */
69 /* Advertisement information. */
70 struct bgp_advertise
*adv
;
76 RB_HEAD(bgp_adj_out_rb
, bgp_adj_out
);
77 RB_PROTOTYPE(bgp_adj_out_rb
, bgp_adj_out
, adj_entry
,
80 /* BGP adjacency in. */
82 /* Linked list pointer. */
83 struct bgp_adj_in
*next
;
84 struct bgp_adj_in
*prev
;
89 /* Received attribute. */
92 /* timestamp (monotime) */
95 /* Addpath identifier */
96 uint32_t addpath_rx_id
;
99 /* BGP advertisement list. */
100 struct bgp_synchronize
{
101 struct bgp_adv_fifo_head update
;
102 struct bgp_adv_fifo_head withdraw
;
103 struct bgp_adv_fifo_head withdraw_low
;
106 /* BGP adjacency linked list. */
107 #define BGP_PATH_INFO_ADD(N, A, TYPE) \
110 (A)->next = (N)->TYPE; \
112 (N)->TYPE->prev = (A); \
116 #define BGP_PATH_INFO_DEL(N, A, TYPE) \
119 (A)->next->prev = (A)->prev; \
121 (A)->prev->next = (A)->next; \
123 (N)->TYPE = (A)->next; \
126 #define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
127 #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
130 extern bool bgp_adj_out_lookup(struct peer
*peer
, struct bgp_dest
*dest
,
131 uint32_t addpath_tx_id
);
132 extern void bgp_adj_in_set(struct bgp_dest
*dest
, struct peer
*peer
,
133 struct attr
*attr
, uint32_t addpath_id
);
134 extern bool bgp_adj_in_unset(struct bgp_dest
*dest
, struct peer
*peer
,
135 uint32_t addpath_id
);
136 extern void bgp_adj_in_remove(struct bgp_dest
*dest
, struct bgp_adj_in
*bai
);
138 extern void bgp_sync_init(struct peer
*peer
);
139 extern void bgp_sync_delete(struct peer
*peer
);
140 extern unsigned int bgp_advertise_attr_hash_key(const void *p
);
141 extern bool bgp_advertise_attr_hash_cmp(const void *p1
, const void *p2
);
142 extern void bgp_advertise_add(struct bgp_advertise_attr
*baa
,
143 struct bgp_advertise
*adv
);
144 extern struct bgp_advertise
*bgp_advertise_new(void);
145 extern void bgp_advertise_free(struct bgp_advertise
*adv
);
146 extern struct bgp_advertise_attr
*bgp_advertise_attr_intern(struct hash
*hash
,
148 extern struct bgp_advertise_attr
*bgp_advertise_attr_new(void);
149 extern void bgp_advertise_delete(struct bgp_advertise_attr
*baa
,
150 struct bgp_advertise
*adv
);
151 extern void bgp_advertise_attr_unintern(struct hash
*hash
,
152 struct bgp_advertise_attr
*baa
);
153 extern void bgp_advertise_attr_free(struct bgp_advertise_attr
*baa
);
155 #endif /* _QUAGGA_BGP_ADVERTISE_H */