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:
Ravi kumar Veeramally 2016-03-14 13:25:25 +02:00
commit a77ab4f4e2
9 changed files with 57 additions and 132 deletions

View file

@ -16,15 +16,16 @@
# limitations under the License.
#
NET_IFACE ?= slip
MDEF_FILE = prj.mdef
KERNEL_TYPE ?= nano
BOARD ?= qemu_x86
CONF_FILE ?= prj_$(ARCH).conf
CONF_FILE ?= prj_$(NET_IFACE).conf
include $(ZEPHYR_BASE)/Makefile.inc
ifeq ($(CONFIG_NETWORKING_WITH_BT), n)
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
else
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
else
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
endif

View file

@ -1,11 +1,12 @@
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING=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_TX_SIZE=5
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_TIMERS=y
CONFIG_ER_COAP=y
CONFIG_ER_COAP_CLIENT=y
CONFIG_ER_COAP_DEBUG=y

View file

@ -9,3 +9,5 @@ CONFIG_NANO_TIMERS=y
CONFIG_ER_COAP=y
CONFIG_ER_COAP_CLIENT=y
CONFIG_ER_COAP_DEBUG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y

View file

@ -13,3 +13,8 @@ obj-y = coap-observe-client.o
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
obj-y += ../../../bluetooth/gatt/ipss.o
endif
ifeq ($(CONFIG_NET_TESTING), y)
ccflags-y +=-I${srctree}/samples/net/common/
ccflags-y +=-DNET_TESTING_SERVER=0
endif

View file

@ -46,6 +46,10 @@
#include <bluetooth/bluetooth.h>
#include <gatt/ipss.h>
#if defined(CONFIG_NET_TESTING)
#include <net_testing.h>
#endif
#if defined(CONFIG_NANOKERNEL)
#define STACKSIZE 2000
char fiberStack[STACKSIZE];
@ -53,35 +57,30 @@ char fiberStack[STACKSIZE];
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 0
/* The 2001:db8::/32 is the private address space for documentation RFC 3849 */
/* admin-local, dynamically allocated multicast address */
#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 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
#else /* ipv6 */
/* The 192.0.2.0/24 is the private address space for documentation RFC 5737 */
#define MY_IPADDR { { { 192, 0, 2, 2 } } }
#else /* CONFIG_NETWORKING_WITH_IPV6 */
#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 } } }
#endif
#endif /* CONFIG_NETWORKING_WITH_IPV6 */
#define MY_PORT 8484
#define PEER_PORT COAP_DEFAULT_PORT
@ -104,35 +103,8 @@ static inline void init_app(void)
{
PRINT("%s: run coap observe client\n", __func__);
#if !defined(CONFIG_BLUETOOTH)
net_set_mac(my_mac, sizeof(my_mac));
#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
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
#endif
}

View file

@ -24,8 +24,8 @@ CONF_FILE ?= prj_$(NET_IFACE).conf
include $(ZEPHYR_BASE)/Makefile.inc
ifeq ($(CONFIG_NETWORKING_WITH_BT), n)
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
else
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
else
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
endif

View file

@ -6,3 +6,5 @@ CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=4
CONFIG_ER_COAP=y
CONFIG_ER_COAP_DEBUG=y
CONFIG_NET_TESTING=y
CONFIG_NETWORKING_IPV6_NO_ND=y

View file

@ -14,6 +14,11 @@ ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
obj-y += ../../../bluetooth/gatt/ipss.o
endif
ifeq ($(CONFIG_NET_TESTING), y)
ccflags-y +=-I${srctree}/samples/net/common/
ccflags-y +=-DNET_TESTING_SERVER=1
endif
obj-y += \
resources/res-plugtest-create1.o \
resources/res-plugtest-create2.o \

View file

@ -62,33 +62,8 @@ char fiberStack[STACKSIZE];
#include <bluetooth/bluetooth.h>
#include <gatt/ipss.h>
#if !defined(CONFIG_BLUETOOTH)
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
/* 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 } } }
#if defined(CONFIG_NET_TESTING)
#include <net_testing.h>
#endif
#if defined(CONFIG_ER_COAP_WITH_DTLS)
@ -96,56 +71,15 @@ static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
#else
#define MY_PORT COAP_DEFAULT_PORT
#endif
#define PEER_PORT 0
#if defined(CONFIG_NETWORKING_WITH_IPV6)
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
#define PEER_PORT 0
static inline void init_app(void)
{
PRINT("%s: run coap server\n", __func__);
#if !defined(CONFIG_BLUETOOTH)
net_set_mac(my_mac, sizeof(my_mac));
#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
#if defined(CONFIG_NET_TESTING)
net_testing_setup();
#endif
}
@ -280,6 +214,9 @@ void startup(void)
static struct net_addr my_addr;
#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.family = AF_INET6;