usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / zebra / bgpd / bgp_ecommunity.h
blobb2fe79ea413acbc8e9ee317f486c8f210721a9ae
1 /* BGP Extended Communities Attribute.
2 Copyright (C) 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
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
9 later version.
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
19 02111-1307, USA. */
21 /* Extended Communities Transitive flag. */
22 #define ECOMMUNITY_FLAG_NON_TRANSITIVE 0x40
24 /* High-order octet of the Extended Communities type field. */
25 #define ECOMMUNITY_ENCODE_AS 0x00
26 #define ECOMMUNITY_ENCODE_IP 0x01
27 #define ECOMMUNITY_ENCODE_4OCTET_AS 0x02
28 #define ECOMMUNITY_ENCODE_OPAQUE 0x03
30 /* Low-order octet of the Extended Communityes type field. */
31 #define ECOMMUNITY_TYPE_COST_COMMUNITY 0x01
32 #define ECOMMUNITY_TYPE_ROUTE_TARGET 0x02
33 #define ECOMMUNITY_TYPE_SITE_ORIGIN 0x03
35 /* High-order octet and Low-order octet of the Extended Communityes type field. */
36 #define ECOMMUNITY_COST_COMMUNITY 0x4301
38 /* Extended communities attribute string format. */
39 #define ECOMMUNITY_FORMAT_CONFIG 0
40 #define ECOMMUNITY_FORMAT_DISPLAY 1
41 #define ECOMMUNITY_FORMAT_RMAP 2
43 /* Extended communities Cost Community */
44 #define ECOMMUNITY_COST_POI_IGP 129
46 /* Extended Communities value is eight octet long. */
47 #define ECOMMUNITY_SIZE 8
49 /* Cost community default value. */
50 #define COST_COMMUNITY_DEFAULT_COST 0x7FFFFFFF
52 /* Extended Communities attribute. */
53 struct ecommunity
55 /* Reference counter. */
56 unsigned long refcnt;
58 /* Size of Extended Communities attribute. */
59 int size;
61 /* Extended Communities value. */
62 u_char *val;
64 /* Human readable format string. */
65 char *str;
68 /* Extended community value is eight octet. */
69 struct ecommunity_val
71 char val[ECOMMUNITY_SIZE];
74 struct ecommunity_cost
76 u_int16_t type;
77 u_char poi;
78 u_char id;
79 u_int32_t val;
82 #define ecom_length(X) ((X)->size * ECOMMUNITY_SIZE)
84 void ecommunity_init (void);
85 void ecommunity_free (struct ecommunity *);
86 struct ecommunity *ecommunity_new (void);
87 struct ecommunity *ecommunity_parse (char *, u_short);
88 struct ecommunity *ecommunity_dup (struct ecommunity *);
89 struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
90 struct ecommunity *ecommunity_intern (struct ecommunity *);
91 int ecommunity_cmp (struct ecommunity *, struct ecommunity *);
92 void ecommunity_unintern (struct ecommunity *);
93 unsigned int ecommunity_hash_make (struct ecommunity *);
94 struct ecommunity *ecommunity_str2com (char *, int, int);
95 char *ecommunity_ecom2str (struct ecommunity *, int);
96 int ecommunity_match (struct ecommunity *, struct ecommunity *);
97 char *ecommunity_str (struct ecommunity *);
98 struct ecommunity *ecommunity_cost_str2com (char *, u_char);
99 int ecommunity_cost_cmp (struct ecommunity *, struct ecommunity *, u_char);