Run indent on files.

This commit is contained in:
Manoel Rebelo Abranches 2011-06-07 21:59:53 -03:00
parent 423a1849ef
commit 4700d08bb4
8 changed files with 307 additions and 288 deletions

View file

@ -9,8 +9,8 @@
static struct arp_entry arp_table[10];
static grub_int8_t new_table_entry = -1;
static
void arp_init_table(void)
static void
arp_init_table (void)
{
grub_memset (arp_table, 0, sizeof (arp_table));
new_table_entry = 0;
@ -20,9 +20,9 @@ static struct arp_entry *
arp_find_entry (const grub_net_network_level_address_t *proto)
{
unsigned i;
for(i = 0; i < ARRAY_SIZE (arp_table); i++)
for (i = 0; i < ARRAY_SIZE (arp_table); i++)
{
if(arp_table[i].avail == 1 &&
if (arp_table[i].avail == 1 &&
arp_table[i].nl_address.ipv4 == proto->ipv4)
return &(arp_table[i]);
}
@ -30,7 +30,7 @@ arp_find_entry (const grub_net_network_level_address_t *proto)
}
grub_err_t
grub_net_arp_resolve(struct grub_net_network_level_interface *inf,
grub_net_arp_resolve (struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *proto_addr,
grub_net_link_level_address_t *hw_addr)
{
@ -53,8 +53,8 @@ grub_net_arp_resolve(struct grub_net_network_level_interface *inf,
nb.end = arp_data + sizeof (arp_data);
grub_netbuff_clear (&nb);
grub_netbuff_reserve (&nb,128);
grub_netbuff_push (&nb, sizeof(*arp_header) + 2 * (6 + 4));
grub_netbuff_reserve (&nb, 128);
grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + 4));
arp_header = (struct arphdr *) nb.data;
arp_header->hrd = grub_cpu_to_be16 (GRUB_NET_ARPHRD_ETHERNET);
arp_header->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP);
@ -71,11 +71,11 @@ grub_net_arp_resolve(struct grub_net_network_level_interface *inf,
grub_memcpy (aux, &inf->address.ipv4, 4);
aux += 4;
/* Target hardware address */
for(i = 0; i < 6; i++)
for (i = 0; i < 6; i++)
aux[i] = 0x00;
aux += 6;
/* Target protocol address */
grub_memcpy(aux, &proto_addr->ipv4, 4);
grub_memcpy (aux, &proto_addr->ipv4, 4);
grub_memset (&target_hw_addr.mac, 0xff, 6);
send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP);
@ -96,39 +96,40 @@ grub_net_arp_resolve(struct grub_net_network_level_interface *inf,
grub_err_t
grub_net_arp_receive (struct grub_net_buff *nb)
{
struct arphdr *arp_header = (struct arphdr *)nb->data;
struct arphdr *arp_header = (struct arphdr *) nb->data;
struct arp_entry *entry;
grub_uint8_t *sender_hardware_address, *sender_protocol_address;
grub_uint8_t *target_hardware_address, *target_protocol_address;
grub_net_network_level_address_t hwaddress;
struct grub_net_network_level_interface *inf;
sender_hardware_address = (grub_uint8_t *) arp_header + sizeof(*arp_header);
sender_hardware_address =
(grub_uint8_t *) arp_header + sizeof (*arp_header);
sender_protocol_address = sender_hardware_address + arp_header->hln;
target_hardware_address = sender_protocol_address + arp_header->pln;
target_protocol_address = target_hardware_address + arp_header->hln;
grub_memcpy (&hwaddress.ipv4, sender_protocol_address, 4);
/* Check if the sender is in the cache table */
entry = arp_find_entry(&hwaddress);
/* Update sender hardware address */
/* Check if the sender is in the cache table. */
entry = arp_find_entry (&hwaddress);
/* Update sender hardware address. */
if (entry)
grub_memcpy(entry->ll_address.mac, sender_hardware_address, 6);
grub_memcpy (entry->ll_address.mac, sender_hardware_address, 6);
else
{
/* Add sender to cache table */
/* Add sender to cache table. */
if (new_table_entry == -1)
arp_init_table();
arp_init_table ();
entry = &(arp_table[new_table_entry]);
entry->avail = 1;
grub_memcpy(&entry->nl_address.ipv4, sender_protocol_address, 4);
grub_memcpy(entry->ll_address.mac, sender_hardware_address, 6);
grub_memcpy (&entry->nl_address.ipv4, sender_protocol_address, 4);
grub_memcpy (entry->ll_address.mac, sender_hardware_address, 6);
new_table_entry++;
if (new_table_entry == ARRAY_SIZE (arp_table))
new_table_entry = 0;
}
FOR_NET_NETWORK_LEVEL_INTERFACES(inf)
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
{
/* Am I the protocol address target? */
if (grub_memcmp (target_protocol_address, &inf->address.ipv4, 6) == 0
@ -136,10 +137,12 @@ grub_net_arp_receive (struct grub_net_buff *nb)
{
grub_net_link_level_address_t aux;
/* Swap hardware fields */
grub_memcpy (target_hardware_address, sender_hardware_address, arp_header->hln);
grub_memcpy (target_hardware_address, sender_hardware_address,
arp_header->hln);
grub_memcpy (sender_hardware_address, inf->hwaddress.mac, 6);
grub_memcpy (aux.mac, sender_protocol_address, 6);
grub_memcpy (sender_protocol_address, target_protocol_address, arp_header->pln);
grub_memcpy (sender_protocol_address, target_protocol_address,
arp_header->pln);
grub_memcpy (target_protocol_address, aux.mac, arp_header->pln);
/* Change operation to REPLY and send packet */
arp_header->op = grub_be_to_cpu16 (ARP_REPLY);

View file

@ -32,7 +32,7 @@ get_card_packet (struct grub_net_card *dev __attribute__ ((unused)),
{
ssize_t actual;
grub_netbuff_clear(pack);
grub_netbuff_clear (pack);
actual = read (fd, pack->data, 1500);
if (actual < 0)
return -1;
@ -42,22 +42,22 @@ get_card_packet (struct grub_net_card *dev __attribute__ ((unused)),
}
static struct grub_net_card_driver emudriver =
{
{
.name = "emu",
.send = send_card_buffer,
.recv = get_card_packet
};
};
static struct grub_net_card emucard =
{
{
.name = "emu0",
.driver = &emudriver,
.default_address = {
.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET,
{ .mac = { 0, 1, 2, 3, 4, 5} }
{.mac = {0, 1, 2, 3, 4, 5}}
},
.flags = 0
};
};
GRUB_MOD_INIT(emunet)
{
@ -84,6 +84,3 @@ GRUB_MOD_FINI(emunet)
grub_net_card_unregister (&emucard);
}
}

View file

@ -12,10 +12,13 @@ card_open (struct grub_net_card *dev)
{
int status;
struct grub_ofnetcard_data *data = dev->data;
char path[grub_strlen(data->path) + grub_strlen(":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512") + 1];
char path[grub_strlen (data->path) +
grub_strlen (":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512") + 1];
/* The full string will prevent a bootp packet to be sent. Just put some valid ip in there. */
grub_snprintf(path,sizeof(path),"%s%s",data->path,":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512");
status = grub_ieee1275_open (path,&(data->handle));
grub_snprintf (path, sizeof (path), "%s%s", data->path,
":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512");
status = grub_ieee1275_open (path, &(data->handle));
if (status)
return grub_error (GRUB_ERR_IO, "Couldn't open network card.");
@ -70,13 +73,13 @@ get_card_packet (struct grub_net_card *dev, struct grub_net_buff *nb)
}
static struct grub_net_card_driver ofdriver =
{
{
.name = "ofnet",
.init = card_open,
.fini = card_close,
.send = send_card_buffer,
.recv = get_card_packet
};
};
static const struct
{
@ -85,21 +88,21 @@ static const struct
}
bootp_response_properties[] =
{
{ .name = "bootp-response", .offset = 0 },
{ .name = "dhcp-response", .offset = 0 },
{ .name = "bootpreply-packet", .offset = 0x2a },
};
{
{ .name = "bootp-response", .offset = 0},
{ .name = "dhcp-response", .offset = 0},
{ .name = "bootpreply-packet", .offset = 0x2a},
};
static grub_bootp_t
grub_getbootp_real ( void )
grub_getbootp_real (void)
{
grub_bootp_t packet = grub_malloc (sizeof *packet);
char *bootp_response;
grub_ssize_t size;
unsigned int i;
for ( i = 0; i < ARRAY_SIZE (bootp_response_properties); i++)
for (i = 0; i < ARRAY_SIZE (bootp_response_properties); i++)
if (grub_ieee1275_get_property_length (grub_ieee1275_chosen,
bootp_response_properties[i].name,
&size) >= 0)
@ -111,8 +114,7 @@ grub_getbootp_real ( void )
bootp_response = grub_malloc (size);
if (grub_ieee1275_get_property (grub_ieee1275_chosen,
bootp_response_properties[i].name,
bootp_response ,
size, 0) < 0)
bootp_response, size, 0) < 0)
return NULL;
grub_memcpy (packet, bootp_response + bootp_response_properties[i].offset, sizeof (*packet));
@ -120,8 +122,8 @@ grub_getbootp_real ( void )
return packet;
}
static
void grub_ofnet_findcards (void)
static void
grub_ofnet_findcards (void)
{
struct grub_net_card *card;
grub_ieee1275_phandle_t devhandle;
@ -131,20 +133,23 @@ void grub_ofnet_findcards (void)
int search_net_devices (struct grub_ieee1275_devalias *alias)
{
if ( !grub_strcmp (alias->type,"network") )
if (!grub_strcmp (alias->type, "network"))
{
card = grub_malloc (sizeof (struct grub_net_card));
struct grub_ofnetcard_data *ofdata = grub_malloc (sizeof (struct grub_ofnetcard_data));
struct grub_ofnetcard_data *ofdata =
grub_malloc (sizeof (struct grub_ofnetcard_data));
ofdata->path = grub_strdup (alias->path);
grub_ieee1275_finddevice (ofdata->path, &devhandle);
if (grub_ieee1275_get_integer_property
(devhandle, "max-frame-size", &(ofdata->mtu), sizeof (ofdata->mtu), 0))
(devhandle, "max-frame-size", &(ofdata->mtu),
sizeof (ofdata->mtu), 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve mtu size.");
if (grub_ieee1275_get_property (devhandle, "mac-address", &(lla.mac), 6, 0))
if (grub_ieee1275_get_property
(devhandle, "mac-address", &(lla.mac), 6, 0))
return grub_error (GRUB_ERR_IO, "Couldn't retrieve mac address.");
lla.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
@ -153,7 +158,7 @@ void grub_ofnet_findcards (void)
card->driver = NULL;
card->data = ofdata;
card->flags = 0;
card->name = grub_xasprintf("eth%d",i++); // grub_strdup (alias->name);
card->name = grub_xasprintf ("eth%d", i++);
grub_net_card_register (card);
return 0;
}
@ -164,8 +169,8 @@ void grub_ofnet_findcards (void)
grub_ieee1275_devices_iterate (search_net_devices);
}
static
void grub_ofnet_probecards (void)
static void
grub_ofnet_probecards (void)
{
struct grub_net_card *card;
struct grub_net_card_driver *driver;
@ -180,14 +185,16 @@ void grub_ofnet_probecards (void)
{
FOR_NET_CARD_DRIVERS (driver)
{
if (driver->init(card) == GRUB_ERR_NONE)
if (driver->init (card) == GRUB_ERR_NONE)
{
card->driver = driver;
if (bootp_pckt && grub_memcmp(bootp_pckt->chaddr,card->default_address.mac,6) == 0)
if (bootp_pckt
&& grub_memcmp (bootp_pckt->chaddr, card->default_address.mac, 6) == 0)
{
addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4;
addr.ipv4 = bootp_pckt->yiaddr;
grub_net_add_addr ("bootp_cli_addr", card, addr, card->default_address, 0);
grub_net_add_addr ("bootp_cli_addr", card, addr,
card->default_address, 0);
FOR_NET_NETWORK_LEVEL_INTERFACES (inter)
if (grub_strcmp (inter->name, "bootp_cli_addr") == 0)
break;
@ -204,7 +211,7 @@ void grub_ofnet_probecards (void)
}
GRUB_MOD_INIT (ofnet)
GRUB_MOD_INIT(ofnet)
{
struct grub_net_card *card;
grub_getbootp = grub_getbootp_real;
@ -216,11 +223,8 @@ GRUB_MOD_INIT (ofnet)
grub_net_card_unregister (card);
}
GRUB_MOD_FINI (ofnet)
GRUB_MOD_FINI(ofnet)
{
grub_net_card_driver_unregister (&ofdriver);
grub_getbootp = NULL;
}

View file

@ -16,10 +16,10 @@ send_ethernet_packet (struct grub_net_network_level_interface *inf,
{
struct etherhdr *eth;
grub_netbuff_push (nb,sizeof(*eth));
grub_netbuff_push (nb, sizeof (*eth));
eth = (struct etherhdr *) nb->data;
grub_memcpy(eth->dst, target_addr.mac, 6);
grub_memcpy(eth->src, inf->hwaddress.mac, 6);
grub_memcpy (eth->dst, target_addr.mac, 6);
grub_memcpy (eth->src, inf->hwaddress.mac, 6);
eth->type = grub_cpu_to_be16 (ethertype);
@ -45,19 +45,19 @@ grub_net_recv_ethernet_packet (struct grub_net_buff *nb)
if (llch->dsap == 0xaa && llch->ssap == 0xaa && llch->ctrl == 0x3)
{
grub_netbuff_pull (nb,sizeof(*llch));
grub_netbuff_pull (nb, sizeof (*llch));
snaph = (struct snaphdr *) nb->data;
type = snaph->type;
}
}
/* ARP packet */
/* ARP packet. */
if (type == GRUB_NET_ETHERTYPE_ARP)
{
grub_net_arp_receive (nb);
grub_netbuff_free (nb);
}
/* IP packet */
/* IP packet. */
if (type == GRUB_NET_ETHERTYPE_IP)
grub_net_recv_ip_packets (nb);

View file

@ -8,9 +8,9 @@
#include <grub/mm.h>
grub_uint16_t
ipchksum(void *ipv, int len)
ipchksum (void *ipv, int len)
{
grub_uint16_t *ip = (grub_uint16_t *)ipv;
grub_uint16_t *ip = (grub_uint16_t *) ipv;
grub_uint32_t sum = 0;
len >>= 1;
@ -34,12 +34,12 @@ grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
grub_net_link_level_address_t ll_target_addr;
grub_err_t err;
grub_netbuff_push (nb, sizeof(*iph));
grub_netbuff_push (nb, sizeof (*iph));
iph = (struct iphdr *) nb->data;
iph->verhdrlen = ((4 << 4) | 5);
iph->service = 0;
iph->len = grub_cpu_to_be16 (nb->tail - nb-> data);
iph->len = grub_cpu_to_be16 (nb->tail - nb->data);
iph->ident = grub_cpu_to_be16 (++id);
iph->frags = 0;
iph->ttl = 0xff;
@ -47,8 +47,8 @@ grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
iph->src = inf->address.ipv4;
iph->dest = target->ipv4;
iph->chksum = 0 ;
iph->chksum = ipchksum((void *)nb->data, sizeof(*iph));
iph->chksum = 0;
iph->chksum = ipchksum ((void *) nb->data, sizeof (*iph));
/* Determine link layer target address via ARP. */
err = grub_net_arp_resolve (inf, target, &ll_target_addr);
@ -56,6 +56,7 @@ grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
return err;
return send_ethernet_packet (inf, nb, ll_target_addr, GRUB_NET_ETHERTYPE_IP);
}
/*
static int
ip_filter (struct grub_net_buff *nb)

View file

@ -22,7 +22,8 @@
#include <grub/net/netbuff.h>
grub_err_t grub_netbuff_put (struct grub_net_buff *nb ,grub_size_t len)
grub_err_t
grub_netbuff_put (struct grub_net_buff *nb, grub_size_t len)
{
nb->tail += len;
if (nb->tail > nb->end)
@ -30,40 +31,49 @@ grub_err_t grub_netbuff_put (struct grub_net_buff *nb ,grub_size_t len)
return GRUB_ERR_NONE;
}
grub_err_t grub_netbuff_unput (struct grub_net_buff *nb ,grub_size_t len)
grub_err_t
grub_netbuff_unput (struct grub_net_buff *nb, grub_size_t len)
{
nb->tail -= len;
if (nb->tail < nb->head)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "unput out of the packet range.");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"unput out of the packet range.");
return GRUB_ERR_NONE;
}
grub_err_t grub_netbuff_push (struct grub_net_buff *nb ,grub_size_t len)
grub_err_t
grub_netbuff_push (struct grub_net_buff *nb, grub_size_t len)
{
nb->data -= len;
if (nb->data < nb->head)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "push out of the packet range.");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"push out of the packet range.");
return GRUB_ERR_NONE;
}
grub_err_t grub_netbuff_pull (struct grub_net_buff *nb ,grub_size_t len)
grub_err_t
grub_netbuff_pull (struct grub_net_buff *nb, grub_size_t len)
{
nb->data += len;
if (nb->data > nb->end)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "pull out of the packet range.");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"pull out of the packet range.");
return GRUB_ERR_NONE;
}
grub_err_t grub_netbuff_reserve (struct grub_net_buff *nb ,grub_size_t len)
grub_err_t
grub_netbuff_reserve (struct grub_net_buff *nb, grub_size_t len)
{
nb->data += len;
nb->tail += len;
if ((nb->tail > nb->end) || (nb->data > nb->end))
return grub_error (GRUB_ERR_OUT_OF_RANGE, "reserve out of the packet range.");
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"reserve out of the packet range.");
return GRUB_ERR_NONE;
}
struct grub_net_buff *grub_netbuff_alloc ( grub_size_t len )
struct grub_net_buff *
grub_netbuff_alloc (grub_size_t len)
{
struct grub_net_buff *nb;
void *data;
@ -71,7 +81,7 @@ struct grub_net_buff *grub_netbuff_alloc ( grub_size_t len )
if (len < NETBUFFMINLEN)
len = NETBUFFMINLEN;
len = ALIGN_UP (len,NETBUFF_ALIGN);
len = ALIGN_UP (len, NETBUFF_ALIGN);
data = grub_memalign (NETBUFF_ALIGN, len + sizeof (*nb));
if (!data)
return NULL;
@ -81,14 +91,15 @@ struct grub_net_buff *grub_netbuff_alloc ( grub_size_t len )
return nb;
}
grub_err_t grub_netbuff_free (struct grub_net_buff *nb)
grub_err_t
grub_netbuff_free (struct grub_net_buff *nb)
{
grub_free (nb->head);
return 0;
}
grub_err_t grub_netbuff_clear (struct grub_net_buff *nb)
grub_err_t
grub_netbuff_clear (struct grub_net_buff *nb)
{
nb->data = nb->tail = nb->head;
return 0;

View file

@ -33,8 +33,8 @@ tftp_open (struct grub_file *file, const char *filename)
nb.end = open_data + sizeof (open_data);
grub_netbuff_clear (&nb);
grub_netbuff_reserve (&nb,1500);
grub_netbuff_push (&nb,sizeof (*tftph));
grub_netbuff_reserve (&nb, 1500);
grub_netbuff_push (&nb, sizeof (*tftph));
tftph = (struct tftphdr *) nb.data;
@ -46,23 +46,23 @@ tftp_open (struct grub_file *file, const char *filename)
rrqlen += grub_strlen (filename) + 1;
rrq += grub_strlen (filename) + 1;
grub_strcpy (rrq,"octet");
grub_strcpy (rrq, "octet");
rrqlen += grub_strlen ("octet") + 1;
rrq += grub_strlen ("octet") + 1;
grub_strcpy (rrq,"blksize");
rrqlen += grub_strlen("blksize") + 1;
grub_strcpy (rrq, "blksize");
rrqlen += grub_strlen ("blksize") + 1;
rrq += grub_strlen ("blksize") + 1;
grub_strcpy (rrq,"1024");
grub_strcpy (rrq, "1024");
rrqlen += grub_strlen ("1024") + 1;
rrq += grub_strlen ("1024") + 1;
grub_strcpy (rrq,"tsize");
grub_strcpy (rrq, "tsize");
rrqlen += grub_strlen ("tsize") + 1;
rrq += grub_strlen ("tsize") + 1;
grub_strcpy (rrq,"0");
grub_strcpy (rrq, "0");
rrqlen += grub_strlen ("0") + 1;
rrq += grub_strlen ("0") + 1;
hdrlen = sizeof (tftph->opcode) + rrqlen;
@ -76,7 +76,7 @@ tftp_open (struct grub_file *file, const char *filename)
return err;
/* Receive OACK packet. */
for ( i = 0; i < 3; i++)
for (i = 0; i < 3; i++)
{
grub_net_poll_cards (100);
if (grub_errno)
@ -86,11 +86,11 @@ tftp_open (struct grub_file *file, const char *filename)
/* Retry. */
/*err = grub_net_send_udp_packet (file->device->net->socket, &nb);
if (err)
return err;*/
return err; */
}
if (file->device->net->socket->status == 0)
return grub_error (GRUB_ERR_TIMEOUT,"Time out opening tftp.");
return grub_error (GRUB_ERR_TIMEOUT, "Time out opening tftp.");
file->size = data->file_size;
return GRUB_ERR_NONE;
@ -114,7 +114,7 @@ tftp_receive (grub_net_socket_t sock, struct grub_net_buff *nb)
switch (grub_be_to_cpu16 (tftph->opcode))
{
case TFTP_OACK:
for (ptr = nb->data + sizeof (tftph->opcode); ptr < nb->tail; )
for (ptr = nb->data + sizeof (tftph->opcode); ptr < nb->tail;)
{
if (grub_memcmp (ptr, "tsize\0", sizeof ("tsize\0") - 1) == 0)
{
@ -127,10 +127,11 @@ tftp_receive (grub_net_socket_t sock, struct grub_net_buff *nb)
}
sock->status = 1;
data->block = 0;
grub_netbuff_clear(nb);
grub_netbuff_clear (nb);
break;
case TFTP_DATA:
grub_netbuff_pull (nb,sizeof (tftph->opcode) + sizeof (tftph->u.data.block));
grub_netbuff_pull (nb, sizeof (tftph->opcode) +
sizeof (tftph->u.data.block));
if (grub_be_to_cpu16 (tftph->u.data.block) == data->block + 1)
{
@ -143,17 +144,18 @@ tftp_receive (grub_net_socket_t sock, struct grub_net_buff *nb)
grub_netbuff_unput (nb, size - 1024);
}
else
grub_netbuff_clear(nb);
grub_netbuff_clear (nb);
break;
case TFTP_ERROR:
grub_netbuff_clear (nb);
return grub_error (GRUB_ERR_IO, (char *)tftph->u.err.errmsg);
return grub_error (GRUB_ERR_IO, (char *) tftph->u.err.errmsg);
break;
}
grub_netbuff_clear (&nb_ack);
grub_netbuff_reserve (&nb_ack,128);
grub_netbuff_push (&nb_ack,sizeof (tftph->opcode) + sizeof (tftph->u.ack.block));
grub_netbuff_reserve (&nb_ack, 128);
grub_netbuff_push (&nb_ack, sizeof (tftph->opcode)
+ sizeof (tftph->u.ack.block));
tftph = (struct tftphdr *) nb_ack.data;
tftph->opcode = grub_cpu_to_be16 (TFTP_ACK);
@ -171,19 +173,19 @@ tftp_close (struct grub_file *file __attribute__ ((unused)))
}
static struct grub_net_app_protocol grub_tftp_protocol =
{
{
.name = "tftp",
.open = tftp_open,
.read = tftp_receive,
.close = tftp_close
};
};
GRUB_MOD_INIT (tftp)
GRUB_MOD_INIT(tftp)
{
grub_net_app_level_register (&grub_tftp_protocol);
}
GRUB_MOD_FINI (tftp)
GRUB_MOD_FINI(tftp)
{
grub_net_app_level_unregister (&grub_tftp_protocol);
}

View file

@ -5,11 +5,12 @@
#include <grub/time.h>
grub_err_t
grub_net_send_udp_packet (const grub_net_socket_t socket , struct grub_net_buff *nb)
grub_net_send_udp_packet (const grub_net_socket_t socket,
struct grub_net_buff *nb)
{
struct udphdr *udph;
grub_netbuff_push (nb,sizeof(*udph));
grub_netbuff_push (nb, sizeof (*udph));
udph = (struct udphdr *) nb->data;
udph->src = grub_cpu_to_be16 (socket->in_port);
@ -30,7 +31,7 @@ grub_net_recv_udp_packet (struct grub_net_buff *nb)
udph = (struct udphdr *) nb->data;
grub_netbuff_pull (nb, sizeof (*udph));
FOR_NET_SOCKETS(sock)
FOR_NET_SOCKETS (sock)
{
if (grub_be_to_cpu16 (udph->dst) == sock->in_port)
{
@ -38,7 +39,7 @@ grub_net_recv_udp_packet (struct grub_net_buff *nb)
sock->out_port = grub_be_to_cpu16 (udph->src);
/* App protocol remove its own reader. */
sock->app->read (sock,nb);
sock->app->read (sock, nb);
/* If there is data, puts packet in socket list. */
if ((nb->tail - nb->data) > 0)