]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
small change in the interface structure.
authorManoel R. Abranches <mrabran@br.ibm.com>
Thu, 29 Apr 2010 20:56:09 +0000 (17:56 -0300)
committerManoel R. Abranches <mrabran@br.ibm.com>
Thu, 29 Apr 2010 20:56:09 +0000 (17:56 -0300)
include/grub/net.h
include/grub/net/interface.h
include/grub/net/protocol.h
net/ethernet.c
net/ip.c
net/tftp.c
net/udp.c

index 75efd51d64391eb13d4a7deaf45a853f09b473ab..f021f0e9c24e53f95839f081f00531c114dd5d87 100644 (file)
 
 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);  
 };
index 0e11c86ba1df5898eda7f458cbb0b6df1bc54661..2e0ddfcc8098bbf6963ec230f288e5c10060ea89 100644 (file)
@@ -2,16 +2,26 @@
 #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
index 2c979481b5bc99ff299353da175bdc4483846742..1efc2ab7b832fada2960d8d535a609b6f7f40a4c 100644 (file)
@@ -4,47 +4,32 @@
 #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
index fc64803e7c75a84fd3193d6052d243fe38eeb7d8..8c13966c1b3cec1db9fa00536568e74541245c0a 100644 (file)
@@ -6,9 +6,10 @@
 #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)
 {
 
index c669ff6d7f595f405fdfd8722eb224909393eb52..6fe58adb0ab82c325335852c535c124c2929345c 100644 (file)
--- a/net/ip.c
+++ b/net/ip.c
@@ -5,6 +5,7 @@
 #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;
@@ -28,7 +29,7 @@ ipchksum(void *ipv, int len)
 
 
 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;
@@ -57,7 +58,7 @@ send_ip_packet (struct grub_net_interface *inf, struct grub_net_protocol *prot,
   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 =
index fdca184e95e90fdebfe63070ec871a112672a538..3f481fe58325edfd0ccb1ded812101879bd1fc16 100644 (file)
@@ -8,10 +8,11 @@
 #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*/
   
@@ -58,7 +59,7 @@ send_tftp_rr (struct grub_net_interface *inf, struct grub_net_protocol *prot,str
  
   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); 
 }
 
 /*
index 600eec5429beb0e7d44df1586271afe644dd8f21..2a4a7690b8c662beb4b0d4c058152ac74f7c8ca2 100644 (file)
--- a/net/udp.c
+++ b/net/udp.c
@@ -3,9 +3,10 @@
 #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;
@@ -21,7 +22,7 @@ send_udp_packet (struct grub_net_interface *inf, struct grub_net_protocol *prot,
   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 =