net/context: Remove token parameter from net_context_send/sendto
And also to the relevant callbacks. That parameter is not used anywhere so it is useless. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
7d97a1871a
commit
03bfc5dd0f
@ -207,7 +207,7 @@ static void telnet_send_prematurely(struct k_timer *timer)
|
||||
}
|
||||
|
||||
static void telnet_sent_cb(struct net_context *client,
|
||||
int status, void *token, void *user_data)
|
||||
int status, void *user_data)
|
||||
{
|
||||
if (status) {
|
||||
telnet_end_client_connection();
|
||||
@ -223,7 +223,7 @@ static inline bool telnet_send(void)
|
||||
if (net_context_send(client_cnx,
|
||||
(u8_t *)lb->buf, lb->len,
|
||||
telnet_sent_cb,
|
||||
K_FOREVER, NULL, NULL)) {
|
||||
K_FOREVER, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ static int telnet_console_out_nothing(int c)
|
||||
static inline void telnet_command_send_reply(u8_t *msg, u16_t len)
|
||||
{
|
||||
net_context_send(client_cnx, msg, len,
|
||||
telnet_sent_cb, K_FOREVER, NULL, NULL);
|
||||
telnet_sent_cb, K_FOREVER, NULL);
|
||||
}
|
||||
|
||||
static inline void telnet_reply_ay_command(void)
|
||||
|
||||
@ -100,12 +100,10 @@ typedef void (*net_context_recv_cb_t)(struct net_context *context,
|
||||
* @param status Value is set to 0 if all data was sent ok, <0 if
|
||||
* there was an error sending data. >0 amount of data that was
|
||||
* sent when not all data was sent ok.
|
||||
* @param token User specified value specified in net_send() call.
|
||||
* @param user_data The user data given in net_send() call.
|
||||
*/
|
||||
typedef void (*net_context_send_cb_t)(struct net_context *context,
|
||||
int status,
|
||||
void *token,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
@ -753,7 +751,6 @@ int net_context_accept(struct net_context *context,
|
||||
* @param cb Caller-supplied callback function.
|
||||
* @param timeout Timeout for the connection. Possible values
|
||||
* are K_FOREVER, K_NO_WAIT, >0.
|
||||
* @param token Caller specified value that is passed as is to callback.
|
||||
* @param user_data Caller-supplied user data.
|
||||
*
|
||||
* @return 0 if ok, < 0 if error
|
||||
@ -763,7 +760,6 @@ int net_context_send(struct net_context *context,
|
||||
size_t len,
|
||||
net_context_send_cb_t cb,
|
||||
s32_t timeout,
|
||||
void *token,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
@ -789,7 +785,6 @@ int net_context_send(struct net_context *context,
|
||||
* @param cb Caller-supplied callback function.
|
||||
* @param timeout Timeout for the connection. Possible values
|
||||
* are K_FOREVER, K_NO_WAIT, >0.
|
||||
* @param token Caller specified value that is passed as is to callback.
|
||||
* @param user_data Caller-supplied user data.
|
||||
*
|
||||
* @return numbers of bytes sent on success, a negative errno otherwise
|
||||
@ -801,7 +796,6 @@ int net_context_sendto(struct net_context *context,
|
||||
socklen_t addrlen,
|
||||
net_context_send_cb_t cb,
|
||||
s32_t timeout,
|
||||
void *token,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
|
||||
@ -175,7 +175,6 @@ static int build_reply(const char *name,
|
||||
|
||||
static inline void pkt_sent(struct net_context *context,
|
||||
int status,
|
||||
void *token,
|
||||
void *user_data)
|
||||
{
|
||||
if (status >= 0) {
|
||||
@ -220,7 +219,7 @@ static void udp_received(struct net_context *context,
|
||||
family == AF_INET6 ?
|
||||
sizeof(struct sockaddr_in6) :
|
||||
sizeof(struct sockaddr_in),
|
||||
pkt_sent, 0, NULL, user_data);
|
||||
pkt_sent, K_NO_WAIT, user_data);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
}
|
||||
@ -262,7 +261,7 @@ static void tcp_received(struct net_context *context,
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
ret = net_context_send(context, buf_tx, ret, pkt_sent,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Cannot send data to peer (%d)", ret);
|
||||
quit();
|
||||
|
||||
@ -108,7 +108,7 @@ static int transmitv(struct net_context *conn, int iovcnt,
|
||||
memcpy(&buf[pos], iov[i].base, iov[i].len);
|
||||
}
|
||||
|
||||
return net_context_send(conn, buf, pos, NULL, K_NO_WAIT, NULL, NULL);
|
||||
return net_context_send(conn, buf, pos, NULL, K_NO_WAIT, NULL);
|
||||
}
|
||||
|
||||
static inline int transmit(struct net_context *conn, const char buffer[],
|
||||
|
||||
@ -59,7 +59,7 @@ void zperf_tcp_upload(const struct shell *shell,
|
||||
/* Send the packet */
|
||||
ret = net_context_send(ctx, sample_packet,
|
||||
sizeof(sample_packet), NULL,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
shell_fprintf(shell, SHELL_WARNING,
|
||||
"Failed to send the packet (%d)\n",
|
||||
|
||||
@ -103,7 +103,7 @@ static int zperf_receiver_send_stat(const struct shell *shell,
|
||||
net_pkt_family(pkt) == AF_INET6 ?
|
||||
sizeof(struct sockaddr_in6) :
|
||||
sizeof(struct sockaddr_in),
|
||||
NULL, 0, NULL, NULL);
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
shell_fprintf(shell, SHELL_WARNING,
|
||||
" Cannot send data to peer (%d)", ret);
|
||||
|
||||
@ -91,9 +91,8 @@ static inline void zperf_upload_fin(const struct shell *shell,
|
||||
USEC_PER_SEC);
|
||||
|
||||
/* Send the packet */
|
||||
ret = net_context_send(context, sample_packet,
|
||||
packet_size, NULL,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
ret = net_context_send(context, sample_packet, packet_size,
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
shell_fprintf(shell, SHELL_WARNING,
|
||||
"Failed to send the packet (%d)\n",
|
||||
@ -208,9 +207,8 @@ void zperf_udp_upload(const struct shell *shell,
|
||||
htonl(HW_CYCLES_TO_USEC(loop_time) % USEC_PER_SEC);
|
||||
|
||||
/* Send the packet */
|
||||
ret = net_context_send(context, sample_packet,
|
||||
packet_size, NULL,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
ret = net_context_send(context, sample_packet, packet_size,
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
shell_fprintf(shell, SHELL_WARNING,
|
||||
"Failed to send the packet (%d)\n",
|
||||
|
||||
@ -63,8 +63,7 @@ static int line_out(u8_t *data, size_t length, void *output_ctx)
|
||||
return length;
|
||||
}
|
||||
|
||||
ret = net_context_send(ctx, data, length,
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
ret = net_context_send(ctx, data, length, NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -100,8 +100,7 @@ static void syslog_hook_net(const char *fmt, ...)
|
||||
printk("%d:%s", ++count, buf->data);
|
||||
}
|
||||
#endif
|
||||
net_context_send(ctx, buf->data, buf->len,
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
net_context_send(ctx, buf->data, buf->len, NULL, K_NO_WAIT, NULL);
|
||||
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
||||
@ -1269,7 +1269,6 @@ static int context_sendto(struct net_context *context,
|
||||
socklen_t addrlen,
|
||||
net_context_send_cb_t cb,
|
||||
s32_t timeout,
|
||||
void *token,
|
||||
void *user_data)
|
||||
{
|
||||
struct net_pkt *pkt;
|
||||
@ -1418,7 +1417,7 @@ static int context_sendto(struct net_context *context,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = net_tcp_send_data(context, cb, token, user_data);
|
||||
ret = net_tcp_send_data(context, cb, user_data);
|
||||
} else if (IS_ENABLED(CONFIG_NET_SOCKETS_PACKET) &&
|
||||
net_context_get_family(context) == AF_PACKET) {
|
||||
ret = net_pkt_write(pkt, buf, len);
|
||||
@ -1462,7 +1461,6 @@ int net_context_send(struct net_context *context,
|
||||
size_t len,
|
||||
net_context_send_cb_t cb,
|
||||
s32_t timeout,
|
||||
void *token,
|
||||
void *user_data)
|
||||
{
|
||||
socklen_t addrlen;
|
||||
@ -1494,7 +1492,7 @@ int net_context_send(struct net_context *context,
|
||||
}
|
||||
|
||||
ret = context_sendto(context, buf, len, &context->remote,
|
||||
addrlen, cb, timeout, token, user_data);
|
||||
addrlen, cb, timeout, user_data);
|
||||
unlock:
|
||||
k_mutex_unlock(&context->lock);
|
||||
|
||||
@ -1509,7 +1507,6 @@ int net_context_sendto(struct net_context *context,
|
||||
socklen_t addrlen,
|
||||
net_context_send_cb_t cb,
|
||||
s32_t timeout,
|
||||
void *token,
|
||||
void *user_data)
|
||||
{
|
||||
int ret;
|
||||
@ -1517,7 +1514,7 @@ int net_context_sendto(struct net_context *context,
|
||||
k_mutex_lock(&context->lock, K_FOREVER);
|
||||
|
||||
ret = context_sendto(context, buf, len, dst_addr, addrlen,
|
||||
cb, timeout, token, user_data);
|
||||
cb, timeout, user_data);
|
||||
|
||||
k_mutex_unlock(&context->lock);
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ static inline void net_context_send_cb(struct net_context *context,
|
||||
}
|
||||
|
||||
if (context->send_cb) {
|
||||
context->send_cb(context, status, NULL, context->user_data);
|
||||
context->send_cb(context, status, context->user_data);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_UDP)
|
||||
|
||||
@ -3230,9 +3230,7 @@ static void tcp_connect(const struct shell *shell, char *host, u16_t port,
|
||||
}
|
||||
|
||||
static void tcp_sent_cb(struct net_context *context,
|
||||
int status,
|
||||
void *token,
|
||||
void *user_data)
|
||||
int status, void *user_data)
|
||||
{
|
||||
PR_SHELL(tcp_shell, "Message sent\n");
|
||||
}
|
||||
@ -3306,7 +3304,7 @@ static int cmd_net_tcp_send(const struct shell *shell, size_t argc,
|
||||
|
||||
ret = net_context_send(tcp_ctx, (u8_t *)argv[arg],
|
||||
strlen(argv[arg]), tcp_sent_cb,
|
||||
TCP_TIMEOUT, NULL, &user_data);
|
||||
TCP_TIMEOUT, &user_data);
|
||||
if (ret < 0) {
|
||||
PR_WARNING("Cannot send msg (%d)\n", ret);
|
||||
return -ENOEXEC;
|
||||
|
||||
@ -991,7 +991,7 @@ static void restart_timer(struct net_tcp *tcp)
|
||||
}
|
||||
|
||||
int net_tcp_send_data(struct net_context *context, net_context_send_cb_t cb,
|
||||
void *token, void *user_data)
|
||||
void *user_data)
|
||||
{
|
||||
struct net_pkt *pkt;
|
||||
|
||||
@ -1027,10 +1027,10 @@ int net_tcp_send_data(struct net_context *context, net_context_send_cb_t cb,
|
||||
* go over the wire. In theory it would be nice to track
|
||||
* specific ACK locations in the stream and make the
|
||||
* callback at that time, but there's nowhere to store the
|
||||
* potentially-separate token/user_data values right now.
|
||||
* user_data value right now.
|
||||
*/
|
||||
if (cb) {
|
||||
cb(context, 0, token, user_data);
|
||||
cb(context, 0, user_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -393,22 +393,20 @@ static inline void net_tcp_foreach(net_tcp_cb_t cb, void *user_data)
|
||||
*
|
||||
* @param context TCP context
|
||||
* @param cb TCP callback function
|
||||
* @param token TCP token
|
||||
* @param user_data User specified data
|
||||
*
|
||||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
#if defined(CONFIG_NET_TCP)
|
||||
int net_tcp_send_data(struct net_context *context, net_context_send_cb_t cb,
|
||||
void *token, void *user_data);
|
||||
void *user_data);
|
||||
#else
|
||||
static inline int net_tcp_send_data(struct net_context *context,
|
||||
net_context_send_cb_t cb, void *token,
|
||||
net_context_send_cb_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(cb);
|
||||
ARG_UNUSED(token);
|
||||
ARG_UNUSED(user_data);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -401,7 +401,7 @@ static int send_response(struct net_context *ctx, struct net_pkt *pkt,
|
||||
}
|
||||
|
||||
ret = net_context_sendto(ctx, reply->data, reply->len, &dst,
|
||||
dst_len, NULL, K_NO_WAIT, NULL, NULL);
|
||||
dst_len, NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot send LLMNR reply to %s (%d)",
|
||||
net_pkt_family(pkt) == AF_INET ?
|
||||
|
||||
@ -259,7 +259,7 @@ static int send_response(struct net_context *ctx,
|
||||
}
|
||||
|
||||
ret = net_context_sendto(ctx, query->data, query->len, &dst,
|
||||
dst_len, NULL, K_NO_WAIT, NULL, NULL);
|
||||
dst_len, NULL, K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot send mDNS reply (%d)", ret);
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ static int dns_write(struct dns_resolve_context *ctx,
|
||||
|
||||
ret = net_context_sendto(net_ctx, dns_data->data, dns_data->len,
|
||||
server, server_addr_len, NULL,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
K_NO_WAIT, NULL);
|
||||
if (ret < 0) {
|
||||
NET_DBG("Cannot send query (%d)", ret);
|
||||
return ret;
|
||||
|
||||
@ -473,10 +473,10 @@ ssize_t zsock_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
|
||||
if (dest_addr) {
|
||||
status = net_context_sendto(ctx, buf, len, dest_addr,
|
||||
addrlen, NULL, timeout,
|
||||
NULL, ctx->user_data);
|
||||
ctx->user_data);
|
||||
} else {
|
||||
status = net_context_send(ctx, buf, len, NULL, timeout,
|
||||
NULL, ctx->user_data);
|
||||
ctx->user_data);
|
||||
}
|
||||
|
||||
if (status < 0) {
|
||||
|
||||
@ -184,7 +184,7 @@ ssize_t zcan_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
|
||||
can_copy_frame_to_zframe((struct can_frame *)buf, &zframe);
|
||||
|
||||
ret = net_context_sendto(ctx, (void *)&zframe, sizeof(zframe),
|
||||
dest_addr, addrlen, NULL, timeout, NULL,
|
||||
dest_addr, addrlen, NULL, timeout,
|
||||
ctx->user_data);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
|
||||
@ -167,7 +167,7 @@ ssize_t zpacket_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
|
||||
}
|
||||
|
||||
status = net_context_sendto(ctx, buf, len, dest_addr, addrlen,
|
||||
NULL, timeout, NULL, ctx->user_data);
|
||||
NULL, timeout, ctx->user_data);
|
||||
if (status < 0) {
|
||||
errno = -status;
|
||||
return -1;
|
||||
|
||||
@ -496,7 +496,7 @@ static void tx_chksum_offload_disabled_test_v6(void)
|
||||
ret = net_context_sendto(udp_v6_ctx_1, test_data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -547,7 +547,7 @@ static void tx_chksum_offload_disabled_test_v4(void)
|
||||
ret = net_context_sendto(udp_v4_ctx_1, test_data, len,
|
||||
(struct sockaddr *)&dst_addr4,
|
||||
sizeof(struct sockaddr_in),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -598,7 +598,7 @@ static void tx_chksum_offload_enabled_test_v6(void)
|
||||
ret = net_context_sendto(udp_v6_ctx_2, test_data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -649,7 +649,7 @@ static void tx_chksum_offload_enabled_test_v4(void)
|
||||
ret = net_context_sendto(udp_v4_ctx_2, test_data, len,
|
||||
(struct sockaddr *)&dst_addr4,
|
||||
sizeof(struct sockaddr_in),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -747,7 +747,7 @@ static void rx_chksum_offload_disabled_test_v6(void)
|
||||
ret = net_context_sendto(udp_v6_ctx_1, test_data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -803,7 +803,7 @@ static void rx_chksum_offload_disabled_test_v4(void)
|
||||
ret = net_context_sendto(udp_v4_ctx_1, test_data, len,
|
||||
(struct sockaddr *)&dst_addr4,
|
||||
sizeof(struct sockaddr_in),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -857,7 +857,7 @@ static void rx_chksum_offload_enabled_test_v6(void)
|
||||
ret = net_context_sendto(udp_v6_ctx_2, test_data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
@ -911,7 +911,7 @@ static void rx_chksum_offload_enabled_test_v4(void)
|
||||
ret = net_context_sendto(udp_v4_ctx_2, test_data, len,
|
||||
(struct sockaddr *)&dst_addr4,
|
||||
sizeof(struct sockaddr_in),
|
||||
NULL, K_FOREVER, NULL, NULL);
|
||||
NULL, K_FOREVER, NULL);
|
||||
zassert_equal(ret, len, "Send UDP pkt failed (%d)\n", ret);
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
|
||||
@ -61,7 +61,7 @@ static bool data_failure;
|
||||
static bool recv_cb_called;
|
||||
static bool recv_cb_reconfig_called;
|
||||
static bool recv_cb_timeout_called;
|
||||
static int test_token, timeout_token;
|
||||
static bool test_sending;
|
||||
|
||||
static struct k_sem wait_data;
|
||||
|
||||
@ -368,8 +368,7 @@ static void net_ctx_accept_v4(void)
|
||||
"Context accept IPv4 UDP test failed");
|
||||
}
|
||||
|
||||
static void send_cb(struct net_context *context, int status,
|
||||
void *token, void *user_data)
|
||||
static void send_cb(struct net_context *context, int status, void *user_data)
|
||||
{
|
||||
sa_family_t family = POINTER_TO_INT(user_data);
|
||||
|
||||
@ -380,27 +379,17 @@ static void send_cb(struct net_context *context, int status,
|
||||
return;
|
||||
}
|
||||
|
||||
if (POINTER_TO_INT(token) != test_token) {
|
||||
TC_ERROR("Token mismatch %d should be %d\n",
|
||||
POINTER_TO_INT(token), test_token);
|
||||
cb_failure = true;
|
||||
return;
|
||||
}
|
||||
|
||||
cb_failure = false;
|
||||
test_token = 0;
|
||||
}
|
||||
|
||||
static void net_ctx_send_v6(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_send(udp_v6_ctx, test_data, strlen(test_data),
|
||||
send_cb, K_NO_WAIT,
|
||||
INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET6));
|
||||
send_cb, K_NO_WAIT, INT_TO_POINTER(AF_INET6));
|
||||
zassert_false(((ret < 0) || cb_failure),
|
||||
"Context send IPv6 UDP test failed");
|
||||
}
|
||||
@ -409,12 +398,10 @@ static void net_ctx_send_v4(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_send(udp_v4_ctx, test_data, strlen(test_data),
|
||||
send_cb, K_NO_WAIT,
|
||||
INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET));
|
||||
send_cb, K_NO_WAIT, INT_TO_POINTER(AF_INET));
|
||||
zassert_false(((ret < 0) || cb_failure),
|
||||
"Context send IPv4 UDP test failed");
|
||||
}
|
||||
@ -429,13 +416,12 @@ static void net_ctx_sendto_v6(void)
|
||||
0, 0, 0, 0, 0, 0, 0, 0x2 } } },
|
||||
};
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_sendto(udp_v6_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&addr,
|
||||
sizeof(struct sockaddr_in6), send_cb,
|
||||
K_NO_WAIT, INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET6));
|
||||
K_NO_WAIT, INT_TO_POINTER(AF_INET6));
|
||||
zassert_false(((ret < 0) || cb_failure),
|
||||
"Context send IPv6 UDP test failed");
|
||||
}
|
||||
@ -449,13 +435,12 @@ static void net_ctx_sendto_v4(void)
|
||||
.sin_addr = { { { 192, 0, 2, 2 } } },
|
||||
};
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_sendto(udp_v4_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&addr,
|
||||
sizeof(struct sockaddr_in), send_cb,
|
||||
K_NO_WAIT, INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET));
|
||||
K_NO_WAIT, INT_TO_POINTER(AF_INET));
|
||||
zassert_false(((ret < 0) || cb_failure),
|
||||
"Context send IPv4 UDP test failed");
|
||||
}
|
||||
@ -520,13 +505,12 @@ static bool net_ctx_sendto_v6_wrong_src(void)
|
||||
0, 0, 0, 0, 0, 0, 0, 0x3 } } },
|
||||
};
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_sendto(udp_v6_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&addr,
|
||||
sizeof(struct sockaddr_in6), send_cb,
|
||||
K_NO_WAIT, INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET6));
|
||||
K_NO_WAIT, INT_TO_POINTER(AF_INET6));
|
||||
if ((ret < 0) || cb_failure) {
|
||||
TC_ERROR("Context sendto IPv6 UDP wrong src "
|
||||
"test failed (%d)\n", ret);
|
||||
@ -558,13 +542,12 @@ static bool net_ctx_sendto_v4_wrong_src(void)
|
||||
.sin_addr = { { { 192, 0, 2, 3 } } },
|
||||
};
|
||||
|
||||
test_token = SENDING;
|
||||
test_sending = true;
|
||||
|
||||
ret = net_context_sendto(udp_v4_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&addr,
|
||||
sizeof(struct sockaddr_in), send_cb,
|
||||
K_NO_WAIT, INT_TO_POINTER(test_token),
|
||||
INT_TO_POINTER(AF_INET));
|
||||
K_NO_WAIT, INT_TO_POINTER(AF_INET));
|
||||
if ((ret < 0) || cb_failure) {
|
||||
TC_ERROR("Context send IPv4 UDP test failed (%d)\n", ret);
|
||||
return false;
|
||||
@ -744,7 +727,6 @@ static void net_ctx_recv_v6_timeout(void)
|
||||
k_sem_take(&wait_data, WAIT_TIME_LONG * 2);
|
||||
|
||||
net_ctx_send_v6();
|
||||
timeout_token = SENDING;
|
||||
|
||||
DBG("Sent data\n");
|
||||
|
||||
@ -773,7 +755,6 @@ static void net_ctx_recv_v4_timeout(void)
|
||||
k_sem_take(&wait_data, WAIT_TIME_LONG * 2);
|
||||
|
||||
net_ctx_send_v4();
|
||||
timeout_token = SENDING;
|
||||
|
||||
DBG("Sent data\n");
|
||||
|
||||
@ -802,7 +783,6 @@ static void net_ctx_recv_v6_timeout_forever(void)
|
||||
k_sleep(WAIT_TIME);
|
||||
|
||||
net_ctx_send_v6();
|
||||
timeout_token = SENDING;
|
||||
|
||||
DBG("Sent data\n");
|
||||
|
||||
@ -829,7 +809,6 @@ static void net_ctx_recv_v4_timeout_forever(void)
|
||||
k_sleep(WAIT_TIME);
|
||||
|
||||
net_ctx_send_v4();
|
||||
timeout_token = SENDING;
|
||||
|
||||
DBG("Sent data\n");
|
||||
|
||||
@ -912,7 +891,7 @@ static int tester_send(struct device *dev, struct net_pkt *pkt)
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (test_token == SENDING || timeout_token == SENDING) {
|
||||
if (test_sending) {
|
||||
/* We are now about to send data to outside but in this
|
||||
* test we just check what would be sent. In real life
|
||||
* one would not do something like this in the sending
|
||||
@ -960,7 +939,7 @@ static int tester_send(struct device *dev, struct net_pkt *pkt)
|
||||
goto out;
|
||||
}
|
||||
|
||||
timeout_token = 0;
|
||||
test_sending = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ static void traffic_class_send_packets_with_prio(enum net_priority prio,
|
||||
ret = net_context_sendto(net_ctxs[tc].ctx, data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
zassert_true(ret > 0, "Send UDP pkt failed");
|
||||
}
|
||||
|
||||
@ -771,7 +771,7 @@ static void traffic_class_recv_packets_with_prio(enum net_priority prio,
|
||||
ret = net_context_sendto(net_ctxs[tc].ctx, data, len,
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
zassert_true(ret > 0, "Send UDP pkt failed");
|
||||
|
||||
/* Let the receiver to receive the packets */
|
||||
|
||||
@ -457,7 +457,7 @@ static void send_some_data(struct net_if *iface)
|
||||
ret = net_context_sendto(udp_v6_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
zassert_true(ret > 0, "Send UDP pkt failed\n");
|
||||
|
||||
net_context_unref(udp_v6_ctx);
|
||||
|
||||
@ -759,7 +759,7 @@ static void test_vlan_send_data(void)
|
||||
ret = net_context_sendto(udp_v6_ctx, test_data, strlen(test_data),
|
||||
(struct sockaddr *)&dst_addr6,
|
||||
sizeof(struct sockaddr_in6),
|
||||
NULL, K_NO_WAIT, NULL, NULL);
|
||||
NULL, K_NO_WAIT, NULL);
|
||||
zassert_true(ret > 0, "Send UDP pkt failed");
|
||||
|
||||
if (k_sem_take(&wait_data, WAIT_TIME)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user