]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_advertise.h
*: auto-convert to SPDX License IDs
[mirror_frr.git] / bgpd / bgp_advertise.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP advertisement and adjacency
3 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 */
5
6 #ifndef _QUAGGA_BGP_ADVERTISE_H
7 #define _QUAGGA_BGP_ADVERTISE_H
8
9 #include "lib/typesafe.h"
10
11 PREDECL_DLIST(bgp_adv_fifo);
12
13 struct update_subgroup;
14
15 /* BGP advertise attribute. */
16 struct bgp_advertise_attr {
17 /* Head of advertisement pointer. */
18 struct bgp_advertise *adv;
19
20 /* Reference counter. */
21 unsigned long refcnt;
22
23 /* Attribute pointer to be announced. */
24 struct attr *attr;
25 };
26
27 struct bgp_advertise {
28 /* FIFO for advertisement. */
29 struct bgp_adv_fifo_item fifo;
30
31 /* Link list for same attribute advertise. */
32 struct bgp_advertise *next;
33 struct bgp_advertise *prev;
34
35 /* Prefix information. */
36 struct bgp_dest *dest;
37
38 /* Reference pointer. */
39 struct bgp_adj_out *adj;
40
41 /* Advertisement attribute. */
42 struct bgp_advertise_attr *baa;
43
44 /* BGP info. */
45 struct bgp_path_info *pathi;
46 };
47
48 DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo);
49
50 /* BGP adjacency out. */
51 struct bgp_adj_out {
52 /* RB Tree of adjacency entries */
53 RB_ENTRY(bgp_adj_out) adj_entry;
54
55 /* Advertised subgroup. */
56 struct update_subgroup *subgroup;
57
58 /* Threading that makes the adj part of subgroup's adj queue */
59 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
60
61 /* Prefix information. */
62 struct bgp_dest *dest;
63
64 uint32_t addpath_tx_id;
65
66 /* Advertised attribute. */
67 struct attr *attr;
68
69 /* Advertisement information. */
70 struct bgp_advertise *adv;
71
72 /* Attribute hash */
73 uint32_t attr_hash;
74 };
75
76 RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
77 RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
78 bgp_adj_out_compare);
79
80 /* BGP adjacency in. */
81 struct bgp_adj_in {
82 /* Linked list pointer. */
83 struct bgp_adj_in *next;
84 struct bgp_adj_in *prev;
85
86 /* Received peer. */
87 struct peer *peer;
88
89 /* Received attribute. */
90 struct attr *attr;
91
92 /* timestamp (monotime) */
93 time_t uptime;
94
95 /* Addpath identifier */
96 uint32_t addpath_rx_id;
97 };
98
99 /* BGP advertisement list. */
100 struct bgp_synchronize {
101 struct bgp_adv_fifo_head update;
102 struct bgp_adv_fifo_head withdraw;
103 struct bgp_adv_fifo_head withdraw_low;
104 };
105
106 /* BGP adjacency linked list. */
107 #define BGP_PATH_INFO_ADD(N, A, TYPE) \
108 do { \
109 (A)->prev = NULL; \
110 (A)->next = (N)->TYPE; \
111 if ((N)->TYPE) \
112 (N)->TYPE->prev = (A); \
113 (N)->TYPE = (A); \
114 } while (0)
115
116 #define BGP_PATH_INFO_DEL(N, A, TYPE) \
117 do { \
118 if ((A)->next) \
119 (A)->next->prev = (A)->prev; \
120 if ((A)->prev) \
121 (A)->prev->next = (A)->next; \
122 else \
123 (N)->TYPE = (A)->next; \
124 } while (0)
125
126 #define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
127 #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
128
129 /* Prototypes. */
130 extern bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
131 uint32_t addpath_tx_id);
132 extern void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer,
133 struct attr *attr, uint32_t addpath_id);
134 extern bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer,
135 uint32_t addpath_id);
136 extern void bgp_adj_in_remove(struct bgp_dest *dest, struct bgp_adj_in *bai);
137
138 extern void bgp_sync_init(struct peer *peer);
139 extern void bgp_sync_delete(struct peer *peer);
140 extern unsigned int bgp_advertise_attr_hash_key(const void *p);
141 extern bool bgp_advertise_attr_hash_cmp(const void *p1, const void *p2);
142 extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
143 struct bgp_advertise *adv);
144 extern struct bgp_advertise *bgp_advertise_new(void);
145 extern void bgp_advertise_free(struct bgp_advertise *adv);
146 extern struct bgp_advertise_attr *bgp_advertise_attr_intern(struct hash *hash,
147 struct attr *attr);
148 extern struct bgp_advertise_attr *bgp_advertise_attr_new(void);
149 extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
150 struct bgp_advertise *adv);
151 extern void bgp_advertise_attr_unintern(struct hash *hash,
152 struct bgp_advertise_attr *baa);
153 extern void bgp_advertise_attr_free(struct bgp_advertise_attr *baa);
154
155 #endif /* _QUAGGA_BGP_ADVERTISE_H */