Skip to content
Permalink
Browse files

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>
  • Loading branch information...
tbursztyka authored and jukkar committed Apr 29, 2019
1 parent e44052f commit b17664b1b02c174956e271ffa7d664b515c3ae2a
Showing with 89 additions and 0 deletions.
  1. +89 −0 include/net/net_offload.h
@@ -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

0 comments on commit b17664b

Please sign in to comment.
You can’t perform that action at this time.