d561d0ad68
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
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
/*
|
|
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
|
* All rights reserved. Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
#ifndef _BOOT_REMOTE_DISK_H
|
|
#define _BOOT_REMOTE_DISK_H
|
|
|
|
#include <boot/vfs.h>
|
|
#include <boot/net/NetDefs.h>
|
|
#include <boot/net/RemoteDiskDefs.h>
|
|
|
|
class UDPPacket;
|
|
class UDPSocket;
|
|
|
|
class RemoteDisk : public Node {
|
|
public:
|
|
RemoteDisk();
|
|
~RemoteDisk();
|
|
|
|
status_t Init(ip_addr_t serverAddress, uint16 serverPort, off_t imageSize);
|
|
|
|
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
|
|
size_t bufferSize);
|
|
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
|
|
size_t bufferSize);
|
|
|
|
virtual status_t GetName(char *nameBuffer, size_t bufferSize) const;
|
|
virtual off_t Size() const;
|
|
|
|
static RemoteDisk *FindAnyRemoteDisk();
|
|
|
|
private:
|
|
ssize_t _ReadFromPacket(off_t &pos, uint8 *&buffer, size_t &bufferSize);
|
|
|
|
static status_t _SendRequest(UDPSocket *socket, ip_addr_t serverAddress,
|
|
uint16 serverPort, remote_disk_header *request, size_t size,
|
|
uint8 expectedReply, UDPPacket **packet);
|
|
status_t _SendRequest(remote_disk_header *request, size_t size,
|
|
uint8 expectedReply, UDPPacket **packet);
|
|
|
|
private:
|
|
ip_addr_t fServerAddress;
|
|
uint16 fServerPort;
|
|
off_t fImageSize;
|
|
uint64 fRequestID;
|
|
UDPSocket *fSocket;
|
|
UDPPacket *fPacket;
|
|
};
|
|
|
|
#endif // _BOOT_REMOTE_DISK_H
|