From 74ae2834873d2af24b2a95a1d282242c20eace6b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Apr 2017 15:13:11 -0600 Subject: [PATCH 1/4] examples/nettest: If doing loopback, but not using the official loopback device, then use the server should use the configured client IP address --- examples/nettest/nettest_client.c | 2 +- examples/nettest/nettest_server.c | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 8de196bca..b27ea0c4f 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -137,7 +137,7 @@ void send_client(void) myaddr.sin_family = AF_INET; myaddr.sin_port = HTONS(PORTNO); -#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK +#ifdef 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); diff --git a/examples/nettest/nettest_server.c b/examples/nettest/nettest_server.c index 990168a5b..ad55506a1 100644 --- a/examples/nettest/nettest_server.c +++ b/examples/nettest/nettest_server.c @@ -110,15 +110,33 @@ void recv_server(void) /* Bind the socket to a local address */ #ifdef CONFIG_EXAMPLES_NETTEST_IPv6 - myaddr.sin6_family = AF_INET6; - myaddr.sin6_port = HTONS(PORTNO); + + myaddr.sin6_family = AF_INET6; + myaddr.sin6_port = HTONS(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); +#else memset(&myaddr.sin6_addr, 0, sizeof(struct in6_addr)); +#endif addrlen = sizeof(struct sockaddr_in6); #else - myaddr.sin_family = AF_INET; - myaddr.sin_port = HTONS(PORTNO); - myaddr.sin_addr.s_addr = INADDR_ANY; + 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(CONFIG_EXAMPLES_NETTEST_CLIENTIP); +#else + myaddr.sin_addr.s_addr = INADDR_ANY; +#endif addrlen = sizeof(struct sockaddr_in); #endif From d03aa9112e3a05b2fa0bb1d1079ba7c1e0f6b3f3 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 5 Apr 2017 18:25:59 -0600 Subject: [PATCH 2/4] Added support for set [{+|-}{e|x|xe|ex}] [ ] Set the 'exit on error control' and/or 'print a trace' of commands when parsing scripts in NSH. The settinngs are in effect from the point of exection, until they are changed again, or in the case of the init script, the settings are returned to the default settings when it exits. Included child scripts will run with the parents settings and changes made in the child script will effect the parent on return. Use 'set -e' to enable and 'set +e' to disable (ignore) the exit condition on commands. The default is -e. Errors cause script to exit. Use 'set -x' to enable and 'set +x' to disable (silence) printing a trace of the script commands as they are ececuted. The default is +x. No printing of a trace of script commands as they are executed. --- nshlib/README.txt | 38 +++++++++++++++++-- nshlib/nsh.h | 34 +++++++++++++++-- nshlib/nsh_command.c | 10 +++-- nshlib/nsh_console.c | 6 +++ nshlib/nsh_consolemain.c | 6 +++ nshlib/nsh_envcmds.c | 81 ++++++++++++++++++++++++++++++++++------ nshlib/nsh_script.c | 7 +++- 7 files changed, 160 insertions(+), 22 deletions(-) diff --git a/nshlib/README.txt b/nshlib/README.txt index 05ba319e9..8edf053b7 100644 --- a/nshlib/README.txt +++ b/nshlib/README.txt @@ -1017,10 +1017,10 @@ o rmmod NAME INIT UNINIT ARG TEXT SIZE DATA SIZE nsh> -o set +o set [{+|-}{e|x|xe|ex}] [ ] - Set the environment variable to the sting . - For example, + Set the environment variable to the sting and or set NSH + parser control options. For example, nsh> echo $foobar @@ -1029,6 +1029,38 @@ o set foovalue nsh> + Set the 'exit on error control' and/or 'print a trace' of commands when parsing + scripts in NSH. The settinngs are in effect from the point of exection, until + they are changed again, or in the case of the init script, the settings are + returned to the default settings when it exits. Included child scripts will run + with the parents settings and changes made in the child script will effect the + parent on return. + + Use 'set -e' to enable and 'set +e' to disable (ignore) the exit condition on commands. + The default is -e. Errors cause script to exit. + + Use 'set -x' to enable and 'set +x' to disable (silence) printing a trace of the script + commands as they are ececuted. + The default is +x. No printing of a trace of script commands as they are executed. + + Example 1 - no exit on command not found + set +e + notacommand + + Example 2 - will exit on command not found + set -e + notacommand + + Example 3 - will exit on command not found, and print a trace of the script commmands + set -ex + + Example 4 - will exit on command not found, and print a trace of the script commmands + and set foobar to foovalue. + set -ex foobar foovalue + nsh> echo $foobar + foovalue + + o sh Execute the sequence of NSH commands in the file referred diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 25ef9ce46..6ce5bbf35 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -690,6 +690,15 @@ # undef NSH_HAVE_TRIMSPACES #endif +#ifndef CONFIG_NSH_DISABLESCRIPT +# define NSH_NP_SET_OPTIONS "ex" /* Maintain order see nsh_npflags_e */ +# define NSH_NP_SET_OPTIONS_INIT (NSH_PFALG_SILENT) +#endif + +#if defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_NSH_DISABLESCRIPT) +# define CONFIG_NSH_DISABLE_SET +#endif + /**************************************************************************** * Public Types ****************************************************************************/ @@ -741,6 +750,22 @@ struct nsh_loop_s }; #endif +#ifndef CONFIG_NSH_DISABLESCRIPT +/* Define the bits that correspond to the option defined in + * NSH_NP_SET_OPTIONS. The bit value is 1 shifted left the offset + * of the char in NSH_NP_SET_OPTIONS string. + */ + +enum nsh_npflags_e +{ + NSH_PFALG_IGNORE = 1, /* set for +e no exit on errors, + * cleared -e exit on error */ + NSH_PFALG_SILENT = 2, /* cleared -x print a trace of commands + * when parsing. + * set +x no print a trace of commands */ +}; +#endif + /* These structure provides the overall state of the parser */ struct nsh_parser_s @@ -752,6 +777,9 @@ struct nsh_parser_s bool np_redirect; /* true: Output from the last command was re-directed */ #endif bool np_fail; /* true: The last command failed */ +#ifndef CONFIG_NSH_DISABLESCRIPT + uint8_t np_flags; /* See nsh_npflags_e above */ +#endif #ifndef CONFIG_NSH_DISABLEBG int np_nice; /* "nice" value applied to last background cmd */ #endif @@ -1175,10 +1203,10 @@ int cmd_lsmod(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif -#ifndef CONFIG_DISABLE_ENVIRON -# ifndef CONFIG_NSH_DISABLE_SET +#ifndef CONFIG_NSH_DISABLE_SET int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -# endif +#endif +#ifndef CONFIG_DISABLE_ENVIRON # ifndef CONFIG_NSH_DISABLE_UNSET int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); # endif diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index ad68fd7c9..2d8b731d2 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -436,10 +436,14 @@ static const struct cmdmap_s g_cmdmap[] = { "rmmod", cmd_rmmod, 2, 2, "" }, #endif -#ifndef CONFIG_DISABLE_ENVIRON -# ifndef CONFIG_NSH_DISABLE_SET +#ifndef CONFIG_NSH_DISABLE_SET +# if !defined(CONFIG_DISABLE_ENVIRON) && !defined(CONFIG_NSH_DISABLESCRIPT) + { "set", cmd_set, 2, 4, "[{+|-}{e|x|xe|ex}] [ ]" }, +# elif !defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_NSH_DISABLESCRIPT) { "set", cmd_set, 3, 3, " " }, -# endif +# elif defined(CONFIG_DISABLE_ENVIRON) && !defined(CONFIG_NSH_DISABLESCRIPT) + { "set", cmd_set, 2, 2, "{+|-}{e|x|xe|ex}" }, +# endif #endif #if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT) diff --git a/nshlib/nsh_console.c b/nshlib/nsh_console.c index 6d68e3acb..1a22f0a66 100644 --- a/nshlib/nsh_console.c +++ b/nshlib/nsh_console.c @@ -480,5 +480,11 @@ FAR struct console_stdio_s *nsh_newconsole(void) #endif } +#ifndef CONFIG_NSH_DISABLESCRIPT + /* Set the initial option flags */ + + pstate->cn_vtbl.np.np_flags = NSH_NP_SET_OPTIONS_INIT; +#endif + return pstate; } diff --git a/nshlib/nsh_consolemain.c b/nshlib/nsh_consolemain.c index f89944ff6..b61cf15af 100644 --- a/nshlib/nsh_consolemain.c +++ b/nshlib/nsh_consolemain.c @@ -85,6 +85,12 @@ int nsh_consolemain(int argc, char *argv[]) /* Execute the start-up script */ (void)nsh_initscript(&pstate->cn_vtbl); + +#ifndef CONFIG_NSH_DISABLESCRIPT + /* Reset the option flags */ + + pstate->cn_vtbl.np.np_flags = NSH_NP_SET_OPTIONS_INIT; +#endif #endif #ifdef CONFIG_NSH_USBDEV_TRACE diff --git a/nshlib/nsh_envcmds.c b/nshlib/nsh_envcmds.c index cbda78ba1..b323d9538 100644 --- a/nshlib/nsh_envcmds.c +++ b/nshlib/nsh_envcmds.c @@ -311,29 +311,86 @@ int cmd_pwd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * Name: cmd_set ****************************************************************************/ -#ifndef CONFIG_DISABLE_ENVIRON #ifndef CONFIG_NSH_DISABLE_SET int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR char *value; - int ret; + int ret = OK; + int ndx = 1; +#ifndef CONFIG_NSH_DISABLESCRIPT + FAR char *popt; + const char opts[] = NSH_NP_SET_OPTIONS; + int op; - /* Trim whitespace from the value */ + /* Support set [{+|-}{e|x|xe|ex}] [ ] */ - value = nsh_trimspaces(argv[2]); - - /* Set the environment variable */ - - ret = setenv(argv[1], value, TRUE); - if (ret < 0) + if (argc == 2 || argc == 4) { - nsh_output(vtbl, g_fmtcmdfailed, argv[0], "setenv", NSH_ERRNO); - } + if (strlen(argv[1]) < 2) + { + ret = -EINVAL; + nsh_output(vtbl, g_fmtargrequired, argv[0], "set", NSH_ERRNO); + } + else + { + op = argv[1][0]; + if (op != '-' && op != '+') + { + ret = -EINVAL; + nsh_output(vtbl, g_fmtarginvalid, argv[0], "set", NSH_ERRNO); + } + else + { + value = &argv[1][1]; + while(*value && *value != ' ') + { + popt = strchr(opts, *value++); + if (popt == NULL) + { + nsh_output(vtbl, g_fmtarginvalid, argv[0], "set", NSH_ERRNO); + ret = -EINVAL; + break; + } + if (op == '+') + { + vtbl->np.np_flags |= 1 << (popt-opts); + } + else + { + vtbl->np.np_flags &= ~(1 << (popt-opts)); + } + } + + if (ret == OK) + { + ndx = 2; + } + } + } + } +# ifndef CONFIG_DISABLE_ENVIRON + if (ret == OK && (argc == 3 || argc == 4)) +# endif +#endif +#ifndef CONFIG_DISABLE_ENVIRON + { + /* Trim whitespace from the value */ + + value = nsh_trimspaces(argv[ndx+1]); + + /* Set the environment variable */ + + ret = setenv(argv[ndx], value, TRUE); + if (ret < 0) + { + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "setenv", NSH_ERRNO); + } + } +#endif return ret; } #endif -#endif /**************************************************************************** * Name: cmd_unset diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index 2c4a369bd..cc20a82ed 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -136,10 +136,15 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, * considerable amount of stack may be used. */ + if ((vtbl->np.np_flags & NSH_PFALG_SILENT) == 0) + { + nsh_output(vtbl,"%s", buffer); + } + ret = nsh_parse(vtbl, buffer); } } - while (pret && ret == OK); + while (pret && (ret == OK || (vtbl->np.np_flags & NSH_PFALG_IGNORE))); /* Close the script file */ From 35cf98d4dfd89c869d492b46c13abbe7b9ad81c8 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 5 Apr 2017 18:31:47 -0600 Subject: [PATCH 3/4] Print expanded variables if -x --- nshlib/nsh.h | 6 +++--- nshlib/nsh_parse.c | 5 +++++ nshlib/nsh_script.c | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nshlib/nsh.h b/nshlib/nsh.h index 6ce5bbf35..94e7e55d8 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -692,7 +692,7 @@ #ifndef CONFIG_NSH_DISABLESCRIPT # define NSH_NP_SET_OPTIONS "ex" /* Maintain order see nsh_npflags_e */ -# define NSH_NP_SET_OPTIONS_INIT (NSH_PFALG_SILENT) +# define NSH_NP_SET_OPTIONS_INIT (NSH_PFLAG_SILENT) #endif #if defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_NSH_DISABLESCRIPT) @@ -758,9 +758,9 @@ struct nsh_loop_s enum nsh_npflags_e { - NSH_PFALG_IGNORE = 1, /* set for +e no exit on errors, + NSH_PFLAG_IGNORE = 1, /* set for +e no exit on errors, * cleared -e exit on error */ - NSH_PFALG_SILENT = 2, /* cleared -x print a trace of commands + NSH_PFLAG_SILENT = 2, /* cleared -x print a trace of commands * when parsing. * set +x no print a trace of commands */ }; diff --git a/nshlib/nsh_parse.c b/nshlib/nsh_parse.c index 231dc2526..ecea05791 100644 --- a/nshlib/nsh_parse.c +++ b/nshlib/nsh_parse.c @@ -1169,6 +1169,11 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline, envstr = nsh_envexpand(vtbl, ptr); + if ((vtbl->np.np_flags & NSH_PFLAG_SILENT) == 0) + { + nsh_output(vtbl," %s=%s\n", ptr, envstr ? envstr :"(null)"); + } + /* Concatenate the result of the operation with the accumulated * string. On failures to allocation memory, nsh_strcat will * just return value value of argument diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index cc20a82ed..37486c252 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -136,7 +136,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, * considerable amount of stack may be used. */ - if ((vtbl->np.np_flags & NSH_PFALG_SILENT) == 0) + if ((vtbl->np.np_flags & NSH_PFLAG_SILENT) == 0) { nsh_output(vtbl,"%s", buffer); } @@ -144,7 +144,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, ret = nsh_parse(vtbl, buffer); } } - while (pret && (ret == OK || (vtbl->np.np_flags & NSH_PFALG_IGNORE))); + while (pret && (ret == OK || (vtbl->np.np_flags & NSH_PFLAG_IGNORE))); /* Close the script file */ From 14fc6d7575f3205da1bcd3af18febcea2b813073 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 6 Apr 2017 09:37:52 -0600 Subject: [PATCH 4/4] examples/udpblaster: Several fixes to work with 6loWPAN. --- examples/nettest/Makefile | 3 - examples/udpblaster/Kconfig | 82 +++++++++++++++---------- examples/udpblaster/Makefile | 11 ++-- examples/udpblaster/udpblaster.h | 4 +- examples/udpblaster/udpblaster_host.c | 24 +++----- examples/udpblaster/udpblaster_target.c | 18 +++--- 6 files changed, 76 insertions(+), 66 deletions(-) diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index 6fc5a26af..a76a15d46 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -99,9 +99,6 @@ else INSTALL_DIR = $(BIN_DIR) endif -CONFIG_XYZ_PROGNAME ?= nettest$(EXEEXT) -PROGNAME = $(CONFIG_XYZ_PROGNAME) - ROOTDEPPATH = --dep-path . # NET test built-in application info diff --git a/examples/udpblaster/Kconfig b/examples/udpblaster/Kconfig index a65b41d81..d31683431 100644 --- a/examples/udpblaster/Kconfig +++ b/examples/udpblaster/Kconfig @@ -12,6 +12,22 @@ config EXAMPLES_UDPBLASTER if EXAMPLES_UDPBLASTER +config EXAMPLES_UDPBLASTER_PROGNAME + string "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_UDPBLASTER_STACKSIZE + int "Nettest stack size" + default 2048 + +config EXAMPLES_UDPBLASTER_PRIORITY + int "Nettest priority" + default 100 + config EXAMPLES_UDPBLASTER_HOSTRATE int "Host send rate (bits/second)" default 800000 @@ -153,87 +169,87 @@ config EXAMPLES_UDPBLASTER_TARGETIPv6_8 specified individually. This is the last of the 8-values. The default for all eight values is fc00::2. -comment "Router IPv6 address" +comment "Host 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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::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. + Host IP 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::1. if EXAMPLES_UDPBLASTER_INIT diff --git a/examples/udpblaster/Makefile b/examples/udpblaster/Makefile index f014d68fc..469c2a212 100644 --- a/examples/udpblaster/Makefile +++ b/examples/udpblaster/Makefile @@ -79,16 +79,19 @@ else INSTALL_DIR = $(BIN_DIR) endif -CONFIG_XYZ_PROGNAME ?= udpblaster$(EXEEXT) -PROGNAME = $(CONFIG_XYZ_PROGNAME) +CONFIG_UPBLASTER_PROGNAME ?= udpblaster$(EXEEXT) +PROGNAME = $(CONFIG_UPBLASTER_PROGNAME) ROOTDEPPATH = --dep-path . # NET test built-in application info +CONFIG_EXAMPLES_UDPBLASTER_STACKSIZE ?= 2048 +CONFIG_EXAMPLES_UDPBLASTER_PRIORITY ?= 100 + APPNAME = udpblaster -PRIORITY = SCHED_PRIORITY_DEFAULT -STACKSIZE = 2048 +PRIORITY = $(CONFIG_EXAMPLES_UDPBLASTER_PRIORITY) +STACKSIZE = $(CONFIG_EXAMPLES_UDPBLASTER_STACKSIZE) # Common build diff --git a/examples/udpblaster/udpblaster.h b/examples/udpblaster/udpblaster.h index 6e2a21db3..fdfe1b7d8 100644 --- a/examples/udpblaster/udpblaster.h +++ b/examples/udpblaster/udpblaster.h @@ -88,7 +88,6 @@ # 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 @@ -96,6 +95,9 @@ # else # define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv4_HDRLEN - UDP_HDRLEN) # endif +#elif defined(CONFIG_NET_6LOWPAN) +# define UDPBLASTER_MTU CONFIG_NET_6LOWPAN_MTU +# define UDPBLASTER_MSS (CONFIG_NET_6LOWPAN_MTU - IPv6_HDRLEN - UDP_HDRLEN) #elif defined(CONFIG_NET_SLIP) # define UDPBLASTER_MTU CONFIG_NET_SLIP_MTU # ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 diff --git a/examples/udpblaster/udpblaster_host.c b/examples/udpblaster/udpblaster_host.c index c2dfcd201..11562d84d 100644 --- a/examples/udpblaster/udpblaster_host.c +++ b/examples/udpblaster/udpblaster_host.c @@ -48,14 +48,6 @@ #include "udpblaster.h" -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * main ****************************************************************************/ @@ -91,14 +83,14 @@ int main(int argc, char **argv, char **envp) #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); + target.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1); + target.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_2); + target.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_3); + target.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_4); + target.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_5); + target.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6); + target.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7); + target.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8); addrlen = sizeof(struct sockaddr_in6); sockfd = socket(PF_INET6, SOCK_DGRAM, 0); diff --git a/examples/udpblaster/udpblaster_target.c b/examples/udpblaster/udpblaster_target.c index a656f0090..afbb1b51b 100644 --- a/examples/udpblaster/udpblaster_target.c +++ b/examples/udpblaster/udpblaster_target.c @@ -223,20 +223,20 @@ int udpblaster_main(int argc, char *argv[]) #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); + host.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_1); + host.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_2); + host.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_3); + host.sin6_addr.s6_addr16[3] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_4); + host.sin6_addr.s6_addr16[4] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_5); + host.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_6); + host.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_7); + host.sin6_addr.s6_addr16[7] = HTONS(CONFIG_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) + fprintf(stderr, "ERROR: socket() failed: %d\n", errno); return 1; } #endif