2010-04-27 21:05:35 +00:00
|
|
|
#include <grub/misc.h>
|
|
|
|
#include <grub/mm.h>
|
|
|
|
#include <grub/net/ethernet.h>
|
|
|
|
#include <grub/net/ip.h>
|
|
|
|
#include <grub/net/arp.h>
|
|
|
|
#include <grub/net/ieee1275/interface.h>
|
|
|
|
#include <grub/net/netbuff.h>
|
2010-04-29 20:56:09 +00:00
|
|
|
#include <grub/net/interface.h>
|
2010-06-21 22:15:45 +00:00
|
|
|
#include <grub/net.h>
|
2010-04-27 21:05:35 +00:00
|
|
|
|
|
|
|
static grub_err_t
|
2010-06-21 22:15:45 +00:00
|
|
|
send_ethernet_packet (struct grub_net_network_layer_interface *inf __attribute__ ((unused)),
|
|
|
|
struct grub_net_network_link_interface *net_link_inf __attribute__ ((unused)) ,struct grub_net_buff *nb)
|
2010-04-27 21:05:35 +00:00
|
|
|
{
|
|
|
|
|
2010-06-21 22:15:45 +00:00
|
|
|
struct etherhdr *eth;
|
|
|
|
|
|
|
|
grub_netbuff_push (nb,sizeof(*eth));
|
2010-04-27 21:05:35 +00:00
|
|
|
eth = (struct etherhdr *) nb->data;
|
2010-06-21 22:15:45 +00:00
|
|
|
eth->dst[0] =0x00;
|
|
|
|
eth->dst[1] =0x11;
|
|
|
|
eth->dst[2] =0x25;
|
|
|
|
eth->dst[3] =0xca;
|
|
|
|
eth->dst[4] =0x1f;
|
|
|
|
eth->dst[5] =0x01;
|
|
|
|
eth->src[0] =0x0a;
|
|
|
|
eth->src[1] =0x11;
|
|
|
|
eth->src[2] =0xbd;
|
|
|
|
eth->src[3] =0xe3;
|
|
|
|
eth->src[4] =0xe3;
|
|
|
|
eth->src[5] =0x04;
|
|
|
|
|
2010-04-27 21:05:35 +00:00
|
|
|
eth->type = 0x0800;
|
2010-06-21 22:15:45 +00:00
|
|
|
|
|
|
|
return send_card_buffer(nb);
|
|
|
|
// return inf->card->driver->send(inf->card,nb);
|
2010-04-27 21:05:35 +00:00
|
|
|
}
|
|
|
|
|
2010-06-21 22:15:45 +00:00
|
|
|
|
|
|
|
static grub_err_t
|
|
|
|
recv_ethernet_packet (struct grub_net_network_layer_interface *inf __attribute__ ((unused)),
|
|
|
|
struct grub_net_network_link_interface *net_link_inf __attribute__ ((unused)) ,struct grub_net_buff *nb)
|
2010-04-27 21:05:35 +00:00
|
|
|
{
|
2010-06-21 22:15:45 +00:00
|
|
|
struct etherhdr *eth;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
get_card_packet (nb);
|
|
|
|
eth = (struct etherhdr *) nb->data;
|
|
|
|
/*change for grub_memcmp*/
|
|
|
|
if( eth->src[0] == 0x00 && eth->src[1] == 0x11 && eth->src[2] == 0x25 &&
|
|
|
|
eth->src[3] == 0xca && eth->src[4] == 0x1f && eth->src[5] == 0x01 && eth->type == 0x800)
|
|
|
|
{
|
|
|
|
//grub_printf("ethernet eth->dst %x:%x:%x:%x:%x:%x\n",eth->dst[0],
|
|
|
|
// eth->dst[1],eth->dst[2],eth->dst[3],eth->dst[4],eth->dst[5]);
|
|
|
|
// grub_printf("ethernet eth->src %x:%x:%x:%x:%x:%x\n",eth->src[0],eth->src[1],
|
|
|
|
// eth->src[2],eth->src[3],eth->src[4],eth->src[5]);
|
|
|
|
//grub_printf("ethernet eth->type 0x%x\n",eth->type);
|
|
|
|
//grub_printf("out from ethernet\n");
|
|
|
|
grub_netbuff_pull(nb,sizeof(*eth));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* - get ethernet header
|
|
|
|
- verify if the next layer is the desired one.
|
|
|
|
- if not. get another packet.
|
|
|
|
- remove ethernet header from buffer*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct grub_net_link_layer_protocol grub_ethernet_protocol =
|
|
|
|
{
|
|
|
|
.name = "ethernet",
|
|
|
|
.id = GRUB_NET_ETHERNET_ID,
|
|
|
|
.send = send_ethernet_packet,
|
|
|
|
.recv = recv_ethernet_packet
|
2010-04-27 21:05:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void ethernet_ini(void)
|
|
|
|
{
|
2010-06-21 22:15:45 +00:00
|
|
|
grub_net_link_layer_protocol_register (&grub_ethernet_protocol);
|
2010-04-27 21:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ethernet_fini(void)
|
|
|
|
{
|
2010-06-21 22:15:45 +00:00
|
|
|
grub_net_link_layer_protocol_unregister (&grub_ethernet_protocol);
|
2010-04-27 21:05:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|