]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_lcommunity.h
bgpd: Adding BGP GR Global & Per Neighbour FSM changes
[mirror_frr.git] / bgpd / bgp_lcommunity.h
1 /* BGP Large Communities Attribute.
2 *
3 * Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
4 *
5 * This file is part of FreeRangeRouting (FRR).
6 *
7 * FRR is free software; you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation; either version 2, or (at your option) any later version.
10 *
11 * FRR is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef _QUAGGA_BGP_LCOMMUNITY_H
22 #define _QUAGGA_BGP_LCOMMUNITY_H
23
24 #include "lib/json.h"
25 #include "bgpd/bgp_route.h"
26
27 /* Large Communities value is twelve octets long. */
28 #define LCOMMUNITY_SIZE 12
29
30 /* Large Communities attribute. */
31 struct lcommunity {
32 /* Reference counter. */
33 unsigned long refcnt;
34
35 /* Size of Extended Communities attribute. */
36 int size;
37
38 /* Large Communities value. */
39 uint8_t *val;
40
41 /* Large Communities as a json object */
42 json_object *json;
43
44 /* Human readable format string. */
45 char *str;
46 };
47
48 /* Large community value is 12 octets. */
49 struct lcommunity_val {
50 char val[LCOMMUNITY_SIZE];
51 };
52
53 #define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE)
54
55 extern void lcommunity_init(void);
56 extern void lcommunity_finish(void);
57 extern void lcommunity_free(struct lcommunity **);
58 extern struct lcommunity *lcommunity_parse(uint8_t *, unsigned short);
59 extern struct lcommunity *lcommunity_dup(struct lcommunity *);
60 extern struct lcommunity *lcommunity_merge(struct lcommunity *,
61 struct lcommunity *);
62 extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *);
63 extern struct lcommunity *lcommunity_intern(struct lcommunity *);
64 extern bool lcommunity_cmp(const void *arg1, const void *arg2);
65 extern void lcommunity_unintern(struct lcommunity **);
66 extern unsigned int lcommunity_hash_make(const void *);
67 extern struct hash *lcommunity_hash(void);
68 extern struct lcommunity *lcommunity_str2com(const char *);
69 extern int lcommunity_match(const struct lcommunity *,
70 const struct lcommunity *);
71 extern char *lcommunity_str(struct lcommunity *, bool make_json);
72 extern int lcommunity_include(struct lcommunity *lcom, uint8_t *ptr);
73 extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr);
74
75 extern void bgp_compute_aggregate_lcommunity(
76 struct bgp_aggregate *aggregate,
77 struct lcommunity *lcommunity);
78
79 extern void bgp_compute_aggregate_lcommunity_hash(
80 struct bgp_aggregate *aggregate,
81 struct lcommunity *lcommunity);
82 extern void bgp_compute_aggregate_lcommunity_val(
83 struct bgp_aggregate *aggregate);
84
85 extern void bgp_remove_lcommunity_from_aggregate(
86 struct bgp_aggregate *aggregate,
87 struct lcommunity *lcommunity);
88 extern void bgp_remove_lcomm_from_aggregate_hash(
89 struct bgp_aggregate *aggregate,
90 struct lcommunity *lcommunity);
91 extern void bgp_aggr_lcommunity_remove(void *arg);
92
93 #endif /* _QUAGGA_BGP_LCOMMUNITY_H */