github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/gadgets/snapshot/socket/tracer/socket_bpfel.go (about) 1 // Code generated by bpf2go; DO NOT EDIT. 2 //go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64 3 4 package tracer 5 6 import ( 7 "bytes" 8 _ "embed" 9 "fmt" 10 "io" 11 12 "github.com/cilium/ebpf" 13 ) 14 15 type socketEntry struct { 16 Daddr [16]uint8 17 Saddr [16]uint8 18 Dport uint16 19 Sport uint16 20 Proto uint16 21 Family uint16 22 State uint8 23 _ [7]byte 24 Inode uint64 25 } 26 27 // loadSocket returns the embedded CollectionSpec for socket. 28 func loadSocket() (*ebpf.CollectionSpec, error) { 29 reader := bytes.NewReader(_SocketBytes) 30 spec, err := ebpf.LoadCollectionSpecFromReader(reader) 31 if err != nil { 32 return nil, fmt.Errorf("can't load socket: %w", err) 33 } 34 35 return spec, err 36 } 37 38 // loadSocketObjects loads socket and converts it into a struct. 39 // 40 // The following types are suitable as obj argument: 41 // 42 // *socketObjects 43 // *socketPrograms 44 // *socketMaps 45 // 46 // See ebpf.CollectionSpec.LoadAndAssign documentation for details. 47 func loadSocketObjects(obj interface{}, opts *ebpf.CollectionOptions) error { 48 spec, err := loadSocket() 49 if err != nil { 50 return err 51 } 52 53 return spec.LoadAndAssign(obj, opts) 54 } 55 56 // socketSpecs contains maps and programs before they are loaded into the kernel. 57 // 58 // It can be passed ebpf.CollectionSpec.Assign. 59 type socketSpecs struct { 60 socketProgramSpecs 61 socketMapSpecs 62 } 63 64 // socketSpecs contains programs before they are loaded into the kernel. 65 // 66 // It can be passed ebpf.CollectionSpec.Assign. 67 type socketProgramSpecs struct { 68 IgSnapTcp *ebpf.ProgramSpec `ebpf:"ig_snap_tcp"` 69 IgSnapUdp *ebpf.ProgramSpec `ebpf:"ig_snap_udp"` 70 } 71 72 // socketMapSpecs contains maps before they are loaded into the kernel. 73 // 74 // It can be passed ebpf.CollectionSpec.Assign. 75 type socketMapSpecs struct { 76 } 77 78 // socketObjects contains all objects after they have been loaded into the kernel. 79 // 80 // It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign. 81 type socketObjects struct { 82 socketPrograms 83 socketMaps 84 } 85 86 func (o *socketObjects) Close() error { 87 return _SocketClose( 88 &o.socketPrograms, 89 &o.socketMaps, 90 ) 91 } 92 93 // socketMaps contains all maps after they have been loaded into the kernel. 94 // 95 // It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign. 96 type socketMaps struct { 97 } 98 99 func (m *socketMaps) Close() error { 100 return _SocketClose() 101 } 102 103 // socketPrograms contains all programs after they have been loaded into the kernel. 104 // 105 // It can be passed to loadSocketObjects or ebpf.CollectionSpec.LoadAndAssign. 106 type socketPrograms struct { 107 IgSnapTcp *ebpf.Program `ebpf:"ig_snap_tcp"` 108 IgSnapUdp *ebpf.Program `ebpf:"ig_snap_udp"` 109 } 110 111 func (p *socketPrograms) Close() error { 112 return _SocketClose( 113 p.IgSnapTcp, 114 p.IgSnapUdp, 115 ) 116 } 117 118 func _SocketClose(closers ...io.Closer) error { 119 for _, closer := range closers { 120 if err := closer.Close(); err != nil { 121 return err 122 } 123 } 124 return nil 125 } 126 127 // Do not access this directly. 128 // 129 //go:embed socket_bpfel.o 130 var _SocketBytes []byte