add a new command, ifconfig.
This commit is contained in:
parent
1b97631a73
commit
7519621c59
6 changed files with 119 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2001-01-11 Eugene Doudine <dudin@np.nk.nornik.ru>
|
||||||
|
|
||||||
|
* stage2/builtins.c [SUPPORT_NETBOOT] (ifconfig_func): New
|
||||||
|
function to configure network interface from command line.
|
||||||
|
[SUPPORT_NETBOOT] (builtin_ifconfig): New variable.
|
||||||
|
[SUPPORT_NETBOOT] (builtin_table): Added a pointer to
|
||||||
|
BUILTIN_IFCONFIG.
|
||||||
|
* netboot/main.c (ifconfig): New function.
|
||||||
|
* netboot/etherboot.h (ifconfig): Added the prototype.
|
||||||
|
|
||||||
2001-01-11 OKUJI Yoshinori <okuji@gnu.org>
|
2001-01-11 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
* docs/Makefile.am [BUILD_EXAMPLE_KERNEL] (noinst_DATA): New
|
* docs/Makefile.am [BUILD_EXAMPLE_KERNEL] (noinst_DATA): New
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -23,6 +23,7 @@ New in 1.0 - XXXX-XX-XX:
|
||||||
* Booting Windows from a logical partition is supported.
|
* Booting Windows from a logical partition is supported.
|
||||||
* The example Multiboot kernel in the directory "docs" is built, if you
|
* The example Multiboot kernel in the directory "docs" is built, if you
|
||||||
specify the option `--enable-example-kernel' to the configure script.
|
specify the option `--enable-example-kernel' to the configure script.
|
||||||
|
* New command, "ifconfig".
|
||||||
|
|
||||||
New in 0.5.96 - 2000-10-04:
|
New in 0.5.96 - 2000-10-04:
|
||||||
* New commands, "reboot" and "halt".
|
* New commands, "reboot" and "halt".
|
||||||
|
|
1
THANKS
1
THANKS
|
@ -22,6 +22,7 @@ Edmund GRIMLEY EVANS <edmundo@rano.demon.co.uk>
|
||||||
Edward Killips <ekillips@triton.net>
|
Edward Killips <ekillips@triton.net>
|
||||||
Eric Hanchrow <erich@microsoft.com>
|
Eric Hanchrow <erich@microsoft.com>
|
||||||
Erik Schoenfelder <schoenfr@gaertner.de>
|
Erik Schoenfelder <schoenfr@gaertner.de>
|
||||||
|
Eugene Doudine <dudin@np.nk.nornik.ru>
|
||||||
Frank Mehnert <fm3@os.inf.tu-dresden.de>
|
Frank Mehnert <fm3@os.inf.tu-dresden.de>
|
||||||
Goran Koruga <goran.koruga@hermes.si>
|
Goran Koruga <goran.koruga@hermes.si>
|
||||||
Hal Snyder <hal@vailsys.com>
|
Hal Snyder <hal@vailsys.com>
|
||||||
|
|
|
@ -462,6 +462,7 @@ External prototypes
|
||||||
#ifdef GRUB
|
#ifdef GRUB
|
||||||
extern void print_network_configuration P((void));
|
extern void print_network_configuration P((void));
|
||||||
extern int arp_server_override P((const char *buf));
|
extern int arp_server_override P((const char *buf));
|
||||||
|
extern int ifconfig P((char *ip, char *sm, char *gw, char *svr));
|
||||||
#endif /* GRUB */
|
#endif /* GRUB */
|
||||||
|
|
||||||
#ifndef GRUB
|
#ifndef GRUB
|
||||||
|
|
|
@ -206,6 +206,49 @@ default_netmask (void)
|
||||||
return (htonl (0xffffff00));
|
return (htonl (0xffffff00));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ifconfig - configure network interface. */
|
||||||
|
int
|
||||||
|
ifconfig (char *ip, char *sm, char *gw, char *svr)
|
||||||
|
{
|
||||||
|
in_addr tmp;
|
||||||
|
|
||||||
|
if (sm)
|
||||||
|
{
|
||||||
|
if (! inet_aton (sm, &tmp))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
netmask = tmp.s_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ip)
|
||||||
|
{
|
||||||
|
if (! inet_aton (ip, &arptable[ARP_CLIENT].ipaddr))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (! netmask && ! sm)
|
||||||
|
netmask = default_netmask ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gw && ! inet_aton (gw, &arptable[ARP_GATEWAY].ipaddr))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (svr && ! inet_aton (svr, &arptable[ARP_SERVER].ipaddr))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (ip || sm)
|
||||||
|
{
|
||||||
|
if (IP_BROADCAST == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
|
||||||
|
|| netmask == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
|
||||||
|
|| ! netmask)
|
||||||
|
network_ready = 0;
|
||||||
|
else
|
||||||
|
network_ready = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
UDP_TRANSMIT - Send a UDP datagram
|
UDP_TRANSMIT - Send a UDP datagram
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
|
@ -1516,6 +1516,66 @@ static struct builtin builtin_hide =
|
||||||
" its partition type code."
|
" its partition type code."
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SUPPORT_NETBOOT
|
||||||
|
/* ifconfig */
|
||||||
|
static int
|
||||||
|
ifconfig_func (char *arg, int flags)
|
||||||
|
{
|
||||||
|
char *svr = 0, *ip = 0, *gw = 0, *sm = 0;
|
||||||
|
|
||||||
|
if (! eth_probe ())
|
||||||
|
{
|
||||||
|
grub_printf ("No ethernet card found.\n");
|
||||||
|
errnum = ERR_DEV_VALUES;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! *arg)
|
||||||
|
{
|
||||||
|
print_network_configuration ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*arg)
|
||||||
|
{
|
||||||
|
if (! grub_memcmp ("--server=", arg, sizeof ("--server=") - 1))
|
||||||
|
svr = arg + sizeof("--server=") - 1;
|
||||||
|
else if (! grub_memcmp ("--address=", arg, sizeof ("--address=") - 1))
|
||||||
|
ip = arg + sizeof ("--address=") - 1;
|
||||||
|
else if (! grub_memcmp ("--gateway=", arg, sizeof ("--gateway=") - 1))
|
||||||
|
gw = arg + sizeof ("--gateway=") - 1;
|
||||||
|
else if (! grub_memcmp ("--mask=", arg, sizeof("--mask=") - 1))
|
||||||
|
sm = arg + sizeof ("--mask=") - 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errnum = ERR_BAD_ARGUMENT;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
arg = skip_to (0, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! ifconfig (ip, sm, gw, svr))
|
||||||
|
{
|
||||||
|
errnum = ERR_BAD_ARGUMENT;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct builtin builtin_ifconfig =
|
||||||
|
{
|
||||||
|
"ifconfig",
|
||||||
|
ifconfig_func,
|
||||||
|
BUILTIN_CMDLINE | BUILTIN_MENU,
|
||||||
|
"ifconfig [--address=IP] [--gateway=IP] [--mask=MASK] [--server=IP]",
|
||||||
|
"Configure the IP address, the netmask, the gateway and the server"
|
||||||
|
" address or print current network configuration."
|
||||||
|
};
|
||||||
|
#endif /* SUPPORT_NETBOOT */
|
||||||
|
|
||||||
|
|
||||||
/* impsprobe */
|
/* impsprobe */
|
||||||
static int
|
static int
|
||||||
|
@ -4349,6 +4409,9 @@ struct builtin *builtin_table[] =
|
||||||
&builtin_help,
|
&builtin_help,
|
||||||
&builtin_hiddenmenu,
|
&builtin_hiddenmenu,
|
||||||
&builtin_hide,
|
&builtin_hide,
|
||||||
|
#ifdef SUPPORT_NETBOOT
|
||||||
|
&builtin_ifconfig,
|
||||||
|
#endif /* SUPPORT_NETBOOT */
|
||||||
&builtin_impsprobe,
|
&builtin_impsprobe,
|
||||||
&builtin_initrd,
|
&builtin_initrd,
|
||||||
&builtin_install,
|
&builtin_install,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue