// automatically generated by stateify.

package raw

import (
	"context"

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

func (p *rawPacket) StateTypeName() string {
	return "pkg/tcpip/transport/raw.rawPacket"
}

func (p *rawPacket) StateFields() []string {
	return []string{
		"rawPacketEntry",
		"data",
		"receivedAt",
		"senderAddr",
		"packetInfo",
		"tosOrTClass",
		"ttlOrHopLimit",
	}
}

func (p *rawPacket) beforeSave() {}

// +checklocksignore
func (p *rawPacket) StateSave(stateSinkObject state.Sink) {
	p.beforeSave()
	var receivedAtValue int64
	receivedAtValue = p.saveReceivedAt()
	stateSinkObject.SaveValue(2, receivedAtValue)
	stateSinkObject.Save(0, &p.rawPacketEntry)
	stateSinkObject.Save(1, &p.data)
	stateSinkObject.Save(3, &p.senderAddr)
	stateSinkObject.Save(4, &p.packetInfo)
	stateSinkObject.Save(5, &p.tosOrTClass)
	stateSinkObject.Save(6, &p.ttlOrHopLimit)
}

func (p *rawPacket) afterLoad(context.Context) {}

// +checklocksignore
func (p *rawPacket) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &p.rawPacketEntry)
	stateSourceObject.Load(1, &p.data)
	stateSourceObject.Load(3, &p.senderAddr)
	stateSourceObject.Load(4, &p.packetInfo)
	stateSourceObject.Load(5, &p.tosOrTClass)
	stateSourceObject.Load(6, &p.ttlOrHopLimit)
	stateSourceObject.LoadValue(2, new(int64), func(y any) { p.loadReceivedAt(ctx, y.(int64)) })
}

func (e *endpoint) StateTypeName() string {
	return "pkg/tcpip/transport/raw.endpoint"
}

func (e *endpoint) StateFields() []string {
	return []string{
		"DefaultSocketOptionsHandler",
		"stack",
		"transProto",
		"waiterQueue",
		"associated",
		"net",
		"stats",
		"ops",
		"rcvList",
		"rcvBufSize",
		"rcvClosed",
		"rcvDisabled",
		"ipv6ChecksumOffset",
		"icmpv6Filter",
	}
}

// +checklocksignore
func (e *endpoint) StateSave(stateSinkObject state.Sink) {
	e.beforeSave()
	stateSinkObject.Save(0, &e.DefaultSocketOptionsHandler)
	stateSinkObject.Save(1, &e.stack)
	stateSinkObject.Save(2, &e.transProto)
	stateSinkObject.Save(3, &e.waiterQueue)
	stateSinkObject.Save(4, &e.associated)
	stateSinkObject.Save(5, &e.net)
	stateSinkObject.Save(6, &e.stats)
	stateSinkObject.Save(7, &e.ops)
	stateSinkObject.Save(8, &e.rcvList)
	stateSinkObject.Save(9, &e.rcvBufSize)
	stateSinkObject.Save(10, &e.rcvClosed)
	stateSinkObject.Save(11, &e.rcvDisabled)
	stateSinkObject.Save(12, &e.ipv6ChecksumOffset)
	stateSinkObject.Save(13, &e.icmpv6Filter)
}

// +checklocksignore
func (e *endpoint) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &e.DefaultSocketOptionsHandler)
	stateSourceObject.Load(1, &e.stack)
	stateSourceObject.Load(2, &e.transProto)
	stateSourceObject.Load(3, &e.waiterQueue)
	stateSourceObject.Load(4, &e.associated)
	stateSourceObject.Load(5, &e.net)
	stateSourceObject.Load(6, &e.stats)
	stateSourceObject.Load(7, &e.ops)
	stateSourceObject.Load(8, &e.rcvList)
	stateSourceObject.Load(9, &e.rcvBufSize)
	stateSourceObject.Load(10, &e.rcvClosed)
	stateSourceObject.Load(11, &e.rcvDisabled)
	stateSourceObject.Load(12, &e.ipv6ChecksumOffset)
	stateSourceObject.Load(13, &e.icmpv6Filter)
	stateSourceObject.AfterLoad(func() { e.afterLoad(ctx) })
}

func (e *EndpointFactory) StateTypeName() string {
	return "pkg/tcpip/transport/raw.EndpointFactory"
}

func (e *EndpointFactory) StateFields() []string {
	return []string{}
}

func (e *EndpointFactory) beforeSave() {}

// +checklocksignore
func (e *EndpointFactory) StateSave(stateSinkObject state.Sink) {
	e.beforeSave()
}

func (e *EndpointFactory) afterLoad(context.Context) {}

// +checklocksignore
func (e *EndpointFactory) StateLoad(ctx context.Context, stateSourceObject state.Source) {
}

func (c *CreateOnlyFactory) StateTypeName() string {
	return "pkg/tcpip/transport/raw.CreateOnlyFactory"
}

func (c *CreateOnlyFactory) StateFields() []string {
	return []string{}
}

func (c *CreateOnlyFactory) beforeSave() {}

// +checklocksignore
func (c *CreateOnlyFactory) StateSave(stateSinkObject state.Sink) {
	c.beforeSave()
}

func (c *CreateOnlyFactory) afterLoad(context.Context) {}

// +checklocksignore
func (c *CreateOnlyFactory) StateLoad(ctx context.Context, stateSourceObject state.Source) {
}

func (l *rawPacketList) StateTypeName() string {
	return "pkg/tcpip/transport/raw.rawPacketList"
}

func (l *rawPacketList) StateFields() []string {
	return []string{
		"head",
		"tail",
	}
}

func (l *rawPacketList) beforeSave() {}

// +checklocksignore
func (l *rawPacketList) StateSave(stateSinkObject state.Sink) {
	l.beforeSave()
	stateSinkObject.Save(0, &l.head)
	stateSinkObject.Save(1, &l.tail)
}

func (l *rawPacketList) afterLoad(context.Context) {}

// +checklocksignore
func (l *rawPacketList) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &l.head)
	stateSourceObject.Load(1, &l.tail)
}

func (e *rawPacketEntry) StateTypeName() string {
	return "pkg/tcpip/transport/raw.rawPacketEntry"
}

func (e *rawPacketEntry) StateFields() []string {
	return []string{
		"next",
		"prev",
	}
}

func (e *rawPacketEntry) beforeSave() {}

// +checklocksignore
func (e *rawPacketEntry) StateSave(stateSinkObject state.Sink) {
	e.beforeSave()
	stateSinkObject.Save(0, &e.next)
	stateSinkObject.Save(1, &e.prev)
}

func (e *rawPacketEntry) afterLoad(context.Context) {}

// +checklocksignore
func (e *rawPacketEntry) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &e.next)
	stateSourceObject.Load(1, &e.prev)
}

func init() {
	state.Register((*rawPacket)(nil))
	state.Register((*endpoint)(nil))
	state.Register((*EndpointFactory)(nil))
	state.Register((*CreateOnlyFactory)(nil))
	state.Register((*rawPacketList)(nil))
	state.Register((*rawPacketEntry)(nil))
}
