samples: net: mbedtls: Fix server compilation
The code has missing proper conversion from net_buf to net_pkt
that was implemented in commit db11fcd
"net/net_pkt: Fully
separate struct net_pkt from struct net_buf"
The sample.yaml had incorrect whitelist string so this is also
fixed here.
Fixes #596
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
914d92e488
commit
cd19a57811
3 changed files with 15 additions and 17 deletions
|
@ -3,6 +3,6 @@ sample:
|
|||
name: TBD
|
||||
tests:
|
||||
- test:
|
||||
arch_whitelist: qemu_x86
|
||||
platform_whitelist: qemu_x86
|
||||
build_only: true
|
||||
tags: net
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#if defined(CONFIG_NET_IPV6)
|
||||
static const socklen_t addrlen = sizeof(struct sockaddr_in6);
|
||||
|
||||
static void set_client_address(struct sockaddr *addr, struct net_buf *rx_buf)
|
||||
static void set_client_address(struct sockaddr *addr, struct net_pkt *rx_buf)
|
||||
{
|
||||
net_ipaddr_copy(&net_sin6(addr)->sin6_addr, &NET_IPV6_HDR(rx_buf)->src);
|
||||
net_sin6(addr)->sin6_family = AF_INET6;
|
||||
|
@ -29,7 +29,7 @@ static void set_client_address(struct sockaddr *addr, struct net_buf *rx_buf)
|
|||
#else
|
||||
static const socklen_t addrlen = sizeof(struct sockaddr_in);
|
||||
|
||||
static void set_client_address(struct sockaddr *addr, struct net_buf *rx_buf)
|
||||
static void set_client_address(struct sockaddr *addr, struct net_pkt *rx_buf)
|
||||
{
|
||||
net_ipaddr_copy(&net_sin(addr)->sin_addr, &NET_IPV4_HDR(rx_buf)->src);
|
||||
net_sin(addr)->sin_family = AF_INET;
|
||||
|
@ -39,7 +39,7 @@ static void set_client_address(struct sockaddr *addr, struct net_buf *rx_buf)
|
|||
#endif
|
||||
|
||||
static void udp_received(struct net_context *context,
|
||||
struct net_buf *buf, int status, void *user_data)
|
||||
struct net_pkt *buf, int status, void *user_data)
|
||||
{
|
||||
struct udp_context *ctx = user_data;
|
||||
|
||||
|
@ -54,32 +54,32 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
{
|
||||
struct udp_context *ctx = context;
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *send_buf;
|
||||
struct net_pkt *send_pkt;
|
||||
|
||||
int rc, len;
|
||||
|
||||
net_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_pkt_get_tx(net_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
send_pkt = net_pkt_get_tx(net_ctx, K_FOREVER);
|
||||
if (!send_pkt) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_pkt_append_all(send_buf, size, (u8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append_all(send_pkt, size, (u8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
len = net_buf_frags_len(send_buf);
|
||||
len = net_buf_frags_len(send_pkt->frags);
|
||||
|
||||
rc = net_context_sendto(send_buf, &net_ctx->remote,
|
||||
rc = net_context_sendto(send_pkt, &net_ctx->remote,
|
||||
addrlen, NULL, K_FOREVER, NULL, NULL);
|
||||
|
||||
if (rc < 0) {
|
||||
printk("Cannot send data to peer (%d)\n", rc);
|
||||
net_pkt_unref(send_buf);
|
||||
net_pkt_unref(send_pkt);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -104,12 +104,10 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rx_buf = ctx->rx_pkt;
|
||||
set_client_address(&net_ctx->remote, ctx->rx_pkt);
|
||||
|
||||
set_client_address(&net_ctx->remote, rx_buf);
|
||||
|
||||
ptr = net_pkt_appdata(rx_buf);
|
||||
rx_buf = rx_buf->frags;
|
||||
ptr = net_pkt_appdata(ctx->rx_pkt);
|
||||
rx_buf = ctx->rx_pkt->frags;
|
||||
len = rx_buf->len - (ptr - rx_buf->data);
|
||||
pos = 0;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_pkt;
|
||||
struct net_pkt *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
char client_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue