net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf. While the first is actually a buffer, the second one is not. It's a network buffer descriptor. More precisely it provides meta data about a network packet, and holds the chain of buffer fragments made of net_buf. Thus renaming net_nbuf to net_pkt and all names around it as well (function, Kconfig option, ..). Though net_pkt if the new name, it still inherit its logic from net_buf. ' This patch is the first of a serie that will separate completely net_pkt from net_buf. Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
9bf3ea071a
commit
bf964cdd4c
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
|
||||
|
@ -93,9 +93,9 @@ static struct net_buf *udp_recv(const char *name,
|
|||
int header_len, recv_len, reply_len;
|
||||
|
||||
NET_INFO("%s received %u bytes", name,
|
||||
net_nbuf_appdatalen(buf));
|
||||
net_pkt_appdatalen(buf));
|
||||
|
||||
reply_buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
reply_buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
|
||||
NET_ASSERT(reply_buf);
|
||||
|
||||
|
@ -106,14 +106,14 @@ static struct net_buf *udp_recv(const char *name,
|
|||
/* First fragment will contain IP header so move the data
|
||||
* down in order to get rid of it.
|
||||
*/
|
||||
header_len = net_nbuf_appdata(buf) - tmp->data;
|
||||
header_len = net_pkt_appdata(buf) - tmp->data;
|
||||
|
||||
NET_ASSERT(header_len < CONFIG_NET_NBUF_DATA_SIZE);
|
||||
NET_ASSERT(header_len < CONFIG_NET_BUF_DATA_SIZE);
|
||||
|
||||
net_buf_pull(tmp, header_len);
|
||||
|
||||
while (tmp) {
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
|
||||
memcpy(net_buf_add(frag, tmp->len), tmp->data, tmp->len);
|
||||
|
||||
|
@ -162,7 +162,7 @@ static void udp_received(struct net_context *context,
|
|||
{
|
||||
struct net_buf *reply_buf;
|
||||
struct sockaddr dst_addr;
|
||||
sa_family_t family = net_nbuf_family(buf);
|
||||
sa_family_t family = net_pkt_family(buf);
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
int ret;
|
||||
|
||||
|
@ -173,7 +173,7 @@ static void udp_received(struct net_context *context,
|
|||
|
||||
reply_buf = udp_recv(dbg, context, buf);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
ret = net_context_sendto(reply_buf, &dst_addr, udp_sent, 0,
|
||||
UINT_TO_POINTER(net_buf_frags_len(reply_buf)),
|
||||
|
@ -181,7 +181,7 @@ static void udp_received(struct net_context *context,
|
|||
if (ret < 0) {
|
||||
NET_ERR("Cannot send data to peer (%d)", ret);
|
||||
|
||||
net_nbuf_unref(reply_buf);
|
||||
net_pkt_unref(reply_buf);
|
||||
|
||||
quit();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ connectivity APIs, following things will happen.
|
|||
4) The application will then receive the data, which is stored inside a chain
|
||||
of net_bufs. The application now owns the data. After it has finished working
|
||||
with it, the application should release the net_bufs data by calling
|
||||
`net_nbuf_unref()`.
|
||||
`net_pkt_unref()`.
|
||||
|
||||
*Data sending (TX):*
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ how the L2 layer is supposed to behave. The generic L2 API has 3
|
|||
functions:
|
||||
|
||||
- recv: All device drivers, once they receive a packet which they put
|
||||
into a :c:type:`struct net_nbuf`, will push this buffer to the IP
|
||||
into a :c:type:`struct net_pkt`, will push this buffer to the IP
|
||||
core stack via :c:func:`net_recv_data()`. At this point, the IP core
|
||||
stack does not know what to do with it. Instead, it passes the
|
||||
buffer along to the L2 stack's recv() function for handling. The L2
|
||||
|
@ -77,12 +77,12 @@ Ethernet device driver
|
|||
|
||||
On reception, it is up to the device driver to fill-in the buffer with
|
||||
as many data fragments as required. The buffer itself is a
|
||||
:c:type:`struct net_nbuf` and should be allocated through
|
||||
:c:func:`net_nbuf_get_reserve_rx(0)`. Then all fragments will be
|
||||
allocated through :c:func:`net_nbuf_get_reserve_data(0)`. Of course
|
||||
:c:type:`struct net_pkt` and should be allocated through
|
||||
:c:func:`net_pkt_get_reserve_rx(0)`. Then all fragments will be
|
||||
allocated through :c:func:`net_pkt_get_reserve_data(0)`. Of course
|
||||
the amount of required fragments depends on the size of the received
|
||||
packet and on the size of a fragment, which is given by
|
||||
`CONFIG_NET_NBUF_DATA_SIZE`.
|
||||
`CONFIG_NET_PKT_DATA_SIZE`.
|
||||
|
||||
Note that it is not up to the device driver to decide on the
|
||||
link-layer space to be reserved in the buffer. Hence the 0 given as
|
||||
|
@ -91,13 +91,13 @@ once the packet's Ethernet header has been successfully parsed.
|
|||
|
||||
In case :c:func:`net_recv_data()` call fails, it will be up to the
|
||||
device driver to un-reference the buffer via
|
||||
:c:func:`net_nbuf_unref()`.
|
||||
:c:func:`net_pkt_unref()`.
|
||||
|
||||
On sending, it is up to the device driver to send the buffer all at
|
||||
once, with all the fragments.
|
||||
|
||||
In case of a fully successful packet transmission only, the device
|
||||
driver must un-reference the buffer via `net_nbuf_unref()`.
|
||||
driver must un-reference the buffer via `net_pkt_unref()`.
|
||||
|
||||
Each Ethernet device driver will need, in the end, to call
|
||||
`NET_DEVICE_INIT_INSTANCE()` like this:
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <console/console.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_ip.h>
|
||||
#include <net/net_context.h>
|
||||
|
||||
|
@ -125,9 +125,9 @@ static void telnet_end_client_connection(void)
|
|||
|
||||
static int telnet_setup_out_buf(struct net_context *client)
|
||||
{
|
||||
out_buf = net_nbuf_get_tx(client, K_FOREVER);
|
||||
out_buf = net_pkt_get_tx(client, K_FOREVER);
|
||||
if (!out_buf) {
|
||||
/* Cannot happen atm, nbuf waits indefinitely */
|
||||
/* Cannot happen atm, net_pkt waits indefinitely */
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ static inline bool telnet_send(void)
|
|||
struct line_buf *lb = telnet_rb_get_line_out();
|
||||
|
||||
if (lb) {
|
||||
net_nbuf_append(out_buf, lb->len, lb->buf, K_FOREVER);
|
||||
net_pkt_append(out_buf, lb->len, lb->buf, K_FOREVER);
|
||||
|
||||
/* We reinitialize the line buffer */
|
||||
lb->len = 0;
|
||||
|
@ -258,7 +258,7 @@ static int telnet_console_out_nothing(int c)
|
|||
|
||||
static inline void telnet_command_send_reply(uint8_t *msg, uint16_t len)
|
||||
{
|
||||
net_nbuf_append(out_buf, len, msg, K_FOREVER);
|
||||
net_pkt_append(out_buf, len, msg, K_FOREVER);
|
||||
|
||||
net_context_send(out_buf, telnet_sent_cb,
|
||||
K_NO_WAIT, NULL, NULL);
|
||||
|
@ -329,7 +329,7 @@ out:
|
|||
static inline bool telnet_handle_command(struct net_buf *buf)
|
||||
{
|
||||
struct telnet_simple_command *cmd =
|
||||
(struct telnet_simple_command *)net_nbuf_appdata(buf);
|
||||
(struct telnet_simple_command *)net_pkt_appdata(buf);
|
||||
|
||||
if (cmd->iac != NVT_CMD_IAC) {
|
||||
return false;
|
||||
|
@ -356,7 +356,7 @@ static inline void telnet_handle_input(struct net_buf *buf)
|
|||
struct console_input *input;
|
||||
uint16_t len, offset, pos;
|
||||
|
||||
len = net_nbuf_appdatalen(buf);
|
||||
len = net_pkt_appdatalen(buf);
|
||||
if (len > CONSOLE_MAX_LINE_LEN || len < TELNET_MIN_MSG) {
|
||||
return;
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ static inline void telnet_handle_input(struct net_buf *buf)
|
|||
}
|
||||
|
||||
offset = net_buf_frags_len(buf) - len;
|
||||
net_nbuf_read(buf->frags, offset, &pos, len, input->line);
|
||||
net_pkt_read(buf->frags, offset, &pos, len, input->line);
|
||||
|
||||
/* LF/CR will be removed if only the line is not NUL terminated */
|
||||
if (input->line[len-1] != NVT_NUL) {
|
||||
|
|
|
@ -20,18 +20,18 @@ config ETH_SAM_GMAC_NAME
|
|||
Device name allows user to obtain a handle to the device object
|
||||
required by all driver API functions. Device name has to be unique.
|
||||
|
||||
config ETH_SAM_GMAC_NBUF_RX_DATA_COUNT
|
||||
int "Network RX data buffers pre-allocated by the SAM ETH driver"
|
||||
config ETH_SAM_GMAC_BUF_RX_COUNT
|
||||
int "Network RX buffers pre-allocated by the SAM ETH driver"
|
||||
default 18
|
||||
help
|
||||
Number of network data buffers that will be permanently allocated by the
|
||||
Ethernet driver. These data buffers are used in receive path. They are
|
||||
Number of network buffers that will be permanently allocated by the
|
||||
Ethernet driver. These buffers are used in receive path. They are
|
||||
pre-alocated by the driver and made available to the GMAC module to be
|
||||
filled in with incoming data. Their number has to be large enough to fit
|
||||
at least one complete Ethernet frame. SAM ETH driver will always allocate
|
||||
that amount of buffers for itself thus reducing the NET_NBUF_RX_DATA_COUNT
|
||||
that amount of buffers for itself thus reducing the NET_BUF_RX_COUNT
|
||||
which is a total amount of RX data buffers used by the whole networking
|
||||
stack. One has to ensure that NET_NBUF_RX_DATA_COUNT is large enough to
|
||||
stack. One has to ensure that NET_PKT_RX_COUNT is large enough to
|
||||
fit at least two ethernet frames: one being received by the GMAC module
|
||||
and the other being processed by the higer layer networking stack.
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <errno.h>
|
||||
#include <gpio.h>
|
||||
#include <spi.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
|
@ -466,8 +466,8 @@ static int eth_enc28j60_tx(struct device *dev, struct net_buf *buf,
|
|||
uint16_t data_len;
|
||||
|
||||
if (first_frag) {
|
||||
data_ptr = net_nbuf_ll(buf);
|
||||
data_len = net_nbuf_ll_reserve(buf) + frag->len;
|
||||
data_ptr = net_pkt_ll(buf);
|
||||
data_len = net_pkt_ll_reserve(buf) + frag->len;
|
||||
first_frag = false;
|
||||
} else {
|
||||
data_ptr = frag->data;
|
||||
|
@ -552,7 +552,7 @@ static int eth_enc28j60_rx(struct device *dev)
|
|||
lengthfr = frm_len;
|
||||
|
||||
/* Get the frame from the buffer */
|
||||
buf = net_nbuf_get_reserve_rx(0, config->timeout);
|
||||
buf = net_pkt_get_reserve_rx(0, config->timeout);
|
||||
if (!buf) {
|
||||
SYS_LOG_ERR("Could not allocate rx buffer");
|
||||
goto done;
|
||||
|
@ -566,7 +566,7 @@ static int eth_enc28j60_rx(struct device *dev)
|
|||
size_t spi_frame_len;
|
||||
|
||||
/* Reserve a data frag to receive the frame */
|
||||
pkt_buf = net_nbuf_get_frag(buf, config->timeout);
|
||||
pkt_buf = net_pkt_get_frag(buf, config->timeout);
|
||||
if (!pkt_buf) {
|
||||
SYS_LOG_ERR("Could not allocate data buffer");
|
||||
net_buf_unref(buf);
|
||||
|
@ -656,14 +656,14 @@ static void enc28j60_thread_main(void *arg1, void *unused1, void *unused2)
|
|||
|
||||
static int eth_net_tx(struct net_if *iface, struct net_buf *buf)
|
||||
{
|
||||
uint16_t len = net_nbuf_ll_reserve(buf) + net_buf_frags_len(buf);
|
||||
uint16_t len = net_pkt_ll_reserve(buf) + net_buf_frags_len(buf);
|
||||
int ret;
|
||||
|
||||
SYS_LOG_DBG("buf %p (len %u)", buf, len);
|
||||
|
||||
ret = eth_enc28j60_tx(iface->dev, buf, len);
|
||||
if (ret == 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <kernel.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
|
||||
#include "fsl_enet.h"
|
||||
|
@ -314,7 +314,7 @@ static int eth_tx(struct net_if *iface, struct net_buf *buf)
|
|||
status_t status;
|
||||
unsigned int imask;
|
||||
|
||||
uint16_t total_len = net_nbuf_ll_reserve(buf) + net_buf_frags_len(buf);
|
||||
uint16_t total_len = net_pkt_ll_reserve(buf) + net_buf_frags_len(buf);
|
||||
|
||||
k_sem_take(&context->tx_buf_sem, K_FOREVER);
|
||||
|
||||
|
@ -329,9 +329,9 @@ static int eth_tx(struct net_if *iface, struct net_buf *buf)
|
|||
* in our case) headers and must be treated specially.
|
||||
*/
|
||||
dst = context->frame_buf;
|
||||
memcpy(dst, net_nbuf_ll(buf),
|
||||
net_nbuf_ll_reserve(buf) + buf->frags->len);
|
||||
dst += net_nbuf_ll_reserve(buf) + buf->frags->len;
|
||||
memcpy(dst, net_pkt_ll(buf),
|
||||
net_pkt_ll_reserve(buf) + buf->frags->len);
|
||||
dst += net_pkt_ll_reserve(buf) + buf->frags->len;
|
||||
|
||||
/* Continue with the rest of fragments (which contain only data) */
|
||||
frag = buf->frags->frags;
|
||||
|
@ -351,7 +351,7 @@ static int eth_tx(struct net_if *iface, struct net_buf *buf)
|
|||
return -1;
|
||||
}
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ static void eth_rx(struct device *iface)
|
|||
return;
|
||||
}
|
||||
|
||||
buf = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
buf = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
/* We failed to get a receive buffer. We don't add
|
||||
* any further logging here because the allocator
|
||||
|
@ -398,7 +398,7 @@ static void eth_rx(struct device *iface)
|
|||
|
||||
if (sizeof(context->frame_buf) < frame_length) {
|
||||
SYS_LOG_ERR("frame too large (%d)\n", frame_length);
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
|
@ -414,7 +414,7 @@ static void eth_rx(struct device *iface)
|
|||
if (status) {
|
||||
irq_unlock(imask);
|
||||
SYS_LOG_ERR("ENET_ReadFrame failed: %d\n", status);
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -424,11 +424,11 @@ static void eth_rx(struct device *iface)
|
|||
struct net_buf *pkt_buf;
|
||||
size_t frag_len;
|
||||
|
||||
pkt_buf = net_nbuf_get_frag(buf, K_NO_WAIT);
|
||||
pkt_buf = net_pkt_get_frag(buf, K_NO_WAIT);
|
||||
if (!pkt_buf) {
|
||||
irq_unlock(imask);
|
||||
SYS_LOG_ERR("Failed to get fragment buf\n");
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ static void eth_rx(struct device *iface)
|
|||
irq_unlock(imask);
|
||||
|
||||
if (net_recv_data(context->iface, buf) < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <misc/util.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <soc.h>
|
||||
#include "phy_sam_gmac.h"
|
||||
|
@ -38,28 +38,28 @@
|
|||
* Verify Kconfig configuration
|
||||
*/
|
||||
|
||||
#if CONFIG_NET_NBUF_DATA_SIZE * CONFIG_ETH_SAM_GMAC_NBUF_RX_DATA_COUNT \
|
||||
#if CONFIG_NET_BUF_DATA_SIZE * CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT \
|
||||
< GMAC_FRAME_SIZE_MAX
|
||||
#error CONFIG_NET_NBUF_DATA_SIZE * CONFIG_ETH_SAM_GMAC_NBUF_RX_DATA_COUNT is \
|
||||
#error CONFIG_NET_BUF_DATA_SIZE * CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT is \
|
||||
not large enough to hold a full frame
|
||||
#endif
|
||||
|
||||
#if CONFIG_NET_NBUF_DATA_SIZE * (CONFIG_NET_NBUF_RX_DATA_COUNT - \
|
||||
CONFIG_ETH_SAM_GMAC_NBUF_RX_DATA_COUNT) < GMAC_FRAME_SIZE_MAX
|
||||
#error Remaining free RX data buffers (CONFIG_NET_NBUF_RX_DATA_COUNT -
|
||||
CONFIG_ETH_SAM_GMAC_NBUF_RX_DATA_COUNT) * CONFIG_NET_NBUF_DATA_SIZE
|
||||
#if CONFIG_NET_BUF_DATA_SIZE * (CONFIG_NET_BUF_RX_COUNT - \
|
||||
CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT) < GMAC_FRAME_SIZE_MAX
|
||||
#error Remaining free RX data buffers (CONFIG_NET_BUF_RX_COUNT -
|
||||
CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT) * CONFIG_NET_BUF_DATA_SIZE
|
||||
are not large enough to hold a full frame
|
||||
#endif
|
||||
|
||||
#if CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_TX_DATA_COUNT \
|
||||
#if CONFIG_NET_BUF_DATA_SIZE * CONFIG_NET_BUF_TX_COUNT \
|
||||
< GMAC_FRAME_SIZE_MAX
|
||||
#pragma message "Maximum frame size GMAC driver is able to transmit " \
|
||||
"CONFIG_NET_NBUF_DATA_SIZE * CONFIG_NET_NBUF_TX_DATA_COUNT is smaller" \
|
||||
"CONFIG_NET_BUF_DATA_SIZE * CONFIG_NET_BUF_TX_COUNT is smaller" \
|
||||
"than a full Ethernet frame"
|
||||
#endif
|
||||
|
||||
#if CONFIG_NET_NBUF_DATA_SIZE & 0x3F
|
||||
#pragma message "CONFIG_NET_NBUF_DATA_SIZE should be a multiple of 64 bytes " \
|
||||
#if CONFIG_NET_BUF_DATA_SIZE & 0x3F
|
||||
#pragma message "CONFIG_NET_BUF_DATA_SIZE should be a multiple of 64 bytes " \
|
||||
"due to the granularity of RX DMA"
|
||||
#endif
|
||||
|
||||
|
@ -77,7 +77,7 @@ static struct gmac_desc tx_desc_que12[PRIORITY_QUEUE_DESC_COUNT]
|
|||
/* RX buffer accounting list */
|
||||
static struct net_buf *rx_buf_list_que0[MAIN_QUEUE_RX_DESC_COUNT];
|
||||
/* TX frames accounting list */
|
||||
static struct net_buf *tx_frame_list_que0[CONFIG_NET_NBUF_TX_COUNT + 1];
|
||||
static struct net_buf *tx_frame_list_que0[CONFIG_NET_PKT_TX_COUNT + 1];
|
||||
|
||||
#define MODULO_INC(val, max) {val = (++val < max) ? val : 0; }
|
||||
|
||||
|
@ -121,12 +121,12 @@ static void ring_buf_put(struct ring_buf *rb, uint32_t val)
|
|||
/*
|
||||
* Free pre-reserved RX buffers
|
||||
*/
|
||||
static void free_rx_bufs(struct ring_buf *rx_nbuf_list)
|
||||
static void free_rx_bufs(struct ring_buf *rx_pkt_list)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
|
||||
for (int i = 0; i < rx_nbuf_list->len; i++) {
|
||||
buf = (struct net_buf *)rx_nbuf_list->buf;
|
||||
for (int i = 0; i < rx_pkt_list->len; i++) {
|
||||
buf = (struct net_buf *)rx_pkt_list->buf;
|
||||
if (buf) {
|
||||
net_buf_unref(buf);
|
||||
}
|
||||
|
@ -155,29 +155,29 @@ static void mac_addr_set(Gmac *gmac, uint8_t index,
|
|||
static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue)
|
||||
{
|
||||
struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list;
|
||||
struct ring_buf *rx_nbuf_list = &queue->rx_nbuf_list;
|
||||
struct ring_buf *rx_pkt_list = &queue->rx_pkt_list;
|
||||
struct net_buf *rx_buf;
|
||||
uint8_t *rx_buf_addr;
|
||||
|
||||
__ASSERT_NO_MSG(rx_nbuf_list->buf);
|
||||
__ASSERT_NO_MSG(rx_pkt_list->buf);
|
||||
|
||||
rx_desc_list->tail = 0;
|
||||
rx_nbuf_list->tail = 0;
|
||||
rx_pkt_list->tail = 0;
|
||||
|
||||
for (int i = 0; i < rx_desc_list->len; i++) {
|
||||
rx_buf = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
|
||||
rx_buf = net_pkt_get_reserve_rx_data(0, K_NO_WAIT);
|
||||
if (rx_buf == NULL) {
|
||||
free_rx_bufs(rx_nbuf_list);
|
||||
free_rx_bufs(rx_pkt_list);
|
||||
SYS_LOG_ERR("Failed to reserve data net buffers");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
rx_nbuf_list->buf[i] = (uint32_t)rx_buf;
|
||||
rx_pkt_list->buf[i] = (uint32_t)rx_buf;
|
||||
|
||||
rx_buf_addr = rx_buf->data;
|
||||
__ASSERT(!((uint32_t)rx_buf_addr & ~GMAC_RXW0_ADDR),
|
||||
"Misaligned RX buffer address");
|
||||
__ASSERT(rx_buf->size == CONFIG_NET_NBUF_DATA_SIZE,
|
||||
__ASSERT(rx_buf->size == CONFIG_NET_BUF_DATA_SIZE,
|
||||
"Incorrect length of RX data buffer");
|
||||
/* Give ownership to GMAC and remove the wrap bit */
|
||||
rx_desc_list->buf[i].w0 = (uint32_t)rx_buf_addr & GMAC_RXW0_ADDR;
|
||||
|
@ -254,7 +254,7 @@ static void tx_error_handler(Gmac *gmac, struct gmac_queue *queue)
|
|||
/* Stop transmission, clean transmit pipeline and control registers */
|
||||
gmac->GMAC_NCR &= ~GMAC_NCR_TXEN;
|
||||
|
||||
/* Free all nbuf resources in the TX path */
|
||||
/* Free all pkt resources in the TX path */
|
||||
while (tx_frames->tail != tx_frames->head) {
|
||||
/* Release net buffer to the buffer pool */
|
||||
buf = UINT_TO_POINTER(tx_frames->buf[tx_frames->tail]);
|
||||
|
@ -285,7 +285,7 @@ static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue)
|
|||
gmac->GMAC_NCR &= ~GMAC_NCR_RXEN;
|
||||
|
||||
queue->rx_desc_list.tail = 0;
|
||||
queue->rx_nbuf_list.tail = 0;
|
||||
queue->rx_pkt_list.tail = 0;
|
||||
|
||||
for (int i = 0; i < queue->rx_desc_list.len; i++) {
|
||||
queue->rx_desc_list.buf[i].w1 = 0;
|
||||
|
@ -415,7 +415,7 @@ static int queue_init(Gmac *gmac, struct gmac_queue *queue)
|
|||
/* Configure GMAC DMA transfer */
|
||||
gmac->GMAC_DCFGR =
|
||||
/* Receive Buffer Size (defined in multiples of 64 bytes) */
|
||||
GMAC_DCFGR_DRBS(CONFIG_NET_NBUF_DATA_SIZE >> 6)
|
||||
GMAC_DCFGR_DRBS(CONFIG_NET_BUF_DATA_SIZE >> 6)
|
||||
/* 4 kB Receiver Packet Buffer Memory Size */
|
||||
| GMAC_DCFGR_RXBMS_FULL
|
||||
/* 4 kB Transmitter Packet Buffer Memory Size */
|
||||
|
@ -471,7 +471,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
{
|
||||
struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list;
|
||||
struct gmac_desc *rx_desc;
|
||||
struct ring_buf *rx_nbuf_list = &queue->rx_nbuf_list;
|
||||
struct ring_buf *rx_pkt_list = &queue->rx_pkt_list;
|
||||
struct net_buf *rx_frame;
|
||||
bool frame_is_complete;
|
||||
struct net_buf *prev_frag;
|
||||
|
@ -498,7 +498,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
rx_frame = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
rx_frame = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
|
||||
/* Process a frame */
|
||||
prev_frag = rx_frame;
|
||||
|
@ -518,7 +518,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
* again.
|
||||
*/
|
||||
while ((rx_desc->w0 & GMAC_RXW0_OWNERSHIP) && !frame_is_complete) {
|
||||
frag = (struct net_buf *)rx_nbuf_list->buf[tail];
|
||||
frag = (struct net_buf *)rx_pkt_list->buf[tail];
|
||||
frag_data = (uint8_t *)(rx_desc->w0 & GMAC_RXW0_ADDR);
|
||||
__ASSERT(frag->data == frag_data,
|
||||
"RX descriptor and buffer list desynchronized");
|
||||
|
@ -526,7 +526,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
if (frame_is_complete) {
|
||||
frag_len = (rx_desc->w1 & GMAC_TXW1_LEN) - frame_len;
|
||||
} else {
|
||||
frag_len = CONFIG_NET_NBUF_DATA_SIZE;
|
||||
frag_len = CONFIG_NET_BUF_DATA_SIZE;
|
||||
}
|
||||
|
||||
frame_len += frag_len;
|
||||
|
@ -537,7 +537,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
DCACHE_INVALIDATE(frag_data, frag_len);
|
||||
|
||||
/* Get a new data net buffer from the buffer pool */
|
||||
new_frag = net_nbuf_get_frag(rx_frame, K_NO_WAIT);
|
||||
new_frag = net_pkt_get_frag(rx_frame, K_NO_WAIT);
|
||||
if (new_frag == NULL) {
|
||||
queue->err_rx_frames_dropped++;
|
||||
net_buf_unref(rx_frame);
|
||||
|
@ -547,7 +547,7 @@ static struct net_buf *frame_get(struct gmac_queue *queue)
|
|||
net_buf_frag_insert(prev_frag, frag);
|
||||
prev_frag = frag;
|
||||
frag = new_frag;
|
||||
rx_nbuf_list->buf[tail] = (uint32_t)frag;
|
||||
rx_pkt_list->buf[tail] = (uint32_t)frag;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,7 +587,7 @@ static void eth_rx(struct gmac_queue *queue)
|
|||
SYS_LOG_DBG("ETH rx");
|
||||
|
||||
if (net_recv_data(dev_data->iface, rx_frame) < 0) {
|
||||
net_nbuf_unref(rx_frame);
|
||||
net_pkt_unref(rx_frame);
|
||||
}
|
||||
|
||||
rx_frame = frame_get(queue);
|
||||
|
@ -618,7 +618,7 @@ static int eth_tx(struct net_if *iface, struct net_buf *buf)
|
|||
* in our case) header. Modify the data pointer to account for more data
|
||||
* in the beginning of the buffer.
|
||||
*/
|
||||
net_buf_push(buf->frags, net_nbuf_ll_reserve(buf));
|
||||
net_buf_push(buf->frags, net_pkt_ll_reserve(buf));
|
||||
|
||||
frag = buf->frags;
|
||||
|
||||
|
@ -848,7 +848,7 @@ static struct eth_sam_dev_data eth0_data = {
|
|||
.buf = tx_desc_que0,
|
||||
.len = ARRAY_SIZE(tx_desc_que0),
|
||||
},
|
||||
.rx_nbuf_list = {
|
||||
.rx_pkt_list = {
|
||||
.buf = (uint32_t *)rx_buf_list_que0,
|
||||
.len = ARRAY_SIZE(rx_buf_list_que0),
|
||||
},
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
/** Total number of queues supported by GMAC hardware module */
|
||||
#define GMAC_QUEUE_NO 3
|
||||
/** RX descriptors count for main queue */
|
||||
#define MAIN_QUEUE_RX_DESC_COUNT CONFIG_ETH_SAM_GMAC_NBUF_RX_DATA_COUNT
|
||||
#define MAIN_QUEUE_RX_DESC_COUNT CONFIG_ETH_SAM_GMAC_BUF_RX_COUNT
|
||||
/** TX descriptors count for main queue */
|
||||
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_NBUF_TX_DATA_COUNT + 1)
|
||||
#define MAIN_QUEUE_TX_DESC_COUNT (CONFIG_NET_BUF_TX_COUNT + 1)
|
||||
/** RX/TX descriptors count for priority queues */
|
||||
#define PRIORITY_QUEUE_DESC_COUNT 1
|
||||
|
||||
|
@ -152,7 +152,7 @@ struct gmac_queue {
|
|||
struct gmac_desc_list tx_desc_list;
|
||||
struct k_sem tx_desc_sem;
|
||||
|
||||
struct ring_buf rx_nbuf_list;
|
||||
struct ring_buf rx_pkt_list;
|
||||
struct ring_buf tx_frames;
|
||||
|
||||
/** Number of RX frames dropped by the driver */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
|
@ -559,7 +559,7 @@ static inline bool verify_crc(struct cc2520_context *cc2520,
|
|||
return false;
|
||||
}
|
||||
|
||||
net_nbuf_set_ieee802154_rssi(buf, cc2520->spi.cmd_buf[1]);
|
||||
net_pkt_set_ieee802154_rssi(buf, cc2520->spi.cmd_buf[1]);
|
||||
|
||||
/**
|
||||
* CC2520 does not provide an LQI but a correlation factor.
|
||||
|
@ -619,7 +619,7 @@ static void cc2520_rx(int arg)
|
|||
goto flush;
|
||||
}
|
||||
|
||||
buf = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
buf = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
SYS_LOG_ERR("No buf available");
|
||||
goto flush;
|
||||
|
@ -629,9 +629,9 @@ static void cc2520_rx(int arg)
|
|||
/**
|
||||
* Reserve 1 byte for length
|
||||
*/
|
||||
net_nbuf_set_ll_reserve(buf, 1);
|
||||
net_pkt_set_ll_reserve(buf, 1);
|
||||
#endif
|
||||
pkt_buf = net_nbuf_get_frag(buf, K_NO_WAIT);
|
||||
pkt_buf = net_pkt_get_frag(buf, K_NO_WAIT);
|
||||
if (!pkt_buf) {
|
||||
SYS_LOG_ERR("No pkt_buf available");
|
||||
goto flush;
|
||||
|
@ -840,8 +840,8 @@ static int cc2520_tx(struct device *dev,
|
|||
struct net_buf *buf,
|
||||
struct net_buf *frag)
|
||||
{
|
||||
uint8_t *frame = frag->data - net_nbuf_ll_reserve(buf);
|
||||
uint8_t len = net_nbuf_ll_reserve(buf) + frag->len;
|
||||
uint8_t *frame = frag->data - net_pkt_ll_reserve(buf);
|
||||
uint8_t len = net_pkt_ll_reserve(buf) + frag->len;
|
||||
struct cc2520_context *cc2520 = dev->driver_data;
|
||||
uint8_t retry = 2;
|
||||
bool status;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
|
@ -547,7 +547,7 @@ static inline void mcr20a_rx(struct mcr20a_context *mcr20a, uint8_t len)
|
|||
|
||||
pkt_len = len - MCR20A_FCS_LENGTH;
|
||||
|
||||
buf = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
buf = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
SYS_LOG_ERR("No buf available");
|
||||
goto out;
|
||||
|
@ -558,9 +558,9 @@ static inline void mcr20a_rx(struct mcr20a_context *mcr20a, uint8_t len)
|
|||
/**
|
||||
* Reserve 1 byte for length
|
||||
*/
|
||||
net_nbuf_set_ll_reserve(buf, 1);
|
||||
net_pkt_set_ll_reserve(buf, 1);
|
||||
#endif
|
||||
pkt_buf = net_nbuf_get_frag(buf, K_NO_WAIT);
|
||||
pkt_buf = net_pkt_get_frag(buf, K_NO_WAIT);
|
||||
if (!pkt_buf) {
|
||||
SYS_LOG_ERR("No pkt_buf available");
|
||||
goto out;
|
||||
|
@ -1035,8 +1035,8 @@ static inline bool write_txfifo_content(struct mcr20a_spi *spi,
|
|||
struct net_buf *frag)
|
||||
{
|
||||
uint8_t cmd[2 + MCR20A_PSDU_LENGTH];
|
||||
uint8_t payload_len = net_nbuf_ll_reserve(buf) + frag->len;
|
||||
uint8_t *payload = frag->data - net_nbuf_ll_reserve(buf);
|
||||
uint8_t payload_len = net_pkt_ll_reserve(buf) + frag->len;
|
||||
uint8_t *payload = frag->data - net_pkt_ll_reserve(buf);
|
||||
bool retval;
|
||||
|
||||
k_sem_take(&spi->spi_sem, K_FOREVER);
|
||||
|
@ -1077,7 +1077,7 @@ static int mcr20a_tx(struct device *dev,
|
|||
k_mutex_lock(&mcr20a->phy_mutex, K_FOREVER);
|
||||
|
||||
SYS_LOG_DBG("%p (%u)",
|
||||
frag, net_nbuf_ll_reserve(buf) + frag->len);
|
||||
frag, net_pkt_ll_reserve(buf) + frag->len);
|
||||
|
||||
if (!mcr20a_mask_irqb(mcr20a, true)) {
|
||||
SYS_LOG_ERR("Failed to mask IRQ_B");
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
|
@ -71,7 +71,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
|
|||
|
||||
SYS_LOG_DBG("Frame received");
|
||||
|
||||
buf = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
buf = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
SYS_LOG_ERR("No buf available");
|
||||
goto out;
|
||||
|
@ -81,10 +81,10 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
|
|||
/**
|
||||
* Reserve 1 byte for length
|
||||
*/
|
||||
net_nbuf_set_ll_reserve(buf, 1);
|
||||
net_pkt_set_ll_reserve(buf, 1);
|
||||
#endif
|
||||
|
||||
pkt_buf = net_nbuf_get_frag(buf, K_NO_WAIT);
|
||||
pkt_buf = net_pkt_get_frag(buf, K_NO_WAIT);
|
||||
if (!pkt_buf) {
|
||||
SYS_LOG_ERR("No pkt_buf available");
|
||||
goto out;
|
||||
|
@ -234,8 +234,8 @@ static int nrf5_tx(struct device *dev,
|
|||
struct net_buf *frag)
|
||||
{
|
||||
struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev);
|
||||
uint8_t payload_len = net_nbuf_ll_reserve(buf) + frag->len;
|
||||
uint8_t *payload = frag->data - net_nbuf_ll_reserve(buf);
|
||||
uint8_t payload_len = net_pkt_ll_reserve(buf) + frag->len;
|
||||
uint8_t *payload = frag->data - net_pkt_ll_reserve(buf);
|
||||
|
||||
SYS_LOG_DBG("%p (%u)", payload, payload_len);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#include <console/uart_pipe.h>
|
||||
#include <net/ieee802154_radio.h>
|
||||
|
@ -31,7 +31,7 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
|
|||
{
|
||||
struct upipe_context *upipe = upipe_dev->driver_data;
|
||||
struct net_buf *pkt_buf = NULL;
|
||||
struct net_buf *nbuf = NULL;
|
||||
struct net_buf *pkt = NULL;
|
||||
|
||||
if (!upipe_dev) {
|
||||
goto done;
|
||||
|
@ -54,37 +54,37 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off)
|
|||
upipe->rx_buf[upipe->rx_off++] = *buf;
|
||||
|
||||
if (upipe->rx_len == upipe->rx_off) {
|
||||
nbuf = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!nbuf) {
|
||||
pkt = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!pkt) {
|
||||
SYS_LOG_DBG("No buf available");
|
||||
goto flush;
|
||||
}
|
||||
|
||||
pkt_buf = net_nbuf_get_frag(nbuf, K_NO_WAIT);
|
||||
pkt_buf = net_pkt_get_frag(pkt, K_NO_WAIT);
|
||||
if (!pkt_buf) {
|
||||
SYS_LOG_DBG("No fragment available");
|
||||
goto out;
|
||||
}
|
||||
|
||||
net_buf_frag_insert(nbuf, pkt_buf);
|
||||
net_buf_frag_insert(pkt, pkt_buf);
|
||||
|
||||
memcpy(pkt_buf->data, upipe->rx_buf, upipe->rx_len - 2);
|
||||
net_buf_add(pkt_buf, upipe->rx_len - 2);
|
||||
|
||||
if (ieee802154_radio_handle_ack(upipe->iface, nbuf) == NET_OK) {
|
||||
if (ieee802154_radio_handle_ack(upipe->iface, pkt) == NET_OK) {
|
||||
SYS_LOG_DBG("ACK packet handled");
|
||||
goto out;
|
||||
}
|
||||
|
||||
SYS_LOG_DBG("Caught a packet (%u)", upipe->rx_len);
|
||||
if (net_recv_data(upipe->iface, nbuf) < 0) {
|
||||
if (net_recv_data(upipe->iface, pkt) < 0) {
|
||||
SYS_LOG_DBG("Packet dropped by NET stack");
|
||||
goto out;
|
||||
}
|
||||
|
||||
goto flush;
|
||||
out:
|
||||
net_nbuf_unref(nbuf);
|
||||
net_pkt_unref(pkt);
|
||||
flush:
|
||||
upipe->rx = false;
|
||||
upipe->rx_len = 0;
|
||||
|
@ -166,8 +166,8 @@ static int upipe_tx(struct device *dev,
|
|||
struct net_buf *buf,
|
||||
struct net_buf *frag)
|
||||
{
|
||||
uint8_t *pkt_buf = frag->data - net_nbuf_ll_reserve(buf);
|
||||
uint8_t len = net_nbuf_ll_reserve(buf) + frag->len;
|
||||
uint8_t *pkt_buf = frag->data - net_pkt_ll_reserve(buf);
|
||||
uint8_t len = net_pkt_ll_reserve(buf) + frag->len;
|
||||
struct upipe_context *upipe = dev->driver_data;
|
||||
uint8_t i, data;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <stddef.h>
|
||||
#include <misc/util.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <console/uart_pipe.h>
|
||||
|
@ -129,7 +129,7 @@ static int slip_send(struct net_if *iface, struct net_buf *buf)
|
|||
{
|
||||
struct net_buf *frag;
|
||||
#if defined(CONFIG_SLIP_TAP)
|
||||
uint16_t ll_reserve = net_nbuf_ll_reserve(buf);
|
||||
uint16_t ll_reserve = net_pkt_ll_reserve(buf);
|
||||
bool send_header_once = false;
|
||||
#endif
|
||||
uint8_t *ptr;
|
||||
|
@ -201,20 +201,20 @@ static int slip_send(struct net_if *iface, struct net_buf *buf)
|
|||
|
||||
#if defined(CONFIG_SLIP_DEBUG)
|
||||
SYS_LOG_DBG("sent data %d bytes",
|
||||
frag->len + net_nbuf_ll_reserve(buf));
|
||||
frag->len + net_pkt_ll_reserve(buf));
|
||||
if (frag->len + ll_reserve) {
|
||||
char msg[8 + 1];
|
||||
|
||||
snprintf(msg, sizeof(msg), "<slip %2d", frag_count++);
|
||||
|
||||
hexdump(msg, net_nbuf_ll(buf),
|
||||
frag->len + net_nbuf_ll_reserve(buf),
|
||||
net_nbuf_ll_reserve(buf));
|
||||
hexdump(msg, net_pkt_ll(buf),
|
||||
frag->len + net_pkt_ll_reserve(buf),
|
||||
net_pkt_ll_reserve(buf));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
slip_writeb(SLIP_END);
|
||||
|
||||
return 0;
|
||||
|
@ -239,7 +239,7 @@ static void process_msg(struct slip_context *slip)
|
|||
}
|
||||
|
||||
if (net_recv_data(slip->iface, buf) < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
slip->rx = slip->last = NULL;
|
||||
|
@ -294,20 +294,20 @@ static inline int slip_input_byte(struct slip_context *slip,
|
|||
if (!slip->first) {
|
||||
slip->first = true;
|
||||
|
||||
slip->rx = net_nbuf_get_reserve_rx(0, K_NO_WAIT);
|
||||
slip->rx = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!slip->rx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
slip->last = net_nbuf_get_frag(slip->rx, K_NO_WAIT);
|
||||
slip->last = net_pkt_get_frag(slip->rx, K_NO_WAIT);
|
||||
if (!slip->last) {
|
||||
net_nbuf_unref(slip->rx);
|
||||
net_pkt_unref(slip->rx);
|
||||
slip->rx = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
net_buf_frag_add(slip->rx, slip->last);
|
||||
slip->ptr = net_nbuf_ip_data(slip->rx);
|
||||
slip->ptr = net_pkt_ip_data(slip->rx);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -325,11 +325,11 @@ static inline int slip_input_byte(struct slip_context *slip,
|
|||
/* We need to allocate a new fragment */
|
||||
struct net_buf *frag;
|
||||
|
||||
frag = net_nbuf_get_reserve_rx_data(0, K_NO_WAIT);
|
||||
frag = net_pkt_get_reserve_rx_data(0, K_NO_WAIT);
|
||||
if (!frag) {
|
||||
SYS_LOG_ERR("[%p] cannot allocate data fragment",
|
||||
slip);
|
||||
net_nbuf_unref(slip->rx);
|
||||
net_pkt_unref(slip->rx);
|
||||
slip->rx = NULL;
|
||||
slip->last = NULL;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#define NET_ARP_BUF(buf) ((struct net_arp_hdr *)net_nbuf_ip_data(buf))
|
||||
#define NET_ARP_BUF(buf) ((struct net_arp_hdr *)net_pkt_ip_data(buf))
|
||||
|
||||
struct net_arp_hdr {
|
||||
uint16_t hwtype; /* HTYPE */
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include <net/net_ip.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <misc/util.h>
|
||||
|
||||
#define NET_ETH_BUF(buf) ((struct net_eth_hdr *)net_nbuf_ll(buf))
|
||||
#define NET_ETH_BUF(buf) ((struct net_eth_hdr *)net_pkt_ll(buf))
|
||||
|
||||
#define NET_ETH_PTYPE_ARP 0x0806
|
||||
#define NET_ETH_PTYPE_IP 0x0800
|
||||
|
|
|
@ -139,18 +139,18 @@ typedef void (*net_context_connect_cb_t)(struct net_context *context,
|
|||
int status,
|
||||
void *user_data);
|
||||
|
||||
/* The net_nbuf_get_pool_func_t is here in order to avoid circular
|
||||
* dependency between nbuf.h and net_context.h
|
||||
/* The net_pkt_get_pool_func_t is here in order to avoid circular
|
||||
* dependency between net_pkt.h and net_context.h
|
||||
*/
|
||||
/**
|
||||
* @typedef net_nbuf_get_pool_func_t
|
||||
* @typedef net_pkt_get_pool_func_t
|
||||
*
|
||||
* @brief Function that is called to get the pool that is used
|
||||
* for net_buf allocations.
|
||||
*
|
||||
* @return Pointer to valid struct net_buf_pool instance.
|
||||
*/
|
||||
typedef struct net_buf_pool *(*net_nbuf_get_pool_func_t)(void);
|
||||
typedef struct net_buf_pool *(*net_pkt_get_pool_func_t)(void);
|
||||
|
||||
struct net_tcp;
|
||||
|
||||
|
@ -197,15 +197,15 @@ struct net_context {
|
|||
*/
|
||||
void *user_data;
|
||||
|
||||
#if defined(CONFIG_NET_CONTEXT_NBUF_POOL)
|
||||
#if defined(CONFIG_NET_CONTEXT_NET_PKT_POOL)
|
||||
/** Get TX net_buf pool for this context.
|
||||
*/
|
||||
net_nbuf_get_pool_func_t tx_pool;
|
||||
net_pkt_get_pool_func_t tx_pool;
|
||||
|
||||
/** Get DATA net_buf pool for this context.
|
||||
*/
|
||||
net_nbuf_get_pool_func_t data_pool;
|
||||
#endif /* CONFIG_NET_CONTEXT_NBUF_POOL */
|
||||
net_pkt_get_pool_func_t data_pool;
|
||||
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
|
||||
|
||||
#if defined(CONFIG_NET_CONTEXT_SYNC_RECV)
|
||||
/**
|
||||
|
@ -733,10 +733,10 @@ void net_context_foreach(net_context_cb_t cb, void *user_data);
|
|||
* to the caller. The DATA pool is used to store data that is sent to
|
||||
* the network.
|
||||
*/
|
||||
#if defined(CONFIG_NET_CONTEXT_NBUF_POOL)
|
||||
#if defined(CONFIG_NET_CONTEXT_NET_PKT_POOL)
|
||||
static inline void net_context_setup_pools(struct net_context *context,
|
||||
net_nbuf_get_pool_func_t tx_pool,
|
||||
net_nbuf_get_pool_func_t data_pool)
|
||||
net_pkt_get_pool_func_t tx_pool,
|
||||
net_pkt_get_pool_func_t data_pool)
|
||||
{
|
||||
NET_ASSERT(context);
|
||||
NET_ASSERT(tx_pool);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -17,10 +17,10 @@ CONFIG_NET_DEBUG_L2_BLUETOOTH=y
|
|||
CONFIG_SYS_LOG_SHOW_COLOR=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
|
@ -158,9 +158,9 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
int header_len, recv_len, reply_len;
|
||||
|
||||
printk("%s received %d bytes", name,
|
||||
net_nbuf_appdatalen(buf));
|
||||
net_pkt_appdatalen(buf));
|
||||
|
||||
reply_buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
reply_buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
|
||||
recv_len = net_buf_frags_len(buf->frags);
|
||||
|
||||
|
@ -171,7 +171,7 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
/* First fragment will contain IP header so move the data
|
||||
* down in order to get rid of it.
|
||||
*/
|
||||
header_len = net_nbuf_appdata(buf) - tmp->data;
|
||||
header_len = net_pkt_appdata(buf) - tmp->data;
|
||||
|
||||
/* After this pull, the tmp->data points directly to application
|
||||
* data.
|
||||
|
@ -216,7 +216,7 @@ static void udp_received(struct net_context *context,
|
|||
{
|
||||
struct net_buf *reply_buf;
|
||||
struct sockaddr dst_addr;
|
||||
sa_family_t family = net_nbuf_family(buf);
|
||||
sa_family_t family = net_pkt_family(buf);
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
int ret;
|
||||
|
||||
|
@ -227,7 +227,7 @@ static void udp_received(struct net_context *context,
|
|||
|
||||
reply_buf = build_reply_buf(dbg, context, buf);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
ret = net_context_sendto(reply_buf, &dst_addr,
|
||||
family == AF_INET6 ?
|
||||
|
@ -238,7 +238,7 @@ static void udp_received(struct net_context *context,
|
|||
user_data);
|
||||
if (ret < 0) {
|
||||
printk("Cannot send data to peer (%d)", ret);
|
||||
net_nbuf_unref(reply_buf);
|
||||
net_pkt_unref(reply_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ static void tcp_received(struct net_context *context,
|
|||
void *user_data)
|
||||
{
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
sa_family_t family = net_nbuf_family(buf);
|
||||
sa_family_t family = net_pkt_family(buf);
|
||||
struct net_buf *reply_buf;
|
||||
int ret;
|
||||
|
||||
|
@ -274,7 +274,7 @@ static void tcp_received(struct net_context *context,
|
|||
NULL);
|
||||
if (ret < 0) {
|
||||
printk("Cannot send data to peer (%d)", ret);
|
||||
net_nbuf_unref(reply_buf);
|
||||
net_pkt_unref(reply_buf);
|
||||
|
||||
quit();
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <net/net_context.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include "udp.h"
|
||||
#include "udp_cfg.h"
|
||||
|
||||
|
@ -70,7 +70,7 @@ struct zoap_reply replies[NUM_REPLIES];
|
|||
|
||||
#define ZOAP_BUF_SIZE 128
|
||||
|
||||
NET_BUF_POOL_DEFINE(zoap_nbuf_pool, 4, 0, sizeof(struct net_nbuf), NULL);
|
||||
NET_BUF_POOL_DEFINE(zoap_pkt_pool, 4, 0, sizeof(struct net_pkt), NULL);
|
||||
NET_BUF_POOL_DEFINE(zoap_data_pool, 4, ZOAP_BUF_SIZE, 0, NULL);
|
||||
|
||||
static const char *const test_path[] = { "test", NULL };
|
||||
|
@ -186,7 +186,7 @@ void dtls_client(void)
|
|||
struct dtls_timing_context timer;
|
||||
struct zoap_packet request, pkt;
|
||||
struct zoap_reply *reply;
|
||||
struct net_buf *nbuf, *frag;
|
||||
struct net_buf *buf, *frag;
|
||||
uint8_t observe = 0;
|
||||
const char *const *p;
|
||||
uint16_t len;
|
||||
|
@ -281,8 +281,8 @@ void dtls_client(void)
|
|||
|
||||
/* Write to server */
|
||||
retry:
|
||||
nbuf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
if (!nbuf) {
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -291,9 +291,9 @@ retry:
|
|||
goto exit;
|
||||
}
|
||||
|
||||
net_buf_frag_add(nbuf, frag);
|
||||
net_buf_frag_add(buf, frag);
|
||||
|
||||
ret = zoap_packet_init(&request, nbuf);
|
||||
ret = zoap_packet_init(&request, buf);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ retry:
|
|||
} while (ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
|
||||
net_buf_unref(nbuf);
|
||||
net_buf_unref(buf);
|
||||
|
||||
if (ret <= 0) {
|
||||
mbedtls_printf("mbedtls_ssl_write failed returned 0x%x\n",
|
||||
|
@ -344,8 +344,8 @@ retry:
|
|||
goto exit;
|
||||
}
|
||||
|
||||
nbuf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
if (!nbuf) {
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
mbedtls_printf("Could not get buffer from pool\n");
|
||||
goto exit;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ retry:
|
|||
goto exit;
|
||||
}
|
||||
|
||||
net_buf_frag_add(nbuf, frag);
|
||||
net_buf_frag_add(buf, frag);
|
||||
len = ZOAP_BUF_SIZE - 1;
|
||||
memset(frag->data, 0, ZOAP_BUF_SIZE);
|
||||
|
||||
|
@ -366,7 +366,7 @@ retry:
|
|||
ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
|
||||
if (ret <= 0) {
|
||||
net_buf_unref(nbuf);
|
||||
net_buf_unref(buf);
|
||||
|
||||
switch (ret) {
|
||||
case MBEDTLS_ERR_SSL_TIMEOUT:
|
||||
|
@ -388,7 +388,7 @@ retry:
|
|||
len = ret;
|
||||
frag->len = len;
|
||||
|
||||
ret = zoap_packet_parse(&pkt, nbuf);
|
||||
ret = zoap_packet_parse(&pkt, buf);
|
||||
if (ret) {
|
||||
mbedtls_printf("Could not parse packet\n");
|
||||
goto exit;
|
||||
|
@ -399,7 +399,7 @@ retry:
|
|||
mbedtls_printf("No handler for response (%d)\n", ret);
|
||||
}
|
||||
|
||||
net_buf_unref(nbuf);
|
||||
net_buf_unref(buf);
|
||||
mbedtls_ssl_close_notify(&ssl);
|
||||
exit:
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zephyr.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -44,7 +44,7 @@ static void udp_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
ctx->rx_nbuf = buf;
|
||||
ctx->rx_pkt = buf;
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,12 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
udp_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(udp_ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(udp_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
return MBEDTLS_ERR_SSL_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
rc = net_context_sendto(send_buf, &dst_addr,
|
||||
addrlen, NULL, K_FOREVER, NULL, NULL);
|
||||
if (rc < 0) {
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -97,13 +97,13 @@ int udp_rx(void *context, unsigned char *buf, size_t size, uint32_t timeout)
|
|||
return MBEDTLS_ERR_SSL_TIMEOUT;
|
||||
}
|
||||
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
if (read_bytes > size) {
|
||||
return MBEDTLS_ERR_SSL_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
ptr = net_nbuf_appdata(ctx->rx_nbuf);
|
||||
rx_buf = ctx->rx_nbuf->frags;
|
||||
ptr = net_pkt_appdata(ctx->rx_pkt);
|
||||
rx_buf = ctx->rx_pkt->frags;
|
||||
len = rx_buf->len - (ptr - rx_buf->data);
|
||||
pos = 0;
|
||||
|
||||
|
@ -120,8 +120,8 @@ int udp_rx(void *context, unsigned char *buf, size_t size, uint32_t timeout)
|
|||
len = rx_buf->len;
|
||||
}
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
|
||||
if (read_bytes != pos) {
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
|
@ -176,7 +176,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
};
|
||||
|
|
|
@ -27,10 +27,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -9,10 +9,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <net/net_context.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/buf.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_ip.h>
|
||||
|
||||
#include <net/zoap.h>
|
||||
|
@ -60,7 +60,7 @@ static unsigned char heap[8192];
|
|||
|
||||
#define ZOAP_BUF_SIZE 128
|
||||
|
||||
NET_BUF_POOL_DEFINE(zoap_nbuf_pool, 4, 0, sizeof(struct net_nbuf), NULL);
|
||||
NET_BUF_POOL_DEFINE(zoap_pkt_pool, 4, 0, sizeof(struct net_pkt), NULL);
|
||||
NET_BUF_POOL_DEFINE(zoap_data_pool, 4, ZOAP_BUF_SIZE, 0, NULL);
|
||||
|
||||
/*
|
||||
|
@ -92,7 +92,7 @@ static int send_response(struct zoap_packet *request, uint8_t response_code)
|
|||
printk("type: %u code %u id %u\n", type, code, id);
|
||||
printk("*******\n");
|
||||
|
||||
buf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ static int piggyback_get(struct zoap_resource *resource,
|
|||
printk("type: %u code %u id %u\n", type, code, id);
|
||||
printk("*******\n");
|
||||
|
||||
buf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ static int query_get(struct zoap_resource *resource,
|
|||
|
||||
printk("*******\n");
|
||||
|
||||
buf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ void dtls_server(void)
|
|||
struct udp_context ctx;
|
||||
struct dtls_timing_context timer;
|
||||
struct zoap_packet pkt;
|
||||
struct net_buf *nbuf, *frag;
|
||||
struct net_buf *buf, *frag;
|
||||
|
||||
mbedtls_ssl_cookie_ctx cookie_ctx;
|
||||
mbedtls_entropy_context entropy;
|
||||
|
@ -549,8 +549,8 @@ reset:
|
|||
|
||||
do {
|
||||
/* Read the request */
|
||||
nbuf = net_buf_alloc(&zoap_nbuf_pool, K_NO_WAIT);
|
||||
if (!nbuf) {
|
||||
buf = net_buf_alloc(&zoap_pkt_pool, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
mbedtls_printf("Could not get buffer from pool\n");
|
||||
goto exit;
|
||||
}
|
||||
|
@ -561,7 +561,7 @@ reset:
|
|||
goto exit;
|
||||
}
|
||||
|
||||
net_buf_frag_add(nbuf, frag);
|
||||
net_buf_frag_add(buf, frag);
|
||||
len = ZOAP_BUF_SIZE - 1;
|
||||
memset(frag->data, 0, ZOAP_BUF_SIZE);
|
||||
|
||||
|
@ -572,7 +572,7 @@ reset:
|
|||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
net_buf_unref(nbuf);
|
||||
net_buf_unref(buf);
|
||||
|
||||
switch (ret) {
|
||||
case MBEDTLS_ERR_SSL_TIMEOUT:
|
||||
|
@ -594,7 +594,7 @@ reset:
|
|||
len = ret;
|
||||
frag->len = len;
|
||||
|
||||
ret = zoap_packet_parse(&pkt, nbuf);
|
||||
ret = zoap_packet_parse(&pkt, buf);
|
||||
if (ret) {
|
||||
mbedtls_printf("Could not parse packet\n");
|
||||
goto exit;
|
||||
|
@ -607,7 +607,7 @@ reset:
|
|||
ret);
|
||||
}
|
||||
|
||||
net_buf_unref(nbuf);
|
||||
net_buf_unref(buf);
|
||||
|
||||
} while (1);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zephyr.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -33,7 +33,7 @@ static void udp_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
ctx->rx_nbuf = buf;
|
||||
ctx->rx_pkt = buf;
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
net_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(net_ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(net_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
return -EIO;
|
||||
|
@ -66,7 +66,7 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
if (rc < 0) {
|
||||
printk("Cannot send data to peer (%d)\n", rc);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -86,16 +86,16 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
|
||||
k_sem_take(&ctx->rx_sem, K_FOREVER);
|
||||
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
if (read_bytes > size) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rx_buf = ctx->rx_nbuf;
|
||||
rx_buf = ctx->rx_pkt;
|
||||
|
||||
set_client_address(&net_ctx->remote, rx_buf);
|
||||
|
||||
ptr = net_nbuf_appdata(rx_buf);
|
||||
ptr = net_pkt_appdata(rx_buf);
|
||||
rx_buf = rx_buf->frags;
|
||||
len = rx_buf->len - (ptr - rx_buf->data);
|
||||
pos = 0;
|
||||
|
@ -113,8 +113,8 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
len = rx_buf->len;
|
||||
}
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
|
||||
if (read_bytes != pos) {
|
||||
return -EIO;
|
||||
|
@ -169,7 +169,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
char client_id;
|
||||
|
|
|
@ -5,10 +5,10 @@ CONFIG_NET_ARP=y
|
|||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_DHCPV4=y
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=5
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=5
|
||||
CONFIG_NET_PKT_RX_COUNT=4
|
||||
CONFIG_NET_PKT_TX_COUNT=4
|
||||
CONFIG_NET_BUF_RX_COUNT=5
|
||||
CONFIG_NET_BUF_TX_COUNT=5
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_NET_IPV4=y
|
|||
CONFIG_NET_ARP=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_DHCPV4=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=4
|
||||
CONFIG_NET_PKT_TX_COUNT=4
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_UDP=y
|
|||
CONFIG_NET_DHCPV4=y
|
||||
CONFIG_NET_SLIP_TAP=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=14
|
||||
CONFIG_NET_PKT_RX_COUNT=4
|
||||
CONFIG_NET_PKT_TX_COUNT=4
|
||||
CONFIG_NET_BUF_RX_COUNT=14
|
||||
CONFIG_NET_BUF_TX_COUNT=14
|
||||
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_RANDOM_GENERATOR=y
|
|||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=14
|
||||
CONFIG_NET_PKT_RX_COUNT=4
|
||||
CONFIG_NET_PKT_TX_COUNT=4
|
||||
CONFIG_NET_BUF_RX_COUNT=14
|
||||
CONFIG_NET_BUF_TX_COUNT=14
|
||||
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
|
||||
|
@ -16,7 +16,7 @@ CONFIG_NET_LOG=y
|
|||
CONFIG_SYS_LOG=y
|
||||
CONFIG_SYS_LOG_NET_LEVEL=4
|
||||
CONFIG_SYS_LOG_SHOW_COLOR=y
|
||||
#CONFIG_NET_DEBUG_NET_BUF=y
|
||||
#CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_DNS_RESOLVE=y
|
||||
#CONFIG_NET_DEBUG_CONTEXT=y
|
||||
#CONFIG_NET_DEBUG_CORE=y
|
||||
|
|
|
@ -11,10 +11,10 @@ CONFIG_NET_IPV4=y
|
|||
CONFIG_NET_IPV6=n
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
CONFIG_NET_NBUF_RX_COUNT=2
|
||||
CONFIG_NET_NBUF_TX_COUNT=3
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=6
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=6
|
||||
CONFIG_NET_PKT_RX_COUNT=2
|
||||
CONFIG_NET_PKT_TX_COUNT=3
|
||||
CONFIG_NET_BUF_RX_COUNT=6
|
||||
CONFIG_NET_BUF_TX_COUNT=6
|
||||
|
||||
# ENC28J60 Ethernet Device
|
||||
CONFIG_ETH_ENC28J60=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -23,7 +23,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -18,10 +18,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -3,10 +3,10 @@ CONFIG_ARC_INIT=n
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -25,7 +25,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -8,10 +8,10 @@ CONFIG_NET_UDP=y
|
|||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
|
||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -23,7 +23,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
CONFIG_NETWORKING=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -23,7 +23,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_BLUETOOTH=n
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_TX_STACK_SIZE=2048
|
||||
CONFIG_NET_RX_STACK_SIZE=2048
|
||||
|
@ -31,7 +31,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -24,7 +24,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -10,10 +10,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -13,10 +13,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -8,10 +8,10 @@ CONFIG_NET_UDP=y
|
|||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_STATISTICS=n
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=36
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=36
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=36
|
||||
CONFIG_NET_BUF_TX_COUNT=36
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
|
@ -75,10 +75,10 @@ static int ipsum_len;
|
|||
/* Note that both tcp and udp can share the same pool but in this
|
||||
* example the UDP context and TCP context have separate pools.
|
||||
*/
|
||||
#if defined(CONFIG_NET_CONTEXT_NBUF_POOL)
|
||||
#if defined(CONFIG_NET_CONTEXT_NET_PKT_POOL)
|
||||
#if defined(CONFIG_NET_TCP)
|
||||
NET_NBUF_TX_POOL_DEFINE(echo_tx_tcp, 15);
|
||||
NET_NBUF_DATA_POOL_DEFINE(echo_data_tcp, 30);
|
||||
NET_PKT_TX_POOL_DEFINE(echo_tx_tcp, 15);
|
||||
NET_PKT_DATA_POOL_DEFINE(echo_data_tcp, 30);
|
||||
|
||||
static struct net_buf_pool *tx_tcp_pool(void)
|
||||
{
|
||||
|
@ -92,8 +92,8 @@ static struct net_buf_pool *data_tcp_pool(void)
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_UDP)
|
||||
NET_NBUF_TX_POOL_DEFINE(echo_tx_udp, 5);
|
||||
NET_NBUF_DATA_POOL_DEFINE(echo_data_udp, 20);
|
||||
NET_PKT_TX_POOL_DEFINE(echo_tx_udp, 5);
|
||||
NET_PKT_DATA_POOL_DEFINE(echo_data_udp, 20);
|
||||
|
||||
static struct net_buf_pool *tx_udp_pool(void)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ static struct net_buf_pool *data_udp_pool(void)
|
|||
return &echo_data_udp;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_NET_CONTEXT_NBUF_POOL */
|
||||
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
|
||||
|
||||
#define MY_PORT 8484
|
||||
#define PEER_PORT 4242
|
||||
|
@ -396,11 +396,11 @@ static struct net_buf *prepare_send_buf(const char *name,
|
|||
struct net_buf *send_buf;
|
||||
bool status;
|
||||
|
||||
send_buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
|
||||
NET_ASSERT(send_buf);
|
||||
|
||||
status = net_nbuf_append(send_buf, expecting_len, lorem_ipsum,
|
||||
status = net_pkt_append(send_buf, expecting_len, lorem_ipsum,
|
||||
K_FOREVER);
|
||||
if (!status) {
|
||||
NET_ERR("%s: cannot create send buf", name);
|
||||
|
@ -455,7 +455,7 @@ static inline void set_dst_addr(sa_family_t family,
|
|||
#if defined(CONFIG_NET_UDP)
|
||||
static bool compare_udp_data(struct net_buf *buf, int expecting_len)
|
||||
{
|
||||
uint8_t *ptr = net_nbuf_appdata(buf);
|
||||
uint8_t *ptr = net_pkt_appdata(buf);
|
||||
int pos = 0;
|
||||
int len;
|
||||
|
||||
|
@ -542,7 +542,7 @@ static bool send_udp_data(struct net_context *udp,
|
|||
proto);
|
||||
if (ret < 0) {
|
||||
NET_ERR("Cannot send %s data to peer (%d)", proto, ret);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
} else {
|
||||
status = true;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ static void udp_received(struct net_context *context,
|
|||
int status,
|
||||
void *user_data)
|
||||
{
|
||||
sa_family_t family = net_nbuf_family(buf);
|
||||
sa_family_t family = net_pkt_family(buf);
|
||||
struct data *data = user_data;
|
||||
struct k_sem *recv;
|
||||
|
||||
|
@ -569,16 +569,16 @@ static void udp_received(struct net_context *context,
|
|||
recv = &conf.recv_ipv6;
|
||||
}
|
||||
|
||||
if (data->expecting_udp != net_nbuf_appdatalen(buf)) {
|
||||
if (data->expecting_udp != net_pkt_appdatalen(buf)) {
|
||||
NET_ERR("Sent %d bytes, received %u bytes",
|
||||
data->expecting_udp, net_nbuf_appdatalen(buf));
|
||||
data->expecting_udp, net_pkt_appdatalen(buf));
|
||||
}
|
||||
|
||||
if (!compare_udp_data(buf, data->expecting_udp)) {
|
||||
NET_DBG("Data mismatch");
|
||||
}
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
k_sem_give(recv);
|
||||
}
|
||||
|
@ -616,7 +616,7 @@ static void send_udp(struct net_context *udp,
|
|||
static bool compare_tcp_data(struct net_buf *buf, int expecting_len,
|
||||
int received_len)
|
||||
{
|
||||
uint8_t *ptr = net_nbuf_appdata(buf), *start;
|
||||
uint8_t *ptr = net_pkt_appdata(buf), *start;
|
||||
int pos = 0;
|
||||
struct net_buf *frag;
|
||||
int len;
|
||||
|
@ -650,7 +650,7 @@ static bool compare_tcp_data(struct net_buf *buf, int expecting_len,
|
|||
len = frag->len;
|
||||
}
|
||||
|
||||
NET_DBG("Compared %d bytes, all ok", net_nbuf_appdatalen(buf));
|
||||
NET_DBG("Compared %d bytes, all ok", net_pkt_appdatalen(buf));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -665,27 +665,27 @@ static void tcp_received(struct net_context *context,
|
|||
|
||||
ARG_UNUSED(status);
|
||||
|
||||
if (!buf || net_nbuf_appdatalen(buf) == 0) {
|
||||
if (!buf || net_pkt_appdatalen(buf) == 0) {
|
||||
if (buf) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (net_nbuf_family(buf) == AF_INET6) {
|
||||
if (net_pkt_family(buf) == AF_INET6) {
|
||||
proto = "IPv6";
|
||||
} else {
|
||||
proto = "IPv4";
|
||||
}
|
||||
|
||||
NET_DBG("Sent %d bytes, received %u bytes",
|
||||
data->expecting_tcp, net_nbuf_appdatalen(buf));
|
||||
data->expecting_tcp, net_pkt_appdatalen(buf));
|
||||
|
||||
if (!compare_tcp_data(buf, data->expecting_tcp, data->received_tcp)) {
|
||||
NET_DBG("Data mismatch");
|
||||
} else {
|
||||
data->received_tcp += net_nbuf_appdatalen(buf);
|
||||
data->received_tcp += net_pkt_appdatalen(buf);
|
||||
}
|
||||
|
||||
if (data->expecting_tcp <= data->received_tcp) {
|
||||
|
@ -693,7 +693,7 @@ static void tcp_received(struct net_context *context,
|
|||
send_tcp_data(context, proto, data);
|
||||
}
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
static void setup_tcp_recv(struct net_context *tcp,
|
||||
|
@ -752,7 +752,7 @@ static bool send_tcp_data(struct net_context *ctx,
|
|||
UINT_TO_POINTER(len), proto);
|
||||
if (ret < 0) {
|
||||
NET_ERR("Cannot send %s data to peer (%d)", proto, ret);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
} else {
|
||||
status = true;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ CONFIG_NET_IPV4=y
|
|||
CONFIG_NET_IPV6=n
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
CONFIG_NET_NBUF_RX_COUNT=5
|
||||
CONFIG_NET_NBUF_TX_COUNT=2
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=6
|
||||
CONFIG_NET_PKT_RX_COUNT=5
|
||||
CONFIG_NET_PKT_TX_COUNT=2
|
||||
CONFIG_NET_BUF_RX_COUNT=10
|
||||
CONFIG_NET_BUF_TX_COUNT=6
|
||||
|
||||
# ENC28J60 Ethernet Device
|
||||
CONFIG_ETH_ENC28J60=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -23,7 +23,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -19,10 +19,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -3,10 +3,10 @@ CONFIG_ARC_INIT=n
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -25,7 +25,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -8,10 +8,10 @@ CONFIG_NET_UDP=y
|
|||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=5
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
|
||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -23,7 +23,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
CONFIG_NETWORKING=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -22,7 +22,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_BLUETOOTH=n
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=20
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_TX_STACK_SIZE=4096
|
||||
|
||||
|
@ -30,7 +30,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=5
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=5
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -24,7 +24,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -11,10 +11,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=40
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=40
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=40
|
||||
CONFIG_NET_BUF_TX_COUNT=40
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=16
|
||||
|
|
|
@ -13,10 +13,10 @@ CONFIG_SYS_LOG_SHOW_COLOR=y
|
|||
CONFIG_INIT_STACKS=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -8,10 +8,10 @@ CONFIG_NET_UDP=y
|
|||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_STATISTICS=n
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=36
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=36
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=36
|
||||
CONFIG_NET_BUF_TX_COUNT=36
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=2
|
||||
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=1
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <sections.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
|
@ -54,10 +54,10 @@ static struct in_addr in4addr_my = MY_IP4ADDR;
|
|||
/* Note that both tcp and udp can share the same pool but in this
|
||||
* example the UDP context and TCP context have separate pools.
|
||||
*/
|
||||
#if defined(CONFIG_NET_CONTEXT_NBUF_POOL)
|
||||
#if defined(CONFIG_NET_CONTEXT_NET_PKT_POOL)
|
||||
#if defined(CONFIG_NET_TCP)
|
||||
NET_NBUF_TX_POOL_DEFINE(echo_tx_tcp, 15);
|
||||
NET_NBUF_DATA_POOL_DEFINE(echo_data_tcp, 30);
|
||||
NET_PKT_TX_POOL_DEFINE(echo_tx_tcp, 15);
|
||||
NET_PKT_DATA_POOL_DEFINE(echo_data_tcp, 30);
|
||||
|
||||
static struct net_buf_pool *tx_tcp_pool(void)
|
||||
{
|
||||
|
@ -71,8 +71,8 @@ static struct net_buf_pool *data_tcp_pool(void)
|
|||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_UDP)
|
||||
NET_NBUF_TX_POOL_DEFINE(echo_tx_udp, 5);
|
||||
NET_NBUF_DATA_POOL_DEFINE(echo_data_udp, 20);
|
||||
NET_PKT_TX_POOL_DEFINE(echo_tx_udp, 5);
|
||||
NET_PKT_DATA_POOL_DEFINE(echo_data_udp, 20);
|
||||
|
||||
static struct net_buf_pool *tx_udp_pool(void)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ static struct net_buf_pool *data_udp_pool(void)
|
|||
return &echo_data_udp;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_NET_CONTEXT_NBUF_POOL */
|
||||
#endif /* CONFIG_NET_CONTEXT_NET_PKT_POOL */
|
||||
|
||||
#define MY_PORT 4242
|
||||
|
||||
|
@ -282,13 +282,13 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
int header_len, recv_len, reply_len;
|
||||
|
||||
NET_INFO("%s received %d bytes", name,
|
||||
net_nbuf_appdatalen(buf));
|
||||
net_pkt_appdatalen(buf));
|
||||
|
||||
if (net_nbuf_appdatalen(buf) == 0) {
|
||||
if (net_pkt_appdatalen(buf) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
reply_buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
reply_buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
|
||||
NET_ASSERT(reply_buf);
|
||||
|
||||
|
@ -299,9 +299,9 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
/* First fragment will contain IP header so move the data
|
||||
* down in order to get rid of it.
|
||||
*/
|
||||
header_len = net_nbuf_appdata(buf) - tmp->data;
|
||||
header_len = net_pkt_appdata(buf) - tmp->data;
|
||||
|
||||
NET_ASSERT(header_len < CONFIG_NET_NBUF_DATA_SIZE);
|
||||
NET_ASSERT(header_len < CONFIG_NET_BUF_DATA_SIZE);
|
||||
|
||||
/* After this pull, the tmp->data points directly to application
|
||||
* data.
|
||||
|
@ -309,7 +309,7 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
net_buf_pull(tmp, header_len);
|
||||
|
||||
while (tmp) {
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
|
||||
if (!net_buf_headroom(tmp)) {
|
||||
/* If there is no link layer headers in the
|
||||
|
@ -326,7 +326,7 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
* in sending side we add the link layer
|
||||
* header if needed.
|
||||
*/
|
||||
net_nbuf_set_ll_reserve(reply_buf, 0);
|
||||
net_pkt_set_ll_reserve(reply_buf, 0);
|
||||
}
|
||||
|
||||
NET_ASSERT(net_buf_tailroom(frag) >= tmp->len);
|
||||
|
@ -335,7 +335,7 @@ static struct net_buf *build_reply_buf(const char *name,
|
|||
|
||||
net_buf_frag_add(reply_buf, frag);
|
||||
|
||||
tmp = net_nbuf_frag_del(buf, tmp);
|
||||
tmp = net_pkt_frag_del(buf, tmp);
|
||||
}
|
||||
|
||||
reply_len = net_buf_frags_len(reply_buf->frags);
|
||||
|
@ -388,7 +388,7 @@ static void udp_received(struct net_context *context,
|
|||
{
|
||||
struct net_buf *reply_buf;
|
||||
struct sockaddr dst_addr;
|
||||
sa_family_t family = net_nbuf_family(buf);
|
||||
sa_family_t family = net_pkt_family(buf);
|
||||
static char dbg[MAX_DBG_PRINT + 1];
|
||||
int ret;
|
||||
|
||||
|
@ -399,7 +399,7 @@ static void udp_received(struct net_context *context,
|
|||
|
||||
reply_buf = build_reply_buf(dbg, context, buf);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
if (!reply_buf) {
|
||||
return;
|
||||
|
@ -414,7 +414,7 @@ static void udp_received(struct net_context *context,
|
|||
user_data);
|
||||
if (ret < 0) {
|
||||
NET_ERR("Cannot send data to peer (%d)", ret);
|
||||
net_nbuf_unref(reply_buf);
|
||||
net_pkt_unref(reply_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,14 +455,14 @@ static void tcp_received(struct net_context *context,
|
|||
return;
|
||||
}
|
||||
|
||||
family = net_nbuf_family(buf);
|
||||
family = net_pkt_family(buf);
|
||||
|
||||
snprintk(dbg, MAX_DBG_PRINT, "TCP IPv%c",
|
||||
family == AF_INET6 ? '6' : '4');
|
||||
|
||||
reply_buf = build_reply_buf(dbg, context, buf);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
if (!reply_buf) {
|
||||
return;
|
||||
|
@ -473,7 +473,7 @@ static void tcp_received(struct net_context *context,
|
|||
NULL);
|
||||
if (ret < 0) {
|
||||
NET_ERR("Cannot send data to peer (%d)", ret);
|
||||
net_nbuf_unref(reply_buf);
|
||||
net_pkt_unref(reply_buf);
|
||||
|
||||
quit();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ CONFIG_NET_L2_ETHERNET=y
|
|||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=64
|
||||
CONFIG_NET_NBUF_TX_COUNT=64
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=64
|
||||
CONFIG_NET_PKT_TX_COUNT=64
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -34,4 +34,4 @@ CONFIG_NET_APP_PEER_IPV4_ADDR="192.168.1.10"
|
|||
|
||||
# See the config.h file and the LINEARIZE_BUFFER define
|
||||
#
|
||||
#CONFIG_NET_NBUF_DATA_SIZE=512
|
||||
#CONFIG_NET_BUF_DATA_SIZE=512
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_LOG=y
|
|||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
|
|
|
@ -62,13 +62,13 @@
|
|||
* - Linearize the buffer, it works better but consumes more memory
|
||||
*
|
||||
* Comment the following define to test the first case, set the
|
||||
* CONFIG_NET_NBUF_DATA_SIZE variable to 384 or 512. See the
|
||||
* CONFIG_NET_BUF_DATA_SIZE variable to 384 or 512. See the
|
||||
* prj_frdm_k64f.conf file.
|
||||
*/
|
||||
#define LINEARIZE_BUFFER
|
||||
|
||||
#ifndef LINEARIZE_BUFFER
|
||||
#if CONFIG_NET_NBUF_DATA_SIZE <= 256
|
||||
#error set CONFIG_NET_NBUF_DATA_SIZE to 384 or 512
|
||||
#if CONFIG_NET_BUF_DATA_SIZE <= 256
|
||||
#error set CONFIG_NET_BUF_DATA_SIZE to 384 or 512
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <misc/printk.h>
|
||||
#include <net/nbuf.h>
|
||||
|
||||
int http_init(struct http_client_ctx *http_ctx)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "http_client_types.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#ifdef LINEARIZE_BUFFER
|
||||
|
||||
|
@ -31,10 +31,10 @@ void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx)
|
|||
goto lb_exit;
|
||||
}
|
||||
|
||||
data_len = min(net_nbuf_appdatalen(rx), HTTP_POOL_BUF_SIZE);
|
||||
data_len = min(net_pkt_appdatalen(rx), HTTP_POOL_BUF_SIZE);
|
||||
offset = net_buf_frags_len(rx) - data_len;
|
||||
|
||||
rc = net_nbuf_linear_copy(data_buf, rx, offset, data_len);
|
||||
rc = net_pkt_linear_copy(data_buf, rx, offset, data_len);
|
||||
if (rc != 0) {
|
||||
rc = -ENOMEM;
|
||||
goto lb_exit;
|
||||
|
@ -67,7 +67,7 @@ void http_receive_cb(struct tcp_client_ctx *tcp_ctx, struct net_buf *rx)
|
|||
|
||||
http_ctx = CONTAINER_OF(tcp_ctx, struct http_client_ctx, tcp_ctx);
|
||||
|
||||
offset = net_buf_frags_len(buf) - net_nbuf_appdatalen(buf);
|
||||
offset = net_buf_frags_len(buf) - net_pkt_appdatalen(buf);
|
||||
|
||||
/* find the fragment */
|
||||
while (buf && offset >= buf->len) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
|
||||
#include <misc/printk.h>
|
||||
|
||||
|
@ -89,7 +89,7 @@ void recv_cb(struct net_context *net_ctx, struct net_buf *rx, int status,
|
|||
return;
|
||||
}
|
||||
|
||||
if (rx == NULL || net_nbuf_appdatalen(rx) == 0) {
|
||||
if (rx == NULL || net_pkt_appdatalen(rx) == 0) {
|
||||
goto lb_exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ The screen application will display the following information:
|
|||
[print_client_banner:42] Connection accepted
|
||||
Address: 192.168.1.10, port: 54327
|
||||
[http_ctx_get:268] Free ctx found, index: 0
|
||||
[http_write:59] net_nbuf_get_tx, rc: 0 <OK>
|
||||
[http_write:59] net_pkt_get_tx, rc: 0 <OK>
|
||||
[http_write:82] net_context_send: 0 <OK>
|
||||
[http_rx_tx:86] Connection closed by peer
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_L2_ETHERNET=y
|
|||
CONFIG_NET_LOG=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
|
|
|
@ -5,10 +5,10 @@ CONFIG_NET_ARP=y
|
|||
CONFIG_NET_LOG=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_L2_ETHERNET=y
|
|||
CONFIG_NET_LOG=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_LOG=y
|
|||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=8
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=8
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=8
|
||||
CONFIG_NET_BUF_TX_COUNT=8
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <net/http_parser.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define URL_DEFAULT_HANDLER_INDEX 0
|
||||
|
@ -116,7 +116,7 @@ void http_rx_tx(struct net_context *net_ctx, struct net_buf *rx, int status,
|
|||
goto lb_exit;
|
||||
}
|
||||
|
||||
rcv_len = net_nbuf_appdatalen(rx);
|
||||
rcv_len = net_pkt_appdatalen(rx);
|
||||
if (rcv_len == 0) {
|
||||
/* don't print info about zero-length app data buffers */
|
||||
goto lb_exit;
|
||||
|
@ -129,7 +129,7 @@ void http_rx_tx(struct net_context *net_ctx, struct net_buf *rx, int status,
|
|||
}
|
||||
|
||||
offset = net_buf_frags_len(rx) - rcv_len;
|
||||
rc = net_nbuf_linear_copy(data, rx, offset, rcv_len);
|
||||
rc = net_pkt_linear_copy(data, rx, offset, rcv_len);
|
||||
if (rc != 0) {
|
||||
printf("[%s:%d] Linear copy error\n", __func__, __LINE__);
|
||||
goto lb_exit;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "http_utils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <net/nbuf.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define HTTP_STATUS_200_OK "HTTP/1.1 200 OK\r\n" \
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zephyr.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -38,8 +38,8 @@ static void ssl_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
if (!net_nbuf_appdatalen(buf)) {
|
||||
net_nbuf_unref(buf);
|
||||
if (!net_pkt_appdatalen(buf)) {
|
||||
net_pkt_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,14 +71,14 @@ int ssl_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
net_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(net_ctx, K_NO_WAIT);
|
||||
send_buf = net_pkt_get_tx(net_ctx, K_NO_WAIT);
|
||||
if (!send_buf) {
|
||||
return MBEDTLS_ERR_SSL_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ int ssl_tx(void *context, const unsigned char *buf, size_t size)
|
|||
rc = net_context_send(send_buf, ssl_sent, K_NO_WAIT, NULL, ctx);
|
||||
|
||||
if (rc < 0) {
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
@ -107,14 +107,14 @@ int ssl_rx(void *context, unsigned char *buf, size_t size)
|
|||
|
||||
if (ctx->frag == NULL) {
|
||||
rx_data = k_fifo_get(&ctx->rx_fifo, K_FOREVER);
|
||||
ctx->rx_nbuf = rx_data->buf;
|
||||
ctx->rx_pkt = rx_data->buf;
|
||||
k_mem_pool_free(&rx_data->block);
|
||||
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
|
||||
ctx->remaining = read_bytes;
|
||||
ctx->frag = ctx->rx_nbuf->frags;
|
||||
ptr = net_nbuf_appdata(ctx->rx_nbuf);
|
||||
ctx->frag = ctx->rx_pkt->frags;
|
||||
ptr = net_pkt_appdata(ctx->rx_pkt);
|
||||
|
||||
len = ptr - ctx->frag->data;
|
||||
net_buf_pull(ctx->frag, len);
|
||||
|
@ -158,8 +158,8 @@ int ssl_rx(void *context, unsigned char *buf, size_t size)
|
|||
len = ctx->frag->len;
|
||||
}
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->frag = NULL;
|
||||
ctx->remaining = 0;
|
||||
|
||||
|
@ -219,7 +219,7 @@ int ssl_init(struct ssl_context *ctx, void *addr)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = tcp_ctx;
|
||||
|
||||
|
@ -270,7 +270,7 @@ int ssl_init(struct ssl_context *ctx, void *addr)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = tcp_ctx;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ struct rx_fifo_block {
|
|||
|
||||
struct ssl_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
struct net_buf *frag;
|
||||
struct k_sem tx_sem;
|
||||
struct k_fifo rx_fifo;
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_TEST_RANDOM_GENERATOR=y
|
|||
CONFIG_NET_TX_STACK_SIZE=2048
|
||||
CONFIG_NET_RX_STACK_SIZE=2048
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
|
@ -35,7 +35,7 @@ CONFIG_NET_DEBUG_CORE=n
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=n
|
||||
CONFIG_NET_DEBUG_IPV6=n
|
||||
CONFIG_NET_DEBUG_CONTEXT=n
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=n
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_TEST_RANDOM_GENERATOR=y
|
|||
CONFIG_NET_TX_STACK_SIZE=2048
|
||||
CONFIG_NET_RX_STACK_SIZE=2048
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
|
@ -35,7 +35,7 @@ CONFIG_NET_DEBUG_CORE=n
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=n
|
||||
CONFIG_NET_DEBUG_IPV6=n
|
||||
CONFIG_NET_DEBUG_CONTEXT=n
|
||||
CONFIG_NET_DEBUG_NET_BUF=n
|
||||
CONFIG_NET_DEBUG_NET_PKT=n
|
||||
CONFIG_NET_DEBUG_UTILS=n
|
||||
CONFIG_NET_DEBUG_IF=n
|
||||
CONFIG_NET_DEBUG_ICMPV6=n
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_SYS_LOG_SPI_LEVEL=1
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
|
@ -30,7 +30,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -4,10 +4,10 @@ CONFIG_SYS_LOG_SPI_LEVEL=1
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
|
@ -30,7 +30,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=6
|
||||
CONFIG_NET_NBUF_TX_COUNT=6
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=10
|
||||
CONFIG_NET_PKT_RX_COUNT=6
|
||||
CONFIG_NET_PKT_TX_COUNT=6
|
||||
CONFIG_NET_BUF_RX_COUNT=10
|
||||
CONFIG_NET_BUF_TX_COUNT=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -27,7 +27,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=6
|
||||
CONFIG_NET_NBUF_TX_COUNT=6
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=10
|
||||
CONFIG_NET_PKT_RX_COUNT=6
|
||||
CONFIG_NET_PKT_TX_COUNT=6
|
||||
CONFIG_NET_BUF_RX_COUNT=10
|
||||
CONFIG_NET_BUF_TX_COUNT=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -27,7 +27,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
CONFIG_NETWORKING=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=6
|
||||
CONFIG_NET_NBUF_TX_COUNT=6
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=10
|
||||
CONFIG_NET_PKT_RX_COUNT=6
|
||||
CONFIG_NET_PKT_TX_COUNT=6
|
||||
CONFIG_NET_BUF_RX_COUNT=10
|
||||
CONFIG_NET_BUF_TX_COUNT=10
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
CONFIG_NET_IPV6=y
|
||||
|
@ -27,7 +27,7 @@ CONFIG_NET_DEBUG_CORE=y
|
|||
CONFIG_NET_DEBUG_IPV6_NBR_CACHE=y
|
||||
CONFIG_NET_DEBUG_IPV6=y
|
||||
CONFIG_NET_DEBUG_CONTEXT=y
|
||||
CONFIG_NET_DEBUG_NET_BUF=y
|
||||
CONFIG_NET_DEBUG_NET_PKT=y
|
||||
CONFIG_NET_DEBUG_UTILS=y
|
||||
CONFIG_NET_DEBUG_IF=y
|
||||
CONFIG_NET_DEBUG_ICMPV6=y
|
||||
|
|
|
@ -9,10 +9,10 @@ CONFIG_NET_IPV6=y
|
|||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_BUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_SHELL=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
|
|
|
@ -9,10 +9,10 @@ CONFIG_NET_IPV6=y
|
|||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_BUF_RX_COUNT=30
|
||||
CONFIG_NET_BUF_TX_COUNT=30
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_SHELL=y
|
||||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <drivers/rand32.h>
|
||||
#include <errno.h>
|
||||
#include <gpio.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_if.h>
|
||||
|
@ -140,12 +140,12 @@ transmit(struct net_context *ctx, char buffer[], size_t len)
|
|||
{
|
||||
struct net_buf *send_buf;
|
||||
|
||||
send_buf = net_nbuf_get_tx(ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (!net_nbuf_append(send_buf, len, buffer, K_FOREVER)) {
|
||||
if (!net_pkt_append(send_buf, len, buffer, K_FOREVER)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -289,14 +289,14 @@ on_context_recv(struct net_context *ctx, struct net_buf *buf,
|
|||
if (status) {
|
||||
/* TODO: handle connection error */
|
||||
NET_ERR("Connection error: %d\n", -status);
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
/* tmp points to fragment containing IP header */
|
||||
tmp = buf->frags;
|
||||
/* skip pos to the first TCP payload */
|
||||
pos = net_nbuf_appdata(buf) - tmp->data;
|
||||
pos = net_pkt_appdata(buf) - tmp->data;
|
||||
|
||||
while (tmp) {
|
||||
len = tmp->len - pos;
|
||||
|
@ -314,13 +314,13 @@ on_context_recv(struct net_context *ctx, struct net_buf *buf,
|
|||
break;
|
||||
}
|
||||
|
||||
tmp = net_nbuf_read(tmp, pos, &pos, len, cmd_buf + cmd_len);
|
||||
tmp = net_pkt_read(tmp, pos, &pos, len, cmd_buf + cmd_len);
|
||||
cmd_len += len;
|
||||
|
||||
if (end_of_line) {
|
||||
/* skip the /n char after /r */
|
||||
if (tmp) {
|
||||
tmp = net_nbuf_read(tmp, pos, &pos, 1, NULL);
|
||||
tmp = net_pkt_read(tmp, pos, &pos, 1, NULL);
|
||||
}
|
||||
|
||||
cmd_buf[cmd_len] = '\0';
|
||||
|
@ -329,7 +329,7 @@ on_context_recv(struct net_context *ctx, struct net_buf *buf,
|
|||
}
|
||||
}
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
/* TODO: handle messages that spans multiple packets? */
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <misc/byteorder.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_ip.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_context.h>
|
||||
|
||||
#include <net_private.h>
|
||||
|
@ -104,12 +104,12 @@ static int led_get(struct zoap_resource *resource,
|
|||
|
||||
id = zoap_header_get_id(request);
|
||||
|
||||
buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
if (!frag) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ static int led_get(struct zoap_resource *resource,
|
|||
r = net_context_sendto(buf, from, sizeof(struct sockaddr_in6),
|
||||
NULL, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -176,12 +176,12 @@ static int led_post(struct zoap_resource *resource,
|
|||
|
||||
id = zoap_header_get_id(request);
|
||||
|
||||
buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
if (!frag) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ static int led_post(struct zoap_resource *resource,
|
|||
r = net_context_sendto(buf, from, sizeof(struct sockaddr_in6),
|
||||
NULL, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -259,12 +259,12 @@ static int led_put(struct zoap_resource *resource,
|
|||
|
||||
id = zoap_header_get_id(request);
|
||||
|
||||
buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
if (!frag) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ static int led_put(struct zoap_resource *resource,
|
|||
r = net_context_sendto(buf, from, sizeof(struct sockaddr_in6),
|
||||
NULL, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -326,12 +326,12 @@ static int dummy_get(struct zoap_resource *resource,
|
|||
|
||||
id = zoap_header_get_id(request);
|
||||
|
||||
buf = net_nbuf_get_tx(context, K_FOREVER);
|
||||
buf = net_pkt_get_tx(context, K_FOREVER);
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_nbuf_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
if (!frag) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ static int dummy_get(struct zoap_resource *resource,
|
|||
r = net_context_sendto(buf, from, sizeof(struct sockaddr_in6),
|
||||
NULL, 0, NULL, NULL);
|
||||
if (r < 0) {
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -418,20 +418,20 @@ static void udp_receive(struct net_context *context,
|
|||
* zoap expects that buffer->data starts at the
|
||||
* beginning of the CoAP header
|
||||
*/
|
||||
header_len = net_nbuf_appdata(buf) - buf->frags->data;
|
||||
header_len = net_pkt_appdata(buf) - buf->frags->data;
|
||||
net_buf_pull(buf->frags, header_len);
|
||||
|
||||
r = zoap_packet_parse(&request, buf);
|
||||
if (r < 0) {
|
||||
NET_ERR("Invalid data received (%d)\n", r);
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
r = zoap_handle_request(&request, resources,
|
||||
(const struct sockaddr *) &from);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
|
||||
if (r < 0) {
|
||||
NET_ERR("No handler for such request (%d)\n", r);
|
||||
|
|
|
@ -28,10 +28,10 @@ CONFIG_SPI_1_CS_GPIO_PIN=0
|
|||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_BUILTIN=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_COUNT=10
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=20
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=20
|
||||
CONFIG_NET_PKT_RX_COUNT=10
|
||||
CONFIG_NET_PKT_TX_COUNT=10
|
||||
CONFIG_NET_BUF_TX_COUNT=20
|
||||
CONFIG_NET_BUF_RX_COUNT=20
|
||||
|
||||
CONFIG_NET_APP_SETTINGS=y
|
||||
CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::1"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zephyr.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -52,20 +52,20 @@ static void udp_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
if (ctx->rx_nbuf) {
|
||||
if (ctx->rx_pkt) {
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
k_yield();
|
||||
|
||||
if (ctx->rx_nbuf) {
|
||||
if (ctx->rx_pkt) {
|
||||
printk("Packet %p is still being handled, "
|
||||
"dropping %p\n", ctx->rx_nbuf, buf);
|
||||
"dropping %p\n", ctx->rx_pkt, buf);
|
||||
|
||||
net_nbuf_unref(buf);
|
||||
net_pkt_unref(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = buf;
|
||||
ctx->rx_pkt = buf;
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
k_yield();
|
||||
}
|
||||
|
@ -80,16 +80,16 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
udp_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(udp_ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(udp_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
addrlen, NULL, K_FOREVER, NULL, NULL);
|
||||
if (rc < 0) {
|
||||
printk("Cannot send data to peer (%d)\n", rc);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -120,15 +120,15 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
|
||||
k_sem_take(&ctx->rx_sem, K_FOREVER);
|
||||
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
if (read_bytes > size) {
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ptr = net_nbuf_appdata(ctx->rx_nbuf);
|
||||
rx_buf = ctx->rx_nbuf->frags;
|
||||
ptr = net_pkt_appdata(ctx->rx_pkt);
|
||||
rx_buf = ctx->rx_pkt->frags;
|
||||
len = rx_buf->len - (ptr - rx_buf->data);
|
||||
pos = 0;
|
||||
|
||||
|
@ -145,8 +145,8 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
len = rx_buf->len;
|
||||
}
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
|
||||
if (read_bytes != pos) {
|
||||
return -EIO;
|
||||
|
@ -202,7 +202,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
@ -253,7 +253,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <zephyr.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -46,7 +46,7 @@ static void udp_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
ARG_UNUSED(status);
|
||||
|
||||
ctx->rx_nbuf = buf;
|
||||
ctx->rx_pkt = buf;
|
||||
k_sem_give(&ctx->rx_sem);
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
net_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(net_ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(net_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
return -EIO;
|
||||
|
@ -79,7 +79,7 @@ int udp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
if (rc < 0) {
|
||||
printk("Cannot send data to peer (%d)\n", rc);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -99,16 +99,16 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
|
||||
k_sem_take(&ctx->rx_sem, K_FOREVER);
|
||||
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
if (read_bytes > size) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rx_buf = ctx->rx_nbuf;
|
||||
rx_buf = ctx->rx_pkt;
|
||||
|
||||
set_client_address(&net_ctx->remote, rx_buf);
|
||||
|
||||
ptr = net_nbuf_appdata(rx_buf);
|
||||
ptr = net_pkt_appdata(rx_buf);
|
||||
rx_buf = rx_buf->frags;
|
||||
len = rx_buf->len - (ptr - rx_buf->data);
|
||||
pos = 0;
|
||||
|
@ -126,8 +126,8 @@ int udp_rx(void *context, unsigned char *buf, size_t size)
|
|||
len = rx_buf->len;
|
||||
}
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
ctx->rx_nbuf = NULL;
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
ctx->rx_pkt = NULL;
|
||||
|
||||
if (read_bytes != pos) {
|
||||
return -EIO;
|
||||
|
@ -183,7 +183,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
@ -225,7 +225,7 @@ int udp_init(struct udp_context *ctx)
|
|||
goto error;
|
||||
}
|
||||
|
||||
ctx->rx_nbuf = NULL;
|
||||
ctx->rx_pkt = NULL;
|
||||
ctx->remaining = 0;
|
||||
ctx->net_ctx = udp_ctx;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct udp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
struct k_sem rx_sem;
|
||||
int remaining;
|
||||
char client_id;
|
||||
|
|
|
@ -12,10 +12,10 @@ CONFIG_NET_IPV6=n
|
|||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
CONFIG_NET_NBUF_RX_COUNT=4
|
||||
CONFIG_NET_NBUF_TX_COUNT=4
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=6
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=6
|
||||
CONFIG_NET_PKT_RX_COUNT=4
|
||||
CONFIG_NET_PKT_TX_COUNT=4
|
||||
CONFIG_NET_BUF_RX_COUNT=6
|
||||
CONFIG_NET_BUF_TX_COUNT=6
|
||||
|
||||
CONFIG_ETH_ENC28J60=y
|
||||
CONFIG_ETH_ENC28J60_0=y
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
|
||||
#if !defined(CONFIG_MBEDTLS_CFG_FILE)
|
||||
|
@ -37,7 +37,7 @@ static void tcp_received(struct net_context *context,
|
|||
ARG_UNUSED(context);
|
||||
struct tcp_context *ctx = user_data;
|
||||
|
||||
ctx->rx_nbuf = buf;
|
||||
ctx->rx_pkt = buf;
|
||||
}
|
||||
|
||||
int tcp_tx(void *context, const unsigned char *buf, size_t size)
|
||||
|
@ -49,13 +49,13 @@ int tcp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
tcp_ctx = ctx->net_ctx;
|
||||
|
||||
send_buf = net_nbuf_get_tx(tcp_ctx, K_FOREVER);
|
||||
send_buf = net_pkt_get_tx(tcp_ctx, K_FOREVER);
|
||||
if (!send_buf) {
|
||||
printk("cannot create buf\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = net_nbuf_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
rc = net_pkt_append(send_buf, size, (uint8_t *) buf, K_FOREVER);
|
||||
if (!rc) {
|
||||
printk("cannot write buf\n");
|
||||
return -EIO;
|
||||
|
@ -67,7 +67,7 @@ int tcp_tx(void *context, const unsigned char *buf, size_t size)
|
|||
|
||||
if (rc < 0) {
|
||||
printk("Cannot send IPv4 data to peer (%d)\n", rc);
|
||||
net_nbuf_unref(send_buf);
|
||||
net_pkt_unref(send_buf);
|
||||
return -EIO;
|
||||
} else {
|
||||
return len;
|
||||
|
@ -88,22 +88,22 @@ int tcp_rx(void *context, unsigned char *buf, size_t size)
|
|||
printk("net_context_recv failed with code:%d\n", rc);
|
||||
return 0;
|
||||
}
|
||||
read_bytes = net_nbuf_appdatalen(ctx->rx_nbuf);
|
||||
read_bytes = net_pkt_appdatalen(ctx->rx_pkt);
|
||||
|
||||
data = net_buf_alloc(&tcp_msg_pool, APP_SLEEP_MSECS);
|
||||
if (data == NULL) {
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
printk("net_buf_alloc failed\n");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
offset = net_buf_frags_len(ctx->rx_nbuf) - read_bytes;
|
||||
rc = net_nbuf_linear_copy(data, ctx->rx_nbuf, offset, read_bytes);
|
||||
ptr = net_nbuf_appdata(data);
|
||||
offset = net_buf_frags_len(ctx->rx_pkt) - read_bytes;
|
||||
rc = net_pkt_linear_copy(data, ctx->rx_pkt, offset, read_bytes);
|
||||
ptr = net_pkt_appdata(data);
|
||||
memcpy(buf, ptr, read_bytes);
|
||||
|
||||
net_nbuf_unref(ctx->rx_nbuf);
|
||||
net_nbuf_unref(data);
|
||||
net_pkt_unref(ctx->rx_pkt);
|
||||
net_pkt_unref(data);
|
||||
|
||||
return read_bytes;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
struct tcp_context {
|
||||
struct net_context *net_ctx;
|
||||
struct sockaddr local_sock;
|
||||
struct net_buf *rx_nbuf;
|
||||
struct net_buf *rx_pkt;
|
||||
int32_t timeout;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,11 +14,11 @@ CONFIG_NET_IPV6_MAX_NEIGHBORS=8
|
|||
CONFIG_NET_MAX_CONTEXTS=5
|
||||
CONFIG_NET_SHELL=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_DATA_SIZE=256
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=15
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=15
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_DATA_SIZE=256
|
||||
CONFIG_NET_BUF_RX_COUNT=15
|
||||
CONFIG_NET_BUF_TX_COUNT=15
|
||||
|
||||
CONFIG_NET_APP_SETTINGS=y
|
||||
CONFIG_NET_APP_MY_IPV6_ADDR="2001:db8::1"
|
||||
|
|
|
@ -6,16 +6,16 @@ CONFIG_NET_L2_ETHERNET=y
|
|||
CONFIG_NET_LOG=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IFACE_UNICAST_IPV4_ADDR_COUNT=3
|
||||
|
||||
CONFIG_PRINTK=y
|
||||
#CONFIG_NET_DEBUG_NET_BUF=y
|
||||
#CONFIG_NET_DEBUG_NET_PKT=y
|
||||
|
||||
CONFIG_NET_IPV4=n
|
||||
# Enable IPv6 support
|
||||
|
@ -34,4 +34,4 @@ CONFIG_NET_APP_PEER_IPV4_ADDR="192.168.1.10"
|
|||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
|
||||
# For IPv6
|
||||
CONFIG_NET_NBUF_DATA_SIZE=256
|
||||
CONFIG_NET_BUF_DATA_SIZE=256
|
||||
|
|
|
@ -6,10 +6,10 @@ CONFIG_NET_LOG=y
|
|||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_INIT_STACKS=y
|
||||
|
||||
CONFIG_NET_NBUF_RX_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_COUNT=16
|
||||
CONFIG_NET_NBUF_RX_DATA_COUNT=16
|
||||
CONFIG_NET_NBUF_TX_DATA_COUNT=16
|
||||
CONFIG_NET_PKT_RX_COUNT=16
|
||||
CONFIG_NET_PKT_TX_COUNT=16
|
||||
CONFIG_NET_BUF_RX_COUNT=16
|
||||
CONFIG_NET_BUF_TX_COUNT=16
|
||||
|
||||
CONFIG_NET_IPV6_RA_RDNSS=y
|
||||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
|
@ -35,4 +35,4 @@ CONFIG_NET_APP_PEER_IPV4_ADDR="192.0.2.2"
|
|||
CONFIG_MAIN_STACK_SIZE=2048
|
||||
|
||||
# For IPv6
|
||||
CONFIG_NET_NBUF_DATA_SIZE=256
|
||||
CONFIG_NET_BUF_DATA_SIZE=256
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <net/mqtt.h>
|
||||
|
||||
#include <net/net_context.h>
|
||||
#include <net/nbuf.h>
|
||||
|
||||
#include <misc/printk.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -8,9 +8,8 @@ CONFIG_NET_IPV6=y
|
|||
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
|
||||
CONFIG_NET_LOG=y
|
||||
CONFIG_NET_MAX_CONTEXTS=10
|
||||
CONFIG_NET_NBUF_DATA_COUNT=30
|
||||
CONFIG_NET_NBUF_RX_COUNT=14
|
||||
CONFIG_NET_NBUF_TX_COUNT=14
|
||||
CONFIG_NET_PKT_RX_COUNT=14
|
||||
CONFIG_NET_PKT_TX_COUNT=14
|
||||
CONFIG_NET_SHELL=y
|
||||
CONFIG_NET_SLIP_TAP=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <board.h>
|
||||
#include <gpio.h>
|
||||
#include <net/nbuf.h>
|
||||
#include <net/net_context.h>
|
||||
#include <net/net_core.h>
|
||||
#include <net/net_if.h>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue