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

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
13 extern "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 = 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
45 extern struct rtnl_link *rtnl_link_bridge_alloc(void);
46
47 extern int rtnl_link_is_bridge(struct rtnl_link *);
48 extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *);
49
50 extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t );
51 extern int rtnl_link_bridge_get_port_state(struct rtnl_link *);
52
53 extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t);
54 extern int rtnl_link_bridge_get_priority(struct rtnl_link *);
55
56 extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t);
57 extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *);
58
59 extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int);
60 extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int);
61 extern int rtnl_link_bridge_get_flags(struct rtnl_link *);
62
63 extern int rtnl_link_bridge_set_self(struct rtnl_link *);
64
65 extern int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *);
66 extern int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t);
67
68 extern char * rtnl_link_bridge_flags2str(int, char *, size_t);
69 extern int rtnl_link_bridge_str2flags(const char *);
70
71 extern char * rtnl_link_bridge_portstate2str(int, char *, size_t);
72 extern int rtnl_link_bridge_str2portstate(const char *);
73
74 extern char * rtnl_link_bridge_hwmode2str(uint16_t, char *, size_t);
75 extern uint16_t rtnl_link_bridge_str2hwmode(const char *);
76
77 extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name);
78
79 extern int rtnl_link_bridge_pvid(struct rtnl_link *link);
80 extern int rtnl_link_bridge_has_vlan(struct rtnl_link *link);
81
82 extern 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
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:638
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:579
rtnl_link_bridge_set_hwmode
int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t)
Set hardware mode.
Definition: bridge.c:818
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:526
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:484
rtnl_link_is_bridge
int rtnl_link_is_bridge(struct rtnl_link *)
Check if a link is a bridge.
Definition: bridge.c:507
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:555
rtnl_link_bridge_set_self
int rtnl_link_bridge_set_self(struct rtnl_link *)
Set link change type to self.
Definition: bridge.c:762
rtnl_link_bridge_alloc
struct rtnl_link * rtnl_link_bridge_alloc(void)
Allocate link object of type bridge.
Definition: bridge.c:458
rtnl_link_bridge_get_hwmode
int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *)
Get hardware mode.
Definition: bridge.c:785
rtnl_link_bridge_get_flags
int rtnl_link_bridge_get_flags(struct rtnl_link *)
Get flags.
Definition: bridge.c:742
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:661
rtnl_link_bridge_get_priority
int rtnl_link_bridge_get_priority(struct rtnl_link *)
Get priority.
Definition: bridge.c:619
rtnl_link_bridge_unset_flags
int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int)
Unset flags.
Definition: bridge.c:686
rtnl_link_bridge_set_priority
int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t)
Set priority.
Definition: bridge.c:598
rtnl_link_bridge_set_flags
int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int)
Set flags.
Definition: bridge.c:719
rtnl_link_bridge_vlan
Definition: bridge.h:20
rtnl_link
Link object.