struct grub_net_card;
+typedef enum
+{
+ GRUB_NET_TFTP_ID,
+ GRUB_NET_UDP_ID,
+ GRUB_NET_IPV4_ID,
+ GRUB_NET_IPV6_ID,
+ GRUB_NET_ETHERNET_ID,
+ GRUB_NET_ARP_ID,
+ GRUB_NET_DHCP_ID
+
+}protocol_type_t;
+
struct grub_net_card_driver
{
+ grub_err_t (*init) (struct grub_net_card *dev);
+ grub_err_t (*fini) (struct grub_net_card *dev);
grub_err_t (*send) (struct grub_net_card *dev,struct grub_net_buff *nb);
grub_size_t (*recv) (struct grub_net_card *dev,struct grub_net_buff *nb);
};
#define GRUB_INTERFACE_HEADER
#include <grub/net.h>
#include <grub/net/protocol.h>
-/*
-extern struct grub_net_topprotocol;
+
+struct grub_net_protstack
+{
+ struct grub_net_protstack *next;
+ struct grub_net_protocol* prot;
+};
struct grub_net_interface
{
struct grub_net_card *card;
- struct grub_net_topprotocol* topprot;
+ struct grub_net_protstack* protstack;
+ char *path;
+ char *username;
+ char *password;
+ /*transport layer addres*/
struct grub_net_addr *tla;
+ /*internet layer addres*/
struct grub_net_addr *ila;
+ /*link layer addres*/
struct grub_net_addr *lla;
};
-*/
+
#endif
#include <grub/net/protocol.h>
#include <grub/net/netbuff.h>
#include <grub/net.h>
-struct protocol_operations;
+
struct grub_net_protocol;
struct grub_net_interface;
+struct grub_net_protstack;
struct grub_net_protocol
{
struct grub_net_protocol *next;
char *name;
grub_err_t (*open) (struct grub_net_interface* inf,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*open_confirm) (struct grub_net_interface *inf,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*get_payload) (struct grub_net_interface *inf,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*get_payload_confirm) (struct grub_net_interface* inf,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*close) (struct grub_net_interface *inf,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*send) (struct grub_net_interface *inf ,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
grub_err_t (*recv) (struct grub_net_interface *inf ,
- struct grub_net_protocol *prot, struct grub_net_buff *nb);
+ struct grub_net_protstack *protstack, struct grub_net_buff *nb);
};
typedef struct grub_net_protocol *grub_net_protocol_t;
-
-struct grub_net_interface
-{
- struct grub_net_card *card;
- struct grub_net_protocol* prot;
- char *path;
- char *username;
- char *password;
- /*transport layer addres*/
- struct grub_net_addr *tla;
- /*internet layer addres*/
- struct grub_net_addr *ila;
- /*link layer addres*/
- struct grub_net_addr *lla;
-};
-
void grub_protocol_register (grub_net_protocol_t prot);
void grub_protocol_unregister (grub_net_protocol_t prot);
#endif
#include <grub/net/ieee1275/interface.h>
#include <grub/net/netbuff.h>
#include <grub/net/protocol.h>
+#include <grub/net/interface.h>
static grub_err_t
-send_ethernet_packet (struct grub_net_interface *inf, struct grub_net_protocol *prot __attribute__ ((unused))
+send_ethernet_packet (struct grub_net_interface *inf,struct grub_net_protstack *protstack __attribute__ ((unused))
,struct grub_net_buff *nb)
{
#include <grub/net/ethernet.h>
#include <grub/net/netbuff.h>
#include <grub/net/protocol.h>
+#include <grub/net/interface.h>
#include <grub/mm.h>
struct grub_net_protocol *grub_ipv4_prot;
static grub_err_t
-send_ip_packet (struct grub_net_interface *inf, struct grub_net_protocol *prot, struct grub_net_buff *nb )
+send_ip_packet (struct grub_net_interface *inf, struct grub_net_protstack *protstack, struct grub_net_buff *nb )
{
struct iphdr *iph;
iph->chksum = ipchksum((void *)nb->head, sizeof(*iph));
- return prot->next->send(inf,prot->next,nb);
+ return protstack->next->prot->send(inf,protstack->next,nb);
}
static struct grub_net_protocol grub_ipv4_protocol =
#include <grub/net/ieee1275/interface.h>
#include <grub/ieee1275/ieee1275.h>
#include <grub/time.h>
+#include <grub/net/interface.h>
/*send read request*/
static grub_err_t
-send_tftp_rr (struct grub_net_interface *inf, struct grub_net_protocol *prot,struct grub_net_buff *nb)
+send_tftp_rr (struct grub_net_interface *inf, struct grub_net_protstack *protstack,struct grub_net_buff *nb)
{
/*Start TFTP header*/
grub_netbuff_unput (nb,nb->tail - (nb->data+hdrlen));
- return prot->next->send(inf,prot->next,nb);
+ return protstack->next->prot->send(inf,protstack->next,nb);
}
/*
#include <grub/net/type_net.h>
#include <grub/net/netbuff.h>
#include <grub/net/protocol.h>
+#include <grub/net/interface.h>
/*Assumes that there is allocated memory to the header before the buffer address. */
static grub_err_t
-send_udp_packet (struct grub_net_interface *inf, struct grub_net_protocol *prot, struct grub_net_buff *nb)
+send_udp_packet (struct grub_net_interface *inf, struct grub_net_protstack *protstack, struct grub_net_buff *nb)
{
struct udphdr *udph;
udph->chksum = 0;
udph->len = sizeof (sizeof (*udph)) + nb->end - nb->head;
- return prot->next->send(inf,prot->next,nb);
+ return protstack->next->prot->send(inf,protstack->next,nb);
}
static struct grub_net_protocol grub_udp_protocol =