]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_attr.h
Initial revision
[mirror_frr.git] / bgpd / bgp_attr.h
1 /* BGP attributes.
2 Copyright (C) 1996, 97, 98 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
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
19 02111-1307, USA. */
20
21 /* Simple bit mapping. */
22 #define BITMAP_NBBY 8
23
24 #define SET_BITMAP(MAP, NUM) \
25 SET_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
26
27 #define CHECK_BITMAP(MAP, NUM) \
28 CHECK_FLAG (MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY))
29
30 /* BGP Attribute type range. */
31 #define BGP_ATTR_TYPE_RANGE 256
32 #define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY)
33
34 /* BGP Attribute flags. */
35 #define BGP_ATTR_FLAG_OPTIONAL 0x80 /* Attribute is optional. */
36 #define BGP_ATTR_FLAG_TRANS 0x40 /* Attribute is transitive. */
37 #define BGP_ATTR_FLAG_PARTIAL 0x20 /* Attribute is partial. */
38 #define BGP_ATTR_FLAG_EXTLEN 0x10 /* Extended length flag. */
39
40 /* BGP attribute header must bigger than 2. */
41 #define BGP_ATTR_MIN_LEN 2 /* Attribute flag and type. */
42
43 /* BGP attribute structure. */
44 struct attr
45 {
46 /* Reference count of this attribute. */
47 unsigned long refcnt;
48
49 /* Flag of attribute is set or not. */
50 u_int32_t flag;
51
52 /* Attributes. */
53 u_char origin;
54 struct in_addr nexthop;
55 u_int32_t med;
56 u_int32_t local_pref;
57 as_t aggregator_as;
58 struct in_addr aggregator_addr;
59 u_int32_t weight;
60 struct in_addr originator_id;
61 struct cluster_list *cluster;
62
63 u_char mp_nexthop_len;
64 #ifdef HAVE_IPV6
65 struct in6_addr mp_nexthop_global;
66 struct in6_addr mp_nexthop_local;
67 #endif /* HAVE_IPV6 */
68 struct in_addr mp_nexthop_global_in;
69 struct in_addr mp_nexthop_local_in;
70
71 /* AS Path structure */
72 struct aspath *aspath;
73
74 /* Community structure */
75 struct community *community;
76
77 /* Extended Communities attribute. */
78 struct ecommunity *ecommunity;
79
80 /* Unknown transitive attribute. */
81 struct transit *transit;
82 };
83
84 /* Router Reflector related structure. */
85 struct cluster_list
86 {
87 unsigned long refcnt;
88 int length;
89 struct in_addr *list;
90 };
91
92 /* Unknown transit attribute. */
93 struct transit
94 {
95 unsigned long refcnt;
96 int length;
97 u_char *val;
98 };
99
100 #define ATTR_FLAG_BIT(X) (1 << ((X) - 1))
101
102 /* Prototypes. */
103 void bgp_attr_init ();
104 int bgp_attr_parse (struct peer *, struct attr *, bgp_size_t,
105 struct bgp_nlri *, struct bgp_nlri *);
106 int bgp_attr_check (struct peer *, struct attr *);
107 struct attr *bgp_attr_intern (struct attr *attr);
108 void bgp_attr_unintern (struct attr *);
109 void bgp_attr_flush (struct attr *);
110 struct attr *bgp_attr_default_set (struct attr *attr, u_char);
111 struct attr *bgp_attr_default_intern (u_char);
112 struct attr *bgp_attr_aggregate_intern (struct bgp *, u_char, struct aspath *, struct community *, int as_set);
113 bgp_size_t bgp_packet_attribute (struct bgp *bgp, struct peer *, struct stream *, struct attr *, struct prefix *, afi_t, safi_t, struct peer *, struct prefix_rd *, u_char *);
114 bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s, struct prefix *p, afi_t, safi_t, struct prefix_rd *, u_char *);
115 void bgp_dump_routes_attr (struct stream *, struct attr *);
116 unsigned int attrhash_key_make (struct attr *);
117 int attrhash_cmp (struct attr *, struct attr *);
118 void attr_show_all (struct vty *);
119
120 /* Cluster list prototypes. */
121 int cluster_loop_check (struct cluster_list *, struct in_addr);
122 void cluster_unintern (struct cluster_list *);
123
124 /* Transit attribute prototypes. */
125 void transit_unintern (struct transit *);