libnl: /data/src/libnl/include/netlink/route/link/bridge.h Source File

libnl 3.12.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
19 struct rtnl_link_bridge_vlan
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 */
30 enum rtnl_link_bridge_flags {
31 RTNL_BRIDGE_HAIRPIN_MODE = 1ul << 0,
32 RTNL_BRIDGE_BPDU_GUARD = 1ul << 1,
33 RTNL_BRIDGE_ROOT_BLOCK = 1ul << 2,
34 RTNL_BRIDGE_FAST_LEAVE = 1ul << 3,
35 RTNL_BRIDGE_UNICAST_FLOOD = 1ul << 4,
36 RTNL_BRIDGE_LEARNING = 1ul << 5,
37 RTNL_BRIDGE_LEARNING_SYNC = 1ul << 6,
38 RTNL_BRIDGE_PROXYARP = 1ul << 7,
39 RTNL_BRIDGE_PROXYARP_WIFI = 1ul << 8,
40 RTNL_BRIDGE_MCAST_FLOOD = 1ul << 9,
41 RTNL_BRIDGE_MCAST_TO_UCAST = 1ul << 10,
42 RTNL_BRIDGE_VLAN_TUNNEL = 1ul << 11,
43 RTNL_BRIDGE_BCAST_FLOOD = 1ul << 12,
44 RTNL_BRIDGE_NEIGH_SUPPRESS = 1ul << 13,
45 RTNL_BRIDGE_ISOLATED = 1ul << 14,
46 RTNL_BRIDGE_LOCKED = 1ul << 15,
47 RTNL_BRIDGE_MAB = 1ul << 16,
48 RTNL_BRIDGE_NEIGH_VLAN_SUPPRESS = 1ul << 17,
49};
50
51#define RTNL_BRIDGE_HWMODE_VEB BRIDGE_MODE_VEB
52#define RTNL_BRIDGE_HWMODE_VEPA BRIDGE_MODE_VEPA
53#define RTNL_BRIDGE_HWMODE_MAX BRIDGE_MODE_VEPA
54#define RTNL_BRIDGE_HWMODE_UNDEF BRIDGE_MODE_UNDEF
55
56extern struct rtnl_link *rtnl_link_bridge_alloc(void);
57
58extern int rtnl_link_is_bridge(struct rtnl_link *);
59extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *);
60
61extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t );
62extern int rtnl_link_bridge_get_port_state(struct rtnl_link *);
63
64extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t);
65extern int rtnl_link_bridge_get_priority(struct rtnl_link *);
66
67extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t);
68extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *);
69
70extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int);
71extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int);
72extern int rtnl_link_bridge_get_flags(struct rtnl_link *);
73
74extern int rtnl_link_bridge_set_self(struct rtnl_link *);
75extern int rtnl_link_bridge_set_master(struct rtnl_link *);
76
77extern int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *);
78extern int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t);
79
80extern char * rtnl_link_bridge_flags2str(int, char *, size_t);
81extern int rtnl_link_bridge_str2flags(const char *);
82
83extern char * rtnl_link_bridge_portstate2str(int, char *, size_t);
84extern int rtnl_link_bridge_str2portstate(const char *);
85
86extern char * rtnl_link_bridge_hwmode2str(uint16_t, char *, size_t);
87extern uint16_t rtnl_link_bridge_str2hwmode(const char *);
88
89extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name);
90
91extern int rtnl_link_bridge_enable_vlan(struct rtnl_link *link);
92extern int rtnl_link_bridge_set_port_vlan_map_range (struct rtnl_link *link, uint16_t start, uint16_t end, int untagged);
93extern int rtnl_link_bridge_unset_port_vlan_map_range (struct rtnl_link *link, uint16_t start, uint16_t end);
94extern int rtnl_link_bridge_set_port_vlan_pvid (struct rtnl_link *link, uint16_t pvid);
95extern int rtnl_link_bridge_pvid(struct rtnl_link *link);
96extern int rtnl_link_bridge_has_vlan(struct rtnl_link *link);
97
98extern struct rtnl_link_bridge_vlan *rtnl_link_bridge_get_port_vlan(struct rtnl_link *link);
99
100extern int rtnl_link_bridge_set_mst_port_state(struct rtnl_link *link, uint16_t instance, uint8_t state);
101extern int rtnl_link_bridge_get_mst_port_state(struct rtnl_link *link, uint16_t instance);
102extern int rtnl_link_bridge_del_mst_port_state(struct rtnl_link *link, uint16_t instance);
103extern int rtnl_link_bridge_clear_mst_port_state_info(struct rtnl_link *link);
104extern int rtnl_link_bridge_foreach_mst_entry(struct rtnl_link *link, void (*cb)(uint16_t instance, uint8_t state, void *arg), void *arg);
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif
111
rtnl_link_bridge_set_mst_port_state
int rtnl_link_bridge_set_mst_port_state(struct rtnl_link *link, uint16_t instance, uint8_t state)
Set the Multiple Spanning Tree (MST) port state for a given MST instance.
Definition bridge.c:1677
rtnl_link_bridge_set_cost
int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t)
Set Spanning Tree Protocol (STP) path cost.
Definition bridge.c:1161
rtnl_link_bridge_get_port_state
int rtnl_link_bridge_get_port_state(struct rtnl_link *)
Get Spanning Tree Protocol (STP) port state.
Definition bridge.c:1102
rtnl_link_bridge_get_mst_port_state
int rtnl_link_bridge_get_mst_port_state(struct rtnl_link *link, uint16_t instance)
Get the Multiple Spanning Tree (MST) port state for a given MST instance.
Definition bridge.c:1720
rtnl_link_bridge_set_hwmode
int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t)
Set hardware mode.
Definition bridge.c:1375
rtnl_link_bridge_flags
rtnl_link_bridge_flags
Bridge flags.
Definition bridge.h:30
rtnl_link_bridge_has_ext_info
int rtnl_link_bridge_has_ext_info(struct rtnl_link *)
Check if bridge has extended information.
Definition bridge.c:1049
rtnl_link_bridge_set_master
int rtnl_link_bridge_set_master(struct rtnl_link *)
Set link change type to master.
Definition bridge.c:1319
rtnl_link_bridge_add
int rtnl_link_bridge_add(struct nl_sock *sk, const char *name)
Create a new kernel bridge device.
Definition bridge.c:1007
rtnl_link_bridge_set_port_vlan_map_range
int rtnl_link_bridge_set_port_vlan_map_range(struct rtnl_link *link, uint16_t start, uint16_t end, int untagged)
Set port vlan membership range.
Definition bridge.c:1517
rtnl_link_is_bridge
int rtnl_link_is_bridge(struct rtnl_link *)
Check if a link is a bridge.
Definition bridge.c:1030
rtnl_link_bridge_set_port_state
int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t)
Set Spanning Tree Protocol (STP) port state.
Definition bridge.c:1078
rtnl_link_bridge_foreach_mst_entry
int rtnl_link_bridge_foreach_mst_entry(struct rtnl_link *link, void(*cb)(uint16_t instance, uint8_t state, void *arg), void *arg)
Iterate over all Multiple Spanning Tree (MST) port state entries.
Definition bridge.c:1823
rtnl_link_bridge_enable_vlan
int rtnl_link_bridge_enable_vlan(struct rtnl_link *link)
Enable the ability to set vlan info.
Definition bridge.c:1485
rtnl_link_bridge_del_mst_port_state
int rtnl_link_bridge_del_mst_port_state(struct rtnl_link *link, uint16_t instance)
Delete the Multiple Spanning Tree (MST) port state for a given MST instance.
Definition bridge.c:1753
rtnl_link_bridge_set_self
int rtnl_link_bridge_set_self(struct rtnl_link *)
Set link change type to self.
Definition bridge.c:1296
rtnl_link_bridge_set_port_vlan_pvid
int rtnl_link_bridge_set_port_vlan_pvid(struct rtnl_link *link, uint16_t pvid)
Set port primary vlan id.
Definition bridge.c:1597
rtnl_link_bridge_alloc
struct rtnl_link * rtnl_link_bridge_alloc(void)
Allocate link object of type bridge.
Definition bridge.c:981
rtnl_link_bridge_get_hwmode
int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *)
Get hardware mode.
Definition bridge.c:1342
rtnl_link_bridge_clear_mst_port_state_info
int rtnl_link_bridge_clear_mst_port_state_info(struct rtnl_link *link)
Delete all Multiple Spanning Tree (MST) port state information.
Definition bridge.c:1789
rtnl_link_bridge_get_flags
int rtnl_link_bridge_get_flags(struct rtnl_link *)
Get flags.
Definition bridge.c:1276
rtnl_link_bridge_get_cost
int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *)
Get Spanning Tree Protocol (STP) path cost.
Definition bridge.c:1184
rtnl_link_bridge_get_priority
int rtnl_link_bridge_get_priority(struct rtnl_link *)
Get priority.
Definition bridge.c:1142
rtnl_link_bridge_unset_flags
int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int)
Unset flags.
Definition bridge.c:1209
rtnl_link_bridge_unset_port_vlan_map_range
int rtnl_link_bridge_unset_port_vlan_map_range(struct rtnl_link *link, uint16_t start, uint16_t end)
Unset port vlan membership range.
Definition bridge.c:1558
rtnl_link_bridge_set_priority
int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t)
Set priority.
Definition bridge.c:1121
rtnl_link_bridge_set_flags
int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int)
Set flags.
Definition bridge.c:1253
rtnl_link_bridge_vlan
Definition bridge.h:20
rtnl_link
Link object.
Definition nl-route.h:29