/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
char *grub_net_default_server;
struct grub_net_route
{
char *name;
int is_gateway;
union
{
};
};
struct grub_net_link_layer_entry {
int avail;
};
static struct grub_net_link_layer_entry *
const struct grub_net_card *card)
{
unsigned i;
if (!card->link_layer_table)
return NULL;
for (i = 0; i < LINK_LAYER_CACHE_SIZE; i++)
{
proto) == 0)
return &card->link_layer_table[i];
}
return NULL;
}
void
const grub_net_network_level_address_t *nl,
const grub_net_link_level_address_t *ll,
int override)
{
/* Check if the sender is in the cache table. */
/* Update sender hardware address. */
if (entry)
return;
/* Add sender to cache table. */
* sizeof (card->link_layer_table[0]));
card->new_ll_entry++;
card->new_ll_entry = 0;
}
int
{
return 1;
if (entry)
return 1;
return 0;
}
{
<< 48)
{
return GRUB_ERR_NONE;
}
{
return GRUB_ERR_NONE;
}
/* Check cache table. */
if (entry)
{
return GRUB_ERR_NONE;
}
switch (proto_addr->type)
{
break;
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
}
if (err)
return err;
if (entry)
{
return GRUB_ERR_NONE;
}
return grub_error (GRUB_ERR_TIMEOUT,
"timeout: could not resolve hardware address");
}
void
{
{
}
GRUB_AS_LIST (card));
}
static struct grub_net_slaac_mac_list *
const grub_net_link_level_address_t *hwaddr)
{
char *ptr;
return slaac;
if (!slaac)
return NULL;
+ sizeof (":slaac"));
{
}
return slaac;
}
struct grub_net_network_level_interface *
const grub_net_link_level_address_t *hwaddr)
{
+ sizeof (":link")];
char *ptr;
{
return inf;
}
{
}
}
/* FIXME: allow to specify mac address. */
static grub_err_t
{
unsigned j = 0;
int interval;
{
continue;
ncards++;
}
{
return grub_errno;
}
{
continue;
if (!ifaces[j])
{
return grub_errno;
}
if (!slaacs[j])
{
return grub_errno;
}
j++;
}
{
/* FIXME: send router solicitation. */
for (j = 0; j < ncards; j++)
{
if (slaacs[j]->slaac_counter)
continue;
done = 0;
}
if (done)
break;
}
err = GRUB_ERR_NONE;
for (j = 0; j < ncards; j++)
{
if (slaacs[j]->slaac_counter)
continue;
}
return err;
}
static inline void
{
GRUB_AS_LIST (route));
}
static inline void
{
GRUB_AS_LIST (route));
}
static int
{
int i;
for (i = 0; i < 4; i++)
{
unsigned long t;
if (grub_errno)
{
return 0;
}
if (*ptr != '.' && i == 0)
{
newip = t;
break;
}
if (t & ~0xff)
return 0;
newip >>= 8;
newip |= (t << 24);
return 0;
ptr++;
}
if (rest)
return 1;
}
static int
{
return 0;
if (ptr[0] == ':')
ptr++;
{
unsigned long t;
if (*ptr == ':')
{
word--;
ptr++;
continue;
}
if (grub_errno)
{
break;
}
if (t & ~0xffff)
return 0;
if (*ptr != ':')
break;
ptr++;
}
return 0;
if (quaddot != -1)
{
}
if (rest)
return 1;
}
static int
const grub_net_network_level_address_t *addr)
{
return 0;
{
return 0;
{
mask = 0;
}
{
{
mask[1] = 0;
}
else
{
mask[0] = 0xffffffffffffffffULL;
}
}
}
return 0;
}
{
const char *rest;
{
return GRUB_ERR_NONE;
}
{
return GRUB_ERR_NONE;
}
if (err)
return err;
if (!naddresses)
name);
/* FIXME: use other results as well. */
return GRUB_ERR_NONE;
}
{
const char *rest;
{
if (*rest == '/')
{
if (!grub_errno && *rest == 0)
return GRUB_ERR_NONE;
}
else if (*rest == 0)
{
return GRUB_ERR_NONE;
}
}
{
if (*rest == '/')
{
if (!grub_errno && *rest == 0)
return GRUB_ERR_NONE;
}
else if (*rest == 0)
{
return GRUB_ERR_NONE;
}
}
name);
}
static int
{
return 0;
if (b == NULL)
return +1;
if (a == NULL)
return -1;
return -1;
return +1;
{
break;
return +1;
return -1;
break;
return +1;
return -1;
break;
}
return 0;
}
struct grub_net_network_level_interface **interf)
{
int depth = 0;
int routecnt = 0;
routecnt++;
{
{
continue;
continue;
}
if (!bestroute->is_gateway)
{
return GRUB_ERR_NONE;
}
if (depth == 0)
}
}
static grub_err_t
{
if (argc != 1)
break;
return grub_error (GRUB_ERR_IO,
N_("you can't delete this address"));
return GRUB_ERR_NONE;
}
void
{
{
return;
{
int i;
for (i = 0; i < 4; i++)
{
(n >> (48 - 16 * i)) & 0xffff);
}
for (i = 0; i < 3; i++)
{
(n >> (48 - 16 * i)) & 0xffff);
}
return;
}
{
((n >> 24) & 0xff), ((n >> 16) & 0xff),
((n >> 8) & 0xff), ((n >> 0) & 0xff));
}
return;
}
}
void
{
str[0] = 0;
{
{
char *ptr;
unsigned i;
{
}
return;
}
}
}
int
const grub_net_link_level_address_t *b)
{
return -1;
return +1;
switch (a->type)
{
}
return 1;
}
int
const grub_net_network_level_address_t *b)
{
return -1;
return +1;
switch (a->type)
{
return 0;
}
return 1;
}
/* FIXME: implement this. */
static char *
{
return NULL;
}
/* FIXME: implement this. */
static char *
{
return NULL;
}
static void
{
{
}
{
}
}
struct grub_net_network_level_interface *
struct grub_net_card *card,
{
if (!inter)
return NULL;
inter->dhcp_acklen = 0;
{
if (mask == -1)
{
if (!(ip_cpu & 0x80000000))
mask = 8;
else if (!(ip_cpu & 0x40000000))
mask = 16;
else if (!(ip_cpu & 0x20000000))
mask = 24;
}
if (mask != -1)
{
if (!route)
return NULL;
{
return NULL;
}
route->is_gateway = 0;
}
}
return inter;
}
/* FIXME: support MAC specifying. */
static grub_err_t
{
char *slash;
if (argc != 3)
break;
/* If a mask was supplied, split args[2] */
{
unsigned long maskval;
if (! addrstr)
return grub_errno;
if (err)
return err;
maskval > 32)
N_("Invalid mask value %s for IPv4 network address %s"),
maskval > 64)
N_("Invalid mask value %s for IPv6 network address %s"),
N_("Unknown address type for mask value %s for address %s"),
else
err = 0;
if (err)
return err;
}
else
{
if (err)
return err;
}
return grub_error (GRUB_ERR_IO,
"this card doesn't support address addition");
flags);
return grub_errno;
}
static grub_err_t
{
if (argc != 1)
{
if (!*prev)
break;
}
return GRUB_ERR_NONE;
}
struct grub_net_network_level_interface *inter)
{
if (!route)
return grub_errno;
{
return grub_errno;
}
route->is_gateway = 0;
return GRUB_ERR_NONE;
}
{
if (!route)
return grub_errno;
{
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
if (argc < 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
N_("At least 3 arguments are expected"));
{
if (err)
return err;
}
else
{
break;
if (!inter)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
}
}
static void
{
{
grub_printf ("temporary\n");
return;
{
((n >> 16) & 0xff),
((n >> 8) & 0xff),
((n >> 0) & 0xff),
}
return;
{
}
return;
}
}
static void
{
grub_xputs (buf);
}
static grub_err_t
{
{
if (route->is_gateway)
{
grub_printf ("gw ");
}
else
grub_printf ("\n");
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
{
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
{
}
return GRUB_ERR_NONE;
}
static grub_net_t
{
{
protname = "tftp";
}
{
protname = "tftp";
}
else
{
const char *comma;
if (comma)
{
}
else
{
}
}
if (!server)
{
return NULL;
}
{
{
if (!ret)
return NULL;
if (server)
{
{
return NULL;
}
}
else
return ret;
}
}
return NULL;
}
static grub_err_t
{
return GRUB_ERR_NONE;
}
static grub_err_t
{
if (!file)
return grub_errno;
return grub_errno;
if (err)
return err;
if (! bufio)
{
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
{
{
}
if (file->enable_progress)
return GRUB_ERR_NONE;
}
static void
{
if (card->num_ifaces == 0)
return;
{
if (err)
{
return;
}
}
while (1)
{
/* Maybe should be better have a fixed number of packets for each card
and just mark them as used and not used. */
if (!nb)
{
break;
}
if (grub_errno)
{
}
}
#if 0
grub_print_error ();
#endif
}
void
{
{
start_time = grub_get_time_ms ();
}
}
static void
{
{
}
}
/* Read from the packets list*/
static grub_ssize_t
{
int try = 0;
while (try <= GRUB_NET_TRIES)
{
{
try = 0;
if (buf)
{
}
{
}
else
if (!len)
return total;
}
{
try++;
}
else
return total;
}
return -1;
}
static grub_off_t
{
return ret;
}
static grub_err_t
{
return GRUB_ERR_NONE;
{
{
return grub_errno;
}
}
{
{
}
if (err)
return err;
return grub_errno;
}
}
static grub_ssize_t
{
{
if (err)
return err;
}
}
{
.name = "netfs",
.dir = grub_net_fs_dir,
.open = grub_net_fs_open,
.read = grub_net_fs_read,
};
static grub_err_t
{
{
}
return GRUB_ERR_NONE;
}
static grub_err_t
grub_net_restore_hw (void)
{
return GRUB_ERR_NONE;
}
static grub_err_t
{
int cached_acks = 0;
{
if (cached_acks)
grub_printf("\n");
cached_acks++;
grub_printf("ClientMAC : %x:%x:%x:%x:%x:%x\n",
}
if (! cached_acks)
grub_printf("No cached DHCP ACKs found.\n");
return GRUB_ERR_NONE;
}
{
N_("SHORTNAME CARD ADDRESS[/MASK] [HWADDRESS]"),
N_("Add a network address."));
"[CARD [HWADDRESS]]",
N_("Perform an IPV6 autoconfiguration"));
N_("SHORTNAME"),
N_("Delete a network address."));
N_("SHORTNAME NET [INTERFACE| gw GATEWAY]"),
N_("Add a network route."));
N_("SHORTNAME"),
N_("Delete a network route."));
grub_bootp_init ();
grub_dns_init ();
}
{
grub_bootp_fini ();
grub_dns_fini ();
grub_net_fini_hw (0);
}