]> git.proxmox.com Git - mirror_frr.git/blame_incremental - bgpd/bgp_advertise.h
bgpd isisd lib: fix return on void functions
[mirror_frr.git] / bgpd / bgp_advertise.h
... / ...
CommitLineData
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/fifo.h>
25
26struct update_subgroup;
27
28/* BGP advertise FIFO. */
29struct bgp_advertise_fifo {
30 struct bgp_advertise *next;
31 struct bgp_advertise *prev;
32 uint32_t count;
33};
34
35/* BGP advertise attribute. */
36struct bgp_advertise_attr {
37 /* Head of advertisement pointer. */
38 struct bgp_advertise *adv;
39
40 /* Reference counter. */
41 unsigned long refcnt;
42
43 /* Attribute pointer to be announced. */
44 struct attr *attr;
45};
46
47struct bgp_advertise {
48 /* FIFO for advertisement. */
49 struct bgp_advertise_fifo fifo;
50
51 /* Link list for same attribute advertise. */
52 struct bgp_advertise *next;
53 struct bgp_advertise *prev;
54
55 /* Prefix information. */
56 struct bgp_node *rn;
57
58 /* Reference pointer. */
59 struct bgp_adj_out *adj;
60
61 /* Advertisement attribute. */
62 struct bgp_advertise_attr *baa;
63
64 /* BGP info. */
65 struct bgp_path_info *pathi;
66};
67
68/* BGP adjacency out. */
69struct bgp_adj_out {
70 /* Lined list pointer. */
71 struct bgp_adj_out *next;
72 struct bgp_adj_out *prev;
73
74 /* Advertised subgroup. */
75 struct update_subgroup *subgroup;
76
77 /* Threading that makes the adj part of subgroup's adj queue */
78 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
79
80 /* Prefix information. */
81 struct bgp_node *rn;
82
83 uint32_t addpath_tx_id;
84
85 /* Advertised attribute. */
86 struct attr *attr;
87
88 /* Advertisement information. */
89 struct bgp_advertise *adv;
90};
91
92/* BGP adjacency in. */
93struct 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. */
109struct bgp_synchronize {
110 struct bgp_advertise_fifo update;
111 struct bgp_advertise_fifo withdraw;
112 struct bgp_advertise_fifo 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#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)
139
140#define BGP_ADV_FIFO_ADD(F, N) \
141 do { \
142 FIFO_ADD((F), (N)); \
143 (F)->count++; \
144 } while (0)
145
146#define BGP_ADV_FIFO_DEL(F, N) \
147 do { \
148 FIFO_DEL((N)); \
149 (F)->count--; \
150 } while (0)
151
152#define BGP_ADV_FIFO_INIT(F) \
153 do { \
154 FIFO_INIT((F)); \
155 (F)->count = 0; \
156 } while (0)
157
158#define BGP_ADV_FIFO_COUNT(F) (F)->count
159
160#define BGP_ADV_FIFO_EMPTY(F) \
161 (((struct bgp_advertise_fifo *)(F))->next \
162 == (struct bgp_advertise *)(F))
163
164#define BGP_ADV_FIFO_HEAD(F) \
165 ((((struct bgp_advertise_fifo *)(F))->next \
166 == (struct bgp_advertise *)(F)) \
167 ? NULL \
168 : (F)->next)
169
170/* Prototypes. */
171extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
172extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
173 uint32_t);
174extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
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);
180extern bool baa_hash_cmp(const void *p1, const void *p2);
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);
192
193#endif /* _QUAGGA_BGP_ADVERTISE_H */