2 Copyright (C) 1996, 97, 98 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
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
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #ifndef _QUAGGA_BGP_ATTR_H
22 #define _QUAGGA_BGP_ATTR_H
24 /* Simple bit mapping. */
27 #define SET_BITMAP(MAP, NUM) \
28 SET_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
30 #define CHECK_BITMAP(MAP, NUM) \
31 CHECK_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
33 #define BGP_MED_MAX UINT32_MAX
36 /* BGP Attribute type range. */
37 #define BGP_ATTR_TYPE_RANGE 256
38 #define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY)
40 /* BGP Attribute flags. */
41 #define BGP_ATTR_FLAG_OPTIONAL 0x80 /* Attribute is optional. */
42 #define BGP_ATTR_FLAG_TRANS 0x40 /* Attribute is transitive. */
43 #define BGP_ATTR_FLAG_PARTIAL 0x20 /* Attribute is partial. */
44 #define BGP_ATTR_FLAG_EXTLEN 0x10 /* Extended length flag. */
46 /* BGP attribute header must bigger than 2. */
47 #define BGP_ATTR_MIN_LEN 3 /* Attribute flag, type length. */
48 #define BGP_ATTR_DEFAULT_WEIGHT 32768
50 /* Additional/uncommon BGP attributes.
51 * lazily allocated as and when a struct attr
56 /* Multi-Protocol Nexthop, AFI IPv6 */
58 struct in6_addr mp_nexthop_global
;
59 struct in6_addr mp_nexthop_local
;
60 #endif /* HAVE_IPV6 */
62 /* Extended Communities attribute. */
63 struct ecommunity
*ecommunity
;
65 /* Route-Reflector Cluster attribute */
66 struct cluster_list
*cluster
;
68 /* Unknown transitive attribute. */
69 struct transit
*transit
;
71 struct in_addr mp_nexthop_global_in
;
72 struct in_addr mp_nexthop_local_in
;
74 /* Aggregator Router ID attribute */
75 struct in_addr aggregator_addr
;
77 /* Route Reflector Originator attribute */
78 struct in_addr originator_id
;
80 /* Local weight, not actually an attribute */
86 /* MP Nexthop length */
87 u_char mp_nexthop_len
;
90 /* BGP core attribute structure. */
93 /* AS Path structure */
94 struct aspath
*aspath
;
96 /* Community structure */
97 struct community
*community
;
99 /* Lazily allocated pointer to extra attributes */
100 struct attr_extra
*extra
;
102 /* Reference count of this attribute. */
103 unsigned long refcnt
;
105 /* Flag of attribute is set or not. */
108 /* Apart from in6_addr, the remaining static attributes */
109 struct in_addr nexthop
;
111 u_int32_t local_pref
;
119 /* Path origin attribute */
123 /* Router Reflector related structure. */
126 unsigned long refcnt
;
128 struct in_addr
*list
;
131 /* Unknown transit attribute. */
134 unsigned long refcnt
;
139 #define ATTR_FLAG_BIT(X) (1 << ((X) - 1))
142 extern void bgp_attr_init (void);
143 extern void bgp_attr_finish (void);
144 extern int bgp_attr_parse (struct peer
*, struct attr
*, bgp_size_t
,
145 struct bgp_nlri
*, struct bgp_nlri
*);
146 extern int bgp_attr_check (struct peer
*, struct attr
*);
147 extern struct attr_extra
*bgp_attr_extra_get (struct attr
*);
148 extern void bgp_attr_extra_free (struct attr
*);
149 extern void bgp_attr_dup (struct attr
*, struct attr
*);
150 extern struct attr
*bgp_attr_intern (struct attr
*attr
);
151 extern void bgp_attr_unintern (struct attr
*);
152 extern void bgp_attr_flush (struct attr
*);
153 extern struct attr
*bgp_attr_default_set (struct attr
*attr
, u_char
);
154 extern struct attr
*bgp_attr_default_intern (u_char
);
155 extern struct attr
*bgp_attr_aggregate_intern (struct bgp
*, u_char
,
157 struct community
*, int as_set
);
158 extern bgp_size_t
bgp_packet_attribute (struct bgp
*bgp
, struct peer
*,
159 struct stream
*, struct attr
*,
160 struct prefix
*, afi_t
, safi_t
,
161 struct peer
*, struct prefix_rd
*, u_char
*);
162 extern bgp_size_t
bgp_packet_withdraw (struct peer
*peer
, struct stream
*s
,
163 struct prefix
*p
, afi_t
, safi_t
,
164 struct prefix_rd
*, u_char
*);
165 extern void bgp_dump_routes_attr (struct stream
*, struct attr
*,
167 extern int attrhash_cmp (const void *, const void *);
168 extern unsigned int attrhash_key_make (void *);
169 extern void attr_show_all (struct vty
*);
170 extern unsigned long int attr_count (void);
171 extern unsigned long int attr_unknown_count (void);
173 /* Cluster list prototypes. */
174 extern int cluster_loop_check (struct cluster_list
*, struct in_addr
);
175 extern void cluster_unintern (struct cluster_list
*);
177 /* Transit attribute prototypes. */
178 void transit_unintern (struct transit
*);
180 /* Exported for unit-test purposes only */
181 extern int bgp_mp_reach_parse (struct peer
*, bgp_size_t
, struct attr
*,
183 extern int bgp_mp_unreach_parse (struct peer
*, bgp_size_t
, struct bgp_nlri
*);
185 #endif /* _QUAGGA_BGP_ATTR_H */