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
|
name: TBD
|
||||||
tests:
|
tests:
|
||||||
- test:
|
- test:
|
||||||
arch_whitelist: qemu_x86
|
platform_whitelist: qemu_x86
|
||||||
build_only: true
|
build_only: true
|
||||||
tags: net
|
tags: net
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
static const socklen_t addrlen = sizeof(struct sockaddr_in6);
|
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_ipaddr_copy(&net_sin6(addr)->sin6_addr, &NET_IPV6_HDR(rx_buf)->src);
|
||||||
net_sin6(addr)->sin6_family = AF_INET6;
|
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
|
#else
|
||||||
static const socklen_t addrlen = sizeof(struct sockaddr_in);
|
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_ipaddr_copy(&net_sin(addr)->sin_addr, &NET_IPV4_HDR(rx_buf)->src);
|
||||||
net_sin(addr)->sin_family = AF_INET;
|
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
|
#endif
|
||||||
|
|
||||||
static void udp_received(struct net_context *context,
|
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;
|
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 udp_context *ctx = context;
|
||||||
struct net_context *net_ctx;
|
struct net_context *net_ctx;
|
||||||
struct net_buf *send_buf;
|
struct net_pkt *send_pkt;
|
||||||
|
|
||||||
int rc, len;
|
int rc, len;
|
||||||
|
|
||||||
net_ctx = ctx->net_ctx;
|
net_ctx = ctx->net_ctx;
|
||||||
|
|
||||||
send_buf = net_pkt_get_tx(net_ctx, K_FOREVER);
|
send_pkt = net_pkt_get_tx(net_ctx, K_FOREVER);
|
||||||
if (!send_buf) {
|
if (!send_pkt) {
|
||||||
printk("cannot create buf\n");
|
printk("cannot create buf\n");
|
||||||
return -EIO;
|
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) {
|
if (!rc) {
|
||||||
printk("cannot write buf\n");
|
printk("cannot write buf\n");
|
||||||
return -EIO;
|
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);
|
addrlen, NULL, K_FOREVER, NULL, NULL);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printk("Cannot send data to peer (%d)\n", rc);
|
printk("Cannot send data to peer (%d)\n", rc);
|
||||||
net_pkt_unref(send_buf);
|
net_pkt_unref(send_pkt);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} else {
|
} else {
|
||||||
return len;
|
return len;
|
||||||
|
@ -104,12 +104,10 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
||||||
return -ENOMEM;
|
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(ctx->rx_pkt);
|
||||||
|
rx_buf = ctx->rx_pkt->frags;
|
||||||
ptr = net_pkt_appdata(rx_buf);
|
|
||||||
rx_buf = rx_buf->frags;
|
|
||||||
len = rx_buf->len - (ptr - rx_buf->data);
|
len = rx_buf->len - (ptr - rx_buf->data);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
struct udp_context {
|
struct udp_context {
|
||||||
struct net_context *net_ctx;
|
struct net_context *net_ctx;
|
||||||
struct net_buf *rx_pkt;
|
struct net_pkt *rx_pkt;
|
||||||
struct k_sem rx_sem;
|
struct k_sem rx_sem;
|
||||||
int remaining;
|
int remaining;
|
||||||
char client_id;
|
char client_id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue