xref: /haiku/src/system/boot/platform/pxe_ia32/network.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 #ifndef _PXE_NETWORK_H
2 #define _PXE_NETWORK_H
3 /*
4  * Copyright 2006, Marcus Overhagen <marcus@overhagen.de. All rights reserved.
5  * Copyright 2005-2007, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
6  * Distributed under the terms of the MIT License.
7  */
8 
9 #include <OS.h>
10 #include <boot/net/Ethernet.h>
11 #include <boot/net/NetStack.h>
12 
13 struct PXE_STRUCT;
14 
15 
16 class PXEService {
17 protected:
18 								PXEService();
19 								~PXEService();
20 
21 			status_t			Init();
22 
23 public:
24 			mac_addr_t			MACAddress() const		{ return fMACAddress; }
25 			ip_addr_t			IPAddress() const		{ return fClientIP; }
26 			ip_addr_t			ServerIPAddress() const	{ return fServerIP; }
27 			const char*			RootPath() const		{ return fRootPath; }
28 
29 protected:
30 			PXE_STRUCT*			fPxeData;
31 			ip_addr_t			fClientIP;
32 			ip_addr_t			fServerIP;
33 			mac_addr_t			fMACAddress;
34 			char*				fRootPath;
35 };
36 
37 
38 class UNDI : public EthernetInterface, public PXEService
39 {
40 public:
41 						UNDI();
42 	virtual 			~UNDI();
43 
44 	status_t 			Init();
45 
46 	virtual mac_addr_t	MACAddress() const;
47 
48 	virtual	void *		AllocateSendReceiveBuffer(size_t size);
49 	virtual	void 		FreeSendReceiveBuffer(void *buffer);
50 
51 	virtual ssize_t		Send(const void *buffer, size_t size);
52 	virtual ssize_t		Receive(void *buffer, size_t size);
53 
54 private:
55 	bool				fRxFinished;
56 	PXE_STRUCT *		fPxeData;
57 };
58 
59 
60 class TFTP : public PXEService {
61 public:
62 								TFTP();
63 								~TFTP();
64 
65 			status_t			Init();
66 
67 			uint16				ServerPort() const;
68 
69 			status_t			ReceiveFile(const char* fileName,
70 									uint8** data, size_t* size);
71 
72 private:
73 			status_t			_Close();
74 };
75 
76 #endif
77