]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_advertise.h
Initial revision
[mirror_frr.git] / bgpd / bgp_advertise.h
CommitLineData
718e3744 1/* BGP advertisement and adjacency
2 Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21/* BGP advertise FIFO. */
22struct bgp_advertise_fifo
23{
24 struct bgp_advertise *next;
25 struct bgp_advertise *prev;
26};
27
28/* BGP advertise attribute. */
29struct bgp_advertise_attr
30{
31 /* Head of advertisement pointer. */
32 struct bgp_advertise *adv;
33
34 /* Reference counter. */
35 unsigned long refcnt;
36
37 /* Attribute pointer to be announced. */
38 struct attr *attr;
39};
40
41struct bgp_advertise
42{
43 /* FIFO for advertisement. */
44 struct bgp_advertise_fifo 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_info *binfo;
61};
62
63/* BGP adjacency out. */
64struct bgp_adj_out
65{
66 /* Lined list pointer. */
67 struct bgp_adj_out *next;
68 struct bgp_adj_out *prev;
69
70 /* Advertised peer. */
71 struct peer *peer;
72
73 /* Advertised attribute. */
74 struct attr *attr;
75
76 /* Advertisement information. */
77 struct bgp_advertise *adv;
78};
79
80/* BGP adjacency in. */
81struct bgp_adj_in
82{
83 /* Linked list pointer. */
84 struct bgp_adj_in *next;
85 struct bgp_adj_in *prev;
86
87 /* Received peer. */
88 struct peer *peer;
89
90 /* Received attribute. */
91 struct attr *attr;
92};
93
94/* BGP advertisement list. */
95struct bgp_synchronize
96{
97 struct bgp_advertise_fifo update;
98 struct bgp_advertise_fifo withdraw;
99 struct bgp_advertise_fifo withdraw_low;
100};
101
102/* FIFO -- first in first out structure and macros. */
103struct fifo
104{
105 struct fifo *next;
106 struct fifo *prev;
107};
108
109#define FIFO_INIT(F) \
110 do { \
111 struct fifo *Xfifo = (struct fifo *)(F); \
112 Xfifo->next = Xfifo->prev = Xfifo; \
113 } while (0)
114
115#define FIFO_ADD(F,N) \
116 do { \
117 struct fifo *Xfifo = (struct fifo *)(F); \
118 struct fifo *Xnode = (struct fifo *)(N); \
119 Xnode->next = Xfifo; \
120 Xnode->prev = Xfifo->prev; \
121 Xfifo->prev = Xfifo->prev->next = Xnode; \
122 } while (0)
123
124#define FIFO_DEL(N) \
125 do { \
126 struct fifo *Xnode = (struct fifo *)(N); \
127 Xnode->prev->next = Xnode->next; \
128 Xnode->next->prev = Xnode->prev; \
129 } while (0)
130
131#define FIFO_HEAD(F) \
132 ((((struct fifo *)(F))->next == (struct fifo *)(F)) \
133 ? NULL : (F)->next)
134
135/* BGP adjacency linked list. */
136#define BGP_INFO_ADD(N,A,TYPE) \
137 do { \
138 (A)->prev = NULL; \
139 (A)->next = (N)->TYPE; \
140 if ((N)->TYPE) \
141 (N)->TYPE->prev = (A); \
142 (N)->TYPE = (A); \
143 } while (0)
144
145#define BGP_INFO_DEL(N,A,TYPE) \
146 do { \
147 if ((A)->next) \
148 (A)->next->prev = (A)->prev; \
149 if ((A)->prev) \
150 (A)->prev->next = (A)->next; \
151 else \
152 (N)->TYPE = (A)->next; \
153 } while (0)
154
155#define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in)
156#define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in)
157#define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
158#define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
159
160/* Prototypes. */
161void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *,
162 struct attr *, afi_t, safi_t, struct bgp_info *);
163void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *,
164 afi_t, safi_t);
165void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *,
166 struct peer *, afi_t, safi_t);
167int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t,
168 struct bgp_node *);
169
170void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *);
171void bgp_adj_in_unset (struct bgp_node *, struct peer *);
172void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *);
173
174struct bgp_advertise *
175bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t);
176
177void bgp_sync_init (struct peer *);
178void bgp_sync_delete (struct peer *);