Hi,
Currently, there is no way to override the tftpserver as retrieved from
a dhcp, bootp or rarp server. The included patch adds the following
commands:
tftpserver - change the tftpserver
network - display the current network configuration
This patch is for the user that wishes to boot a kernel from a tftp
server but does not have access to the dhcp server to change the
configuration. It is also available at:
ftp://walfield.org/pub/people/neal/grub/tftpserver-0.5.94.
This patch should apply cleanly to a vanilla 0.5.94 grub.
Enjoy,
-Neal
--
----------------------------------------------------------------------------
Neal Walfield [EMAIL PROTECTED]
UMass Lowell - Fox 1512 Phone: 978-934-5347
Fax: 603-415-3645
Love is the triumph of imagination over intelligence.
-- H. L. Mencken
--- grub-0.5.94/ChangeLog Tue Mar 21 11:03:35 2000
+++ grub-0.5.94-new/ChangeLog Sun Apr 23 00:11:08 2000
@@ -1,3 +1,17 @@
+2000-04-22 Neal H Walfield <[EMAIL PROTECTED]>
+
+ * stage2/builtins.c: Added the print_network_configuration_func
+ (`network') command to dump the current network configuration via
+ print_network_configuration ().
+ Added the tftpserver_func (`tftpserver') command to change the
+ tftpserver retrieved via dhcp, bootp or rarp.
+
+ * netboot/main.c: Added the function arp_server_override.
+ This function takes a string holding a network address and
+ replaces the current server with it (arptable[ARP_SERVER]).
+
+ * netboot/etherboot.h: Added the arp_server_override prototype.
+
2000-03-21 Gordon Matzigkeit <[EMAIL PROTECTED]>
* stage2/Makefile.am (start_exec-start.o): Force dependency on
diff -r -u grub-0.5.94/netboot/etherboot.h grub-0.5.94-new/netboot/etherboot.h
--- grub-0.5.94/netboot/etherboot.h Thu Feb 10 21:50:35 2000
+++ grub-0.5.94-new/netboot/etherboot.h Sat Apr 22 19:56:19 2000
@@ -343,6 +343,7 @@
***************************************************************************/
/* main.c */
extern void print_network_configuration (void);
+extern int arp_server_override P((char *buf));
#if 0
extern void print_bytes P((unsigned char *bytes, int len));
diff -r -u grub-0.5.94/netboot/main.c grub-0.5.94-new/netboot/main.c
--- grub-0.5.94/netboot/main.c Sat Feb 12 02:00:47 2000
+++ grub-0.5.94-new/netboot/main.c Sat Apr 22 23:33:51 2000
@@ -151,6 +151,115 @@
}
}
+int
+arp_server_override (char *buffer)
+{
+
+ int addr[4];
+
+ /* ip presentation to number */
+ static int inet_pton (char *input, int addr[4])
+ {
+ int i;
+ int octet;
+ char *str;
+ int invalid;
+ int have_digit;
+
+ /* The buffer should point to a valid ip address */
+ str = input;
+
+ /* Ignore white space */
+ while (*str == ' ')
+ str++;
+
+ invalid = 0;
+ octet = 0;
+ i = 0;
+ have_digit = 0;
+ for (;;)
+ {
+ /* Digit */
+ if (*str >= '0' && *str <= '9')
+ {
+ octet = octet * 10 + *str - '0';
+ have_digit = 1;
+ str ++;
+ continue;
+ }
+
+ /* Seperator */
+ if (*str == '.')
+ {
+ if (! have_digit)
+ {
+ invalid = 1;
+ break;
+ }
+ addr[i++] = octet;
+ octet = 0;
+ have_digit = 0;
+ str++;
+
+ if (i == 4)
+ break;
+ else
+ continue;
+ }
+
+ /* End of string? */
+ if (! *str)
+ {
+ if (have_digit)
+ addr[i++] = octet;
+ break;
+ }
+
+ invalid = 1;
+ break;
+ }
+
+ if (invalid)
+ return 1;
+
+ /* Eat any trailing white space */
+ while (*str == ' ')
+ str++;
+ /* Make sure we are at the end of the string */
+ if (*str != '\0')
+ return 1;
+
+ /* Is the address a nice a a.b.c.d? If not, convert */
+ if (i < 4)
+ {
+ int j;
+
+ octet = addr[i - 1];
+ for (j = 3; j >= i - 1; j--)
+ {
+ addr[j] = octet & 0xFF;
+ octet >>= 8;
+ }
+ }
+
+ /* Acceptable */
+ return 0;
+ }
+
+ if (inet_pton (buffer, addr) != 0)
+ {
+ grub_printf ("Invalid ip address.\n");
+ return 0;
+ }
+
+ grub_printf("tftpserver is: %d.%d.%d.%d\n", addr[0], addr[1], addr[2], addr[3]);
+
+ arptable[ARP_SERVER].ipaddr.s_addr = (addr[0]) + (addr[1] << 8)
+ + (addr[2] << 16) + (addr[3] << 24);
+
+ return 0;
+}
+
/**************************************************************************
DEFAULT_NETMASK - Return default netmask for IP address
**************************************************************************/
diff -r -u grub-0.5.94/stage2/builtins.c grub-0.5.94-new/stage2/builtins.c
--- grub-0.5.94/stage2/builtins.c Tue Feb 29 16:47:48 2000
+++ grub-0.5.94-new/stage2/builtins.c Sat Apr 22 23:30:05 2000
@@ -2165,6 +2165,29 @@
};
+static int
+print_network_configuration_func (char *arg, int flags)
+{
+#ifdef SUPPORT_NETBOOT
+ /* Notify the configuration. */
+ print_network_configuration ();
+ return 0;
+#else
+ errnum = ERR_UNRECOGNIZED;
+ return 1;
+#endif
+}
+
+static struct builtin builtin_network =
+{
+ "network",
+ print_network_configuration_func,
+ BUILTIN_CMDLINE,
+ "network",
+ "Print the current network configuration."
+};
+
+
/* Print the root device information. */
static void
print_root_device (void)
@@ -2824,6 +2847,39 @@
};
+/* tftpserver */
+static int
+tftpserver_func (char *arg, int flags)
+{
+#ifdef SUPPORT_NETBOOT
+ /* Check that a server was specified */
+ if (! *arg)
+ {
+ grub_printf ("Specify an ip address.\n");
+ return 1;
+ }
+
+ arp_server_override(arg);
+ return 0;
+
+#else
+ errnum = ERR_UNRECOGNIZED;
+ return 1;
+#endif
+}
+
+static struct builtin builtin_tftpserver =
+{
+ "tftpserver",
+ tftpserver_func,
+ BUILTIN_CMDLINE,
+ "tftpserver IPADDR",
+ "Override the tftp server retrieved from the dhcp, bootp or rarp server."
+ " This is useful when the server either assigns the wrong tftp server"
+ " or does not assign one."
+};
+
+
/* timeout */
static int
timeout_func (char *arg, int flags)
@@ -2957,6 +3013,7 @@
&builtin_map,
&builtin_module,
&builtin_modulenounzip,
+ &builtin_network,
&builtin_password,
&builtin_pause,
&builtin_quit,
@@ -2967,6 +3024,7 @@
&builtin_setkey,
&builtin_setup,
&builtin_testload,
+ &builtin_tftpserver,
&builtin_timeout,
&builtin_title,
&builtin_unhide,