github.com/vishvananda/netlink@v1.3.1/protinfo.go (about) 1 package netlink 2 3 import ( 4 "strings" 5 ) 6 7 // Protinfo represents bridge flags from netlink. 8 type 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 Isolated bool 18 NeighSuppress bool 19 VlanTunnel bool 20 } 21 22 // String returns a list of enabled flags 23 func (prot *Protinfo) String() string { 24 if prot == nil { 25 return "<nil>" 26 } 27 28 var boolStrings []string 29 if prot.Hairpin { 30 boolStrings = append(boolStrings, "Hairpin") 31 } 32 if prot.Guard { 33 boolStrings = append(boolStrings, "Guard") 34 } 35 if prot.FastLeave { 36 boolStrings = append(boolStrings, "FastLeave") 37 } 38 if prot.RootBlock { 39 boolStrings = append(boolStrings, "RootBlock") 40 } 41 if prot.Learning { 42 boolStrings = append(boolStrings, "Learning") 43 } 44 if prot.Flood { 45 boolStrings = append(boolStrings, "Flood") 46 } 47 if prot.ProxyArp { 48 boolStrings = append(boolStrings, "ProxyArp") 49 } 50 if prot.ProxyArpWiFi { 51 boolStrings = append(boolStrings, "ProxyArpWiFi") 52 } 53 if prot.Isolated { 54 boolStrings = append(boolStrings, "Isolated") 55 } 56 if prot.NeighSuppress { 57 boolStrings = append(boolStrings, "NeighSuppress") 58 } 59 if prot.VlanTunnel { 60 boolStrings = append(boolStrings, "VlanTunnel") 61 } 62 return strings.Join(boolStrings, " ") 63 } 64 65 func boolToByte(x bool) []byte { 66 if x { 67 return []byte{1} 68 } 69 return []byte{0} 70 } 71 72 func byteToBool(x byte) bool { 73 return uint8(x) != 0 74 }