summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-25 16:52:12 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-09-25 16:52:12 +0000
commitc88644cf5a6aae414656ef8ae47f5afac65c4c51 (patch)
treee26df7dd9056ec61a818343435418a4f1e28b7e2
parenta287b899e8cab06d557f2308d4801c237d85b9dd (diff)
2007-09-25 Joel Sherrill <joel.sherrill@oarcorp.com>
* .cvsignore, ChangeLog, Makefile, init.c: New files.
-rw-r--r--telnetd/.cvsignore1
-rw-r--r--telnetd/ChangeLog4
-rw-r--r--telnetd/Makefile63
-rw-r--r--telnetd/init.c153
4 files changed, 221 insertions, 0 deletions
diff --git a/telnetd/.cvsignore b/telnetd/.cvsignore
new file mode 100644
index 0000000..fecf58a
--- /dev/null
+++ b/telnetd/.cvsignore
@@ -0,0 +1 @@
+o-optimize
diff --git a/telnetd/ChangeLog b/telnetd/ChangeLog
new file mode 100644
index 0000000..d886edc
--- /dev/null
+++ b/telnetd/ChangeLog
@@ -0,0 +1,4 @@
+2007-09-25 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * .cvsignore, ChangeLog, Makefile, init.c: New files.
+
diff --git a/telnetd/Makefile b/telnetd/Makefile
new file mode 100644
index 0000000..8be56e6
--- /dev/null
+++ b/telnetd/Makefile
@@ -0,0 +1,63 @@
+#
+# $Id$
+#
+
+SAMPLE=telnetd
+PGM=${ARCH}/$(SAMPLE).exe
+
+MANAGERS=all
+
+# C source names, if any, go here -- minus the .c
+C_FILES=init.c
+C_O_FILES=$(C_FILES:%.c=${ARCH}/%.o)
+
+H_FILES=
+
+DOCTYPES=
+DOCS=$(DOCTYPES:%=$(SAMPLE).%)
+
+SRCS=$(DOCS) $(C_FILES)
+OBJS=$(C_O_FILES)
+
+PRINT_SRCS=$(DOCS)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS_LD +=
+CFLAGS_OPTIMIZE_V +=
+CFLAGS_DEBUG_V += -v -qrtems_debug
+
+LD_PATHS +=
+LD_LIBS += -ltelnetd
+
+CFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(OBJS) $(PGM)
+
+${PGM}: $(ARCH) $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+${ARCH}/init.o: ${ARCH} init.c
+
+# Install the program(s), appending _g or _p as appropriate.
+# for include files, just use $(INSTALL)
+install: all
+ $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
diff --git a/telnetd/init.c b/telnetd/init.c
new file mode 100644
index 0000000..729573f
--- /dev/null
+++ b/telnetd/init.c
@@ -0,0 +1,153 @@
+/* Init
+ *
+ * This routine is the initialization task for this test program.
+ *
+ * Don't forget to change the IP addresses
+ */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
+#define CONFIGURE_MAXIMUM_PTYS 1
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_MEMORY_OVERHEAD 256
+#define CONFIGURE_MESSAGE_BUFFER_MEMORY 32 * 1024
+#define CONFIGURE_MAXIMUM_SEMAPHORES 40
+#define CONFIGURE_MAXIMUM_TASKS 20
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (64*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 120
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+
+#define CONFIGURE_MAXIMUM_DRIVERS 10
+#define CONFIGURE_INIT
+
+#include <stdlib.h>
+#include <rtems.h>
+#include <rtems/telnetd.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+/* configuration information */
+
+#include <rtems/confdefs.h>
+#include <bsp.h>
+
+#include <errno.h>
+#include <time.h>
+
+#include <rtems/confdefs.h>
+#include <stdio.h>
+#include <rtems/rtems_bsdnet.h>
+#include <rtems/telnetd.h>
+#include <rtems/shell.h>
+
+
+#include <rtems/error.h>
+#include <rpc/rpc.h>
+#include <netinet/in.h>
+#include <time.h>
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include "../networkconfig.h"
+
+/*
+ * Number of sessions
+ */
+int session = 0;
+
+/*
+ * Macro to printf and printk the same arguments
+ */
+
+#define printKF( ... ) \
+ do { \
+ printf( __VA_ARGS__ ); \
+ printk( __VA_ARGS__ ); \
+ } while (0)
+
+
+/*
+ * echo shell
+ */
+void echoShell(
+ char *pty_name,
+ void *cmd_arg
+)
+{
+ int cmds = 0;
+ char line[256];
+ char *c;
+ int l;
+
+ ++session;
+ printKF( "Connected to %s with argument %p for session %d\n",
+ pty_name, cmd_arg, session );
+
+ while (1) {
+ cmds++;
+ printf( "> " );
+ c = fgets( line, 256, stdin );
+ if ( !c ) {
+ printKF( "Connection terminated\n");
+ return;
+ }
+ l = strlen( line );
+ if ( line[l-1] == '\n' ) {
+ line[l-1] = '\0';
+ }
+ if ( !strcmp( line, "bye" ) ) {
+ printKF( "%s", "Terminating connection\n");
+ return;
+ }
+ if ( !strcmp( line, "exit" ) ) {
+ printKF("\n\n*** End of Telnetd Server Test ***\n\r" );
+ exit(0);
+ }
+ printKF( "echo %d-%d> %s\n", session, cmds, line );
+ }
+}
+
+/*
+ * Init task
+ */
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ printf("\n\n*** Telnetd Server Test ***\n\r" );
+
+ printf("============== Initializing Network ==============\n");
+ rtems_bsdnet_initialize_network ();
+
+ printf("============== Add Route ==============\n");
+ rtems_bsdnet_show_inet_routes ();
+
+ printf("============== Start Telnetd ==============\n");
+ printk( "Starting echoShell via telnetd -- default password is rtems\n" );
+ rtems_telnetd_initialize(
+ echoShell, /* "shell" function */
+ NULL, /* no context necessary for echoShell */
+ FALSE, /* spawn a new thread */
+ RTEMS_MINIMUM_STACK_SIZE, /* default stack size please */
+ 1 /* priority .. we feel important today */
+ );
+
+ printf("============== Deleting Init Task ==============\n");
+ rtems_task_delete(RTEMS_SELF);
+}
+