net: if: Connect interface with offloaded socket implementation

Instead of keeping a boolean informing whether a network interface is
offloaded at socket layer or not, keep a pointer to a function which
allows to create an offloaded socket. Native interfaces keep this as
NULL, while for offloaded interfaces it allows to connect an offloaded
socket implementation with an interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2022-03-30 14:16:42 +02:00 committed by Carles Cufí
commit fa8ba73833
10 changed files with 69 additions and 5 deletions

View file

@ -1066,6 +1066,8 @@ static const struct socket_op_vtable offload_socket_fd_op_vtable = {
.setsockopt = NULL,
};
static int offload_socket(int family, int type, int proto);
/* Setup the Modem NET Interface. */
static void modem_net_iface_init(struct net_if *iface)
{
@ -1077,6 +1079,8 @@ static void modem_net_iface_init(struct net_if *iface)
sizeof(data->mac_addr),
NET_LINK_ETHERNET);
data->net_iface = iface;
net_if_socket_offload_set(iface, offload_socket);
}
static struct net_if_api api_funcs = {

View file

@ -62,6 +62,8 @@ static inline uint8_t *modem_get_mac(const struct device *dev)
return data->mac_addr;
}
static int offload_socket(int family, int type, int proto);
/* Setup the Modem NET Interface. */
static void modem_net_iface_init(struct net_if *iface)
{
@ -73,6 +75,8 @@ static void modem_net_iface_init(struct net_if *iface)
data->netif = iface;
socket_offload_dns_register(&offload_dns_ops);
net_if_socket_offload_set(iface, offload_socket);
}
/**

View file

@ -2097,6 +2097,8 @@ static inline uint8_t *modem_get_mac(const struct device *dev)
return data->mac_addr;
}
static int offload_socket(int family, int type, int proto);
static void modem_net_iface_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
@ -2111,6 +2113,8 @@ static void modem_net_iface_init(struct net_if *iface)
#ifdef CONFIG_DNS_RESOLVER
socket_offload_dns_register(&offload_dns_ops);
#endif
net_if_socket_offload_set(iface, offload_socket);
}
static struct net_if_api api_funcs = {