Reintroduce open/close of net cards. Clean up ofnet.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-05 16:37:14 +02:00
parent 382077365b
commit 0bc2cd0f82
12 changed files with 313 additions and 285 deletions

View file

@ -287,8 +287,6 @@ int EXPORT_FUNC(grub_pxe_call) (int func, void * data, grub_uint32_t pxe_rm_entr
extern struct grub_pxe_bangpxe *grub_pxe_pxenv;
void grub_pxe_unload (void);
#endif
#endif /* GRUB_CPU_PXE_H */

View file

@ -64,12 +64,9 @@ struct grub_ieee1275_common_hdr
typedef grub_uint32_t grub_ieee1275_ihandle_t;
typedef grub_uint32_t grub_ieee1275_phandle_t;
struct grub_ofnetcard_data
{
char *path;
grub_ieee1275_ihandle_t handle;
grub_uint32_t mtu;
};
extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
char **device,
char **path);
/* Maps a device alias to a pathname. */
extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
@ -203,5 +200,6 @@ int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
alias));
char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
#endif /* ! GRUB_IEEE1275_HEADER */

View file

@ -1,66 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2007 Free Software Foundation, Inc.
*
* GRUB 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 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/>.
*/
#ifndef GRUB_OFNET_HEADER
#define GRUB_OFNET_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
struct grub_ofnet
{
/* The net name. */
const char *name;
/* The OF device string. */
char *dev;
/*server ip*/
char *sip;
/*client ip*/
char *cip;
/*gateway*/
char *gat;
/**/
int type;
};
typedef struct grub_ofnet *grub_ofnet_t;
struct grub_bootp {
grub_uint8_t op; /* 1 = BOOTREQUEST, 2 = BOOTREPLY */
grub_uint8_t htype; /* Hardware address type. */
grub_uint8_t hlen; /* Hardware address length */
grub_uint8_t hops; /* Used by gateways in cross-gateway booting. */
grub_uint32_t xid; /* Transaction ID */
grub_uint16_t secs; /* Seconds elapsed. */
grub_uint16_t unused; /* Unused. */
grub_uint32_t ciaddr; /* Client IP address, */
grub_uint32_t yiaddr; /* Client IP address filled by server. */
grub_uint32_t siaddr; /* Server IP address. */
grub_uint32_t giaddr; /* Gateway IP address. */
unsigned char chaddr [16]; /* Client hardware address */
char sname [64]; /* Server name */
char file [128]; /* Boot filename */
unsigned char vend [64];
};
typedef struct grub_bootp* grub_bootp_t;
extern grub_bootp_t (*EXPORT_VAR (grub_getbootp)) (void);
#endif /* ! GRUB_NET_HEADER */

View file

@ -60,6 +60,8 @@ struct grub_net_card_driver
{
struct grub_net_card_driver *next;
char *name;
grub_err_t (*open) (const struct grub_net_card *dev);
void (*close) (const struct grub_net_card *dev);
grub_err_t (*send) (const struct grub_net_card *dev,
struct grub_net_buff *buf);
grub_ssize_t (*recv) (const struct grub_net_card *dev,
@ -87,6 +89,8 @@ struct grub_net_card
struct grub_net_card_driver *driver;
grub_net_link_level_address_t default_address;
grub_net_card_flags_t flags;
int num_ifaces;
int opened;
union
{
struct
@ -236,7 +240,7 @@ struct grub_net_network_level_interface
struct grub_net_network_level_interface *next;
struct grub_net_network_level_interface **prev;
char *name;
const struct grub_net_card *card;
struct grub_net_card *card;
grub_net_network_level_address_t address;
grub_net_link_level_address_t hwaddress;
grub_net_interface_flags_t flags;
@ -284,7 +288,7 @@ grub_net_session_recv (struct grub_net_session *session, void *buf,
struct grub_net_network_level_interface *
grub_net_add_addr (const char *name,
const struct grub_net_card *card,
struct grub_net_card *card,
grub_net_network_level_address_t addr,
grub_net_link_level_address_t hwaddress,
grub_net_interface_flags_t flags);
@ -321,12 +325,8 @@ grub_net_card_register (struct grub_net_card *card)
GRUB_AS_LIST (card));
}
static inline void
grub_net_card_unregister (struct grub_net_card *card)
{
grub_list_remove (GRUB_AS_LIST_P (&grub_net_cards),
GRUB_AS_LIST (card));
}
void
grub_net_card_unregister (struct grub_net_card *card);
#define FOR_NET_CARDS(var) for (var = grub_net_cards; var; var = var->next)
#define FOR_NET_CARDS_SAFE(var, next) for (var = grub_net_cards, next = var->next; var; var = next, next = var->next)
@ -390,7 +390,7 @@ struct grub_net_bootp_packet
struct grub_net_network_level_interface *
grub_net_configure_by_dhcp_ack (const char *name,
const struct grub_net_card *card,
struct grub_net_card *card,
grub_net_interface_flags_t flags,
const struct grub_net_bootp_packet *bp,
grub_size_t size,
@ -398,7 +398,7 @@ grub_net_configure_by_dhcp_ack (const char *name,
void
grub_net_process_dhcp (struct grub_net_buff *nb,
const struct grub_net_card *card);
struct grub_net_card *card);
int
grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,
@ -418,6 +418,8 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target,
extern struct grub_net_network_level_interface *grub_net_network_level_interfaces;
#define FOR_NET_NETWORK_LEVEL_INTERFACES(var) for (var = grub_net_network_level_interfaces; var; var = var->next)
#define FOR_NET_NETWORK_LEVEL_INTERFACES_SAFE(var,next) for (var = grub_net_network_level_interfaces, next = var->next; var; var = next, next = var->next)
grub_err_t grub_net_send_link_layer (struct grub_net_network_level_interface *inf,
struct grub_net_buff *nb,
grub_net_link_level_address_t *target);