IPv6 support. Several fixes and unifications
This commit is contained in:
parent
96bd62413f
commit
9aad3cd91d
13 changed files with 505 additions and 156 deletions
|
@ -64,7 +64,8 @@ typedef enum
|
|||
GRUB_ERR_BUG,
|
||||
GRUB_ERR_NET_PORT_CLOSED,
|
||||
GRUB_ERR_NET_INVALID_RESPONSE,
|
||||
GRUB_ERR_NET_UNKNOWN_ERROR
|
||||
GRUB_ERR_NET_UNKNOWN_ERROR,
|
||||
GRUB_ERR_NET_PACKET_TOO_BIG
|
||||
}
|
||||
grub_err_t;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ enum
|
|||
GRUB_NET_UDP_HEADER_SIZE = 8,
|
||||
GRUB_NET_TCP_HEADER_SIZE = 20,
|
||||
GRUB_NET_OUR_IPV4_HEADER_SIZE = 20,
|
||||
GRUB_NET_OUR_IPV6_HEADER_SIZE = 40,
|
||||
GRUB_NET_TCP_RESERVE_SIZE = GRUB_NET_TCP_HEADER_SIZE
|
||||
+ GRUB_NET_OUR_IPV4_HEADER_SIZE
|
||||
+ GRUB_NET_MAX_LINK_HEADER_SIZE
|
||||
|
@ -127,7 +128,8 @@ struct grub_net_network_level_interface;
|
|||
typedef enum grub_network_level_protocol_id
|
||||
{
|
||||
GRUB_NET_NETWORK_LEVEL_PROTOCOL_DHCP_RECV,
|
||||
GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
|
||||
GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4,
|
||||
GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6
|
||||
} grub_network_level_protocol_id_t;
|
||||
|
||||
typedef struct grub_net_network_level_address
|
||||
|
@ -136,6 +138,7 @@ typedef struct grub_net_network_level_address
|
|||
union
|
||||
{
|
||||
grub_uint32_t ipv4;
|
||||
grub_uint64_t ipv6[2];
|
||||
};
|
||||
} grub_net_network_level_address_t;
|
||||
|
||||
|
@ -148,6 +151,10 @@ typedef struct grub_net_network_level_netaddress
|
|||
grub_uint32_t base;
|
||||
int masksize;
|
||||
} ipv4;
|
||||
struct {
|
||||
grub_uint64_t base[2];
|
||||
int masksize;
|
||||
} ipv6;
|
||||
};
|
||||
} grub_net_network_level_netaddress_t;
|
||||
|
||||
|
@ -389,13 +396,17 @@ grub_net_process_dhcp (struct grub_net_buff *nb,
|
|||
int
|
||||
grub_net_hwaddr_cmp (const grub_net_link_level_address_t *a,
|
||||
const grub_net_link_level_address_t *b);
|
||||
int
|
||||
grub_net_addr_cmp (const grub_net_network_level_address_t *a,
|
||||
const grub_net_network_level_address_t *b);
|
||||
|
||||
|
||||
/*
|
||||
Currently suppoerted adresses:
|
||||
Currently supported adresses:
|
||||
IPv4: XXX.XXX.XXX.XXX
|
||||
IPv&: XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX
|
||||
*/
|
||||
#define GRUB_NET_MAX_STR_ADDR_LEN sizeof ("XXX.XXX.XXX.XXX")
|
||||
#define GRUB_NET_MAX_STR_ADDR_LEN sizeof ("XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX")
|
||||
|
||||
void
|
||||
grub_net_addr_to_str (const grub_net_network_level_address_t *target,
|
||||
|
@ -428,4 +439,7 @@ grub_net_tcp_retransmit (void);
|
|||
|
||||
extern char *grub_net_default_server;
|
||||
|
||||
#define GRUB_NET_TRIES 40
|
||||
#define GRUB_NET_INTERVAL 400
|
||||
|
||||
#endif /* ! GRUB_NET_HEADER */
|
||||
|
|
|
@ -21,30 +21,6 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/net.h>
|
||||
|
||||
enum
|
||||
{
|
||||
/* IANA ARP constant to define hardware type as ethernet. */
|
||||
GRUB_NET_ARPHRD_ETHERNET = 1
|
||||
};
|
||||
|
||||
/* ARP header operation codes */
|
||||
#define ARP_REQUEST 1
|
||||
#define ARP_REPLY 2
|
||||
|
||||
struct arp_entry {
|
||||
int avail;
|
||||
grub_net_network_level_address_t nl_address;
|
||||
grub_net_link_level_address_t ll_address;
|
||||
};
|
||||
|
||||
struct arphdr {
|
||||
grub_uint16_t hrd;
|
||||
grub_uint16_t pro;
|
||||
grub_uint8_t hln;
|
||||
grub_uint8_t pln;
|
||||
grub_uint16_t op;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
extern grub_err_t grub_net_arp_receive(struct grub_net_buff *nb);
|
||||
|
||||
extern grub_err_t grub_net_arp_resolve(struct grub_net_network_level_interface *inf,
|
||||
|
|
|
@ -22,17 +22,18 @@
|
|||
#include <grub/net.h>
|
||||
|
||||
/* IANA Ethertype */
|
||||
enum
|
||||
{
|
||||
GRUB_NET_ETHERTYPE_IP = 0x0800,
|
||||
GRUB_NET_ETHERTYPE_ARP = 0x0806
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
GRUB_NET_ETHERTYPE_IP = 0x0800,
|
||||
GRUB_NET_ETHERTYPE_ARP = 0x0806,
|
||||
GRUB_NET_ETHERTYPE_IP6 = 0x86DD,
|
||||
} grub_net_ethertype_t;
|
||||
|
||||
grub_err_t
|
||||
send_ethernet_packet (struct grub_net_network_level_interface *inf,
|
||||
struct grub_net_buff *nb,
|
||||
grub_net_link_level_address_t target_addr,
|
||||
grub_uint16_t ethertype);
|
||||
grub_net_ethertype_t ethertype);
|
||||
grub_err_t
|
||||
grub_net_recv_ethernet_packet (struct grub_net_buff *nb,
|
||||
const struct grub_net_card *card);
|
||||
|
|
|
@ -32,9 +32,13 @@ typedef enum grub_net_ip_protocol
|
|||
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,
|
||||
const struct grub_net_card *card,
|
||||
const grub_net_link_level_address_t *hwaddress);
|
||||
grub_net_recv_ip4_packets (struct grub_net_buff *nb,
|
||||
const struct grub_net_card *card,
|
||||
const grub_net_link_level_address_t *hwaddress);
|
||||
grub_err_t
|
||||
grub_net_recv_ip6_packets (struct grub_net_buff *nb,
|
||||
const struct grub_net_card *card,
|
||||
const grub_net_link_level_address_t *hwaddress);
|
||||
|
||||
grub_err_t
|
||||
grub_net_send_ip_packet (struct grub_net_network_level_interface *inf,
|
||||
|
|
|
@ -98,13 +98,15 @@ typedef grub_uint64_t grub_size_t;
|
|||
typedef grub_int64_t grub_ssize_t;
|
||||
|
||||
# if GRUB_CPU_SIZEOF_LONG == 8
|
||||
# define PRIxGRUB_SIZE "lx"
|
||||
# define PRIxGRUB_ADDR "lx"
|
||||
# define PRIuGRUB_SIZE "lu"
|
||||
# define PRIxGRUB_SIZE "lx"
|
||||
# define PRIxGRUB_ADDR "lx"
|
||||
# define PRIuGRUB_SIZE "lu"
|
||||
# define PRIdGRUB_SSIZE "ld"
|
||||
# else
|
||||
# define PRIxGRUB_SIZE "llx"
|
||||
# define PRIxGRUB_ADDR "llx"
|
||||
# define PRIuGRUB_SIZE "llu"
|
||||
# define PRIxGRUB_SIZE "llx"
|
||||
# define PRIxGRUB_ADDR "llx"
|
||||
# define PRIuGRUB_SIZE "llu"
|
||||
# define PRIdGRUB_SSIZE "lld"
|
||||
# endif
|
||||
#else
|
||||
typedef grub_uint32_t grub_addr_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue