github.com/sagernet/gvisor@v0.0.0-20240428053021-e691de28565f/pkg/tcpip/transport/packet/packet_state_autogen.go (about) 1 // automatically generated by stateify. 2 3 package packet 4 5 import ( 6 "context" 7 8 "github.com/sagernet/gvisor/pkg/state" 9 ) 10 11 func (p *packet) StateTypeName() string { 12 return "pkg/tcpip/transport/packet.packet" 13 } 14 15 func (p *packet) StateFields() []string { 16 return []string{ 17 "packetEntry", 18 "data", 19 "receivedAt", 20 "senderAddr", 21 "packetInfo", 22 } 23 } 24 25 func (p *packet) beforeSave() {} 26 27 // +checklocksignore 28 func (p *packet) StateSave(stateSinkObject state.Sink) { 29 p.beforeSave() 30 var receivedAtValue int64 31 receivedAtValue = p.saveReceivedAt() 32 stateSinkObject.SaveValue(2, receivedAtValue) 33 stateSinkObject.Save(0, &p.packetEntry) 34 stateSinkObject.Save(1, &p.data) 35 stateSinkObject.Save(3, &p.senderAddr) 36 stateSinkObject.Save(4, &p.packetInfo) 37 } 38 39 func (p *packet) afterLoad(context.Context) {} 40 41 // +checklocksignore 42 func (p *packet) StateLoad(ctx context.Context, stateSourceObject state.Source) { 43 stateSourceObject.Load(0, &p.packetEntry) 44 stateSourceObject.Load(1, &p.data) 45 stateSourceObject.Load(3, &p.senderAddr) 46 stateSourceObject.Load(4, &p.packetInfo) 47 stateSourceObject.LoadValue(2, new(int64), func(y any) { p.loadReceivedAt(ctx, y.(int64)) }) 48 } 49 50 func (ep *endpoint) StateTypeName() string { 51 return "pkg/tcpip/transport/packet.endpoint" 52 } 53 54 func (ep *endpoint) StateFields() []string { 55 return []string{ 56 "DefaultSocketOptionsHandler", 57 "waiterQueue", 58 "cooked", 59 "ops", 60 "stats", 61 "rcvList", 62 "rcvBufSize", 63 "rcvClosed", 64 "rcvDisabled", 65 "closed", 66 "boundNetProto", 67 "boundNIC", 68 "lastError", 69 } 70 } 71 72 // +checklocksignore 73 func (ep *endpoint) StateSave(stateSinkObject state.Sink) { 74 ep.beforeSave() 75 stateSinkObject.Save(0, &ep.DefaultSocketOptionsHandler) 76 stateSinkObject.Save(1, &ep.waiterQueue) 77 stateSinkObject.Save(2, &ep.cooked) 78 stateSinkObject.Save(3, &ep.ops) 79 stateSinkObject.Save(4, &ep.stats) 80 stateSinkObject.Save(5, &ep.rcvList) 81 stateSinkObject.Save(6, &ep.rcvBufSize) 82 stateSinkObject.Save(7, &ep.rcvClosed) 83 stateSinkObject.Save(8, &ep.rcvDisabled) 84 stateSinkObject.Save(9, &ep.closed) 85 stateSinkObject.Save(10, &ep.boundNetProto) 86 stateSinkObject.Save(11, &ep.boundNIC) 87 stateSinkObject.Save(12, &ep.lastError) 88 } 89 90 // +checklocksignore 91 func (ep *endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source) { 92 stateSourceObject.Load(0, &ep.DefaultSocketOptionsHandler) 93 stateSourceObject.Load(1, &ep.waiterQueue) 94 stateSourceObject.Load(2, &ep.cooked) 95 stateSourceObject.Load(3, &ep.ops) 96 stateSourceObject.Load(4, &ep.stats) 97 stateSourceObject.Load(5, &ep.rcvList) 98 stateSourceObject.Load(6, &ep.rcvBufSize) 99 stateSourceObject.Load(7, &ep.rcvClosed) 100 stateSourceObject.Load(8, &ep.rcvDisabled) 101 stateSourceObject.Load(9, &ep.closed) 102 stateSourceObject.Load(10, &ep.boundNetProto) 103 stateSourceObject.Load(11, &ep.boundNIC) 104 stateSourceObject.Load(12, &ep.lastError) 105 stateSourceObject.AfterLoad(func() { ep.afterLoad(ctx) }) 106 } 107 108 func (l *packetList) StateTypeName() string { 109 return "pkg/tcpip/transport/packet.packetList" 110 } 111 112 func (l *packetList) StateFields() []string { 113 return []string{ 114 "head", 115 "tail", 116 } 117 } 118 119 func (l *packetList) beforeSave() {} 120 121 // +checklocksignore 122 func (l *packetList) StateSave(stateSinkObject state.Sink) { 123 l.beforeSave() 124 stateSinkObject.Save(0, &l.head) 125 stateSinkObject.Save(1, &l.tail) 126 } 127 128 func (l *packetList) afterLoad(context.Context) {} 129 130 // +checklocksignore 131 func (l *packetList) StateLoad(ctx context.Context, stateSourceObject state.Source) { 132 stateSourceObject.Load(0, &l.head) 133 stateSourceObject.Load(1, &l.tail) 134 } 135 136 func (e *packetEntry) StateTypeName() string { 137 return "pkg/tcpip/transport/packet.packetEntry" 138 } 139 140 func (e *packetEntry) StateFields() []string { 141 return []string{ 142 "next", 143 "prev", 144 } 145 } 146 147 func (e *packetEntry) beforeSave() {} 148 149 // +checklocksignore 150 func (e *packetEntry) StateSave(stateSinkObject state.Sink) { 151 e.beforeSave() 152 stateSinkObject.Save(0, &e.next) 153 stateSinkObject.Save(1, &e.prev) 154 } 155 156 func (e *packetEntry) afterLoad(context.Context) {} 157 158 // +checklocksignore 159 func (e *packetEntry) StateLoad(ctx context.Context, stateSourceObject state.Source) { 160 stateSourceObject.Load(0, &e.next) 161 stateSourceObject.Load(1, &e.prev) 162 } 163 164 func init() { 165 state.Register((*packet)(nil)) 166 state.Register((*endpoint)(nil)) 167 state.Register((*packetList)(nil)) 168 state.Register((*packetEntry)(nil)) 169 }