Fixed get_card_packet to correctly read data from network card into buffer.
* net/ieee1275/interface.c (get_card_packet): read data regardless of ethernet header
This commit is contained in:
parent
f8795693f1
commit
818a356eb1
1 changed files with 4 additions and 50 deletions
|
@ -1,9 +1,4 @@
|
||||||
#include <grub/net/ieee1275/interface.h>
|
#include <grub/net/ieee1275/interface.h>
|
||||||
#include <grub/time.h>
|
|
||||||
#include <grub/mm.h>
|
|
||||||
#include <grub/net/ethernet.h>
|
|
||||||
#include <grub/net/ip.h>
|
|
||||||
#include <grub/net/arp.h>
|
|
||||||
#include <grub/net/netbuff.h>
|
#include <grub/net/netbuff.h>
|
||||||
#include <grub/ieee1275/ofnet.h>
|
#include <grub/ieee1275/ofnet.h>
|
||||||
|
|
||||||
|
@ -37,56 +32,15 @@ int send_card_buffer (struct grub_net_buff *pack)
|
||||||
int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
|
int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
|
|
||||||
int actual;
|
int actual, rc;
|
||||||
char *datap;
|
|
||||||
struct iphdr *iph;
|
|
||||||
struct etherhdr *eth;
|
|
||||||
struct arphdr *arph;
|
|
||||||
struct ip6hdr *ip6h;
|
|
||||||
pack->data = pack->tail = pack->head;
|
pack->data = pack->tail = pack->head;
|
||||||
datap = pack->data;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
grub_ieee1275_read (handle,datap,sizeof (*eth),&actual);
|
rc = grub_ieee1275_read (handle,pack->data,1500,&actual);
|
||||||
|
|
||||||
}while (actual <= 0);
|
}while (actual <= 0 || rc < 0);
|
||||||
eth = (struct etherhdr *) datap;
|
grub_netbuff_put (pack, actual);
|
||||||
datap += sizeof(*eth);
|
|
||||||
|
|
||||||
|
|
||||||
switch (eth->type)
|
|
||||||
{
|
|
||||||
case 0x806:
|
|
||||||
|
|
||||||
grub_ieee1275_read (handle,datap,sizeof (*arph),&actual);
|
|
||||||
arph = (struct arphdr *) datap;
|
|
||||||
|
|
||||||
grub_netbuff_put (pack,sizeof (*eth) + sizeof (*arph));
|
|
||||||
break;
|
|
||||||
case 0x800:
|
|
||||||
grub_ieee1275_read (handle,datap,sizeof (*iph),&actual);
|
|
||||||
iph = (struct iphdr *) datap;
|
|
||||||
datap += sizeof(*iph);
|
|
||||||
|
|
||||||
|
|
||||||
grub_ieee1275_read (handle,datap,iph->len - sizeof (*iph),&actual);
|
|
||||||
|
|
||||||
|
|
||||||
grub_netbuff_put (pack,sizeof (*eth) + iph->len);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x86DD:
|
|
||||||
grub_ieee1275_read (handle,datap,sizeof (*ip6h),&actual);
|
|
||||||
ip6h = (struct ip6hdr *) datap;
|
|
||||||
|
|
||||||
datap += sizeof(*ip6h);
|
|
||||||
grub_ieee1275_read (handle,datap,ip6h->payload_len - sizeof (*ip6h),&actual);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
grub_printf("Unknow packet %x\n",eth->type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// grub_printf("packsize %d\n",pack->tail - pack->data);
|
// grub_printf("packsize %d\n",pack->tail - pack->data);
|
||||||
return 0;// sizeof (eth) + iph.len;
|
return 0;// sizeof (eth) + iph.len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue