fix some bugs in netboot, print out the network configuration if bootp or arp succeeds.

This commit is contained in:
okuji 2000-02-11 02:50:36 +00:00
parent b9104596eb
commit bfbcbe125e
7 changed files with 96 additions and 10 deletions

View file

@ -1,3 +1,24 @@
2000-02-11 OKUJI Yoshinori <okuji@gnu.org>
From Pavel Roskin:
* stage2/shared.h [!GRUB_SHARED_HEADER] (GRUB_SHARED_HEADER):
Defined.
[GRUB_SHARED_HEADER]: Don't declare or define anything.
* netboot/main.c (print_network_configuration): New function.
(await_reply): Check for Control-C instead of ESC, because GRUB
already uses ESC for another purpose.
(rfc951_sleep): Check for the key input in the loop. If
Control-C is pushed, return immediately.
* netboot/etherboot (print_network_configuration): Declared.
(CTRL_C): New macro.
(ESC): Undefined.
* netboot/config.c (eth_probe): Clear ARPTABLE after clearing
NETWORK_READY.
* stage2/builtins.c (bootp_func): Call
print_network_configuration if bootp succeeds.
(rarp_func): Call print_network_configuration if rarp succeeds.
2000-02-11 OKUJI Yoshinori <okuji@gnu.org>
From Per Lundberg <plundis@byggdok.se>:

View file

@ -433,6 +433,9 @@ int eth_probe(void)
/* Clear the ready flag. */
network_ready = 0;
/* Clear the ARP table. */
grub_memset ((char *) arptable, 0,
MAX_ARP * sizeof (struct arptable_t));
p = 0;
#ifdef INCLUDE_PCI

View file

@ -29,7 +29,11 @@ Author: Martin Renters
#define TAGGED_IMAGE /* choose at least one */
#endif
#define ESC 0x1B
#if 0
# define ESC 0x1B
#else
# define CTRL_C 3
#endif
#ifndef DEFAULT_BOOTFILE
#define DEFAULT_BOOTFILE "/tftpboot/kernel"
@ -338,6 +342,8 @@ extern int rarp P((void));
External prototypes
***************************************************************************/
/* main.c */
extern void print_network_configuration (void);
#if 0
extern void print_bytes P((unsigned char *bytes, int len));
extern void load P((void));

View file

@ -36,7 +36,7 @@ Author: Martin Renters
struct arptable_t arptable[MAX_ARP];
/* Set if the user pushes the ESC key. */
/* Set if the user pushes Control-C. */
int ip_abort = 0;
/* Set if an ethernet card is probed and IP addresses are set. */
int network_ready = 0;
@ -123,6 +123,34 @@ static char dhcprequest[] =
static char broadcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
void
print_network_configuration (void)
{
static void sprint_ip_addr (char *buf, unsigned long addr)
{
grub_sprintf (buf, "%d.%d.%d.%d",
addr >> 24, (addr >> 16) & 0xFF,
(addr >> 8) & 0xFF, addr & 0xFF);
}
if (! eth_probe ())
grub_printf ("No ethernet card found.\n");
else if (! network_ready)
grub_printf ("Not initialized yet.\n");
else
{
char me[16], my_mask[16], server[16], gw[16];
sprint_ip_addr (me, arptable[ARP_CLIENT].ipaddr.s_addr);
sprint_ip_addr (my_mask, netmask);
sprint_ip_addr (server, arptable[ARP_SERVER].ipaddr.s_addr);
sprint_ip_addr (gw, arptable[ARP_GATEWAY].ipaddr.s_addr);
grub_printf ("Address: %s Netmask: %s\nServer: %s Gateway: %s\n",
me, my_mask, server, gw);
}
}
/**************************************************************************
DEFAULT_NETMASK - Return default netmask for IP address
**************************************************************************/
@ -591,6 +619,7 @@ await_reply (int type, int ival, char *ptr, int timeout)
int protohdrlen = (ETHER_HDR_SIZE + sizeof (struct iphdr)
+ sizeof (struct udphdr));
/* Clear the abort flag. */
ip_abort = 0;
#ifdef CONGESTED
@ -600,7 +629,8 @@ await_reply (int type, int ival, char *ptr, int timeout)
#endif
while (time > currticks ())
{
if (checkkey () != -1 && getkey () == ESC)
/* If Control-C is pushed, return immediately. */
if (checkkey () != -1 && ASCII_CHAR (getkey ()) == CTRL_C)
{
ip_abort = 1;
return 0;
@ -979,5 +1009,7 @@ rfc951_sleep (int exp)
grub_printf ("<sleep>\n");
for (tmo = (tmo & seed) + currticks (); currticks () < tmo;)
;
/* If the user interrupts, return immediately. */
if (checkkey () != -1 && ASCII_CHAR (getkey ()) == CTRL_C)
break;
}

View file

@ -1,3 +1,24 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Based on "src/misc.c" in etherboot-4.4.2. */
/**************************************************************************
MISC Support Routines
**************************************************************************/
@ -320,9 +341,3 @@ iskey(void)
}
#endif /* ETHERBOOT32 */
#endif
/*
* Local variables:
* c-basic-offset: 8
* End:
*/

View file

@ -256,6 +256,8 @@ bootp_func (char *arg, int flags)
return 1;
}
/* Notify the configuration. */
print_network_configuration ();
return 0;
#else
errnum = ERR_UNRECOGNIZED;
@ -1994,6 +1996,8 @@ rarp_func (char *arg, int flags)
return 1;
}
/* Notify the configuration. */
print_network_configuration ();
return 0;
#else
errnum = ERR_UNRECOGNIZED;

View file

@ -23,6 +23,9 @@
* Generic defines to use anywhere
*/
#ifndef GRUB_SHARED_HEADER
#define GRUB_SHARED_HEADER 1
#include <config.h>
/* Add an underscore to a C symbol in assembler code if needed. */
@ -780,3 +783,5 @@ int load_initrd (char *initrd);
void init_bios_info (void);
#endif /* ASM_FILE */
#endif /* ! GRUB_SHARED_HEADER */