Clean Debug messages

This commit is contained in:
Manoel R. Abranches 2010-06-29 06:50:15 -03:00
parent 1edb7287ff
commit 3ec6213b17
8 changed files with 46 additions and 80 deletions

View file

@ -7,6 +7,7 @@
#include <grub/net/netbuff.h>
#include <grub/net/interface.h>
#include <grub/net.h>
#include <grub/time.h>
static grub_err_t
send_ethernet_packet (struct grub_net_network_layer_interface *inf __attribute__ ((unused)),
@ -42,6 +43,8 @@ recv_ethernet_packet (struct grub_net_network_layer_interface *inf __attribute__
struct grub_net_network_link_interface *net_link_inf __attribute__ ((unused)) ,struct grub_net_buff *nb)
{
struct etherhdr *eth;
grub_uint64_t start_time, current_time;
start_time = grub_get_time_ms();
while (1)
{
get_card_packet (nb);
@ -59,6 +62,9 @@ recv_ethernet_packet (struct grub_net_network_layer_interface *inf __attribute__
grub_netbuff_pull(nb,sizeof(*eth));
return 0;
}
current_time = grub_get_time_ms();
if (current_time - start_time > TIMEOUT_TIME_MS)
return grub_error (GRUB_ERR_TIMEOUT, "Time out.");
}
/* - get ethernet header
- verify if the next layer is the desired one.

View file

@ -29,9 +29,7 @@ int send_card_buffer (struct grub_net_buff *pack)
{
int actual;
//grub_printf("packet size transmited: %d\n",pack->tail - pack->data);
grub_ieee1275_write (handle,pack->data,pack->tail - pack->data,&actual);
// grub_printf("actual transmited %d\n",actual);
return actual;
}
@ -50,18 +48,11 @@ int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
do
{
grub_ieee1275_read (handle,datap,sizeof (*eth),&actual);
// if (actual <= 0)
// grub_millisleep(10);
}while (actual <= 0);
eth = (struct etherhdr *) datap;
datap += sizeof(*eth);
// 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 ("eth.type 0x%x\n",eth->type);
switch (eth->type)
{
@ -77,10 +68,6 @@ int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
iph = (struct iphdr *) datap;
datap += sizeof(*iph);
// grub_printf("ip.src 0x%x\n",iph->src);
// grub_printf("ip.dst 0x%x\n",iph->dest);
// grub_printf("ip.len 0x%x\n",iph->len);
// grub_printf("ip.protocol 0x%x\n",iph->protocol);
grub_ieee1275_read (handle,datap,iph->len - sizeof (*iph),&actual);
@ -89,11 +76,8 @@ int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
break;
case 0x86DD:
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);

View file

@ -7,6 +7,7 @@
#include <grub/net.h>
#include <grub/net/netbuff.h>
#include <grub/mm.h>
#include <grub/time.h>
struct grub_net_protocol *grub_ipv4_prot;
@ -65,6 +66,8 @@ recv_ip_packet (struct grub_net_network_layer_interface *inf,
{
struct iphdr *iph;
grub_uint64_t start_time, current_time;
start_time = grub_get_time_ms();
while (1)
{
trans_net_inf->inner_layer->link_prot->recv(inf,trans_net_inf->inner_layer,nb);
@ -74,6 +77,10 @@ recv_ip_packet (struct grub_net_network_layer_interface *inf,
grub_netbuff_pull(nb,sizeof(*iph));
return 0;
}
current_time = grub_get_time_ms();
if (current_time - start_time > TIMEOUT_TIME_MS)
return grub_error (GRUB_ERR_TIMEOUT, "Time out.");
}
/* grub_printf("ip.src 0x%x\n",iph->src);
grub_printf("ip.dst 0x%x\n",iph->dest);

View file

@ -41,11 +41,6 @@ grub_err_t grub_netbuff_unput (struct grub_net_buff *net_buff ,grub_size_t len)
grub_err_t grub_netbuff_push (struct grub_net_buff *net_buff ,grub_size_t len)
{
net_buff->data -= len;
/* grub_printf("push len =%d\n",len);
grub_printf("pack->head =%x\n",(unsigned int)net_buff->head);
grub_printf("pack->data =%x\n",(unsigned int)net_buff->data);
grub_printf("pack->tail =%x\n",(unsigned int)net_buff->tail);
grub_printf("pack->end =%x\n",(unsigned int)net_buff->end);*/
if (net_buff->data < net_buff->head)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "push out of the packet range.");
return GRUB_ERR_NONE;
@ -87,7 +82,7 @@ struct grub_net_buff *grub_netbuff_alloc ( grub_size_t len )
grub_err_t grub_netbuff_free (struct grub_net_buff *net_buff)
{
grub_free (net_buff);
grub_free (net_buff->head);
return 0;
}

View file

@ -70,7 +70,7 @@ tftp_open (struct grub_net_network_layer_interface *inf __attribute((unused)),
grub_netbuff_push (nb,sizeof (*tftph));
udp_interf = (struct udp_interf *) app_interface->data;
udp_interf->src = TFTP_CLIENT_PORT + rrq_count++;
udp_interf->src = TFTP_CLIENT_PORT;// + rrq_count++;
udp_interf->dst = TFTP_SERVER_PORT;
tftph = (struct tftphdr *) nb->data;
@ -112,6 +112,8 @@ tftp_open (struct grub_net_network_layer_interface *inf __attribute((unused)),
app_interface->trans_prot->send (inf,protstack->interface,nb);
/*Receive OACK*/
grub_netbuff_clear (nb);
grub_netbuff_reserve (nb,80*1024);
return app_interface->app_prot->recv(inf,protstack,nb);
}
@ -211,6 +213,8 @@ static int tftp_file_size (struct grub_net_network_layer_interface* inf ,
{
tftp_open (inf, protocol_stack,nb, filename);
grub_netbuff_clear (nb);
grub_netbuff_reserve (nb,80*1024);
tftp_send_err (inf, protocol_stack,nb,"Abort transference.",0);
return tftp_file.size;

View file

@ -4,6 +4,7 @@
#include <grub/net/netbuff.h>
#include <grub/net/protocol.h>
#include <grub/net/interface.h>
#include <grub/time.h>
static grub_err_t
send_udp_packet (struct grub_net_network_layer_interface *inf,
@ -35,7 +36,8 @@ receive_udp_packet (struct grub_net_network_layer_interface *inf,
struct udphdr *udph;
struct udp_interf *udp_interf;
udp_interf = (struct udp_interf *) app_trans_inf->data;
grub_uint64_t start_time, current_time;
start_time = grub_get_time_ms();
while(1)
{
app_trans_inf->inner_layer->net_prot->recv(inf,app_trans_inf->inner_layer,nb);
@ -62,6 +64,10 @@ receive_udp_packet (struct grub_net_network_layer_interface *inf,
return 0;
}
current_time = grub_get_time_ms();
if (current_time - start_time > TIMEOUT_TIME_MS)
return grub_error (GRUB_ERR_TIMEOUT, "Time out.");
}
}