// automatically generated by stateify.

package packetmmap

import (
	"context"

	"gvisor.dev/gvisor/pkg/state"
)

func (m *Endpoint) StateTypeName() string {
	return "pkg/sentry/socket/netstack/packetmmap.Endpoint"
}

func (m *Endpoint) StateFields() []string {
	return []string{
		"rxRingBuffer",
		"txRingBuffer",
		"mapped",
		"mode",
		"cooked",
		"stack",
		"packetEP",
		"reserve",
		"version",
		"headerLen",
		"received",
		"dropped",
		"wq",
		"mappings",
	}
}

func (m *Endpoint) beforeSave() {}

// +checklocksignore
func (m *Endpoint) StateSave(stateSinkObject state.Sink) {
	m.beforeSave()
	stateSinkObject.Save(0, &m.rxRingBuffer)
	stateSinkObject.Save(1, &m.txRingBuffer)
	stateSinkObject.Save(2, &m.mapped)
	stateSinkObject.Save(3, &m.mode)
	stateSinkObject.Save(4, &m.cooked)
	stateSinkObject.Save(5, &m.stack)
	stateSinkObject.Save(6, &m.packetEP)
	stateSinkObject.Save(7, &m.reserve)
	stateSinkObject.Save(8, &m.version)
	stateSinkObject.Save(9, &m.headerLen)
	stateSinkObject.Save(10, &m.received)
	stateSinkObject.Save(11, &m.dropped)
	stateSinkObject.Save(12, &m.wq)
	stateSinkObject.Save(13, &m.mappings)
}

func (m *Endpoint) afterLoad(context.Context) {}

// +checklocksignore
func (m *Endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &m.rxRingBuffer)
	stateSourceObject.Load(1, &m.txRingBuffer)
	stateSourceObject.Load(2, &m.mapped)
	stateSourceObject.Load(3, &m.mode)
	stateSourceObject.Load(4, &m.cooked)
	stateSourceObject.Load(5, &m.stack)
	stateSourceObject.Load(6, &m.packetEP)
	stateSourceObject.Load(7, &m.reserve)
	stateSourceObject.Load(8, &m.version)
	stateSourceObject.Load(9, &m.headerLen)
	stateSourceObject.Load(10, &m.received)
	stateSourceObject.Load(11, &m.dropped)
	stateSourceObject.Load(12, &m.wq)
	stateSourceObject.Load(13, &m.mappings)
}

func (rb *ringBuffer) StateTypeName() string {
	return "pkg/sentry/socket/netstack/packetmmap.ringBuffer"
}

func (rb *ringBuffer) StateFields() []string {
	return []string{
		"framesPerBlock",
		"frameSize",
		"frameMax",
		"blockSize",
		"head",
		"rxOwnerMap",
		"size",
		"mapping",
		"data",
	}
}

func (rb *ringBuffer) beforeSave() {}

// +checklocksignore
func (rb *ringBuffer) StateSave(stateSinkObject state.Sink) {
	rb.beforeSave()
	stateSinkObject.Save(0, &rb.framesPerBlock)
	stateSinkObject.Save(1, &rb.frameSize)
	stateSinkObject.Save(2, &rb.frameMax)
	stateSinkObject.Save(3, &rb.blockSize)
	stateSinkObject.Save(4, &rb.head)
	stateSinkObject.Save(5, &rb.rxOwnerMap)
	stateSinkObject.Save(6, &rb.size)
	stateSinkObject.Save(7, &rb.mapping)
	stateSinkObject.Save(8, &rb.data)
}

// +checklocksignore
func (rb *ringBuffer) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &rb.framesPerBlock)
	stateSourceObject.Load(1, &rb.frameSize)
	stateSourceObject.Load(2, &rb.frameMax)
	stateSourceObject.Load(3, &rb.blockSize)
	stateSourceObject.Load(4, &rb.head)
	stateSourceObject.Load(5, &rb.rxOwnerMap)
	stateSourceObject.Load(6, &rb.size)
	stateSourceObject.Load(7, &rb.mapping)
	stateSourceObject.Load(8, &rb.data)
	stateSourceObject.AfterLoad(func() { rb.afterLoad(ctx) })
}

func init() {
	state.Register((*Endpoint)(nil))
	state.Register((*ringBuffer)(nil))
}
