]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_advertise.h
Merge pull request #9194 from idryzhov/pim-bool-false
[mirror_frr.git] / bgpd / bgp_advertise.h
CommitLineData
718e3744 1/* BGP advertisement and adjacency
896014f4
DL
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 */
718e3744 20
00d252cb 21#ifndef _QUAGGA_BGP_ADVERTISE_H
22#define _QUAGGA_BGP_ADVERTISE_H
23
a274fef8 24#include "lib/typesafe.h"
ea863ec6 25
960b9a53 26PREDECL_DLIST(bgp_adv_fifo);
3f9c7369 27
a274fef8 28struct update_subgroup;
718e3744 29
30/* BGP advertise attribute. */
d62a17ae 31struct bgp_advertise_attr {
32 /* Head of advertisement pointer. */
33 struct bgp_advertise *adv;
718e3744 34
d62a17ae 35 /* Reference counter. */
36 unsigned long refcnt;
718e3744 37
d62a17ae 38 /* Attribute pointer to be announced. */
39 struct attr *attr;
718e3744 40};
41
d62a17ae 42struct bgp_advertise {
43 /* FIFO for advertisement. */
a274fef8 44 struct bgp_adv_fifo_item fifo;
718e3744 45
d62a17ae 46 /* Link list for same attribute advertise. */
47 struct bgp_advertise *next;
48 struct bgp_advertise *prev;
718e3744 49
d62a17ae 50 /* Prefix information. */
9bcb3eef 51 struct bgp_dest *dest;
718e3744 52
d62a17ae 53 /* Reference pointer. */
54 struct bgp_adj_out *adj;
718e3744 55
d62a17ae 56 /* Advertisement attribute. */
57 struct bgp_advertise_attr *baa;
718e3744 58
d62a17ae 59 /* BGP info. */
9b6d8fcf 60 struct bgp_path_info *pathi;
718e3744 61};
62
960b9a53 63DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo);
a274fef8 64
718e3744 65/* BGP adjacency out. */
d62a17ae 66struct bgp_adj_out {
a79c04e7
DS
67 /* RB Tree of adjacency entries */
68 RB_ENTRY(bgp_adj_out) adj_entry;
718e3744 69
d62a17ae 70 /* Advertised subgroup. */
71 struct update_subgroup *subgroup;
3f9c7369 72
d62a17ae 73 /* Threading that makes the adj part of subgroup's adj queue */
74 TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
3f9c7369 75
d62a17ae 76 /* Prefix information. */
9bcb3eef 77 struct bgp_dest *dest;
718e3744 78
d7c0a89a 79 uint32_t addpath_tx_id;
adbac85e 80
d62a17ae 81 /* Advertised attribute. */
82 struct attr *attr;
718e3744 83
d62a17ae 84 /* Advertisement information. */
85 struct bgp_advertise *adv;
2adac256
DA
86
87 /* Attribute hash */
88 uint32_t attr_hash;
718e3744 89};
90
a79c04e7
DS
91RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
92RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
93 bgp_adj_out_compare);
94
718e3744 95/* BGP adjacency in. */
d62a17ae 96struct bgp_adj_in {
97 /* Linked list pointer. */
98 struct bgp_adj_in *next;
99 struct bgp_adj_in *prev;
718e3744 100
d62a17ae 101 /* Received peer. */
102 struct peer *peer;
718e3744 103
d62a17ae 104 /* Received attribute. */
105 struct attr *attr;
43143c8f 106
6566d669
DL
107 /* timestamp (monotime) */
108 time_t uptime;
109
d62a17ae 110 /* Addpath identifier */
d7c0a89a 111 uint32_t addpath_rx_id;
718e3744 112};
113
114/* BGP advertisement list. */
d62a17ae 115struct bgp_synchronize {
a274fef8
DL
116 struct bgp_adv_fifo_head update;
117 struct bgp_adv_fifo_head withdraw;
118 struct bgp_adv_fifo_head withdraw_low;
718e3744 119};
120
718e3744 121/* BGP adjacency linked list. */
1defdda8 122#define BGP_PATH_INFO_ADD(N, A, TYPE) \
d62a17ae 123 do { \
124 (A)->prev = NULL; \
125 (A)->next = (N)->TYPE; \
126 if ((N)->TYPE) \
127 (N)->TYPE->prev = (A); \
128 (N)->TYPE = (A); \
129 } while (0)
130
1defdda8 131#define BGP_PATH_INFO_DEL(N, A, TYPE) \
d62a17ae 132 do { \
133 if ((A)->next) \
134 (A)->next->prev = (A)->prev; \
135 if ((A)->prev) \
136 (A)->prev->next = (A)->next; \
137 else \
138 (N)->TYPE = (A)->next; \
139 } while (0)
718e3744 140
1defdda8
DS
141#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
142#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
718e3744 143
144/* Prototypes. */
9bcb3eef
DS
145extern bool bgp_adj_out_lookup(struct peer *, struct bgp_dest *, uint32_t);
146extern void bgp_adj_in_set(struct bgp_dest *, struct peer *, struct attr *,
d7c0a89a 147 uint32_t);
9bcb3eef
DS
148extern bool bgp_adj_in_unset(struct bgp_dest *, struct peer *, uint32_t);
149extern void bgp_adj_in_remove(struct bgp_dest *, struct bgp_adj_in *);
d62a17ae 150
151extern void bgp_sync_init(struct peer *);
152extern void bgp_sync_delete(struct peer *);
d8b87afe 153extern unsigned int baa_hash_key(const void *p);
74df8d6d 154extern bool baa_hash_cmp(const void *p1, const void *p2);
d62a17ae 155extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
156 struct bgp_advertise *adv);
157extern struct bgp_advertise *bgp_advertise_new(void);
158extern void bgp_advertise_free(struct bgp_advertise *adv);
159extern struct bgp_advertise_attr *bgp_advertise_intern(struct hash *hash,
160 struct attr *attr);
161extern struct bgp_advertise_attr *baa_new(void);
162extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
163 struct bgp_advertise *adv);
164extern void bgp_advertise_unintern(struct hash *hash,
165 struct bgp_advertise_attr *baa);
00d252cb 166
167#endif /* _QUAGGA_BGP_ADVERTISE_H */