summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-04-18 20:26:56 +1000
committerKinseyMoore <48726349+KinseyMoore@users.noreply.github.com>2023-04-18 10:44:06 -0500
commite072cceaaba0669b71f2cb8da0532362ee04a852 (patch)
tree040cf1b085b929df1b241b3774275c1c7efec016
parentwaf: Add support for the legacy stack (diff)
downloadrtems-net-services-e072cceaaba0669b71f2cb8da0532362ee04a852.tar.bz2
legacy: Fixes for the legacy network stack
-rw-r--r--netservices.py7
-rw-r--r--stack/legacy/include/ntp/config.h6
-rw-r--r--testsuites/ntp01/test_main.c103
-rw-r--r--testsuites/telnetd01/init.c38
-rw-r--r--testsuites/ttcpshell01/test_main.c36
-rw-r--r--ttcp/ttcp.c2
6 files changed, 117 insertions, 75 deletions
diff --git a/netservices.py b/netservices.py
index bcc5e9e..5922b22 100644
--- a/netservices.py
+++ b/netservices.py
@@ -80,6 +80,7 @@ def bsp_configure(conf, arch_bsp):
def build(bld):
stack_name = bld.env.STACK_NAME
+ stack_def = 'RTEMS_NET_' + stack_name.upper()
stack_inc = str(bld.path.find_node('stack/' + stack_name + '/include'))
ns_cflags = ['-g', '-Wall', bld.env.OPTIMIZATION]
@@ -102,7 +103,7 @@ def build(bld):
source=ntp_source_files,
includes=ntp_incl + [stack_inc + '/ntp'],
cflags=ns_cflags,
- defines=['HAVE_CONFIG_H=1'],
+ defines=[stack_def, 'HAVE_CONFIG_H=1'],
use=[stack_name])
bld.install_files("${PREFIX}/" + arch_lib_path, ["libntp.a"])
@@ -115,6 +116,7 @@ def build(bld):
source=ttcp_source_files,
includes=ttcp_incl,
cflags=ns_cflags,
+ defines=[stack_def],
use=[stack_name])
bld.install_files("${PREFIX}/" + arch_lib_path, ["libttcp.a"])
@@ -150,6 +152,7 @@ def build(bld):
source='testsuites/ntp01/test_main.c',
cflags=ns_cflags,
includes=ntp_test_incl,
+ defines=[stack_def],
lib=libs,
use=['ntp', stack_name])
@@ -159,6 +162,7 @@ def build(bld):
target='ttcpshell01.exe',
source='testsuites/ttcpshell01/test_main.c',
cflags=ns_cflags,
+ defines=[stack_def],
includes=ttcp_test_incl,
lib=libs,
use=['ttcp', stack_name])
@@ -169,6 +173,7 @@ def build(bld):
target='telnetd01.exe',
source='testsuites/telnetd01/init.c',
cflags=ns_cflags,
+ defines=[stack_def],
includes=test_app_incl,
lib=libs,
use=['telnetd', stack_name])
diff --git a/stack/legacy/include/ntp/config.h b/stack/legacy/include/ntp/config.h
index e0aae2b..fe7090c 100644
--- a/stack/legacy/include/ntp/config.h
+++ b/stack/legacy/include/ntp/config.h
@@ -953,13 +953,13 @@
/* #undef HAVE_SYNCH_H */
/* Define to 1 if you have the `sysconf' function. */
-#define HAVE_SYSCONF 1
+/* #undef HAVE_SYSCONF */
/* Define to 1 if you have the <sysexits.h> header file. */
/* #undef HAVE_SYSEXITS_H */
/* */
-#define HAVE_SYSLOG_FACILITYNAMES 1
+/* #undef HAVE_SYSLOG_FACILITYNAMES */
/* Define to 1 if you have the <sys/audioio.h> header file. */
/* #undef HAVE_SYS_AUDIOIO_H */
@@ -1389,7 +1389,7 @@
#define LT_OBJDIR ".libs/"
/* Does the target support multicast IP? */
-#define MCAST 1
+/* #undef MCAST */
/* Should we recommend a minimum value for tickadj? */
/* #undef MIN_REC_TICKADJ */
diff --git a/testsuites/ntp01/test_main.c b/testsuites/ntp01/test_main.c
index ffc656a..734e742 100644
--- a/testsuites/ntp01/test_main.c
+++ b/testsuites/ntp01/test_main.c
@@ -38,19 +38,67 @@
#include <rtems/ntpd.h>
#include <rtems/shell.h>
+#if RTEMS_NET_LWIP
#include <lwip/dhcp.h>
#include <lwip/prot/dhcp.h>
#include <arch/sys_arch.h>
-
-#include <tmacros.h>
-
#include <netstart.h>
#include <bsd_compat.h>
+#endif
+
+#include <tmacros.h>
const char rtems_test_name[] = "NTP 1";
+static int net_start(void);
+
+#if RTEMS_NET_LWIP
struct netif net_interface;
+static int net_start(void) {
+ ip_addr_t ipaddr, netmask, gw;
+
+ IP_ADDR4( &ipaddr, 10, 0, 2, 14 );
+ IP_ADDR4( &netmask, 255, 255, 255, 0 );
+ IP_ADDR4( &gw, 10, 0, 2, 3 );
+ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x22, 0x01 };
+
+ rtems_bsd_compat_initialize();
+
+ ret = start_networking(
+ &net_interface,
+ &ipaddr,
+ &netmask,
+ &gw,
+ mac_ethernet_address
+ );
+
+ if ( ret != 0 ) {
+ return 1;
+ }
+
+ dhcp_start( &net_interface );
+
+ /*
+ * Wait for DHCP bind to start NTP. lwIP does automatic address updating in
+ * the backend that NTP isn't prepared for which causes socket conflicts when
+ * the socket for the old address gets updated to the new address and NTP's
+ * address information for the old socket is stale. NTP tries to create a new
+ * socket for the new address before deleting the old one and gets an error
+ * because it can't bind twice to the same address. This causes NTP
+ * acquisition to be delayed by minutes in the worst case.
+ */
+ volatile struct dhcp *dhcp_state = netif_dhcp_data(&net_interface);
+ if ( dhcp_state != NULL ) {
+ while (dhcp_state->state != DHCP_STATE_BOUND) {
+ sleep(1);
+ }
+ }
+
+ return 0;
+}
+#endif
+
static const char etc_resolv_conf[] =
"nameserver 8.8.8.8\n";
@@ -330,19 +378,21 @@ static const char etc_services[] =
static void setup_etc(void)
{
int rv;
-
+
+ /* FIXME: no direct IMFS */
+
rv = IMFS_make_linearfile("/etc/resolv.conf", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH, etc_resolv_conf, sizeof(etc_resolv_conf));
assert(rv == 0);
-
+
rv = IMFS_make_linearfile("/etc/ntp.conf", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH, etc_ntp_conf, sizeof(etc_ntp_conf));
assert(rv == 0);
-
+
rv = IMFS_make_linearfile("/etc/leap-seconds", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH, etc_leap_seconds, sizeof(etc_leap_seconds));
assert(rv == 0);
-
+
rv = IMFS_make_linearfile("/etc/services", S_IWUSR | S_IRUSR |
S_IRGRP | S_IROTH, etc_services, sizeof(etc_services));
assert(rv == 0);
@@ -373,47 +423,10 @@ static rtems_task Init( rtems_task_argument argument )
TEST_BEGIN();
- ip_addr_t ipaddr, netmask, gw;
-
- IP_ADDR4( &ipaddr, 10, 0, 2, 14 );
- IP_ADDR4( &netmask, 255, 255, 255, 0 );
- IP_ADDR4( &gw, 10, 0, 2, 3 );
- unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x22, 0x01 };
-
- rtems_bsd_compat_initialize();
-
- ret = start_networking(
- &net_interface,
- &ipaddr,
- &netmask,
- &gw,
- mac_ethernet_address
- );
-
- if ( ret != 0 ) {
- return;
- }
+ rtems_test_assert( net_start() == 0 );
rtems_shell_init_environment();
- dhcp_start( &net_interface );
-
- /*
- * Wait for DHCP bind to start NTP. lwIP does automatic address updating in
- * the backend that NTP isn't prepared for which causes socket conflicts when
- * the socket for the old address gets updated to the new address and NTP's
- * address information for the old socket is stale. NTP tries to create a new
- * socket for the new address before deleting the old one and gets an error
- * because it can't bind twice to the same address. This causes NTP
- * acquisition to be delayed by minutes in the worst case.
- */
- volatile struct dhcp *dhcp_state = netif_dhcp_data(&net_interface);
- if ( dhcp_state != NULL ) {
- while (dhcp_state->state != DHCP_STATE_BOUND) {
- sleep(1);
- }
- }
-
run_test();
TEST_END();
diff --git a/testsuites/telnetd01/init.c b/testsuites/telnetd01/init.c
index 9bb013a..9d78fd1 100644
--- a/testsuites/telnetd01/init.c
+++ b/testsuites/telnetd01/init.c
@@ -27,16 +27,18 @@
*/
#include <rtems/telnetd.h>
+
+#if RTEMS_NET_LWIP
#include <lwip/dhcp.h>
#include <arch/sys_arch.h>
+#include <netstart.h>
+#endif
#include <tmacros.h>
-#include <netstart.h>
-
const char rtems_test_name[] = "TELNETD 1";
-struct netif net_interface;
+static int net_start(void);
rtems_shell_env_t env;
@@ -55,6 +57,9 @@ rtems_telnetd_config_table rtems_telnetd_config = {
.stack_size = 8 * RTEMS_MINIMUM_STACK_SIZE,
};
+#if RTEMS_NET_LWIP
+struct netif net_interface;
+
#define print_ip( tag, ip ) \
printf( \
"%s: %" PRId32 ".%" PRId32 ".%" PRId32 ".%" PRId32 "\n", \
@@ -85,13 +90,7 @@ rtems_shell_cmd_t shell_NETINFO_Command = {
NULL /* next */
};
-static rtems_task Init( rtems_task_argument argument )
-{
- rtems_status_code sc;
- int ret;
-
- TEST_BEGIN();
-
+static int net_start(void) {
ip_addr_t ipaddr, netmask, gw;
IP_ADDR4( &ipaddr, 10, 0, 2, 14 );
@@ -99,6 +98,8 @@ static rtems_task Init( rtems_task_argument argument )
IP_ADDR4( &gw, 10, 0, 2, 3 );
unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x22, 0x01 };
+ rtems_shell_init_environment();
+
ret = start_networking(
&net_interface,
&ipaddr,
@@ -108,13 +109,24 @@ static rtems_task Init( rtems_task_argument argument )
);
if ( ret != 0 ) {
- return;
+ return 1;
}
- rtems_shell_init_environment();
-
dhcp_start( &net_interface );
+ return 0;
+}
+#endif
+
+static rtems_task Init( rtems_task_argument argument )
+{
+ rtems_status_code sc;
+ int ret;
+
+ TEST_BEGIN();
+
+ rtems_test_assert( net_start() == 0 );
+
sc = rtems_telnetd_start( &rtems_telnetd_config );
rtems_test_assert( sc == RTEMS_SUCCESSFUL );
diff --git a/testsuites/ttcpshell01/test_main.c b/testsuites/ttcpshell01/test_main.c
index 164bee4..b3e626c 100644
--- a/testsuites/ttcpshell01/test_main.c
+++ b/testsuites/ttcpshell01/test_main.c
@@ -36,16 +36,20 @@
#include <rtems/shell.h>
#include <rtems/console.h>
#include <ttcp.h>
+
+#if RTEMS_NET_LWIP
#include <lwip/dhcp.h>
#include <arch/sys_arch.h>
-
-#include <tmacros.h>
-
#include <netstart.h>
+#endif
+#include <tmacros.h>
const char rtems_test_name[] = "lwIP TTCP 1";
+static int net_start(void);
+
+#if RTEMS_NET_LWIP
struct netif net_interface;
rtems_shell_cmd_t shell_TTCP_Command = {
@@ -57,13 +61,7 @@ rtems_shell_cmd_t shell_TTCP_Command = {
NULL /* next */
};
-static rtems_task Init( rtems_task_argument argument )
-{
- rtems_status_code sc;
- int ret;
-
- TEST_BEGIN();
-
+static int net_start(void) {
ip_addr_t ipaddr, netmask, gw;
IP_ADDR4( &ipaddr, 10, 0, 2, 14 );
@@ -80,13 +78,25 @@ static rtems_task Init( rtems_task_argument argument )
);
if ( ret != 0 ) {
- return;
+ return 1;
}
- rtems_shell_init_environment();
-
dhcp_start( &net_interface );
+ return 0;
+}
+
+static rtems_task Init( rtems_task_argument argument )
+{
+ rtems_status_code sc;
+ int ret;
+
+ TEST_BEGIN();
+
+ rtems_test_assert( net_start() == 0 );
+
+ rtems_shell_init_environment();
+
sc = rtems_shell_init(
"SHLL", /* task name */
RTEMS_MINIMUM_STACK_SIZE * 4, /* task stack size */
diff --git a/ttcp/ttcp.c b/ttcp/ttcp.c
index 73ac2a6..ae358d0 100644
--- a/ttcp/ttcp.c
+++ b/ttcp/ttcp.c
@@ -67,8 +67,10 @@
#define __need_getopt_newlib
#include <getopt.h>
#include <rtems/shell.h>
+#if RTEMS_NET_LWIP
#include <lwip/inet.h>
#include <lwip/netdb.h>
+#endif
#undef TCP_NODELAY
#define select lwip_select
#endif