// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64 || wasm

package bpf

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"
	"structs"

	"github.com/cilium/ebpf"
)

type SockTermIpv4RevnatEntry struct {
	_           structs.HostLayout
	Address     uint32
	Port        uint16
	RevNatIndex uint16
}

type SockTermIpv4RevnatTuple struct {
	_       structs.HostLayout
	Cookie  uint64
	Address uint32
	Port    uint16
	Pad     uint16
}

type SockTermIpv6RevnatEntry struct {
	_       structs.HostLayout
	Address struct {
		_    structs.HostLayout
		Addr [16]uint8
	}
	Port        uint16
	RevNatIndex uint16
}

type SockTermIpv6RevnatTuple struct {
	_       structs.HostLayout
	Cookie  uint64
	Address struct {
		_    structs.HostLayout
		Addr [16]uint8
	}
	Port uint16
	Pad  uint16
	_    [4]byte
}

type SockTermSockTermFilter struct {
	_       structs.HostLayout
	Address struct {
		_     structs.HostLayout
		Addr6 struct {
			_    structs.HostLayout
			Addr [16]uint8
		}
	}
	Port          uint16
	AddressFamily uint8
	_             [1]byte
}

// LoadSockTerm returns the embedded CollectionSpec for SockTerm.
func LoadSockTerm() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_SockTermBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load SockTerm: %w", err)
	}

	return spec, err
}

// LoadSockTermObjects loads SockTerm and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*SockTermObjects
//	*SockTermPrograms
//	*SockTermMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func LoadSockTermObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := LoadSockTerm()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// SockTermSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type SockTermSpecs struct {
	SockTermProgramSpecs
	SockTermMapSpecs
	SockTermVariableSpecs
}

// SockTermProgramSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type SockTermProgramSpecs struct {
	CilSockTcpDestroyV4 *ebpf.ProgramSpec `ebpf:"cil_sock_tcp_destroy_v4"`
	CilSockTcpDestroyV6 *ebpf.ProgramSpec `ebpf:"cil_sock_tcp_destroy_v6"`
	CilSockUdpDestroyV4 *ebpf.ProgramSpec `ebpf:"cil_sock_udp_destroy_v4"`
	CilSockUdpDestroyV6 *ebpf.ProgramSpec `ebpf:"cil_sock_udp_destroy_v6"`
}

// SockTermMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type SockTermMapSpecs struct {
	CiliumLb4ReverseSk *ebpf.MapSpec `ebpf:"cilium_lb4_reverse_sk"`
	CiliumLb6ReverseSk *ebpf.MapSpec `ebpf:"cilium_lb6_reverse_sk"`
}

// SockTermVariableSpecs contains global variables before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type SockTermVariableSpecs struct {
	CiliumSockTermFilter *ebpf.VariableSpec `ebpf:"cilium_sock_term_filter"`
}

// SockTermObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to LoadSockTermObjects or ebpf.CollectionSpec.LoadAndAssign.
type SockTermObjects struct {
	SockTermPrograms
	SockTermMaps
	SockTermVariables
}

func (o *SockTermObjects) Close() error {
	return _SockTermClose(
		&o.SockTermPrograms,
		&o.SockTermMaps,
	)
}

// SockTermMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to LoadSockTermObjects or ebpf.CollectionSpec.LoadAndAssign.
type SockTermMaps struct {
	CiliumLb4ReverseSk *ebpf.Map `ebpf:"cilium_lb4_reverse_sk"`
	CiliumLb6ReverseSk *ebpf.Map `ebpf:"cilium_lb6_reverse_sk"`
}

func (m *SockTermMaps) Close() error {
	return _SockTermClose(
		m.CiliumLb4ReverseSk,
		m.CiliumLb6ReverseSk,
	)
}

// SockTermVariables contains all global variables after they have been loaded into the kernel.
//
// It can be passed to LoadSockTermObjects or ebpf.CollectionSpec.LoadAndAssign.
type SockTermVariables struct {
	CiliumSockTermFilter *ebpf.Variable `ebpf:"cilium_sock_term_filter"`
}

// SockTermPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to LoadSockTermObjects or ebpf.CollectionSpec.LoadAndAssign.
type SockTermPrograms struct {
	CilSockTcpDestroyV4 *ebpf.Program `ebpf:"cil_sock_tcp_destroy_v4"`
	CilSockTcpDestroyV6 *ebpf.Program `ebpf:"cil_sock_tcp_destroy_v6"`
	CilSockUdpDestroyV4 *ebpf.Program `ebpf:"cil_sock_udp_destroy_v4"`
	CilSockUdpDestroyV6 *ebpf.Program `ebpf:"cil_sock_udp_destroy_v6"`
}

func (p *SockTermPrograms) Close() error {
	return _SockTermClose(
		p.CilSockTcpDestroyV4,
		p.CilSockTcpDestroyV6,
		p.CilSockUdpDestroyV4,
		p.CilSockUdpDestroyV6,
	)
}

func _SockTermClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed sockterm_bpfel.o
var _SockTermBytes []byte
