// Code generated by bpf2go; DO NOT EDIT.
//go:build (mips || mips64 || ppc64 || s390x) && linux

package tc

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

	"github.com/cilium/ebpf"
)

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

	return spec, err
}

// loadTcObjects loads tc and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*tcObjects
//	*tcPrograms
//	*tcMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadTcObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadTc()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// tcSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcSpecs struct {
	tcProgramSpecs
	tcMapSpecs
	tcVariableSpecs
}

// tcProgramSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcProgramSpecs struct {
	BlockQuic       *ebpf.ProgramSpec `ebpf:"block_quic"`
	ClearTcpSynTs   *ebpf.ProgramSpec `ebpf:"clear_tcp_syn_ts"`
	SetIpIdZero     *ebpf.ProgramSpec `ebpf:"set_ip_id_zero"`
	SetIpTtl        *ebpf.ProgramSpec `ebpf:"set_ip_ttl"`
	SetTcpSynWindow *ebpf.ProgramSpec `ebpf:"set_tcp_syn_window"`
}

// tcMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcMapSpecs struct {
}

// tcVariableSpecs contains global variables before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcVariableSpecs struct {
}

// tcObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadTcObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcObjects struct {
	tcPrograms
	tcMaps
	tcVariables
}

func (o *tcObjects) Close() error {
	return _TcClose(
		&o.tcPrograms,
		&o.tcMaps,
	)
}

// tcMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadTcObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcMaps struct {
}

func (m *tcMaps) Close() error {
	return _TcClose()
}

// tcVariables contains all global variables after they have been loaded into the kernel.
//
// It can be passed to loadTcObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcVariables struct {
}

// tcPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadTcObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcPrograms struct {
	BlockQuic       *ebpf.Program `ebpf:"block_quic"`
	ClearTcpSynTs   *ebpf.Program `ebpf:"clear_tcp_syn_ts"`
	SetIpIdZero     *ebpf.Program `ebpf:"set_ip_id_zero"`
	SetIpTtl        *ebpf.Program `ebpf:"set_ip_ttl"`
	SetTcpSynWindow *ebpf.Program `ebpf:"set_tcp_syn_window"`
}

func (p *tcPrograms) Close() error {
	return _TcClose(
		p.BlockQuic,
		p.ClearTcpSynTs,
		p.SetIpIdZero,
		p.SetIpTtl,
		p.SetTcpSynWindow,
	)
}

func _TcClose(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 tc_bpfeb.o
var _TcBytes []byte
