Merge remote-tracking branch 'origin/master' into composite
This commit is contained in:
commit
a11806ee5f
@ -960,6 +960,13 @@ examples/nettest
|
||||
CONFIG_EXAMPLES_NETTEST=y - Enables the nettest example
|
||||
CONFIG_EXAMPLES_NETLIB=y - The networking library in needed.
|
||||
|
||||
Configurations:
|
||||
|
||||
- Server on target hardware; client on host
|
||||
- Client on target hardware; Server on host
|
||||
- Server and Client on different targets.
|
||||
- Loopback configuration with both client and server on the same target.
|
||||
|
||||
See also examples/tcpecho
|
||||
|
||||
examples/nrf24l01_term
|
||||
@ -2106,6 +2113,12 @@ examples/udp
|
||||
|
||||
CONFIG_NETUTILS_NETLIB=y
|
||||
|
||||
Possible configurations:
|
||||
|
||||
- Server on target hardware; client on host
|
||||
- Client on target hardware; Server on host
|
||||
- Server and Client on different targets.
|
||||
|
||||
examples/udpblaster
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -12,20 +12,28 @@ config EXAMPLES_NETTEST
|
||||
|
||||
if EXAMPLES_NETTEST
|
||||
|
||||
config EXAMPLES_NETTEST_PROGNAME
|
||||
string "Program name"
|
||||
config EXAMPLES_NETTEST_SENDSIZE
|
||||
int "Payload size"
|
||||
default 4096
|
||||
---help---
|
||||
The test client sends well-known packets to ther server. The server
|
||||
will receive and verfity those packets. This setting determines
|
||||
size of each packet.
|
||||
|
||||
config EXAMPLES_NETTEST_PROGNAME1
|
||||
string "Target1 program name"
|
||||
default "nettest"
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the program that will be use when the Nettest
|
||||
program is installed.
|
||||
|
||||
config EXAMPLES_NETTEST_STACKSIZE
|
||||
int "Nettest stack size"
|
||||
config EXAMPLES_NETTEST_STACKSIZE1
|
||||
int "Target1 stack size"
|
||||
default 2048
|
||||
|
||||
config EXAMPLES_NETTEST_PRIORITY
|
||||
int "Nettest priority"
|
||||
config EXAMPLES_NETTEST_PRIORITY1
|
||||
int "Target1 priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_NETTEST_LOOPBACK
|
||||
@ -36,26 +44,66 @@ config EXAMPLES_NETTEST_LOOPBACK
|
||||
Perform the test using the local loopback device. In this case,
|
||||
both the client and the server reside on the target.
|
||||
|
||||
if EXAMPLES_NETTEST_LOOPBACK
|
||||
# No server if loopback; No second target if loopback
|
||||
|
||||
config EXAMPLES_NETTEST_SERVER_STACKSIZE
|
||||
int "Server stack size"
|
||||
default 2048
|
||||
if !EXAMPLES_NETTEST_LOOPBACK
|
||||
|
||||
config EXAMPLES_NETTEST_SERVER_PRIORITY
|
||||
int "Server priority"
|
||||
default 100
|
||||
|
||||
endif # EXAMPLES_NETTEST_LOOPBACK
|
||||
|
||||
config EXAMPLES_NETTEST_SERVER
|
||||
bool "Target is server"
|
||||
config EXAMPLES_NETTEST_SERVER1
|
||||
bool "Target1 is server"
|
||||
default n
|
||||
depends on !EXAMPLES_NETTEST_LOOPBACK
|
||||
---help---
|
||||
Select to use the host as the client side of the test. Default: The
|
||||
target is the client side of the test
|
||||
|
||||
config EXAMPLES_NETTEST_TARGET2
|
||||
bool "Second endpoint is a target"
|
||||
default n
|
||||
---help---
|
||||
By default, the host PC is configured as the second endpoint of the
|
||||
NETTEST. If this option is selected, then the second endpoint
|
||||
will be built into the FLASH image as well. This means that you
|
||||
can use two target boards to run the test with no host PC
|
||||
involvement.
|
||||
|
||||
if EXAMPLES_NETTEST_TARGET2
|
||||
|
||||
config EXAMPLES_NETTEST_PROGNAME2
|
||||
string "Target2 program name"
|
||||
default "tcpserver" if !EXAMPLES_NETTEST_SERVER2
|
||||
default "tcpclient" if EXAMPLES_NETTEST_SERVER2
|
||||
depends on BUILD_KERNEL
|
||||
---help---
|
||||
This is the name of the Target2 program that will be use when the
|
||||
NSH ELF program is installed.
|
||||
|
||||
config EXAMPLES_NETTEST_PRIORITY2
|
||||
int "Target2 task priority"
|
||||
default 100
|
||||
|
||||
config EXAMPLES_NETTEST_STACKSIZE2
|
||||
int "Target2 stack size"
|
||||
default 2048
|
||||
|
||||
endif # EXAMPLES_NETTEST_TARGET2
|
||||
endif # !EXAMPLES_NETTEST_LOOPBACK
|
||||
|
||||
if EXAMPLES_NETTEST_LOOPBACK
|
||||
config EXAMPLES_NETTEST_DAEMON_STACKSIZE
|
||||
int "Server daemon stack size"
|
||||
default 2048
|
||||
|
||||
config EXAMPLES_NETTEST_DAEMON_PRIORITY
|
||||
int "Server daemon priority"
|
||||
default 100
|
||||
#endif
|
||||
|
||||
endif # EXAMPLES_NETTEST_LOOPBACK
|
||||
|
||||
config EXAMPLES_NETTEST_DEVNAME
|
||||
string "Network device"
|
||||
default "eth0"
|
||||
|
||||
config EXAMPLES_NETTEST_PERFORMANCE
|
||||
bool "Test for Performance"
|
||||
default n
|
||||
@ -78,6 +126,8 @@ config EXAMPLES_NETTEST_IPv6
|
||||
|
||||
endchoice # IP Domain
|
||||
|
||||
# No hardware initialization if loopback
|
||||
|
||||
config EXAMPLES_NETTEST_INIT
|
||||
bool "Initialize network"
|
||||
default n if NSH_BUILTIN_APPS
|
||||
@ -114,17 +164,19 @@ config EXAMPLES_NETTEST_NETMASK
|
||||
|
||||
endif # EXAMPLES_NETTEST_INIT
|
||||
|
||||
# No server if loopback
|
||||
|
||||
if !EXAMPLES_NETTEST_LOOPBACK
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIP
|
||||
hex "Client IP Address"
|
||||
config EXAMPLES_NETTEST_SERVERIP
|
||||
hex "Server IP Address"
|
||||
default 0x0a000001 if !EXAMPLES_NETTEST_SERVER
|
||||
default 0x0a000002 if EXAMPLES_NETTEST_SERVER
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -385,19 +437,21 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8
|
||||
endif # NET_ICMPv6_AUTOCONF
|
||||
endif # EXAMPLES_NETTEST_INIT
|
||||
|
||||
# Addresses are well known if loopback is used.
|
||||
|
||||
if !EXAMPLES_NETTEST_LOOPBACK || !NET_LOOPBACK
|
||||
|
||||
comment "Client IPv6 address"
|
||||
comment "Server IPv6 address"
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_1
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the cleint,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -405,15 +459,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_1
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the first of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_2
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -421,15 +475,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_2
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the second of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_3
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -437,15 +491,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_3
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the Third of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_4
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -453,15 +507,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_4
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the fourth of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_5
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -469,15 +523,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_5
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the fifth of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_6
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -485,15 +539,15 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_6
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the sixth of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_7
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -501,16 +555,16 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_7
|
||||
values forming the full IP address must be specified individually.
|
||||
This is the seventh of the 8-values.
|
||||
|
||||
config EXAMPLES_NETTEST_CLIENTIPv6ADDR_8
|
||||
config EXAMPLES_NETTEST_SERVERIPv6ADDR_8
|
||||
hex "[7]"
|
||||
default 0x0001 if !EXAMPLES_NETTEST_SERVER
|
||||
default 0x0002 if EXAMPLES_NETTEST_SERVER
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
IP address of the client. If the target is the client, then
|
||||
EXAMPLES_NETTEST_CLIENTIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the server,
|
||||
then the default value of EXAMPLES_NETTEST_CLIENTIP is set to the
|
||||
IP address of the server. If the target is the server, then
|
||||
EXAMPLES_NETTEST_SERVERIP should be the same as
|
||||
EXAMPLES_NETTEST_IPADDR (default). If the target is the client,
|
||||
then the default value of EXAMPLES_NETTEST_SERVERIP is set to the
|
||||
host PC IP address (possibly the gateway address,
|
||||
EXAMPLES_NETTEST_DRIPADDR?).
|
||||
|
||||
@ -520,4 +574,9 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_8
|
||||
|
||||
endif # !EXAMPLES_NETTEST_LOOPBACK
|
||||
endif # EXAMPLES_NETTEST_IPv6
|
||||
|
||||
config EXAMPLES_NETTEST_SERVER_PORTNO
|
||||
int "Server port number"
|
||||
default 5471
|
||||
|
||||
endif # EXAMPLES_NETTEST
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# examples/nettest/Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007-2008, 2010-2012, 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -39,27 +39,94 @@ include $(APPDIR)/Make.defs
|
||||
|
||||
# Basic TCP networking test
|
||||
|
||||
TARG_ASRCS =
|
||||
TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT))
|
||||
|
||||
TARG_CSRCS =
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
TARG_CSRCS += nettest_server.c nettest_client.c
|
||||
else ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
|
||||
TARG_CSRCS += nettest_server.c
|
||||
else
|
||||
TARG_CSRCS += nettest_client.c
|
||||
TARGCMN_CSRCS = nettest_cmdline.c
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_INIT),y)
|
||||
TARGCMN_CSRCS += nettest_netinit.c
|
||||
endif
|
||||
TARG_MAINSRC = nettest.c
|
||||
|
||||
TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT))
|
||||
TARG_MAINOBJ = $(TARG_MAINSRC:.c=$(OBJEXT))
|
||||
TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT))
|
||||
|
||||
TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) $(TARG_CSRCS)
|
||||
TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS)
|
||||
# Target 1 Files
|
||||
|
||||
TARG1_CSRCS =
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
TARG1_CSRCS += nettest_server.c nettest_client.c
|
||||
else ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
|
||||
TARG1_CSRCS += nettest_server.c
|
||||
else
|
||||
TARG1_CSRCS += nettest_client.c
|
||||
endif
|
||||
TARG1_MAINSRC = nettest_target1.c
|
||||
|
||||
TARG1_COBJS = $(TARG1_CSRCS:.c=$(OBJEXT))
|
||||
TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
TARG_CSRCS = $(TARG1_CSRCS) $(TARG1_CSRCS) $(TARGCMN_CSRCS)
|
||||
TARG_OBJS = $(TARG1_COBJS) $(TARGCMN_COBJS)
|
||||
|
||||
# Target 1 Application Info
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y)
|
||||
CONFIG_EXAMPLES_NETTEST_PROGNAME1 ?= tcpserver
|
||||
APPNAME1 = tcpserver
|
||||
else
|
||||
CONFIG_EXAMPLES_NETTEST_PROGNAME1 ?= tcpclient
|
||||
APPNAME1 = tcpclient
|
||||
endif
|
||||
CONFIG_EXAMPLES_NETTEST_PRIORITY1 ?= 100
|
||||
CONFIG_EXAMPLES_NETTEST_STACKSIZE1 ?= 2048
|
||||
|
||||
PROGNAME1 = $(CONFIG_EXAMPLES_NETTEST_PROGNAME1)
|
||||
PRIORITY1 = $(CONFIG_EXAMPLES_NETTEST_PRIORITY1)
|
||||
STACKSIZE1 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE1)
|
||||
|
||||
# Target 2
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
|
||||
TARG2_CSRCS =
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y)
|
||||
TARG2_CSRCS += nettest_client.c
|
||||
else
|
||||
TARG2_CSRCS += nettest_server.c
|
||||
endif
|
||||
TARG2_MAINSRC = nettest_target2.c
|
||||
|
||||
TARG2_COBJS = $(TARG2_CSRCS:.c=$(OBJEXT))
|
||||
TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
# Target 2 Application Info
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER1),y)
|
||||
CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpclient
|
||||
APPNAME2 = tcpclient
|
||||
else
|
||||
CONFIG_EXAMPLES_NETTEST_PROGNAME2 ?= tcpserver
|
||||
APPNAME2 = tcpserver
|
||||
endif
|
||||
CONFIG_EXAMPLES_NETTEST_PRIORITY2 ?= 100
|
||||
CONFIG_EXAMPLES_NETTEST_STACKSIZE2 ?= 2048
|
||||
|
||||
PROGNAME2 = $(CONFIG_EXAMPLES_NETTEST_PROGNAME2)
|
||||
PRIORITY2 = $(CONFIG_EXAMPLES_NETTEST_PRIORITY2)
|
||||
STACKSIZE2 = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE2)
|
||||
|
||||
endif
|
||||
|
||||
# All targets
|
||||
|
||||
TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS)
|
||||
TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
TARG_OBJS += $(TARG_MAINOBJ)
|
||||
TARG_OBJS += $(TARG1_MAINOBJ) $(TARG2_MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
MAINNAME1 = nettest1_main
|
||||
MAINNAME2 = nettest2_main
|
||||
else
|
||||
MAINNAME1 = nettest_main
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
@ -72,25 +139,32 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
# Host
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
|
||||
HOSTCFLAGS += -DNETTEST_HOST=1
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
|
||||
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)"
|
||||
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_SERVERIP="$(CONFIG_EXAMPLES_NETTEST_SERVERIP)"
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_PERFORMANCE),y)
|
||||
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1
|
||||
endif
|
||||
|
||||
HOST_SRCS = host.c
|
||||
HOST_SRCS = nettest_host.c
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
|
||||
HOST_SRCS += nettest_client.c
|
||||
HOST_SRCS += nettest_client.c
|
||||
HOST_BIN = tcpclient$(EXEEXT)
|
||||
else
|
||||
HOST_SRCS += nettest_server.c
|
||||
HOST_SRCS += nettest_server.c
|
||||
HOST_BIN = tcpserver$(EXEEXT)
|
||||
endif
|
||||
|
||||
HOSTOBJEXT ?= .hobj
|
||||
HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT))
|
||||
HOST_BIN = host
|
||||
HOSTOBJEXT ?= hobj
|
||||
HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJEXT))
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
@ -101,45 +175,38 @@ endif
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# NET test built-in application info
|
||||
|
||||
CONFIG_EXAMPLES_NETTEST_STACKSIZE ?= 2048
|
||||
CONFIG_EXAMPLES_NETTEST_PRIORITY ?= 100
|
||||
|
||||
APPNAME = nettest
|
||||
PRIORITY = $(CONFIG_EXAMPLES_NETTEST_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_EXAMPLES_NETTEST_STACKSIZE)
|
||||
|
||||
CONFIG_EXAMPLES_NETTEST_PROGNAME ?= nettest$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_EXAMPLES_HELLO_PROGNAME)
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built $(HOST_BIN)
|
||||
.PHONY: clean depend distclean
|
||||
.PHONY: clean depend distclean preconfig
|
||||
|
||||
$(TARG_AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c
|
||||
$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS) : %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
$(HOST_OBJS): %$(HOSTOBJEXT): %.c
|
||||
|
||||
$(HOST_OBJS): %.$(HOSTOBJEXT): %.c
|
||||
@echo "CC: $<"
|
||||
$(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
config.h: $(TOPDIR)/include/nuttx/config.h
|
||||
@echo "CP: $<"
|
||||
$(Q) cp $< $@
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
|
||||
$(HOST_BIN): config.h $(HOST_OBJS)
|
||||
@echo "LD: $@"
|
||||
$(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
.built: config.h $(TARG_OBJS)
|
||||
@ -147,12 +214,12 @@ endif
|
||||
$(Q) touch .built
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG_MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME1): $(OBJS) $(TARG1_MAINOBJ)
|
||||
@echo "LD: $(PROGNAME1)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME1) $(ARCHCRT0OBJ) $(TARG1_MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME1)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME1)
|
||||
|
||||
else
|
||||
install:
|
||||
@ -160,24 +227,34 @@ install:
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(MAINNAME1))
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
ifeq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(MAINNAME2))
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat \
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat
|
||||
else
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat
|
||||
endif
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile config.h $(TARG_SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep
|
||||
.depend: Makefile config.h $(TARG_CSRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_CSRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_TARGET2),y)
|
||||
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
|
||||
$(call DELFILE, *$(HOSTOBJEXT))
|
||||
$(call DELFILE, *.$(HOSTOBJEXT))
|
||||
$(call DELFILE, $(HOST_BIN))
|
||||
endif
|
||||
endif
|
||||
$(call DELFILE, .built)
|
||||
$(call DELFILE, *.dSYM)
|
||||
@ -188,7 +265,6 @@ distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
||||
.PHONY: preconfig
|
||||
preconfig:
|
||||
|
||||
-include Make.dep
|
||||
|
@ -77,14 +77,36 @@
|
||||
# define PF_INETX PF_INET
|
||||
#endif
|
||||
|
||||
#define PORTNO 5471
|
||||
#define SENDSIZE 4096
|
||||
#ifndef CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO
|
||||
# define CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO 5471
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_SENDSIZE
|
||||
# define SENDSIZE CONFIG_EXAMPLES_NETTEST_SENDSIZE
|
||||
#else
|
||||
# define SENDSIZE 4096
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
uint16_t g_nettestserver_ipv6[8];
|
||||
#else
|
||||
uint32_t g_nettestserver_ipv4;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void send_client(void);
|
||||
extern void recv_server(void);
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
void nettest_initialize(void);
|
||||
#endif
|
||||
|
||||
void nettest_cmdline(int argc, char **argv);
|
||||
extern void nettest_client(void);
|
||||
extern void nettest_server(void);
|
||||
|
||||
#endif /* __EXAMPLES_NETTEST_H */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettest-client.c
|
||||
* examples/nettest/nettest_client.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -56,12 +56,12 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void send_client(void)
|
||||
void nettest_client(void)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
struct sockaddr_in6 myaddr;
|
||||
struct sockaddr_in6 server;
|
||||
#else
|
||||
struct sockaddr_in myaddr;
|
||||
struct sockaddr_in server;
|
||||
#endif
|
||||
char *outbuf;
|
||||
#ifndef CONFIG_EXAMPLES_NETTEST_PERFORMANCE
|
||||
@ -100,56 +100,29 @@ void send_client(void)
|
||||
goto errout_with_buffers;
|
||||
}
|
||||
|
||||
/* Connect the socket to the server */
|
||||
/* Set up the server address */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
myaddr.sin6_family = AF_INET6;
|
||||
myaddr.sin6_port = HTONS(PORTNO);
|
||||
server.sin6_family = AF_INET6;
|
||||
server.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO);
|
||||
memcpy(server.sin6_addr.s6_addr16, g_nettestserver_ipv6, 8 * sizeof(uint16_t));
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK)
|
||||
myaddr.sin6_addr.s6_addr16[0] = 0; /* Use the loopback address */
|
||||
myaddr.sin6_addr.s6_addr16[1] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[2] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[3] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[4] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[5] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[6] = 0;
|
||||
myaddr.sin6_addr.s6_addr16[7] = HTONS(1);
|
||||
printf("Connecting to IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
g_nettestserver_ipv6[0], g_nettestserver_ipv6[1], g_nettestserver_ipv6[2], g_nettestserver_ipv6[3],
|
||||
g_nettestserver_ipv6[4], g_nettestserver_ipv6[5], g_nettestserver_ipv6[6], g_nettestserver_ipv6[7]);
|
||||
#else
|
||||
myaddr.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1);
|
||||
myaddr.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2);
|
||||
myaddr.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3);
|
||||
myaddr.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4);
|
||||
myaddr.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5);
|
||||
myaddr.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6);
|
||||
myaddr.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7);
|
||||
myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8);
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO);
|
||||
server.sin_addr.s_addr = (in_addr_t)g_nettestserver_ipv4;
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
|
||||
printf("Connecting to IPv4 Address: %08lx\n", (unsigned long)g_nettestserver_ipv4);
|
||||
#endif
|
||||
|
||||
printf("IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
myaddr.sin6_addr.s6_addr16[0], myaddr.sin6_addr.s6_addr16[1],
|
||||
myaddr.sin6_addr.s6_addr16[2], myaddr.sin6_addr.s6_addr16[3],
|
||||
myaddr.sin6_addr.s6_addr16[4], myaddr.sin6_addr.s6_addr16[5],
|
||||
myaddr.sin6_addr.s6_addr16[6], myaddr.sin6_addr.s6_addr16[7]);
|
||||
/* Connect the socket to the server */
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
#else
|
||||
myaddr.sin_family = AF_INET;
|
||||
myaddr.sin_port = HTONS(PORTNO);
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK)
|
||||
myaddr.sin_addr.s_addr = HTONL(0x7f000001);
|
||||
#else
|
||||
myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP);
|
||||
#endif
|
||||
|
||||
printf("IPv4 Address: %08x\n", myaddr.sin_addr.s_addr);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
|
||||
printf("client: Connecting...\n");
|
||||
if (connect( sockfd, (struct sockaddr*)&myaddr, addrlen) < 0)
|
||||
if (connect( sockfd, (struct sockaddr*)&server, addrlen) < 0)
|
||||
{
|
||||
printf("client: connect failure: %d\n", errno);
|
||||
goto errout_with_socket;
|
||||
@ -240,6 +213,7 @@ void send_client(void)
|
||||
goto errout_with_socket;
|
||||
}
|
||||
|
||||
printf("client: Terminating\n");
|
||||
close(sockfd);
|
||||
free(outbuf);
|
||||
#ifndef CONFIG_EXAMPLES_NETTEST_PERFORMANCE
|
||||
|
137
examples/nettest/nettest_cmdline.c
Normal file
137
examples/nettest/nettest_cmdline.c
Normal file
@ -0,0 +1,137 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/netest_cmdline.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "nettest.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
|
||||
uint16_t g_nettestserver_ipv6[8] =
|
||||
{
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK)
|
||||
0 /* Use the loopback address */
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
HTONS(1);
|
||||
#else
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_1),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_2),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_3),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_4),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_5),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_6),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_7),
|
||||
HTONS(CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_8)
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(NET_LOOPBACK)
|
||||
uint32_t g_nettestserver_ipv4 = HTONL(0x7f000001);
|
||||
#else
|
||||
uint32_t g_nettestserver_ipv4 = HTONL(CONFIG_EXAMPLES_NETTEST_SERVERIP);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* show_usage
|
||||
****************************************************************************/
|
||||
|
||||
static void show_usage(FAR const char *progname)
|
||||
{
|
||||
fprintf(stderr, "USAGE: %s [<server-addr>]\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* nettest_cmdline
|
||||
****************************************************************************/
|
||||
|
||||
void nettest_cmdline(int argc, char **argv)
|
||||
{
|
||||
/* Currently only a single command line option is supported: The server
|
||||
* IP address.
|
||||
*/
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Convert the <server-addr> argument into a binary address */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
ret = inet_pton(AF_INET6, argv[1], g_nettestserver_ipv6);
|
||||
#else
|
||||
ret = inet_pton(AF_INET, argv[1], &g_nettestserver_ipv4);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: <server-addr> is invalid\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
}
|
||||
else if (argc != 1)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Too many arguments\n");
|
||||
show_usage(argv[0]);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/host.c
|
||||
* examples/nettest/nettest_host.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -55,9 +55,9 @@
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_SERVER
|
||||
send_client();
|
||||
nettest_client();
|
||||
#else
|
||||
recv_server();
|
||||
nettest_server();
|
||||
#endif
|
||||
|
||||
return 0;
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettest.c
|
||||
* examples/nettest/nettest_netinit.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009-2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -38,28 +38,31 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
//#include <nuttx/config.h>
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include "netutils/netlib.h"
|
||||
|
||||
#include "nettest.h"
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_DEVNAME
|
||||
# define DEVNAME CONFIG_EXAMPLES_NETTEST_DEVNAME
|
||||
#else
|
||||
# define DEVNAME "eth0"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -111,11 +114,10 @@ static const uint16_t g_ipv6_netmask[8] =
|
||||
#endif /* CONFIG_EXAMPLES_NETTEST_INIT && CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
static void netest_initialize(void)
|
||||
void nettest_initialize(void)
|
||||
{
|
||||
#ifndef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
struct in_addr addr;
|
||||
@ -133,37 +135,37 @@ static void netest_initialize(void)
|
||||
mac[3] = 0xad;
|
||||
mac[4] = 0xbe;
|
||||
mac[5] = 0xef;
|
||||
netlib_setmacaddr("eth0", mac);
|
||||
netlib_setmacaddr(DEVNAME, mac);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
/* Perform ICMPv6 auto-configuration */
|
||||
|
||||
netlib_icmpv6_autoconfiguration("eth0");
|
||||
netlib_icmpv6_autoconfiguration(DEVNAME);
|
||||
|
||||
#else /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
|
||||
/* Set up our fixed host address */
|
||||
|
||||
netlib_set_ipv6addr("eth0",
|
||||
netlib_set_ipv6addr(DEVNAME,
|
||||
(FAR const struct in6_addr *)g_ipv6_hostaddr);
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
netlib_set_dripv6addr("eth0",
|
||||
netlib_set_dripv6addr(DEVNAME,
|
||||
(FAR const struct in6_addr *)g_ipv6_draddr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
netlib_set_ipv6netmask("eth0",
|
||||
netlib_set_ipv6netmask(DEVNAME,
|
||||
(FAR const struct in6_addr *)g_ipv6_netmask);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
netlib_ifup(DEVNAME);
|
||||
|
||||
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
#else /* CONFIG_EXAMPLES_NETTEST_IPv6 */
|
||||
@ -171,88 +173,20 @@ static void netest_initialize(void)
|
||||
/* Set up our host address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR);
|
||||
netlib_set_ipv4addr("eth0", &addr);
|
||||
netlib_set_ipv4addr(DEVNAME, &addr);
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR);
|
||||
netlib_set_dripv4addr("eth0", &addr);
|
||||
netlib_set_dripv4addr(DEVNAME, &addr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
netlib_set_ipv4netmask(DEVNAME, &addr);
|
||||
|
||||
#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */
|
||||
}
|
||||
#endif /*CONFIG_EXAMPLES_NETTEST_INIT */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
|
||||
static int server_child(int argc, char *argv[])
|
||||
{
|
||||
recv_server();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_EXAMPLES_NETTEST_INIT */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* nettest_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int nettest_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
|
||||
pid_t child;
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
int statloc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
/* Initialize the network */
|
||||
|
||||
netest_initialize();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
|
||||
/* Then perform the server side of the test on a child task */
|
||||
|
||||
child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_SERVER_PRIORITY,
|
||||
CONFIG_EXAMPLES_NETTEST_SERVER_STACKSIZE, server_child,
|
||||
NULL);
|
||||
if (child < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Failed to server daemon\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
usleep(500*1000);
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_NETTEST_SERVER)
|
||||
/* Then perform the server side of the test on this thread */
|
||||
|
||||
recv_server();
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_EXAMPLES_NETTEST_SERVER) || \
|
||||
defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
|
||||
/* Then perform the client side of the test on this thread */
|
||||
|
||||
send_client();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID)
|
||||
printf("main: Waiting for the server to exit\n");
|
||||
(void)waitpid(child, &statloc, 0);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -57,7 +57,7 @@
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void recv_server(void)
|
||||
void nettest_server(void)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
struct sockaddr_in6 myaddr;
|
||||
@ -112,33 +112,32 @@ void recv_server(void)
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_IPv6
|
||||
|
||||
myaddr.sin6_family = AF_INET6;
|
||||
myaddr.sin6_port = HTONS(PORTNO);
|
||||
|
||||
myaddr.sin6_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO);
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK)
|
||||
myaddr.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1);
|
||||
myaddr.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2);
|
||||
myaddr.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3);
|
||||
myaddr.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4);
|
||||
myaddr.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5);
|
||||
myaddr.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6);
|
||||
myaddr.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7);
|
||||
myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8);
|
||||
memcpy(myaddr.sin6_addr.s6_addr16, g_nettestserver_ipv6, 8 * sizeof(uint16_t));
|
||||
#else
|
||||
memset(&myaddr.sin6_addr, 0, sizeof(struct in6_addr));
|
||||
memset(myaddr.sin6_addr.s6_addr16, 0, 8 * sizeof(uint16_t));
|
||||
#endif
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
|
||||
printf("Binding to IPv6 Address: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
myaddr.sin6_addr.s6_addr16[0], myaddr.sin6_addr.s6_addr16[1],
|
||||
myaddr.sin6_addr.s6_addr16[2], myaddr.sin6_addr.s6_addr16[3],
|
||||
myaddr.sin6_addr.s6_addr16[4], myaddr.sin6_addr.s6_addr16[5],
|
||||
myaddr.sin6_addr.s6_addr16[6], myaddr.sin6_addr.s6_addr16[7]);
|
||||
#else
|
||||
myaddr.sin_family = AF_INET;
|
||||
myaddr.sin_port = HTONS(PORTNO);
|
||||
myaddr.sin_port = HTONS(CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO);
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && !defined(NET_LOOPBACK)
|
||||
myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP);
|
||||
myaddr.sin_addr.s_addr = (in_addr_t)g_nettestserver_ipv4;
|
||||
#else
|
||||
myaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
#endif
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
|
||||
printf("Binding to IPv4 Address: %08lx\n",
|
||||
(unsigned long)myaddr.sin_addr.s_addr);
|
||||
#endif
|
||||
|
||||
if (bind(listensd, (struct sockaddr*)&myaddr, addrlen) < 0)
|
||||
@ -157,7 +156,8 @@ void recv_server(void)
|
||||
|
||||
/* Accept only one connection */
|
||||
|
||||
printf("server: Accepting connections on port %d\n", PORTNO);
|
||||
printf("server: Accepting connections on port %d\n",
|
||||
CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO);
|
||||
acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen);
|
||||
if (acceptsd < 0)
|
||||
{
|
||||
|
130
examples/nettest/nettest_target1.c
Normal file
130
examples/nettest/nettest_target1.c
Normal file
@ -0,0 +1,130 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettest_target1.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "nettest.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
|
||||
static int server_child(int argc, char *argv[])
|
||||
{
|
||||
nettest_server();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* nettest_main
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BUILD_KERNEL)
|
||||
int main(int argc, FAR char *argv[])
|
||||
#elif defined(CONFIG_EXAMPLES_NETTEST_TARGET2)
|
||||
int nettest1_main(int argc, char *argv[])
|
||||
#else
|
||||
int nettest_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
|
||||
pid_t child;
|
||||
#ifdef CONFIG_SCHED_WAITPID
|
||||
int statloc;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Parse any command line options */
|
||||
|
||||
nettest_cmdline(argc, argv);
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
/* Initialize the network */
|
||||
|
||||
nettest_initialize();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
|
||||
/* Then perform the server side of the test on a child task */
|
||||
|
||||
child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_DAEMON_PRIORITY,
|
||||
CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE, server_child,
|
||||
NULL);
|
||||
if (child < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Failed to server daemon\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
usleep(500*1000);
|
||||
|
||||
#elif defined(CONFIG_EXAMPLES_NETTEST_SERVER)
|
||||
/* Then perform the server side of the test on this thread */
|
||||
|
||||
nettest_server();
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_EXAMPLES_NETTEST_SERVER) || \
|
||||
defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
|
||||
/* Then perform the client side of the test on this thread */
|
||||
|
||||
nettest_client();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID)
|
||||
printf("main: Waiting for the server to exit\n");
|
||||
(void)waitpid(child, &statloc, 0);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
75
examples/nettest/nettest_target2.c
Normal file
75
examples/nettest/nettest_target2.c
Normal file
@ -0,0 +1,75 @@
|
||||
/****************************************************************************
|
||||
* examples/nettest/nettest_target2.c
|
||||
*
|
||||
* Copyright (C) 2007, 2009-2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include "nettest.h"
|
||||
|
||||
/****************************************************************************
|
||||
* nettest_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int nettest2_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
/* Parse any command line options */
|
||||
|
||||
nettest_cmdline(argc, argv);
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
|
||||
/* Initialize the network */
|
||||
|
||||
nettest_initialize();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_NETTEST_SERVER)
|
||||
/* Then perform the client side of the test on this thread */
|
||||
|
||||
nettest_client();
|
||||
#else
|
||||
/* Then perform the server side of the test on this thread */
|
||||
|
||||
nettest_server();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -55,7 +55,8 @@
|
||||
#include <nuttx/mtd/mtd.h>
|
||||
#include <nuttx/fs/smart.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/fs/mksmartfs.h>
|
||||
|
||||
#include "fsutils/mksmartfs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -821,7 +822,7 @@ int smart_main(int argc, char *argv[])
|
||||
/* Initialize to provide SMART on an MTD interface */
|
||||
|
||||
MTD_IOCTL(mtd, MTDIOC_BULKERASE, 0);
|
||||
ret = smart_initialize(1, mtd);
|
||||
ret = smart_initialize(1, mtd, "SmartTest");
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("ERROR: SMART initialization failed: %d\n", -ret);
|
||||
@ -831,7 +832,11 @@ int smart_main(int argc, char *argv[])
|
||||
|
||||
/* Create a SMARTFS filesystem */
|
||||
|
||||
(void)mksmartfs("/dev/smart1");
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
(void)mksmartfs("/dev/smart1", 1024, 1);
|
||||
#else
|
||||
(void)mksmartfs("/dev/smart1", 1024);
|
||||
#endif
|
||||
|
||||
/* Mount the file system */
|
||||
|
||||
|
@ -42,7 +42,7 @@ config EXAMPLES_UDP_TARGET2
|
||||
By default, the host PC is configured as the second endpoint of the
|
||||
UDP test. If this option is selected, then the second endpoint
|
||||
will be built into the FLASH image as well. This means that you
|
||||
can use two target boards to run the test with not host PC
|
||||
can use two target boards to run the test with no host PC
|
||||
involvement.
|
||||
|
||||
if EXAMPLES_UDP_TARGET2
|
||||
@ -511,4 +511,13 @@ config EXAMPLES_UDP_SERVERIPv6ADDR_8
|
||||
This is the last of the 8-values.
|
||||
|
||||
endif # EXAMPLES_UDP_IPv6
|
||||
|
||||
config EXAMPLES_UDP_SERVER_PORTNO
|
||||
int "Server port number"
|
||||
default 5471
|
||||
|
||||
config EXAMPLES_UDP_CLIENT_PORTNO
|
||||
int "Client port number"
|
||||
default 5472
|
||||
|
||||
endif # EXAMPLES_UDP
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# apps/examples/udp/Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2008, 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007-2008, 2011-2012, 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -41,8 +41,9 @@ include $(APPDIR)/Make.defs
|
||||
|
||||
TARGCMN_CSRCS = udp_cmdline.c
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_NETINIT),y)
|
||||
TARGCMN_CSRCS += target_netinit.c
|
||||
TARGCMN_CSRCS += udp_netinit.c
|
||||
endif
|
||||
|
||||
TARGCMN_COBJS = $(TARGCMN_CSRCS:.c=$(OBJEXT))
|
||||
|
||||
# Target 1
|
||||
@ -53,7 +54,7 @@ TARG1_CRCS += udp_server.c
|
||||
else
|
||||
TARG1_CRCS += udp_client.c
|
||||
endif
|
||||
TARG1_MAINSRC = target1.c
|
||||
TARG1_MAINSRC = udp_target1.c
|
||||
|
||||
TARG1_COBJS = $(TARG1_CRCS:.c=$(OBJEXT))
|
||||
TARG1_MAINOBJ = $(TARG1_MAINSRC:.c=$(OBJEXT))
|
||||
@ -76,15 +77,15 @@ STACKSIZE1 = $(CONFIG_EXAMPLES_UDP_STACKSIZE1)
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_TARGET2),y)
|
||||
|
||||
TARG2_CRCS =
|
||||
TARG2_CSRCS =
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y)
|
||||
TARG2_CRCS += udp_client.c
|
||||
TARG2_CSRCS += udp_client.c
|
||||
else
|
||||
TARG2_CRCS += udp_server.c
|
||||
TARG2_CSRCS += udp_server.c
|
||||
endif
|
||||
TARG2_MAINSRC = target2.c
|
||||
TARG2_MAINSRC = udp_target2.c
|
||||
|
||||
TARG2_COBJS = $(TARG2_CRCS:.c=$(OBJEXT))
|
||||
TARG2_COBJS = $(TARG2_CSRCS:.c=$(OBJEXT))
|
||||
TARG2_MAINOBJ = $(TARG2_MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y)
|
||||
@ -103,7 +104,7 @@ STACKSIZE2 = $(CONFIG_EXAMPLES_UDP_STACKSIZE2)
|
||||
|
||||
endif
|
||||
|
||||
TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS)
|
||||
TARG_SRCS = $(TARG1_CRCS) $(TARG1_MAINSRC) $(TARG2_CSRCS) $(TARG2_MAINSRC) $(TARGCMN_CSRCS)
|
||||
TARG_OBJS = $(TARG1_COBJS) $(TARG2_COBJS) $(TARGCMN_COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
@ -115,18 +116,18 @@ endif
|
||||
ifneq ($(CONFIG_EXAMPLES_UDP_TARGET2),y)
|
||||
|
||||
HOSTCFLAGS += -DEXAMPLES_UDP_HOST=1
|
||||
HOSTOBJSEXT ?= o1
|
||||
HOSTOBJSEXT ?= hobj
|
||||
|
||||
HOST_SRCS = host.c udp_cmdline.c
|
||||
HOST_SRCS = udp_host.c udp_cmdline.c
|
||||
ifeq ($(CONFIG_EXAMPLES_UDP_SERVER1),y)
|
||||
HOST_SRCS += udp_client.c
|
||||
HOST_BIN = udpclient$(EXEEXT)
|
||||
else
|
||||
HOST_SRCS += udp_server.c
|
||||
HOST_BIN = udpserver$(EXEEXT)
|
||||
endif
|
||||
|
||||
HOST_OBJS = $(HOST_SRCS:.c=.$(HOSTOBJSEXT))
|
||||
HOST_BIN = host$(EXEEXT)
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
@ -161,7 +162,7 @@ VPATH =
|
||||
all: .built
|
||||
.PHONY: clean depend distclean preconfig
|
||||
|
||||
$(TARG1_COBJS) $(TARG1_MAINOBJ)$(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS): %$(OBJEXT): %.c
|
||||
$(TARG1_COBJS) $(TARG1_MAINOBJ) $(TARG2_COBJS) $(TARG2_MAINOBJ) $(TARGCMN_COBJS): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
$(TARG_BIN): $(TARG_OBJS) $(HOST_BIN)
|
||||
|
@ -83,7 +83,13 @@
|
||||
# define PF_INETX PF_INET
|
||||
#endif
|
||||
|
||||
#define PORTNO 5471
|
||||
#ifndef CONFIG_EXAMPLES_UDP_SERVER_PORTNO
|
||||
# define CONFIG_EXAMPLES_UDP_SERVER_PORTNO 5471
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_UDP_CLIENT_PORTNO
|
||||
# define CONFIG_EXAMPLES_UDP_CLIENT_PORTNO 5472
|
||||
#endif
|
||||
|
||||
#define ASCIISIZE (0x7f - 0x20)
|
||||
#define SENDSIZE (ASCIISIZE+1)
|
||||
@ -93,9 +99,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
uint16_t g_server_ipv6[8];
|
||||
uint16_t g_udpserver_ipv6[8];
|
||||
#else
|
||||
uint32_t g_server_ipv4;
|
||||
uint32_t g_udpserver_ipv4;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -103,11 +109,11 @@ uint32_t g_server_ipv4;
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_NETINIT
|
||||
int target_netinit(void);
|
||||
int udp_netinit(void);
|
||||
#endif
|
||||
|
||||
void parse_cmdline(int argc, char **argv);
|
||||
void send_client(void);
|
||||
void recv_server(void);
|
||||
void udp_cmdline(int argc, char **argv);
|
||||
void udp_client(void);
|
||||
void udp_server(void);
|
||||
|
||||
#endif /* __EXAMPLES_UDP_UDP_H */
|
||||
|
@ -57,6 +57,59 @@
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int create_socket(void)
|
||||
{
|
||||
socklen_t addrlen;
|
||||
int sockfd;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv4
|
||||
struct sockaddr_in addr;
|
||||
|
||||
/* Create a new IPv4 UDP socket */
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("client ERROR: client socket failure %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Bind the UDP socket to a IPv4 port */
|
||||
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = HTONS(CONFIG_EXAMPLES_UDP_CLIENT_PORTNO);
|
||||
addr.sin_addr.s_addr = HTONL(INADDR_ANY);
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
|
||||
#else
|
||||
struct sockaddr_in6 addr;
|
||||
|
||||
/* Create a new IPv6 UDP socket */
|
||||
|
||||
sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("client ERROR: client socket failure %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Bind the UDP socket to a IPv6 port */
|
||||
|
||||
addr.sin6_family = AF_INET6;
|
||||
addr.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_CLIENT_PORTNO);
|
||||
memset(addr.sin6_addr.s6_addr, 0, sizeof(struct in6_addr));
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
#endif
|
||||
|
||||
if (bind(sockfd, (FAR struct sockaddr *)&addr, addrlen) < 0)
|
||||
{
|
||||
printf("client ERROR: Bind failure: %d\n", errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
static inline void fill_buffer(unsigned char *buf, int offset)
|
||||
{
|
||||
int ch;
|
||||
@ -77,7 +130,7 @@ static inline void fill_buffer(unsigned char *buf, int offset)
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void send_client(void)
|
||||
void udp_client(void)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
struct sockaddr_in6 server;
|
||||
@ -92,10 +145,10 @@ void send_client(void)
|
||||
|
||||
/* Create a new UDP socket */
|
||||
|
||||
sockfd = socket(PF_INETX, SOCK_DGRAM, 0);
|
||||
sockfd = create_socket();
|
||||
if (sockfd < 0)
|
||||
{
|
||||
printf("client socket failure %d\n", errno);
|
||||
printf("client ERROR: create_socket failed %d\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -111,13 +164,13 @@ void send_client(void)
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
server.sin6_family = AF_INET6;
|
||||
server.sin6_port = HTONS(PORTNO);
|
||||
memcpy(server.sin6_addr.s6_addr16, g_server_ipv6, 8 * sizeof(uint16_t));
|
||||
server.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO);
|
||||
memcpy(server.sin6_addr.s6_addr16, g_udpserver_ipv6, 8 * sizeof(uint16_t));
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
#else
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = HTONS(PORTNO);
|
||||
server.sin_addr.s_addr = (in_addr_t)g_server_ipv4;
|
||||
server.sin_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO);
|
||||
server.sin_addr.s_addr = (in_addr_t)g_udpserver_ipv4;
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
#endif
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
uint16_t g_server_ipv6[8] =
|
||||
uint16_t g_udpserver_ipv6[8] =
|
||||
{
|
||||
HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_1),
|
||||
HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_2),
|
||||
@ -62,7 +62,7 @@ uint16_t g_server_ipv6[8] =
|
||||
HTONS(CONFIG_EXAMPLES_UDP_SERVERIPv6ADDR_8)
|
||||
};
|
||||
#else
|
||||
uint32_t g_server_ipv4 = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP);
|
||||
uint32_t g_udpserver_ipv4 = HTONL(CONFIG_EXAMPLES_UDP_SERVERIP);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -84,10 +84,10 @@ static void show_usage(FAR const char *progname)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* parse_cmdline
|
||||
* udp_cmdline
|
||||
****************************************************************************/
|
||||
|
||||
void parse_cmdline(int argc, char **argv)
|
||||
void udp_cmdline(int argc, char **argv)
|
||||
{
|
||||
/* Currently only a single command line option is supported: The server
|
||||
* IP address.
|
||||
@ -100,9 +100,9 @@ void parse_cmdline(int argc, char **argv)
|
||||
/* Convert the <server-addr> argument into a binary address */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
ret = inet_pton(AF_INET6, argv[1], g_server_ipv6);
|
||||
ret = inet_pton(AF_INET6, argv[1], g_udpserver_ipv6);
|
||||
#else
|
||||
ret = inet_pton(AF_INET, argv[1], &g_server_ipv4);
|
||||
ret = inet_pton(AF_INET, argv[1], &g_udpserver_ipv4);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/host.c
|
||||
* examples/udp/udp_host.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -56,14 +56,14 @@ int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
/* Parse any command line options */
|
||||
|
||||
parse_cmdline(argc, argv);
|
||||
udp_cmdline(argc, argv);
|
||||
|
||||
/* Run the server or client, depending upon how target1 was configured */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER1
|
||||
send_client();
|
||||
udp_client();
|
||||
#else
|
||||
recv_server();
|
||||
udp_server();
|
||||
#endif
|
||||
|
||||
return 0;
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/target_netinit.c
|
||||
* examples/udp/udp_netinit.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -117,10 +117,10 @@ static bool g_initialized;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* target_netinit
|
||||
* udp_netinit
|
||||
****************************************************************************/
|
||||
|
||||
int target_netinit(void)
|
||||
int udp_netinit(void)
|
||||
{
|
||||
if (!g_initialized)
|
||||
{
|
@ -84,7 +84,7 @@ static inline int check_buffer(unsigned char *buf)
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void recv_server(void)
|
||||
void udp_server(void)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
struct sockaddr_in6 server;
|
||||
@ -124,13 +124,13 @@ void recv_server(void)
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_IPv6
|
||||
server.sin6_family = AF_INET6;
|
||||
server.sin6_port = HTONS(PORTNO);
|
||||
server.sin6_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO);
|
||||
memset(&server.sin6_addr, 0, sizeof(struct in6_addr));
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
#else
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = HTONS(PORTNO);
|
||||
server.sin_port = HTONS(CONFIG_EXAMPLES_UDP_SERVER_PORTNO);
|
||||
server.sin_addr.s_addr = HTONL(INADDR_ANY);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/target1.c
|
||||
* examples/udp/udp_target1.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -58,20 +58,20 @@ int udp_main(int argc, char *argv[])
|
||||
{
|
||||
/* Parse any command line options */
|
||||
|
||||
parse_cmdline(argc, argv);
|
||||
udp_cmdline(argc, argv);
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_NETINIT
|
||||
/* Initialize the network */
|
||||
|
||||
(void)target_netinit();
|
||||
(void)udp_netinit();
|
||||
#endif
|
||||
|
||||
/* Run the server or client, depending upon how we are configured */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER1
|
||||
recv_server();
|
||||
udp_server();
|
||||
#else
|
||||
send_client();
|
||||
udp_client();
|
||||
#endif
|
||||
|
||||
return 0;
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/udp/target2.c
|
||||
* examples/udp/udp_target2.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -56,20 +56,20 @@ int udp2_main(int argc, char *argv[])
|
||||
{
|
||||
/* Parse any command line options */
|
||||
|
||||
parse_cmdline(argc, argv);
|
||||
udp_cmdline(argc, argv);
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_NETINIT
|
||||
/* Initialize the network */
|
||||
|
||||
(void)target_netinit();
|
||||
(void)udp_netinit();
|
||||
#endif
|
||||
|
||||
/* Run the server or client, depending upon how target1 was configured */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER1
|
||||
send_client();
|
||||
udp_client();
|
||||
#else
|
||||
recv_server();
|
||||
udp_server();
|
||||
#endif
|
||||
|
||||
return 0;
|
@ -112,6 +112,8 @@ int ieee802154_getcca(int fd, FAR struct ieee802154_cca_s *cca);
|
||||
|
||||
int ieee802154_getdevmode(int fd, FAR enum ieee802154_devmode_e *devmode);
|
||||
|
||||
int ieee802154_setassocpermit(int fd, bool assocpermit);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* Netork driver IOCTL helpers */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config SYSTEM_DHCPC
|
||||
config SYSTEM_DHCPC_RENEW
|
||||
bool "DHCP Address Renewal"
|
||||
default n
|
||||
select NETUTILS_DHCPC
|
||||
@ -11,9 +11,9 @@ config SYSTEM_DHCPC
|
||||
---help---
|
||||
Enble the DHCP client 'renew' command
|
||||
|
||||
if SYSTEM_DHCPC
|
||||
if SYSTEM_DHCPC_RENEW
|
||||
|
||||
config SYSTEM_DHCPC_PROGNAME
|
||||
config DHCPC_RENEW_PROGNAME
|
||||
string "Program name"
|
||||
default "renew"
|
||||
depends on BUILD_KERNEL
|
||||
@ -21,11 +21,11 @@ config SYSTEM_DHCPC_PROGNAME
|
||||
This is the name of the program that will be use when the NSH ELF
|
||||
program is installed.
|
||||
|
||||
config SYSTEM_DHCPC_PRIORITY
|
||||
config DHCPC_RENEW_PRIORITY
|
||||
int "DHCPC task priority"
|
||||
default 100
|
||||
|
||||
config SYSTEM_DHCPC_STACKSIZE
|
||||
config DHCPC_RENEW_STACKSIZE
|
||||
int "DHCPC stack size"
|
||||
default 2048
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_SYSTEM_DHCPC),y)
|
||||
ifeq ($(CONFIG_SYSTEM_DHCPC_RENEW),y)
|
||||
CONFIGURED_APPS += system/dhcpc
|
||||
endif
|
||||
|
||||
|
@ -39,31 +39,31 @@ include $(APPDIR)/Make.defs
|
||||
|
||||
# DHCPC address renewal built-in application info
|
||||
|
||||
CONFIG_SYSTEM_DHCPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
||||
CONFIG_SYSTEM_DHCPC_STACKSIZE ?= 2048
|
||||
CONFIG_DHCPC_RENEW_PRIORITY ?= SCHED_PRIORITY_DEFAULT
|
||||
CONFIG_DHCPC_RENEW_STACKSIZE ?= 2048
|
||||
|
||||
APPNAME = renew
|
||||
PRIORITY = $(CONFIG_SYSTEM_DHCPC_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_SYSTEM_DHCPC_STACKSIZE)
|
||||
RENEW_APPNAME = renew
|
||||
RENEW_PRIORITY = $(CONFIG_DHCPC_RENEW_PRIORITY)
|
||||
RENEW_STACKSIZE = $(CONFIG_DHCPC_RENEW_STACKSIZE)
|
||||
|
||||
CONFIG_SYSTEM_DHCPC_PROGNAME ?= renew$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_SYSTEM_DHCPC_PROGNAME)
|
||||
CONFIG_DHCPC_RENEW_PROGNAME ?= renew$(EXEEXT)
|
||||
RENEW_PROGNAME = $(CONFIG_DHCPC_RENEW_PROGNAME)
|
||||
|
||||
# DHCPC address renewal
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC = dhcpc_main.c
|
||||
RENEW_SRCS =
|
||||
RENEW_MAINSRC = renew_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
|
||||
RENEW_OBJS = $(RENEW_SRCS:.c=$(OBJEXT))
|
||||
RENEW_MAINOBJ = $(RENEW_MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
# Other DHCPC commands go here
|
||||
|
||||
SRCS = $(RENEW_SRCS) $(RENEW_MAINSRC)
|
||||
OBJS = $(RENEW_OBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
OBJS += $(MAINOBJ)
|
||||
OBJS += $(RENEW_MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
@ -91,10 +91,7 @@ VPATH =
|
||||
all: .built
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(OBJS) $(RENEW_MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
@ -102,12 +99,12 @@ $(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
@touch .built
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
$(BIN_DIR)$(DELIM)$(RENEW_PROGNAME): $(OBJS) $(RENEW_MAINOBJ)
|
||||
@echo "LD: $(RENEW_PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(RENEW_PROGNAME) $(ARCHCRT0OBJ) $(RENEW_MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(RENEW_PROGNAME)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
install: $(BIN_DIR)$(DELIM)$(RENEW_PROGNAME)
|
||||
|
||||
else
|
||||
install:
|
||||
@ -115,10 +112,10 @@ install:
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(RENEW_APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(RENEW_APPNAME),$(RENEW_PRIORITY),$(RENEW_STACKSIZE),$(RENEW_APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(RENEW_APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* system/dhcpc/dhcpc_main.c
|
||||
* system/dhcpc/renew_main.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -66,13 +66,13 @@ static void dhcpc_showusage(FAR const char *progname, int exitcode)
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* dhcpc_main
|
||||
* renew_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int dhcpc_main(int argc, char *argv[])
|
||||
int renew_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
FAR const char *devname;
|
@ -47,8 +47,9 @@ STACKSIZE = 4096
|
||||
# IEEE 802.15.4 SAK (Swiss Army Knife)
|
||||
|
||||
ASRCS =
|
||||
CSRCS = i8sak_acceptassoc.c i8sak_assoc.c i8sak_blaster.c i8sak_poll.c
|
||||
CSRCS += i8sak_sniffer.c i8sak_startpan.c i8sak_tx.c wpanlistener.c
|
||||
CSRCS = i8sak_acceptassoc.c i8sak_assoc.c i8sak_scan.c i8sak_blaster.c i8sak_poll.c
|
||||
CSRCS += i8sak_sniffer.c i8sak_startpan.c i8sak_tx.c i8sak_chan.c
|
||||
CSRCS += wpanlistener.c
|
||||
MAINSRC = i8sak_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
|
@ -146,7 +146,7 @@ struct i8sak_s
|
||||
|
||||
/* Settings */
|
||||
|
||||
uint8_t chnum;
|
||||
uint8_t chan;
|
||||
uint8_t chpage;
|
||||
struct ieee802154_addr_s addr;
|
||||
struct ieee802154_addr_s ep;
|
||||
@ -154,6 +154,9 @@ struct i8sak_s
|
||||
uint8_t payload[IEEE802154_MAX_MAC_PAYLOAD_SIZE];
|
||||
uint16_t payload_len;
|
||||
int blasterperiod;
|
||||
|
||||
struct ieee802154_pandesc_s pandescs[CONFIG_MAC802154_NPANDESC];
|
||||
uint8_t npandesc;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -175,10 +178,12 @@ bool i8sak_str2bool(FAR const char *str);
|
||||
void i8sak_startpan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_acceptassoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_assoc_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_scan_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_tx_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_poll_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_sniffer_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_blaster_cmd (FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]);
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
|
@ -76,6 +76,7 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
|
||||
bool acceptall = true; /* start off assuming we are going to allow all connections */
|
||||
int option;
|
||||
int optcnt;
|
||||
int fd;
|
||||
|
||||
optcnt = 0;
|
||||
while ((option = getopt(argc, argv, ":he:")) != ERROR)
|
||||
@ -115,6 +116,15 @@ void i8sak_acceptassoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[]
|
||||
}
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("cannot open %s, errno=%d\n", i8sak->devname, errno);
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
ieee802154_setassocpermit(fd, true);
|
||||
|
||||
if (!optcnt)
|
||||
{
|
||||
i8sak->acceptall = acceptall;
|
||||
|
@ -79,10 +79,12 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
{
|
||||
struct ieee802154_assoc_req_s assocreq;
|
||||
struct wpanlistener_eventfilter_s filter;
|
||||
FAR struct ieee802154_pandesc_s *pandesc;
|
||||
int fd;
|
||||
int option;
|
||||
int optcnt;
|
||||
int ret;
|
||||
uint8_t resindex;
|
||||
|
||||
/* If the addresses has never been automatically or manually set before, set
|
||||
* it assuming that we are the default device address and the endpoint is the
|
||||
@ -96,7 +98,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
}
|
||||
|
||||
optcnt = 0;
|
||||
while ((option = getopt(argc, argv, ":hs:e:")) != ERROR)
|
||||
while ((option = getopt(argc, argv, ":hr:s:e:")) != ERROR)
|
||||
{
|
||||
optcnt++;
|
||||
switch (option)
|
||||
@ -105,12 +107,31 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
fprintf(stderr, "Requests association with endpoint\n"
|
||||
"Usage: %s [-h]\n"
|
||||
" -h = this help menu\n"
|
||||
" -r = use scan result index\n"
|
||||
, argv[0]);
|
||||
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
return;
|
||||
case 'r':
|
||||
resindex = i8sak_str2luint8(optarg);
|
||||
|
||||
if (resindex >= i8sak->npandesc)
|
||||
{
|
||||
fprintf(stderr, "ERROR: missing argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
}
|
||||
|
||||
pandesc = &i8sak->pandescs[resindex];
|
||||
|
||||
i8sak->chan = pandesc->chan;
|
||||
i8sak->chpage = pandesc->chpage;
|
||||
memcpy(&i8sak->ep, &pandesc->coordaddr, sizeof(struct ieee802154_addr_s));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
/* Parse extended address and put it into the i8sak instance */
|
||||
@ -158,15 +179,6 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
/* TODO: Perform a scan operation here, to determine addressing information
|
||||
* of coordinator.
|
||||
*/
|
||||
|
||||
fprintf(stderr, "i8sak: scan not implemented. Using default values\n");
|
||||
}
|
||||
|
||||
/* Register new callback for receiving the association notifications */
|
||||
|
||||
memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));
|
||||
@ -177,7 +189,7 @@ void i8sak_assoc_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
|
||||
printf("i8sak: issuing ASSOC. request\n");
|
||||
|
||||
assocreq.chnum = i8sak->chnum;
|
||||
assocreq.chan = i8sak->chan;
|
||||
assocreq.chpage = i8sak->chpage;
|
||||
|
||||
memcpy(&assocreq.coordaddr, &i8sak->ep, sizeof(struct ieee802154_addr_s));
|
||||
|
139
wireless/ieee802154/i8sak/i8sak_chan.c
Normal file
139
wireless/ieee802154/i8sak/i8sak_chan.c
Normal file
@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/i8sak/i8sak_chan.c
|
||||
* IEEE 802.15.4 Swiss Army Knife
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#include "i8sak.h"
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name : i8sak_chan_cmd
|
||||
*
|
||||
* Description :
|
||||
* Try and extract data from the coordinator
|
||||
****************************************************************************/
|
||||
|
||||
void i8sak_chan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
{
|
||||
int option;
|
||||
int fd;
|
||||
int argind;
|
||||
bool getchan = false;
|
||||
uint8_t channel;
|
||||
|
||||
argind = 1;
|
||||
while ((option = getopt(argc, argv, ":hg")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
argind++;
|
||||
case 'h':
|
||||
fprintf(stderr, "Polls coordinator for data\n"
|
||||
"Usage: %s [-h]\n"
|
||||
" -h = this help menu\n"
|
||||
, argv[0]);
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
return;
|
||||
case 'g':
|
||||
getchan = true;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fprintf(stderr, "ERROR: missing argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
case '?':
|
||||
fprintf(stderr, "ERROR: unknown argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
}
|
||||
}
|
||||
|
||||
if (!getchan)
|
||||
{
|
||||
if (argc < argind + 1)
|
||||
{
|
||||
fprintf(stderr, "ERROR: missing channel\n");
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
}
|
||||
|
||||
channel = i8sak_str2luint8(argv[argind]);
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("cannot open %s, errno=%d\n", i8sak->devname, errno);
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
if (getchan)
|
||||
{
|
||||
ieee802154_getchan(fd, &channel);
|
||||
printf("i8sak: Channel: %d\n", (int)channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("i8sak: Setting Channel: %d\n", (int)channel);
|
||||
ieee802154_setchan(fd, channel);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
@ -104,10 +104,12 @@ static const struct i8sak_command_s g_i8sak_commands[] =
|
||||
{"startpan", (CODE void *)i8sak_startpan_cmd},
|
||||
{"acceptassoc", (CODE void *)i8sak_acceptassoc_cmd},
|
||||
{"assoc", (CODE void *)i8sak_assoc_cmd},
|
||||
{"scan", (CODE void *)i8sak_scan_cmd},
|
||||
{"tx", (CODE void *)i8sak_tx_cmd},
|
||||
{"poll", (CODE void *)i8sak_poll_cmd},
|
||||
{"sniffer", (CODE void *)i8sak_sniffer_cmd},
|
||||
{"blaster", (CODE void *)i8sak_blaster_cmd},
|
||||
{"chan", (CODE void *)i8sak_chan_cmd},
|
||||
};
|
||||
|
||||
#define NCOMMANDS (sizeof(g_i8sak_commands) / sizeof(struct i8sak_command_s))
|
||||
@ -559,7 +561,7 @@ static int i8sak_setup(FAR struct i8sak_s *i8sak, FAR const char *devname)
|
||||
i8sak->daemon_started = false;
|
||||
i8sak->daemon_shutdown = false;
|
||||
|
||||
i8sak->chnum = CONFIG_IEEE802154_I8SAK_CHNUM;
|
||||
i8sak->chan = CONFIG_IEEE802154_I8SAK_CHNUM;
|
||||
i8sak->chpage = CONFIG_IEEE802154_I8SAK_CHPAGE;
|
||||
|
||||
if (strlen(devname) > I8SAK_MAX_DEVNAME)
|
||||
@ -730,11 +732,13 @@ static int i8sak_showusage(FAR const char *progname, int exitcode)
|
||||
fprintf(stderr, "Usage: %s\n"
|
||||
" startpan [-h]\n"
|
||||
" acceptassoc [-h|e <eaddr>]\n"
|
||||
" assoc [-h] [<panid>] \n"
|
||||
" scan [-h|p|a|e] minch-maxch\n"
|
||||
" assoc [-h] [<panid>]\n"
|
||||
" tx [-h|d] <hex-payload>\n"
|
||||
" poll [-h]\n"
|
||||
" blaster [-h|q|f <hex payload>|p <period_ms>]\n"
|
||||
" sniffer [-h|q]\n"
|
||||
" chan [-h|g] [<chan>]"
|
||||
, progname);
|
||||
exit(exitcode);
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
ret = OK;
|
||||
while ((option = getopt(argc, argv, ":h")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
@ -112,11 +111,6 @@ void i8sak_poll_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != OK)
|
||||
{
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
|
253
wireless/ieee802154/i8sak/i8sak_scan.c
Normal file
253
wireless/ieee802154/i8sak/i8sak_scan.c
Normal file
@ -0,0 +1,253 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/i8sak/i8sak_scan.c
|
||||
* IEEE 802.15.4 Swiss Army Knife
|
||||
*
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
*
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
* Author: Gregory Nuttx <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
|
||||
#include "i8sak.h"
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_ioctl.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static void scan_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name : i8sak_scan_cmd
|
||||
*
|
||||
* Description :
|
||||
* Request association with the Coordinator
|
||||
****************************************************************************/
|
||||
|
||||
void i8sak_scan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
{
|
||||
struct ieee802154_scan_req_s scan;
|
||||
struct wpanlistener_eventfilter_s filter;
|
||||
int fd;
|
||||
int option;
|
||||
int argind;
|
||||
int i;
|
||||
int minchannel;
|
||||
int maxchannel;
|
||||
|
||||
scan.type = IEEE802154_SCANTYPE_PASSIVE;
|
||||
|
||||
argind = 1;
|
||||
while ((option = getopt(argc, argv, ":hpae")) != ERROR)
|
||||
{
|
||||
argind++;
|
||||
switch (option)
|
||||
{
|
||||
case 'h':
|
||||
fprintf(stderr, "Requests association with endpoint\n"
|
||||
"Usage: %s [-h|p|a|e] minCh-maxCh\n"
|
||||
" -h = this help menu\n"
|
||||
" -p = passive scan (default)\n"
|
||||
" -a = active scan\n"
|
||||
" -e = energy scan\n"
|
||||
, argv[0]);
|
||||
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
return;
|
||||
|
||||
case 'p':
|
||||
scan.type = IEEE802154_SCANTYPE_PASSIVE;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
scan.type = IEEE802154_SCANTYPE_ACTIVE;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
scan.type = IEEE802154_SCANTYPE_ED;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fprintf(stderr, "ERROR: missing argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
|
||||
case '?':
|
||||
fprintf(stderr, "ERROR: unknown argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak); /* This exits for us */
|
||||
}
|
||||
}
|
||||
|
||||
/* There should always be one argument after the list option argument */
|
||||
|
||||
if (argc != argind + 1)
|
||||
{
|
||||
fprintf(stderr, "ERROR: invalid channel list\n");
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
scan.duration = 5;
|
||||
scan.chpage = i8sak->chpage;
|
||||
|
||||
/* Parse channel list */
|
||||
|
||||
sscanf(argv[argind], "%d-%d", &minchannel, &maxchannel);
|
||||
|
||||
scan.numchan = maxchannel - minchannel + 1;
|
||||
|
||||
if (scan.numchan > 15)
|
||||
{
|
||||
fprintf(stderr, "ERROR: too many channels\n");
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
for (i = 0; i < scan.numchan; i++)
|
||||
{
|
||||
scan.channels[i] = minchannel + i;
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
printf("i8sak: cannot open %s, errno=%d\n", i8sak->devname, errno);
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
/* Register new callback for receiving the scan confirmation notification */
|
||||
|
||||
memset(&filter, 0, sizeof(struct wpanlistener_eventfilter_s));
|
||||
filter.confevents.scan = true;
|
||||
|
||||
wpanlistener_add_eventreceiver(&i8sak->wpanlistener, scan_eventcb, &filter,
|
||||
(FAR void *)i8sak, true);
|
||||
|
||||
printf("i8sak: starting scan\n");
|
||||
|
||||
ieee802154_scan_req(fd, &scan);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void scan_eventcb(FAR struct ieee802154_notif_s *notif, FAR void *arg)
|
||||
{
|
||||
FAR struct i8sak_s *i8sak = (FAR struct i8sak_s *)arg;
|
||||
FAR struct ieee802154_scan_conf_s *scan = ¬if->u.scanconf;
|
||||
int i;
|
||||
|
||||
printf("\n\ni8sak: Scan complete: %s\n",
|
||||
IEEE802154_STATUS_STRING[scan->status]);
|
||||
|
||||
printf("Scan type: ");
|
||||
|
||||
switch (scan->type)
|
||||
{
|
||||
case IEEE802154_SCANTYPE_ACTIVE:
|
||||
printf("Active\n");
|
||||
break;
|
||||
case IEEE802154_SCANTYPE_PASSIVE:
|
||||
printf("Passive\n");
|
||||
break;
|
||||
case IEEE802154_SCANTYPE_ED:
|
||||
printf("Energy\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Copy the results from the notification */
|
||||
|
||||
i8sak->npandesc = scan->numdesc;
|
||||
memcpy(i8sak->pandescs, scan->pandescs,
|
||||
sizeof(struct ieee802154_pandesc_s) * i8sak->npandesc);
|
||||
|
||||
printf("Scan results: \n");
|
||||
|
||||
for (i = 0; i < scan->numdesc; i++)
|
||||
{
|
||||
printf("Result %d\n", i);
|
||||
printf(" Channel: %u\n", scan->pandescs[i].chan);
|
||||
printf(" PAN ID: %02X:%02X\n",
|
||||
scan->pandescs[i].coordaddr.panid[0],
|
||||
scan->pandescs[i].coordaddr.panid[1]);
|
||||
|
||||
if (scan->pandescs[i].coordaddr.mode == IEEE802154_ADDRMODE_SHORT)
|
||||
{
|
||||
printf(" Coordinator saddr: %02X:%02X\n",
|
||||
scan->pandescs[i].coordaddr.saddr[0],
|
||||
scan->pandescs[i].coordaddr.saddr[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" Coordinator eaddr: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
scan->pandescs[i].coordaddr.eaddr[0],
|
||||
scan->pandescs[i].coordaddr.eaddr[1],
|
||||
scan->pandescs[i].coordaddr.eaddr[2],
|
||||
scan->pandescs[i].coordaddr.eaddr[3],
|
||||
scan->pandescs[i].coordaddr.eaddr[4],
|
||||
scan->pandescs[i].coordaddr.eaddr[5],
|
||||
scan->pandescs[i].coordaddr.eaddr[6],
|
||||
scan->pandescs[i].coordaddr.eaddr[7]);
|
||||
}
|
||||
}
|
||||
}
|
@ -73,11 +73,12 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
{
|
||||
struct ieee802154_reset_req_s resetreq;
|
||||
struct ieee802154_start_req_s startreq;
|
||||
bool beaconenabled = false;
|
||||
int option;
|
||||
int fd;
|
||||
int i;
|
||||
|
||||
while ((option = getopt(argc, argv, ":h")) != ERROR)
|
||||
while ((option = getopt(argc, argv, ":hb")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@ -85,11 +86,15 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
fprintf(stderr, "Starts PAN as PAN Coordinator\n"
|
||||
"Usage: %s [-h]\n"
|
||||
" -h = this help menu\n"
|
||||
" -b = start beacon-enabled PAN\n"
|
||||
, argv[0]);
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
|
||||
optind = -1;
|
||||
return;
|
||||
case 'b':
|
||||
beaconenabled = true;
|
||||
break;
|
||||
case ':':
|
||||
fprintf(stderr, "ERROR: missing argument\n");
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
@ -184,11 +189,22 @@ void i8sak_startpan_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
printf("i8sak: starting PAN\n");
|
||||
|
||||
IEEE802154_PANIDCOPY(startreq.panid, i8sak->addr.panid);
|
||||
startreq.chnum = i8sak->chnum;
|
||||
startreq.chan = i8sak->chan;
|
||||
startreq.chpage = i8sak->chpage;
|
||||
startreq.beaconorder = 15;
|
||||
startreq.pancoord = true;
|
||||
|
||||
if (beaconenabled)
|
||||
{
|
||||
startreq.beaconorder = 6;
|
||||
startreq.superframeorder = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
startreq.beaconorder = 15;
|
||||
}
|
||||
|
||||
startreq.pancoord = true;
|
||||
startreq.coordrealign = false;
|
||||
startreq.battlifeext = false;
|
||||
|
||||
ieee802154_start_req(fd, &startreq);
|
||||
|
||||
|
@ -80,6 +80,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
enum ieee802154_devmode_e devmode;
|
||||
struct wpanlistener_eventfilter_s eventfilter;
|
||||
bool sendasdev = false;
|
||||
bool sendmax = false;
|
||||
int argind;
|
||||
int option;
|
||||
int fd;
|
||||
@ -87,7 +88,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
|
||||
ret = OK;
|
||||
argind = 1;
|
||||
while ((option = getopt(argc, argv, ":hd")) != ERROR)
|
||||
while ((option = getopt(argc, argv, ":hdm")) != ERROR)
|
||||
{
|
||||
switch (option)
|
||||
{
|
||||
@ -96,6 +97,7 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
"Usage: %s [-h|d] [<hex-payload>]\n"
|
||||
" -h = this help menu\n"
|
||||
" -d = send as device instead of coord\n"
|
||||
" -m = send the largest frame possible"
|
||||
, argv[0]);
|
||||
|
||||
/* Must manually reset optind if we are going to exit early */
|
||||
@ -108,6 +110,11 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
argind++;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
sendmax = true;
|
||||
argind++;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
fprintf(stderr, "ERROR: missing argument\n");
|
||||
|
||||
@ -119,20 +126,21 @@ void i8sak_tx_cmd(FAR struct i8sak_s *i8sak, int argc, FAR char *argv[])
|
||||
case '?':
|
||||
fprintf(stderr, "ERROR: unknown argument\n");
|
||||
ret = ERROR;
|
||||
break;
|
||||
optind = -1;
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != OK)
|
||||
{
|
||||
i8sak_cmd_error(i8sak);
|
||||
}
|
||||
|
||||
if (argc == argind + 1)
|
||||
{
|
||||
i8sak->payload_len = i8sak_str2payload(argv[1], &i8sak->payload[0]);
|
||||
}
|
||||
|
||||
if (sendmax)
|
||||
{
|
||||
i8sak->payload_len = IEEE802154_MAX_SAFE_MAC_PAYLOAD_SIZE;
|
||||
}
|
||||
|
||||
fd = open(i8sak->devname, O_RDWR);
|
||||
if (fd < 0)
|
||||
{
|
||||
|
@ -47,16 +47,16 @@ CSRCS += ieee802154_resetreq.c ieee802154_rxenabreq.c ieee802154_scanreq.c
|
||||
CSRCS += ieee802154_setreq.c ieee802154_startreq.c ieee802154_syncreq.c
|
||||
CSRCS += ieee802154_pollreq.c ieee802154_enableevents.c
|
||||
# Add Get/Set Attribute helpers
|
||||
CSRCS += ieee802154_setchan.c ieee802154_getchan.c
|
||||
CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c
|
||||
CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c
|
||||
CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c
|
||||
CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c
|
||||
CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c
|
||||
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
|
||||
CSRCS += ieee802154_getdevmode.c
|
||||
CSRCS += ieee802154_setchan.c ieee802154_getchan.c
|
||||
CSRCS += ieee802154_setpanid.c ieee802154_getpanid.c
|
||||
CSRCS += ieee802154_setsaddr.c ieee802154_getsaddr.c
|
||||
CSRCS += ieee802154_seteaddr.c ieee802154_geteaddr.c
|
||||
CSRCS += ieee802154_setpromisc.c ieee802154_getpromisc.c
|
||||
CSRCS += ieee802154_setrxonidle.c ieee802154_getrxonidle.c
|
||||
CSRCS += ieee802154_settxpwr.c ieee802154_gettxpwr.c
|
||||
CSRCS += ieee802154_getdevmode.c ieee802154_setassocpermit.c
|
||||
|
||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||
ifeq ($(CONFIG_NET_6LOWPAN),y)
|
||||
# Add Get/Set Attribute helpers
|
||||
CSRCS += sixlowpan_assocreq.c sixlowpan_assocresp.c sixlowpan_disassocreq.c
|
||||
CSRCS += sixlowpan_getreq.c sixlowpan_gtsreq.c sixlowpan_orphanresp.c
|
||||
@ -64,14 +64,14 @@ CSRCS += sixlowpan_resetreq.c sixlowpan_rxenabreq.c sixlowpan_scanreq.c
|
||||
CSRCS += sixlowpan_setreq.c sixlowpan_startreq.c sixlowpan_syncreq.c
|
||||
CSRCS += sixlowpan_pollreq.c
|
||||
# Add IOCTL helpers
|
||||
CSRCS += sixlowpan_setchan.c sixlowpan_getchan.c
|
||||
CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c
|
||||
CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c
|
||||
CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c
|
||||
CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c
|
||||
CSRCS += sixlowpan_setrxonidle.c sixlowpan_getrxonidle.c
|
||||
CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c
|
||||
endif
|
||||
CSRCS += sixlowpan_setchan.c sixlowpan_getchan.c
|
||||
CSRCS += sixlowpan_setpanid.c sixlowpan_getpanid.c
|
||||
CSRCS += sixlowpan_setsaddr.c sixlowpan_getsaddr.c
|
||||
CSRCS += sixlowpan_seteaddr.c sixlowpan_geteaddr.c
|
||||
CSRCS += sixlowpan_setpromisc.c sixlowpan_getpromisc.c
|
||||
CSRCS += sixlowpan_setrxonidle.c sixlowpan_getrxonidle.c
|
||||
CSRCS += sixlowpan_settxpwr.c sixlowpan_gettxpwr.c
|
||||
endif
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
|
@ -58,10 +58,10 @@ int ieee802154_getchan(int fd, FAR uint8_t *chan)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL;
|
||||
req.attr = IEEE802154_ATTR_PHY_CHAN;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
*chan = req.attrval.phy.channel;
|
||||
*chan = req.attrval.phy.chan;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int ieee802154_geteaddr(int fd, FAR uint8_t *eaddr)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
req.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
|
||||
|
@ -58,7 +58,7 @@ int ieee802154_getsaddr(int fd, FAR uint8_t *saddr)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
ret = ieee802154_get_req(fd, &req);
|
||||
|
||||
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
|
||||
|
64
wireless/ieee802154/libmac/ieee802154_setassocpermit.c
Normal file
64
wireless/ieee802154/libmac/ieee802154_setassocpermit.c
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* apps/wireless/ieee802154/libmac/ieee802154_assocpermit.c
|
||||
*
|
||||
* Copyright (C) 2017 Verge Inc. All rights reserved.
|
||||
* Author: Anthony Merlino <anthony@vergeaero.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "wireless/ieee802154.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_setassocpermit(int fd, bool assocpermit)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_ASSOCIATION_PERMIT;
|
||||
req.attrval.mac.assocpermit = assocpermit;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
@ -57,8 +57,8 @@ int ieee802154_setchan(int fd, uint8_t chan)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL;
|
||||
req.attrval.phy.channel = chan;
|
||||
req.attr = IEEE802154_ATTR_PHY_CHAN;
|
||||
req.attrval.phy.chan = chan;
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int ieee802154_seteaddr(int fd, FAR const uint8_t *eaddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
req.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
|
@ -58,7 +58,7 @@ int ieee802154_setsaddr(int fd, FAR const uint8_t *saddr)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
|
||||
|
||||
return ieee802154_set_req(fd, &req);
|
||||
|
@ -58,10 +58,10 @@ int sixlowpan_getchan(int sock, FAR const char *ifname, FAR uint8_t *chan)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL;
|
||||
req.attr = IEEE802154_ATTR_PHY_CHAN;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
*chan = req.attrval.phy.channel;
|
||||
*chan = req.attrval.phy.chan;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int sixlowpan_geteaddr(int sock, FAR const char *ifname, FAR uint8_t *eaddr)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
req.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
IEEE802154_EADDRCOPY(eaddr, req.attrval.mac.eaddr);
|
||||
|
@ -58,7 +58,7 @@ int sixlowpan_getsaddr(int sock, FAR const char *ifname, FAR uint8_t *saddr)
|
||||
struct ieee802154_get_req_s req;
|
||||
int ret;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
ret = sixlowpan_get_req(sock, ifname, &req);
|
||||
|
||||
IEEE802154_SADDRCOPY(saddr, req.attrval.mac.saddr);
|
||||
|
@ -57,8 +57,8 @@ int sixlowpan_setchan(int sock, FAR const char *ifname, uint8_t chan)
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_PHY_CURRENT_CHANNEL;
|
||||
req.attrval.phy.channel = chan;
|
||||
req.attr = IEEE802154_ATTR_PHY_CHAN;
|
||||
req.attrval.phy.chan = chan;
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ int sixlowpan_seteaddr(int sock, FAR const char *ifname, FAR const uint8_t *eadd
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_EXTENDED_ADDR;
|
||||
req.attr = IEEE802154_ATTR_MAC_EADDR;
|
||||
IEEE802154_EADDRCOPY(req.attrval.mac.eaddr, eaddr);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
|
@ -57,7 +57,7 @@ int sixlowpan_setsaddr(int sock, FAR const char *ifname, FAR const uint8_t *sadd
|
||||
{
|
||||
struct ieee802154_set_req_s req;
|
||||
|
||||
req.attr = IEEE802154_ATTR_MAC_SHORT_ADDRESS;
|
||||
req.attr = IEEE802154_ATTR_MAC_SADDR;
|
||||
IEEE802154_SADDRCOPY(req.attrval.mac.saddr, saddr);
|
||||
|
||||
return sixlowpan_set_req(sock, ifname, &req);
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
ifeq ($(CONFIG_WIRELESS_IWPAN),y)
|
||||
|
||||
CSRCS =
|
||||
CSRCS =
|
||||
MAINSRC = iwpan.c
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
|
@ -1,16 +1,16 @@
|
||||
Copyright (c) 2010, Volkan YAZICI <volkan.yazici@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
Loading…
Reference in New Issue
Block a user