summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-07-23 08:45:02 +0000
committerFelix Fietkau2025-07-23 08:45:02 +0000
commit8442c948c19383f374aba54c0843855ef78d0ea2 (patch)
tree0b44fcfdf3397fb4390637a88b43659a0ff4333f
parent184706abaf50d819cfc6218c769c3f99ea2628da (diff)
ucode: add function for getting ring information
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--lib-ucode.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib-ucode.c b/lib-ucode.c
index b696401..b6e258d 100644
--- a/lib-ucode.c
+++ b/lib-ucode.c
@@ -2,6 +2,7 @@
#include <math.h>
#include <libubox/utils.h>
#include <libubox/usock.h>
+#include <libubox/udebug-proto.h>
#include <libubox/udebug.h>
#include <ucode/module.h>
#include "udebug-pcap.h"
@@ -254,6 +255,24 @@ uc_udebug_rbuf_get_flags(uc_vm_t *vm, size_t nargs)
}
static uc_value_t *
+uc_udebug_rbuf_get_info(uc_vm_t *vm, size_t nargs)
+{
+ struct udebug_remote_buf *rb = uc_fn_rbuf(vm);
+ uc_value_t *val;
+
+ if (!rb)
+ return NULL;
+
+ val = ucv_object_new(vm);
+ ucv_object_add(val, "ring_size", ucv_int64_new(rb->buf.hdr->ring_size));
+ ucv_object_add(val, "data_size", ucv_int64_new(rb->buf.hdr->data_size));
+ ucv_object_add(val, "format", ucv_int64_new(rb->buf.hdr->format));
+ ucv_object_add(val, "sub_format", ucv_int64_new(rb->buf.hdr->sub_format));
+
+ return val;
+}
+
+static uc_value_t *
uc_udebug_rbuf_close(uc_vm_t *vm, size_t nargs)
{
struct udebug_remote_buf *rb = uc_fn_rbuf(vm);
@@ -661,6 +680,7 @@ static const uc_function_list_t rbuf_fns[] = {
{ "get_flags", uc_udebug_rbuf_get_flags },
{ "set_fetch_duration", uc_udebug_rbuf_set_fetch_duration },
{ "set_fetch_count", uc_udebug_rbuf_set_fetch_count },
+ { "get_info", uc_udebug_rbuf_get_info },
{ "close", uc_udebug_rbuf_close },
};