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

package loader

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

	"github.com/cilium/ebpf"
)

type Ja4TcAcceptEvent struct {
	PidTgid     uint64
	Fd          uint32
	SrcIp       uint32
	SrcPort     uint16
	TimestampNs uint64
}

type Ja4TcAcceptKey struct {
	PidTgid uint64
	Fd      uint32
}

type Ja4TcSslConnInfo struct {
	Fd      uint32
	SrcIp   uint32
	SrcPort uint16
}

type Ja4TcSslReadArgs struct {
	SslPtr uint64
	BufPtr uint64
	Num    uint32
}

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

	return spec, err
}

// LoadJa4TcObjects loads Ja4Tc and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*Ja4TcObjects
//	*Ja4TcPrograms
//	*Ja4TcMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func LoadJa4TcObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := LoadJa4Tc()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// Ja4TcSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type Ja4TcSpecs struct {
	Ja4TcProgramSpecs
	Ja4TcMapSpecs
}

// Ja4TcSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type Ja4TcProgramSpecs struct {
	CaptureXdp *ebpf.ProgramSpec `ebpf:"capture_xdp"`
}

// Ja4TcMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type Ja4TcMapSpecs struct {
	AcceptMap   *ebpf.MapSpec `ebpf:"accept_map"`
	FdConnMap   *ebpf.MapSpec `ebpf:"fd_conn_map"`
	RbAccept    *ebpf.MapSpec `ebpf:"rb_accept"`
	RbHttpPlain *ebpf.MapSpec `ebpf:"rb_http_plain"`
	RbSslData   *ebpf.MapSpec `ebpf:"rb_ssl_data"`
	RbTcpSyn    *ebpf.MapSpec `ebpf:"rb_tcp_syn"`
	RbTlsHello  *ebpf.MapSpec `ebpf:"rb_tls_hello"`
	SslArgsMap  *ebpf.MapSpec `ebpf:"ssl_args_map"`
	SslConnMap  *ebpf.MapSpec `ebpf:"ssl_conn_map"`
}

// Ja4TcObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
type Ja4TcObjects struct {
	Ja4TcPrograms
	Ja4TcMaps
}

func (o *Ja4TcObjects) Close() error {
	return _Ja4TcClose(
		&o.Ja4TcPrograms,
		&o.Ja4TcMaps,
	)
}

// Ja4TcMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
type Ja4TcMaps struct {
	AcceptMap   *ebpf.Map `ebpf:"accept_map"`
	FdConnMap   *ebpf.Map `ebpf:"fd_conn_map"`
	RbAccept    *ebpf.Map `ebpf:"rb_accept"`
	RbHttpPlain *ebpf.Map `ebpf:"rb_http_plain"`
	RbSslData   *ebpf.Map `ebpf:"rb_ssl_data"`
	RbTcpSyn    *ebpf.Map `ebpf:"rb_tcp_syn"`
	RbTlsHello  *ebpf.Map `ebpf:"rb_tls_hello"`
	SslArgsMap  *ebpf.Map `ebpf:"ssl_args_map"`
	SslConnMap  *ebpf.Map `ebpf:"ssl_conn_map"`
}

func (m *Ja4TcMaps) Close() error {
	return _Ja4TcClose(
		m.AcceptMap,
		m.FdConnMap,
		m.RbAccept,
		m.RbHttpPlain,
		m.RbSslData,
		m.RbTcpSyn,
		m.RbTlsHello,
		m.SslArgsMap,
		m.SslConnMap,
	)
}

// Ja4TcPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to LoadJa4TcObjects or ebpf.CollectionSpec.LoadAndAssign.
type Ja4TcPrograms struct {
	CaptureXdp *ebpf.Program `ebpf:"capture_xdp"`
}

func (p *Ja4TcPrograms) Close() error {
	return _Ja4TcClose(
		p.CaptureXdp,
	)
}

func _Ja4TcClose(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 ja4tc_x86_bpfel.o
var _Ja4TcBytes []byte
