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#ifndef _QUAGGA_BGP_ADVERTISE_H 22#define _QUAGGA_BGP_ADVERTISE_H 23 24/* 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. */ 40 struct fifo fifo; 41 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{ 93 struct fifo update; 94 struct fifo withdraw; 95 struct fifo withdraw_low; 96}; 97 98#define BGP_ADV_FIFO_HEAD(F) ((struct bgp_advertise *)FIFO_HEAD(F)) 99 100/* 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. */ 126extern void bgp_adj_out_set (struct bgp_node *, struct peer *, struct prefix *, 127 struct attr *, afi_t, safi_t, struct bgp_info *); 128extern void bgp_adj_out_unset (struct bgp_node *, struct peer *, struct prefix *, 129 afi_t, safi_t); 130extern void bgp_adj_out_remove (struct bgp_node *, struct bgp_adj_out *, 131 struct peer *, afi_t, safi_t); 132extern int bgp_adj_out_lookup (struct peer *, struct prefix *, afi_t, safi_t, 133 struct bgp_node *); 134 135extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *); 136extern void bgp_adj_in_unset (struct bgp_node *, struct peer *); 137extern void bgp_adj_in_remove (struct bgp_node *, struct bgp_adj_in *); 138 139extern struct bgp_advertise * 140bgp_advertise_clean (struct peer *, struct bgp_adj_out *, afi_t, safi_t); 141 142extern void bgp_sync_init (struct peer *); 143extern void bgp_sync_delete (struct peer *); 144 145#endif /* _QUAGGA_BGP_ADVERTISE_H */ 146