blob: 51ba62679e627dd93b2a5fe89a7de3a6e46357fb [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* 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
paul00d252c2005-05-23 14:19:54 +000021#ifndef _QUAGGA_BGP_ADVERTISE_H
22#define _QUAGGA_BGP_ADVERTISE_H
23
Donald Sharpb0d02882016-01-08 07:37:14 -050024#include <lib/fifo.h>
25
paul718e3742002-12-13 20:15:29 +000026/* BGP advertise attribute. */
27struct bgp_advertise_attr
28{
29 /* Head of advertisement pointer. */
30 struct bgp_advertise *adv;
31
32 /* Reference counter. */
33 unsigned long refcnt;
34
35 /* Attribute pointer to be announced. */
36 struct attr *attr;
37};
38
39struct bgp_advertise
40{
41 /* FIFO for advertisement. */
Paul Jakma7aa9dce2014-09-19 14:42:23 +010042 struct fifo fifo;
paul718e3742002-12-13 20:15:29 +000043
44 /* Link list for same attribute advertise. */
45 struct bgp_advertise *next;
46 struct bgp_advertise *prev;
47
48 /* Prefix information. */
49 struct bgp_node *rn;
50
51 /* Reference pointer. */
52 struct bgp_adj_out *adj;
53
54 /* Advertisement attribute. */
55 struct bgp_advertise_attr *baa;
56
57 /* BGP info. */
58 struct bgp_info *binfo;
59};
60
61/* BGP adjacency out. */
62struct bgp_adj_out
63{
64 /* Lined list pointer. */
65 struct bgp_adj_out *next;
66 struct bgp_adj_out *prev;
67
68 /* Advertised peer. */
69 struct peer *peer;
70
71 /* Advertised attribute. */
72 struct attr *attr;
73
74 /* Advertisement information. */
75 struct bgp_advertise *adv;
76};
77
78/* BGP adjacency in. */
79struct bgp_adj_in
80{
81 /* Linked list pointer. */
82 struct bgp_adj_in *next;
83 struct bgp_adj_in *prev;
84
85 /* Received peer. */
86 struct peer *peer;
87
88 /* Received attribute. */
89 struct attr *attr;
90};
91
92/* BGP advertisement list. */
93struct bgp_synchronize
94{
Paul Jakma7aa9dce2014-09-19 14:42:23 +010095 struct fifo update;
96 struct fifo withdraw;
97 struct fifo withdraw_low;
paul718e3742002-12-13 20:15:29 +000098};
99
Paul Jakma7aa9dce2014-09-19 14:42:23 +0100100#define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F))
101
paul718e3742002-12-13 20:15:29 +0000102/* BGP adjacency linked list. */
103#define BGP_INFO_ADD(N,A,TYPE) \
104 do { \
105 (A)->prev = NULL; \
106 (A)->next = (N)->TYPE; \
107 if ((N)->TYPE) \
108 (N)->TYPE->prev = (A); \
109 (N)->TYPE = (A); \
110 } while (0)
111
112#define BGP_INFO_DEL(N,A,TYPE) \
113 do { \
114 if ((A)->next) \
115 (A)->next->prev = (A)->prev; \
116 if ((A)->prev) \
117 (A)->prev->next = (A)->next; \
118 else \
119 (N)->TYPE = (A)->next; \
120 } while (0)
121
122#define BGP_ADJ_IN_ADD(N,A) BGP_INFO_ADD(N,A,adj_in)
123#define BGP_ADJ_IN_DEL(N,A) BGP_INFO_DEL(N,A,adj_in)
124#define BGP_ADJ_OUT_ADD(N,A) BGP_INFO_ADD(N,A,adj_out)
125#define BGP_ADJ_OUT_DEL(N,A) BGP_INFO_DEL(N,A,adj_out)
126
127/* Prototypes. */
paul94f2b392005-06-28 12:44:16 +0000128extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *,
paul718e3742002-12-13 20:15:29 +0000129 struct attr *, afi_t, safi_t, struct bgp_info *);
paul94f2b392005-06-28 12:44:16 +0000130extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *,
paul718e3742002-12-13 20:15:29 +0000131 afi_t, safi_t);
paul94f2b392005-06-28 12:44:16 +0000132extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *,
paul718e3742002-12-13 20:15:29 +0000133 struct peer *, afi_t, safi_t);
paul94f2b392005-06-28 12:44:16 +0000134extern int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t,
paul718e3742002-12-13 20:15:29 +0000135 struct bgp_node *);
136
paul94f2b392005-06-28 12:44:16 +0000137extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *);
David Lamparter4584c232015-04-13 09:50:00 +0200138extern int bgp_adj_in_unset (struct bgp_node *, struct peer *);
paul94f2b392005-06-28 12:44:16 +0000139extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *);
paul718e3742002-12-13 20:15:29 +0000140
paul94f2b392005-06-28 12:44:16 +0000141extern struct bgp_advertise *
paul718e3742002-12-13 20:15:29 +0000142bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t);
143
paul94f2b392005-06-28 12:44:16 +0000144extern void bgp_sync_init (struct peer *);
145extern void bgp_sync_delete (struct peer *);
paul00d252c2005-05-23 14:19:54 +0000146
147#endif /* _QUAGGA_BGP_ADVERTISE_H */