haiku/headers/private/kernel/boot/net/ARP.h
Ingo Weinhold d561d0ad68 Added a mini networking stack to the boot loader. It speaks basic ARP,
IP, and UDP, as well as a home brewn UDP based protocol, "remote disk",
which provides random access to a single remote file/device. The Open
Firmware flavored boot loader automatically initializes the net stack,
searches for a remote disk, and tries to boot from it, if the boot
device is a network device (e.g. when loading the boot loader via
TFTP).

This is quite nice for developing with a two-machine setup, since one
doesn't even need to install Haiku on the test machine anymore, but can
serve it directly from the development machine. When the networking
support in the kernel is working, this method could even be used to
fully boot, not just for loading kernel and initial modules.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15689 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-27 22:01:33 +00:00

50 lines
1.1 KiB
C++

/*
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _BOOT_ARP_H
#define _BOOT_ARP_H
#include <boot/net/Ethernet.h>
#include <OS.h>
class ARPService : public EthernetSubService {
// actually ARP for IP over ethernet
public:
ARPService(EthernetService *ethernet);
virtual ~ARPService();
status_t Init();
virtual uint16 EthernetProtocol() const;
virtual void HandleEthernetPacket(EthernetService *ethernet,
const mac_addr_t &targetAddress, const void *data, size_t size);
status_t GetMACForIP(ip_addr_t ip, mac_addr_t &mac);
private:
enum { MAP_ENTRY_COUNT = 10 };
enum { ARP_REQUEST_RETRY_COUNT = 3 };
enum { ARP_REPLY_TIMEOUT = 5000 };
struct MapEntry {
int32 age;
ip_addr_t ip;
mac_addr_t mac;
};
status_t _SendARPPacket(ip_addr_t ip, const mac_addr_t &mac, uint16 opcode);
MapEntry *_FindEntry(ip_addr_t ip);
void _PutEntry(ip_addr_t ip, const mac_addr_t &mac);
EthernetService *fEthernet;
int32 fAge;
MapEntry fEntries[MAP_ENTRY_COUNT];
};
#endif // _BOOT_ARP_H