mirror of
https://git.proxmox.com/git/grub2
synced 2025-05-21 09:11:23 +00:00

* include/grub/net/arp.h: added arp header, arp cache entry and related constants and functions * net/arp.c: added functions arp_init_table, arp_find_entry, arp_resolve and arp_receive * net/ethernet.c (send_ethernet_packet): replaced hardcoded hardware address by parameter target_addr * net/ethernet.c (recv_ethernet_packet): added call to arp_receive when packet is of type 0x803 (ARP) and only return when packet is of type determined by parameter ethertype * net/ip.c (send_ip_packet): added call to arp_resolve to determine hardware address of destination * net/netbuff.c (grub_netbuff_alloc): fixed swapped parameters in call to grub_memalign
43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#ifndef GRUB_NET_ARP_HEADER
|
|
#define GRUB_NET_ARP_HEADER 1
|
|
#include <grub/misc.h>
|
|
#include <grub/net.h>
|
|
#include <grub/net/protocol.h>
|
|
|
|
/* IANA ARP constant to define hardware type as ethernet */
|
|
#define ARPHRD_ETHERNET 1
|
|
/* IANA Ethertype */
|
|
#define ARP_ETHERTYPE 0x806
|
|
|
|
/* Size for cache table */
|
|
#define SIZE_ARP_TABLE 5
|
|
|
|
/* ARP header operation codes */
|
|
#define ARP_REQUEST 1
|
|
#define ARP_REPLY 2
|
|
|
|
struct arp_entry {
|
|
grub_uint8_t avail;
|
|
struct grub_net_network_layer_protocol *nl_protocol;
|
|
struct grub_net_link_layer_protocol *ll_protocol;
|
|
struct grub_net_addr nl_address;
|
|
struct grub_net_addr 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 arp_receive(struct grub_net_network_layer_interface *inf __attribute__ ((unused)),
|
|
struct grub_net_network_link_interface *net_link_inf, struct grub_net_buff *nb);
|
|
|
|
extern grub_err_t arp_resolve(struct grub_net_network_layer_interface *inf __attribute__ ((unused)),
|
|
struct grub_net_network_link_interface *net_link_inf, struct grub_net_addr *proto_addr,
|
|
struct grub_net_addr *hw_addr);
|
|
|
|
#endif
|