net: sockets: Add separate macro for registering offloaded sockets
Add a separate macro for registering offloaded sockets implementation, along with information in the structure whether the implementation is offloaded or not. This allows to differentiate between native and offloaded socket implementations, which is critical for binding socket API with an interface. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
fa8ba73833
commit
7946988b16
|
@ -1207,5 +1207,5 @@ NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, modem_init, NULL,
|
|||
&api_funcs, MDM_MAX_DATA_LENGTH);
|
||||
|
||||
/* Register NET sockets. */
|
||||
NET_SOCKET_REGISTER(quectel_bg9x, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
offload_is_supported, offload_socket);
|
||||
NET_SOCKET_OFFLOAD_REGISTER(quectel_bg9x, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY,
|
||||
AF_UNSPEC, offload_is_supported, offload_socket);
|
||||
|
|
|
@ -2399,5 +2399,5 @@ NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, modem_init, NULL, &mdata, NULL,
|
|||
CONFIG_MODEM_SIMCOM_SIM7080_INIT_PRIORITY, &api_funcs,
|
||||
MDM_MAX_DATA_LENGTH);
|
||||
|
||||
NET_SOCKET_REGISTER(simcom_sim7080, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
offload_is_supported, offload_socket);
|
||||
NET_SOCKET_OFFLOAD_REGISTER(simcom_sim7080, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY,
|
||||
AF_UNSPEC, offload_is_supported, offload_socket);
|
||||
|
|
|
@ -1966,8 +1966,8 @@ static bool offload_is_supported(int family, int type, int proto)
|
|||
return true;
|
||||
}
|
||||
|
||||
NET_SOCKET_REGISTER(ublox_sara_r4, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
offload_is_supported, offload_socket);
|
||||
NET_SOCKET_OFFLOAD_REGISTER(ublox_sara_r4, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY,
|
||||
AF_UNSPEC, offload_is_supported, offload_socket);
|
||||
|
||||
#if defined(CONFIG_DNS_RESOLVER)
|
||||
/* TODO: This is a bare-bones implementation of DNS handling
|
||||
|
|
|
@ -588,8 +588,8 @@ static const struct socket_op_vtable eswifi_socket_fd_op_vtable = {
|
|||
};
|
||||
|
||||
#ifdef CONFIG_NET_SOCKETS_OFFLOAD
|
||||
NET_SOCKET_REGISTER(eswifi, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
eswifi_socket_is_supported, eswifi_socket_create);
|
||||
NET_SOCKET_OFFLOAD_REGISTER(eswifi, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
eswifi_socket_is_supported, eswifi_socket_create);
|
||||
#endif
|
||||
|
||||
static int eswifi_off_getaddrinfo(const char *node, const char *service,
|
||||
|
|
|
@ -1304,8 +1304,8 @@ static int simplelink_socket_accept(void *obj, struct sockaddr *addr,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_NET_SOCKETS_OFFLOAD
|
||||
NET_SOCKET_REGISTER(simplelink, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
simplelink_is_supported, simplelink_socket_create);
|
||||
NET_SOCKET_OFFLOAD_REGISTER(simplelink, CONFIG_NET_SOCKETS_OFFLOAD_PRIORITY, AF_UNSPEC,
|
||||
simplelink_is_supported, simplelink_socket_create);
|
||||
#endif
|
||||
|
||||
void simplelink_sockets_init(void)
|
||||
|
|
|
@ -934,6 +934,7 @@ struct ifreq {
|
|||
*/
|
||||
struct net_socket_register {
|
||||
int family;
|
||||
bool is_offloaded;
|
||||
bool (*is_supported)(int family, int type, int proto);
|
||||
int (*handler)(int family, int type, int proto);
|
||||
};
|
||||
|
@ -943,14 +944,21 @@ struct net_socket_register {
|
|||
#define NET_SOCKET_GET_NAME(socket_name, prio) \
|
||||
__net_socket_register_##prio##_##socket_name
|
||||
|
||||
#define NET_SOCKET_REGISTER(socket_name, prio, _family, _is_supported, _handler) \
|
||||
#define _NET_SOCKET_REGISTER(socket_name, prio, _family, _is_supported, _handler, _is_offloaded) \
|
||||
static const STRUCT_SECTION_ITERABLE(net_socket_register, \
|
||||
NET_SOCKET_GET_NAME(socket_name, prio)) = { \
|
||||
NET_SOCKET_GET_NAME(socket_name, prio)) = { \
|
||||
.family = _family, \
|
||||
.is_offloaded = _is_offloaded, \
|
||||
.is_supported = _is_supported, \
|
||||
.handler = _handler, \
|
||||
}
|
||||
|
||||
#define NET_SOCKET_REGISTER(socket_name, prio, _family, _is_supported, _handler) \
|
||||
_NET_SOCKET_REGISTER(socket_name, prio, _family, _is_supported, _handler, false)
|
||||
|
||||
#define NET_SOCKET_OFFLOAD_REGISTER(socket_name, prio, _family, _is_supported, _handler) \
|
||||
_NET_SOCKET_REGISTER(socket_name, prio, _family, _is_supported, _handler, true)
|
||||
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in a new issue