libnl 3.7.0
bridge.h
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
4 */
5
6#ifndef NETLINK_LINK_BRIDGE_H_
7#define NETLINK_LINK_BRIDGE_H_
8
9#include <netlink/netlink.h>
10#include <netlink/route/link.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#define RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX 4096
17#define RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN (RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX / 32)
18
20{
21 uint16_t pvid;
22 uint32_t vlan_bitmap[RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN];
23 uint32_t untagged_bitmap[RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN];
24};
25
26/**
27 * Bridge flags
28 * @ingroup bridge
29 */
31 RTNL_BRIDGE_HAIRPIN_MODE = 0x0001,
32 RTNL_BRIDGE_BPDU_GUARD = 0x0002,
33 RTNL_BRIDGE_ROOT_BLOCK = 0x0004,
34 RTNL_BRIDGE_FAST_LEAVE = 0x0008,
35 RTNL_BRIDGE_UNICAST_FLOOD = 0x0010,
36 RTNL_BRIDGE_LEARNING = 0x0020,
37 RTNL_BRIDGE_LEARNING_SYNC = 0x0040,
38};
39
40#define RTNL_BRIDGE_HWMODE_VEB BRIDGE_MODE_VEB
41#define RTNL_BRIDGE_HWMODE_VEPA BRIDGE_MODE_VEPA
42#define RTNL_BRIDGE_HWMODE_MAX BRIDGE_MODE_VEPA
43#define RTNL_BRIDGE_HWMODE_UNDEF BRIDGE_MODE_UNDEF
44
45extern struct rtnl_link *rtnl_link_bridge_alloc(void);
46
47extern int rtnl_link_is_bridge(struct rtnl_link *);
48extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *);
49
50extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t );
52
53extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t);
54extern int rtnl_link_bridge_get_priority(struct rtnl_link *);
55
56extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t);
57extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *);
58
59extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int);
60extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int);
61extern int rtnl_link_bridge_get_flags(struct rtnl_link *);
62
63extern int rtnl_link_bridge_set_self(struct rtnl_link *);
64
65extern int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *);
66extern int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t);
67
68extern char * rtnl_link_bridge_flags2str(int, char *, size_t);
69extern int rtnl_link_bridge_str2flags(const char *);
70
71extern char * rtnl_link_bridge_portstate2str(int, char *, size_t);
72extern int rtnl_link_bridge_str2portstate(const char *);
73
74extern char * rtnl_link_bridge_hwmode2str(uint16_t, char *, size_t);
75extern uint16_t rtnl_link_bridge_str2hwmode(const char *);
76
77extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name);
78
79extern int rtnl_link_bridge_pvid(struct rtnl_link *link);
80extern int rtnl_link_bridge_has_vlan(struct rtnl_link *link);
81
82extern struct rtnl_link_bridge_vlan *rtnl_link_bridge_get_port_vlan(struct rtnl_link *link);
83#ifdef __cplusplus
84}
85#endif
86
87#endif
88
int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t)
Set Spanning Tree Protocol (STP) path cost.
Definition: bridge.c:638
int rtnl_link_bridge_get_port_state(struct rtnl_link *)
Get Spanning Tree Protocol (STP) port state.
Definition: bridge.c:579
int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t)
Set hardware mode.
Definition: bridge.c:818
rtnl_link_bridge_flags
Bridge flags.
Definition: bridge.h:30
int rtnl_link_bridge_has_ext_info(struct rtnl_link *)
Check if bridge has extended information.
Definition: bridge.c:526
int rtnl_link_bridge_add(struct nl_sock *sk, const char *name)
Create a new kernel bridge device.
Definition: bridge.c:484
int rtnl_link_is_bridge(struct rtnl_link *)
Check if a link is a bridge.
Definition: bridge.c:507
int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t)
Set Spanning Tree Protocol (STP) port state.
Definition: bridge.c:555
int rtnl_link_bridge_set_self(struct rtnl_link *)
Set link change type to self.
Definition: bridge.c:762
struct rtnl_link * rtnl_link_bridge_alloc(void)
Allocate link object of type bridge.
Definition: bridge.c:458
int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *)
Get hardware mode.
Definition: bridge.c:785
int rtnl_link_bridge_get_flags(struct rtnl_link *)
Get flags.
Definition: bridge.c:742
int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *)
Get Spanning Tree Protocol (STP) path cost.
Definition: bridge.c:661
int rtnl_link_bridge_get_priority(struct rtnl_link *)
Get priority.
Definition: bridge.c:619
int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int)
Unset flags.
Definition: bridge.c:686
int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t)
Set priority.
Definition: bridge.c:598
int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int)
Set flags.
Definition: bridge.c:719