1 /* BGP advertisement and adjacency
2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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
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.
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
21 #ifndef _QUAGGA_BGP_ADVERTISE_H
22 #define _QUAGGA_BGP_ADVERTISE_H
24 #include "lib/typesafe.h"
26 PREDECL_DLIST(bgp_adv_fifo
);
28 struct update_subgroup
;
30 /* BGP advertise attribute. */
31 struct bgp_advertise_attr
{
32 /* Head of advertisement pointer. */
33 struct bgp_advertise
*adv
;
35 /* Reference counter. */
38 /* Attribute pointer to be announced. */
42 struct bgp_advertise
{
43 /* FIFO for advertisement. */
44 struct bgp_adv_fifo_item fifo
;
46 /* Link list for same attribute advertise. */
47 struct bgp_advertise
*next
;
48 struct bgp_advertise
*prev
;
50 /* Prefix information. */
51 struct bgp_dest
*dest
;
53 /* Reference pointer. */
54 struct bgp_adj_out
*adj
;
56 /* Advertisement attribute. */
57 struct bgp_advertise_attr
*baa
;
60 struct bgp_path_info
*pathi
;
63 DECLARE_DLIST(bgp_adv_fifo
, struct bgp_advertise
, fifo
);
65 /* BGP adjacency out. */
67 /* RB Tree of adjacency entries */
68 RB_ENTRY(bgp_adj_out
) adj_entry
;
70 /* Advertised subgroup. */
71 struct update_subgroup
*subgroup
;
73 /* Threading that makes the adj part of subgroup's adj queue */
74 TAILQ_ENTRY(bgp_adj_out
) subgrp_adj_train
;
76 /* Prefix information. */
77 struct bgp_dest
*dest
;
79 uint32_t addpath_tx_id
;
81 /* Advertised attribute. */
84 /* Advertisement information. */
85 struct bgp_advertise
*adv
;
91 RB_HEAD(bgp_adj_out_rb
, bgp_adj_out
);
92 RB_PROTOTYPE(bgp_adj_out_rb
, bgp_adj_out
, adj_entry
,
95 /* BGP adjacency in. */
97 /* Linked list pointer. */
98 struct bgp_adj_in
*next
;
99 struct bgp_adj_in
*prev
;
104 /* Received attribute. */
107 /* timestamp (monotime) */
110 /* Addpath identifier */
111 uint32_t addpath_rx_id
;
114 /* BGP advertisement list. */
115 struct bgp_synchronize
{
116 struct bgp_adv_fifo_head update
;
117 struct bgp_adv_fifo_head withdraw
;
118 struct bgp_adv_fifo_head withdraw_low
;
121 /* BGP adjacency linked list. */
122 #define BGP_PATH_INFO_ADD(N, A, TYPE) \
125 (A)->next = (N)->TYPE; \
127 (N)->TYPE->prev = (A); \
131 #define BGP_PATH_INFO_DEL(N, A, TYPE) \
134 (A)->next->prev = (A)->prev; \
136 (A)->prev->next = (A)->next; \
138 (N)->TYPE = (A)->next; \
141 #define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
142 #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
145 extern bool bgp_adj_out_lookup(struct peer
*peer
, struct bgp_dest
*dest
,
146 uint32_t addpath_tx_id
);
147 extern void bgp_adj_in_set(struct bgp_dest
*dest
, struct peer
*peer
,
148 struct attr
*attr
, uint32_t addpath_id
);
149 extern bool bgp_adj_in_unset(struct bgp_dest
*dest
, struct peer
*peer
,
150 uint32_t addpath_id
);
151 extern void bgp_adj_in_remove(struct bgp_dest
*dest
, struct bgp_adj_in
*bai
);
153 extern void bgp_sync_init(struct peer
*peer
);
154 extern void bgp_sync_delete(struct peer
*peer
);
155 extern unsigned int bgp_advertise_attr_hash_key(const void *p
);
156 extern bool bgp_advertise_attr_hash_cmp(const void *p1
, const void *p2
);
157 extern void bgp_advertise_add(struct bgp_advertise_attr
*baa
,
158 struct bgp_advertise
*adv
);
159 extern struct bgp_advertise
*bgp_advertise_new(void);
160 extern void bgp_advertise_free(struct bgp_advertise
*adv
);
161 extern struct bgp_advertise_attr
*bgp_advertise_attr_intern(struct hash
*hash
,
163 extern struct bgp_advertise_attr
*bgp_advertise_attr_new(void);
164 extern void bgp_advertise_delete(struct bgp_advertise_attr
*baa
,
165 struct bgp_advertise
*adv
);
166 extern void bgp_advertise_attr_unintern(struct hash
*hash
,
167 struct bgp_advertise_attr
*baa
);
168 extern void bgp_advertise_attr_free(struct bgp_advertise_attr
*baa
);
170 #endif /* _QUAGGA_BGP_ADVERTISE_H */