Skip to content

Commit 54ad361

Browse files
committed
avoid hardcoding network interfaces count
1 parent f5cf37b commit 54ad361

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

libraries/SocketWrapper/Ethernet.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ class EthernetClass: public NetworkInterface
4545

4646
EthernetHardwareStatus hardwareStatus() {
4747
const struct device *const dev = DEVICE_DT_GET(DT_COMPAT_GET_ANY_STATUS_OKAY(ethernet_phy));
48+
int if_count;
49+
NET_IFACE_COUNT(&if_count);
4850
if (device_is_ready(dev)) {
49-
for (int i = 1; i <= 3; i++) {
51+
for (int i = 1; i <= if_count; i++) {
5052
auto _if = net_if_get_by_index(i);
51-
if ((_if != nullptr) && !net_eth_type_is_wifi(_if)) {
53+
if (!net_eth_type_is_wifi(_if)) {
5254
netif = _if;
5355
break;
5456
}

loader/llext_exports.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ FORCE_EXPORT_SYM(net_if_ipv4_set_gw);
7676
FORCE_EXPORT_SYM(net_if_ipv4_addr_add);
7777
FORCE_EXPORT_SYM(net_if_ipv4_set_netmask_by_addr);
7878
FORCE_EXPORT_SYM(net_if_lookup_by_dev);
79+
FORCE_EXPORT_SYM(_net_if_list_start);
80+
FORCE_EXPORT_SYM(_net_if_list_end);
7981
#endif
8082

8183
#if defined(CONFIG_NET_L2_ETHERNET)

0 commit comments

Comments
 (0)