xref: /haiku/src/add-ons/kernel/file_systems/netfs/headers/shared/InsecureConnection.h (revision 5a1d355fdf2747f80f8c46e2539f844a0b813346)
1*5a1d355fSStephan Aßmus // InsecureConnection.h
2*5a1d355fSStephan Aßmus 
3*5a1d355fSStephan Aßmus #ifndef NET_FS_INSECURE_CONNECTION_H
4*5a1d355fSStephan Aßmus #define NET_FS_INSECURE_CONNECTION_H
5*5a1d355fSStephan Aßmus 
6*5a1d355fSStephan Aßmus #ifdef HAIKU_TARGET_PLATFORM_BEOS
7*5a1d355fSStephan Aßmus #	include <socket.h>
8*5a1d355fSStephan Aßmus #else
9*5a1d355fSStephan Aßmus #	include <netinet/in.h>
10*5a1d355fSStephan Aßmus #	include <sys/socket.h>
11*5a1d355fSStephan Aßmus #endif
12*5a1d355fSStephan Aßmus 
13*5a1d355fSStephan Aßmus #include "AbstractConnection.h"
14*5a1d355fSStephan Aßmus 
15*5a1d355fSStephan Aßmus // InsecureConnection
16*5a1d355fSStephan Aßmus class InsecureConnection : public AbstractConnection {
17*5a1d355fSStephan Aßmus public:
18*5a1d355fSStephan Aßmus 								InsecureConnection();
19*5a1d355fSStephan Aßmus 	virtual						~InsecureConnection();
20*5a1d355fSStephan Aßmus 
21*5a1d355fSStephan Aßmus 			status_t			Init(int socket);				// server side
22*5a1d355fSStephan Aßmus 	virtual	status_t			Init(const char* parameters);	// client side
23*5a1d355fSStephan Aßmus 
24*5a1d355fSStephan Aßmus 			status_t			FinishInitialization();
25*5a1d355fSStephan Aßmus 
26*5a1d355fSStephan Aßmus private:
27*5a1d355fSStephan Aßmus 			status_t			_OpenClientChannel(in_addr serverAddr,
28*5a1d355fSStephan Aßmus 									uint16 port, Channel** channel);
29*5a1d355fSStephan Aßmus 
30*5a1d355fSStephan Aßmus 			status_t			_SendErrorReply(Channel* channel,
31*5a1d355fSStephan Aßmus 									status_t error);
32*5a1d355fSStephan Aßmus };
33*5a1d355fSStephan Aßmus 
34*5a1d355fSStephan Aßmus // InsecureConnectionDefs
35*5a1d355fSStephan Aßmus namespace InsecureConnectionDefs {
36*5a1d355fSStephan Aßmus 
37*5a1d355fSStephan Aßmus 	// ConnectRequest
38*5a1d355fSStephan Aßmus 	struct ConnectRequest {
39*5a1d355fSStephan Aßmus 		int32	protocolVersion;
40*5a1d355fSStephan Aßmus 		uint32	serverAddress;
41*5a1d355fSStephan Aßmus 		int32	upStreamChannels;
42*5a1d355fSStephan Aßmus 		int32	downStreamChannels;
43*5a1d355fSStephan Aßmus 	};
44*5a1d355fSStephan Aßmus 
45*5a1d355fSStephan Aßmus 	// ConnectReply
46*5a1d355fSStephan Aßmus 	struct ConnectReply {
47*5a1d355fSStephan Aßmus 		int32	error;
48*5a1d355fSStephan Aßmus 		int32	upStreamChannels;
49*5a1d355fSStephan Aßmus 		int32	downStreamChannels;
50*5a1d355fSStephan Aßmus 		uint16	port;
51*5a1d355fSStephan Aßmus 	};
52*5a1d355fSStephan Aßmus 
53*5a1d355fSStephan Aßmus 	extern const int32 kProtocolVersion;
54*5a1d355fSStephan Aßmus 	extern const bigtime_t kAcceptingTimeout;
55*5a1d355fSStephan Aßmus 
56*5a1d355fSStephan Aßmus 	// number of client up/down stream channels
57*5a1d355fSStephan Aßmus 	extern const int32 kMinUpStreamChannels;
58*5a1d355fSStephan Aßmus 	extern const int32 kMaxUpStreamChannels;
59*5a1d355fSStephan Aßmus 	extern const int32 kDefaultUpStreamChannels;
60*5a1d355fSStephan Aßmus 	extern const int32 kMinDownStreamChannels;
61*5a1d355fSStephan Aßmus 	extern const int32 kMaxDownStreamChannels;
62*5a1d355fSStephan Aßmus 	extern const int32 kDefaultDownStreamChannels;
63*5a1d355fSStephan Aßmus 
64*5a1d355fSStephan Aßmus } // namespace InsecureConnectionDefs
65*5a1d355fSStephan Aßmus 
66*5a1d355fSStephan Aßmus #endif	// NET_FS_INSECURE_CONNECTION_H
67