libnl 3.5.0

bridge.h
1 /*
2 * netlink/route/link/bridge.h Bridge
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
7 * of the License.
8 *
9 * Copyright (c) 2013 Thomas Graf <tgraf@suug.ch>
10 */
11
12 #ifndef NETLINK_LINK_BRIDGE_H_
13 #define NETLINK_LINK_BRIDGE_H_
14
15 #include <netlink/netlink.h>
16 #include <netlink/route/link.h>
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #define RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX 4096
23 #define RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN (RTNL_LINK_BRIDGE_VLAN_BITMAP_MAX / 32)
24
25 struct rtnl_link_bridge_vlan
26 {
27 uint16_t pvid;
28 uint32_t vlan_bitmap[RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN];
29 uint32_t untagged_bitmap[RTNL_LINK_BRIDGE_VLAN_BITMAP_LEN];
30 };
31
32 /**
33 * Bridge flags
34 * @ingroup bridge
35 */
36 enum rtnl_link_bridge_flags {
37 RTNL_BRIDGE_HAIRPIN_MODE = 0x0001,
38 RTNL_BRIDGE_BPDU_GUARD = 0x0002,
39 RTNL_BRIDGE_ROOT_BLOCK = 0x0004,
40 RTNL_BRIDGE_FAST_LEAVE = 0x0008,
41 RTNL_BRIDGE_UNICAST_FLOOD = 0x0010,
42 RTNL_BRIDGE_LEARNING = 0x0020,
43 RTNL_BRIDGE_LEARNING_SYNC = 0x0040,
44 };
45
46 #define RTNL_BRIDGE_HWMODE_VEB BRIDGE_MODE_VEB
47 #define RTNL_BRIDGE_HWMODE_VEPA BRIDGE_MODE_VEPA
48 #define RTNL_BRIDGE_HWMODE_MAX BRIDGE_MODE_VEPA
49 #define RTNL_BRIDGE_HWMODE_UNDEF BRIDGE_MODE_UNDEF
50
51 extern struct rtnl_link *rtnl_link_bridge_alloc(void);
52
53 extern int rtnl_link_is_bridge(struct rtnl_link *);
54 extern int rtnl_link_bridge_has_ext_info(struct rtnl_link *);
55
56 extern int rtnl_link_bridge_set_port_state(struct rtnl_link *, uint8_t );
57 extern int rtnl_link_bridge_get_port_state(struct rtnl_link *);
58
59 extern int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t);
60 extern int rtnl_link_bridge_get_priority(struct rtnl_link *);
61
62 extern int rtnl_link_bridge_set_cost(struct rtnl_link *, uint32_t);
63 extern int rtnl_link_bridge_get_cost(struct rtnl_link *, uint32_t *);
64
65 extern int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int);
66 extern int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int);
67 extern int rtnl_link_bridge_get_flags(struct rtnl_link *);
68
69 extern int rtnl_link_bridge_set_self(struct rtnl_link *);
70
71 extern int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *);
72 extern int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t);
73
74 extern char * rtnl_link_bridge_flags2str(int, char *, size_t);
75 extern int rtnl_link_bridge_str2flags(const char *);
76
77 extern char * rtnl_link_bridge_portstate2str(int, char *, size_t);
78 extern int rtnl_link_bridge_str2portstate(const char *);
79
80 extern char * rtnl_link_bridge_hwmode2str(uint16_t, char *, size_t);
81 extern uint16_t rtnl_link_bridge_str2hwmode(const char *);
82
83 extern int rtnl_link_bridge_add(struct nl_sock *sk, const char *name);
84
85 extern int rtnl_link_bridge_pvid(struct rtnl_link *link);
86 extern int rtnl_link_bridge_has_vlan(struct rtnl_link *link);
87
88 extern struct rtnl_link_bridge_vlan *rtnl_link_bridge_get_port_vlan(struct rtnl_link *link);
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif
94
rtnl_link_bridge_set_hwmode
int rtnl_link_bridge_set_hwmode(struct rtnl_link *, uint16_t)
Set hardware mode.
Definition: bridge.c:825
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:645
rtnl_link_bridge_set_self
int rtnl_link_bridge_set_self(struct rtnl_link *)
Set link change type to self.
Definition: bridge.c:769
rtnl_link_bridge_unset_flags
int rtnl_link_bridge_unset_flags(struct rtnl_link *, unsigned int)
Unset flags.
Definition: bridge.c:693
rtnl_link_bridge_get_priority
int rtnl_link_bridge_get_priority(struct rtnl_link *)
Get priority.
Definition: bridge.c:626
rtnl_link_bridge_vlan
Definition: bridge.h:25
rtnl_link
Link object.
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:586
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:562
rtnl_link_bridge_set_priority
int rtnl_link_bridge_set_priority(struct rtnl_link *, uint16_t)
Set priority.
Definition: bridge.c:605
rtnl_link_is_bridge
int rtnl_link_is_bridge(struct rtnl_link *)
Check if a link is a bridge.
Definition: bridge.c:514
rtnl_link_bridge_alloc
struct rtnl_link * rtnl_link_bridge_alloc(void)
Allocate link object of type bridge.
Definition: bridge.c:464
rtnl_link_bridge_get_hwmode
int rtnl_link_bridge_get_hwmode(struct rtnl_link *, uint16_t *)
Get hardware mode.
Definition: bridge.c:792
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:491
rtnl_link_bridge_flags
rtnl_link_bridge_flags
Bridge flags.
Definition: bridge.h:36
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:533
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:668
rtnl_link_bridge_set_flags
int rtnl_link_bridge_set_flags(struct rtnl_link *, unsigned int)
Set flags.
Definition: bridge.c:726
rtnl_link_bridge_get_flags
int rtnl_link_bridge_get_flags(struct rtnl_link *)
Get flags.
Definition: bridge.c:749