Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions subsys/net/ip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,39 @@ config NET_BUF_USER_DATA_SIZE
Example: For Bluetooth, the user_data shall be at least 4 bytes as
that is used for identifying the type of data they are carrying.

choice
prompt "Default Network Interface"
default NET_DEFAULT_IF_FIRST
help
If system has multiple interfaces enabled, then user shall be able
to choose default interface. Otherwise first interface will be the
default interface.

config NET_DEFAULT_IF_FIRST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making this change.

bool "First available interface"

config NET_DEFAULT_IF_ETHERNET
bool "Ethernet"
depends on NET_L2_ETHERNET

config NET_DEFAULT_IF_BLUETOOTH
bool "Bluetooth"
depends on NET_L2_BT

config NET_DEFAULT_IF_IEEE802154
bool "IEEE 802.15.4"
depends on NET_L2_IEEE802154

config NET_DEFAULT_IF_OFFLOAD
bool "Offloaded interface"
depends on NET_L2_OFFLOAD

config NET_DEFAULT_IF_DUMMY
bool "Dummy testing interface"
depends on NET_L2_DUMMY

endchoice

source "subsys/net/ip/Kconfig.stack"

source "subsys/net/ip/l2/Kconfig"
Expand Down
20 changes: 19 additions & 1 deletion subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,29 @@ struct net_if *net_if_lookup_by_dev(struct device *dev)

struct net_if *net_if_get_default(void)
{
struct net_if *iface = NULL;

if (__net_if_start == __net_if_end) {
return NULL;
}

return __net_if_start;
#if defined(CONFIG_NET_DEFAULT_IF_ETHERNET)
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(ETHERNET));
#endif
#if defined(CONFIG_NET_DEFAULT_IF_IEEE802154)
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(IEEE802154));
#endif
#if defined(CONFIG_NET_DEFAULT_IF_BLUETOOTH)
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(BLUETOOTH));
#endif
#if defined(CONFIG_NET_DEFAULT_IF_DUMMY)
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY));
#endif
#if defined(CONFIG_NET_DEFAULT_IF_OFFLOAD)
iface = net_if_get_first_by_type(&NET_L2_GET_NAME(OFFLOAD_IP));
#endif

return iface ? iface : __net_if_start;
}

struct net_if *net_if_get_first_by_type(const struct net_l2 *l2)
Expand Down