summaryrefslogtreecommitdiffstats
path: root/dnstest
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-21 13:13:06 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1998-08-21 13:13:06 +0000
commit8cfa3aa0c87e24822964dfcca00f2b21b85dd147 (patch)
treef5b6a15a1b29354695bcebafbbcab2e06af4a01d /dnstest
parentAdded gratuitous arp and commented out a confusing printf. (diff)
downloadnetwork-demos-8cfa3aa0c87e24822964dfcca00f2b21b85dd147.tar.bz2
New files
Diffstat (limited to 'dnstest')
-rw-r--r--dnstest/Makefile59
-rw-r--r--dnstest/init.c56
-rw-r--r--dnstest/test.c116
3 files changed, 231 insertions, 0 deletions
diff --git a/dnstest/Makefile b/dnstest/Makefile
new file mode 100644
index 0000000..03fa00a
--- /dev/null
+++ b/dnstest/Makefile
@@ -0,0 +1,59 @@
+SAMPLE=dnstest
+PGM=${ARCH}/$(SAMPLE).exe
+
+MANAGERS=io event semaphore
+
+# C source names, if any, go here -- minus the .c
+C_PIECES= init test
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+DOCTYPES=
+DOCS=$(DOCTYPES:%=$(SAMPLE).%)
+
+SRCS=$(DOCS) $(C_FILES) $(CC_FILES) $(H_FILES) $(S_FILES)
+OBJS=$(C_O_FILES) $(CC_O_FILES) $(S_O_FILES)
+
+PRINT_SRCS=$(DOCS)
+
+PGM=${ARCH}/$(SAMPLE).exe
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+CFLAGS_LD += -Wl,--defsym -Wl,HeapSize=0xC0000
+CFLAGS_OPTIMIZE_V +=
+CFLAGS_DEBUG_V += -v -qrtems_debug
+
+LD_PATHS +=
+LD_LIBS +=
+
+#
+# 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) $(PGM)
+
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+# 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/dnstest/init.c b/dnstest/init.c
new file mode 100644
index 0000000..3075468
--- /dev/null
+++ b/dnstest/init.c
@@ -0,0 +1,56 @@
+/*
+ * RTEMS configuration/initialization
+ *
+ * This program may be distributed and used for any purpose.
+ * I ask only that you:
+ * 1. Leave this author information intact.
+ * 2. Document any changes you make.
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ */
+
+#include <bsp.h>
+
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024)
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+#define CONFIGURE_MAXIMUM_TASKS 20
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 10486
+
+#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
+#define CONFIGURE_INIT_TASK_PRIORITY 100
+#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
+ RTEMS_NO_TIMESLICE | \
+ RTEMS_NO_ASR | \
+ RTEMS_INTERRUPT_LEVEL(0))
+
+#define CONFIGURE_INIT
+rtems_task Init (rtems_task_argument argument);
+
+#include <confdefs.h>
+
+#include <stdio.h>
+#include <rtems/rtems_bsdnet.h>
+#include "../networkconfig.h"
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ void testDNS(void);
+
+ rtems_bsdnet_initialize_network ();
+ testDNS ();
+ exit (0);
+}
+
diff --git a/dnstest/test.c b/dnstest/test.c
new file mode 100644
index 0000000..1e88690
--- /dev/null
+++ b/dnstest/test.c
@@ -0,0 +1,116 @@
+/*
+ * Test RTEMS networking
+ *
+ * This program may be distributed and used for any purpose.
+ * I ask only that you:
+ * 1. Leave this author information intact.
+ * 2. Document any changes you make.
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <rtems.h>
+#include <rtems/rtems_bsdnet.h>
+#include <rtems/error.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+
+/*
+ * Show network-related statistics
+ */
+static void
+showStatistics (void)
+{
+ rtems_bsdnet_show_inet_routes ();
+ rtems_bsdnet_show_mbuf_stats ();
+ rtems_bsdnet_show_if_stats ();
+ rtems_bsdnet_show_ip_stats ();
+ rtems_bsdnet_show_icmp_stats ();
+ rtems_bsdnet_show_udp_stats ();
+ rtems_bsdnet_show_tcp_stats ();
+}
+
+/*
+ * Show host information
+ */
+static void
+showhost (struct hostent *hp)
+{
+ char **ap;
+ struct in_addr in;
+
+ if (hp == NULL) {
+ printf ("Host information not available.\n");
+ return;
+ }
+ printf ("Official name: %s\n", hp->h_name);
+ ap = hp->h_aliases;
+ if (ap && *ap) {
+ printf ("Alias%s:\n", ap[1] ? "es" : "");
+ while (*ap)
+ printf (" %s\n", *ap++);
+ }
+ if ((hp->h_addrtype == AF_INET) && (hp->h_length == sizeof in)) {
+ ap = hp->h_addr_list;
+ if (ap && *ap) {
+ printf ("Address%s:", ap[1] ? "es" : "");
+ while (*ap) {
+ memcpy (&in, *ap++, sizeof in);
+ printf (" %s", inet_ntoa (in));
+ }
+ printf ("\n");
+ }
+ }
+ else {
+ printf ("Address type: %d\n", hp->h_addrtype);
+ printf ("Address length: %d\n", hp->h_length);
+ }
+}
+
+/*
+ * Test Domain Name Servers
+ */
+void
+testDNS (void)
+{
+ char namebuf[100];
+ char *name, *cp;
+ struct hostent *hp;
+
+ for (;;) {
+ printf ("\nhost? ");
+ if (fgets (namebuf, sizeof namebuf, stdin) == NULL)
+ return;
+ cp = namebuf;
+ while (isspace (*cp))
+ cp++;
+ if (cp[0] == '\0') {
+ showStatistics ();
+ continue;
+ }
+ name = cp;
+ while (isgraph (*cp))
+ cp++;
+ *cp = '\0';
+ if (isdigit(*name)) {
+ struct in_addr addr;
+
+ addr.s_addr = inet_addr (name);
+ hp = gethostbyaddr ((char *)&addr, sizeof addr, AF_INET);
+ }
+ else {
+ hp = gethostbyname (name);
+ }
+ showhost (hp);
+ }
+}