net: apps: Update CoAP apps to use net_testing header file
Update CoAP apps project configuration files and also update according to common net_testing header file. Change-Id: I09294dfd71e3d0cac980be4ae6d142cc3a59d85c Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
6d740fd4ca
commit
a77ab4f4e2
9 changed files with 57 additions and 132 deletions
|
@ -16,15 +16,16 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
NET_IFACE ?= slip
|
||||||
MDEF_FILE = prj.mdef
|
MDEF_FILE = prj.mdef
|
||||||
KERNEL_TYPE ?= nano
|
KERNEL_TYPE ?= nano
|
||||||
BOARD ?= qemu_x86
|
BOARD ?= qemu_x86
|
||||||
CONF_FILE ?= prj_$(ARCH).conf
|
CONF_FILE ?= prj_$(NET_IFACE).conf
|
||||||
|
|
||||||
include $(ZEPHYR_BASE)/Makefile.inc
|
include $(ZEPHYR_BASE)/Makefile.inc
|
||||||
|
|
||||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), n)
|
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
|
||||||
else
|
|
||||||
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
|
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
|
||||||
|
else
|
||||||
|
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||||
CONFIG_NETWORKING=y
|
CONFIG_NETWORKING=y
|
||||||
CONFIG_NETWORKING_WITH_LOGGING=y
|
CONFIG_NETWORKING_WITH_LOGGING=y
|
||||||
CONFIG_NETWORKING_UART=y
|
CONFIG_NETWORKING_WITH_15_4=y
|
||||||
|
CONFIG_NETWORKING_WITH_15_4_TI_CC2520=y
|
||||||
|
CONFIG_NETWORKING_WITH_6LOWPAN=y
|
||||||
|
CONFIG_6LOWPAN_COMPRESSION_IPHC=y
|
||||||
CONFIG_IP_BUF_RX_SIZE=3
|
CONFIG_IP_BUF_RX_SIZE=3
|
||||||
CONFIG_IP_BUF_TX_SIZE=5
|
CONFIG_IP_BUF_TX_SIZE=5
|
||||||
CONFIG_NANO_TIMEOUTS=y
|
|
||||||
CONFIG_NANO_TIMERS=y
|
|
||||||
CONFIG_ER_COAP=y
|
CONFIG_ER_COAP=y
|
||||||
CONFIG_ER_COAP_CLIENT=y
|
CONFIG_ER_COAP_CLIENT=y
|
||||||
CONFIG_ER_COAP_DEBUG=y
|
CONFIG_ER_COAP_DEBUG=y
|
|
@ -9,3 +9,5 @@ CONFIG_NANO_TIMERS=y
|
||||||
CONFIG_ER_COAP=y
|
CONFIG_ER_COAP=y
|
||||||
CONFIG_ER_COAP_CLIENT=y
|
CONFIG_ER_COAP_CLIENT=y
|
||||||
CONFIG_ER_COAP_DEBUG=y
|
CONFIG_ER_COAP_DEBUG=y
|
||||||
|
CONFIG_NET_TESTING=y
|
||||||
|
CONFIG_NETWORKING_IPV6_NO_ND=y
|
|
@ -13,3 +13,8 @@ obj-y = coap-observe-client.o
|
||||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||||
obj-y += ../../../bluetooth/gatt/ipss.o
|
obj-y += ../../../bluetooth/gatt/ipss.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_TESTING), y)
|
||||||
|
ccflags-y +=-I${srctree}/samples/net/common/
|
||||||
|
ccflags-y +=-DNET_TESTING_SERVER=0
|
||||||
|
endif
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
#include <gatt/ipss.h>
|
#include <gatt/ipss.h>
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_TESTING)
|
||||||
|
#include <net_testing.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NANOKERNEL)
|
#if defined(CONFIG_NANOKERNEL)
|
||||||
#define STACKSIZE 2000
|
#define STACKSIZE 2000
|
||||||
char fiberStack[STACKSIZE];
|
char fiberStack[STACKSIZE];
|
||||||
|
@ -53,35 +57,30 @@ char fiberStack[STACKSIZE];
|
||||||
|
|
||||||
static coap_observee_t *obs;
|
static coap_observee_t *obs;
|
||||||
|
|
||||||
#if !defined(CONFIG_BLUETOOTH)
|
|
||||||
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
|
||||||
/* The peer is the server in our case. Just invent a mac
|
|
||||||
* address for it because lower parts of the stack cannot set it
|
|
||||||
* in this test as we do not have any radios.
|
|
||||||
*/
|
|
||||||
static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is my mac address
|
|
||||||
*/
|
|
||||||
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
#if 0
|
/* admin-local, dynamically allocated multicast address */
|
||||||
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
|
#define MCAST_IPADDR { { { 0xff, 0x84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }
|
||||||
|
|
||||||
|
/* Define the peer IP address where to send messages */
|
||||||
|
#if !defined(CONFIG_NET_TESTING)
|
||||||
#define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
#define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
||||||
#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }
|
#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }
|
||||||
#else
|
|
||||||
#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } }
|
|
||||||
#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } }
|
|
||||||
#endif
|
#endif
|
||||||
#else /* ipv6 */
|
|
||||||
/* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */
|
#else /* CONFIG_NETWORKING_WITH_IPV6 */
|
||||||
#define MY_IPADDR { { { 192, 0, 2, 2 } } }
|
|
||||||
|
#error "IPv4 not supported at the moment, fix me!"
|
||||||
|
|
||||||
|
/* Organization-local 239.192.0.0/14 */
|
||||||
|
#define MCAST_IPADDR { { { 239, 192, 0, 2 } } }
|
||||||
|
|
||||||
|
#if !defined(CONFIG_NET_TESTING)
|
||||||
#define PEER_IPADDR { { { 192, 0, 2, 1 } } }
|
#define PEER_IPADDR { { { 192, 0, 2, 1 } } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_NETWORKING_WITH_IPV6 */
|
||||||
|
|
||||||
#define MY_PORT 8484
|
#define MY_PORT 8484
|
||||||
#define PEER_PORT COAP_DEFAULT_PORT
|
#define PEER_PORT COAP_DEFAULT_PORT
|
||||||
|
|
||||||
|
@ -104,35 +103,8 @@ static inline void init_app(void)
|
||||||
{
|
{
|
||||||
PRINT("%s: run coap observe client\n", __func__);
|
PRINT("%s: run coap observe client\n", __func__);
|
||||||
|
|
||||||
#if !defined(CONFIG_BLUETOOTH)
|
#if defined(CONFIG_NET_TESTING)
|
||||||
net_set_mac(my_mac, sizeof(my_mac));
|
net_testing_setup();
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
|
||||||
{
|
|
||||||
uip_ipaddr_t addr;
|
|
||||||
uip_ipaddr(&addr, 192,0,2,2);
|
|
||||||
uip_sethostaddr(&addr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
|
||||||
{
|
|
||||||
uip_ipaddr_t *addr;
|
|
||||||
const uip_lladdr_t *lladdr = (const uip_lladdr_t *)&peer_mac;
|
|
||||||
|
|
||||||
addr = (uip_ipaddr_t *)&in6addr_peer;
|
|
||||||
uip_ds6_defrt_add(addr, 0);
|
|
||||||
|
|
||||||
/* We cannot send to peer unless it is in neighbor
|
|
||||||
* cache. Neighbor cache should be populated automatically
|
|
||||||
* but do it here so that test works from first packet.
|
|
||||||
*/
|
|
||||||
uip_ds6_nbr_add(addr, lladdr, 0, NBR_REACHABLE);
|
|
||||||
|
|
||||||
addr = (uip_ipaddr_t *)&in6addr_my;
|
|
||||||
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ CONF_FILE ?= prj_$(NET_IFACE).conf
|
||||||
|
|
||||||
include $(ZEPHYR_BASE)/Makefile.inc
|
include $(ZEPHYR_BASE)/Makefile.inc
|
||||||
|
|
||||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), n)
|
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
|
||||||
else
|
|
||||||
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
|
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
|
||||||
|
else
|
||||||
|
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -6,3 +6,5 @@ CONFIG_IP_BUF_RX_SIZE=3
|
||||||
CONFIG_IP_BUF_TX_SIZE=4
|
CONFIG_IP_BUF_TX_SIZE=4
|
||||||
CONFIG_ER_COAP=y
|
CONFIG_ER_COAP=y
|
||||||
CONFIG_ER_COAP_DEBUG=y
|
CONFIG_ER_COAP_DEBUG=y
|
||||||
|
CONFIG_NET_TESTING=y
|
||||||
|
CONFIG_NETWORKING_IPV6_NO_ND=y
|
||||||
|
|
|
@ -14,6 +14,11 @@ ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||||
obj-y += ../../../bluetooth/gatt/ipss.o
|
obj-y += ../../../bluetooth/gatt/ipss.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_TESTING), y)
|
||||||
|
ccflags-y +=-I${srctree}/samples/net/common/
|
||||||
|
ccflags-y +=-DNET_TESTING_SERVER=1
|
||||||
|
endif
|
||||||
|
|
||||||
obj-y += \
|
obj-y += \
|
||||||
resources/res-plugtest-create1.o \
|
resources/res-plugtest-create1.o \
|
||||||
resources/res-plugtest-create2.o \
|
resources/res-plugtest-create2.o \
|
||||||
|
|
|
@ -62,33 +62,8 @@ char fiberStack[STACKSIZE];
|
||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
#include <gatt/ipss.h>
|
#include <gatt/ipss.h>
|
||||||
|
|
||||||
#if !defined(CONFIG_BLUETOOTH)
|
#if defined(CONFIG_NET_TESTING)
|
||||||
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
#include <net_testing.h>
|
||||||
/* The peer is the client in our case. Just invent a mac
|
|
||||||
* address for it because lower parts of the stack cannot set it
|
|
||||||
* in this test as we do not have any radios.
|
|
||||||
*/
|
|
||||||
static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is my mac address
|
|
||||||
*/
|
|
||||||
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
|
||||||
#if 0
|
|
||||||
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
|
|
||||||
#define MY_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }
|
|
||||||
#define PEER_IPADDR { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }
|
|
||||||
#else
|
|
||||||
#define PEER_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x17, 0x0a, 0xbe, 0xef, 0xf0, 0x0d, 0 } } }
|
|
||||||
#define MY_IPADDR { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0x08, 0xbe, 0xef, 0x15, 0xf0, 0x0d, 0 } } }
|
|
||||||
#endif
|
|
||||||
#else /* ipv6 */
|
|
||||||
/* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */
|
|
||||||
#define MY_IPADDR { { { 192, 0, 2, 2 } } }
|
|
||||||
#define PEER_IPADDR { { { 192, 0, 2, 1 } } }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_ER_COAP_WITH_DTLS)
|
#if defined(CONFIG_ER_COAP_WITH_DTLS)
|
||||||
|
@ -96,56 +71,15 @@ static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||||
#else
|
#else
|
||||||
#define MY_PORT COAP_DEFAULT_PORT
|
#define MY_PORT COAP_DEFAULT_PORT
|
||||||
#endif
|
#endif
|
||||||
#define PEER_PORT 0
|
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
#define PEER_PORT 0
|
||||||
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
|
||||||
static const struct in6_addr in6addr_peer = PEER_IPADDR;
|
|
||||||
static struct in6_addr in6addr_my = MY_IPADDR;
|
|
||||||
#else
|
|
||||||
static const struct in_addr in4addr_any = { { { 0 } } };
|
|
||||||
static struct in_addr in4addr_peer = PEER_IPADDR;
|
|
||||||
static struct in_addr in4addr_my = MY_IPADDR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void init_app(void)
|
static inline void init_app(void)
|
||||||
{
|
{
|
||||||
PRINT("%s: run coap server\n", __func__);
|
PRINT("%s: run coap server\n", __func__);
|
||||||
|
|
||||||
#if !defined(CONFIG_BLUETOOTH)
|
#if defined(CONFIG_NET_TESTING)
|
||||||
net_set_mac(my_mac, sizeof(my_mac));
|
net_testing_setup();
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
|
||||||
{
|
|
||||||
uip_ipaddr_t addr;
|
|
||||||
uip_ipaddr(&addr, 192,0,2,2);
|
|
||||||
uip_sethostaddr(&addr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
|
||||||
{
|
|
||||||
uip_ipaddr_t *addr;
|
|
||||||
|
|
||||||
/* Set the routes and neighbor cache only if we do not have
|
|
||||||
* neighbor discovery enabled. This setting should only be
|
|
||||||
* used if running in qemu and using slip (tun device).
|
|
||||||
*/
|
|
||||||
const uip_lladdr_t *lladdr = (const uip_lladdr_t *)&peer_mac;
|
|
||||||
|
|
||||||
addr = (uip_ipaddr_t *)&in6addr_peer;
|
|
||||||
uip_ds6_defrt_add(addr, 0);
|
|
||||||
|
|
||||||
/* We cannot send to peer unless it is in neighbor
|
|
||||||
* cache. Neighbor cache should be populated automatically
|
|
||||||
* but do it here so that test works from first packet.
|
|
||||||
*/
|
|
||||||
uip_ds6_nbr_add(addr, lladdr, 0, NBR_REACHABLE);
|
|
||||||
|
|
||||||
addr = (uip_ipaddr_t *)&in6addr_my;
|
|
||||||
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +214,9 @@ void startup(void)
|
||||||
static struct net_addr my_addr;
|
static struct net_addr my_addr;
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
|
static const struct in6_addr in6addr_my = IN6ADDR_ANY_INIT;
|
||||||
|
static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
|
||||||
|
|
||||||
any_addr.in6_addr = in6addr_any;
|
any_addr.in6_addr = in6addr_any;
|
||||||
any_addr.family = AF_INET6;
|
any_addr.family = AF_INET6;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue