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