several cleanups. Ping reply support

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-08 14:41:52 +02:00
parent 6e706342c3
commit 1367c143dd
10 changed files with 263 additions and 88 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/>.
*/
#ifndef GRUB_NET_ARP_HEADER
#define GRUB_NET_ARP_HEADER 1
#include <grub/misc.h>

View file

@ -21,13 +21,15 @@
#include <grub/misc.h>
#include <grub/net.h>
enum
typedef enum grub_net_ip_protocol
{
IP_UDP = 0x11 /* UDP protocol */
};
#define IP_BROADCAST 0xFFFFFFFF
GRUB_NET_IP_ICMP = 1,
GRUB_NET_IP_TCP = 6,
GRUB_NET_IP_UDP = 17
} grub_net_ip_protocol_t;
#define GRUB_NET_IP_BROADCAST 0xFFFFFFFF
grub_uint16_t grub_net_ip_chksum(void *ipv, int len);
grub_uint16_t grub_net_ip_chksum(void *ipv, grub_size_t len);
grub_err_t
grub_net_recv_ip_packets (struct grub_net_buff *nb,
@ -37,6 +39,16 @@ grub_net_recv_ip_packets (struct grub_net_buff *nb,
grub_err_t
grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *target,
struct grub_net_buff *nb);
struct grub_net_buff *nb,
grub_net_ip_protocol_t proto);
grub_err_t
grub_net_recv_icmp_packet (struct grub_net_buff *nb,
struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *src);
grub_err_t
grub_net_recv_udp_packet (struct grub_net_buff *nb,
struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *src);
#endif

View file

@ -11,28 +11,23 @@ struct udphdr
grub_uint16_t chksum;
} __attribute__ ((packed));
struct grub_net_udp_socket;
typedef struct grub_net_udp_socket *grub_net_udp_socket_t;
grub_net_socket_t
grub_net_udp_socket_t
grub_net_udp_open (char *server,
grub_uint16_t out_port,
grub_err_t (*recv_hook) (grub_net_socket_t sock,
grub_err_t (*recv_hook) (grub_net_udp_socket_t sock,
struct grub_net_buff *nb,
void *data),
void *recv_hook_data);
static inline void
grub_net_udp_close (grub_net_socket_t sock)
{
grub_net_socket_unregister (sock);
grub_free (sock);
}
void
grub_net_udp_close (grub_net_udp_socket_t sock);
grub_err_t
grub_net_send_udp_packet (const grub_net_socket_t socket, struct grub_net_buff *nb);
grub_err_t
grub_net_recv_udp_packet (struct grub_net_buff *nb,
struct grub_net_network_level_interface *inf);
grub_net_send_udp_packet (const grub_net_udp_socket_t socket,
struct grub_net_buff *nb);
#endif