move helper annotations to helpers module

This commit is contained in:
2025-10-02 01:55:32 +05:30
parent 23f3cbcea7
commit 1a66887f48
12 changed files with 22 additions and 11 deletions

View File

@ -1,4 +1,13 @@
from .helper_utils import HelperHandlerRegistry
from .bpf_helper_handler import handle_helper_call
from .helpers import ktime, pid, deref, XDP_DROP, XDP_PASS
__all__ = ["HelperHandlerRegistry", "handle_helper_call"]
__all__ = [
"HelperHandlerRegistry",
"handle_helper_call",
"ktime",
"pid",
"deref",
"XDP_DROP",
"XDP_PASS",
]

View File

@ -0,0 +1,19 @@
import ctypes
def ktime():
return ctypes.c_int64(0)
def pid():
return ctypes.c_int32(0)
def deref(ptr):
"dereference a pointer"
result = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_void_p)).contents.value
return result if result is not None else 0
XDP_DROP = ctypes.c_int64(1)
XDP_PASS = ctypes.c_int64(2)