basic tcp implementation

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-10 08:46:48 +02:00
parent 92bb3cfc17
commit 3a7af37260
12 changed files with 802 additions and 27 deletions

View file

@ -59,6 +59,7 @@ typedef enum
GRUB_ERR_NET_BAD_ADDRESS,
GRUB_ERR_NET_ROUTE_LOOP,
GRUB_ERR_NET_NO_ROUTE,
GRUB_ERR_NET_NO_ANSWER,
GRUB_ERR_WAIT,
GRUB_ERR_BUG
}

View file

@ -415,6 +415,9 @@ grub_net_network_level_interface_unregister (struct grub_net_network_level_inter
inter->prev = 0;
}
void
grub_net_tcp_retransmit (void);
extern char *grub_net_default_server;
#endif /* ! GRUB_NET_HEADER */

View file

@ -50,5 +50,15 @@ 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);
grub_err_t
grub_net_recv_tcp_packet (struct grub_net_buff *nb,
struct grub_net_network_level_interface *inf,
const grub_net_network_level_address_t *source);
grub_uint16_t
grub_net_ip_transport_checksum (struct grub_net_buff *nb,
grub_uint16_t proto,
const grub_net_network_level_address_t *src,
const grub_net_network_level_address_t *dst);
#endif

44
include/grub/net/tcp.h Normal file
View file

@ -0,0 +1,44 @@
/*
* 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_TCP_HEADER
#define GRUB_NET_TCP_HEADER 1
#include <grub/types.h>
#include <grub/net.h>
struct grub_net_tcp_socket;
typedef struct grub_net_tcp_socket *grub_net_tcp_socket_t;
grub_net_tcp_socket_t
grub_net_tcp_open (char *server,
grub_uint16_t out_port,
grub_err_t (*recv_hook) (grub_net_tcp_socket_t sock,
struct grub_net_buff *nb,
void *data),
void (*error_hook) (grub_net_tcp_socket_t sock,
void *data),
void *hook_data);
grub_err_t
grub_net_send_tcp_packet (const grub_net_tcp_socket_t socket,
struct grub_net_buff *nb);
void
grub_net_tcp_close (grub_net_tcp_socket_t sock);
#endif

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_UDP_HEADER
#define GRUB_NET_UDP_HEADER 1
#include <grub/types.h>