Network infrastructure.
The ARP protocol was made by Paulo Pinatti <ppinatti@br.ibm.com> * include/grub/net/arp.h: New file. * include/grub/net/device.h: Likewise. * include/grub/net/ethernet.h: Likewise. * include/grub/net/ip.h: Likewise. * include/grub/net/netbuff.h: Likewise. * include/grub/net/tftp.h: Likewise. * include/grub/net/udp.h: Likewise. * include/grub/ieee1275/ofnet.h: Likewise. * include/grub/emu/export.h: Likewise. * include/grub/net.h: Likewise. * grub-core/net/arp.c: Likewise. * grub-core/net/ethernet.c: Likewise. * grub-core/net/ip.c: Likewise. * grub-core/net/udp.c: Likewise. * grub-core/net/tftp.c: Likewise. * grub-core/net/netbuff.c: Likewise. * grub-core/net/net.c: Likewise. * grub-core/net/drivers/emu/emunet.c: Likewise. * grub-core/net/drivers/ieee1275/ofnet.c: Likewise. * grub-core/Makefile.am (KERNEL_HEADER_FILES): Add net.h, ofnet.h and export.h. * grub-core/Makefile.core.def (net): New module. (tftp): Likewise. (ofnet): Likewise. (emunet): Likewise. * grub-core/commands/ls.c (grub_ls_list_devices) [!GRUB_UTIL]: List network protocols. * grub-core/kern/device.c (grub_net_open) : New variable. (grub_device_open): Handle network device. (grub_device_close): Likewise. * grub-core/kern/file.c (grub_file_net_seek) : New variable. (grub_grubnet_fini): Likewise. (grub_file_seek): Seek in network device. * grub-core/kern/fs.c (grub_fs_probe): Handle network devices. * grub-core/kern/ieee1275/init.c (grub_machine_set_prefix): Handle network root. (grub_machine_fini): Call grub_grubnet_fini. * grub-core/kern/ieee1275/openfw.c (grub_ieee1275_parse_args): Handle network. (grub_ieee1275_get_aliasdevname): New function. * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_get_mbi_size): Add unofficial Solaris network info. (grub_multiboot_make_mbi): Likewise. * grub-core/fs/i386/pc/pxe.c: Moved from here ... * grub-core/net/i386/pc/pxe.c: ...here. Adapted for new design. * include/grub/device.h (grub_fs): Removed. * include/grub/err.h (grub_err_t): Add network-related values. * include/grub/i386/pc/pxe.h: Removed bootp parts. * include/grub/ieee1275/ieee1275.h (grub_ofnetcard_data): New struct. (grub_ieee1275_get_aliasdevname): New proto. * include/grub/net.h: Rewritten. Also-By: Paulo Pinatti <ppinatti@br.ibm.com> Also-By: Vladimir Serbinenko <phcoder@gmail.com>
This commit is contained in:
commit
90162423e9
35 changed files with 3447 additions and 399 deletions
|
@ -26,6 +26,8 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
grub_net_t (*grub_net_open) (const char *name) = NULL;
|
||||
|
||||
grub_device_t
|
||||
grub_device_open (const char *name)
|
||||
{
|
||||
|
@ -46,15 +48,19 @@ grub_device_open (const char *name)
|
|||
if (! dev)
|
||||
goto fail;
|
||||
|
||||
dev->net = NULL;
|
||||
/* Try to open a disk. */
|
||||
disk = grub_disk_open (name);
|
||||
if (! disk)
|
||||
goto fail;
|
||||
dev->disk = grub_disk_open (name);
|
||||
if (dev->disk)
|
||||
return dev;
|
||||
if (grub_net_open && grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
dev->net = grub_net_open (name);
|
||||
}
|
||||
|
||||
dev->disk = disk;
|
||||
dev->net = 0; /* FIXME */
|
||||
|
||||
return dev;
|
||||
if (dev->net)
|
||||
return dev;
|
||||
|
||||
fail:
|
||||
if (disk)
|
||||
|
@ -71,6 +77,12 @@ grub_device_close (grub_device_t device)
|
|||
if (device->disk)
|
||||
grub_disk_close (device->disk);
|
||||
|
||||
if (device->net)
|
||||
{
|
||||
grub_free (device->net->name);
|
||||
grub_free (device->net);
|
||||
}
|
||||
|
||||
grub_free (device);
|
||||
|
||||
return grub_errno;
|
||||
|
|
|
@ -20,10 +20,14 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/device.h>
|
||||
|
||||
grub_err_t (*grub_file_net_seek) (struct grub_file *file, grub_off_t offset) = NULL;
|
||||
void (*EXPORT_VAR (grub_grubnet_fini)) (void);
|
||||
|
||||
grub_file_filter_t grub_file_filters_all[GRUB_FILE_FILTER_MAX];
|
||||
grub_file_filter_t grub_file_filters_enabled[GRUB_FILE_FILTER_MAX];
|
||||
|
||||
|
@ -148,7 +152,6 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
|||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
res = (file->fs->read) (file, buf, len);
|
||||
if (res > 0)
|
||||
file->offset += res;
|
||||
|
@ -179,8 +182,12 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
|
|||
"attempt to seek outside of the file");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (file->device->net && grub_file_net_seek)
|
||||
grub_file_net_seek (file, offset);
|
||||
|
||||
old = file->offset;
|
||||
file->offset = offset;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ grub_fs_probe (grub_device_t device)
|
|||
count--;
|
||||
}
|
||||
}
|
||||
else if (device->net->fs)
|
||||
else if (device->net && device->net->fs)
|
||||
return device->net->fs;
|
||||
|
||||
grub_error (GRUB_ERR_UNKNOWN_FS, "unknown filesystem");
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <grub/ieee1275/console.h>
|
||||
#include <grub/ieee1275/ofdisk.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/offsets.h>
|
||||
#include <grub/memory.h>
|
||||
|
||||
|
@ -74,7 +76,22 @@ grub_machine_set_prefix (void)
|
|||
char bootpath[64]; /* XXX check length */
|
||||
char *filename;
|
||||
char *prefix;
|
||||
|
||||
grub_bootp_t bootp_pckt;
|
||||
char addr[GRUB_NET_MAX_STR_ADDR_LEN];
|
||||
|
||||
/* Set the net prefix when possible. */
|
||||
if (grub_getbootp && (bootp_pckt = grub_getbootp()))
|
||||
{
|
||||
grub_uint32_t n = bootp_pckt->siaddr;
|
||||
grub_snprintf (addr, GRUB_NET_MAX_STR_ADDR_LEN, "%d.%d.%d.%d",
|
||||
((n >> 24) & 0xff), ((n >> 16) & 0xff),
|
||||
((n >> 8) & 0xff), ((n >> 0) & 0xff));
|
||||
prefix = grub_xasprintf ("(tftp,%s)%s", addr,grub_prefix);
|
||||
grub_env_set ("prefix", prefix);
|
||||
grub_free (prefix);
|
||||
return;
|
||||
}
|
||||
|
||||
if (grub_prefix[0])
|
||||
{
|
||||
grub_env_set ("prefix", grub_prefix);
|
||||
|
@ -247,6 +264,8 @@ grub_machine_init (void)
|
|||
void
|
||||
grub_machine_fini (void)
|
||||
{
|
||||
if (grub_grubnet_fini)
|
||||
grub_grubnet_fini ();
|
||||
grub_ofdisk_fini ();
|
||||
grub_console_fini ();
|
||||
}
|
||||
|
|
|
@ -22,11 +22,16 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/net/tftp.h>
|
||||
|
||||
grub_bootp_t (*grub_getbootp) (void);
|
||||
enum grub_ieee1275_parse_type
|
||||
{
|
||||
GRUB_PARSE_FILENAME,
|
||||
GRUB_PARSE_PARTITION,
|
||||
GRUB_PARSE_DEVICE
|
||||
};
|
||||
|
||||
/* Walk children of 'devpath', calling hook for each. */
|
||||
|
@ -366,12 +371,14 @@ grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype)
|
|||
ret = grub_strndup (args, (grub_size_t)(comma - args));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
else if (!grub_strcmp ("network", type))
|
||||
{
|
||||
if (ptype == GRUB_PARSE_DEVICE)
|
||||
ret = grub_strdup(device);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX Handle net devices by configuring & registering a grub_net_dev
|
||||
here, then return its name?
|
||||
Example path: "net:<server ip>,<file name>,<client ip>,<gateway
|
||||
ip>,<bootp retries>,<tftp retries>". */
|
||||
grub_printf ("Unsupported type %s for device %s\n", type, device);
|
||||
}
|
||||
|
||||
|
@ -381,6 +388,12 @@ fail:
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_ieee1275_get_aliasdevname (const char *path)
|
||||
{
|
||||
return grub_ieee1275_parse_args (path, GRUB_PARSE_DEVICE);
|
||||
}
|
||||
|
||||
char *
|
||||
grub_ieee1275_get_filename (const char *path)
|
||||
{
|
||||
|
@ -467,3 +480,4 @@ grub_ieee1275_canonicalise_devname (const char *path)
|
|||
grub_free (buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue