blob: 7841b4b9a62c8aadf682fd046c8f9bd7b7f2695a [file] [log] [blame]
Job Snijders3334bab2017-01-20 14:47:12 +00001/* BGP Large Communities Attribute.
2
3Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
4
5This file is part of GNU Zebra.
6
7GNU Zebra is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by the
9Free Software Foundation; either version 2, or (at your option) any
10later version.
11
12GNU Zebra is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Zebra; see the file COPYING. If not, write to the Free
19Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
21
22#ifndef _QUAGGA_BGP_LCOMMUNITY_H
23#define _QUAGGA_BGP_LCOMMUNITY_H
24
25/* Extended communities attribute string format. */
26#define LCOMMUNITY_FORMAT_ROUTE_MAP 0
27#define LCOMMUNITY_FORMAT_COMMUNITY_LIST 1
28#define LCOMMUNITY_FORMAT_DISPLAY 2
29
30/* Large Communities value is twelve octets long. */
31#define LCOMMUNITY_SIZE 12
32
33/* Large Communities attribute. */
34struct lcommunity
35{
36 /* Reference counter. */
37 unsigned long refcnt;
38
39 /* Size of Extended Communities attribute. */
40 int size;
41
42 /* Extended Communities value. */
43 u_int8_t *val;
44
45 /* Human readable format string. */
46 char *str;
47};
48
49/* Extended community value is eight octet. */
50struct lcommunity_val
51{
52 char val[LCOMMUNITY_SIZE];
53};
54
55#define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE)
56
57extern void lcommunity_init (void);
58extern void lcommunity_finish (void);
59extern void lcommunity_free (struct lcommunity **);
60extern struct lcommunity *lcommunity_parse (u_int8_t *, u_short);
61extern struct lcommunity *lcommunity_dup (struct lcommunity *);
62extern struct lcommunity *lcommunity_merge (struct lcommunity *, struct lcommunity *);
63extern struct lcommunity *lcommunity_uniq_sort (struct lcommunity *);
64extern struct lcommunity *lcommunity_intern (struct lcommunity *);
65extern int lcommunity_cmp (const void *, const void *);
66extern void lcommunity_unintern (struct lcommunity **);
67extern unsigned int lcommunity_hash_make (void *);
68extern struct hash *lcommunity_hash (void);
69extern struct lcommunity *lcommunity_str2com (const char *);
70extern char *lcommunity_lcom2str (struct lcommunity *, int);
71extern int lcommunity_match (const struct lcommunity *, const struct lcommunity *);
72extern char *lcommunity_str (struct lcommunity *);
73extern int lcommunity_include (struct lcommunity *lcom, u_char *ptr);
74extern void lcommunity_del_val (struct lcommunity *lcom, u_char *ptr);
75#endif /* _QUAGGA_BGP_LCOMMUNITY_H */