grub/net/ieee1275/interface.c
Paulo de Rezende Pinatti 818a356eb1 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
2010-07-29 16:36:17 -03:00

46 lines
867 B
C

#include <grub/net/ieee1275/interface.h>
#include <grub/net/netbuff.h>
#include <grub/ieee1275/ofnet.h>
static grub_ieee1275_ihandle_t handle;
int card_open (void)
{
grub_ieee1275_open (grub_net->dev , &handle);
return 0;
}
int card_close (void)
{
if (handle)
grub_ieee1275_close (handle);
return 0;
}
int send_card_buffer (struct grub_net_buff *pack)
{
int actual;
grub_ieee1275_write (handle,pack->data,pack->tail - pack->data,&actual);
return actual;
}
int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
{
int actual, rc;
pack->data = pack->tail = pack->head;
do
{
rc = grub_ieee1275_read (handle,pack->data,1500,&actual);
}while (actual <= 0 || rc < 0);
grub_netbuff_put (pack, actual);
// grub_printf("packsize %d\n",pack->tail - pack->data);
return 0;// sizeof (eth) + iph.len;
}