net: Refactor code to use new generic net_buf API

Change-Id: Id008bbf43062ca0641a76edaabef47c650287444
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2015-10-30 17:42:03 +02:00 committed by Anas Nashif
commit 2272312b8d
121 changed files with 1716 additions and 1537 deletions

View file

@ -67,7 +67,7 @@ static void eth_rx(struct device *port)
goto release_desc;
}
buf = net_buf_get_reserve_rx(0);
buf = ip_buf_get_reserve_rx(0);
if (buf == NULL) {
ETH_ERR("Failed to obtain RX buffer.\n");
goto release_desc;
@ -79,7 +79,7 @@ static void eth_rx(struct device *port)
goto release_desc;
}
memcpy(uip_buf(buf), (void *)context->rx_buf, frm_len);
memcpy(net_buf_add(buf, frm_len), (void *)context->rx_buf, frm_len);
uip_len(buf) = frm_len;
net_driver_ethernet_recv(buf);

377
include/net/ip_buf.h Normal file
View file

@ -0,0 +1,377 @@
/** @file
* @brief IP buffer API
*
* IP data is passed between application and IP stack via a ip_buf struct.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Data buffer API - used for all data to/from net */
#ifndef __IP_BUF_H
#define __IP_BUF_H
#include <stdint.h>
#include <stdbool.h>
#include <net/net_core.h>
#include "contiki/ip/uipopt.h"
#include "contiki/ip/uip.h"
#include "contiki/packetbuf.h"
#if defined(CONFIG_NET_BUF_DEBUG)
#undef DEBUG_IP_BUFS
#define DEBUG_IP_BUFS
#endif
#ifdef DEBUG_IP_BUFS
#define NET_BUF_CHECK_IF_IN_USE(buf) \
do { \
if (buf->ref) { \
NET_ERR("**ERROR** buf %p in use (%s:%s():%d)\n", \
buf, __FILE__, __func__, __LINE__); \
} \
} while (0)
#define NET_BUF_CHECK_IF_NOT_IN_USE(buf) \
do { \
if (!buf->ref) { \
NET_ERR("**ERROR** buf %p not in use (%s:%s():%d)\n",\
buf, __FILE__, __func__, __LINE__); \
} \
} while (0)
#else
#define NET_BUF_CHECK_IF_IN_USE(buf)
#define NET_BUF_CHECK_IF_NOT_IN_USE(buf)
#endif
struct net_context;
/** @cond ignore */
enum ip_buf_type {
IP_BUF_RX = 0,
IP_BUF_TX = 1,
};
/** @endcond */
/** The default MTU is 1280 (minimum IPv6 packet size) + LL header
* In Contiki terms this is UIP_LINK_MTU + UIP_LLH_LEN = UIP_BUFSIZE
*
* Contiki assumes that this value is UIP_BUFSIZE so do not change it
* without changing the value of UIP_BUFSIZE!
*/
#define IP_BUF_MAX_DATA UIP_BUFSIZE
struct ip_buf {
/** @cond ignore */
enum ip_buf_type type;
uint16_t reserve; /* length of the protocol headers */
/* @endcond */
/** Network connection context */
struct net_context *context;
/** @cond ignore */
/* uIP stack specific data */
uint16_t len; /* Contiki will set this to 0 if packet is discarded */
uint8_t uip_ext_len;
uint8_t uip_ext_bitmap;
uint8_t uip_ext_opt_offset;
uint8_t uip_flags;
uint16_t uip_slen;
uint16_t uip_appdatalen;
uint8_t *uip_next_hdr;
void *uip_appdata; /* application data */
void *uip_sappdata; /* app data to be sent */
void *uip_conn;
void *uip_udp_conn;
linkaddr_t dest;
linkaddr_t src;
/* Neighbor discovery vars. Note that we are using void pointers here
* so that we do not need to include Contiki headers in this file.
*/
void *nd6_opt_prefix_info;
void *nd6_prefix;
void *nd6_nbr;
void *nd6_defrt;
void *nd6_ifaddr;
uint8_t *nd6_opt_llao;
uip_ipaddr_t ipaddr;
uint8_t nd6_opt_offset;
/* @endcond */
};
/** @cond ignore */
/* Value returned by ip_buf_len() contains length of all the protocol headers,
* like IP and UDP, and the length of the user payload.
*/
#define ip_buf_len(buf) ((buf)->len)
/* Macros to access net_buf when inside Contiki stack */
#define uip_buf(buf) ((buf)->data)
#define uip_len(buf) (((struct ip_buf *)net_buf_user_data((buf)))->len)
#define uip_slen(buf) (((struct ip_buf *)net_buf_user_data((buf)))->uip_slen)
#define uip_ext_len(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_ext_len)
#define uip_ext_bitmap(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_ext_bitmap)
#define uip_ext_opt_offset(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_ext_opt_offset)
#define uip_nd6_opt_offset(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_opt_offset)
#define uip_next_hdr(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_next_hdr)
#define uip_appdata(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_appdata)
#define uip_appdatalen(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_appdatalen)
#define uip_sappdata(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_sappdata)
#define uip_flags(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_flags)
#define uip_conn(buf) \
((struct uip_conn *) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_conn))
#define uip_set_conn(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_conn)
#define uip_udp_conn(buf) \
((struct uip_udp_conn *) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_udp_conn))
#define uip_set_udp_conn(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->uip_udp_conn)
#define uip_nd6_opt_prefix_info(buf) \
((uip_nd6_opt_prefix_info *) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_opt_prefix_info))
#define uip_set_nd6_opt_prefix_info(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_opt_prefix_info)
#define uip_prefix(buf) \
((uip_ds6_prefix_t *) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_prefix))
#define uip_set_prefix(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_prefix)
#define uip_nbr(buf) \
((uip_ds6_nbr_t *) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_nbr))
#define uip_set_nbr(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_nbr)
#define uip_defrt(buf) \
((uip_ds6_defrt_t *) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_defrt))
#define uip_set_defrt(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_defrt)
#define uip_addr(buf) \
((uip_ds6_addr_t *) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_ifaddr))
#define uip_set_addr(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_ifaddr)
#define uip_nd6_opt_llao(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_opt_llao)
#define uip_set_nd6_opt_llao(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->nd6_opt_llao)
#define uip_nd6_ipaddr(buf) \
(((struct ip_buf *)net_buf_user_data((buf)))->ipaddr)
/* These two return only the application data and length without
* IP and UDP header length.
*/
#define ip_buf_appdata(buf) uip_appdata(buf)
#define ip_buf_appdatalen(buf) uip_appdatalen(buf)
#define ip_buf_reserve(buf) (((struct ip_buf *) \
net_buf_user_data((buf)))->reserve)
#define ip_buf_ll_src(buf) (((struct ip_buf *)net_buf_user_data((buf)))->src)
#define ip_buf_ll_dest(buf) (((struct ip_buf *)net_buf_user_data((buf)))->dest)
#define ip_buf_context(buf) (((struct ip_buf *)net_buf_user_data((buf)))->context)
#define ip_buf_type(ptr) (((struct ip_buf *)net_buf_user_data((ptr)))->type)
/* @endcond */
/** NET_BUF_IP
*
* @brief This macro returns IP header information struct stored in net_buf.
*
* @details The macro returns pointer to uip_ip_hdr struct which
* contains IP header information.
*
* @param buf Network buffer.
*
* @return Pointer to uip_ip_hdr.
*/
#define NET_BUF_IP(buf) ((struct uip_ip_hdr *)&uip_buf(buf)[UIP_LLH_LEN])
/** NET_BUF_UDP
*
* @brief This macro returns UDP header information struct stored in net_buf.
*
* @details The macro returns pointer to uip_udp_hdr struct which
* contains UDP header information.
*
* @param buf Network buffer.
*
* @return Pointer to uip_ip_hdr.
*/
#define NET_BUF_UDP(buf) ((struct uip_udp_hdr *)&uip_buf(buf)[UIP_LLIPH_LEN])
/**
* @brief Get buffer from the available buffers pool.
*
* @details Get network buffer from buffer pool. You must have
* network context before able to use this function.
*
* @param context Network context that will be related to
* this buffer.
*
* @return Network buffer if successful, NULL otherwise.
*/
/* Get buffer from the available buffers pool */
#ifdef DEBUG_IP_BUFS
#define ip_buf_get_rx(context) ip_buf_get_rx_debug(context, __func__, __LINE__)
#define ip_buf_get_tx(context) ip_buf_get_tx_debug(context, __func__, __LINE__)
struct net_buf *ip_buf_get_rx_debug(struct net_context *context,
const char *caller, int line);
struct net_buf *ip_buf_get_tx_debug(struct net_context *context,
const char *caller, int line);
#else
struct net_buf *ip_buf_get_rx(struct net_context *context);
struct net_buf *ip_buf_get_tx(struct net_context *context);
#endif
/**
* @brief Get buffer from pool but also reserve headroom for
* potential headers.
*
* @details Normally this version is not useful for applications
* but is mainly used by network fragmentation code.
*
* @param reserve How many bytes to reserve for headroom.
*
* @return Network buffer if successful, NULL otherwise.
*/
/* Same as net_buf_get, but also reserve headroom for potential headers */
#ifdef DEBUG_IP_BUFS
#define ip_buf_get_reserve_rx(res) ip_buf_get_reserve_rx_debug(res, \
__func__, \
__LINE__)
#define ip_buf_get_reserve_tx(res) ip_buf_get_reserve_tx_debug(res, \
__func__, \
__LINE__)
struct net_buf *ip_buf_get_reserve_rx_debug(uint16_t reserve_head,
const char *caller, int line);
struct net_buf *ip_buf_get_reserve_tx_debug(uint16_t reserve_head,
const char *caller, int line);
#else
struct net_buf *ip_buf_get_reserve_rx(uint16_t reserve_head);
struct net_buf *ip_buf_get_reserve_tx(uint16_t reserve_head);
#endif
/**
* @brief Place buffer back into the available buffers pool.
*
* @details Releases the buffer to other use. This needs to be
* called by application after it has finished with
* the buffer.
*
* @param buf Network buffer to release.
*
*/
#ifdef DEBUG_IP_BUFS
#define ip_buf_unref(buf) ip_buf_unref_debug(buf, __func__, __LINE__)
void ip_buf_unref_debug(struct net_buf *buf, const char *caller, int line);
#else
void ip_buf_unref(struct net_buf *buf);
#endif
/** @cond ignore */
void ip_buf_init(void);
/* @endcond */
/** @cond ignore */
#if defined(CONFIG_INIT_STACKS) && defined(CONFIG_PRINTK)
#include <offsets.h>
#include <misc/printk.h>
enum {
STACK_DIRECTION_UP,
STACK_DIRECTION_DOWN,
};
static inline unsigned net_calculate_unused(const char *stack, unsigned size,
int stack_growth)
{
unsigned i, unused = 0;
if (stack_growth == STACK_DIRECTION_DOWN) {
for (i = __tTCS_SIZEOF; i < size; i++) {
if ((unsigned char)stack[i] == 0xaa) {
unused++;
} else {
break;
}
}
} else {
for (i = size - 1; i >= __tTCS_SIZEOF; i--) {
if ((unsigned char)stack[i] == 0xaa) {
unused++;
} else {
break;
}
}
}
return unused;
}
static inline unsigned net_get_stack_dir(struct net_buf *buf,
struct net_buf **ref)
{
if (buf > *ref) {
return 1;
} else {
return 0;
}
}
static inline void net_analyze_stack(const char *name,
unsigned char *stack,
size_t size)
{
unsigned unused;
int stack_growth;
char *dir;
struct net_buf *buf = NULL;
if (net_get_stack_dir(buf, &buf)) {
dir = "up";
stack_growth = STACK_DIRECTION_UP;
} else {
dir = "down";
stack_growth = STACK_DIRECTION_DOWN;
}
unused = net_calculate_unused(stack, size, stack_growth);
printk("net: ip: %s stack grows %s, "
"stack(%p/%u): unused %u bytes\n",
name, dir, stack, size, unused);
}
#else
#define net_analyze_stack(...)
#endif
/* @endcond */
#endif /* __IP_BUF_H */

143
include/net/l2_buf.h Normal file
View file

@ -0,0 +1,143 @@
/** @file
* @brief L2 buffer API
*
* L2 (layer 2 or MAC layer) data is passed between application and
* IP stack via a l2_buf struct. Currently L2 buffers are only used
* in IEEE 802.15.4 code.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Data buffer API - used for all data to/from net */
#ifndef __L2_BUF_H
#define __L2_BUF_H
#include <stdint.h>
#include <net/ip_buf.h>
#include "contiki/ip/uipopt.h"
#include "contiki/ip/uip.h"
#include "contiki/packetbuf.h"
#if defined(CONFIG_NET_BUF_DEBUG)
#undef DEBUG_L2_BUFS
#define DEBUG_L2_BUFS
#endif
/** @cond ignore */
void l2_buf_init(void);
/* @endcond */
/** For the MAC/L2 layer (after the IPv6 packet is fragmented to smaller
* chunks), we can use much smaller buffers (depending on used radio
* technology). For 802.15.4 we use the 128 bytes long buffers.
*/
#ifndef NET_L2_BUF_MAX_SIZE
#define NET_L2_BUF_MAX_SIZE (PACKETBUF_SIZE + PACKETBUF_HDR_SIZE)
#endif
struct l2_buf {
/** @cond ignore */
/* 6LoWPAN pointers */
uint8_t *packetbuf_ptr;
uint8_t packetbuf_hdr_len;
int packetbuf_payload_len;
uint8_t uncomp_hdr_len;
int last_tx_status;
struct packetbuf_attr pkt_packetbuf_attrs[PACKETBUF_NUM_ATTRS];
struct packetbuf_addr pkt_packetbuf_addrs[PACKETBUF_NUM_ADDRS];
uint16_t pkt_buflen, pkt_bufptr;
uint8_t pkt_hdrptr;
uint8_t *pkt_packetbufptr;
/* @endcond */
};
/** @cond ignore */
#define uip_packetbuf_ptr(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->packetbuf_ptr)
#define uip_packetbuf_hdr_len(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->packetbuf_hdr_len)
#define uip_packetbuf_payload_len(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->packetbuf_payload_len)
#define uip_uncomp_hdr_len(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->uncomp_hdr_len)
#define uip_last_tx_status(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->last_tx_status)
#define uip_pkt_buflen(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_buflen)
#define uip_pkt_bufptr(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_bufptr)
#define uip_pkt_hdrptr(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_hdrptr)
#define uip_pkt_packetbufptr(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_packetbufptr)
#define uip_pkt_packetbuf_attrs(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_packetbuf_attrs)
#define uip_pkt_packetbuf_addrs(buf) \
(((struct l2_buf *)net_buf_user_data((buf)))->pkt_packetbuf_addrs)
/* Note that we do not reserve extra space for the header when the packetbuf
* is converted to use net_buf, so the packet starts directly from the
* data pointer. This is done in order to simplify the 802.15.4 packet
* handling. So the L2 buffer should only be allocated by calling
* reserve function like this: l2_buf_get_reserve(0);
*/
#define uip_pkt_packetbuf(ptr) ((ptr)->data)
/* @endcond */
/**
* @brief Get buffer from the available buffers pool
* and also reserve headroom for potential headers.
*
* @details Normally this version is not useful for applications
* but is mainly used by network fragmentation code.
*
* @param reserve How many bytes to reserve for headroom.
*
* @return Network buffer if successful, NULL otherwise.
*/
#ifdef DEBUG_L2_BUFS
#define l2_buf_get_reserve(res) l2_buf_get_reserve_debug(res, \
__func__, __LINE__)
struct net_buf *l2_buf_get_reserve_debug(uint16_t reserve_head,
const char *caller, int line);
#else
struct net_buf *l2_buf_get_reserve(uint16_t reserve_head);
#endif
/**
* @brief Place buffer back into the available buffers pool.
*
* @details Releases the buffer to other use. This needs to be
* called by application after it has finished with
* the buffer.
*
* @param buf Network buffer to release.
*
*/
#ifdef DEBUG_L2_BUFS
#define l2_buf_unref(buf) l2_buf_unref_debug(buf, __func__, __LINE__)
void l2_buf_unref_debug(struct net_buf *buf, const char *caller, int line);
#else
void l2_buf_unref(struct net_buf *buf);
#endif
#endif /* __L2_BUF_H */

View file

