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 /* Simple bit mapping. */
24 #define SET_BITMAP(MAP, NUM) \
25 SET_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
27 #define CHECK_BITMAP(MAP, NUM) \
28 CHECK_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
30 #define BGP_MED_MAX UINT32_MAX
32 /* BGP Attribute type range. */
33 #define BGP_ATTR_TYPE_RANGE 256
34 #define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY)
36 /* BGP Attribute flags. */
37 #define BGP_ATTR_FLAG_OPTIONAL 0x80 /* Attribute is optional. */
38 #define BGP_ATTR_FLAG_TRANS 0x40 /* Attribute is transitive. */
39 #define BGP_ATTR_FLAG_PARTIAL 0x20 /* Attribute is partial. */
40 #define BGP_ATTR_FLAG_EXTLEN 0x10 /* Extended length flag. */
42 /* BGP attribute header must bigger than 2. */
43 #define BGP_ATTR_MIN_LEN 2 /* Attribute flag and type. */
45 /* BGP attribute structure. */
48 /* Reference count of this attribute. */
51 /* Flag of attribute is set or not. */
56 struct in_addr nexthop
;
60 struct in_addr aggregator_addr
;
62 struct in_addr originator_id
;
63 struct cluster_list
*cluster
;
65 u_char mp_nexthop_len
;
67 struct in6_addr mp_nexthop_global
;
68 struct in6_addr mp_nexthop_local
;
69 #endif /* HAVE_IPV6 */
70 struct in_addr mp_nexthop_global_in
;
71 struct in_addr mp_nexthop_local_in
;
73 /* AS Path structure */
74 struct aspath
*aspath
;
76 /* Community structure */
77 struct community
*community
;
79 /* Extended Communities attribute. */
80 struct ecommunity
*ecommunity
;
82 /* Unknown transitive attribute. */
83 struct transit
*transit
;
86 /* Router Reflector related structure. */
94 /* Unknown transit attribute. */
102 #define ATTR_FLAG_BIT(X) (1 << ((X) - 1))
105 void bgp_attr_init ();
106 int bgp_attr_parse (struct peer
*, struct attr
*, bgp_size_t
,
107 struct bgp_nlri
*, struct bgp_nlri
*);
108 int bgp_attr_check (struct peer
*, struct attr
*);
109 struct attr
*bgp_attr_intern (struct attr
*attr
);
110 void bgp_attr_unintern (struct attr
*);
111 void bgp_attr_flush (struct attr
*);
112 struct attr
*bgp_attr_default_set (struct attr
*attr
, u_char
);
113 struct attr
*bgp_attr_default_intern (u_char
);
114 struct attr
*bgp_attr_aggregate_intern (struct bgp
*, u_char
,
116 struct community
*, int as_set
);
117 bgp_size_t
bgp_packet_attribute (struct bgp
*bgp
, struct peer
*,
118 struct stream
*, struct attr
*,
119 struct prefix
*, afi_t
, safi_t
,
120 struct peer
*, struct prefix_rd
*, char *);
121 bgp_size_t
bgp_packet_withdraw (struct peer
*peer
, struct stream
*s
,
122 struct prefix
*p
, afi_t
, safi_t
,
123 struct prefix_rd
*, char *);
124 void bgp_dump_routes_attr (struct stream
*, struct attr
*, struct prefix
*);
125 unsigned int attrhash_key_make (struct attr
*);
126 int attrhash_cmp (struct attr
*, struct attr
*);
127 void attr_show_all (struct vty
*);
129 /* Cluster list prototypes. */
130 int cluster_loop_check (struct cluster_list
*, struct in_addr
);
131 void cluster_unintern (struct cluster_list
*);
133 /* Transit attribute prototypes. */
134 void transit_unintern (struct transit
*);