...
1 package nl
2
3 import (
4 "fmt"
5 "unsafe"
6 )
7
8 const (
9 SizeofBridgeVlanInfo = 0x04
10 )
11
12
13 const (
14 BRIDGE_FLAGS_MASTER = iota + 1
15 BRIDGE_FLAGS_SELF
16 )
17
18
25 const (
26 IFLA_BRIDGE_FLAGS = iota
27 IFLA_BRIDGE_MODE
28 IFLA_BRIDGE_VLAN_INFO
29 )
30
31 const (
32 BRIDGE_VLAN_INFO_MASTER = 1 << iota
33 BRIDGE_VLAN_INFO_PVID
34 BRIDGE_VLAN_INFO_UNTAGGED
35 BRIDGE_VLAN_INFO_RANGE_BEGIN
36 BRIDGE_VLAN_INFO_RANGE_END
37 )
38
39
40
41
42
43
44 type BridgeVlanInfo struct {
45 Flags uint16
46 Vid uint16
47 }
48
49 func (b *BridgeVlanInfo) Serialize() []byte {
50 return (*(*[SizeofBridgeVlanInfo]byte)(unsafe.Pointer(b)))[:]
51 }
52
53 func DeserializeBridgeVlanInfo(b []byte) *BridgeVlanInfo {
54 return (*BridgeVlanInfo)(unsafe.Pointer(&b[0:SizeofBridgeVlanInfo][0]))
55 }
56
57 func (b *BridgeVlanInfo) PortVID() bool {
58 return b.Flags&BRIDGE_VLAN_INFO_PVID > 0
59 }
60
61 func (b *BridgeVlanInfo) EngressUntag() bool {
62 return b.Flags&BRIDGE_VLAN_INFO_UNTAGGED > 0
63 }
64
65 func (b *BridgeVlanInfo) String() string {
66 return fmt.Sprintf("%+v", *b)
67 }
68
69
70 const (
71 RTEXT_FILTER_VF = 1 << iota
72 RTEXT_FILTER_BRVLAN
73 RTEXT_FILTER_BRVLAN_COMPRESSED
74 )
75
View as plain text