1package netlink
2
3import (
4	"strings"
5)
6
7// Protinfo represents bridge flags from netlink.
8type Protinfo struct {
9	Hairpin      bool
10	Guard        bool
11	FastLeave    bool
12	RootBlock    bool
13	Learning     bool
14	Flood        bool
15	ProxyArp     bool
16	ProxyArpWiFi bool
17}
18
19// String returns a list of enabled flags
20func (prot *Protinfo) String() string {
21	var boolStrings []string
22	if prot.Hairpin {
23		boolStrings = append(boolStrings, "Hairpin")
24	}
25	if prot.Guard {
26		boolStrings = append(boolStrings, "Guard")
27	}
28	if prot.FastLeave {
29		boolStrings = append(boolStrings, "FastLeave")
30	}
31	if prot.RootBlock {
32		boolStrings = append(boolStrings, "RootBlock")
33	}
34	if prot.Learning {
35		boolStrings = append(boolStrings, "Learning")
36	}
37	if prot.Flood {
38		boolStrings = append(boolStrings, "Flood")
39	}
40	if prot.ProxyArp {
41		boolStrings = append(boolStrings, "ProxyArp")
42	}
43	if prot.ProxyArpWiFi {
44		boolStrings = append(boolStrings, "ProxyArpWiFi")
45	}
46	return strings.Join(boolStrings, " ")
47}
48
49func boolToByte(x bool) []byte {
50	if x {
51		return []byte{1}
52	}
53	return []byte{0}
54}
55
56func byteToBool(x byte) bool {
57	return uint8(x) != 0
58}
59