// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64

package telematics

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

	"github.com/cilium/ebpf"
)

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

	return spec, err
}

// loadTelematicsObjects loads telematics and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*telematicsObjects
//	*telematicsPrograms
//	*telematicsMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadTelematicsObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadTelematics()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// telematicsSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type telematicsSpecs struct {
	telematicsProgramSpecs
	telematicsMapSpecs
	telematicsVariableSpecs
}

// telematicsProgramSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type telematicsProgramSpecs struct {
	TracepointSyscallsSysEnterConnect  *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_connect"`
	TracepointSyscallsSysEnterExecve   *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_execve"`
	TracepointSyscallsSysEnterMmap     *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_mmap"`
	TracepointSyscallsSysEnterMprotect *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_mprotect"`
	TracepointSyscallsSysEnterRecvfrom *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_recvfrom"`
	TracepointSyscallsSysEnterSendto   *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_enter_sendto"`
	TracepointSyscallsSysExitAccept4   *ebpf.ProgramSpec `ebpf:"tracepoint__syscalls__sys_exit_accept4"`
}

// telematicsMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type telematicsMapSpecs struct {
	AcceptEvents     *ebpf.MapSpec `ebpf:"accept_events"`
	ConnectEvents    *ebpf.MapSpec `ebpf:"connect_events"`
	ExecEvents       *ebpf.MapSpec `ebpf:"exec_events"`
	MmapEvents       *ebpf.MapSpec `ebpf:"mmap_events"`
	MonitoredCgroups *ebpf.MapSpec `ebpf:"monitored_cgroups"`
	MprotectEvents   *ebpf.MapSpec `ebpf:"mprotect_events"`
	SocketDataEvents *ebpf.MapSpec `ebpf:"socket_data_events"`
}

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

// telematicsObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadTelematicsObjects or ebpf.CollectionSpec.LoadAndAssign.
type telematicsObjects struct {
	telematicsPrograms
	telematicsMaps
	telematicsVariables
}

func (o *telematicsObjects) Close() error {
	return _TelematicsClose(
		&o.telematicsPrograms,
		&o.telematicsMaps,
	)
}

// telematicsMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadTelematicsObjects or ebpf.CollectionSpec.LoadAndAssign.
type telematicsMaps struct {
	AcceptEvents     *ebpf.Map `ebpf:"accept_events"`
	ConnectEvents    *ebpf.Map `ebpf:"connect_events"`
	ExecEvents       *ebpf.Map `ebpf:"exec_events"`
	MmapEvents       *ebpf.Map `ebpf:"mmap_events"`
	MonitoredCgroups *ebpf.Map `ebpf:"monitored_cgroups"`
	MprotectEvents   *ebpf.Map `ebpf:"mprotect_events"`
	SocketDataEvents *ebpf.Map `ebpf:"socket_data_events"`
}

func (m *telematicsMaps) Close() error {
	return _TelematicsClose(
		m.AcceptEvents,
		m.ConnectEvents,
		m.ExecEvents,
		m.MmapEvents,
		m.MonitoredCgroups,
		m.MprotectEvents,
		m.SocketDataEvents,
	)
}

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

// telematicsPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadTelematicsObjects or ebpf.CollectionSpec.LoadAndAssign.
type telematicsPrograms struct {
	TracepointSyscallsSysEnterConnect  *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_connect"`
	TracepointSyscallsSysEnterExecve   *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_execve"`
	TracepointSyscallsSysEnterMmap     *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_mmap"`
	TracepointSyscallsSysEnterMprotect *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_mprotect"`
	TracepointSyscallsSysEnterRecvfrom *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_recvfrom"`
	TracepointSyscallsSysEnterSendto   *ebpf.Program `ebpf:"tracepoint__syscalls__sys_enter_sendto"`
	TracepointSyscallsSysExitAccept4   *ebpf.Program `ebpf:"tracepoint__syscalls__sys_exit_accept4"`
}

func (p *telematicsPrograms) Close() error {
	return _TelematicsClose(
		p.TracepointSyscallsSysEnterConnect,
		p.TracepointSyscallsSysEnterExecve,
		p.TracepointSyscallsSysEnterMmap,
		p.TracepointSyscallsSysEnterMprotect,
		p.TracepointSyscallsSysEnterRecvfrom,
		p.TracepointSyscallsSysEnterSendto,
		p.TracepointSyscallsSysExitAccept4,
	)
}

func _TelematicsClose(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 telematics_x86_bpfel.o
var _TelematicsBytes []byte
