aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

commit 4b5760995b79ffa4726432bada697d979f7583ba
parent 12cddc39055e5d740ddde92c1b7ae24100e4cef6
Author: xplshn <anto@xplshn.com.ar>
Date:   Wed, 25 Nov 2026 22:27:44 -0300

net: an interface says whether it is virtual or wireless, and ip link prints it

Diffstat:
Mcmd/net/ip.c | 4++++
Mshared/libutil/net_linux.c | 19++++++++++++++++++-
Mshared/net.h | 4++++
3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/cmd/net/ip.c b/cmd/net/ip.c @@ -55,6 +55,10 @@ print_link_iface(const struct NetInterface *iface) printf("POINTOPOINT "); if (iface->flags & NET_IF_RUNNING) printf("RUNNING "); + if (iface->flags & NET_IF_VIRTUAL) + printf("VIRTUAL "); + if (iface->flags & NET_IF_WIRELESS) + printf("WIRELESS "); printf("\n"); if (iface->has_mac) { printf( diff --git a/shared/libutil/net_linux.c b/shared/libutil/net_linux.c @@ -11,6 +11,7 @@ #include <errno.h> #include <fcntl.h> #include <ifaddrs.h> +#include <limits.h> #include <linux/if_tun.h> #include <net/if.h> #include <net/route.h> @@ -51,6 +52,22 @@ interface_flags_to_linux(unsigned int flags) return linux_flags; } +// what sysfs says the interface is: no device behind it, or a radio +static unsigned int +interface_kind(const char *name) +{ + char path[PATH_MAX]; + unsigned int flags = 0; + + snprintf(path, sizeof(path), "%s/%s/device", ARUU_LINUX_PATH_SYS_CLASS_NET, name); + if (access(path, F_OK) != 0) + flags |= NET_IF_VIRTUAL; + snprintf(path, sizeof(path), "%s/%s/wireless", ARUU_LINUX_PATH_SYS_CLASS_NET, name); + if (access(path, F_OK) == 0) + flags |= NET_IF_WIRELESS; + return flags; +} + static unsigned int interface_flags_from_linux(unsigned int linux_flags) { @@ -129,7 +146,7 @@ net_get_interfaces(struct NetInterface **ifaces, int *count) iface = &list[found_count]; memset(iface, 0, sizeof(*iface)); strlcpy(iface->name, ifa->ifa_name, sizeof(iface->name)); - iface->flags = interface_flags_from_linux(ifa->ifa_flags); + iface->flags = interface_flags_from_linux(ifa->ifa_flags) | interface_kind(iface->name); get_mtu_metric(iface->name, &iface->mtu, &iface->metric); found_count++; } diff --git a/shared/net.h b/shared/net.h @@ -19,6 +19,10 @@ enum NetInterfaceFlag { NET_IF_PROMISC = 0x00000080, NET_IF_ALLMULTI = 0x00000100, NET_IF_MULTICAST = 0x00000200, + // no device behind it (a bridge, a tunnel); unknown is not virtual + NET_IF_VIRTUAL = 0x00000400, + // a radio; unknown is not wireless + NET_IF_WIRELESS = 0x00000800, }; struct NetStats {