Parse ipv6 header on incoming packets.

This commit is contained in:
Manoel R. Abranches 2010-06-23 14:49:46 -03:00
parent bf6d9eeb53
commit 1edb7287ff
4 changed files with 39 additions and 19 deletions

View file

@ -3,7 +3,6 @@
# Images.
<<<<<<< TREE
kernel_img_HEADERS += ieee1275/ieee1275.h \
command.h i18n.h env_private.h net/ip.h net/udp.h net/ethernet.h net/arp.h net/tftp.h\
net/ieee1275/interface.h net/type_net.h net.h net/interface.h net/protocol.h net/netbuff.h

View file

@ -145,7 +145,7 @@ grub_ofnetfs_open (struct grub_file *file , const char *name )
return 1;
}
grub_printf("name = %s\n",name);
// grub_printf("name = %s\n",name);
struct grub_net_protocol_stack *stack;
struct grub_net_buff *pack;
@ -164,38 +164,37 @@ grub_ofnetfs_open (struct grub_file *file , const char *name )
for (found_addr = 0x800000; found_addr < + 2000 * 0x100000; found_addr += 0x100000)
{
grub_printf("traing to claim %d bytes at 0x%x\n",file_size,found_addr);
// grub_printf("trying to claim %d bytes at 0x%x\n",file_size,found_addr);
if (grub_claimmap (found_addr , file_size) != -1)
break;
}
grub_printf("Claimed %d bytes at 0x%x\n",file_size,found_addr);
// grub_printf("Claimed %d bytes at 0x%x\n",file_size,found_addr);
file->data = (void *) found_addr;
grub_printf("file->data = 0x%x\n",(int)file->data);
grub_printf("file_size = %d\n",file_size);
grub_printf("OPEN\n");
// grub_printf("file->data = 0x%x\n",(int)file->data);
// grub_printf("file_size = %d\n",file_size);
// grub_printf("OPEN\n");
grub_netbuff_clear(pack);
grub_netbuff_reserve (pack,80*1024);
app_interface->app_prot->open (NULL,stack,pack,(char *) name);
do {
//if (app_interface->app_prot->recv (NULL,stack,pack) == GRUB_ERR_NONE)
grub_printf("RECEIVE PACKET\n");
// grub_printf("RECEIVE PACKET\n");
grub_netbuff_clear(pack);
grub_netbuff_reserve (pack,80*1024);
app_interface->app_prot->recv (NULL,stack,pack);
if (grub_errno != GRUB_ERR_NONE)
return grub_errno;
grub_printf("RECEIVED PACKET\n");
// grub_printf("RECEIVED PACKET\n");
// {
grub_printf("payload_size= %d\n",pack->tail - pack->data);
grub_printf("amount= %d\n",amount);
grub_printf("file_size= %d\n",file_size);
// grub_printf("payload_size= %d\n",pack->tail - pack->data);
// grub_printf("amount= %d\n",amount);
// grub_printf("file_size= %d\n",file_size);
datap = (char *)file->data + amount;
amount += (pack->tail - pack->data);
grub_printf("datap = 0x%x\n",(int)datap );
// amount += pack->tail - pack->data;
// grub_printf("datap = 0x%x\n",(int)datap );
grub_memcpy(datap, pack->data, pack->tail - pack->data);
grub_printf("SEND ACK\n");
// grub_printf("SEND ACK\n");
grub_netbuff_clear(pack);
grub_netbuff_reserve (pack,80*1024);
@ -204,12 +203,12 @@ grub_ofnetfs_open (struct grub_file *file , const char *name )
if (grub_errno != GRUB_ERR_NONE)
return grub_errno;
grub_printf("SENT ACK\n");
// grub_printf("SENT ACK\n");
//}
// file->data = grub_realloc(file->data,amount);
}while (amount < file_size);
grub_printf("transfer complete\n");
// grub_printf("transfer complete\n");
file->size = file_size;
// grub_netbuff_free(pack);

View file

@ -16,6 +16,18 @@ struct iphdr {
grub_uint32_t dest;
} __attribute__ ((packed)) ;
struct ip6hdr
{
grub_uint8_t version:4,
priority:4;
grub_uint8_t flow_lbl[3];
grub_uint16_t payload_len;
grub_uint8_t nexthdr;
grub_uint8_t hop_limit;
grub_uint8_t saddr[16];
grub_uint8_t daddr[16];
} __attribute__ ((packed));
#define IP_UDP 17 /* UDP protocol */
#define IP_BROADCAST 0xFFFFFFFF

View file

@ -44,6 +44,7 @@ int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
struct iphdr *iph;
struct etherhdr *eth;
struct arphdr *arph;
struct ip6hdr *ip6h;
pack->data = pack->tail = pack->head;
datap = pack->data;
do
@ -86,11 +87,20 @@ int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
grub_netbuff_put (pack,sizeof (*eth) + iph->len);
break;
case 0x86DD:
grub_printf("Ipv6 not yet implemented.\n");
grub_printf("!!!!!!!!!!!!!!!!!IPV6 packet received!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
grub_ieee1275_read (handle,datap,sizeof (*ip6h),&actual);
ip6h = (struct ip6hdr *) datap;
grub_printf("ip6hdr->payload_len = %x\n",ip6h->payload_len);
grub_printf("ip6hdr->nexthdr = %x\n",ip6h->nexthdr);
datap += sizeof(*ip6h);
grub_ieee1275_read (handle,datap,ip6h->payload_len - sizeof (*ip6h),&actual);
break;
default:
grub_printf("Unknow packet %x\n",eth->type);
grub_printf("Unknow packet %x\n",eth->type);
break;
}
// grub_printf("packsize %d\n",pack->tail - pack->data);