]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_lcommunity.h
*: auto-convert to SPDX License IDs
[mirror_frr.git] / bgpd / bgp_lcommunity.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP Large Communities Attribute.
3 *
4 * Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
5 */
6
7 #ifndef _QUAGGA_BGP_LCOMMUNITY_H
8 #define _QUAGGA_BGP_LCOMMUNITY_H
9
10 #include "lib/json.h"
11 #include "bgpd/bgp_route.h"
12 #include "bgpd/bgp_clist.h"
13
14 /* Large Communities value is twelve octets long. */
15 #define LCOMMUNITY_SIZE 12
16
17 /* Large Communities attribute. */
18 struct lcommunity {
19 /* Reference counter. */
20 unsigned long refcnt;
21
22 /* Size of Extended Communities attribute. */
23 int size;
24
25 /* Large Communities value. */
26 uint8_t *val;
27
28 /* Large Communities as a json object */
29 json_object *json;
30
31 /* Human readable format string. */
32 char *str;
33 };
34
35 /* Large community value is 12 octets. */
36 struct lcommunity_val {
37 char val[LCOMMUNITY_SIZE];
38 };
39
40 #define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE)
41
42 extern void lcommunity_init(void);
43 extern void lcommunity_finish(void);
44 extern void lcommunity_free(struct lcommunity **);
45 extern struct lcommunity *lcommunity_parse(uint8_t *, unsigned short);
46 extern struct lcommunity *lcommunity_dup(struct lcommunity *);
47 extern struct lcommunity *lcommunity_merge(struct lcommunity *,
48 struct lcommunity *);
49 extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *);
50 extern struct lcommunity *lcommunity_intern(struct lcommunity *);
51 extern bool lcommunity_cmp(const void *arg1, const void *arg2);
52 extern void lcommunity_unintern(struct lcommunity **);
53 extern unsigned int lcommunity_hash_make(const void *);
54 extern struct hash *lcommunity_hash(void);
55 extern struct lcommunity *lcommunity_str2com(const char *);
56 extern bool lcommunity_match(const struct lcommunity *,
57 const struct lcommunity *);
58 extern char *lcommunity_str(struct lcommunity *, bool make_json,
59 bool translate_alias);
60 extern bool lcommunity_include(struct lcommunity *lcom, uint8_t *ptr);
61 extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr);
62
63 extern void bgp_compute_aggregate_lcommunity(
64 struct bgp_aggregate *aggregate,
65 struct lcommunity *lcommunity);
66
67 extern void bgp_compute_aggregate_lcommunity_hash(
68 struct bgp_aggregate *aggregate,
69 struct lcommunity *lcommunity);
70 extern void bgp_compute_aggregate_lcommunity_val(
71 struct bgp_aggregate *aggregate);
72
73 extern void bgp_remove_lcommunity_from_aggregate(
74 struct bgp_aggregate *aggregate,
75 struct lcommunity *lcommunity);
76 extern void bgp_remove_lcomm_from_aggregate_hash(
77 struct bgp_aggregate *aggregate,
78 struct lcommunity *lcommunity);
79 extern void bgp_aggr_lcommunity_remove(void *arg);
80
81 #endif /* _QUAGGA_BGP_LCOMMUNITY_H */