net/offload: Add dummy functions when offloading is disabled

Thit will help removing usage of #if defined(CONFIG_NET_OFFLOAD) in
relevant places.

Note that static inlines are used instead of #define foo(...), to keep
the parameter check at build time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2019-04-29 10:30:38 +02:00 committed by Jukka Rissanen
parent e44052f25a
commit b17664b1b0

View file

@ -27,6 +27,8 @@
extern "C" {
#endif
#if defined(CONFIG_NET_OFFLOAD)
/** For return parameters and return values of the elements in this
* struct, see similarly named functions in net_context.h
*/
@ -420,6 +422,93 @@ static inline int net_offload_put(struct net_if *iface,
return net_if_offload(iface)->put(context);
}
#else
/** @cond INTERNAL_HIDDEN */
static inline int net_offload_get(struct net_if *iface,
sa_family_t family,
enum net_sock_type type,
enum net_ip_protocol ip_proto,
struct net_context **context)
{
return 0;
}
static inline int net_offload_bind(struct net_if *iface,
struct net_context *context,
const struct sockaddr *addr,
socklen_t addrlen)
{
return 0;
}
static inline int net_offload_listen(struct net_if *iface,
struct net_context *context,
int backlog)
{
return 0;
}
static inline int net_offload_connect(struct net_if *iface,
struct net_context *context,
const struct sockaddr *addr,
socklen_t addrlen,
net_context_connect_cb_t cb,
s32_t timeout,
void *user_data)
{
return 0;
}
static inline int net_offload_accept(struct net_if *iface,
struct net_context *context,
net_tcp_accept_cb_t cb,
s32_t timeout,
void *user_data)
{
return 0;
}
static inline int net_offload_send(struct net_if *iface,
struct net_pkt *pkt,
net_context_send_cb_t cb,
s32_t timeout,
void *user_data)
{
return 0;
}
static inline int net_offload_sendto(struct net_if *iface,
struct net_pkt *pkt,
const struct sockaddr *dst_addr,
socklen_t addrlen,
net_context_send_cb_t cb,
s32_t timeout,
void *user_data)
{
return 0;
}
static inline int net_offload_recv(struct net_if *iface,
struct net_context *context,
net_context_recv_cb_t cb,
s32_t timeout,
void *user_data)
{
return 0;
}
static inline int net_offload_put(struct net_if *iface,
struct net_context *context)
{
return 0;
}
/** @endcond */
#endif /* CONFIG_NET_OFFLOAD */
#ifdef __cplusplus
}
#endif