github.com/sagernet/gvisor@v0.0.0-20240428053021-e691de28565f/pkg/tcpip/link/tun/tun_state_autogen.go (about) 1 // automatically generated by stateify. 2 3 package tun 4 5 import ( 6 "context" 7 8 "github.com/sagernet/gvisor/pkg/state" 9 ) 10 11 func (d *Device) StateTypeName() string { 12 return "pkg/tcpip/link/tun.Device" 13 } 14 15 func (d *Device) StateFields() []string { 16 return []string{ 17 "Queue", 18 "endpoint", 19 "notifyHandle", 20 "flags", 21 } 22 } 23 24 // +checklocksignore 25 func (d *Device) StateSave(stateSinkObject state.Sink) { 26 d.beforeSave() 27 stateSinkObject.Save(0, &d.Queue) 28 stateSinkObject.Save(1, &d.endpoint) 29 stateSinkObject.Save(2, &d.notifyHandle) 30 stateSinkObject.Save(3, &d.flags) 31 } 32 33 func (d *Device) afterLoad(context.Context) {} 34 35 // +checklocksignore 36 func (d *Device) StateLoad(ctx context.Context, stateSourceObject state.Source) { 37 stateSourceObject.Load(0, &d.Queue) 38 stateSourceObject.Load(1, &d.endpoint) 39 stateSourceObject.Load(2, &d.notifyHandle) 40 stateSourceObject.Load(3, &d.flags) 41 } 42 43 func (f *Flags) StateTypeName() string { 44 return "pkg/tcpip/link/tun.Flags" 45 } 46 47 func (f *Flags) StateFields() []string { 48 return []string{ 49 "TUN", 50 "TAP", 51 "NoPacketInfo", 52 } 53 } 54 55 func (f *Flags) beforeSave() {} 56 57 // +checklocksignore 58 func (f *Flags) StateSave(stateSinkObject state.Sink) { 59 f.beforeSave() 60 stateSinkObject.Save(0, &f.TUN) 61 stateSinkObject.Save(1, &f.TAP) 62 stateSinkObject.Save(2, &f.NoPacketInfo) 63 } 64 65 func (f *Flags) afterLoad(context.Context) {} 66 67 // +checklocksignore 68 func (f *Flags) StateLoad(ctx context.Context, stateSourceObject state.Source) { 69 stateSourceObject.Load(0, &f.TUN) 70 stateSourceObject.Load(1, &f.TAP) 71 stateSourceObject.Load(2, &f.NoPacketInfo) 72 } 73 74 func (r *tunEndpointRefs) StateTypeName() string { 75 return "pkg/tcpip/link/tun.tunEndpointRefs" 76 } 77 78 func (r *tunEndpointRefs) StateFields() []string { 79 return []string{ 80 "refCount", 81 } 82 } 83 84 func (r *tunEndpointRefs) beforeSave() {} 85 86 // +checklocksignore 87 func (r *tunEndpointRefs) StateSave(stateSinkObject state.Sink) { 88 r.beforeSave() 89 stateSinkObject.Save(0, &r.refCount) 90 } 91 92 // +checklocksignore 93 func (r *tunEndpointRefs) StateLoad(ctx context.Context, stateSourceObject state.Source) { 94 stateSourceObject.Load(0, &r.refCount) 95 stateSourceObject.AfterLoad(func() { r.afterLoad(ctx) }) 96 } 97 98 func init() { 99 state.Register((*Device)(nil)) 100 state.Register((*Flags)(nil)) 101 state.Register((*tunEndpointRefs)(nil)) 102 }