From 19a33c694c30f3554f6989f95e86087c7b26e4d2 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 12 Aug 1998 23:06:42 +0000 Subject: Added support for non-bootp servers --- tftpTest/init.c | 30 ++++++++++++++++++++++++++++-- tftpTest/test.c | 26 +++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/tftpTest/init.c b/tftpTest/init.c index 34df675..869de33 100644 --- a/tftpTest/init.c +++ b/tftpTest/init.c @@ -42,7 +42,9 @@ rtems_driver_address_table Device_drivers[] = { #include +#if (defined (USE_BOOTP)) #include +#endif extern void testTFTP (void); /* @@ -69,7 +71,14 @@ Init (rtems_task_argument ignored) /* * Hook up drivers */ - if (rtems_ka9q_execute_command ("attach rtems broadcast n ether " MY_ETHERNET_ADDRESS)) +#if (defined (USE_BOOTP)) + if (rtems_ka9q_execute_command ("attach rtems broadcast y" + " ether " MY_ETHERNET_ADDRESS)) +#else + if (rtems_ka9q_execute_command ("attach rtems broadcast y" + " ip " MY_IP_ADDRESS + " ether " MY_ETHERNET_ADDRESS)) +#endif rtems_panic ("Can't attach Ethernet driver.\n"); /* @@ -84,6 +93,9 @@ Init (rtems_task_argument ignored) if (rtems_ka9q_execute_command ("arp add 255.255.255.255 ether FF:FF:FF:FF:FF:FF")) rtems_panic ("Can't add broadcast entry to ARP table.\n"); +#if (defined (USE_BOOTP)) + { + int i; /* * Get BOOTP information */ @@ -92,8 +104,22 @@ Init (rtems_task_argument ignored) break; if (++i == 10) rtems_panic ("Can't get information from BOOTP server.\n"); - rtems_task_wake_after (i * ticksPerSecond); + delay_task (i); + } + if (BootpFileName) + printf ("BOOTP filename: `%s'\n", BootpFileName); + else + printf ("BOOTP -- No filename!\n"); } +#else + if (rtems_ka9q_execute_command ("ifconfig rtems netmask 255.255.255.0")) + rtems_panic ("Can't set netmask.\n"); + if (rtems_ka9q_execute_command ("route add default rtems")) + rtems_panic ("Can't add default route.\n"); + printf ("Routing table after adding default route\n"); + rtems_ka9q_execute_command ("route"); +#endif + /* * Test TFTP driver diff --git a/tftpTest/test.c b/tftpTest/test.c index b900030..6c78da7 100644 --- a/tftpTest/test.c +++ b/tftpTest/test.c @@ -21,6 +21,8 @@ #include #include +#include "../usercfg.h" + static char cbuf[1024]; static char *fullname; static rtems_interval then, now; @@ -107,17 +109,32 @@ static int makeFullname (rtems_unsigned32 host, const char *file) { const char *hostname; +#if !defined(USE_BOOTP) + static char name[16]; +#endif + + printf( "makeFullname(0x08%x, %s)\n", host, file); +#if (defined (USE_BOOTP)) if (host) { hostname = rtems_hostname_for_address (BootpHost.s_addr, 0); if (hostname == NULL) { printf ("No host to read from!\n"); return 0; } + } else { + hostname = ""; } - else { +#else + if (host) { + sprintf( name, "%d.%d.%d.%d", host >> 24, (host >> 16) & 0xff, + (host >> 8) & 0xff, host & 0xff + ); + hostname = name; + } else { hostname = ""; } +#endif fullname = realloc (fullname, 8 + strlen (file) + strlen (hostname)); sprintf (fullname, "/TFTP/%s/%s", hostname, file); printf ("Read `%s'.\n", fullname); @@ -146,14 +163,17 @@ testTFTP (void) /* * Check read speed */ +#if (defined (USE_BOOTP)) if (BootpFileName == NULL) { printf ("Nothing to read!\n"); return; } if (makeFullname (BootpHost.s_addr, BootpFileName)) { +#else + if (makeFullname (aton (DATA_SOURCE_HOST), DATA_SOURCE_FILE)) { +#endif + testRawRead (); testFread (); } } - #include - int foo = INT_MAX; -- cgit v1.2.3