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