Fix regressions by previous commits

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-02 18:15:59 +02:00
parent 5855ddc402
commit e571f2332e
5 changed files with 52 additions and 29 deletions

View file

@ -47,6 +47,7 @@ static grub_err_t
grub_ls_list_devices (int longlist)
{
grub_net_app_level_t proto;
int first = 1;
auto int grub_ls_print_devices (const char *name);
int grub_ls_print_devices (const char *name)
@ -62,10 +63,11 @@ grub_ls_list_devices (int longlist)
grub_device_iterate (grub_ls_print_devices);
grub_xputs ("\n");
grub_puts_ (N_ ("Network protocols:\n"));
FOR_NET_APP_LEVEL (proto)
{
if (first)
grub_puts_ (N_ ("Network protocols:"));
first = 0;
grub_printf ("%s ", proto->name);
}

View file

@ -97,7 +97,7 @@ parse_ip (const char *val, grub_uint32_t *ip, const char **rest)
return 0;
ptr++;
}
*ip = newip;
*ip = grub_cpu_to_le32 (newip);
if (rest)
*rest = ptr - 1;
return 0;
@ -114,7 +114,8 @@ match_net (const grub_net_network_level_netaddress_t *net,
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
{
grub_int32_t mask = (1 << net->ipv4.masksize) - 1;
return ((net->ipv4.base & mask) == (addr->ipv4 & mask));
return ((grub_be_to_cpu32 (net->ipv4.base) & mask)
== (grub_be_to_cpu32 (addr->ipv4) & mask));
}
}
return 0;
@ -380,13 +381,17 @@ print_net_address (const grub_net_network_level_netaddress_t *target)
switch (target->type)
{
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
grub_printf ("%d.%d.%d.%d/%d ", ((target->ipv4.base >> 24) & 0xff),
((target->ipv4.base >> 16) & 0xff),
((target->ipv4.base >> 8) & 0xff),
((target->ipv4.base >> 0) & 0xff),
target->ipv4.masksize);
break;
{
grub_uint32_t n = grub_be_to_cpu32 (target->ipv4.base);
grub_printf ("%d.%d.%d.%d/%d ", ((n >> 24) & 0xff),
((n >> 16) & 0xff),
((n >> 8) & 0xff),
((n >> 0) & 0xff),
target->ipv4.masksize);
}
return;
}
grub_printf ("Unknown address type %d\n", target->type);
}
static void
@ -395,12 +400,16 @@ print_address (const grub_net_network_level_address_t *target)
switch (target->type)
{
case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4:
grub_printf ("%d.%d.%d.%d ", ((target->ipv4 >> 24) & 0xff),
((target->ipv4 >> 16) & 0xff),
((target->ipv4 >> 8) & 0xff),
((target->ipv4 >> 0) & 0xff));
break;
{
grub_uint32_t n = grub_be_to_cpu32 (target->ipv4);
grub_printf ("%d.%d.%d.%d ", ((n >> 24) & 0xff),
((n >> 16) & 0xff),
((n >> 8) & 0xff),
((n >> 0) & 0xff));
}
return;
}
grub_printf ("Unknown address type %d\n", target->type);
}
static grub_err_t
@ -420,6 +429,7 @@ grub_cmd_listroutes (struct grub_command *cmd __attribute__ ((unused)),
}
else
grub_printf ("%s", route->interface->name);
grub_printf ("\n");
}
return GRUB_ERR_NONE;
}
@ -466,6 +476,8 @@ grub_net_open_real (const char *name)
return ret;
}
}
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no such device");
return NULL;
}

View file

@ -306,7 +306,7 @@ grub_pxefs_label (grub_device_t device __attribute ((unused)),
static struct grub_fs grub_pxefs_fs =
{
.name = "pxefs",
.name = "pxe",
.dir = grub_pxefs_dir,
.open = grub_pxefs_open,
.read = grub_pxefs_read,
@ -590,7 +590,7 @@ GRUB_MOD_INIT(pxe)
addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
addr.ipv4 = grub_pxe_your_ip;
inter = grub_net_add_addr ("pxe", &grub_pxe_card, addr);
if (grub_pxe_default_gateway_ip)
if (grub_pxe_default_gateway_ip != grub_pxe_default_server_ip)
{
grub_net_network_level_netaddress_t target;
grub_net_network_level_address_t gw;
@ -600,7 +600,7 @@ GRUB_MOD_INIT(pxe)
target.ipv4.masksize = 32;
gw.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
gw.ipv4 = grub_pxe_default_gateway_ip;
grub_net_add_route_gw ("pxe_default", target, gw);
grub_net_add_route_gw ("pxe_gw", target, gw);
}
{
grub_net_network_level_netaddress_t target;
@ -608,7 +608,7 @@ GRUB_MOD_INIT(pxe)
target.ipv4.base = grub_pxe_default_gateway_ip ?
: grub_pxe_default_server_ip;
target.ipv4.masksize = 32;
grub_net_add_route ("pxe_default", target, inter);
grub_net_add_route ("pxe", target, inter);
}
}
}

View file

@ -53,8 +53,11 @@ grub_device_open (const char *name)
dev->disk = grub_disk_open (name);
if (dev->disk)
return dev;
if (grub_net_open)
dev->net = grub_net_open (name);
if (grub_net_open && grub_errno == GRUB_ERR_UNKNOWN_DEVICE)
{
grub_errno = GRUB_ERR_NONE;
dev->net = grub_net_open (name);
}
if (dev->net)
return dev;

View file

@ -59,19 +59,25 @@ typedef enum grub_network_level_protocol_id
GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
} grub_network_level_protocol_id_t;
typedef union grub_net_network_level_address
typedef struct grub_net_network_level_address
{
grub_network_level_protocol_id_t type;
grub_uint32_t ipv4;
union
{
grub_uint32_t ipv4;
};
} grub_net_network_level_address_t;
typedef union grub_net_network_level_netaddress
typedef struct grub_net_network_level_netaddress
{
grub_network_level_protocol_id_t type;
struct {
grub_uint32_t base;
int masksize;
} ipv4;
union
{
struct {
grub_uint32_t base;
int masksize;
} ipv4;
};
} grub_net_network_level_netaddress_t;
struct grub_net_network_level_interface;
@ -81,7 +87,7 @@ struct grub_net_network_level_interface
struct grub_net_network_level_interface *next;
char *name;
struct grub_net_card *card;
union grub_net_network_level_address address;
grub_net_network_level_address_t address;
void *data;
};