Add apps/exemples/udpblaster
This commit is contained in:
parent
7557ef9803
commit
2e0d0ede6d
@ -1430,4 +1430,6 @@
|
||||
explicit expansion in all cases. From Stefan Kolb (2015-09-03).
|
||||
* apps/canutils/uavcan: Add support for libuavcan. From Paul
|
||||
Alexander Patience (2015-09-25).
|
||||
* apps/examples/udpblaster: Add a test to stress the network by
|
||||
sending UDP packets at a very high rate. (2015-09-30).
|
||||
|
||||
|
@ -75,6 +75,7 @@ source "$APPSDIR/examples/timer/Kconfig"
|
||||
source "$APPSDIR/examples/tiff/Kconfig"
|
||||
source "$APPSDIR/examples/touchscreen/Kconfig"
|
||||
source "$APPSDIR/examples/udp/Kconfig"
|
||||
source "$APPSDIR/examples/udpblaster/Kconfig"
|
||||
source "$APPSDIR/examples/discover/Kconfig"
|
||||
source "$APPSDIR/examples/webserver/Kconfig"
|
||||
source "$APPSDIR/examples/unionfs/Kconfig"
|
||||
|
@ -1872,6 +1872,14 @@ examples/udp
|
||||
|
||||
CONFIG_NETUTILS_NETLIB=y
|
||||
|
||||
examples/udpblaster
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is a simple network test for stressing UDP transfers. It simply
|
||||
sends UDP packets from both the host and the target and the highest ratei
|
||||
possible.
|
||||
|
||||
|
||||
examples/unionfs
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
|
16
examples/udpblaster/.gitignore
vendored
Normal file
16
examples/udpblaster/.gitignore
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/host
|
||||
/config.h
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
||||
/*.hobj
|
||||
/*.exe
|
||||
/*.dSYM
|
325
examples/udpblaster/Kconfig
Normal file
325
examples/udpblaster/Kconfig
Normal file
@ -0,0 +1,325 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config EXAMPLES_UDPBLASTER
|
||||
bool "UDP blaster example"
|
||||
default n
|
||||
depends on NET_UDP
|
||||
---help---
|
||||
Enable the network test example
|
||||
|
||||
if EXAMPLES_UDPBLASTER
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTRATE
|
||||
int "Host send rate (bits/second)"
|
||||
default 800000
|
||||
|
||||
choice
|
||||
prompt "IP Domain"
|
||||
default EXAMPLES_UDPBLASTER_IPv4 if NET_IPv4
|
||||
default EXAMPLES_UDPBLASTER_IPv6 if NET_IPv6 && !NET_IPv4
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv4
|
||||
bool "IPv4"
|
||||
depends on NET_IPv4
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6
|
||||
bool "IPv6"
|
||||
depends on NET_IPv6
|
||||
|
||||
endchoice # IP Domain
|
||||
|
||||
config EXAMPLES_UDPBLASTER_INIT
|
||||
bool "Initialize network"
|
||||
default n if NSH_BUILTIN_APPS
|
||||
default y if !NSH_BUILTIN_APPS
|
||||
depends on !BUILD_KERNEL && !EXAMPLES_UDPBLASTER_LOOPBACK
|
||||
---help---
|
||||
Include logic to initialize the network. This should not be done if
|
||||
the network is already initialized when udpblaster runs. This is
|
||||
usually the case, for example, when udpblaster is run as an NSH built-
|
||||
in task.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_NOMAC
|
||||
bool "Use Canned MAC Address"
|
||||
default n
|
||||
depends on EXAMPLES_UDPBLASTER_INIT
|
||||
|
||||
if EXAMPLES_UDPBLASTER_IPv4
|
||||
|
||||
comment "IPv4 addresses"
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIP
|
||||
hex "Target IP address"
|
||||
default 0x0a000002
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIP
|
||||
hex "Host IP address)"
|
||||
default 0x0a000001
|
||||
|
||||
if EXAMPLES_UDPBLASTER_INIT
|
||||
|
||||
config EXAMPLES_UDPBLASTER_NETMASK
|
||||
hex "Network Mask"
|
||||
default 0xffffff00
|
||||
|
||||
endif # EXAMPLES_UDPBLASTER_INIT
|
||||
endif # EXAMPLES_UDPBLASTER_IPv4
|
||||
|
||||
if EXAMPLES_UDPBLASTER_IPv6
|
||||
if !NET_ICMPv6_AUTOCONF
|
||||
|
||||
comment "Target IPv6 address"
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the first of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the second of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the third of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the fourth of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the fifth of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the sixth of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the seventh of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_TARGETIPv6_8
|
||||
hex "[7]"
|
||||
default 0x0002
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Target IPv6 address. This is a 16-bit integer value in host order.
|
||||
Each of the eight values forming the full IP address must be
|
||||
specified individually. This is the last of the 8-values. The
|
||||
default for all eight values is fc00::2.
|
||||
|
||||
comment "Router IPv6 address"
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_1
|
||||
hex "[0]"
|
||||
default 0xfc00
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the first of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_2
|
||||
hex "[1]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the second of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_3
|
||||
hex "[2]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the third of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_4
|
||||
hex "[3]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fourth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_5
|
||||
hex "[4]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the fifth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_6
|
||||
hex "[5]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the sixth of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_7
|
||||
hex "[6]"
|
||||
default 0x0000
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the seventh of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_HOSTIPv6_8
|
||||
hex "[7]"
|
||||
default 0x0001
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Default router IP address (aka, Gateway). This is a 16-bit integer
|
||||
value in host order. Each of the eight values forming the full IP
|
||||
address must be specified individually. This is the last of the
|
||||
8-values. The default for all eight values is fc00::1.
|
||||
|
||||
if EXAMPLES_UDPBLASTER_INIT
|
||||
|
||||
comment "IPv6 Network mask"
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_1
|
||||
hex "[0]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the first of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_2
|
||||
hex "[1]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the second of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_3
|
||||
hex "[2]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the third of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_4
|
||||
hex "[3]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fourth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_5
|
||||
hex "[4]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the fifth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_6
|
||||
hex "[5]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the sixth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_7
|
||||
hex "[6]"
|
||||
default 0xffff
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the seventh of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
config EXAMPLES_UDPBLASTER_IPv6NETMASK_8
|
||||
hex "[7]"
|
||||
default 0xff80
|
||||
range 0x0 0xffff
|
||||
---help---
|
||||
Network mask. This is a 16-bit integer value in host order. Each
|
||||
of the eight values forming the full IP address must be specified
|
||||
individually. This is the eighth of the 8-values. The default for
|
||||
all eight values is fe00::0.
|
||||
|
||||
endif # NET_ICMPv6_AUTOCONF
|
||||
endif # EXAMPLES_UDPBLASTER_INIT
|
||||
endif # EXAMPLES_UDPBLASTER_IPv6
|
||||
endif # EXAMPLES_UDPBLASTER
|
39
examples/udpblaster/Make.defs
Normal file
39
examples/udpblaster/Make.defs
Normal file
@ -0,0 +1,39 @@
|
||||
############################################################################
|
||||
# apps/examples/udpblaster/Make.defs
|
||||
# Adds selected applications to apps/ build
|
||||
#
|
||||
# Copyright (C) 2015 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_EXAMPLES_UDPBLASTER),y)
|
||||
CONFIGURED_APPS += examples/udpblaster
|
||||
endif
|
169
examples/udpblaster/Makefile
Normal file
169
examples/udpblaster/Makefile
Normal file
@ -0,0 +1,169 @@
|
||||
############################################################################
|
||||
# examples/udpblaster/Makefile
|
||||
#
|
||||
# Copyright (C) 2015 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
-include $(TOPDIR)/.config
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Basic TCP networking test
|
||||
|
||||
TARG_ASRCS =
|
||||
TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT))
|
||||
|
||||
TARG_CSRCS = udpblaster_text.c
|
||||
TARG_MAINSRC = udpblaster_target.c
|
||||
|
||||
TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT))
|
||||
TARG_MAINOBJ = $(TARG_MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) $(TARG_CSRCS)
|
||||
TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
TARG_OBJS += $(TARG_MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
TARG_BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
TARG_BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
TARG_BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
HOSTCFLAGS += -DUDPBLASTER_HOST=1
|
||||
|
||||
HOST_SRCS = udpblaster_host.c udpblaster_text.c
|
||||
|
||||
HOSTOBJEXT ?= .hobj
|
||||
HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT))
|
||||
HOST_BIN = host
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
|
||||
else
|
||||
INSTALL_DIR = $(BIN_DIR)
|
||||
endif
|
||||
|
||||
CONFIG_XYZ_PROGNAME ?= udpblaster$(EXEEXT)
|
||||
PROGNAME = $(CONFIG_XYZ_PROGNAME)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# NET test built-in application info
|
||||
|
||||
APPNAME = udpblaster
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built $(HOST_BIN)
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(TARG_AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_UDPBLASTER_LOOPBACK),y)
|
||||
$(HOST_OBJS): %$(HOSTOBJEXT): %.c
|
||||
@echo "CC: $<"
|
||||
$(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
|
||||
endif
|
||||
|
||||
config.h: $(TOPDIR)/include/nuttx/config.h
|
||||
@echo "CP: $<"
|
||||
$(Q) cp $< $@
|
||||
|
||||
ifneq ($(CONFIG_EXAMPLES_UDPBLASTER_LOOPBACK),y)
|
||||
$(HOST_BIN): config.h $(HOST_OBJS)
|
||||
@echo "LD: $@"
|
||||
$(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
|
||||
endif
|
||||
|
||||
.built: config.h $(TARG_OBJS)
|
||||
$(call ARCHIVE, $(TARG_BIN), $(TARG_OBJS))
|
||||
$(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)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
else
|
||||
install:
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
.depend: Makefile config.h $(TARG_SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
ifneq ($(CONFIG_EXAMPLES_UDPBLASTER_LOOPBACK),y)
|
||||
$(call DELFILE, *$(HOSTOBJEXT))
|
||||
$(call DELFILE, $(HOST_BIN))
|
||||
endif
|
||||
$(call DELFILE, .built)
|
||||
$(call DELFILE, *.dSYM)
|
||||
$(call DELFILE, config.h)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
||||
|
127
examples/udpblaster/udpblaster.h
Normal file
127
examples/udpblaster/udpblaster.h
Normal file
@ -0,0 +1,127 @@
|
||||
/****************************************************************************
|
||||
* examples/udpblaster/udpblaster.h
|
||||
*
|
||||
* Copyright (C) 2015 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __EXAMPLES_UDPBLASTER_UDPBLASTER_H
|
||||
#define __EXAMPLES_UDPBLASTER_UDPBLASTER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef UDPBLASTER_HOST
|
||||
/* HTONS/L macros are unique to uIP */
|
||||
|
||||
# define HTONS(a) htons(a)
|
||||
# define HTONL(a) htonl(a)
|
||||
|
||||
/* Have SO_LINGER */
|
||||
|
||||
# define UDPBLASTER_HAVE_SOLINGER 1
|
||||
|
||||
#else
|
||||
# ifdef CONFIG_NET_SOLINGER
|
||||
# define UDPBLASTER_HAVE_SOLINGER 1
|
||||
# else
|
||||
# undef UDPBLASTER_HAVE_SOLINGER
|
||||
# endif
|
||||
#endif /* UDPBLASTER_HOST */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
# define AF_INETX AF_INET6
|
||||
# define PF_INETX PF_INET6
|
||||
#else
|
||||
# define AF_INETX AF_INET
|
||||
# define PF_INETX PF_INET
|
||||
#endif
|
||||
|
||||
#define UDPBLASTER_PORTNO 5471
|
||||
|
||||
#define ETH_HDRLEN 14 /* Size of the Ethernet header */
|
||||
#define IPv4_HDRLEN 20 /* Size of IPv4 header */
|
||||
#define IPv6_HDRLEN 40 /* Size of IPv6 header */
|
||||
#define UDP_HDRLEN 8 /* Size of UDP header */
|
||||
|
||||
#if defined(CONFIG_NET_ETHERNET)
|
||||
# define UDPBLASTER_MTU CONFIG_NET_ETH_MTU
|
||||
# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - ETH_HDRLEN - IPv6_HDRLEN - UDP_HDRLEN)
|
||||
# else
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - ETH_HDRLEN - IPv4_HDRLEN - UDP_HDRLEN)
|
||||
# endif
|
||||
#
|
||||
#elif defined(CONFIG_NET_LOOPBACK)
|
||||
# define UDPBLASTER_MTU 1518
|
||||
# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv6_HDRLEN - UDP_HDRLEN)
|
||||
# else
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv4_HDRLEN - UDP_HDRLEN)
|
||||
# endif
|
||||
#elif defined(CONFIG_NET_SLIP)
|
||||
# define UDPBLASTER_MTU CONFIG_NET_SLIP_MTU
|
||||
# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv6_HDRLEN - UDP_HDRLEN)
|
||||
# else
|
||||
# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv4_HDRLEN - UDP_HDRLEN)
|
||||
# endif
|
||||
#else
|
||||
# error "Additional link layer definitions needed"
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#define UDPBLASTER_SENDSIZE MIN(UDPBLASTER_MSS, g_udpblaster_strlen)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern const char g_udpblaster_text[];
|
||||
extern const int g_udpblaster_strlen;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __EXAMPLES_UDPBLASTER_UDPBLASTER_H */
|
154
examples/udpblaster/udpblaster_host.c
Normal file
154
examples/udpblaster/udpblaster_host.c
Normal file
@ -0,0 +1,154 @@
|
||||
/****************************************************************************
|
||||
* examples/udpblaster/udpblaster_host.c
|
||||
*
|
||||
* Copyright (C) 2015 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 Gregory Nutt 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 <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "udpblaster.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* main
|
||||
****************************************************************************/
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4
|
||||
struct sockaddr_in target;
|
||||
#else
|
||||
struct sockaddr_in6 target;
|
||||
#endif
|
||||
socklen_t addrlen;
|
||||
size_t sendsize;
|
||||
unsigned long delay;
|
||||
int npackets;
|
||||
int ndots;
|
||||
int sockfd;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4
|
||||
target.sin_family = AF_INET;
|
||||
target.sin_port = HTONS(UDPBLASTER_PORTNO);
|
||||
target.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_TARGETIP);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: socket() failed: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
target.sin6_family = AF_INET6;
|
||||
target.sin6_port = HTONS(UDPBLASTER_PORTNO);
|
||||
target.sin6_addr.s6_addr16[0] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_1);
|
||||
target.sin6_addr.s6_addr16[1] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_2);
|
||||
target.sin6_addr.s6_addr16[2] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_3);
|
||||
target.sin6_addr.s6_addr16[3] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_4);
|
||||
target.sin6_addr.s6_addr16[4] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_5);
|
||||
target.sin6_addr.s6_addr16[5] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_6);
|
||||
target.sin6_addr.s6_addr16[6] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_7);
|
||||
target.sin6_addr.s6_addr16[7] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_8);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
sockfd = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: socket() failed: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* bytes/packet = UDPBLASTER_SENDSIZE
|
||||
* bits/sec = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE
|
||||
* bytes/sec = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / 8
|
||||
* packets/sec = (bytes/sec) / (bytes/packet)
|
||||
* = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / UDPBLASTER_SENDSIZE / 8
|
||||
* delay = microseconds/packet
|
||||
* = (1000000 * UDPBLASTER_SENDSIZE) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / 8
|
||||
* = (125000 * UDPBLASTER_SENDSIZE) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE
|
||||
*/
|
||||
|
||||
sendsize = UDPBLASTER_SENDSIZE;
|
||||
delay = (125000 * sendsize) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE;
|
||||
|
||||
npackets = 0;
|
||||
ndots = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ret = sendto(sockfd, g_udpblaster_text, sendsize, 0,
|
||||
(struct sockaddr *)&target, addrlen);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sendto() failed: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (++npackets >= 10)
|
||||
{
|
||||
putchar('.');
|
||||
npackets = 0;
|
||||
|
||||
if (++ndots >= 50)
|
||||
{
|
||||
putchar('\n');
|
||||
ndots = 0;
|
||||
}
|
||||
}
|
||||
|
||||
usleep(delay);
|
||||
}
|
||||
|
||||
return 0; /* Won't get here */
|
||||
}
|
271
examples/udpblaster/udpblaster_target.c
Normal file
271
examples/udpblaster/udpblaster_target.c
Normal file
@ -0,0 +1,271 @@
|
||||
/****************************************************************************
|
||||
* examples/udpblaster/udpblaster_target.c
|
||||
*
|
||||
* Copyright (C) 2015 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 <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <apps/netutils/netlib.h>
|
||||
|
||||
#include "udpblaster.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_UDPBLASTER_INIT) && \
|
||||
defined(CONFIG_EXAMPLES_UDPBLASTER_IPv6) && \
|
||||
!defined(CONFIG_NET_ICMPv6_AUTOCONF)
|
||||
/* Our host IPv6 address */
|
||||
|
||||
static const uint16_t g_ipv6_hostaddr[8] =
|
||||
{
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_2),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_3),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_4),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_5),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8),
|
||||
};
|
||||
|
||||
/* Default routine IPv6 address */
|
||||
|
||||
static const uint16_t g_ipv6_draddr[8] =
|
||||
{
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_1),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_2),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_3),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_4),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_5),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_6),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_7),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_8),
|
||||
};
|
||||
|
||||
/* IPv6 netmask */
|
||||
|
||||
static const uint16_t g_ipv6_netmask[8] =
|
||||
{
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_1),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_2),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_3),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_4),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_5),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_6),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_7),
|
||||
HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_8),
|
||||
};
|
||||
#endif /* CONFIG_EXAMPLES_UDPBLASTER_INIT && CONFIG_EXAMPLES_UDPBLASTER_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_INIT
|
||||
static void netest_initialize(void)
|
||||
{
|
||||
#ifndef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
struct in_addr addr;
|
||||
#endif
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_NOMAC
|
||||
uint8_t mac[IFHWADDRLEN];
|
||||
#endif
|
||||
|
||||
/* Many embedded network interfaces must have a software assigned MAC */
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_NOMAC
|
||||
mac[0] = 0x00;
|
||||
mac[1] = 0xe0;
|
||||
mac[2] = 0xde;
|
||||
mac[3] = 0xad;
|
||||
mac[4] = 0xbe;
|
||||
mac[5] = 0xef;
|
||||
netlib_setmacaddr("eth0", mac);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
/* Perform ICMPv6 auto-configuration */
|
||||
|
||||
netlib_icmpv6_autoconfiguration("eth0");
|
||||
|
||||
#else /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
|
||||
/* Set up our fixed host address */
|
||||
|
||||
netlib_set_ipv6addr("eth0",
|
||||
(FAR const struct in6_addr *)g_ipv6_hostaddr);
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
netlib_set_dripv6addr("eth0",
|
||||
(FAR const struct in6_addr *)g_ipv6_draddr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
netlib_set_ipv6netmask("eth0",
|
||||
(FAR const struct in6_addr *)g_ipv6_netmask);
|
||||
|
||||
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
#else /* CONFIG_EXAMPLES_UDPBLASTER_IPv6 */
|
||||
|
||||
/* Set up our host address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_TARGETIP);
|
||||
netlib_set_ipv4addr("eth0", &addr);
|
||||
|
||||
/* Set up the default router address */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_HOSTIP);
|
||||
netlib_set_dripv4addr("eth0", &addr);
|
||||
|
||||
/* Setup the subnet mask */
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
#endif /* CONFIG_EXAMPLES_UDPBLASTER_IPv6 */
|
||||
}
|
||||
#endif /*CONFIG_EXAMPLES_UDPBLASTER_INIT */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* udpblaster_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int udpblaster_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4
|
||||
struct sockaddr_in host;
|
||||
#else
|
||||
struct sockaddr_in6 host;
|
||||
#endif
|
||||
socklen_t addrlen;
|
||||
int npackets;
|
||||
int ndots;
|
||||
int sockfd;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_INIT
|
||||
/* Initialize the network */
|
||||
|
||||
netest_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4
|
||||
host.sin_family = AF_INET;
|
||||
host.sin_port = HTONS(UDPBLASTER_PORTNO);
|
||||
host.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_HOSTIP);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in);
|
||||
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: socket() failed: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
host.sin6_family = AF_INET6;
|
||||
host.sin6_port = HTONS(UDPBLASTER_PORTNO);
|
||||
host.sin6_addr.s6_addr16[0] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_1);
|
||||
host.sin6_addr.s6_addr16[1] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_2);
|
||||
host.sin6_addr.s6_addr16[2] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_3);
|
||||
host.sin6_addr.s6_addr16[3] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_4);
|
||||
host.sin6_addr.s6_addr16[4] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_5);
|
||||
host.sin6_addr.s6_addr16[5] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_6);
|
||||
host.sin6_addr.s6_addr16[6] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_7);
|
||||
host.sin6_addr.s6_addr16[7] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_8);
|
||||
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
sockfd = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: socket() failed: %d\n", errno)
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
npackets = 0;
|
||||
ndots = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ret = sendto(sockfd, g_udpblaster_text, UDPBLASTER_SENDSIZE, 0,
|
||||
(struct sockaddr *)&host, addrlen);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: sendto() failed: %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (++npackets >= 10)
|
||||
{
|
||||
putchar('.');
|
||||
npackets = 0;
|
||||
|
||||
if (++ndots >= 50)
|
||||
{
|
||||
putchar('\n');
|
||||
ndots = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* Won't get here */
|
||||
}
|
121
examples/udpblaster/udpblaster_text.c
Normal file
121
examples/udpblaster/udpblaster_text.c
Normal file
@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* examples/udpblaster/udpblaster_text.c
|
||||
*
|
||||
* Copyright (C) 2015 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 "udpblaster.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
const char g_udpblaster_text[] =
|
||||
"ONE day Henny-penny was picking up corn in the cornyard when--whack!--"
|
||||
"something hit her upon the head. 'Goodness gracious me!' said Henny-"
|
||||
"penny; 'the sky's a-going to fall; I must go and tell the king.'\n\n"
|
||||
|
||||
"So she went along and she went along and she went along till she met "
|
||||
"Cocky-locky. 'Where are you going, Hennypenny?' says Cocky-locky. 'Oh! "
|
||||
"I'm going to tell the king the sky's a-falling,' says Henny-penny. 'May "
|
||||
"I come with you?' says Cocky-locky. 'Certainly,' says Henny-penny. So "
|
||||
"Hennypenny and Cocky-locky went to tell the king the sky was falling.\n\n"
|
||||
|
||||
"They went along, and they went along, and they went along, till they "
|
||||
"met Ducky-daddles. 'Where are you going to, Hennypenny and Cocky-locky?' "
|
||||
"says Ducky-daddles. 'Oh! we're going to tell the king the sky's a-falling,' "
|
||||
"said Henny-penny and Cocky-locky. 'May I come with you?' said Ducky-daddles. "
|
||||
"'Certainly,' said Henny-penny and Cocky-locky. So Hennypenny, Cocky-locky, "
|
||||
"and Ducky-daddles went to tell the king the sky was a-falling.\n\n"
|
||||
|
||||
"So they went along and they went along, and they went along, till they met "
|
||||
"Goosey-poosey. 'Where are you going to, Henny-penny, Cocky-locky, and "
|
||||
"Ducky-daddles?' said Gooseypoosey. 'Oh! we're going to tell the king the "
|
||||
"sky's a-falling,' said Henny-penny and Cocky-locky and Ducky-daddles. 'May "
|
||||
"I come with you?' said Goosey-poosey. 'Certainly,' said Hennypenny, "
|
||||
"Cocky-locky, and Ducky-daddles. So Henny-penny, Cocky-locky, Ducky-daddles, "
|
||||
"and Goosey-poosey went to tell the king the sky was a-falling.\n\n"
|
||||
|
||||
"So they went along, and they went along, and they went along, till they met "
|
||||
"Turkey-lurkey. 'Where are you going, Henny-penny, Cocky-locky, Ducky-daddles, "
|
||||
"and Gooseypoosey?' says Turkey-turkey. 'Oh! we're going to tell the king the "
|
||||
"sky's a-falling,' said Henny-penny, Cocky-locky, Duckydaddies, and Goosey-poosey. "
|
||||
"'May I come with you, Hennypenny, Cocky-locky, Ducky-daddles, and Goosey-poosey?' "
|
||||
"said Turkey-lurkey. 'Oh, certainly, Turkey-turkey,' said Henny-penny, Cocky-locky, "
|
||||
"Ducky-daddles, and Gooseypoosey. So Henny-penny, Cocky-locky, Ducky-daddles, "
|
||||
"Goosey-poosey, and Turkey-lurkey all went to tell the king the sky was a-"
|
||||
"falling.\n\n"
|
||||
|
||||
"So they went along, and they went along, and they went along, till they met "
|
||||
"Foxy-woxy, and Foxy-woxy said to Hennypenny, Cocky-locky, Ducky-daddles, "
|
||||
"Goosey-poosey, and Turkey-lurkey: 'Where are you going, Henny-penny, "
|
||||
"Cockylocky, Ducky-daddles, Goosey-poosey, and Turkey-lurkey?' And Henny-penny, "
|
||||
"Cocky-locky, Ducky-daddles, Goosey poosey, and Turkey-lurkey said to "
|
||||
"Foxy-woxy: 'We' re going to tell the king the sky's a-falling.' 'Oh! but "
|
||||
"this is not the way to the king, Henny-penny, Cocky-locky, Ducky-daddles, "
|
||||
"Goosey-poosey, and Turkey-lurkey,' says Foxy-woxy; 'I know the proper way; "
|
||||
"shall I show it you?' 'Oh, certainly, Foxywoxy,' said Henny-penny, Cocky-locky, "
|
||||
"Ducky-daddles, Goosey-poosey, and Turkey-lurkey. So Henny-penny, Cockylocky, "
|
||||
"Ducky-daddles, Goosey-poosey, Turkey-lurkey, and Foxy-woxy all went to tell "
|
||||
"the king the sky was a-falling. So they went along, and they went along, and "
|
||||
"they went along, till they came to a narrow and dark hole. Now this was the "
|
||||
"door of Foxy-woxy's cave. But Foxy-woxy said to Henny-penny, Cocky-locky, "
|
||||
"Ducky-daddles, Goosey-poosey, and Turkeyturkey: 'This is the short way to the "
|
||||
"king's palace: you'll soon get there if you follow me. I will go first and you "
|
||||
"come after, Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and "
|
||||
"Turkey-turkey.' 'Why, of course, certainly, without doubt, why not?' said "
|
||||
"Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and Turkey-lurkey.\n\n"
|
||||
|
||||
"So Foxy-woxy went into his cave, and he didn't go very far, but turned round "
|
||||
"to wait for Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and "
|
||||
"Turkey-lurkey. So at last at first Turkey-lurkey went through the dark hole "
|
||||
"into the cave. He hadn't got far when 'Hrumph', Foxy-woxy snapped off Turkey-"
|
||||
"lurkey's head and threw his body over his left shoulder. Then Goosey-poosey "
|
||||
"went in, and 'Hrumph', off went her head and Goosey-poosey was thrown beside "
|
||||
"Turkey-lurkey. Then Ducky-daddles waddled down, and 'Hrumph', snapped "
|
||||
"Foxy-woxy, and Ducky-daddles's head was off and Duckydaddies was thrown "
|
||||
"alongside Turkey-turkey and Gooseypoosey. Then Cocky-locky strutted down "
|
||||
"into the cave, and he hadn't gone far when 'Snap, Hrumph!' went Foxy-woxy, "
|
||||
"and Cocky-locky was thrown alongside of Turkey-lurkey, Gooseypoosey, and "
|
||||
"Ducky-daddles.\n\n"
|
||||
|
||||
"But Foxy-woxy had made two bites at Cocky-locky, and when the first snap "
|
||||
"only hurt Cocky-locky, but didn't kill him, he called out to Henny-penny. "
|
||||
"But she turned tail and off she ran home, so she never told the king the "
|
||||
"sky was a-falling.\n\n";
|
||||
|
||||
const int g_udpblaster_strlen = sizeof(g_udpblaster_text) - 1;
|
Loading…
x
Reference in New Issue
Block a user