From 7ca6bf9d91f84dea748ee1e537299cca8059f8f4 Mon Sep 17 00:00:00 2001 From: okuji Date: Mon, 29 May 2000 08:59:38 +0000 Subject: [PATCH] add a new command tftpserver. --- ChangeLog | 11 +++++++++++ NEWS | 2 ++ netboot/etherboot.h | 3 +++ netboot/main.c | 13 +++++++++++++ netboot/misc.c | 7 +++---- stage2/builtins.c | 30 ++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0f23b0e8..8dd2f9729 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-05-29 OKUJI Yoshinori + + Based on a patch by Neal H Walfield : + * netboot/misc.c [GRUB] (inet_aton): Defined. + * netboot/main.c (arp_server_override): New function. + * netboot/etherboot.h [GRUB] (arp_server_override): Declared. + (inet_aton): Likewise. + * stage2/builtins.c (tftpserver_func): New function. + (builtin_tftpserver): New variable. + (builtin_table): Added a pointer to BUILTIN_TFTPSERVER. + 2000-05-28 OKUJI Yoshinori * stage2/asm.S (codestart): Fix a typo: DISKLESS_SUPPORT -> diff --git a/NEWS b/NEWS index 14165a938..be9609799 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ New in 0.5.95 - XXXX-XX-XX: and "make" will produce two additional images, ``nbgrub'' for Net Boot Image Proposal and ``pxegrub'' for Preboot Execution Environment. See the documentation, for more details. +* The command "tftpserver" overrides a TFTP server address returned by a + BOOTP server, a DHCP server or a RARP server. New in 0.5.94 - 2000-03-06: * Stage 1 supports both the LBA mode and the CHS mode. diff --git a/netboot/etherboot.h b/netboot/etherboot.h index 846662dfd..97f61f831 100644 --- a/netboot/etherboot.h +++ b/netboot/etherboot.h @@ -457,6 +457,7 @@ External prototypes /* main.c */ #ifdef GRUB extern void print_network_configuration P((void)); +extern int arp_server_override P((const char *buf)); #endif /* GRUB */ #ifndef GRUB @@ -517,7 +518,9 @@ extern int getdec P((char **)); #ifndef GRUB extern void printf P((const char *, ...)); extern char *sprintf P((char *, const char *, ...)); +#endif /* ! GRUB */ extern int inet_aton P((char *p, in_addr *i)); +#ifndef GRUB extern void gateA20_set P((void)); extern void gateA20_unset P((void)); extern void putchar P((int)); diff --git a/netboot/main.c b/netboot/main.c index 1667c36ec..186ebe61b 100644 --- a/netboot/main.c +++ b/netboot/main.c @@ -167,6 +167,19 @@ print_network_configuration (void) } } +/* Override the server IP address. */ +int +arp_server_override (const char *buffer) +{ + in_addr in; + + if (! inet_aton ((char *) buffer, &in)) + return 0; + + arptable[ARP_SERVER].ipaddr.s_addr = in.s_addr; + return 1; +} + /************************************************************************** DEFAULT_NETMASK - Return default netmask for IP address **************************************************************************/ diff --git a/netboot/misc.c b/netboot/misc.c index 9d8d04a1d..4fc42d68d 100644 --- a/netboot/misc.c +++ b/netboot/misc.c @@ -159,8 +159,9 @@ void printf(const char *fmt, ...) do_printf(buf, fmt, ((const int *)&fmt)+1); while (*p) putchar(*p++); } +#endif /* ! GRUB */ -#ifdef IMAGE_MENU +#if defined(IMAGE_MENU) || defined(GRUB) /************************************************************************** INET_ATON - Convert an ascii x.x.x.x to binary form **************************************************************************/ @@ -184,9 +185,7 @@ int inet_aton(char *p, in_addr *i) i->s_addr = htonl((ip << 8) | val); return(1); } - -#endif /* IMAGE_MENU */ -#endif /* ! GRUB */ +#endif /* IMAGE_MENU || GRUB */ int getdec(char **ptr) { diff --git a/stage2/builtins.c b/stage2/builtins.c index c56e30742..062989360 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -2943,6 +2943,35 @@ static struct builtin builtin_testload = " step is to try loading a kernel." }; + +/* tftpserver */ +static int +tftpserver_func (char *arg, int flags) +{ +#ifdef SUPPORT_NETBOOT + if (! *arg || ! arp_server_override (arg)) + { + errnum = ERR_BAD_ARGUMENT; + return 1; + } + + print_network_configuration (); + return 0; +#else + errnum = ERR_UNRECOGNIZED; + return 1; +#endif +} + +static struct builtin builtin_tftpserver = +{ + "tftpserver", + tftpserver_func, + BUILTIN_CMDLINE | BUILTIN_MENU, + "tftpserver IPADDR", + "Override the TFTP server address." +}; + /* timeout */ static int @@ -3077,6 +3106,7 @@ struct builtin *builtin_table[] = &builtin_setkey, &builtin_setup, &builtin_testload, + &builtin_tftpserver, &builtin_timeout, &builtin_title, &builtin_unhide,