net: context: Refactor because of timeout overhaul

The net_context API will change, the s32_t timeout parameter
will be changed to k_timeout_t. All the Zephyr users of this API will
be changed in subsequent commits. This is internal Zephyr API only,
so the API is not deprecated etc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2020-04-03 10:48:00 +03:00
commit e56fa75ade
5 changed files with 81 additions and 48 deletions

View file

@ -866,7 +866,7 @@ int net_context_connect(struct net_context *context,
const struct sockaddr *addr,
socklen_t addrlen,
net_context_connect_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**
@ -896,7 +896,7 @@ int net_context_connect(struct net_context *context,
*/
int net_context_accept(struct net_context *context,
net_tcp_accept_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**
@ -922,7 +922,7 @@ int net_context_send(struct net_context *context,
const void *buf,
size_t len,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**
@ -952,7 +952,7 @@ int net_context_sendto(struct net_context *context,
const struct sockaddr *dst_addr,
socklen_t addrlen,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**
@ -977,7 +977,7 @@ int net_context_sendmsg(struct net_context *context,
const struct msghdr *msghdr,
int flags,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**
@ -1018,7 +1018,7 @@ int net_context_sendmsg(struct net_context *context,
*/
int net_context_recv(struct net_context *context,
net_context_recv_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data);
/**

View file

@ -219,15 +219,21 @@ static inline int net_offload_connect(struct net_if *iface,
const struct sockaddr *addr,
socklen_t addrlen,
net_context_connect_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
NET_ASSERT(iface);
NET_ASSERT(net_if_offload(iface));
NET_ASSERT(net_if_offload(iface)->connect);
return net_if_offload(iface)->connect(context, addr, addrlen, cb,
timeout, user_data);
return net_if_offload(iface)->connect(
context, addr, addrlen, cb,
#ifdef CONFIG_LEGACY_TIMEOUT_API
Z_TIMEOUT_MS(timeout),
#else
k_ticks_to_ms_floor64(timeout.ticks),
#endif
user_data);
}
/**
@ -260,14 +266,21 @@ static inline int net_offload_connect(struct net_if *iface,
static inline int net_offload_accept(struct net_if *iface,
struct net_context *context,
net_tcp_accept_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
NET_ASSERT(iface);
NET_ASSERT(net_if_offload(iface));
NET_ASSERT(net_if_offload(iface)->accept);
return net_if_offload(iface)->accept(context, cb, timeout, user_data);
return net_if_offload(iface)->accept(
context, cb,
#ifdef CONFIG_LEGACY_TIMEOUT_API
Z_TIMEOUT_MS(timeout),
#else
k_ticks_to_ms_floor64(timeout.ticks),
#endif
user_data);
}
/**
@ -299,14 +312,21 @@ static inline int net_offload_accept(struct net_if *iface,
static inline int net_offload_send(struct net_if *iface,
struct net_pkt *pkt,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
NET_ASSERT(iface);
NET_ASSERT(net_if_offload(iface));
NET_ASSERT(net_if_offload(iface)->send);
return net_if_offload(iface)->send(pkt, cb, timeout, user_data);
return net_if_offload(iface)->send(
pkt, cb,
#ifdef CONFIG_LEGACY_TIMEOUT_API
Z_TIMEOUT_MS(timeout),
#else
k_ticks_to_ms_floor64(timeout.ticks),
#endif
user_data);
}
/**
@ -342,15 +362,21 @@ static inline int net_offload_sendto(struct net_if *iface,
const struct sockaddr *dst_addr,
socklen_t addrlen,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
NET_ASSERT(iface);
NET_ASSERT(net_if_offload(iface));
NET_ASSERT(net_if_offload(iface)->sendto);
return net_if_offload(iface)->sendto(pkt, dst_addr, addrlen, cb,
timeout, user_data);
return net_if_offload(iface)->sendto(
pkt, dst_addr, addrlen, cb,
#ifdef CONFIG_LEGACY_TIMEOUT_API
Z_TIMEOUT_MS(timeout),
#else
k_ticks_to_ms_floor64(timeout.ticks),
#endif
user_data);
}
/**
@ -389,14 +415,21 @@ static inline int net_offload_sendto(struct net_if *iface,
static inline int net_offload_recv(struct net_if *iface,
struct net_context *context,
net_context_recv_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
NET_ASSERT(iface);
NET_ASSERT(net_if_offload(iface));
NET_ASSERT(net_if_offload(iface)->recv);
return net_if_offload(iface)->recv(context, cb, timeout, user_data);
return net_if_offload(iface)->recv(
context, cb,
#ifdef CONFIG_LEGACY_TIMEOUT_API
Z_TIMEOUT_MS(timeout),
#else
k_ticks_to_ms_floor64(timeout.ticks),
#endif
user_data);
}
/**
@ -455,7 +488,7 @@ static inline int net_offload_connect(struct net_if *iface,
const struct sockaddr *addr,
socklen_t addrlen,
net_context_connect_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
return 0;
@ -464,7 +497,7 @@ static inline int net_offload_connect(struct net_if *iface,
static inline int net_offload_accept(struct net_if *iface,
struct net_context *context,
net_tcp_accept_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
return 0;
@ -473,7 +506,7 @@ static inline int net_offload_accept(struct net_if *iface,
static inline int net_offload_send(struct net_if *iface,
struct net_pkt *pkt,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
return 0;
@ -484,7 +517,7 @@ static inline int net_offload_sendto(struct net_if *iface,
const struct sockaddr *dst_addr,
socklen_t addrlen,
net_context_send_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
return 0;
@ -493,7 +526,7 @@ static inline int net_offload_sendto(struct net_if *iface,
static inline int net_offload_recv(struct net_if *iface,
struct net_context *context,
net_context_recv_cb_t cb,
s32_t timeout,
k_timeout_t timeout,
void *user_data)
{
return 0;