]>
Commit | Line | Data |
---|---|---|
57d187bc | 1 | /* BGP Large Communities Attribute. |
2acb4ac2 DL |
2 | * |
3 | * Copyright (C) 2016 Keyur Patel <keyur@arrcus.com> | |
4 | * | |
8678d638 | 5 | * This file is part of FRRouting (FRR). |
2acb4ac2 DL |
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 | |
896014f4 DL |
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 | |
2acb4ac2 | 19 | */ |
57d187bc JS |
20 | |
21 | #ifndef _QUAGGA_BGP_LCOMMUNITY_H | |
22 | #define _QUAGGA_BGP_LCOMMUNITY_H | |
23 | ||
8d9b8ed9 | 24 | #include "lib/json.h" |
4c99b6c2 | 25 | #include "bgpd/bgp_route.h" |
c850908b | 26 | #include "bgpd/bgp_clist.h" |
57d187bc JS |
27 | |
28 | /* Large Communities value is twelve octets long. */ | |
29 | #define LCOMMUNITY_SIZE 12 | |
30 | ||
31 | /* Large Communities attribute. */ | |
d62a17ae | 32 | struct lcommunity { |
33 | /* Reference counter. */ | |
34 | unsigned long refcnt; | |
57d187bc | 35 | |
d62a17ae | 36 | /* Size of Extended Communities attribute. */ |
37 | int size; | |
57d187bc | 38 | |
f1e1e1c3 | 39 | /* Large Communities value. */ |
d7c0a89a | 40 | uint8_t *val; |
57d187bc | 41 | |
8d9b8ed9 PM |
42 | /* Large Communities as a json object */ |
43 | json_object *json; | |
44 | ||
d62a17ae | 45 | /* Human readable format string. */ |
46 | char *str; | |
57d187bc JS |
47 | }; |
48 | ||
f1e1e1c3 | 49 | /* Large community value is 12 octets. */ |
d62a17ae | 50 | struct lcommunity_val { |
51 | char val[LCOMMUNITY_SIZE]; | |
57d187bc JS |
52 | }; |
53 | ||
54 | #define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE) | |
55 | ||
d62a17ae | 56 | extern void lcommunity_init(void); |
57 | extern void lcommunity_finish(void); | |
58 | extern void lcommunity_free(struct lcommunity **); | |
d7c0a89a | 59 | extern struct lcommunity *lcommunity_parse(uint8_t *, unsigned short); |
d62a17ae | 60 | extern struct lcommunity *lcommunity_dup(struct lcommunity *); |
61 | extern struct lcommunity *lcommunity_merge(struct lcommunity *, | |
62 | struct lcommunity *); | |
63 | extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *); | |
64 | extern struct lcommunity *lcommunity_intern(struct lcommunity *); | |
74df8d6d | 65 | extern bool lcommunity_cmp(const void *arg1, const void *arg2); |
d62a17ae | 66 | extern void lcommunity_unintern(struct lcommunity **); |
d8b87afe | 67 | extern unsigned int lcommunity_hash_make(const void *); |
d62a17ae | 68 | extern struct hash *lcommunity_hash(void); |
69 | extern struct lcommunity *lcommunity_str2com(const char *); | |
3dc339cd DA |
70 | extern bool lcommunity_match(const struct lcommunity *, |
71 | const struct lcommunity *); | |
c0945b78 DA |
72 | extern char *lcommunity_str(struct lcommunity *, bool make_json, |
73 | bool translate_alias); | |
3dc339cd | 74 | extern bool lcommunity_include(struct lcommunity *lcom, uint8_t *ptr); |
d7c0a89a | 75 | extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr); |
4c99b6c2 NT |
76 | |
77 | extern void bgp_compute_aggregate_lcommunity( | |
78 | struct bgp_aggregate *aggregate, | |
79 | struct lcommunity *lcommunity); | |
f1eb1f05 | 80 | |
81 | extern void bgp_compute_aggregate_lcommunity_hash( | |
82 | struct bgp_aggregate *aggregate, | |
83 | struct lcommunity *lcommunity); | |
84 | extern void bgp_compute_aggregate_lcommunity_val( | |
85 | struct bgp_aggregate *aggregate); | |
86 | ||
4c99b6c2 NT |
87 | extern void bgp_remove_lcommunity_from_aggregate( |
88 | struct bgp_aggregate *aggregate, | |
89 | struct lcommunity *lcommunity); | |
f1eb1f05 | 90 | extern void bgp_remove_lcomm_from_aggregate_hash( |
91 | struct bgp_aggregate *aggregate, | |
92 | struct lcommunity *lcommunity); | |
4c99b6c2 NT |
93 | extern void bgp_aggr_lcommunity_remove(void *arg); |
94 | ||
57d187bc | 95 | #endif /* _QUAGGA_BGP_LCOMMUNITY_H */ |