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
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
21 #ifndef _QUAGGA_BGP_ADVERTISE_H
22 #define _QUAGGA_BGP_ADVERTISE_H
24 struct update_subgroup
;
26 /* BGP advertise FIFO. */
27 struct bgp_advertise_fifo
29 struct bgp_advertise
*next
;
30 struct bgp_advertise
*prev
;
34 /* BGP advertise attribute. */
35 struct bgp_advertise_attr
37 /* Head of advertisement pointer. */
38 struct bgp_advertise
*adv
;
40 /* Reference counter. */
43 /* Attribute pointer to be announced. */
49 /* FIFO for advertisement. */
50 struct bgp_advertise_fifo fifo
;
52 /* Link list for same attribute advertise. */
53 struct bgp_advertise
*next
;
54 struct bgp_advertise
*prev
;
56 /* Prefix information. */
59 /* Reference pointer. */
60 struct bgp_adj_out
*adj
;
62 /* Advertisement attribute. */
63 struct bgp_advertise_attr
*baa
;
66 struct bgp_info
*binfo
;
69 /* BGP adjacency out. */
72 /* Lined list pointer. */
73 struct bgp_adj_out
*next
;
74 struct bgp_adj_out
*prev
;
76 /* Advertised subgroup. */
77 struct update_subgroup
*subgroup
;
79 /* Threading that makes the adj part of subgroup's adj queue */
80 TAILQ_ENTRY(bgp_adj_out
) subgrp_adj_train
;
82 /* Prefix information. */
85 /* Advertised attribute. */
88 /* Advertisement information. */
89 struct bgp_advertise
*adv
;
92 /* BGP adjacency in. */
95 /* Linked list pointer. */
96 struct bgp_adj_in
*next
;
97 struct bgp_adj_in
*prev
;
102 /* Received attribute. */
106 /* BGP advertisement list. */
107 struct bgp_synchronize
109 struct bgp_advertise_fifo update
;
110 struct bgp_advertise_fifo withdraw
;
111 struct bgp_advertise_fifo withdraw_low
;
114 /* BGP adjacency linked list. */
115 #define BGP_INFO_ADD(N,A,TYPE) \
118 (A)->next = (N)->TYPE; \
120 (N)->TYPE->prev = (A); \
124 #define BGP_INFO_DEL(N,A,TYPE) \
127 (A)->next->prev = (A)->prev; \
129 (A)->prev->next = (A)->next; \
131 (N)->TYPE = (A)->next; \
134 #define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in)
135 #define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in)
136 #define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
137 #define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
139 #define BGP_ADV_FIFO_ADD(F, N) \
141 FIFO_ADD((F), (N)); \
145 #define BGP_ADV_FIFO_DEL(F, N) \
151 #define BGP_ADV_FIFO_INIT(F) \
157 #define BGP_ADV_FIFO_COUNT(F) \
160 #define BGP_ADV_FIFO_EMPTY(F) \
161 (((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F))
163 #define BGP_ADV_FIFO_HEAD(F) \
164 ((((struct bgp_advertise_fifo *)(F))->next == (struct bgp_advertise *)(F)) \
168 extern int bgp_adj_out_lookup (struct peer
*, struct prefix
*, afi_t
, safi_t
,
171 extern void bgp_adj_in_set (struct bgp_node
*, struct peer
*, struct attr
*);
172 extern void bgp_adj_in_unset (struct bgp_node
*, struct peer
*);
173 extern void bgp_adj_in_remove (struct bgp_node
*, struct bgp_adj_in
*);
175 extern void bgp_sync_init (struct peer
*);
176 extern void bgp_sync_delete (struct peer
*);
177 extern unsigned int baa_hash_key (void *p
);
178 extern int baa_hash_cmp (const void *p1
, const void *p2
);
179 extern void bgp_advertise_add (struct bgp_advertise_attr
*baa
,
180 struct bgp_advertise
*adv
);
181 extern struct bgp_advertise
*bgp_advertise_new (void);
182 extern void bgp_advertise_free (struct bgp_advertise
*adv
);
183 extern struct bgp_advertise_attr
*
184 bgp_advertise_intern (struct hash
*hash
, struct attr
*attr
);
185 extern struct bgp_advertise_attr
*baa_new (void);
187 bgp_advertise_delete (struct bgp_advertise_attr
*baa
,
188 struct bgp_advertise
*adv
);
190 bgp_advertise_unintern (struct hash
*hash
, struct bgp_advertise_attr
*baa
);
191 extern struct bgp_adj_out
*
192 bgp_adj_peer_lookup (struct peer
*peer
, struct bgp_node
*rn
);
194 #endif /* _QUAGGA_BGP_ADVERTISE_H */