summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2023-04-19 13:29:29 -0500
committerKinsey Moore <kinsey.moore@oarcorp.com>2023-04-19 13:29:29 -0500
commit51f9c567d97fa78e84e1829e6b53522117ab1f0b (patch)
tree4d8fe792baf38830b37ea2e95c6c7a4d04287b4c
parentlibbsd: Get network tests compiling under libbsd (diff)
downloadrtems-net-services-51f9c567d97fa78e84e1829e6b53522117ab1f0b.tar.bz2
libbsd: Get telnet functional
Telnet has also been tested to be functional under lwIP. NTP needs rework at least under libbsd.
-rw-r--r--stack/legacy/include/net_adapter_extra.h3
-rw-r--r--stack/libbsd/include/net_adapter_extra.h13
-rw-r--r--stack/libbsd/net_adapter.c53
-rw-r--r--stack/lwip/include/net_adapter_extra.h3
-rw-r--r--testsuites/ntp01/test_main.c20
-rw-r--r--testsuites/telnetd01/init.c23
-rw-r--r--testsuites/ttcpshell01/test_main.c25
7 files changed, 105 insertions, 35 deletions
diff --git a/stack/legacy/include/net_adapter_extra.h b/stack/legacy/include/net_adapter_extra.h
new file mode 100644
index 0000000..61972d3
--- /dev/null
+++ b/stack/legacy/include/net_adapter_extra.h
@@ -0,0 +1,3 @@
+#include <bsp/irq-info.h>
+#define CONFIGURE_SHELL_USER_COMMANDS_ADAPTER \
+ &bsp_interrupt_shell_command
diff --git a/stack/libbsd/include/net_adapter_extra.h b/stack/libbsd/include/net_adapter_extra.h
new file mode 100644
index 0000000..e01a53f
--- /dev/null
+++ b/stack/libbsd/include/net_adapter_extra.h
@@ -0,0 +1,13 @@
+#include <rtems/netcmds-config.h>
+#include <bsp/irq-info.h>
+#define CONFIGURE_SHELL_USER_COMMANDS_ADAPTER \
+ &bsp_interrupt_shell_command, \
+ &rtems_shell_ARP_Command, \
+ &rtems_shell_HOSTNAME_Command, \
+ &rtems_shell_PING_Command, \
+ &rtems_shell_ROUTE_Command, \
+ &rtems_shell_NETSTAT_Command, \
+ &rtems_shell_IFCONFIG_Command, \
+ &rtems_shell_TCPDUMP_Command, \
+ &rtems_shell_SYSCTL_Command, \
+ &rtems_shell_VMSTAT_Command
diff --git a/stack/libbsd/net_adapter.c b/stack/libbsd/net_adapter.c
index 1c39f72..3760c89 100644
--- a/stack/libbsd/net_adapter.c
+++ b/stack/libbsd/net_adapter.c
@@ -40,14 +40,26 @@
#include <machine/rtems-bsd-commands.h>
#include <rtems/rtems/status.h>
#include <fcntl.h>
-//#include <ifaddrs.h>
#include <stdio.h>
-//#include <stdlib.h>
+#include <stdlib.h>
#include <unistd.h>
#include <rtems/dhcpcd.h>
#include <rtems/bsd/bsd.h>
#include <rtems/bsd/iface.h>
+#define RTEMS_BSD_CONFIG_NET_PF_UNIX
+#define RTEMS_BSD_CONFIG_NET_IP_MROUTE
+
+#ifdef RTEMS_BSD_MODULE_NETINET6
+#define RTEMS_BSD_CONFIG_NET_IP6_MROUTE
+#endif
+
+#define RTEMS_BSD_CONFIG_NET_IF_BRIDGE
+#define RTEMS_BSD_CONFIG_NET_IF_LAGG
+#define RTEMS_BSD_CONFIG_NET_IF_VLAN
+#define RTEMS_BSD_CONFIG_BSP_CONFIG
+#define RTEMS_BSD_CONFIG_INIT
+#include <machine/rtems-bsd-config.h>
static void
default_network_ifconfig_hwif0(char *ifname)
@@ -88,22 +100,12 @@ default_network_dhcpcd(void)
}
static void
-default_wait_for_link_up( const char *name )
+default_network_set_self_prio(rtems_task_priority prio)
{
- size_t seconds = 0;
- while ( true ) {
- bool link_active = false;
- assert(rtems_bsd_iface_link_state( name, &link_active ) == 0);
- if (link_active) {
- return;
- }
- sleep( 1 );
- ++seconds;
- if (seconds > 10) {
- printf("error: %s: no active link\n", name);
- assert(seconds < 10);
- }
- }
+ rtems_status_code sc;
+
+ sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio);
+ assert(sc == RTEMS_SUCCESSFUL);
}
int net_start()
@@ -112,6 +114,14 @@ int net_start()
char ifnamebuf[IF_NAMESIZE];
rtems_status_code sc;
+ /*
+ * Default the syslog priority to 'debug' to aid developers.
+ */
+ rtems_bsd_setlogpriority("debug");
+
+ /* Let other tasks run to complete background work */
+ default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U);
+
rtems_bsd_initialize();
ifname = if_indextoname(1, &ifnamebuf[0]);
@@ -120,17 +130,10 @@ int net_start()
sc = rtems_task_wake_after(2);
assert(sc == RTEMS_SUCCESSFUL);
- default_network_ifconfig_hwif0(ifname);
rtems_bsd_ifconfig_lo0();
+ default_network_ifconfig_hwif0(ifname);
default_network_dhcpcd();
- /*
- * Per test option to wait for the network interface. If the address
- * is static the PHY may take a while to connect and bring the
- * interface online.
- */
- default_wait_for_link_up( ifname );
-
// needs to wait for DHCP to finish
return 0;
}
diff --git a/stack/lwip/include/net_adapter_extra.h b/stack/lwip/include/net_adapter_extra.h
new file mode 100644
index 0000000..61972d3
--- /dev/null
+++ b/stack/lwip/include/net_adapter_extra.h
@@ -0,0 +1,3 @@
+#include <bsp/irq-info.h>
+#define CONFIGURE_SHELL_USER_COMMANDS_ADAPTER \
+ &bsp_interrupt_shell_command
diff --git a/testsuites/ntp01/test_main.c b/testsuites/ntp01/test_main.c
index 229a013..76c2f9e 100644
--- a/testsuites/ntp01/test_main.c
+++ b/testsuites/ntp01/test_main.c
@@ -39,6 +39,7 @@
#include <rtems/shell.h>
#include <net_adapter.h>
+#include <net_adapter_extra.h>
#include <tmacros.h>
@@ -384,7 +385,7 @@ static rtems_task Init( rtems_task_argument argument )
#include <bsp/irq-info.h>
#define CONFIGURE_SHELL_USER_COMMANDS \
- &bsp_interrupt_shell_command, \
+ CONFIGURE_SHELL_USER_COMMANDS_ADAPTER, \
&rtems_shell_DATE_Command, \
&rtems_shell_SHUTDOWN_Command
@@ -401,10 +402,23 @@ static rtems_task Init( rtems_task_argument argument )
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER
-#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32
+#define CONFIGURE_MAXIMUM_DRIVERS 32
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 64
-#define CONFIGURE_MAXIMUM_TASKS 12
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
+#define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32
+
+#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024)
+#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4
+#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024)
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+
+#define CONFIGURE_MAXIMUM_TASKS 25
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
diff --git a/testsuites/telnetd01/init.c b/testsuites/telnetd01/init.c
index 03edfa3..83b018c 100644
--- a/testsuites/telnetd01/init.c
+++ b/testsuites/telnetd01/init.c
@@ -29,6 +29,7 @@
#include <rtems/telnetd.h>
#include <net_adapter.h>
+#include <net_adapter_extra.h>
#include <tmacros.h>
@@ -85,14 +86,30 @@ static rtems_task Init( rtems_task_argument argument )
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER
-#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32
+#define CONFIGURE_MAXIMUM_DRIVERS 32
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 64
+
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
+#define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32
+
+#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024)
+#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4
+#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024)
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+
+#define CONFIGURE_SHELL_USER_COMMANDS \
+ CONFIGURE_SHELL_USER_COMMANDS_ADAPTER
+
+#define CONFIGURE_MAXIMUM_TASKS 25
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
-#define CONFIGURE_MAXIMUM_TASKS 12
-
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
diff --git a/testsuites/ttcpshell01/test_main.c b/testsuites/ttcpshell01/test_main.c
index c84a788..06eeaeb 100644
--- a/testsuites/ttcpshell01/test_main.c
+++ b/testsuites/ttcpshell01/test_main.c
@@ -38,6 +38,7 @@
#include <ttcp.h>
#include <net_adapter.h>
+#include <net_adapter_extra.h>
#include <tmacros.h>
@@ -85,14 +86,30 @@ static rtems_task Init( rtems_task_argument argument )
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER
-#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32
+#define CONFIGURE_MAXIMUM_DRIVERS 32
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 64
+
+#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
+
+#define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32
+
+#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024)
+#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4
+#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024)
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024)
+
+#define CONFIGURE_SHELL_USER_COMMANDS \
+ CONFIGURE_SHELL_USER_COMMANDS_ADAPTER, \
+ &shell_TTCP_Command
+
+#define CONFIGURE_MAXIMUM_TASKS 25
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
-#define CONFIGURE_SHELL_USER_COMMANDS &shell_TTCP_Command
-
-#define CONFIGURE_MAXIMUM_TASKS 12
#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 20