@ -1,458 +0,0 @@
/** @file
* @brief Network buffer API
*
* Network data is passed between application and IP stack via a net_buf struct.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Data buffer API - used for all data to/from net */
#ifndef __NET_BUF_H
#define __NET_BUF_H
#include <stdint.h>
#include <stdbool.h>
#include <net/net_core.h>
#include "contiki/ip/uipopt.h"
#include "contiki/ip/uip.h"
#include "contiki/packetbuf.h"
#if defined(CONFIG_NETWORKING_WITH_LOGGING)
#undef DEBUG_NET_BUFS
#define DEBUG_NET_BUFS
#endif
#ifdef DEBUG_NET_BUFS
#define NET_BUF_CHECK_IF_IN_USE(buf) \
do { \
if (buf->in_use) { \
NET_ERR("**ERROR** buf %p in use (%s:%s():%d)\n", \
buf, __FILE__, __func__, __LINE__); \
} \
} while (0)
#define NET_BUF_CHECK_IF_NOT_IN_USE(buf) \
do { \
if (!buf->in_use) { \
NET_ERR("**ERROR** buf %p not in use (%s:%s():%d)\n",\
buf, __FILE__, __func__, __LINE__); \
} \
} while (0)
#else
#define NET_BUF_CHECK_IF_IN_USE(buf)
#define NET_BUF_CHECK_IF_NOT_IN_USE(buf)
#endif
struct net_context;
/** @cond ignore */
enum net_buf_type {
NET_BUF_RX = 0,
NET_BUF_TX = 1,
};
/** @endcond */
/** The default MTU is 1280 (minimum IPv6 packet size) + LL header
* In Contiki terms this is UIP_LINK_MTU + UIP_LLH_LEN = UIP_BUFSIZE
*
* Contiki assumes that this value is UIP_BUFSIZE so do not change it
* without changing the value of UIP_BUFSIZE!
*/
#define NET_BUF_MAX_DATA UIP_BUFSIZE
struct net_buf {
/** @cond ignore */
/* FIFO uses first 4 bytes itself, reserve space */
int __unused;
bool in_use;
enum net_buf_type type;
/* @endcond */
/** Network connection context */
struct net_context *context;
/** @cond ignore */
/* uIP stack specific data */
uint16_t len;
uint8_t uip_ext_len;
uint8_t uip_ext_bitmap;
uint8_t uip_ext_opt_offset;
uint8_t uip_flags;
uint16_t uip_slen;
uint16_t uip_appdatalen;
uint8_t *uip_next_hdr;
void *uip_appdata; /* application data */
void *uip_sappdata; /* app data to be sent */
void *uip_conn;
void *uip_udp_conn;
linkaddr_t dest;
linkaddr_t src;
/* Neighbor discovery vars */
void *nd6_opt_prefix_info;
void *nd6_prefix;
void *nd6_nbr;
void *nd6_defrt;
void *nd6_ifaddr;
uint8_t *nd6_opt_llao;
uip_ipaddr_t ipaddr;
uint8_t nd6_opt_offset;
/* @endcond */
/** Buffer data length */
uint16_t datalen;
/** Buffer head pointer */
uint8_t *data;
/** Actual network buffer storage */
uint8_t buf[NET_BUF_MAX_DATA];
};
#define net_buf_data(buf) ((buf)->data)
#define net_buf_datalen(buf) ((buf)->datalen)
/** @cond ignore */
/* Macros to access net_buf when inside Contiki stack */
#define uip_buf(ptr) ((ptr)->buf)
#define uip_len(buf) ((buf)->len)
#define uip_slen(buf) ((buf)->uip_slen)
#define uip_ext_len(buf) ((buf)->uip_ext_len)
#define uip_ext_bitmap(buf) ((buf)->uip_ext_bitmap)
#define uip_ext_opt_offset(buf) ((buf)->uip_ext_opt_offset)
#define uip_nd6_opt_offset(buf) ((buf)->nd6_opt_offset)
#define uip_next_hdr(buf) ((buf)->uip_next_hdr)
#define uip_appdata(buf) ((buf)->uip_appdata)
#define uip_appdatalen(buf) ((buf)->uip_appdatalen)
#define uip_sappdata(buf) ((buf)->uip_sappdata)
#define uip_flags(buf) ((buf)->uip_flags)
#define uip_conn(buf) ((struct uip_conn *)((buf)->uip_conn))
#define uip_set_conn(buf) ((buf)->uip_conn)
#define uip_udp_conn(buf) ((struct uip_udp_conn *)((buf)->uip_udp_conn))
#define uip_set_udp_conn(buf) ((buf)->uip_udp_conn)
#define uip_nd6_opt_prefix_info(buf) ((uip_nd6_opt_prefix_info *)((buf)->nd6_opt_prefix_info))
#define uip_set_nd6_opt_prefix_info(buf) ((buf)->nd6_opt_prefix_info)
#define uip_prefix(buf) ((uip_ds6_prefix_t *)((buf)->nd6_prefix))
#define uip_set_prefix(buf) ((buf)->nd6_prefix)
#define uip_nbr(buf) ((uip_ds6_nbr_t *)((buf)->nd6_nbr))
#define uip_set_nbr(buf) ((buf)->nd6_nbr)
#define uip_defrt(buf) ((uip_ds6_defrt_t *)((buf)->nd6_defrt))
#define uip_set_defrt(buf) ((buf)->nd6_defrt)
#define uip_addr(buf) ((uip_ds6_addr_t *)((buf)->nd6_ifaddr))
#define uip_set_addr(buf) ((buf)->nd6_ifaddr)
#define uip_nd6_opt_llao(buf) ((buf)->nd6_opt_llao)
#define uip_set_nd6_opt_llao(buf) ((buf)->nd6_opt_llao)
#define uip_nd6_ipaddr(buf) ((buf)->ipaddr)
/* @endcond */
/** NET_BUF_IP
*
* @brief This macro returns IP header information struct stored in net_buf.
*
* @details The macro returns pointer to uip_ip_hdr struct which
* contains IP header information.
*
* @param buf Network buffer.
*
* @return Pointer to uip_ip_hdr.
*/
#define NET_BUF_IP(buf) ((struct uip_ip_hdr *)&uip_buf(buf)[UIP_LLH_LEN])
/** NET_BUF_UDP
*
* @brief This macro returns UDP header information struct stored in net_buf.
*
* @details The macro returns pointer to uip_udp_hdr struct which
* contains UDP header information.
*
* @param buf Network buffer.
*
* @return Pointer to uip_ip_hdr.
*/
#define NET_BUF_UDP(buf) ((struct uip_udp_hdr *)&uip_buf(buf)[UIP_LLIPH_LEN])
/**
* @brief Get buffer from the available buffers pool.
*
* @details Get network buffer from buffer pool. You must have
* network context before able to use this function.
*
* @param context Network context that will be related to
* this buffer.
*
* @return Network buffer if successful, NULL otherwise.
*/
/* Get buffer from the available buffers pool */
#ifdef DEBUG_NET_BUFS
#define net_buf_get_rx(context) net_buf_get_rx_debug(context, __func__, __LINE__)
#define net_buf_get_tx(context) net_buf_get_tx_debug(context, __func__, __LINE__)
struct net_buf *net_buf_get_rx_debug(struct net_context *context, const char *caller, int line);
struct net_buf *net_buf_get_tx_debug(struct net_context *context, const char *caller, int line);
#else
struct net_buf *net_buf_get_rx(struct net_context *context);
struct net_buf *net_buf_get_tx(struct net_context *context);
#endif
/**
* @brief Get buffer from pool but also reserve headroom for
* potential headers.
*
* @details Normally this version is not useful for applications
* but is mainly used by network fragmentation code.
*
* @param reserve How many bytes to reserve for headroom.
*
* @return Network buffer if successful, NULL otherwise.
*/
/* Same as net_buf_get, but also reserve headroom for potential headers */
#ifdef DEBUG_NET_BUFS
#define net_buf_get_reserve_rx(res) net_buf_get_reserve_rx_debug(res, __func__, __LINE__)
#define net_buf_get_reserve_tx(res) net_buf_get_reserve_tx_debug(res, __func__, __LINE__)
struct net_buf *net_buf_get_reserve_rx_debug(uint16_t reserve_head, const char *caller, int line);
struct net_buf *net_buf_get_reserve_tx_debug(uint16_t reserve_head, const char *caller, int line);
#else
struct net_buf *net_buf_get_reserve_rx(uint16_t reserve_head);
struct net_buf *net_buf_get_reserve_tx(uint16_t reserve_head);
#endif
/**
* @brief Place buffer back into the available buffers pool.
*
* @details Releases the buffer to other use. This needs to be
* called by application after it has finished with
* the buffer.
*
* @param buf Network buffer to release.
*
*/
/* Place buffer back into the available buffers pool */
#ifdef DEBUG_NET_BUFS
#define net_buf_put(buf) net_buf_put_debug(buf, __func__, __LINE__)
void net_buf_put_debug(struct net_buf *buf, const char *caller, int line);
#else
void net_buf_put(struct net_buf *buf);
#endif
/**
* @brief Prepare data to be added at the end of the buffer.
*
* @details Move the tail pointer forward.
*
* @param buf Network buffer.
* @param len Size of data to be added.
*
* @return Pointer to new tail.
*/
uint8_t *net_buf_add(struct net_buf *buf, uint16_t len);
/**
* @brief Push data to the beginning of the buffer.
*
* @details Move the data pointer backwards.
*
* @param buf Network buffer.
* @param len Size of data to be added.
*
* @return Pointer to new head.
*/
uint8_t *net_buf_push(struct net_buf *buf, uint16_t len);
/**
* @brief Remove data from the beginning of the buffer.
*
* @details Move the data pointer forward.
*
* @param buf Network buffer.
* @param len Size of data to be removed.
*
* @return Pointer to new head.
*/
uint8_t *net_buf_pull(struct net_buf *buf, uint16_t len);
/** @def net_buf_tail
*
* @brief Return pointer to the end of the data in the buffer.
*
* @details This macro returns the tail of the buffer.
*
* @param buf Network buffer.
*
* @return Pointer to tail.
*/
#define net_buf_tail(buf) ((buf)->data + (buf)->len)
/** @cond ignore */
void net_buf_init(void);
/* @endcond */
/** For the MAC layer (after the IPv6 packet is fragmented to smaller
* chunks), we can use much smaller buffers (depending on used radio
* technology). For 802.15.4 we use the 128 bytes long buffers.
*/
#ifndef NET_MAC_BUF_MAX_SIZE
#define NET_MAC_BUF_MAX_SIZE PACKETBUF_SIZE
#endif
struct net_mbuf {
/** @cond ignore */
/* FIFO uses first 4 bytes itself, reserve space */
int __unused;
bool in_use;
/* @endcond */
/** @cond ignore */
/* 6LoWPAN pointers */
uint8_t *packetbuf_ptr;
uint8_t packetbuf_hdr_len;
int packetbuf_payload_len;
uint8_t uncomp_hdr_len;
int last_tx_status;
struct packetbuf_attr pkt_packetbuf_attrs[PACKETBUF_NUM_ATTRS];
struct packetbuf_addr pkt_packetbuf_addrs[PACKETBUF_NUM_ADDRS];
uint16_t pkt_buflen, pkt_bufptr;
uint8_t pkt_hdrptr;
uint8_t pkt_packetbuf[PACKETBUF_SIZE + PACKETBUF_HDR_SIZE];
uint8_t *pkt_packetbufptr;
/* @endcond */
};
/**
* @brief Get buffer from the available buffers pool
* and also reserve headroom for potential headers.
*
* @details Normally this version is not useful for applications
* but is mainly used by network fragmentation code.
*
* @param reserve How many bytes to reserve for headroom.
*
* @return Network buffer if successful, NULL otherwise.
*/
#ifdef DEBUG_NET_BUFS
#define net_mbuf_get_reserve(res) net_mbuf_get_reserve_debug(res, __func__, __LINE__)
struct net_mbuf *net_mbuf_get_reserve_debug(uint16_t reserve_head, const char *caller, int line);
#else
struct net_mbuf *net_mbuf_get_reserve(uint16_t reserve_head);
#endif
/**
* @brief Place buffer back into the available buffers pool.
*
* @details Releases the buffer to other use. This needs to be
* called by application after it has finished with
* the buffer.
*
* @param buf Network buffer to release.
*/
#ifdef DEBUG_NET_BUFS
#define net_mbuf_put(buf) net_mbuf_put_debug(buf, __func__, __LINE__)
void net_mbuf_put_debug(struct net_mbuf *buf, const char *caller, int line);
#else
void net_mbuf_put(struct net_mbuf *buf);
#endif
/** @cond ignore */
#define uip_packetbuf_ptr(buf) ((buf)->packetbuf_ptr)
#define uip_packetbuf_hdr_len(buf) ((buf)->packetbuf_hdr_len)
#define uip_packetbuf_payload_len(buf) ((buf)->packetbuf_payload_len)
#define uip_uncomp_hdr_len(buf) ((buf)->uncomp_hdr_len)
#define uip_last_tx_status(buf) ((buf)->last_tx_status)
#define uip_pkt_buflen(buf) ((buf)->pkt_buflen)
#define uip_pkt_bufptr(buf) ((buf)->pkt_bufptr)
#define uip_pkt_hdrptr(buf) ((buf)->pkt_hdrptr)
#define uip_pkt_packetbuf(buf) ((buf)->pkt_packetbuf)
#define uip_pkt_packetbufptr(buf) ((buf)->pkt_packetbufptr)
#define uip_pkt_packetbuf_attrs(buf) ((buf)->pkt_packetbuf_attrs)
#define uip_pkt_packetbuf_addrs(buf) ((buf)->pkt_packetbuf_addrs)
/* @endcond */
/** @cond ignore */
#if defined(CONFIG_INIT_STACKS) && defined(CONFIG_PRINTK)
#include <offsets.h>
#include <misc/printk.h>
enum {
STACK_DIRECTION_UP,
STACK_DIRECTION_DOWN,
};
static inline unsigned net_calculate_unused(const char *stack, unsigned size,
int stack_growth)
{
unsigned i, unused = 0;
if (stack_growth == STACK_DIRECTION_DOWN) {
for (i = __tTCS_SIZEOF; i < size; i++) {
if ((unsigned char)stack[i] == 0xaa) {
unused++;
} else {
break;
}
}
} else {
for (i = size - 1; i >= __tTCS_SIZEOF; i--) {
if ((unsigned char)stack[i] == 0xaa) {
unused++;
} else {
break;
}
}
}
return unused;
}
static inline unsigned net_get_stack_dir(struct net_buf *buf,
struct net_buf **ref)
{
if (buf > *ref) {
return 1;
} else {
return 0;
}
}
static inline void net_analyze_stack(const char *name,
unsigned char *stack,
size_t size)
{
unsigned unused;
int stack_growth;
char *dir;
struct net_buf *buf = NULL;
if (net_get_stack_dir(buf, &buf)) {
dir = "up";
stack_growth = STACK_DIRECTION_UP;
} else {
dir = "down";
stack_growth = STACK_DIRECTION_DOWN;
}
unused = net_calculate_unused(stack, size, stack_growth);
printk("net: ip: %s stack grows %s, "
"stack(%p/%u): unused %u bytes\n",
name, dir, stack, size, unused);
}
#else
#define net_analyze_stack(...)
#endif
/* @endcond */
#endif /* __NET_BUF_H */

View file

@ -110,8 +110,8 @@ int net_set_mac(uint8_t *mac, uint8_t len);
*
* @details Application can call this function if it has received
* a network packet from peer. The application needs to write
* reply data into net_buf. The app can use net_buf_data(buf) and
* net_buf_datalen(buf) to set the application data and length.
* reply data into net_buf. The app can use ip_buf_appdata(buf) and
* ip_buf_appdatalen(buf) to set the application data and length.
*
* @param context Network context
* @param buf Network buffer containing the network data.

View file

@ -26,7 +26,7 @@
#include <stdint.h>
#include <net/net_ip.h>
#include <net/net_buf.h>
#include <net/buf.h>
/**
* @brief Get network context.

View file

@ -25,21 +25,22 @@ menuconfig NETWORKING
prompt "Generic networking support"
select NANO_TIMEOUTS
select NANO_TIMERS
select NET_BUF
default n
help
This option enabled generic networking support.
if NETWORKING
config NET_BUF_RX_SIZE
int "Number of network buffers to use when receiving data"
config IP_BUF_RX_SIZE
int "Number of IP net buffers to use when receiving data"
default 1
help
Each network buffer will contain one received IPv6 or IPv4 packet.
Each buffer will occupy 1280 bytes of memory.
config NET_BUF_TX_SIZE
int "Number of network buffers to use when sending data"
config IP_BUF_TX_SIZE
int "Number of IP net buffers to use when sending data"
default 2
help
Each network buffer will contain one sent IPv6 or IPv4 packet.
@ -136,6 +137,7 @@ config NETWORKING_WITH_LOGGING
bool
prompt "Enable logging of the uIP stack"
depends on NETWORKING
select NET_BUF_DEBUG
default n
help
Enable packet and uIP stack logging

View file

@ -5,13 +5,10 @@ ccflags-y += -I${srctree}/net/ip/contiki/os
ccflags-y += -I${srctree}/net/ip
ccflags-y += -I${srctree}/include/drivers
ifneq ($(CONFIG_NET_BUF_SIZE),)
ccflags-y += -DNET_NUM_BUFS=$(CONFIG_NET_BUF_SIZE)
endif
# Zypher specific files
obj-y = net_init.o \
net_buf.o \
ip_buf.o \
l2_buf.o \
net_context.o
# Contiki IP stack files

View file

@ -56,6 +56,6 @@
#include "sys/energest.h"
#include <net/net_buf.h>
#include <net/buf.h>
#endif /* CONTIKI_H_ */

View file

