From 8cfa3aa0c87e24822964dfcca00f2b21b85dd147 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 21 Aug 1998 13:13:06 +0000 Subject: New files --- dnstest/Makefile | 59 ++++++++++++++++++++++++++++ dnstest/init.c | 56 +++++++++++++++++++++++++++ dnstest/test.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 231 insertions(+) create mode 100644 dnstest/Makefile create mode 100644 dnstest/init.c create mode 100644 dnstest/test.c 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 + +#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 + +#include +#include +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * 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); + } +} -- cgit v1.2.3