From ea33faff11e0d7b385000e5cfbd18e9da686ff6e Mon Sep 17 00:00:00 2001 From: Anjan Chanda <anjan.chanda@iopsys.eu> Date: Thu, 9 Nov 2023 13:04:52 +0100 Subject: [PATCH] show base interface for WiFi 4addr interfaces --- src/ubus.c | 9 +++++++++ src/wifi_api.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/ubus.c b/src/ubus.c index 1a5216c..c315785 100644 --- a/src/ubus.c +++ b/src/ubus.c @@ -29,6 +29,7 @@ #include <easy/easy.h> +#include "wifi_api.h" #include "util.h" #include "debug.h" #include "timer.h" @@ -736,6 +737,14 @@ int hostmngr_ubus_show_hosts(struct ubus_context *ctx, struct ubus_object *obj, blobmsg_add_string(&bb, "device", e->ifname); ifname = e->ifname; } + + if (is_wifi_interface(ifname) == 1) { + char pifname[16] = {0}; + + interface_get_4addr_parent(ifname, pifname); + blobmsg_add_string(&bb, "parent_device", pifname); + } + net = hostmngr_ifname_to_network(p, ifname); blobmsg_add_string(&bb, "network", net ? net : ""); diff --git a/src/wifi_api.c b/src/wifi_api.c index 70c032e..21e1e72 100644 --- a/src/wifi_api.c +++ b/src/wifi_api.c @@ -65,6 +65,9 @@ int is_wifi_interface(const char *ifname) char rpath[PATH_MAX] = {0}; struct stat s; + if (!ifname) + return 0; + memset(&s, 0, sizeof(struct stat)); snprintf(path, 512, "/sys/class/net/%s/phy80211", ifname); if (!realpath(path, rpath)) @@ -90,6 +93,9 @@ int is_ap_interface(const char *ifname) enum wifi_mode mode; int ret; + if (!ifname) + return 0; + ret = wifi_get_mode(ifname, &mode); if (!ret) { if (mode == WIFI_MODE_AP || mode == WIFI_MODE_AP_VLAN) -- GitLab