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