summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-02-16 00:47:08 +0200
committerPaul Buetow <paul@buetow.org>2024-02-16 00:47:08 +0200
commit02707dde82ed3030aa66d8155928f364cefe143d (patch)
tree312c20bb8677597e4b2cf7f4195148bde7a74cd4 /internal
parent5818548de594c17e4b6f5cfc3cf25ae0702e2e3d (diff)
move flags to types
Diffstat (limited to 'internal')
-rw-r--r--internal/flags/flags.go13
-rw-r--r--internal/types/types.go4
2 files changed, 9 insertions, 8 deletions
diff --git a/internal/flags/flags.go b/internal/flags/flags.go
index ac7abd4..d50410b 100644
--- a/internal/flags/flags.go
+++ b/internal/flags/flags.go
@@ -3,6 +3,7 @@ package flags
import (
"flag"
"fmt"
+ "ioriotng/internal/types"
"unsafe"
bpf "github.com/aquasecurity/libbpfgo"
@@ -17,6 +18,7 @@ func New() (flags Flags) {
flag.IntVar(&flags.UidFilter, "uid", 0, "Filter for processes with UID")
flag.IntVar(&flags.EventMapSize, "mapSize", 4096, "BPF FD event ring buffer map size")
flag.Parse()
+
return flags
}
@@ -26,13 +28,10 @@ func (flags Flags) SetBPF(bpfModule *bpf.Module) error {
return err
}
- flagsValues := struct {
- UidFilter int32
- }{
- UidFilter: int32(flags.UidFilter),
- }
-
- key := uint32(1)
+ var (
+ key = uint32(1)
+ flagsValues = types.FlagValues{uint32(flags.UidFilter)}
+ )
return flagsMap.Update(unsafe.Pointer(&key), unsafe.Pointer(&flagsValues))
}
diff --git a/internal/types/types.go b/internal/types/types.go
index 473339f..2339727 100644
--- a/internal/types/types.go
+++ b/internal/types/types.go
@@ -29,6 +29,8 @@ type OpenatEnterEvent struct {
Comm [MAX_PROGNAME_LENGTH]byte
}
-// TODO: Move Flags type struct to here, too
+type FlagValues struct {
+ UidFilter uint32
+}
// duration := float64(e.ExitTime-e.EnterTime) / float64(1_000_000)