1d561d0adSIngo Weinhold /* 2d561d0adSIngo Weinhold * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3d561d0adSIngo Weinhold * All rights reserved. Distributed under the terms of the MIT License. 4d561d0adSIngo Weinhold */ 5d561d0adSIngo Weinhold 6d561d0adSIngo Weinhold #ifndef _BOOT_REMOTE_DISK_H 7d561d0adSIngo Weinhold #define _BOOT_REMOTE_DISK_H 8d561d0adSIngo Weinhold 9d561d0adSIngo Weinhold #include <boot/vfs.h> 10d561d0adSIngo Weinhold #include <boot/net/NetDefs.h> 11d561d0adSIngo Weinhold #include <boot/net/RemoteDiskDefs.h> 12d561d0adSIngo Weinhold 13d561d0adSIngo Weinhold class UDPPacket; 14d561d0adSIngo Weinhold class UDPSocket; 15d561d0adSIngo Weinhold 16d561d0adSIngo Weinhold class RemoteDisk : public Node { 17d561d0adSIngo Weinhold public: 18d561d0adSIngo Weinhold RemoteDisk(); 19d561d0adSIngo Weinhold ~RemoteDisk(); 20d561d0adSIngo Weinhold 21d561d0adSIngo Weinhold status_t Init(ip_addr_t serverAddress, uint16 serverPort, off_t imageSize); 22d561d0adSIngo Weinhold 23d561d0adSIngo Weinhold virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, 24d561d0adSIngo Weinhold size_t bufferSize); 25d561d0adSIngo Weinhold virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, 26d561d0adSIngo Weinhold size_t bufferSize); 27d561d0adSIngo Weinhold 28d561d0adSIngo Weinhold virtual status_t GetName(char *nameBuffer, size_t bufferSize) const; 29d561d0adSIngo Weinhold virtual off_t Size() const; 30d561d0adSIngo Weinhold 31*43792b9eSMarcus Overhagen ip_addr_t ServerIPAddress() const; 32*43792b9eSMarcus Overhagen uint16 ServerPort() const; 33*43792b9eSMarcus Overhagen 34d561d0adSIngo Weinhold static RemoteDisk *FindAnyRemoteDisk(); 35d561d0adSIngo Weinhold 36d561d0adSIngo Weinhold private: 37d561d0adSIngo Weinhold ssize_t _ReadFromPacket(off_t &pos, uint8 *&buffer, size_t &bufferSize); 38d561d0adSIngo Weinhold 39d561d0adSIngo Weinhold static status_t _SendRequest(UDPSocket *socket, ip_addr_t serverAddress, 40d561d0adSIngo Weinhold uint16 serverPort, remote_disk_header *request, size_t size, 41d561d0adSIngo Weinhold uint8 expectedReply, UDPPacket **packet); 42d561d0adSIngo Weinhold status_t _SendRequest(remote_disk_header *request, size_t size, 43d561d0adSIngo Weinhold uint8 expectedReply, UDPPacket **packet); 44d561d0adSIngo Weinhold 45d561d0adSIngo Weinhold private: 46d561d0adSIngo Weinhold ip_addr_t fServerAddress; 47d561d0adSIngo Weinhold uint16 fServerPort; 48d561d0adSIngo Weinhold off_t fImageSize; 49d561d0adSIngo Weinhold uint64 fRequestID; 50d561d0adSIngo Weinhold UDPSocket *fSocket; 51d561d0adSIngo Weinhold UDPPacket *fPacket; 52d561d0adSIngo Weinhold }; 53d561d0adSIngo Weinhold 54d561d0adSIngo Weinhold #endif // _BOOT_REMOTE_DISK_H 55