]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_lcommunity.h
zebra: Convert socket interface to use `union sockunion`
[mirror_frr.git] / bgpd / bgp_lcommunity.h
CommitLineData
57d187bc 1/* BGP Large Communities Attribute.
2acb4ac2
DL
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
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"
57d187bc
JS
25
26/* Large Communities value is twelve octets long. */
27#define LCOMMUNITY_SIZE 12
28
29/* Large Communities attribute. */
d62a17ae 30struct lcommunity {
31 /* Reference counter. */
32 unsigned long refcnt;
57d187bc 33
d62a17ae 34 /* Size of Extended Communities attribute. */
35 int size;
57d187bc 36
f1e1e1c3 37 /* Large Communities value. */
d7c0a89a 38 uint8_t *val;
57d187bc 39
8d9b8ed9
PM
40 /* Large Communities as a json object */
41 json_object *json;
42
d62a17ae 43 /* Human readable format string. */
44 char *str;
57d187bc
JS
45};
46
f1e1e1c3 47/* Large community value is 12 octets. */
d62a17ae 48struct lcommunity_val {
49 char val[LCOMMUNITY_SIZE];
57d187bc
JS
50};
51
52#define lcom_length(X) ((X)->size * LCOMMUNITY_SIZE)
53
d62a17ae 54extern void lcommunity_init(void);
55extern void lcommunity_finish(void);
56extern void lcommunity_free(struct lcommunity **);
d7c0a89a 57extern struct lcommunity *lcommunity_parse(uint8_t *, unsigned short);
d62a17ae 58extern struct lcommunity *lcommunity_dup(struct lcommunity *);
59extern struct lcommunity *lcommunity_merge(struct lcommunity *,
60 struct lcommunity *);
61extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *);
62extern struct lcommunity *lcommunity_intern(struct lcommunity *);
74df8d6d 63extern bool lcommunity_cmp(const void *arg1, const void *arg2);
d62a17ae 64extern void lcommunity_unintern(struct lcommunity **);
65extern unsigned int lcommunity_hash_make(void *);
66extern struct hash *lcommunity_hash(void);
67extern struct lcommunity *lcommunity_str2com(const char *);
d62a17ae 68extern int lcommunity_match(const struct lcommunity *,
69 const struct lcommunity *);
8d9b8ed9 70extern char *lcommunity_str(struct lcommunity *, bool make_json);
d7c0a89a
QY
71extern int lcommunity_include(struct lcommunity *lcom, uint8_t *ptr);
72extern void lcommunity_del_val(struct lcommunity *lcom, uint8_t *ptr);
57d187bc 73#endif /* _QUAGGA_BGP_LCOMMUNITY_H */