aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/declextract/interface.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/declextract/interface.go')
-rw-r--r--pkg/declextract/interface.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkg/declextract/interface.go b/pkg/declextract/interface.go
new file mode 100644
index 000000000..dfb223d16
--- /dev/null
+++ b/pkg/declextract/interface.go
@@ -0,0 +1,46 @@
+// Copyright 2024 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package declextract
+
+import (
+ "slices"
+)
+
+type Interface struct {
+ Type string
+ Name string
+ IdentifyingConst string
+ Files []string
+ Func string
+ Access string
+ Subsystems []string
+ ManualDescriptions bool
+ AutoDescriptions bool
+}
+
+const (
+ IfaceSyscall = "SYSCALL"
+ IfaceNetlinkOp = "NETLINK"
+ IfaceIouring = "IOURING"
+
+ AccessUnknown = "unknown"
+ AccessUser = "user"
+ AccessNsAdmin = "ns_admin"
+ AccessAdmin = "admin"
+)
+
+func (ctx *context) noteInterface(iface *Interface) {
+ ctx.interfaces = append(ctx.interfaces, iface)
+}
+
+func (ctx *context) finishInterfaces() {
+ for _, iface := range ctx.interfaces {
+ slices.Sort(iface.Files)
+ iface.Files = slices.Compact(iface.Files)
+ if iface.Access == "" {
+ iface.Access = AccessUnknown
+ }
+ }
+ ctx.interfaces = sortAndDedupSlice(ctx.interfaces)
+}