@ -42,7 +42,7 @@
* @{
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "contiki-net.h"
#include "net/ip/simple-udp.h"

View file

@ -38,6 +38,8 @@
* \author Julien Abeille <jabeille@cisco.com> (IPv6 related code)
*/
#include <net/ip_buf.h>
#include "contiki-net.h"
#include "net/ip/uip-split.h"
#include "net/ip/uip-packetqueue.h"
@ -50,7 +52,7 @@
#include <string.h>
#define DEBUG DEBUG_NONE
#include "net/ip/uip-debug.h"
#include "contiki/ip/uip-debug.h"
#if UIP_LOGGING
#include <stdio.h>
@ -553,7 +555,7 @@ tcpip_ipv6_output(struct net_buf *buf)
PRINTF("%s(): buf %p len %d\n", __FUNCTION__, buf, uip_len(buf));
if(uip_len(buf) > UIP_LINK_MTU) {
UIP_LOG("tcpip_ipv6_output: Packet to big");
UIP_LOG("tcpip_ipv6_output: Packet too big");
uip_len(buf) = 0;
uip_ext_len(buf) = 0;
return 0;
@ -736,10 +738,6 @@ tcpip_ipv6_output(struct net_buf *buf)
#endif /*UIP_CONF_IPV6_QUEUE_PKT*/
if (ret == 0) {
if (!net_buf_datalen(buf)) {
/* Set the original length if it is not set yet */
net_buf_datalen(buf) = uip_len(buf);
}
uip_len(buf) = 0;
uip_ext_len(buf) = 0;
}
@ -750,9 +748,6 @@ tcpip_ipv6_output(struct net_buf *buf)
}
/* Multicast IP destination address. */
ret = tcpip_output(buf, NULL);
if (!net_buf_datalen(buf)) {
net_buf_datalen(buf) = uip_len(buf);
}
uip_len(buf) = 0;
uip_ext_len(buf) = 0;
return ret;

View file

@ -29,7 +29,7 @@
*
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "contiki-net.h"
#include "udp-socket.h"

View file

@ -32,7 +32,7 @@
#ifndef UDP_SOCKET_H
#define UDP_SOCKET_H
#include <net/net_buf.h>
#include <net/buf.h>
#include "net/ip/uip.h"

View file

@ -19,7 +19,7 @@ MEMB(packets_memb, struct uip_packetqueue_packet, MAX_NUM_QUEUED_PACKETS);
/*---------------------------------------------------------------------------*/
static void
packet_timedout(struct net_mbuf *buf, void *ptr)
packet_timedout(struct net_buf *buf, void *ptr)
{
struct uip_packetqueue_handle *h = ptr;
@ -36,7 +36,7 @@ uip_packetqueue_new(struct uip_packetqueue_handle *handle)
}
/*---------------------------------------------------------------------------*/
struct uip_packetqueue_packet *
uip_packetqueue_alloc(struct net_mbuf *buf, struct uip_packetqueue_handle *handle, clock_time_t lifetime)
uip_packetqueue_alloc(struct net_buf *buf, struct uip_packetqueue_handle *handle, clock_time_t lifetime)
{
PRINTF("uip_packetqueue_alloc %p\n", handle);
if(handle->packet != NULL) {

View file

@ -1,4 +1,4 @@
#include <net/net_buf.h>
#include <net/buf.h>
#ifndef UIP_PACKETQUEUE_H
#define UIP_PACKETQUEUE_H
@ -23,7 +23,7 @@ void uip_packetqueue_new(struct uip_packetqueue_handle *handle);
struct uip_packetqueue_packet *
uip_packetqueue_alloc(struct net_mbuf *buf, struct uip_packetqueue_handle *handle, clock_time_t lifetime);
uip_packetqueue_alloc(struct net_buf *buf, struct uip_packetqueue_handle *handle, clock_time_t lifetime);
void

View file

@ -37,7 +37,7 @@
* Adam Dunkels <adam@sics.se>
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "contiki-conf.h"

View file

@ -40,7 +40,7 @@
#ifndef UIP_UDP_PACKET_H_
#define UIP_UDP_PACKET_H_
#include <net/net_buf.h>
#include <net/buf.h>
#include "net/ip/uip.h"

View file

@ -41,7 +41,7 @@
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "contiki.h"
#include "contiki-net.h"
@ -68,7 +68,6 @@
/* Internal Data */
/*---------------------------------------------------------------------------*/
static struct ctimer mcast_periodic;
static struct net_buf netbuf;
static uint8_t fwd_delay;
static uint8_t fwd_spread;
@ -78,10 +77,8 @@ static uint8_t fwd_spread;
#define UIP_IP_BUF(buf) ((struct uip_ip_hdr *)&uip_buf(buf)[UIP_LLH_LEN])
/*---------------------------------------------------------------------------*/
static void
mcast_fwd(struct net_mbuf *mbuf, void *p)
mcast_fwd(struct net_buf *buf, void *p)
{
struct net_buf *buf = (struct net_buf *)mbuf;
UIP_IP_BUF(buf)->ttl--;
tcpip_output(buf, NULL);
uip_len(buf) = 0;
@ -94,6 +91,7 @@ in(struct net_buf *buf)
rpl_dag_t *d; /* Our DODAG */
uip_ipaddr_t *parent_ipaddr; /* Our pref. parent's IPv6 address */
const uip_lladdr_t *parent_lladdr; /* Our pref. parent's LL address */
struct net_buf *netbuf;
/*
* Fetch a pointer to the LL address of our preferred parent
@ -122,7 +120,7 @@ in(struct net_buf *buf)
* We accept a datagram if it arrived from our preferred parent, discard
* otherwise.
*/
if(memcmp(parent_lladdr, &buf->src,
if(memcmp(parent_lladdr, &ip_buf_ll_src(buf),
UIP_LLADDR_LEN)) {
PRINTF("SMRF: Routable in but SMRF ignored it\n");
UIP_MCAST6_STATS_ADD(mcast_dropped);
@ -172,8 +170,14 @@ in(struct net_buf *buf)
fwd_delay = fwd_delay * (1 + ((random_rand() >> 11) % fwd_spread));
}
memcpy(&netbuf, buf, sizeof(*buf));
ctimer_set((struct net_mbuf *)&netbuf, &mcast_periodic, fwd_delay, mcast_fwd, NULL);
netbuf = net_buf_clone(buf);
if (netbuf) {
memcpy(net_buf_user_data(netbuf), net_buf_user_data(buf),
buf->user_data_size);
ctimer_set(netbuf, &mcast_periodic, fwd_delay, mcast_fwd, NULL);
} else {
PRINTF("SMRF: cannot clone net buffer\n");
}
}
PRINTF("SMRF: %u bytes: fwd in %u [%u]\n",
uip_len(buf), fwd_delay, fwd_spread);

View file

@ -59,7 +59,7 @@
#ifndef UIP_MCAST6_H_
#define UIP_MCAST6_H_
#include <net/net_buf.h>
#include <net/buf.h>
#include "contiki-conf.h"
#include "net/ipv6/multicast/uip-mcast6-engines.h"

View file

@ -43,7 +43,7 @@
*
*/
#include <net/net_buf.h>
#include <net/buf.h>
#include "net/ip/uip.h"
#include "net/nbr-table.h"

View file

@ -42,7 +42,7 @@
#ifndef UIP_DS6_H_
#define UIP_DS6_H_
#include <net/net_buf.h>
#include <net/buf.h>
#include "net/ip/uip.h"
#include "sys/stimer.h"

View file

@ -42,7 +42,7 @@
* \author Mathilde Durvy <mdurvy@cisco.com>
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include <string.h>
#include "net/ipv6/uip-ds6.h"
@ -322,6 +322,8 @@ uip_icmp6_send(struct net_buf *buf, const uip_ipaddr_t *dest, int type, int code
UIP_ICMP_BUF(buf)->icmpchksum = ~uip_icmp6chksum(buf);
uip_len(buf) = UIP_IPH_LEN + UIP_ICMPH_LEN + payload_len;
net_buf_add(buf, uip_len(buf));
tcpip_ipv6_output(buf);
}
/*---------------------------------------------------------------------------*/

View file

@ -42,7 +42,7 @@
* \author Mathilde Durvy <mdurvy@cisco.com>
*/
#include <net/net_buf.h>
#include <net/buf.h>
#ifndef ICMP6_H_
#define ICMP6_H_

View file

@ -68,6 +68,8 @@
* \author Julien Abeille <jabeille@cisco.com>
*/
#include <net/ip_buf.h>
#include <string.h>
#include "net/ipv6/uip-icmp6.h"
#include "net/ipv6/uip-nd6.h"
@ -337,7 +339,7 @@ uip_nd6_ns_output(struct net_buf *buf, uip_ipaddr_t * src, uip_ipaddr_t * dest,
bool send_from_here = true;
if (!buf) {
buf = net_buf_get_reserve_tx(UIP_IPICMPH_LEN);
buf = ip_buf_get_reserve_tx(UIP_IPICMPH_LEN);
if (!buf) {
PRINTF("%s(): Cannot send NS, no net buffers\n", __FUNCTION__);
return;
@ -375,7 +377,7 @@ uip_nd6_ns_output(struct net_buf *buf, uip_ipaddr_t * src, uip_ipaddr_t * dest,
PRINTF("Dropping NS due to no suitable source address\n");
uip_len(buf) = 0;
if (send_from_here) {
net_buf_put(buf);
ip_buf_unref(buf);
}
return;
}
@ -406,7 +408,9 @@ uip_nd6_ns_output(struct net_buf *buf, uip_ipaddr_t * src, uip_ipaddr_t * dest,
PRINTF("\n");
if (send_from_here) {
tcpip_ipv6_output(buf);
if (tcpip_ipv6_output(buf) == 0) {
ip_buf_unref(buf);
}
}
return;
}
@ -682,7 +686,7 @@ uip_nd6_ra_output(uip_ipaddr_t * dest)
bool send_from_here = true;
if (!buf) {
buf = net_buf_get_reserve_tx(UIP_IPICMPH_LEN);
buf = ip_buf_get_reserve_tx(UIP_IPICMPH_LEN);
if (!buf) {
PRINTF("%s(): Cannot send RA, no net buffers\n", __FUNCTION__);
return;
@ -795,7 +799,9 @@ uip_nd6_ra_output(uip_ipaddr_t * dest)
PRINTF("\n");
if (send_from_here) {
tcpip_ipv6_output(buf);
if (tcpip_ipv6_output(buf) == 0) {
ip_buf_unref(buf);
}
}
return;
}
@ -810,7 +816,7 @@ uip_nd6_rs_output(struct net_buf *buf)
bool send_from_here = false;
if (!buf) {
buf = net_buf_get_reserve_tx(UIP_IPICMPH_LEN);
buf = ip_buf_get_reserve_tx(UIP_IPICMPH_LEN);
if (!buf) {
PRINTF("%s(): Cannot send RS, no net buffers\n", __FUNCTION__);
return;
@ -851,7 +857,9 @@ uip_nd6_rs_output(struct net_buf *buf)
PRINTF("\n");
if (send_from_here) {
tcpip_ipv6_output(buf);
if (tcpip_ipv6_output(buf) == 0) {
ip_buf_unref(buf);
}
}
return;
}

View file

@ -45,7 +45,7 @@
#ifndef UIP_ND6_H_
#define UIP_ND6_H_
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "net/ip/uip.h"
#include "sys/stimer.h"

View file

@ -71,7 +71,7 @@
* the packet back to the peer.
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "net/ip/uip.h"
#include "net/ip/uipopt.h"
@ -86,7 +86,7 @@
/* For Debug, logging, statistics */
/*---------------------------------------------------------------------------*/
#define DEBUG DEBUG_NONE
#define DEBUG DEBUG_FULL
#include "net/ip/uip-debug.h"
#if UIP_CONF_IPV6_RPL

View file

@ -43,6 +43,8 @@
* @{
*/
#include <net/l2_buf.h>
#include "net/llsec/anti-replay.h"
#include "net/packetbuf.h"
@ -51,7 +53,7 @@ static uint32_t counter;
/*---------------------------------------------------------------------------*/
void
anti_replay_set_counter(struct net_mbuf *buf)
anti_replay_set_counter(struct net_buf *buf)
{
frame802154_frame_counter_t reordered_counter;
@ -62,7 +64,7 @@ anti_replay_set_counter(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
uint32_t
anti_replay_get_counter(struct net_mbuf *buf)
anti_replay_get_counter(struct net_buf *buf)
{
frame802154_frame_counter_t disordered_counter;
@ -73,7 +75,7 @@ anti_replay_get_counter(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
void
anti_replay_init_info(struct net_mbuf *buf, struct anti_replay_info *info)
anti_replay_init_info(struct net_buf *buf, struct anti_replay_info *info)
{
info->last_broadcast_counter
= info->last_unicast_counter
@ -81,7 +83,7 @@ anti_replay_init_info(struct net_mbuf *buf, struct anti_replay_info *info)
}
/*---------------------------------------------------------------------------*/
int
anti_replay_was_replayed(struct net_mbuf *buf, struct anti_replay_info *info)
anti_replay_was_replayed(struct net_buf *buf, struct anti_replay_info *info)
{
uint32_t received_counter;

View file

@ -45,6 +45,8 @@
#ifndef ANTI_REPLAY_H
#define ANTI_REPLAY_H
#include <net/l2_buf.h>
#include "contiki.h"
struct anti_replay_info {
@ -55,25 +57,25 @@ struct anti_replay_info {
/**
* \brief Sets the frame counter packetbuf attributes.
*/
void anti_replay_set_counter(struct net_mbuf *buf);
void anti_replay_set_counter(struct net_buf *buf);
/**
* \brief Gets the frame counter from packetbuf.
*/
uint32_t anti_replay_get_counter(struct net_mbuf *buf);
uint32_t anti_replay_get_counter(struct net_buf *buf);
/**
* \brief Initializes the anti-replay information about the sender
* \param info Anti-replay information about the sender
*/
void anti_replay_init_info(struct net_mbuf *buf, struct anti_replay_info *info);
void anti_replay_init_info(struct net_buf *buf, struct anti_replay_info *info);
/**
* \brief Checks if received frame was replayed
* \param info Anti-replay information about the sender
* \retval 0 <-> received frame was not replayed
*/
int anti_replay_was_replayed(struct net_mbuf *buf, struct anti_replay_info *info);
int anti_replay_was_replayed(struct net_buf *buf, struct anti_replay_info *info);
#endif /* ANTI_REPLAY_H */

View file

@ -42,6 +42,8 @@
* @{
*/
#include <net/l2_buf.h>
#include "net/llsec/ccm-star.h"
#include "net/llsec/llsec802154.h"
#include "net/packetbuf.h"
@ -50,7 +52,7 @@
/*---------------------------------------------------------------------------*/
static void
set_nonce(struct net_mbuf *buf, uint8_t *nonce,
set_nonce(struct net_buf *buf, uint8_t *nonce,
uint8_t flags,
const uint8_t *extended_source_address,
uint8_t counter)
@ -71,7 +73,7 @@ set_nonce(struct net_mbuf *buf, uint8_t *nonce,
/*---------------------------------------------------------------------------*/
/* XORs the block m[pos] ... m[pos + 15] with K_{counter} */
static void
ctr_step(struct net_mbuf *buf, const uint8_t *extended_source_address,
ctr_step(struct net_buf *buf, const uint8_t *extended_source_address,
uint8_t pos,
uint8_t *m_and_result,
uint8_t m_len,
@ -89,7 +91,7 @@ ctr_step(struct net_mbuf *buf, const uint8_t *extended_source_address,
}
/*---------------------------------------------------------------------------*/
static void
mic(struct net_mbuf *buf, const uint8_t *extended_source_address,
mic(struct net_buf *buf, const uint8_t *extended_source_address,
uint8_t *result,
uint8_t mic_len)
{
@ -163,7 +165,7 @@ mic(struct net_mbuf *buf, const uint8_t *extended_source_address,
}
/*---------------------------------------------------------------------------*/
static void
ctr(struct net_mbuf *buf, const uint8_t *extended_source_address)
ctr(struct net_buf *buf, const uint8_t *extended_source_address)
{
uint8_t m_len;
uint8_t *m;

View file

@ -45,6 +45,8 @@
#ifndef CCM_STAR_H_
#define CCM_STAR_H_
#include <net/l2_buf.h>
#include "contiki.h"
#include "net/mac/frame802154.h"
@ -68,14 +70,14 @@ struct ccm_star_driver {
* \param result The generated MIC will be put here
* \param mic_len <= 16; set to LLSEC802154_MIC_LENGTH to be compliant
*/
void (* mic)(struct net_mbuf *buf, const uint8_t *extended_source_address,
void (* mic)(struct net_buf *buf, const uint8_t *extended_source_address,
uint8_t *result,
uint8_t mic_len);
/**
* \brief XORs the frame in the packetbuf with the key stream.
*/
void (* ctr)(struct net_mbuf *buf, const uint8_t *extended_source_address);
void (* ctr)(struct net_buf *buf, const uint8_t *extended_source_address);
};
extern const struct ccm_star_driver CCM_STAR;

View file

@ -56,6 +56,7 @@
*/
#include <stdbool.h>
#include <net/buf.h>
#include "net/mac/mac.h"
#ifndef LLSEC_H_
@ -73,7 +74,7 @@ struct llsec_driver {
void (* bootstrap)(llsec_on_bootstrapped_t on_bootstrapped);
/** Secures outgoing frames before passing them to NETSTACK_MAC. */
uint8_t (* send)(struct net_mbuf *buf, mac_callback_t sent_callback,
uint8_t (* send)(struct net_buf *buf, mac_callback_t sent_callback,
bool last_fragment, void *ptr);
/**
@ -87,7 +88,7 @@ struct llsec_driver {
* Decrypts incoming frames;
* filters out injected or replayed frames.
*/
uint8_t (* input)(struct net_mbuf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Returns the security-related overhead per frame in bytes */
uint8_t (* get_overhead)(void);

View file

@ -42,7 +42,7 @@
* @{
*/
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include "net/llsec/nullsec.h"
#include "net/mac/frame802154.h"
@ -68,7 +68,7 @@ bootstrap(llsec_on_bootstrapped_t on_bootstrapped)
}
/*---------------------------------------------------------------------------*/
static uint8_t
send(struct net_mbuf *buf, mac_callback_t sent, bool last_fragment, void *ptr)
send(struct net_buf *buf, mac_callback_t sent, bool last_fragment, void *ptr)
{
packetbuf_set_attr(buf, PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
return NETSTACK_MAC.send(buf, sent, last_fragment, ptr);
@ -81,7 +81,7 @@ on_frame_created(void)
}
/*---------------------------------------------------------------------------*/
static uint8_t
input(struct net_mbuf *buf)
input(struct net_buf *buf)
{
return NETSTACK_FRAGMENT.reassemble(buf);
}

View file

@ -37,7 +37,7 @@
* Adam Dunkels <adam@sics.se>
*/
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include "net/mac/csma.h"
#include "net/packetbuf.h"
@ -134,8 +134,8 @@ MEMB(packet_memb, struct rdc_buf_list, MAX_QUEUED_PACKETS);
MEMB(metadata_memb, struct qbuf_metadata, MAX_QUEUED_PACKETS);
LIST(neighbor_list);
static void packet_sent(struct net_mbuf *buf, void *ptr, int status, int num_transmissions);
static void transmit_packet_list(struct net_mbuf *buf, void *ptr);
static void packet_sent(struct net_buf *buf, void *ptr, int status, int num_transmissions);
static void transmit_packet_list(struct net_buf *buf, void *ptr);
/*---------------------------------------------------------------------------*/
static struct neighbor_queue *
@ -169,7 +169,7 @@ default_timebase(void)
}
/*---------------------------------------------------------------------------*/
static void
free_packet(struct net_mbuf *buf, struct neighbor_queue *n, struct rdc_buf_list *p)
free_packet(struct net_buf *buf, struct neighbor_queue *n, struct rdc_buf_list *p)
{
if(p != NULL) {
/* Remove packet from list and deallocate */
@ -190,13 +190,13 @@ free_packet(struct net_mbuf *buf, struct neighbor_queue *n, struct rdc_buf_list
/* This was the last packet in the queue, we free the neighbor */
list_remove(neighbor_list, n);
memb_free(&neighbor_memb, n);
net_mbuf_put(buf);
l2_buf_unref(buf);
}
}
}
/*---------------------------------------------------------------------------*/
static void
transmit_packet_list(struct net_mbuf *buf, void *ptr)
transmit_packet_list(struct net_buf *buf, void *ptr)
{
struct neighbor_queue *n = ptr;
if(n) {
@ -212,7 +212,7 @@ transmit_packet_list(struct net_mbuf *buf, void *ptr)
}
/*---------------------------------------------------------------------------*/
static void
packet_sent(struct net_mbuf *buf, void *ptr, int status, int num_transmissions)
packet_sent(struct net_buf *buf, void *ptr, int status, int num_transmissions)
{
struct neighbor_queue *n;
struct rdc_buf_list *q;
@ -326,7 +326,7 @@ packet_sent(struct net_mbuf *buf, void *ptr, int status, int num_transmissions)
}
/*---------------------------------------------------------------------------*/
static uint8_t
send_packet(struct net_mbuf *buf, mac_callback_t sent, bool last_fragment, void *ptr)
send_packet(struct net_buf *buf, mac_callback_t sent, bool last_fragment, void *ptr)
{
struct rdc_buf_list *q;
struct neighbor_queue *n;
@ -335,7 +335,7 @@ send_packet(struct net_mbuf *buf, mac_callback_t sent, bool last_fragment, void
const linkaddr_t *addr = packetbuf_addr(buf, PACKETBUF_ADDR_RECEIVER);
if (!buf) {
UIP_LOG("csma: send_packet(): net_mbuf is NULL, cannot send packet");
UIP_LOG("csma: send_packet(): net_buf is NULL, cannot send packet");
return 0;
}
@ -430,7 +430,7 @@ send_packet(struct net_mbuf *buf, mac_callback_t sent, bool last_fragment, void
}
/*---------------------------------------------------------------------------*/
static uint8_t
input_packet(struct net_mbuf *buf)
input_packet(struct net_buf *buf)
{
return NETSTACK_LLSEC.input(buf);
}

View file

@ -36,6 +36,8 @@
* Joakim Eriksson <joakime@sics.se>
*/
#include <net/l2_buf.h>
#include "net/mac/framer-802154.h"
#include "net/mac/frame802154.h"
#include "net/llsec/llsec802154.h"
@ -108,7 +110,7 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
}
/*---------------------------------------------------------------------------*/
static int
create_frame(struct net_mbuf *buf, int do_create)
create_frame(struct net_buf *buf, int do_create)
{
frame802154_t params;
int hdr_len;
@ -218,19 +220,19 @@ create_frame(struct net_mbuf *buf, int do_create)
}
/*---------------------------------------------------------------------------*/
static int
hdr_length(struct net_mbuf *buf)
hdr_length(struct net_buf *buf)
{
return create_frame(buf, 0);
}
/*---------------------------------------------------------------------------*/
static int
create(struct net_mbuf *buf)
create(struct net_buf *buf)
{
return create_frame(buf, 1);
}
/*---------------------------------------------------------------------------*/
static int
parse(struct net_mbuf *buf)
parse(struct net_buf *buf)
{
frame802154_t frame;
int hdr_len;

View file

@ -57,13 +57,13 @@ struct nullmac_hdr {
/*---------------------------------------------------------------------------*/
static int
hdr_length(struct net_mbuf *buf)
hdr_length(struct net_buf *buf)
{
return sizeof(struct nullmac_hdr);
}
/*---------------------------------------------------------------------------*/
static int
create(struct net_mbuf *buf)
create(struct net_buf *buf)
{
struct nullmac_hdr *hdr;
@ -78,7 +78,7 @@ create(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
static int
parse(struct net_mbuf *buf)
parse(struct net_buf *buf)
{
struct nullmac_hdr *hdr;
hdr = packetbuf_dataptr(buf);

View file

@ -34,7 +34,7 @@
/*---------------------------------------------------------------------------*/
int
framer_canonical_create_and_secure(struct net_mbuf *buf)
framer_canonical_create_and_secure(struct net_buf *buf)
{
int hdr_len;

View file

@ -38,7 +38,7 @@
* Joakim Eriksson <joakime@sics.se>
*/
#include <net/net_buf.h>
#include <net/buf.h>
#ifndef FRAMER_H_
#define FRAMER_H_
@ -48,15 +48,15 @@
struct framer {
int (* length)(struct net_mbuf *buf);
int (* create)(struct net_mbuf *buf);
int (* length)(struct net_buf *buf);
int (* create)(struct net_buf *buf);
/** Creates the frame and calls LLSEC.on_frame_created() */
int (* create_and_secure)(struct net_mbuf *buf);
int (* parse)(struct net_mbuf *buf);
int (* create_and_secure)(struct net_buf *buf);
int (* parse)(struct net_buf *buf);
};
int framer_canonical_create_and_secure(struct net_mbuf *buf);
int framer_canonical_create_and_secure(struct net_buf *buf);
#endif /* FRAMER_H_ */

View file

@ -36,6 +36,8 @@
* Niclas Finne <nfi@sics.se>
*/
#include <net/l2_buf.h>
#include "net/mac/framer-802154.h"
#include "net/mac/frame802154.h"
#include "net/mac/handler-802154.h"
@ -63,7 +65,7 @@ static struct ctimer scan_timer;
static struct ctimer beacon_send_timer;
static void handle_beacon(frame802154_t *frame);
static void handle_beacon_send_timer(struct net_mbuf *mbuf, void *p);
static void handle_beacon_send_timer(struct net_buf *mbuf, void *p);
static int answer_beacon_requests;
static uint16_t panid;
static scan_callback_t callback;
@ -129,13 +131,13 @@ handle_beacon(frame802154_t *frame)
}
/*---------------------------------------------------------------------------*/
static void
handle_beacon_send_timer(struct net_mbuf *buf, void *p)
handle_beacon_send_timer(struct net_buf *buf, void *p)
{
struct net_mbuf *mbuf;
struct net_buf *mbuf;
frame802154_t params;
uint8_t len;
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if(!mbuf) {
return;
}
@ -179,7 +181,7 @@ handle_beacon_send_timer(struct net_mbuf *buf, void *p)
frame802154_create(&params, packetbuf_hdrptr(mbuf), len);
if(NETSTACK_RADIO.send(mbuf, packetbuf_hdrptr(mbuf),
packetbuf_totlen(mbuf)) != RADIO_TX_OK) {
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return;
}
@ -191,11 +193,11 @@ handle_beacon_send_timer(struct net_mbuf *buf, void *p)
void
handler_802154_send_beacon_request(void)
{
struct net_mbuf *mbuf;
struct net_buf *mbuf;
frame802154_t params;
uint8_t len;
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if(!mbuf) {
return;
}
@ -232,7 +234,7 @@ handler_802154_send_beacon_request(void)
frame802154_create(&params, packetbuf_hdrptr(mbuf), len);
if(NETSTACK_RADIO.send(mbuf, packetbuf_hdrptr(mbuf),
packetbuf_totlen(mbuf)) != RADIO_TX_OK) {
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return;
}
HANDLER_802154_STAT(handler_802154_stats.beacons_reqs_sent++);
@ -240,7 +242,7 @@ handler_802154_send_beacon_request(void)
}
/*---------------------------------------------------------------------------*/
static void
handle_scan_timer(struct net_mbuf *mbuf, void *p)
handle_scan_timer(struct net_buf *mbuf, void *p)
{
if(!scan) {
return;

View file

@ -44,6 +44,8 @@
#include <string.h>
#include <net/l2_buf.h>
#include "contiki-net.h"
#include "net/mac/mac-sequence.h"
#include "net/packetbuf.h"
@ -62,7 +64,7 @@ static struct seqno received_seqnos[MAX_SEQNOS];
/*---------------------------------------------------------------------------*/
int
mac_sequence_is_duplicate(struct net_mbuf *buf)
mac_sequence_is_duplicate(struct net_buf *buf)
{
int i;
@ -84,7 +86,7 @@ mac_sequence_is_duplicate(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
void
mac_sequence_register_seqno(struct net_mbuf *buf)
mac_sequence_register_seqno(struct net_buf *buf)
{
int i, j;

View file

@ -53,7 +53,7 @@
* the sequence number of the incoming packet with the last few ones
* we saw, filtering with the Rime address.
*/
int mac_sequence_is_duplicate(struct net_mbuf *buf);
int mac_sequence_is_duplicate(struct net_buf *buf);
/**
* \brief Register the sequence number of the packetbuf
@ -61,6 +61,6 @@ int mac_sequence_is_duplicate(struct net_mbuf *buf);
* This function is used to add the sequence number of the incoming
* packet to the history.
*/
void mac_sequence_register_seqno(struct net_mbuf *buf);
void mac_sequence_register_seqno(struct net_buf *buf);
#endif /* MAC_SEQUENCE_H */

View file

@ -30,8 +30,9 @@
*
*/
#include <net/l2_buf.h>
#include "net/mac/mac.h"
#include "net/net_buf.h"
#define DEBUG 0
#include "net/ip/uip-debug.h"
@ -50,7 +51,7 @@ net_mac_stats_t net_mac_stats = {0};
/*---------------------------------------------------------------------------*/
void
mac_call_sent_callback(struct net_mbuf *buf, mac_callback_t sent, void *ptr, int status, int num_tx)
mac_call_sent_callback(struct net_buf *buf, mac_callback_t sent, void *ptr, int status, int num_tx)
{
PRINTF("buf %p mac_callback_t %p ptr %p status %d num_tx %d\n", buf,
(void *)sent, ptr, status, num_tx);

View file

@ -44,7 +44,7 @@
#include "contiki-conf.h"
#include "dev/radio.h"
#include <net/net_buf.h>
#include <net/buf.h>
#if NET_MAC_CONF_STATS
/* Statistics for sent bytes. */
@ -55,9 +55,9 @@ typedef struct net_mac_stats {
extern net_mac_stats_t net_mac_stats;
#endif
typedef void (* mac_callback_t)(struct net_mbuf *buf, void *ptr, int status, int transmissions);
typedef void (* mac_callback_t)(struct net_buf *buf, void *ptr, int status, int transmissions);
void mac_call_sent_callback(struct net_mbuf *buf, mac_callback_t sent, void *ptr, int status, int num_tx);
void mac_call_sent_callback(struct net_buf *buf, mac_callback_t sent, void *ptr, int status, int num_tx);
/**
* The structure of a MAC protocol driver in Contiki.
@ -69,11 +69,11 @@ struct mac_driver {
void (* init)(void);
/** Send a packet from the Rime buffer */
uint8_t (* send)(struct net_mbuf *buf, mac_callback_t sent_callback,
uint8_t (* send)(struct net_buf *buf, mac_callback_t sent_callback,
bool last_fragment, void *ptr);
/** Callback for getting notified of incoming packet. */
uint8_t (* input)(struct net_mbuf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Turn the MAC layer on. */
int (* on)(void);

View file

@ -37,7 +37,7 @@
* Adam Dunkels <adam@sics.se>
*/
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include "net/mac/nullmac.h"
#include "net/netstack.h"
@ -48,7 +48,7 @@
/*---------------------------------------------------------------------------*/
static uint8_t
send_packet(struct net_mbuf *buf, mac_callback_t sent,
send_packet(struct net_buf *buf, mac_callback_t sent,
bool last_fragment, void *ptr)
{
NETSTACK_RDC.send(buf, sent, ptr);
@ -56,7 +56,7 @@ send_packet(struct net_mbuf *buf, mac_callback_t sent,
}
/*---------------------------------------------------------------------------*/
static uint8_t
packet_input(struct net_mbuf *buf)
packet_input(struct net_buf *buf)
{
return NETSTACK_LLSEC.input(buf);
}

View file

@ -38,7 +38,7 @@
* Niclas Finne <nfi@sics.se>
*/
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include "net/mac/mac-sequence.h"
#include "net/mac/nullrdc.h"
@ -131,7 +131,7 @@
/*---------------------------------------------------------------------------*/
static int
send_one_packet(struct net_mbuf *buf, mac_callback_t sent, void *ptr)
send_one_packet(struct net_buf *buf, mac_callback_t sent, void *ptr)
{
int ret;
int last_sent_ok = 0;
@ -306,13 +306,13 @@ send_one_packet(struct net_mbuf *buf, mac_callback_t sent, void *ptr)
}
/*---------------------------------------------------------------------------*/
static uint8_t
send_packet(struct net_mbuf *buf, mac_callback_t sent, void *ptr)
send_packet(struct net_buf *buf, mac_callback_t sent, void *ptr)
{
return send_one_packet(buf, sent, ptr);
}
/*---------------------------------------------------------------------------*/
static uint8_t
send_list(struct net_mbuf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
send_list(struct net_buf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
while(buf_list != NULL) {
/* We backup the next pointer, as it may be nullified by
@ -336,7 +336,7 @@ send_list(struct net_mbuf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_l
}
/*---------------------------------------------------------------------------*/
static uint8_t
packet_input(struct net_mbuf *buf)
packet_input(struct net_buf *buf)
{
#if NULLRDC_SEND_802154_ACK
int original_datalen;

View file

@ -41,7 +41,7 @@
#ifndef RDC_H_
#define RDC_H_
#include <net/net_buf.h>
#include <net/buf.h>
#include "contiki-conf.h"
#include "net/mac/mac.h"
@ -73,13 +73,13 @@ struct rdc_driver {
void (* init)(void);
/** Send a packet from the Rime buffer */
uint8_t (* send)(struct net_mbuf *buf, mac_callback_t sent_callback, void *ptr);
uint8_t (* send)(struct net_buf *buf, mac_callback_t sent_callback, void *ptr);
/** Send a packet list */
uint8_t (* send_list)(struct net_mbuf *buf, mac_callback_t sent_callback, void *ptr, struct rdc_buf_list *list);
uint8_t (* send_list)(struct net_buf *buf, mac_callback_t sent_callback, void *ptr, struct rdc_buf_list *list);
/** Callback for getting notified of incoming packet. */
uint8_t (* input)(struct net_mbuf *buf);
uint8_t (* input)(struct net_buf *buf);
/** Turn the MAC layer on. */
int (* on)(void);

View file

@ -45,6 +45,8 @@
#include <string.h>
#include <net/l2_buf.h>
#include "net/mac/sicslowmac/sicslowmac.h"
#include "net/mac/frame802154.h"
#include "net/packetbuf.h"
@ -95,7 +97,7 @@ is_broadcast_addr(uint8_t mode, uint8_t *addr)
}
/*---------------------------------------------------------------------------*/
static uint8_t
send_packet(struct net_mbuf *buf, mac_callback_t sent, void *ptr)
send_packet(struct net_buf *buf, mac_callback_t sent, void *ptr)
{
frame802154_t params;
uint8_t len;
@ -180,7 +182,7 @@ send_packet(struct net_mbuf *buf, mac_callback_t sent, void *ptr)
}
/*---------------------------------------------------------------------------*/
uint8_t
send_list(struct net_mbuf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
send_list(struct net_buf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
if(buf_list != NULL) {
queuebuf_to_packetbuf(buf, buf_list->buf);
@ -193,7 +195,7 @@ send_list(struct net_mbuf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_l
}
/*---------------------------------------------------------------------------*/
static uint8_t
input_packet(struct net_mbuf *buf)
input_packet(struct net_buf *buf)
{
frame802154_t frame;
int len;

View file

@ -41,7 +41,7 @@
#ifndef NETSTACK_H
#define NETSTACK_H
#include <net/net_buf.h>
#include <net/buf.h>
#include "contiki-conf.h"

View file

@ -1,4 +1,4 @@
#include <net/net_buf.h>
#include <net/buf.h>
#include "dev/nullradio.h"
@ -17,13 +17,13 @@ prepare(const void *payload, unsigned short payload_len)
}
/*---------------------------------------------------------------------------*/
static int
transmit(struct net_mbuf *buf, unsigned short transmit_len)
transmit(struct net_buf *buf, unsigned short transmit_len)
{
return RADIO_TX_OK;
}
/*---------------------------------------------------------------------------*/
static int
send(struct net_mbuf *buf, const void *payload, unsigned short payload_len)
send(struct net_buf *buf, const void *payload, unsigned short payload_len)
{
prepare(payload, payload_len);
return transmit(buf, payload_len);

View file

@ -59,7 +59,7 @@
#include <stddef.h>
#include <net/net_buf.h>
#include <net/buf.h>
/**
* Each radio has a set of parameters that designate the current
@ -232,10 +232,10 @@ struct radio_driver {
int (* prepare)(const void *payload, unsigned short payload_len);
/** Send the packet that has previously been prepared. */
int (* transmit)(struct net_mbuf *buf, unsigned short transmit_len);
int (* transmit)(struct net_buf *buf, unsigned short transmit_len);
/** Prepare & transmit a packet. */
int (* send)(struct net_mbuf *buf, const void *payload, unsigned short payload_len);
int (* send)(struct net_buf *buf, const void *payload, unsigned short payload_len);
/** Read a received packet into a buffer. */
int (* read)(void *buf, unsigned short buf_len);

View file

@ -40,6 +40,8 @@
#include <simple/uart.h>
#include <net/net_core.h>
#include <net/l2_buf.h>
#include "contiki.h"
#include "net/ip/uip.h"
@ -272,7 +274,7 @@ PROCESS_THREAD(slip_process, ev, data, not_used)
slip_active = 1;
buf = net_buf_get_reserve_rx(0);
buf = ip_buf_get_reserve_rx(0);
if (!buf) {
NET_ERR("No RX buffers left, slip msg discarded\n");
rxbuf_init();
@ -296,7 +298,7 @@ PROCESS_THREAD(slip_process, ev, data, not_used)
* the buffer here as that would cause double free.
*/
if (uip_len(buf) != 0) {
net_buf_put(buf);
ip_buf_unref(buf);
}
} else if(uip_len(buf) > 0
&& uip_len(buf) == (((uint16_t)(BUF(buf)->len[0]) << 8) + BUF(buf)->len[1])
@ -315,9 +317,11 @@ PROCESS_THREAD(slip_process, ev, data, not_used)
}
}
net_buf_add(buf, uip_len(buf));
#ifdef SLIP_CONF_TCPIP_INPUT
if (SLIP_CONF_TCPIP_INPUT(buf) < 0) {
net_buf_put(buf);
ip_buf_unref(buf);
}
#else
tcpip_input(buf);
@ -325,17 +329,19 @@ PROCESS_THREAD(slip_process, ev, data, not_used)
} else {
NET_DBG("Dropping slip message buf %p\n", buf);
uip_len(buf) = 0;
net_buf_put(buf);
ip_buf_unref(buf);
SLIP_STATISTICS(slip_ip_drop++);
}
#else /* NETSTACK_CONF_WITH_IPV6 */
if(uip_len(buf) > 0) {
net_buf_add(buf, uip_len(buf));
if(input_callback) {
input_callback();
}
#ifdef SLIP_CONF_TCPIP_INPUT
if (SLIP_CONF_TCPIP_INPUT(buf) < 0) {
net_buf_put(buf);
ip_buf_unref(buf);
}
#else
tcpip_input(buf);

View file

@ -42,7 +42,7 @@
* @{
*/
#include <net/net_buf.h>
#include <net/buf.h>
#include "sys/ctimer.h"
#include "contiki.h"
@ -101,8 +101,8 @@ ctimer_init(void)
}
/*---------------------------------------------------------------------------*/
void
ctimer_set(struct net_mbuf *buf, struct ctimer *c, clock_time_t t,
void (*f)(struct net_mbuf *, void *), void *ptr)
ctimer_set(struct net_buf *buf, struct ctimer *c, clock_time_t t,
void (*f)(struct net_buf *, void *), void *ptr)
{
c->p = &ctimer_process;
c->f = f;

View file

@ -51,22 +51,20 @@
*
*/
#include <net/net_buf.h>
#include <net/buf.h>
#ifndef CTIMER_H_
#define CTIMER_H_
#include "sys/etimer.h"
struct net_mbuf;
struct ctimer {
struct ctimer *next;
struct etimer etimer;
struct process *p;
void (*f)(struct net_mbuf *, void *);
void (*f)(struct net_buf *, void *);
void *ptr;
struct net_mbuf *buf;
struct net_buf *buf;
};
/**
@ -115,8 +113,8 @@ void ctimer_restart(struct ctimer *c);
* the callback function f will be called with ptr as argument.
*
*/
void ctimer_set(struct net_mbuf *buf, struct ctimer *c, clock_time_t t,
void (*f)(struct net_mbuf *, void *), void *ptr);
void ctimer_set(struct net_buf *buf, struct ctimer *c, clock_time_t t,
void (*f)(struct net_buf *, void *), void *ptr);
/**
* \brief Stop a pending callback timer.

View file

@ -45,7 +45,7 @@
#include <stdio.h>
#include <net/net_buf.h>
#include <net/buf.h>
#include <net/net_core.h>
#include "sys/process.h"

View file

@ -44,6 +44,8 @@
#include <string.h>
#include <net/l2_buf.h>
#include "contiki-net.h"
#include "net/packetbuf.h"
@ -52,7 +54,7 @@
#endif
#if 0
/* Moved to net_buf.h */
/* Moved to l2_buf.h */
struct packetbuf_attr packetbuf_attrs[PACKETBUF_NUM_ATTRS];
struct packetbuf_addr packetbuf_addrs[PACKETBUF_NUM_ADDRS];
@ -85,7 +87,7 @@ void uip_log(char *msg);
/*---------------------------------------------------------------------------*/
void
packetbuf_clear(struct net_mbuf *buf)
packetbuf_clear(struct net_buf *buf)
{
uip_pkt_buflen(buf) = uip_pkt_bufptr(buf) = 0;
uip_pkt_hdrptr(buf) = PACKETBUF_HDR_SIZE;
@ -95,13 +97,13 @@ packetbuf_clear(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
void
packetbuf_clear_hdr(struct net_mbuf *buf)
packetbuf_clear_hdr(struct net_buf *buf)
{
uip_pkt_hdrptr(buf) = PACKETBUF_HDR_SIZE;
}
/*---------------------------------------------------------------------------*/
int
packetbuf_copyfrom(struct net_mbuf *buf, const void *from, uint16_t len)
packetbuf_copyfrom(struct net_buf *buf, const void *from, uint16_t len)
{
uint16_t l;
@ -113,7 +115,7 @@ packetbuf_copyfrom(struct net_mbuf *buf, const void *from, uint16_t len)
}
/*---------------------------------------------------------------------------*/
void
packetbuf_compact(struct net_mbuf *buf)
packetbuf_compact(struct net_buf *buf)
{
int i, len;
@ -131,7 +133,7 @@ packetbuf_compact(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
int
packetbuf_copyto_hdr(struct net_mbuf *buf, uint8_t *to)
packetbuf_copyto_hdr(struct net_buf *buf, uint8_t *to)
{
#if DEBUG_LEVEL > 0
{
@ -149,7 +151,7 @@ packetbuf_copyto_hdr(struct net_mbuf *buf, uint8_t *to)
}
/*---------------------------------------------------------------------------*/
int
packetbuf_copyto(struct net_mbuf *buf, void *to)
packetbuf_copyto(struct net_buf *buf, void *to)
{
#if DEBUG_LEVEL > 0
{
@ -181,7 +183,7 @@ packetbuf_copyto(struct net_mbuf *buf, void *to)
}
/*---------------------------------------------------------------------------*/
int
packetbuf_hdralloc(struct net_mbuf *buf, int size)
packetbuf_hdralloc(struct net_buf *buf, int size)
{
if(uip_pkt_hdrptr(buf) >= size && packetbuf_totlen(buf) + size <= PACKETBUF_SIZE) {
uip_pkt_hdrptr(buf) -= size;
@ -191,13 +193,13 @@ packetbuf_hdralloc(struct net_mbuf *buf, int size)
}
/*---------------------------------------------------------------------------*/
void
packetbuf_hdr_remove(struct net_mbuf *buf, int size)
packetbuf_hdr_remove(struct net_buf *buf, int size)
{
uip_pkt_hdrptr(buf) += size;
}
/*---------------------------------------------------------------------------*/
int
packetbuf_hdrreduce(struct net_mbuf *buf, int size)
packetbuf_hdrreduce(struct net_buf *buf, int size)
{
if(uip_pkt_buflen(buf) < size) {
return 0;
@ -209,26 +211,26 @@ packetbuf_hdrreduce(struct net_mbuf *buf, int size)
}
/*---------------------------------------------------------------------------*/
void
packetbuf_set_datalen(struct net_mbuf *buf, uint16_t len)
packetbuf_set_datalen(struct net_buf *buf, uint16_t len)
{
PRINTF("packetbuf_set_len: len %d\n", len);
uip_pkt_buflen(buf) = len;
}
/*---------------------------------------------------------------------------*/
void *
packetbuf_dataptr(struct net_mbuf *buf)
packetbuf_dataptr(struct net_buf *buf)
{
return (void *)(&uip_pkt_packetbuf(buf)[uip_pkt_bufptr(buf) + PACKETBUF_HDR_SIZE]);
}
/*---------------------------------------------------------------------------*/
void *
packetbuf_hdrptr(struct net_mbuf *buf)
packetbuf_hdrptr(struct net_buf *buf)
{
return (void *)(&uip_pkt_packetbuf(buf)[uip_pkt_hdrptr(buf)]);
}
/*---------------------------------------------------------------------------*/
void
packetbuf_reference(struct net_mbuf *buf, void *ptr, uint16_t len)
packetbuf_reference(struct net_buf *buf, void *ptr, uint16_t len)
{
packetbuf_clear(buf);
uip_pkt_packetbufptr(buf) = ptr;
@ -236,25 +238,25 @@ packetbuf_reference(struct net_mbuf *buf, void *ptr, uint16_t len)
}
/*---------------------------------------------------------------------------*/
int
packetbuf_is_reference(struct net_mbuf *buf)
packetbuf_is_reference(struct net_buf *buf)
{
return uip_pkt_packetbufptr(buf) != &uip_pkt_packetbuf(buf)[PACKETBUF_HDR_SIZE];
}
/*---------------------------------------------------------------------------*/
void *
packetbuf_reference_ptr(struct net_mbuf *buf)
packetbuf_reference_ptr(struct net_buf *buf)
{
return uip_pkt_packetbufptr(buf);
}
/*---------------------------------------------------------------------------*/
uint16_t
packetbuf_datalen(struct net_mbuf *buf)
packetbuf_datalen(struct net_buf *buf)
{
return uip_pkt_buflen(buf);
}
/*---------------------------------------------------------------------------*/
uint8_t
packetbuf_hdrlen(struct net_mbuf *buf)
packetbuf_hdrlen(struct net_buf *buf)
{
uint8_t hdrlen;
@ -269,13 +271,13 @@ packetbuf_hdrlen(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
uint16_t
packetbuf_totlen(struct net_mbuf *buf)
packetbuf_totlen(struct net_buf *buf)
{
return packetbuf_hdrlen(buf) + packetbuf_datalen(buf);
}
/*---------------------------------------------------------------------------*/
void
packetbuf_attr_clear(struct net_mbuf *buf)
packetbuf_attr_clear(struct net_buf *buf)
{
int i;
for(i = 0; i < PACKETBUF_NUM_ATTRS; ++i) {
@ -287,7 +289,7 @@ packetbuf_attr_clear(struct net_mbuf *buf)
}
/*---------------------------------------------------------------------------*/
void
packetbuf_attr_copyto(struct net_mbuf *buf, struct packetbuf_attr *attrs,
packetbuf_attr_copyto(struct net_buf *buf, struct packetbuf_attr *attrs,
struct packetbuf_addr *addrs)
{
memcpy(attrs, uip_pkt_packetbuf_attrs(buf), sizeof(uip_pkt_packetbuf_attrs(buf)));
@ -295,7 +297,7 @@ packetbuf_attr_copyto(struct net_mbuf *buf, struct packetbuf_attr *attrs,
}
/*---------------------------------------------------------------------------*/
void
packetbuf_attr_copyfrom(struct net_mbuf *buf, struct packetbuf_attr *attrs,
packetbuf_attr_copyfrom(struct net_buf *buf, struct packetbuf_attr *attrs,
struct packetbuf_addr *addrs)
{
memcpy(uip_pkt_packetbuf_attrs(buf), attrs, sizeof(uip_pkt_packetbuf_attrs(buf)));
@ -304,7 +306,7 @@ packetbuf_attr_copyfrom(struct net_mbuf *buf, struct packetbuf_attr *attrs,
/*---------------------------------------------------------------------------*/
#if !PACKETBUF_CONF_ATTRS_INLINE
int
packetbuf_set_attr(struct net_mbuf *buf, uint8_t type, const packetbuf_attr_t val)
packetbuf_set_attr(struct net_buf *buf, uint8_t type, const packetbuf_attr_t val)
{
/* uip_pkt_packetbuf_attrs(buf)[type].type = type; */
uip_pkt_packetbuf_attrs(buf)[type].val = val;
@ -312,13 +314,13 @@ packetbuf_set_attr(struct net_mbuf *buf, uint8_t type, const packetbuf_attr_t va
}
/*---------------------------------------------------------------------------*/
packetbuf_attr_t
packetbuf_attr(struct net_mbuf *buf, uint8_t type)
packetbuf_attr(struct net_buf *buf, uint8_t type)
{
return uip_pkt_packetbuf_attrs(buf)[type].val;
}
/*---------------------------------------------------------------------------*/
int
packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr)
packetbuf_set_addr(struct net_buf *buf, uint8_t type, const linkaddr_t *addr)
{
/* uip_pkt_packetbuf_addrs(buf)[type - PACKETBUF_ADDR_FIRST].type = type; */
linkaddr_copy(&uip_pkt_packetbuf_addrs(buf)[type - PACKETBUF_ADDR_FIRST].addr, addr);
@ -326,14 +328,14 @@ packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr)
}
/*---------------------------------------------------------------------------*/
const linkaddr_t *
packetbuf_addr(struct net_mbuf *buf, uint8_t type)
packetbuf_addr(struct net_buf *buf, uint8_t type)
{
return &uip_pkt_packetbuf_addrs(buf)[type - PACKETBUF_ADDR_FIRST].addr;
}
/*---------------------------------------------------------------------------*/
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
int
packetbuf_holds_broadcast(struct net_mbuf *buf)
packetbuf_holds_broadcast(struct net_buf *buf)
{
return linkaddr_cmp(&uip_pkt_packetbuf_addrs(buf)[PACKETBUF_ADDR_RECEIVER - PACKETBUF_ADDR_FIRST].addr, &linkaddr_null);
}

View file

@ -74,7 +74,7 @@
#define PACKETBUF_HDR_SIZE 48
#endif
struct net_mbuf;
struct net_buf;
/**
* \brief Clear and reset the packetbuf
@ -85,7 +85,7 @@ struct net_mbuf;
* packet in the packetbuf.
*
*/
void packetbuf_clear(struct net_mbuf *buf);
void packetbuf_clear(struct net_buf *buf);
/**
* \brief Clear and reset the header of the packetbuf
@ -98,9 +98,9 @@ void packetbuf_clear(struct net_mbuf *buf);
* packet buffer for a later retransmission.
*
*/
void packetbuf_clear_hdr(struct net_mbuf *buf);
void packetbuf_clear_hdr(struct net_buf *buf);
void packetbuf_hdr_remove(struct net_mbuf *buf, int bytes);
void packetbuf_hdr_remove(struct net_buf *buf, int bytes);
/**
* \brief Get a pointer to the data in the packetbuf
@ -120,7 +120,7 @@ void packetbuf_hdr_remove(struct net_mbuf *buf, int bytes);
* the header for incoming packets.
*
*/
void *packetbuf_dataptr(struct net_mbuf *buf);
void *packetbuf_dataptr(struct net_buf *buf);
/**
* \brief Get a pointer to the header in the packetbuf, for outbound packets
@ -132,7 +132,7 @@ void *packetbuf_dataptr(struct net_mbuf *buf);
* stored in the packetbuf.
*
*/
void *packetbuf_hdrptr(struct net_mbuf *buf);
void *packetbuf_hdrptr(struct net_buf *buf);
/**
* \brief Get the length of the header in the packetbuf
@ -145,7 +145,7 @@ void *packetbuf_hdrptr(struct net_mbuf *buf);
* packetbuf_hdrptr() function.
*
*/
uint8_t packetbuf_hdrlen(struct net_mbuf *buf);
uint8_t packetbuf_hdrlen(struct net_buf *buf);
/**
@ -164,14 +164,14 @@ uint8_t packetbuf_hdrlen(struct net_mbuf *buf);
* length of the packet - both header and data.
*
*/
uint16_t packetbuf_datalen(struct net_mbuf *buf);
uint16_t packetbuf_datalen(struct net_buf *buf);
/**
* \brief Get the total length of the header and data in the packetbuf
* \return Length of data and header in the packetbuf
*
*/
uint16_t packetbuf_totlen(struct net_mbuf *buf);
uint16_t packetbuf_totlen(struct net_buf *buf);
/**
* \brief Set the length of the data in the packetbuf
@ -181,7 +181,7 @@ uint16_t packetbuf_totlen(struct net_mbuf *buf);
* parts: header and data. This function is used to set
* the length of the data in the packetbuf.
*/
void packetbuf_set_datalen(struct net_mbuf *buf, uint16_t len);
void packetbuf_set_datalen(struct net_buf *buf, uint16_t len);
/**
* \brief Point the packetbuf to external data
@ -194,7 +194,7 @@ void packetbuf_set_datalen(struct net_mbuf *buf, uint16_t len);
* specifies the length of the external data that the
* packetbuf references.
*/
void packetbuf_reference(struct net_mbuf *buf, void *ptr, uint16_t len);
void packetbuf_reference(struct net_buf *buf, void *ptr, uint16_t len);
/**
* \brief Check if the packetbuf references external data
@ -206,7 +206,7 @@ void packetbuf_reference(struct net_mbuf *buf, void *ptr, uint16_t len);
* previously been referenced with packetbuf_reference().
*
*/
int packetbuf_is_reference(struct net_mbuf *buf);
int packetbuf_is_reference(struct net_buf *buf);
/**
* \brief Get a pointer to external data referenced by the packetbuf
@ -219,7 +219,7 @@ int packetbuf_is_reference(struct net_mbuf *buf);
* pointer to the external data.
*
*/
void *packetbuf_reference_ptr(struct net_mbuf *buf);
void *packetbuf_reference_ptr(struct net_buf *buf);
/**
* \brief Compact the packetbuf
@ -235,7 +235,7 @@ void *packetbuf_reference_ptr(struct net_mbuf *buf);
* that the entire packet is consecutive in memory.
*
*/
void packetbuf_compact(struct net_mbuf *buf);
void packetbuf_compact(struct net_buf *buf);
/**
* \brief Copy from external data into the packetbuf
@ -250,7 +250,7 @@ void packetbuf_compact(struct net_mbuf *buf);
* copied into the rimbuf is returned.
*
*/
int packetbuf_copyfrom(struct net_mbuf *buf, const void *from, uint16_t len);
int packetbuf_copyfrom(struct net_buf *buf, const void *from, uint16_t len);
/**
* \brief Copy the entire packetbuf to an external buffer
@ -270,7 +270,7 @@ int packetbuf_copyfrom(struct net_mbuf *buf, const void *from, uint16_t len);
* returned.
*
*/
int packetbuf_copyto(struct net_mbuf *buf, void *to);
int packetbuf_copyto(struct net_buf *buf, void *to);
/**
* \brief Copy the header portion of the packetbuf to an external buffer
@ -286,7 +286,7 @@ int packetbuf_copyto(struct net_mbuf *buf, void *to);
* copied to the external buffer is returned.
*
*/
int packetbuf_copyto_hdr(struct net_mbuf *buf, uint8_t *to);
int packetbuf_copyto_hdr(struct net_buf *buf, uint8_t *to);
/**
* \brief Extend the header of the packetbuf, for outbound packets
@ -300,7 +300,7 @@ int packetbuf_copyto_hdr(struct net_mbuf *buf, uint8_t *to);
* zero and does not allocate anything.
*
*/
int packetbuf_hdralloc(struct net_mbuf *buf, int size);
int packetbuf_hdralloc(struct net_buf *buf, int size);
/**
* \brief Reduce the header in the packetbuf, for incoming packets
@ -314,7 +314,7 @@ int packetbuf_hdralloc(struct net_mbuf *buf, int size);
* zero and does not allocate anything.
*
*/
int packetbuf_hdrreduce(struct net_mbuf *buf, int size);
int packetbuf_hdrreduce(struct net_buf *buf, int size);
/* Packet attributes stuff below: */
@ -430,26 +430,26 @@ extern struct packetbuf_attr packetbuf_attrs[];
extern struct packetbuf_addr packetbuf_addrs[];
#endif
static int packetbuf_set_attr(struct net_mbuf *buf, uint8_t type, const packetbuf_attr_t val);
static packetbuf_attr_t packetbuf_attr(struct net_mbuf *buf, uint8_t type);
static int packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr);
static const linkaddr_t *packetbuf_addr(struct net_mbuf *buf, uint8_t type);
static int packetbuf_set_attr(struct net_buf *buf, uint8_t type, const packetbuf_attr_t val);
static packetbuf_attr_t packetbuf_attr(struct net_buf *buf, uint8_t type);
static int packetbuf_set_addr(struct net_buf *buf, uint8_t type, const linkaddr_t *addr);
static const linkaddr_t *packetbuf_addr(struct net_buf *buf, uint8_t type);
static inline int
packetbuf_set_attr(struct net_mbuf *buf, uint8_t type, const packetbuf_attr_t val)
packetbuf_set_attr(struct net_buf *buf, uint8_t type, const packetbuf_attr_t val)
{
/* packetbuf_attrs[type].type = type; */
uip_pkt_packetbuf_attrs(buf)[type].val = val;
return 1;
}
static inline packetbuf_attr_t
packetbuf_attr(struct net_mbuf *buf, uint8_t type)
packetbuf_attr(struct net_buf *buf, uint8_t type)
{
return uip_pkt_packetbuf_attrs(buf)[type].val;
}
static inline int
packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr)
packetbuf_set_addr(struct net_buf *buf, uint8_t type, const linkaddr_t *addr)
{
/* packetbuf_addrs[type - PACKETBUF_ADDR_FIRST].type = type; */
linkaddr_copy(&uip_pkt_packetbuf_addrs(buf)[type - PACKETBUF_ADDR_FIRST].addr, addr);
@ -457,29 +457,29 @@ packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr)
}
static inline const linkaddr_t *
packetbuf_addr(struct net_mbuf *buf, uint8_t type)
packetbuf_addr(struct net_buf *buf, uint8_t type)
{
return &uip_pkt_packetbuf_addrs(buf)[type - PACKETBUF_ADDR_FIRST].addr;
}
#else /* PACKETBUF_CONF_ATTRS_INLINE */
int packetbuf_set_attr(struct net_mbuf *buf, uint8_t type, const packetbuf_attr_t val);
packetbuf_attr_t packetbuf_attr(struct net_mbuf *buf, uint8_t type);
int packetbuf_set_addr(struct net_mbuf *buf, uint8_t type, const linkaddr_t *addr);
const linkaddr_t *packetbuf_addr(struct net_mbuf *buf, uint8_t type);
int packetbuf_set_attr(struct net_buf *buf, uint8_t type, const packetbuf_attr_t val);
packetbuf_attr_t packetbuf_attr(struct net_buf *buf, uint8_t type);
int packetbuf_set_addr(struct net_buf *buf, uint8_t type, const linkaddr_t *addr);
const linkaddr_t *packetbuf_addr(struct net_buf *buf, uint8_t type);
#endif /* PACKETBUF_CONF_ATTRS_INLINE */
/**
* \brief Checks whether the current packet is a broadcast.
* \retval 0 iff current packet is not a broadcast
*/
int packetbuf_holds_broadcast(struct net_mbuf *buf);
int packetbuf_holds_broadcast(struct net_buf *buf);
void packetbuf_attr_clear(struct net_mbuf *buf);
void packetbuf_attr_clear(struct net_buf *buf);
void packetbuf_attr_copyto(struct net_mbuf *buf,
void packetbuf_attr_copyto(struct net_buf *buf,
struct packetbuf_attr *attrs,
struct packetbuf_addr *addrs);
void packetbuf_attr_copyfrom(struct net_mbuf *buf,
void packetbuf_attr_copyfrom(struct net_buf *buf,
struct packetbuf_attr *attrs,
struct packetbuf_addr *addrs);

View file

@ -313,7 +313,7 @@ queuebuf_init(void)
}
/*---------------------------------------------------------------------------*/
int
queuebuf_numfree(struct net_mbuf *buf)
queuebuf_numfree(struct net_buf *buf)
{
if(packetbuf_is_reference(buf)) {
return memb_numfree(&refbufmem);
@ -324,10 +324,10 @@ queuebuf_numfree(struct net_mbuf *buf)
/*---------------------------------------------------------------------------*/
#if QUEUEBUF_DEBUG
struct queuebuf *
queuebuf_new_from_packetbuf_debug(struct net_mbuf *netbuf, const char *file, int line)
queuebuf_new_from_packetbuf_debug(struct net_buf *netbuf, const char *file, int line)
#else /* QUEUEBUF_DEBUG */
struct queuebuf *
queuebuf_new_from_packetbuf(struct net_mbuf *netbuf)
queuebuf_new_from_packetbuf(struct net_buf *netbuf)
#endif /* QUEUEBUF_DEBUG */
{
struct queuebuf *buf;
@ -409,7 +409,7 @@ queuebuf_new_from_packetbuf(struct net_mbuf *netbuf)
}
/*---------------------------------------------------------------------------*/
void
queuebuf_update_attr_from_packetbuf(struct net_mbuf *netbuf, struct queuebuf *buf)
queuebuf_update_attr_from_packetbuf(struct net_buf *netbuf, struct queuebuf *buf)
{
struct queuebuf_data *buframptr = queuebuf_load_to_ram(buf);
packetbuf_attr_copyto(netbuf, buframptr->attrs, buframptr->addrs);
@ -421,7 +421,7 @@ queuebuf_update_attr_from_packetbuf(struct net_mbuf *netbuf, struct queuebuf *bu
}
/*---------------------------------------------------------------------------*/
void
queuebuf_update_from_packetbuf(struct net_mbuf *netbuf, struct queuebuf *buf)
queuebuf_update_from_packetbuf(struct net_buf *netbuf, struct queuebuf *buf)
{
struct queuebuf_data *buframptr = queuebuf_load_to_ram(buf);
packetbuf_attr_copyto(netbuf, buframptr->attrs, buframptr->addrs);
@ -463,7 +463,7 @@ queuebuf_free(struct queuebuf *buf)
}
/*---------------------------------------------------------------------------*/
void
queuebuf_to_packetbuf(struct net_mbuf *netbuf, struct queuebuf *b)
queuebuf_to_packetbuf(struct net_buf *netbuf, struct queuebuf *b)
{
struct queuebuf_ref *r;
if(memb_inmemb(&bufmem, b)) {

View file

@ -90,15 +90,15 @@ struct queuebuf;
void queuebuf_init(void);
#if QUEUEBUF_DEBUG
struct queuebuf *queuebuf_new_from_packetbuf_debug(struct net_mbuf *buf, const char *file, int line);
struct queuebuf *queuebuf_new_from_packetbuf_debug(struct net_buf *buf, const char *file, int line);
#define queuebuf_new_from_packetbuf(buf) queuebuf_new_from_packetbuf_debug(buf,__FILE__, __LINE__)
#else /* QUEUEBUF_DEBUG */
struct queuebuf *queuebuf_new_from_packetbuf(struct net_mbuf *buf);
struct queuebuf *queuebuf_new_from_packetbuf(struct net_buf *buf);
#endif /* QUEUEBUF_DEBUG */
void queuebuf_update_attr_from_packetbuf(struct net_mbuf *buf, struct queuebuf *b);
void queuebuf_update_from_packetbuf(struct net_mbuf *buf, struct queuebuf *b);
void queuebuf_update_attr_from_packetbuf(struct net_buf *buf, struct queuebuf *b);
void queuebuf_update_from_packetbuf(struct net_buf *buf, struct queuebuf *b);
void queuebuf_to_packetbuf(struct net_mbuf *buf, struct queuebuf *b);
void queuebuf_to_packetbuf(struct net_buf *buf, struct queuebuf *b);
void queuebuf_free(struct queuebuf *b);
void *queuebuf_dataptr(struct queuebuf *b);
@ -109,7 +109,7 @@ packetbuf_attr_t queuebuf_attr(struct queuebuf *b, uint8_t type);
void queuebuf_debug_print(void);
int queuebuf_numfree(struct net_mbuf *buf);
int queuebuf_numfree(struct net_buf *buf);
#endif /* __QUEUEBUF_H__ */

View file

@ -44,7 +44,7 @@
* @{
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "net/ip/uip.h"
#include "net/ip/tcpip.h"
@ -246,7 +246,7 @@ rpl_update_header_empty(struct net_buf *buf)
/* We should send back the packet to the originating parent,
but it is not feasible yet, so we send a No-Path DAO instead */
PRINTF("RPL generate No-Path DAO\n");
parent = rpl_get_parent((uip_lladdr_t *)&buf->src);
parent = rpl_get_parent((uip_lladdr_t *)&ip_buf_ll_src(buf));
if(parent != NULL) {
dao_output_target(parent, &UIP_IP_BUF(buf)->destipaddr, RPL_ZERO_LIFETIME);
}

View file

@ -45,7 +45,7 @@
* @{
*/
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "net/ip/tcpip.h"
#include "net/ip/uip.h"
@ -195,7 +195,7 @@ dis_output(struct net_buf *buf, uip_ipaddr_t *addr)
*/
if (!buf) {
buf = net_buf_get_reserve_tx(0);
buf = ip_buf_get_reserve_tx(0);
if (!buf) {
PRINTF("%s(): Cannot get net_buf\n", __FUNCTION__);
return;
@ -248,7 +248,7 @@ dio_input(struct net_buf *buf)
PRINTF("\n");
if((nbr = uip_ds6_nbr_lookup(&from)) == NULL) {
if((nbr = uip_ds6_nbr_add(&from, (uip_lladdr_t *)&buf->src,
if((nbr = uip_ds6_nbr_add(&from, (uip_lladdr_t *)&ip_buf_ll_src(buf),
0, NBR_REACHABLE)) != NULL) {
/* set reachable timer */
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
@ -261,7 +261,7 @@ dio_input(struct net_buf *buf)
PRINTF("RPL: Out of memory, dropping DIO from ");
PRINT6ADDR(&from);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)&buf->src);
PRINTLLADDR((uip_lladdr_t *)&ip_buf_ll_src(buf));
PRINTF("\n");
goto out;
}
@ -452,7 +452,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
/* DAG Information Object */
pos = 0;
buf = net_buf_get_reserve_tx(0);
buf = ip_buf_get_reserve_tx(0);
if (!buf) {
PRINTF("%s(): Cannot get net_buf\n", __FUNCTION__);
return;
@ -516,7 +516,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
} else {
PRINTF("RPL: Unable to send DIO because of unhandled DAG MC type %u\n",
(unsigned)instance->mc.type);
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
}
@ -766,7 +766,7 @@ dao_input(struct net_buf *buf)
if((nbr = uip_ds6_nbr_lookup(&dao_sender_addr)) == NULL) {
if((nbr = uip_ds6_nbr_add(&dao_sender_addr,
(uip_lladdr_t *)&buf->src,
(uip_lladdr_t *)&ip_buf_ll_src(buf),
0, NBR_REACHABLE)) != NULL) {
/* set reachable timer */
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
@ -779,7 +779,7 @@ dao_input(struct net_buf *buf)
PRINTF("RPL: Out of Memory, dropping DAO from ");
PRINT6ADDR(&dao_sender_addr);
PRINTF(", ");
PRINTLLADDR((uip_lladdr_t *)&buf->src);
PRINTLLADDR((uip_lladdr_t *)&ip_buf_ll_src(buf));
PRINTF("\n");
return;
}
@ -880,7 +880,7 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime)
RPL_DEBUG_DAO_OUTPUT(parent);
#endif
buf = net_buf_get_reserve_tx(0);
buf = ip_buf_get_reserve_tx(0);
if (!buf) {
PRINTF("%s(): Cannot get net_buf\n", __FUNCTION__);
return;
@ -935,7 +935,7 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime)
return;
}
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
/*---------------------------------------------------------------------------*/

View file

@ -53,9 +53,9 @@
/*---------------------------------------------------------------------------*/
static struct ctimer periodic_timer;
static void handle_periodic_timer(struct net_mbuf *mbuf, void *ptr);
static void handle_periodic_timer(struct net_buf *mbuf, void *ptr);
static void new_dio_interval(rpl_instance_t *instance);
static void handle_dio_timer(struct net_mbuf *mbuf, void *ptr);
static void handle_dio_timer(struct net_buf *mbuf, void *ptr);
static uint16_t next_dis;
@ -64,7 +64,7 @@ static uint8_t dio_send_ok;
/*---------------------------------------------------------------------------*/
static void
handle_periodic_timer(struct net_mbuf *not_used, void *ptr)
handle_periodic_timer(struct net_buf *not_used, void *ptr)
{
rpl_purge_routes();
rpl_recalculate_ranks();
@ -126,7 +126,7 @@ new_dio_interval(rpl_instance_t *instance)
}
/*---------------------------------------------------------------------------*/
static void
handle_dio_timer(struct net_mbuf *not_used, void *ptr)
handle_dio_timer(struct net_buf *not_used, void *ptr)
{
rpl_instance_t *instance;
@ -201,7 +201,7 @@ rpl_reset_dio_timer(rpl_instance_t *instance)
#endif /* RPL_LEAF_ONLY */
}
/*---------------------------------------------------------------------------*/
static void handle_dao_timer(struct net_mbuf *mbuf, void *ptr);
static void handle_dao_timer(struct net_buf *mbuf, void *ptr);
static void
set_dao_lifetime_timer(rpl_instance_t *instance)
{
@ -224,7 +224,7 @@ set_dao_lifetime_timer(rpl_instance_t *instance)
}
/*---------------------------------------------------------------------------*/
static void
handle_dao_timer(struct net_mbuf *not_used, void *ptr)
handle_dao_timer(struct net_buf *not_used, void *ptr)
{
rpl_instance_t *instance;
#if RPL_CONF_MULTICAST
@ -396,7 +396,7 @@ get_probing_target(rpl_dag_t *dag)
}
/*---------------------------------------------------------------------------*/
static void
handle_probing_timer(struct net_mbuf *not_used, void *ptr)
handle_probing_timer(struct net_buf *not_used, void *ptr)
{
rpl_instance_t *instance = (rpl_instance_t *)ptr;
rpl_parent_t *probing_target = RPL_PROBING_SELECT_FUNC(instance->current_dag);

View file

@ -38,7 +38,7 @@
#ifndef RPL_H
#define RPL_H
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "rpl-conf.h"

View file

@ -17,7 +17,7 @@
*/
#include "contiki-conf.h"
#include <net/net_buf.h>
#include <net/buf.h>
#ifndef COMPRESSION_H_
#define COMPRESSION_H_

View file

@ -17,7 +17,7 @@
*/
#include "contiki-conf.h"
#include <net/net_buf.h>
#include <net/buf.h>
#include <net/mac/mac.h>
#ifndef FRAGMENTATION_H_
@ -25,7 +25,7 @@
struct fragmentation {
int (* fragment)(struct net_buf *buf, void *ptr);
int (* reassemble)(struct net_mbuf *buf);
int (* reassemble)(struct net_buf *buf);
};
#endif /* FRAGMENTATION_H_ */

View file

@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <net/net_buf.h>
#include <net/buf.h>
#include <net/sicslowpan/null_compression.h>
#include <net/netstack.h>

View file

@ -20,7 +20,7 @@
#include <string.h>
#include <errno.h>
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include <net/net_core.h>
#include <net/sicslowpan/null_fragmentation.h>
@ -40,7 +40,7 @@ void uip_log(char *msg);
#endif
static void
packet_sent(struct net_mbuf *buf, void *ptr, int status, int transmissions)
packet_sent(struct net_buf *buf, void *ptr, int status, int transmissions)
{
const linkaddr_t *dest = packetbuf_addr(buf, PACKETBUF_ADDR_RECEIVER);
uip_ds6_link_neighbor_callback(dest, status, transmissions);
@ -49,10 +49,10 @@ packet_sent(struct net_mbuf *buf, void *ptr, int status, int transmissions)
static int fragment(struct net_buf *buf, void *ptr)
{
struct net_mbuf *mbuf;
struct net_buf *mbuf;
int ret;
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (!mbuf) {
return 0;
}
@ -62,8 +62,8 @@ static int fragment(struct net_buf *buf, void *ptr)
ret = packetbuf_copyfrom(mbuf, &uip_buf(buf)[UIP_LLH_LEN],
uip_len(buf));
PRINTF("%s: buffer len %d copied %d\n", __FUNCTION__, uip_len(buf), ret);
packetbuf_set_addr(mbuf, PACKETBUF_ADDR_RECEIVER, &buf->dest);
net_buf_put(buf);
packetbuf_set_addr(mbuf, PACKETBUF_ADDR_RECEIVER, &ip_buf_ll_dest(buf));
ip_buf_unref(buf);
return NETSTACK_LLSEC.send(mbuf, &packet_sent, true, ptr);
}
@ -83,11 +83,11 @@ static int send_upstream(struct net_buf *buf)
return 0;
}
static int reassemble(struct net_mbuf *mbuf)
static int reassemble(struct net_buf *mbuf)
{
struct net_buf *buf;
buf = net_buf_get_reserve_rx(0);
buf = ip_buf_get_reserve_rx(0);
if (!buf) {
return 0;
}
@ -97,18 +97,19 @@ static int reassemble(struct net_mbuf *mbuf)
memcpy(uip_buf(buf), packetbuf_dataptr(mbuf),
packetbuf_datalen(mbuf));
uip_len(buf) = packetbuf_datalen(mbuf);
net_buf_add(buf, uip_len(buf));
if (send_upstream(buf) < 0) {
net_buf_put(buf);
ip_buf_unref(buf);
} else {
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
}
return 1;
} else {
PRINTF("packet discarded, datalen %d MAX %d\n",
packetbuf_datalen(mbuf), UIP_BUFSIZE - UIP_LLH_LEN);
net_buf_put(buf);
ip_buf_unref(buf);
return 0;
}
}

View file

@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include <net/sicslowpan/sicslowpan_compression.h>
#include <net/netstack.h>
#include "net/packetbuf.h"
@ -301,7 +301,7 @@ uncompress_addr(uip_ipaddr_t *ipaddr, uint8_t const prefix[],
* dest
*/
static int
compress_hdr_iphc(struct net_mbuf *mbuf, struct net_buf *buf, linkaddr_t *link_destaddr)
compress_hdr_iphc(struct net_buf *mbuf, struct net_buf *buf, linkaddr_t *link_destaddr)
{
uint8_t tmp, iphc0, iphc1;
@ -575,7 +575,7 @@ compress_hdr_iphc(struct net_mbuf *mbuf, struct net_buf *buf, linkaddr_t *link_d
* fragment.
*/
static int
uncompress_hdr_iphc(struct net_mbuf *mbuf, struct net_buf *ibuf)
uncompress_hdr_iphc(struct net_buf *mbuf, struct net_buf *ibuf)
{
uint8_t tmp, iphc0, iphc1;
uint8_t buf[UIP_IPUDPH_LEN] = {}; /* Size of (IP + UDP) header*/
@ -667,11 +667,12 @@ uncompress_hdr_iphc(struct net_mbuf *mbuf, struct net_buf *ibuf)
/* if tmp == 0 we do not have a context and therefore no prefix */
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->srcipaddr,
tmp != 0 ? context->prefix : NULL, unc_ctxconf[tmp],
(uip_lladdr_t *)&ibuf->src);
(uip_lladdr_t *)&ip_buf_ll_src(ibuf));
} else {
/* no compression and link local */
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->srcipaddr, llprefix, unc_llconf[tmp],
(uip_lladdr_t *)&ibuf->src);
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->srcipaddr, llprefix,
unc_llconf[tmp],
(uip_lladdr_t *)&ip_buf_ll_src(ibuf));
}
/* Destination address */
@ -712,11 +713,12 @@ uncompress_hdr_iphc(struct net_mbuf *mbuf, struct net_buf *ibuf)
return 0;
}
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->destipaddr, context->prefix,
unc_ctxconf[tmp], (uip_lladdr_t *)&ibuf->dest);
unc_ctxconf[tmp], (uip_lladdr_t *)&ip_buf_ll_dest(ibuf));
} else {
/* not context based => link local M = 0, DAC = 0 - same as SAC */
uncompress_addr(&SICSLOWPAN_IP_BUF(buf)->destipaddr, llprefix,
unc_llconf[tmp], (uip_lladdr_t *)&ibuf->dest);
unc_llconf[tmp],
(uip_lladdr_t *)&ip_buf_ll_dest(ibuf));
}
}
uip_uncomp_hdr_len(mbuf) += UIP_IPH_LEN;
@ -828,6 +830,7 @@ compress_hdr_ipv6(struct net_buf *buf)
memmove(uip_buf(buf) + SICSLOWPAN_IPV6_HDR_LEN, uip_buf(buf), uip_len(buf));
*uip_buf(buf) = SICSLOWPAN_DISPATCH_IPV6;
uip_len(buf)++;
buf->len++;
return 1;
}
/** @} */
@ -837,6 +840,7 @@ static int
uncompress_hdr_ipv6(struct net_buf *buf)
{
uip_len(buf)--;
buf->len--;
memmove(uip_buf(buf), uip_buf(buf) + SICSLOWPAN_IPV6_HDR_LEN, uip_len(buf));
return 1;
}
@ -849,7 +853,7 @@ uncompress_hdr_ipv6(struct net_buf *buf)
static int compress(struct net_buf *buf)
{
uint8_t hdr_diff;
struct net_mbuf *mbuf;
struct net_buf *mbuf;
int ret;
if(uip_len(buf) >= COMPRESSION_THRESHOLD) {
@ -860,7 +864,7 @@ static int compress(struct net_buf *buf)
return compress_hdr_ipv6(buf);
}
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (!mbuf) {
return 0;
}
@ -874,12 +878,12 @@ static int compress(struct net_buf *buf)
/* Compress the headers */
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPHC
ret = compress_hdr_iphc(mbuf, buf, &buf->dest);
ret = compress_hdr_iphc(mbuf, buf, &ip_buf_ll_dest(buf));
#endif /* SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPHC */
/* if IPHC compression fails then send uncompressed ipv6 packet */
if (!ret) {
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
PRINTF("sending uncompressed IPv6 packet\n");
return compress_hdr_ipv6(buf);
return 0;
@ -892,20 +896,21 @@ static int compress(struct net_buf *buf)
memmove(uip_buf(buf) + uip_packetbuf_hdr_len(mbuf),
uip_buf(buf) + uip_uncomp_hdr_len(mbuf), uip_len(buf) - uip_uncomp_hdr_len(mbuf));
uip_len(buf) -= hdr_diff;
buf->len -= hdr_diff;
packetbuf_clear(mbuf);
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return 1;
}
static int uncompress(struct net_buf *buf)
{
struct net_mbuf *mbuf;
struct net_buf *mbuf;
if (*uip_buf(buf) == SICSLOWPAN_DISPATCH_IPV6) {
return uncompress_hdr_ipv6(buf);
}
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (!mbuf) {
return 0;
}
@ -937,13 +942,14 @@ static int uncompress(struct net_buf *buf)
uip_len(buf) - uip_packetbuf_hdr_len(mbuf));
memcpy(uip_buf(buf), uip_packetbuf_ptr(mbuf), uip_uncomp_hdr_len(mbuf));
uip_len(buf) += (uip_uncomp_hdr_len(mbuf) - uip_packetbuf_hdr_len(mbuf));
buf->len += (uip_uncomp_hdr_len(mbuf) - uip_packetbuf_hdr_len(mbuf));
#endif
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return 1;
fail:
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return 0;
}

View file

@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include <net_driver_15_4.h>
#include <net/sicslowpan/sicslowpan_fragmentation.h>
#include <net/netstack.h>
@ -183,7 +183,7 @@ clear_fragments(uint8_t frag_info_index)
}
/*---------------------------------------------------------------------------*/
static int
store_fragment(struct net_mbuf *mbuf, uint8_t index, uint8_t offset)
store_fragment(struct net_buf *mbuf, uint8_t index, uint8_t offset)
{
int i;
for(i = 0; i < SICSLOWPAN_FRAGMENT_BUFFERS; i++) {
@ -207,7 +207,7 @@ store_fragment(struct net_mbuf *mbuf, uint8_t index, uint8_t offset)
/*---------------------------------------------------------------------------*/
/* add a new fragment to the buffer */
static int8_t
add_fragment(struct net_mbuf *mbuf, uint16_t tag, uint16_t frag_size, uint8_t offset)
add_fragment(struct net_buf *mbuf, uint16_t tag, uint16_t frag_size, uint8_t offset)
{
int i;
int len;
@ -280,43 +280,49 @@ store:
/* Copy all the fragments that are associated with a specific context into uip */
static struct net_buf *copy_frags2uip(int context)
{
int i;
struct net_buf *buf = NULL;
int i, total_len = 0;
struct net_buf *buf;
buf = net_buf_get_reserve_rx(0);
buf = ip_buf_get_reserve_rx(0);
if(!buf) {
return NULL;
}
/* Copy from the fragment context info buffer first */
linkaddr_copy(&buf->dest, &frag_info[context].receiver);
linkaddr_copy(&buf->src, &frag_info[context].sender);
linkaddr_copy(&ip_buf_ll_dest(buf), &frag_info[context].receiver);
linkaddr_copy(&ip_buf_ll_src(buf), &frag_info[context].sender);
for(i = 0; i < SICSLOWPAN_FRAGMENT_BUFFERS; i++) {
/* And also copy all matching fragments */
if(frag_buf[i].len > 0 && frag_buf[i].index == context) {
memcpy(uip_buf(buf) + (uint16_t)(frag_buf[i].offset << 3),
(uint8_t *)frag_buf[i].data, frag_buf[i].len);
total_len += frag_buf[i].len;
}
}
net_buf_add(buf, total_len);
uip_len(buf) = total_len;
/* deallocate all the fragments for this context */
clear_fragments(context);
return buf;
}
static struct net_buf *copy_buf(struct net_mbuf *mbuf)
static struct net_buf *copy_buf(struct net_buf *mbuf)
{
struct net_buf *buf = NULL;
struct net_buf *buf;
buf = net_buf_get_reserve_rx(0);
buf = ip_buf_get_reserve_rx(0);
if(!buf) {
return NULL;
}
/* Copy from the fragment context info buffer first */
linkaddr_copy(&buf->dest, packetbuf_addr(mbuf, PACKETBUF_ADDR_RECEIVER));
linkaddr_copy(&buf->src, packetbuf_addr(mbuf, PACKETBUF_ADDR_SENDER));
linkaddr_copy(&ip_buf_ll_dest(buf),
packetbuf_addr(mbuf, PACKETBUF_ADDR_RECEIVER));
linkaddr_copy(&ip_buf_ll_src(buf),
packetbuf_addr(mbuf, PACKETBUF_ADDR_SENDER));
PRINTFI("%s: mbuf datalen %d dataptr %p buf %p\n", __FUNCTION__,
packetbuf_datalen(mbuf), packetbuf_dataptr(mbuf), uip_buf(buf));
@ -324,8 +330,9 @@ static struct net_buf *copy_buf(struct net_mbuf *mbuf)
packetbuf_datalen(mbuf) <= UIP_BUFSIZE - UIP_LLH_LEN) {
memcpy(uip_buf(buf), packetbuf_dataptr(mbuf), packetbuf_datalen(mbuf));
uip_len(buf) = packetbuf_datalen(mbuf);
net_buf_add(buf, uip_len(buf));
} else {
net_buf_put(buf);
ip_buf_unref(buf);
buf = NULL;
}
@ -333,7 +340,7 @@ static struct net_buf *copy_buf(struct net_mbuf *mbuf)
}
static void
packet_sent(struct net_mbuf *buf, void *ptr, int status, int transmissions)
packet_sent(struct net_buf *buf, void *ptr, int status, int transmissions)
{
const linkaddr_t *dest = packetbuf_addr(buf, PACKETBUF_ADDR_RECEIVER);
uip_ds6_link_neighbor_callback(dest, status, transmissions);
@ -347,7 +354,7 @@ packet_sent(struct net_mbuf *buf, void *ptr, int status, int transmissions)
* \param dest the link layer destination address of the packet
*/
static void
send_packet(struct net_mbuf *buf, linkaddr_t *dest, bool last_fragment, void *ptr)
send_packet(struct net_buf *buf, linkaddr_t *dest, bool last_fragment, void *ptr)
{
/* Set the link layer destination address for the packet as a
* packetbuf attribute. The MAC layer can access the destination
@ -383,7 +390,7 @@ static int fragment(struct net_buf *buf, void *ptr)
/* Number of bytes processed. */
uint16_t processed_ip_out_len;
struct net_mbuf *mbuf;
struct net_buf *mbuf;
bool last_fragment = false;
#define USE_FRAMER_HDRLEN 0
@ -400,7 +407,7 @@ static int fragment(struct net_buf *buf, void *ptr)
PRINTFO("max_payload: %d, framer_hdrlen: %d \n",max_payload, framer_hdrlen);
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (!mbuf) {
goto fail;
}
@ -414,8 +421,9 @@ static int fragment(struct net_buf *buf, void *ptr)
if((int)uip_len(buf) <= max_payload) {
/* The packet does not need to be fragmented, send buf */
packetbuf_copyfrom(mbuf, uip_buf(buf), uip_len(buf));
packetbuf_set_addr(mbuf, PACKETBUF_ADDR_RECEIVER, &buf->dest);
net_buf_put(buf);
packetbuf_set_addr(mbuf, PACKETBUF_ADDR_RECEIVER,
&ip_buf_ll_dest(buf));
ip_buf_unref(buf);
NETSTACK_LLSEC.send(mbuf, &packet_sent, true, ptr);
return 1;
}
@ -467,7 +475,7 @@ static int fragment(struct net_buf *buf, void *ptr)
PRINTFO("could not allocate queuebuf for first fragment, dropping packet\n");
goto fail;
}
send_packet(mbuf, &buf->dest, last_fragment, ptr);
send_packet(mbuf, &ip_buf_ll_dest(buf), last_fragment, ptr);
queuebuf_to_packetbuf(mbuf, q);
queuebuf_free(q);
q = NULL;
@ -513,7 +521,7 @@ static int fragment(struct net_buf *buf, void *ptr)
PRINTFO("could not allocate queuebuf, dropping fragment\n");
goto fail;
}
send_packet(mbuf, &buf->dest, last_fragment, ptr);
send_packet(mbuf, &ip_buf_ll_dest(buf), last_fragment, ptr);
queuebuf_to_packetbuf(mbuf, q);
queuebuf_free(q);
q = NULL;
@ -528,17 +536,17 @@ static int fragment(struct net_buf *buf, void *ptr)
}
}
net_buf_put(buf);
ip_buf_unref(buf);
return 1;
fail:
if (mbuf) {
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
}
return 0;
}
static int reassemble(struct net_mbuf *mbuf)
static int reassemble(struct net_buf *mbuf)
{
/* size of the IP packet (read from fragment) */
uint16_t frag_size = 0;
@ -690,12 +698,12 @@ static int reassemble(struct net_mbuf *mbuf)
out:
/* free MAC buffer */
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
return 1;
fail:
if(buf) {
net_buf_put(buf);
ip_buf_unref(buf);
}
return 0;
}

View file

@ -18,7 +18,7 @@
#include "contiki.h"
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include <simple/uart.h>
#include "net/packetbuf.h"
@ -112,9 +112,9 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off)
if (input_len && input_len == input_offset) {
if (input_len < NETWORK_TEST_MAX_PACKET_LEN) {
struct net_mbuf *mbuf;
struct net_buf *mbuf;
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (mbuf) {
packetbuf_copyfrom(mbuf, input, input_len);
packetbuf_set_datalen(mbuf, input_len);
@ -124,7 +124,7 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off)
if (net_driver_15_4_recv_from_hw(mbuf) < 0) {
PRINTF("dummy154radio: rdc input failed, packet discarded\n");
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
}
}
}
@ -185,22 +185,22 @@ prepare(const void *payload, unsigned short payload_len)
}
/*---------------------------------------------------------------------------*/
static int
transmit(struct net_mbuf *buf, unsigned short transmit_len)
transmit(struct net_buf *buf, unsigned short transmit_len)
{
return RADIO_TX_OK;
}
#ifndef CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART
static void route_buf(struct net_mbuf *buf)
static void route_buf(struct net_buf *buf)
{
int len;
struct net_mbuf *mbuf;
struct net_buf *mbuf;
len = packetbuf_copyto(buf, loopback);
/* Receiver buffer that is passed to 15.4 Rx fiber */
PRINTF("dummy154radio: got %d bytes\n", len);
mbuf = net_mbuf_get_reserve(0);
mbuf = l2_buf_get_reserve(0);
if (mbuf) {
packetbuf_copyfrom(mbuf, loopback, len);
packetbuf_set_datalen(mbuf, len);
@ -211,7 +211,7 @@ static void route_buf(struct net_mbuf *buf)
if (net_driver_15_4_recv_from_hw(mbuf) < 0) {
PRINTF("dummy154radio: rdc input failed, "
"packet discarded\n");
net_mbuf_put(mbuf);
l2_buf_unref(mbuf);
}
NET_BUF_CHECK_IF_NOT_IN_USE(mbuf);
@ -221,7 +221,7 @@ static void route_buf(struct net_mbuf *buf)
/*---------------------------------------------------------------------------*/
static int
send(struct net_mbuf *buf, const void *payload, unsigned short payload_len)
send(struct net_buf *buf, const void *payload, unsigned short payload_len)
{
#if defined CONFIG_NETWORKING_WITH_15_4_LOOPBACK_UART
static uint8_t output[NETWORK_TEST_MAX_PACKET_LEN];

View file

@ -87,21 +87,20 @@ static int prepare_and_send_buf(coap_context_t *ctx, session_t *session,
* by this function unless there was an error and buf was
* not actually sent.
*/
buf = net_buf_get_tx(ctx->net_ctx);
buf = ip_buf_get_tx(ctx->net_ctx);
if (!buf) {
len = -ENOBUFS;
goto out;
}
max_data_len = sizeof(buf->buf) - sizeof(struct uip_udp_hdr) -
sizeof(struct uip_ip_hdr);
max_data_len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN;
PRINTF("%s: reply to peer data %p len %d\n", __FUNCTION__, data, len);
if (len > max_data_len) {
PRINTF("%s: too much (%d bytes) data to send (max %d bytes)\n",
__FUNCTION__, len, max_data_len);
net_buf_put(buf);
ip_buf_unref(buf);
len = -EINVAL;
goto out;
}
@ -124,12 +123,12 @@ static int prepare_and_send_buf(coap_context_t *ctx, session_t *session,
uip_set_udp_conn(buf) = net_context_get_udp_connection(ctx->net_ctx);
memcpy(net_buf_add(buf, 0), data, len);
net_buf_add(buf, len);
net_buf_datalen(buf) = len;
memcpy(net_buf_add(buf, len), data, len);
ip_buf_appdatalen(buf) = len;
ip_buf_appdata(buf) = buf->data + ip_buf_reserve(buf);
if (net_reply(ctx->net_ctx, buf)) {
net_buf_put(buf);
ip_buf_unref(buf);
}
out:
return len;
@ -176,27 +175,23 @@ int coap_context_wait_data(coap_context_t *coap_ctx, int32_t ticks)
session.size = sizeof(session.addr);
session.ifindex = 1;
uip_datalen(buf) = buf->datalen;
uip_appdata(buf) = buf->data;
PRINTF("coap-context: got message from ");
PRINTF("coap-context: got dtls message from ");
PRINT6ADDR(&session.addr.ipaddr);
PRINTF(":%d %u bytes\n", uip_ntohs(session.addr.port), uip_datalen(buf));
PRINTF(":%d %u bytes\n", uip_ntohs(session.addr.port), uip_appdatalen(buf));
PRINTF("Received data buf %p buflen %d data %p datalen %d\n",
buf, uip_len(buf), net_buf_data(buf),
net_buf_datalen(buf));
PRINTF("Received appdata %p appdatalen %d\n",
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
coap_ctx->buf = buf;
ret = dtls_handle_message(coap_ctx->dtls_context, &session,
net_buf_data(buf), net_buf_datalen(buf));
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
/* We always release the buffer here as this buffer is never sent
* to network anyway.
*/
if (coap_ctx->buf) {
net_buf_put(coap_ctx->buf);
ip_buf_unref(coap_ctx->buf);
coap_ctx->buf = NULL;
}
@ -226,7 +221,7 @@ event(struct dtls_context_t *ctx, session_t *session,
} else if(level == DTLS_ALERT_LEVEL_FATAL && code < 256) {
/* Fatal alert */
if (coap_ctx && coap_ctx->buf) {
net_buf_put(coap_ctx->buf);
ip_buf_unref(coap_ctx->buf);
coap_ctx->buf = NULL;
}
coap_ctx->status = STATUS_ALERT;
@ -512,22 +507,21 @@ int coap_context_reply(coap_context_t *ctx, struct net_buf *buf)
{
int max_data_len, ret;
max_data_len = sizeof(buf->buf) - sizeof(struct uip_udp_hdr) -
sizeof(struct uip_ip_hdr);
max_data_len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN;
PRINTF("%s: reply to peer data %p len %d\n", __FUNCTION__,
net_buf_data(buf), net_buf_datalen(buf));
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
if (net_buf_datalen(buf) > max_data_len) {
if (ip_buf_appdatalen(buf) > max_data_len) {
PRINTF("%s: too much (%d bytes) data to send (max %d bytes)\n",
__FUNCTION__, net_buf_datalen(buf), max_data_len);
net_buf_put(buf);
__FUNCTION__, ip_buf_appdatalen(buf), max_data_len);
ip_buf_unref(buf);
ret = -EINVAL;
goto out;
}
if (net_reply(ctx->net_ctx, buf)) {
net_buf_put(buf);
ip_buf_unref(buf);
}
out:
return ret;
@ -539,16 +533,13 @@ int coap_context_wait_data(coap_context_t *coap_ctx, int32_t ticks)
buf = net_receive(coap_ctx->net_ctx, ticks);
if (buf) {
uip_datalen(buf) = buf->datalen;
uip_appdata(buf) = buf->data;
PRINTF("coap-context: got message from ");
PRINT6ADDR(&UIP_IP_BUF(buf)->srcipaddr);
PRINTF(":%d %u bytes\n", uip_ntohs(UIP_UDP_BUF(buf)->srcport), uip_datalen(buf));
PRINTF(":%d %u bytes\n", uip_ntohs(UIP_UDP_BUF(buf)->srcport),
uip_appdatalen(buf));
PRINTF("Received data buf %p buflen %d data %p datalen %d\n",
buf, uip_len(buf), net_buf_data(buf),
net_buf_datalen(buf));
PRINTF("Received data appdata %p appdatalen %d\n",
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
coap_ctx->buf = buf;
@ -564,24 +555,24 @@ static int coap_context_send(coap_context_t *ctx, struct net_buf *buf)
{
int max_data_len, ret;
max_data_len = sizeof(buf->buf) - sizeof(struct uip_udp_hdr) -
sizeof(struct uip_ip_hdr);
max_data_len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN;
PRINTF("%s: send to peer data %p len %d\n", __FUNCTION__,
net_buf_data(buf), net_buf_datalen(buf));
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
if (net_buf_datalen(buf) > max_data_len) {
if (ip_buf_appdatalen(buf) > max_data_len) {
PRINTF("%s: too much (%d bytes) data to send (max %d bytes)\n",
__FUNCTION__, net_buf_datalen(buf), max_data_len);
net_buf_put(buf);
__FUNCTION__, ip_buf_appdatalen(buf), max_data_len);
ip_buf_unref(buf);
ret = -EINVAL;
goto out;
}
if ((ret = net_send(buf)) < 0) {
ret = net_send(buf);
if (ret < 0) {
PRINT("%s: sending %d bytes failed\n", __FUNCTION__,
net_buf_datalen(buf));
net_buf_put(buf);
ip_buf_appdatalen(buf));
ip_buf_unref(buf);
}
out:
@ -600,7 +591,7 @@ coap_context_send_message(coap_context_t *coap_ctx,
return 0;
}
net_buf_datalen(coap_ctx->buf) = length;
ip_buf_appdatalen(coap_ctx->buf) = length;
if (!uip_udp_conn(coap_ctx->buf)) {
/* Normal send, not a reply */
@ -616,7 +607,7 @@ coap_context_send_message(coap_context_t *coap_ctx,
* set the send buffer length correctly.
*/
uip_len(coap_ctx->buf) = 0;
net_buf_data(coap_ctx->buf) = (uint8_t *)data;
ip_buf_appdata(coap_ctx->buf) = (uint8_t *)data;
ret = coap_context_reply(coap_ctx, coap_ctx->buf);
}

View file

@ -38,7 +38,7 @@
#ifndef COAP_CONTEXT_H_
#define COAP_CONTEXT_H_
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include <net/net_socket.h>
#include "contiki-conf.h"

View file

@ -64,18 +64,19 @@ coap_engine_receive(coap_context_t *coap_ctx)
coap_packet_t response[1];
coap_transaction_t *transaction = NULL;
PRINTF("%s(): received uip_datalen %u\n", __FUNCTION__,
(uint16_t)uip_datalen(coap_ctx->buf));
PRINTF("%s(): received data len %u\n", __FUNCTION__,
(uint16_t)uip_appdatalen(coap_ctx->buf));
if(uip_newdata(coap_ctx->buf)) {
PRINTF("receiving UDP datagram from: ");
PRINT6ADDR(&UIP_IP_BUF(coap_ctx->buf)->srcipaddr);
PRINTF(":%u\n Length: %u\n", uip_ntohs(UIP_UDP_BUF(coap_ctx->buf)->srcport),
uip_datalen(coap_ctx->buf));
PRINTF(":%u\n Length: %u (payload %u)\n",
uip_ntohs(UIP_UDP_BUF(coap_ctx->buf)->srcport),
uip_appdatalen(coap_ctx->buf));
erbium_status_code =
coap_parse_message(message, uip_appdata(coap_ctx->buf), uip_datalen(coap_ctx->buf));
coap_parse_message(message, uip_appdata(coap_ctx->buf), uip_appdatalen(coap_ctx->buf));
coap_set_context(message, coap_ctx);
if(erbium_status_code == NO_ERROR) {

View file

@ -316,17 +316,17 @@ coap_obs_request_registration(coap_context_t *coap_ctx,
uint8_t *ptr;
if (coap_ctx->buf) {
net_buf_put(coap_ctx->buf);
ip_buf_unref(coap_ctx->buf);
}
coap_ctx->buf = net_buf_get_tx(coap_ctx->net_ctx);
coap_ctx->buf = ip_buf_get_tx(coap_ctx->net_ctx);
if (!coap_ctx->buf) {
coap_clear_transaction(t);
return NULL;
}
ptr = net_buf_add(coap_ctx->buf, 0);
net_buf_data(coap_ctx->buf) = ptr;
ip_buf_appdata(coap_ctx->buf) = ptr;
obs = coap_obs_add_observee(coap_ctx, addr, port,
(uint8_t *)token, token_len, uri,
@ -336,11 +336,12 @@ coap_obs_request_registration(coap_context_t *coap_ctx,
t->callback_data = obs;
t->packet_len = coap_serialize_message(request, t->packet);
uip_len(coap_ctx->buf) = t->packet_len;
net_buf_add(coap_ctx->buf, uip_len(coap_ctx->buf));
coap_send_transaction(t);
} else {
PRINTF("Could not allocate obs_subject resource buffer");
coap_clear_transaction(t);
net_buf_put(coap_ctx->buf);
ip_buf_unref(coap_ctx->buf);
coap_ctx->buf = NULL;
}
} else {

View file

@ -82,8 +82,10 @@ coap_new_transaction(uint16_t mid, coap_context_t *coap_ctx,
void
coap_send_transaction(coap_transaction_t *t)
{
PRINTF("Sending transaction %u buf %p data %p -> %p len %d\n", t->mid,
t->coap_ctx->buf, t->packet, net_buf_data(t->coap_ctx->buf),
PRINTF("Sending transaction %u appdata %p len %d (%d)\n",
t->mid,
ip_buf_appdata(t->coap_ctx->buf),
ip_buf_appdatalen(t->coap_ctx->buf),
t->packet_len);
if (!t->coap_ctx || !t->coap_ctx->buf) {
@ -92,14 +94,8 @@ coap_send_transaction(coap_transaction_t *t)
return;
}
/* Copy the data from the transaction internal buffer to net_buf which
* is used when actually sending the data. The payload will contain
* a NULL byte but that is not sent.
*/
memcpy(net_buf_data(t->coap_ctx->buf), t->packet, t->packet_len + 1);
coap_send_message(t->coap_ctx, &t->addr, t->port,
net_buf_data(t->coap_ctx->buf),
t->packet_len);
t->packet, t->packet_len);
if(COAP_TYPE_CON ==
((COAP_HEADER_TYPE_MASK & t->packet[0]) >> COAP_HEADER_TYPE_POSITION)) {
@ -174,20 +170,27 @@ coap_get_transaction_by_mid(uint16_t mid)
static inline struct net_buf *get_retransmit_buf(coap_transaction_t *t)
{
coap_context_t *coap_ctx = t->coap_ctx;
uint8_t *ptr;
if (coap_ctx->buf) {
return coap_ctx->buf;
}
coap_ctx->buf = net_buf_get_tx(coap_ctx->net_ctx);
coap_ctx->buf = ip_buf_get_tx(coap_ctx->net_ctx);
if (!coap_ctx->buf) {
return NULL;
}
ptr = net_buf_add(coap_ctx->buf, 0);
net_buf_data(coap_ctx->buf) = ptr;
uip_len(coap_ctx->buf) = t->packet_len;
/* We set the major buf params correctly. The application data pointer
* should point to start of the coap packet data.
* The tail of the packet points now to byte after coap packet.
*/
ip_buf_appdata(coap_ctx->buf) = net_buf_add(coap_ctx->buf, t->packet_len);
ip_buf_appdatalen(coap_ctx->buf) = t->packet_len;
/* The total length of the packet is the coap packet + all the UDP/IP
* headers.
*/
uip_len(coap_ctx->buf) = ip_buf_len(coap_ctx->buf);
return coap_ctx->buf;
}

View file

@ -39,7 +39,7 @@
#ifndef ER_COAP_H_
#define ER_COAP_H_
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include <stddef.h> /* for size_t */
#include "contiki-net.h"

359
net/ip/ip_buf.c Normal file
View file

@ -0,0 +1,359 @@
/** @file
@brief Network buffers for IP stack
IP data is passed between application and IP stack via
a net_buf struct.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <nanokernel.h>
#include <toolchain.h>
#include <string.h>
#include <stdint.h>
#include <net/net_core.h>
#include <net/buf.h>
#include <net/ip_buf.h>
#include <net/net_ip.h>
#include "ip/uip.h"
extern struct net_tuple *net_context_get_tuple(struct net_context *context);
/* Available (free) buffers queue */
#ifndef IP_BUF_RX_SIZE
#if CONFIG_IP_BUF_RX_SIZE > 0
#define IP_BUF_RX_SIZE CONFIG_IP_BUF_RX_SIZE
#else
#define IP_BUF_RX_SIZE 1
#endif
#endif
#ifndef IP_BUF_TX_SIZE
#if CONFIG_IP_BUF_TX_SIZE > 0
#define IP_BUF_TX_SIZE CONFIG_IP_BUF_TX_SIZE
#else
#define IP_BUF_TX_SIZE 1
#endif
#endif
#ifdef DEBUG_IP_BUFS
static int num_free_rx_bufs = IP_BUF_RX_SIZE;
static int num_free_tx_bufs = IP_BUF_TX_SIZE;
static inline void dec_free_rx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_rx_bufs--;
if (num_free_rx_bufs < 0) {
NET_DBG("*** ERROR *** Invalid RX buffer count.\n");
num_free_rx_bufs = 0;
}
}
static inline void inc_free_rx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_rx_bufs++;
}
static inline void dec_free_tx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_tx_bufs--;
if (num_free_tx_bufs < 0) {
NET_DBG("*** ERROR *** Invalid TX buffer count.\n");
num_free_tx_bufs = 0;
}
}
static inline void inc_free_tx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_tx_bufs++;
}
static inline int get_frees(enum ip_buf_type type)
{
switch (type) {
case IP_BUF_RX:
return num_free_rx_bufs;
case IP_BUF_TX:
return num_free_tx_bufs;
}
return 0xffffffff;
}
#define inc_free_rx_bufs_func inc_free_rx_bufs
#define inc_free_tx_bufs_func inc_free_tx_bufs
#else
#define dec_free_rx_bufs(...)
#define inc_free_rx_bufs(...)
#define dec_free_tx_bufs(...)
#define inc_free_tx_bufs(...)
#define inc_free_rx_bufs_func NULL
#define inc_free_tx_bufs_func NULL
#endif
static struct nano_fifo free_rx_bufs;
static struct nano_fifo free_tx_bufs;
static inline void free_rx_bufs_func(struct net_buf *buf)
{
inc_free_rx_bufs_func(buf);
nano_fifo_put(buf->free, buf);
}
static inline void free_tx_bufs_func(struct net_buf *buf)
{
inc_free_tx_bufs_func(buf);
nano_fifo_put(buf->free, buf);
}
static NET_BUF_POOL(rx_buffers, IP_BUF_RX_SIZE, IP_BUF_MAX_DATA, \
&free_rx_bufs, free_rx_bufs_func, \
sizeof(struct ip_buf));
static NET_BUF_POOL(tx_buffers, IP_BUF_TX_SIZE, IP_BUF_MAX_DATA, \
&free_tx_bufs, free_tx_bufs_func, \
sizeof(struct ip_buf));
static inline const char *type2str(enum ip_buf_type type)
{
switch (type) {
case IP_BUF_RX:
return "RX";
case IP_BUF_TX:
return "TX";
}
return NULL;
}
#ifdef DEBUG_IP_BUFS
static struct net_buf *ip_buf_get_reserve_debug(enum ip_buf_type type,
uint16_t reserve_head,
const char *caller,
int line)
#else
static struct net_buf *ip_buf_get_reserve(enum ip_buf_type type,
uint16_t reserve_head)
#endif
{
struct net_buf *buf = NULL;
/* Note that we do not reserve any space in front of the
* buffer so buf->data points to first byte of the IP header.
* This is done like this so that IP stack works the same
* way as BT and 802.15.4 stacks.
*
* The reserve_head variable in the function will tell
* the size of the IP + other headers if there are any.
* That variable is only used to calculate the pointer
* where the application data starts.
*/
switch (type) {
case IP_BUF_RX:
buf = net_buf_get(&free_rx_bufs, 0);
dec_free_rx_bufs(buf);
break;
case IP_BUF_TX:
buf = net_buf_get(&free_tx_bufs, 0);
dec_free_tx_bufs(buf);
break;
}
if (!buf) {
#ifdef DEBUG_IP_BUFS
NET_ERR("Failed to get free %s buffer (%s():%d)\n",
type2str(type), caller, line);
#else
NET_ERR("Failed to get free %s buffer\n", type2str(type));
#endif
return NULL;
}
ip_buf_type(buf) = type;
ip_buf_appdata(buf) = buf->data + reserve_head;
ip_buf_appdatalen(buf) = 0;
ip_buf_reserve(buf) = reserve_head;
net_buf_add(buf, reserve_head);
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_IP_BUFS
NET_DBG("%s [%d] buf %p reserve %u ref %d (%s():%d)\n",
type2str(type), get_frees(type),
buf, reserve_head, buf->ref, caller, line);
#else
NET_DBG("%s buf %p reserve %u ref %d\n", type2str(type), buf,
reserve_head, buf->ref);
#endif
return buf;
}
#ifdef DEBUG_IP_BUFS
struct net_buf *ip_buf_get_reserve_rx_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_buf *ip_buf_get_reserve_rx(uint16_t reserve_head)
#endif
{
#ifdef DEBUG_IP_BUFS
return ip_buf_get_reserve_debug(IP_BUF_RX, reserve_head,
caller, line);
#else
return ip_buf_get_reserve(IP_BUF_RX, reserve_head);
#endif
}
#ifdef DEBUG_IP_BUFS
struct net_buf *ip_buf_get_reserve_tx_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_buf *ip_buf_get_reserve_tx(uint16_t reserve_head)
#endif
{
#ifdef DEBUG_IP_BUFS
return ip_buf_get_reserve_debug(IP_BUF_TX, reserve_head,
caller, line);
#else
return ip_buf_get_reserve(IP_BUF_TX, reserve_head);
#endif
}
#ifdef DEBUG_IP_BUFS
static struct net_buf *ip_buf_get_debug(enum ip_buf_type type,
struct net_context *context,
const char *caller, int line)
#else
static struct net_buf *ip_buf_get(enum ip_buf_type type,
struct net_context *context)
#endif
{
struct net_buf *buf;
struct net_tuple *tuple;
uint16_t reserve = 0;
tuple = net_context_get_tuple(context);
if (!tuple) {
return NULL;
}
switch (tuple->ip_proto) {
case IPPROTO_UDP:
reserve = UIP_IPUDPH_LEN;
break;
case IPPROTO_TCP:
reserve = UIP_IPTCPH_LEN;
break;
case IPPROTO_ICMPV6:
reserve = UIP_IPICMPH_LEN;
break;
}
#ifdef DEBUG_IP_BUFS
buf = ip_buf_get_reserve_debug(type, reserve, caller, line);
#else
buf = ip_buf_get_reserve(type, reserve);
#endif
if (!buf) {
return buf;
}
ip_buf_context(buf) = context;
return buf;
}
#ifdef DEBUG_IP_BUFS
struct net_buf *ip_buf_get_rx_debug(struct net_context *context,
const char *caller, int line)
#else
struct net_buf *ip_buf_get_rx(struct net_context *context)
#endif
{
#ifdef DEBUG_IP_BUFS
return ip_buf_get_debug(IP_BUF_RX, context, caller, line);
#else
return ip_buf_get(IP_BUF_RX, context);
#endif
}
#ifdef DEBUG_IP_BUFS
struct net_buf *ip_buf_get_tx_debug(struct net_context *context,
const char *caller, int line)
#else
struct net_buf *ip_buf_get_tx(struct net_context *context)
#endif
{
#ifdef DEBUG_IP_BUFS
return ip_buf_get_debug(IP_BUF_TX, context, caller, line);
#else
return ip_buf_get(IP_BUF_TX, context);
#endif
}
#ifdef DEBUG_IP_BUFS
void ip_buf_unref_debug(struct net_buf *buf, const char *caller, int line)
#else
void ip_buf_unref(struct net_buf *buf)
#endif
{
if (!buf) {
#ifdef DEBUG_IP_BUFS
NET_DBG("*** ERROR *** buf %p (%s():%d)\n", buf, caller, line);
#else
NET_DBG("*** ERROR *** buf %p\n", buf);
#endif
return;
}
#ifdef DEBUG_IP_BUFS
NET_DBG("%s [%d] buf %p ref %d (%s():%d)\n",
type2str(ip_buf_type(buf)), get_frees(ip_buf_type(buf)) + 1,
buf, buf->ref - 1, caller, line);
#else
NET_DBG("%s buf %p ref %d\n",
type2str(ip_buf_type(buf)), buf, buf->ref - 1);
#endif
net_buf_unref(buf);
}
void ip_buf_init(void)
{
NET_DBG("Allocating %d RX and %d TX buffers for IP stack\n",
IP_BUF_RX_SIZE, IP_BUF_TX_SIZE);
net_buf_pool_init(rx_buffers);
net_buf_pool_init(tx_buffers);
}

161
net/ip/l2_buf.c Normal file
View file

@ -0,0 +1,161 @@
/** @file
@brief Network buffers for IP stack
IP data is passed between application and IP stack via
a net_buf struct.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <zephyr.h>
#include <toolchain.h>
#include <string.h>
#include <stdint.h>
#include <net/net_core.h>
#include <net/buf.h>
#include <net/l2_buf.h>
#include <net/net_ip.h>
#include "ip/uip.h"
/* Available (free) layer 2 (MAC/L2) buffers queue */
#ifndef NET_NUM_L2_BUFS
/* Default value is 13 (receiving side) which means that max. UDP data
* (1232 bytes) can be received in one go. In sending side we need 1
* mbuf + some extras.
*/
#define NET_NUM_L2_BUFS 16
#endif
#ifdef DEBUG_L2_BUFS
static int num_free_l2_bufs = NET_NUM_L2_BUFS;
static inline void dec_free_l2_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_l2_bufs--;
if (num_free_l2_bufs < 0) {
NET_DBG("*** ERROR *** Invalid L2 buffer count.\n");
num_free_l2_bufs = 0;
}
}
static inline void inc_free_l2_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_l2_bufs++;
}
static inline int get_free_l2_bufs(void)
{
return num_free_l2_bufs;
}
#define inc_free_l2_bufs_func inc_free_l2_bufs
#else
#define dec_free_l2_bufs(...)
#define inc_free_l2_bufs(...)
#define get_free_l2_bufs(...)
#define inc_free_l2_bufs_func NULL
#endif
static struct nano_fifo free_l2_bufs;
static inline void free_l2_bufs_func(struct net_buf *buf)
{
inc_free_l2_bufs_func(buf);
nano_fifo_put(buf->free, buf);
}
static NET_BUF_POOL(l2_buffers, NET_NUM_L2_BUFS, NET_L2_BUF_MAX_SIZE, \
&free_l2_bufs, free_l2_bufs_func, \
sizeof(struct l2_buf));
#ifdef DEBUG_L2_BUFS
struct net_buf *l2_buf_get_reserve_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_buf *l2_buf_get_reserve(uint16_t reserve_head)
#endif
{
struct net_buf *buf;
buf = net_buf_get(&free_l2_bufs, reserve_head);
if (!buf) {
#ifdef DEBUG_L2_BUFS
NET_ERR("Failed to get free L2 buffer (%s():%d)\n",
caller, line);
#else
NET_ERR("Failed to get free L2 buffer\n");
#endif
return NULL;
}
dec_free_l2_bufs(buf);
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_L2_BUFS
NET_DBG("[%d] buf %p reserve %u ref %d (%s():%d)\n",
get_free_l2_bufs(), buf, reserve_head, buf->ref,
caller, line);
#else
NET_DBG("buf %p reserve %u ref %d\n", buf, reserve_head, buf->ref);
#endif
return buf;
}
#ifdef DEBUG_L2_BUFS
void l2_buf_unref_debug(struct net_buf *buf, const char *caller, int line)
#else
void l2_buf_unref(struct net_buf *buf)
#endif
{
if (!buf) {
#ifdef DEBUG_L2_BUFS
NET_DBG("*** ERROR *** buf %p (%s():%d)\n", buf, caller, line);
#else
NET_DBG("*** ERROR *** buf %p\n", buf);
#endif
return;
}
#ifdef DEBUG_L2_BUFS
NET_DBG("[%d] buf %p ref %d (%s():%d)\n",
get_free_l2_bufs() + 1, buf, buf->ref, caller, line);
#else
NET_DBG("buf %p ref %d\n", buf, buf->ref);
#endif
net_buf_unref(buf);
}
void l2_buf_init(void)
{
NET_DBG("Allocating %d L2 buffers\n", NET_NUM_L2_BUFS);
net_buf_pool_init(l2_buffers);
}

View file

@ -1,484 +0,0 @@
/** @file
@brief Network buffers
Network data is passed between application and IP stack via
a net_buf struct.
*/
/*
* Copyright (c) 2015 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <nanokernel.h>
#include <toolchain.h>
#include <string.h>
#include <stdint.h>
#include <net/net_core.h>
#include <net/net_buf.h>
#include <net/net_ip.h>
#include "ip/uip.h"
extern struct net_tuple *net_context_get_tuple(struct net_context *context);
/* Available (free) buffers queue */
#ifndef NET_BUF_RX_SIZE
#if CONFIG_NET_BUF_RX_SIZE > 0
#define NET_BUF_RX_SIZE CONFIG_NET_BUF_RX_SIZE
#else
#define NET_BUF_RX_SIZE 1
#endif
#endif
#ifndef NET_BUF_TX_SIZE
#if CONFIG_NET_BUF_TX_SIZE > 0
#define NET_BUF_TX_SIZE CONFIG_NET_BUF_TX_SIZE
#else
#define NET_BUF_TX_SIZE 1
#endif
#endif
static struct net_buf rx_buffers[NET_BUF_RX_SIZE];
static struct net_buf tx_buffers[NET_BUF_TX_SIZE];
static struct nano_fifo free_rx_bufs;
static struct nano_fifo free_tx_bufs;
/* Available (free) MAC buffers queue */
#ifndef NET_NUM_MAC_BUFS
/* Default value is 13 (receiving side) which means that max. UDP data
* (1232 bytes) can be received in one go. In sending side we need 1
* mbuf + some extras.
*/
#define NET_NUM_MAC_BUFS 16
#endif
static struct net_mbuf mac_buffers[NET_NUM_MAC_BUFS];
static struct nano_fifo free_mbufs;
static inline const char *type2str(enum net_buf_type type)
{
switch (type) {
case NET_BUF_RX:
return "RX";
case NET_BUF_TX:
return "TX";
}
return NULL;
}
#ifdef DEBUG_NET_BUFS
static int num_free_rx_bufs = NET_BUF_RX_SIZE;
static int num_free_tx_bufs = NET_BUF_TX_SIZE;
static int num_free_mbufs = NET_NUM_MAC_BUFS;
static inline void dec_free_rx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_rx_bufs--;
if (num_free_rx_bufs < 0) {
NET_DBG("*** ERROR *** Invalid RX buffer count.\n");
num_free_rx_bufs = 0;
}
}
static inline void inc_free_rx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_rx_bufs++;
}
static inline void dec_free_tx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_tx_bufs--;
if (num_free_tx_bufs < 0) {
NET_DBG("*** ERROR *** Invalid TX buffer count.\n");
num_free_tx_bufs = 0;
}
}
static inline void inc_free_tx_bufs(struct net_buf *buf)
{
if (!buf) {
return;
}
num_free_tx_bufs++;
}
static inline int get_frees(enum net_buf_type type)
{
switch (type) {
case NET_BUF_RX:
return num_free_rx_bufs;
case NET_BUF_TX:
return num_free_tx_bufs;
}
return 0xffffffff;
}
static inline void dec_free_mbufs(struct net_mbuf *buf)
{
if (!buf) {
return;
}
num_free_mbufs--;
if (num_free_mbufs < 0) {
NET_DBG("*** ERROR *** Invalid L2 buffer count.\n");
num_free_mbufs = 0;
}
}
static inline void inc_free_mbufs(struct net_mbuf *buf)
{
if (!buf) {
return;
}
num_free_mbufs++;
}
static inline int get_free_mbufs(void)
{
return num_free_mbufs;
}
#else
#define dec_free_rx_bufs(...)
#define inc_free_rx_bufs(...)
#define dec_free_tx_bufs(...)
#define inc_free_tx_bufs(...)
#define dec_free_mbufs(...)
#define inc_free_mbufs(...)
#define get_free_mbufs(...)
#endif
#ifdef DEBUG_NET_BUFS
static struct net_buf *net_buf_get_reserve_debug(enum net_buf_type type,
uint16_t reserve_head,
const char *caller,
int line)
#else
static struct net_buf *net_buf_get_reserve(enum net_buf_type type,
uint16_t reserve_head)
#endif
{
struct net_buf *buf = NULL;
switch (type) {
case NET_BUF_RX:
buf = nano_fifo_get(&free_rx_bufs);
dec_free_rx_bufs(buf);
break;
case NET_BUF_TX:
buf = nano_fifo_get(&free_tx_bufs);
dec_free_tx_bufs(buf);
break;
}
if (!buf) {
#ifdef DEBUG_NET_BUFS
NET_ERR("Failed to get free %s buffer (%s():%d)\n",
type2str(type), caller, line);
#else
NET_ERR("Failed to get free %s buffer\n", type2str(type));
#endif
return NULL;
}
buf->data = buf->buf + reserve_head;
buf->datalen = 0;
buf->type = type;
NET_BUF_CHECK_IF_IN_USE(buf);
#ifdef DEBUG_NET_BUFS
NET_DBG("%s [%d] buf %p reserve %u inuse %d (%s():%d)\n",
type2str(type), get_frees(type),
buf, reserve_head, buf->in_use, caller, line);
#else
NET_DBG("%s buf %p reserve %u inuse %d\n", type2str(type), buf,
reserve_head, buf->in_use);
#endif
buf->in_use = true;
return buf;
}
#ifdef DEBUG_NET_BUFS
struct net_buf *net_buf_get_reserve_rx_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_buf *net_buf_get_reserve_rx(uint16_t reserve_head)
#endif
{
#ifdef DEBUG_NET_BUFS
return net_buf_get_reserve_debug(NET_BUF_RX, reserve_head,
caller, line);
#else
return net_buf_get_reserve(NET_BUF_RX, reserve_head);
#endif
}
#ifdef DEBUG_NET_BUFS
struct net_buf *net_buf_get_reserve_tx_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_buf *net_buf_get_reserve_tx(uint16_t reserve_head)
#endif
{
#ifdef DEBUG_NET_BUFS
return net_buf_get_reserve_debug(NET_BUF_TX, reserve_head,
caller, line);
#else
return net_buf_get_reserve(NET_BUF_TX, reserve_head);
#endif
}
#ifdef DEBUG_NET_BUFS
static struct net_buf *net_buf_get_debug(enum net_buf_type type,
struct net_context *context,
const char *caller, int line)
#else
static struct net_buf *net_buf_get(enum net_buf_type type,
struct net_context *context)
#endif
{
struct net_buf *buf;
struct net_tuple *tuple;
uint16_t reserve = 0;
tuple = net_context_get_tuple(context);
if (!tuple) {
return NULL;
}
switch (tuple->ip_proto) {
case IPPROTO_UDP:
reserve = UIP_IPUDPH_LEN;
break;
case IPPROTO_TCP:
reserve = UIP_IPTCPH_LEN;
break;
case IPPROTO_ICMPV6:
reserve = UIP_IPICMPH_LEN;
break;
}
#ifdef DEBUG_NET_BUFS
buf = net_buf_get_reserve_debug(type, reserve, caller, line);
#else
buf = net_buf_get_reserve(type, reserve);
#endif
if (!buf) {
return buf;
}
buf->context = context;
return buf;
}
#ifdef DEBUG_NET_BUFS
struct net_buf *net_buf_get_rx_debug(struct net_context *context,
const char *caller, int line)
#else
struct net_buf *net_buf_get_rx(struct net_context *context)
#endif
{
#ifdef DEBUG_NET_BUFS
return net_buf_get_debug(NET_BUF_RX, context, caller, line);
#else
return net_buf_get(NET_BUF_RX, context);
#endif
}
#ifdef DEBUG_NET_BUFS
struct net_buf *net_buf_get_tx_debug(struct net_context *context,
const char *caller, int line)
#else
struct net_buf *net_buf_get_tx(struct net_context *context)
#endif
{
#ifdef DEBUG_NET_BUFS
return net_buf_get_debug(NET_BUF_TX, context, caller, line);
#else
return net_buf_get(NET_BUF_TX, context);
#endif
}
#ifdef DEBUG_NET_BUFS
void net_buf_put_debug(struct net_buf *buf, const char *caller, int line)
#else
void net_buf_put(struct net_buf *buf)
#endif
{
if (!buf) {
#ifdef DEBUG_NET_BUFS
NET_DBG("*** ERROR *** buf %p (%s():%d)\n", buf, caller, line);
#else
NET_DBG("*** ERROR *** buf %p\n", buf);
#endif
return;
}
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_NET_BUFS
NET_DBG("%s [%d] buf %p inuse %d (%s():%d)\n", type2str(buf->type),
get_frees(buf->type) + 1, buf, buf->in_use, caller, line);
#else
NET_DBG("%s buf %p inuse %d\n", type2str(buf->type), buf, buf->in_use);
#endif
buf->in_use = false;
switch (buf->type) {
case NET_BUF_RX:
nano_fifo_put(&free_rx_bufs, buf);
inc_free_rx_bufs(buf);
break;
case NET_BUF_TX:
nano_fifo_put(&free_tx_bufs, buf);
inc_free_tx_bufs(buf);
break;
}
}
uint8_t *net_buf_add(struct net_buf *buf, uint16_t len)
{
uint8_t *tail = buf->data + buf->len;
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
buf->len += len;
return tail;
}
uint8_t *net_buf_push(struct net_buf *buf, uint16_t len)
{
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
buf->data -= len;
buf->len += len;
return buf->data;
}
uint8_t *net_buf_pull(struct net_buf *buf, uint16_t len)
{
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
buf->len -= len;
return buf->data += len;
}
#ifdef DEBUG_NET_BUFS
struct net_mbuf *net_mbuf_get_reserve_debug(uint16_t reserve_head, const char *caller, int line)
#else
struct net_mbuf *net_mbuf_get_reserve(uint16_t reserve_head)
#endif
{
struct net_mbuf *buf;
buf = nano_fifo_get(&free_mbufs);
if (!buf) {
#ifdef DEBUG_NET_BUFS
NET_ERR("Failed to get free mac buffer (%s():%d)\n", caller, line);
#else
NET_ERR("Failed to get free mac buffer\n");
#endif
return NULL;
}
dec_free_mbufs(buf);
NET_BUF_CHECK_IF_IN_USE(buf);
#ifdef DEBUG_NET_BUFS
NET_DBG("[%d] buf %p reserve %u inuse %d (%s():%d)\n",
get_free_mbufs(), buf, reserve_head, buf->in_use,
caller, line);
#else
NET_DBG("buf %p reserve %u inuse %d\n", buf, reserve_head, buf->in_use);
#endif
buf->in_use = true;
return buf;
}
#ifdef DEBUG_NET_BUFS
void net_mbuf_put_debug(struct net_mbuf *buf, const char *caller, int line)
#else
void net_mbuf_put(struct net_mbuf *buf)
#endif
{
if (!buf) {
#ifdef DEBUG_NET_BUFS
NET_DBG("*** ERROR *** buf %p (%s():%d)\n", buf, caller, line);
#else
NET_DBG("*** ERROR *** buf %p\n", buf);
#endif
return;
}
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_NET_BUFS
NET_DBG("[%d] buf %p inuse %d (%s():%d)\n",
get_free_mbufs() + 1, buf, buf->in_use, caller, line);
#else
NET_DBG("buf %p inuse %d\n", buf, buf->in_use);
#endif
buf->in_use = false;
inc_free_mbufs(buf);
nano_fifo_put(&free_mbufs, buf);
}
static void net_mbuf_init(void)
{
nano_fifo_init(&free_mbufs);
for (int i = 0; i < NET_NUM_MAC_BUFS; i++) {
nano_fifo_put(&free_mbufs, &mac_buffers[i]);
}
}
void net_buf_init(void)
{
int i;
NET_DBG("Allocating %d RX and %d TX buffers\n",
NET_BUF_RX_SIZE, NET_BUF_TX_SIZE);
nano_fifo_init(&free_rx_bufs);
nano_fifo_init(&free_tx_bufs);
for (i = 0; i < NET_BUF_RX_SIZE; i++) {
nano_fifo_put(&free_rx_bufs, &rx_buffers[i]);
}
for (i = 0; i < NET_BUF_TX_SIZE; i++) {
nano_fifo_put(&free_tx_bufs, &tx_buffers[i]);
}
net_mbuf_init();
}

View file

@ -33,7 +33,7 @@
#include "contiki/ip/uip-debug.h"
#include <net/net_core.h>
#include <net/net_buf.h>
#include <net/l2_buf.h>
#include <net/net_ip.h>
#include <net/net_socket.h>
#include <net/netstack.h>
@ -58,15 +58,16 @@ static int net_driver_15_4_open(void)
static int net_driver_15_4_send(struct net_buf *buf)
{
int orig_len = buf->len;
int orig_len = ip_buf_len(buf);
if (!NETSTACK_COMPRESS.compress(buf)) {
NET_DBG("compression failed\n");
net_buf_put(buf);
ip_buf_unref(buf);
return -EINVAL;
}
NET_DBG("sending %d bytes (original len %d)\n", buf->len, orig_len);
NET_DBG("sending %d bytes (original len %d)\n", ip_buf_len(buf),
orig_len);
nano_fifo_put(&tx_queue, buf);
return 1;
@ -86,16 +87,15 @@ static void net_tx_15_4_fiber(void)
/* It is possible that uIP stack overwrote the len.
* We need to fix this here.
*/
uip_len(buf) = uip_slen(buf) = uip_appdatalen(buf) =
net_buf_datalen(buf);
uip_len(buf) = ip_buf_len(buf);
}
NET_DBG("Sending (buf %p, len %u) to 15.4 stack\n",
buf, buf->len);
NET_DBG("Sending (%u bytes) to 15.4 stack\n",
ip_buf_len(buf));
if (!NETSTACK_FRAGMENT.fragment(buf, NULL)) {
/* Release buffer on error */
net_buf_put(buf);
ip_buf_unref(buf);
}
net_analyze_stack("802.15.4 TX", tx_fiber_stack,
@ -105,7 +105,7 @@ static void net_tx_15_4_fiber(void)
static void net_rx_15_4_fiber(void)
{
struct net_mbuf *buf;
struct net_buf *buf;
#if NET_MAC_CONF_STATS
int byte_count;
#endif
@ -121,7 +121,7 @@ static void net_rx_15_4_fiber(void)
#endif
if (!NETSTACK_RDC.input(buf)) {
NET_DBG("RDC input failed\n");
net_mbuf_put(buf);
l2_buf_unref(buf);
} else {
#if NET_MAC_CONF_STATS
net_mac_stats.bytes_received += byte_count;
@ -185,7 +185,7 @@ int net_driver_15_4_recv(struct net_buf *buf)
return 0;
}
int net_driver_15_4_recv_from_hw(struct net_mbuf *buf)
int net_driver_15_4_recv_from_hw(struct net_buf *buf)
{
nano_fifo_put(&rx_queue, buf);
return 0;

View file

@ -16,4 +16,4 @@
int net_driver_15_4_init(void);
int net_driver_15_4_recv(struct net_buf *buf);
int net_driver_15_4_recv_from_hw(struct net_mbuf *buf);
int net_driver_15_4_recv_from_hw(struct net_buf *buf);

View file

@ -79,7 +79,7 @@ static int net_driver_ethernet_send(struct net_buf *buf)
*/
uip_arp_out(buf);
#else
memcpy(eth_hdr->dest.addr, buf->dest.u8, UIP_LLADDR_LEN);
memcpy(eth_hdr->dest.addr, ip_buf_ll_dest(buf).u8, UIP_LLADDR_LEN);
memcpy(eth_hdr->src.addr, uip_lladdr.addr, UIP_LLADDR_LEN);
#endif
@ -88,7 +88,7 @@ static int net_driver_ethernet_send(struct net_buf *buf)
/* Release the buffer because we sent all the data
* successfully.
*/
net_buf_put(buf);
ip_buf_unref(buf);
}
return res;
@ -108,13 +108,13 @@ void net_driver_ethernet_recv(struct net_buf *buf)
* length variable.
*/
if (uip_len(buf) == 0) {
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
if (!tx_cb) {
NET_ERR("Ethernet transmit callback is uninitialized.\n");
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
@ -122,13 +122,13 @@ void net_driver_ethernet_recv(struct net_buf *buf)
NET_ERR("Failed to send ARP response.\n");
}
net_buf_put(buf);
ip_buf_unref(buf);
} else
#endif
if (net_recv(buf) != 0) {
NET_ERR("Unexpected return value from net_recv.\n");
net_buf_put(buf);
ip_buf_unref(buf);
}
}

View file

@ -1,4 +1,4 @@
#include <net/net_buf.h>
#include <net/ip_buf.h>
#ifdef CONFIG_ETHERNET

View file

@ -32,7 +32,7 @@
#include "contiki/ip/uip-debug.h"
#include <net/net_core.h>
#include <net/net_buf.h>
#include <net/buf.h>
#include <net/net_ip.h>
#include <net/net_socket.h>

View file

@ -30,7 +30,7 @@
#endif
#include <net/net_core.h>
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include "contiki/os/dev/slip.h"
@ -43,13 +43,14 @@ static int net_driver_slip_open(void)
static int net_driver_slip_send(struct net_buf *buf)
{
NET_DBG("Sending %d bytes\n", buf->len);
NET_DBG("Sending %d bytes, application data %d bytes\n",
ip_buf_len(buf), ip_buf_appdatalen(buf));
if (!slip_send(buf)) {
/* Release the buffer because we sent all the data
* successfully.
*/
net_buf_put(buf);
ip_buf_unref(buf);
return 1;
}

View file

@ -31,7 +31,9 @@
#include <string.h>
#include <errno.h>
#include <net/net_buf.h>
#include <net/ip_buf.h>
#include <net/l2_buf.h>
#include <net/net_core.h>
#include <net/net_ip.h>
#include <net/net_socket.h>
@ -78,7 +80,7 @@ static struct net_dev {
/* Called by application to send a packet */
int net_send(struct net_buf *buf)
{
if (buf->len == 0) {
if (ip_buf_len(buf) == 0) {
return -ENODATA;
}
@ -195,10 +197,11 @@ static inline int udp_prepare_and_send(struct net_context *context,
* to fix the length here. The protocol specific
* part is added also here.
*/
uip_len(buf) = uip_slen(buf) = uip_appdatalen(buf) =
net_buf_datalen(buf);
uip_len(buf) = ip_buf_len(buf);
}
ip_buf_appdata(buf) = &uip_buf(buf)[UIP_IPUDPH_LEN];
port = NET_BUF_UDP(buf)->srcport;
NET_BUF_UDP(buf)->srcport = NET_BUF_UDP(buf)->destport;
NET_BUF_UDP(buf)->destport = port;
@ -213,7 +216,8 @@ static inline int udp_prepare_and_send(struct net_context *context,
*/
nbr = uip_ds6_nbr_lookup((uip_ipaddr_t *)&NET_BUF_IP(buf)->destipaddr);
if (!nbr) {
const uip_lladdr_t *lladdr = (const uip_lladdr_t *)&buf->src;
const uip_lladdr_t *lladdr =
(const uip_lladdr_t *)&ip_buf_ll_src(buf);
nbr = uip_ds6_nbr_add(
(uip_ipaddr_t *)&NET_BUF_IP(buf)->destipaddr,
lladdr, 0, NBR_REACHABLE);
@ -244,7 +248,8 @@ static inline int udp_prepare_and_send(struct net_context *context,
ret = simple_udp_sendto_port(buf,
net_context_get_udp_connection(context),
buf->data, buf->len,
ip_buf_appdata(buf),
ip_buf_appdatalen(buf),
&NET_BUF_IP(buf)->destipaddr,
uip_ntohs(NET_BUF_UDP(buf)->destport));
if (!ret) {
@ -303,7 +308,7 @@ int net_reply(struct net_context *context, struct net_buf *buf)
/* Called by driver when an IP packet has been received */
int net_recv(struct net_buf *buf)
{
if (buf->len == 0) {
if (ip_buf_len(buf) == 0) {
return -ENODATA;
}
@ -327,16 +332,17 @@ static void udp_packet_receive(struct simple_udp_connection *c,
/* If the context is not there, then we must discard
* the buffer here, otherwise we have a buffer leak.
*/
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
uip_appdatalen(buf) = datalen;
buf->datalen = datalen;
buf->data = uip_appdata(buf);
ip_buf_appdatalen(buf) = datalen;
ip_buf_appdata(buf) = &uip_buf(buf)[UIP_IPUDPH_LEN];
NET_DBG("packet received buf %p context %p len %d appdatalen %d\n",
buf, context, buf->len, datalen);
NET_DBG("packet received context %p len %d "
"appdata %p appdatalen %d\n",
context, ip_buf_len(buf),
ip_buf_appdata(buf), ip_buf_appdatalen(buf));
nano_fifo_put(net_context_get_queue(context), buf);
}
@ -345,8 +351,10 @@ static void udp_packet_receive(struct simple_udp_connection *c,
struct net_buf *net_receive(struct net_context *context, int32_t timeout)
{
struct nano_fifo *rx_queue = net_context_get_queue(context);
struct net_buf *buf;
struct net_tuple *tuple;
int ret = 0;
uint16_t reserve = 0;
tuple = net_context_get_tuple(context);
if (!tuple) {
@ -376,6 +384,7 @@ struct net_buf *net_receive(struct net_context *context, int32_t timeout)
}
net_context_set_receiver_registered(context);
ret = 0;
reserve = UIP_IPUDPH_LEN;
break;
case IPPROTO_TCP:
NET_DBG("TCP not yet supported\n");
@ -398,20 +407,30 @@ struct net_buf *net_receive(struct net_context *context, int32_t timeout)
switch (timeout) {
case TICKS_UNLIMITED:
return nano_fifo_get_wait(rx_queue);
buf = nano_fifo_get_wait(rx_queue);
break;
case TICKS_NONE:
return nano_fifo_get(rx_queue);
buf = nano_fifo_get(rx_queue);
break;
default:
#ifdef CONFIG_NANO_TIMEOUTS
#ifdef CONFIG_MICROKERNEL
return nano_task_fifo_get_wait_timeout(rx_queue, timeout);
buf = nano_task_fifo_get_wait_timeout(rx_queue, timeout);
#else /* CONFIG_MICROKERNEL */
return nano_fiber_fifo_get_wait_timeout(rx_queue, timeout);
buf = nano_fiber_fifo_get_wait_timeout(rx_queue, timeout);
#endif
#else /* CONFIG_NANO_TIMEOUTS */
return nano_fifo_get(rx_queue);
buf = nano_fifo_get(rx_queue);
#endif
break;
}
if (buf && reserve) {
ip_buf_appdatalen(buf) = ip_buf_len(buf) - reserve;
ip_buf_appdata(buf) = &uip_buf(buf)[reserve];
}
return buf;
}
static void udp_packet_reply(struct simple_udp_connection *c,
@ -430,21 +449,22 @@ static void udp_packet_reply(struct simple_udp_connection *c,
/* If the context is not there, then we must discard
* the buffer here, otherwise we have a buffer leak.
*/
net_buf_put(buf);
ip_buf_unref(buf);
return;
}
queue = net_context_get_queue(context);
NET_DBG("packet reply buf %p context %p len %d queue %p\n",
buf, context, buf->len, queue);
/* Contiki stack will overwrite the uip_len(buf) and
* uip_appdatalen(buf) values, so in order to allow
* the application to use them, copy the values here.
*/
buf->datalen = uip_len(buf);
buf->data = uip_appdata(buf);
ip_buf_appdatalen(buf) = datalen;
NET_DBG("packet reply context %p len %d "
"appdata %p appdatalen %d queue %p\n",
context, ip_buf_len(buf),
ip_buf_appdata(buf), ip_buf_appdatalen(buf), queue);
nano_fifo_put(queue, buf);
}
@ -460,15 +480,15 @@ static int check_and_send_packet(struct net_buf *buf)
return -EINVAL;
}
tuple = net_context_get_tuple(buf->context);
tuple = net_context_get_tuple(ip_buf_context(buf));
if (!tuple) {
return -EINVAL;
}
switch (tuple->ip_proto) {
case IPPROTO_UDP:
udp = net_context_get_udp_connection(buf->context);
if (!net_context_get_receiver_registered(buf->context)) {
udp = net_context_get_udp_connection(ip_buf_context(buf));
if (!net_context_get_receiver_registered(ip_buf_context(buf))) {
ret = simple_udp_register(udp, tuple->local_port,
#ifdef CONFIG_NETWORKING_WITH_IPV6
(uip_ip6addr_t *)&tuple->remote_addr->in6_addr,
@ -476,22 +496,25 @@ static int check_and_send_packet(struct net_buf *buf)
(uip_ip4addr_t *)&tuple->remote_addr->in_addr,
#endif
tuple->remote_port, udp_packet_reply,
buf->context);
ip_buf_context(buf));
if (!ret) {
NET_DBG("UDP connection creation failed\n");
ret = -ENOENT;
break;
}
net_context_set_receiver_registered(buf->context);
net_context_set_receiver_registered(ip_buf_context(buf));
}
/* Remember the original length as the uIP stack might
* reset the uip_len(buf) value.
if (ip_buf_appdatalen(buf) == 0) {
/* User application has not set the application data
* length. The buffer will be discarded if we do not
* set the value correctly.
*/
buf->datalen = uip_len(buf);
ret = simple_udp_send(buf, udp, buf->data, buf->len);
uip_appdatalen(buf) = buf->len - UIP_IPUDPH_LEN;
}
ret = simple_udp_send(buf, udp, uip_appdata(buf),
uip_appdatalen(buf));
break;
case IPPROTO_TCP:
NET_DBG("TCP not yet supported\n");
@ -527,7 +550,7 @@ static void net_tx_fiber(void)
*/
ret = check_and_send_packet(buf);
if (ret < 0) {
net_buf_put(buf);
ip_buf_unref(buf);
goto wait_next;
} else if (ret > 0) {
goto wait_next;
@ -540,7 +563,7 @@ static void net_tx_fiber(void)
ret = process_run(buf);
} while (ret > 0);
net_buf_put(buf);
ip_buf_unref(buf);
wait_next:
/* Check stack usage (no-op if not enabled) */
@ -567,7 +590,7 @@ static void net_rx_fiber(void)
NET_DBG("Received buf %p\n", buf);
if (!tcpip_input(buf)) {
net_buf_put(buf);
ip_buf_unref(buf);
}
/* The buffer is on to its way to receiver at this
* point. We must not remove it here.
@ -685,9 +708,14 @@ static uint8_t net_tcpip_output(struct net_buf *buf, const uip_lladdr_t *lladdr)
}
if(lladdr == NULL) {
linkaddr_copy(&buf->dest, &linkaddr_null);
linkaddr_copy(&ip_buf_ll_dest(buf), &linkaddr_null);
} else {
linkaddr_copy(&buf->dest, (const linkaddr_t *)lladdr);
linkaddr_copy(&ip_buf_ll_dest(buf),
(const linkaddr_t *)lladdr);
}
if (ip_buf_len(buf) == 0) {
return 0;
}
res = netdev.drv->send(buf);
@ -758,7 +786,10 @@ int net_init(void)
#endif /* UIP_STATISTICS == 1 */
net_context_init();
net_buf_init();
ip_buf_init();
l2_buf_init();
init_tx_queue();
init_rx_queue();
init_timer_fiber();

View file

@ -49,7 +49,7 @@
#endif
#ifdef WITH_CONTIKI
#include <net/net_buf.h>
#include <net/ip_buf.h>
#endif
#define dtls_set_version(H,V) dtls_int_to_uint16((H)->version, (V))
@ -1171,7 +1171,7 @@ dtls_prepare_record(dtls_peer_t *peer, dtls_security_parameters_t *security,
unsigned int i;
if (*rlen < DTLS_RH_LENGTH) {
dtls_alert("The sendbuf (%zu bytes) is too small\n", *rlen);
dtls_alert("The sendbuf (%d bytes) is too small\n", *rlen);
return dtls_alert_fatal_create(DTLS_ALERT_INTERNAL_ERROR);
}
@ -1413,19 +1413,19 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer,
size_t overall_len = 0;
#ifdef WITH_CONTIKI
buf = net_buf_get_reserve_tx(0);
buf = ip_buf_get_reserve_tx(UIP_IPUDPH_LEN);
if (!buf) {
return -ENOMEM;
}
sendbuf = buf->buf;
len = sizeof(buf->buf);
sendbuf = ip_buf_appdata(buf);
len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN; /* max application data len */
#endif
res = dtls_prepare_record(peer, security, type, buf_array, buf_len_array, buf_array_len, sendbuf, &len);
if (res < 0) {
#ifdef WITH_CONTIKI
net_buf_put(buf);
ip_buf_unref(buf);
#endif
return res;
}
@ -1481,7 +1481,7 @@ dtls_send_multi(dtls_context_t *ctx, dtls_peer_t *peer,
res = CALL(ctx, write, session, sendbuf, len);
#ifdef WITH_CONTIKI
net_buf_put(buf);
ip_buf_unref(buf);
#endif
/* Guess number of bytes application data actually sent:
@ -3887,9 +3887,9 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) {
if (node->retransmit_cnt < DTLS_DEFAULT_MAX_RETRANSMIT) {
#ifdef WITH_CONTIKI
/* Prepare to receive max. IPv6 frame size packets. */
struct net_buf *buf = net_buf_get_reserve_tx(0);
unsigned char *sendbuf = buf->buf;
size_t len = sizeof(buf->buf);
struct net_buf *buf = ip_buf_get_reserve_tx(UIP_IPUDPH_LEN);
unsigned char *sendbuf = ip_buf_appdata(buf);
size_t len = IP_BUF_MAX_DATA - UIP_IPUDPH_LEN;
#else
unsigned char sendbuf[DTLS_MAX_BUF];
size_t len = sizeof(sendbuf);
@ -3919,7 +3919,7 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) {
if (err < 0) {
dtls_warn("can not retransmit packet, err: %i\n", err);
#ifdef WITH_CONTIKI
net_buf_put(buf);
ip_buf_unref(buf);
#endif
return;
}
@ -3927,10 +3927,11 @@ dtls_retransmit(dtls_context_t *context, netq_t *node) {
sizeof(dtls_record_header_t));
dtls_debug_hexdump("retransmit unencrypted", node->data, node->length);
net_buf_add(buf, len);
(void)CALL(context, write, &node->peer->session, sendbuf, len);
#ifdef WITH_CONTIKI
net_buf_put(buf);
ip_buf_unref(buf);
#endif
return;

View file

@ -2,8 +2,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=5
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=5
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_TIMERS=y
CONFIG_ER_COAP=y

View file

@ -2,8 +2,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=5
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=5
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_TIMERS=y
CONFIG_ER_COAP=y

View file

@ -2,8 +2,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=4
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=4
CONFIG_NANO_TIMEOUTS=y
CONFIG_ER_COAP=y
CONFIG_ER_COAP_WITH_DTLS=y

View file

@ -2,8 +2,8 @@ CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=4
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=4
CONFIG_NANO_TIMEOUTS=y
CONFIG_ER_COAP=y
CONFIG_ER_COAP_WITH_DTLS=y

View file

@ -4,8 +4,8 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_TX_SIZE=4
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=4
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_NANO_TIMEOUTS=y
CONFIG_TINYDTLS=y
CONFIG_TINYDTLS_DEBUG=y

View file

@ -4,7 +4,7 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_TX_SIZE=4
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=4
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_NANO_TIMEOUTS=y
CONFIG_TINYDTLS=y

View file

@ -3,8 +3,8 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=2
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y
CONFIG_TINYDTLS=y
CONFIG_TINYDTLS_DEBUG=y

View file

@ -3,7 +3,7 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=2
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y
CONFIG_TINYDTLS=y

View file

@ -4,5 +4,5 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=2
CONFIG_NET_BUF_TX_SIZE=3
CONFIG_IP_BUF_RX_SIZE=2
CONFIG_IP_BUF_TX_SIZE=3

View file

@ -4,5 +4,5 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=2
CONFIG_NET_BUF_TX_SIZE=3
CONFIG_IP_BUF_RX_SIZE=2
CONFIG_IP_BUF_TX_SIZE=3

View file

@ -3,6 +3,6 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=2
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y

View file

@ -1,8 +1,8 @@
CONFIG_INIT_STACKS=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=2
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y
CONFIG_ETHERNET=y
CONFIG_ETH_DW=y

View file

@ -4,6 +4,6 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORKING_UART=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NET_BUF_RX_SIZE=3
CONFIG_NET_BUF_TX_SIZE=2
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y

View file

@ -2,5 +2,5 @@ CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_6LOWPAN=y
CONFIG_NETWORKING_WITH_15_4=y
CONFIG_NET_BUF_RX_SIZE=5
CONFIG_NET_BUF_TX_SIZE=3
CONFIG_IP_BUF_RX_SIZE=5
CONFIG_IP_BUF_TX_SIZE=3

View file

@ -2,6 +2,6 @@ CONFIG_NETWORKING=y
CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_6LOWPAN=y
CONFIG_NETWORKING_WITH_15_4=y
CONFIG_NET_BUF_RX_SIZE=5
CONFIG_NET_BUF_TX_SIZE=3
CONFIG_NET_15_4_LOOPBACK_NUM=1
CONFIG_IP_BUF_RX_SIZE=5
CONFIG_IP_BUF_TX_SIZE=3

Some files were not shown because too many files have changed in this diff Show more