Send TFTP_ERROR on tftp premature close. Several cleanups

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-06 12:53:37 +02:00
parent 72b9ad936a
commit b975df6348
10 changed files with 262 additions and 153 deletions

View file

@ -1,3 +1,21 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/net/ip.h>
#include <grub/misc.h>
#include <grub/net/arp.h>
@ -7,8 +25,32 @@
#include <grub/net/netbuff.h>
#include <grub/mm.h>
struct iphdr {
grub_uint8_t verhdrlen;
grub_uint8_t service;
grub_uint16_t len;
grub_uint16_t ident;
grub_uint16_t frags;
grub_uint8_t ttl;
grub_uint8_t protocol;
grub_uint16_t chksum;
grub_uint32_t src;
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));
grub_uint16_t
ipchksum (void *ipv, int len)
grub_net_ip_chksum (void *ipv, int len)
{
grub_uint16_t *ip = (grub_uint16_t *) ipv;
grub_uint32_t sum = 0;
@ -48,7 +90,7 @@ grub_net_send_ip_packet (struct grub_net_network_level_interface * inf,
iph->dest = target->ipv4;
iph->chksum = 0;
iph->chksum = ipchksum ((void *) nb->data, sizeof (*iph));
iph->chksum = grub_net_ip_chksum ((void *) nb->data, sizeof (*iph));
/* Determine link layer target address via ARP. */
err = grub_net_arp_resolve (inf, target, &ll_target_addr);