10e478f5aSAxel Dörfler/*
2c9dd7d0dSRene Gollent * Copyright 2011-2016, Haiku, Inc. All Rights Reserved.
30e478f5aSAxel Dörfler * Distributed under the terms of the MIT License.
40e478f5aSAxel Dörfler */
50e478f5aSAxel Dörfler#ifndef _SECURE_SOCKET_H
60e478f5aSAxel Dörfler#define _SECURE_SOCKET_H
70e478f5aSAxel Dörfler
80e478f5aSAxel Dörfler
90e478f5aSAxel Dörfler#include <Socket.h>
100e478f5aSAxel Dörfler
110e478f5aSAxel Dörfler
125ebdc799SAdrien Destuguesclass BCertificate;
135ebdc799SAdrien Destugues
145ebdc799SAdrien Destugues
150e478f5aSAxel Dörflerclass BSecureSocket : public BSocket {
160e478f5aSAxel Dörflerpublic:
170e478f5aSAxel Dörfler								BSecureSocket();
180e478f5aSAxel Dörfler								BSecureSocket(const BNetworkAddress& peer,
190e478f5aSAxel Dörfler									bigtime_t timeout = B_INFINITE_TIMEOUT);
200e478f5aSAxel Dörfler								BSecureSocket(const BSecureSocket& other);
210e478f5aSAxel Dörfler	virtual						~BSecureSocket();
220e478f5aSAxel Dörfler
23d10ecc2cSJulian Harnath	virtual bool				CertificateVerificationFailed(BCertificate&
24c86ad7f9SAdrien Destugues									certificate, const char* message);
255ebdc799SAdrien Destugues
26c6149613SAdrien Destugues			status_t			InitCheck();
27c6149613SAdrien Destugues
285ebdc799SAdrien Destugues	// BSocket implementation
295ebdc799SAdrien Destugues
30c9dd7d0dSRene Gollent	virtual	status_t			Accept(BAbstractSocket*& _socket);
31c9dd7d0dSRene Gollent
320e478f5aSAxel Dörfler	virtual	status_t			Connect(const BNetworkAddress& peer,
330e478f5aSAxel Dörfler									bigtime_t timeout = B_INFINITE_TIMEOUT);
340e478f5aSAxel Dörfler	virtual	void				Disconnect();
350e478f5aSAxel Dörfler
360e478f5aSAxel Dörfler	virtual	status_t			WaitForReadable(bigtime_t timeout
370e478f5aSAxel Dörfler										= B_INFINITE_TIMEOUT) const;
380e478f5aSAxel Dörfler
390e478f5aSAxel Dörfler	// BDataIO implementation
400e478f5aSAxel Dörfler
410e478f5aSAxel Dörfler	virtual ssize_t				Read(void* buffer, size_t size);
420e478f5aSAxel Dörfler	virtual ssize_t				Write(const void* buffer, size_t size);
430e478f5aSAxel Dörfler
44c6149613SAdrien Destuguesprotected:
45e1c98ceaSMark Hellegers			status_t			_SetupCommon(const char* host = NULL);
46e1c98ceaSMark Hellegers			status_t			_SetupConnect(const char* host = NULL);
47c9dd7d0dSRene Gollent			status_t			_SetupAccept();
48c6149613SAdrien Destugues
490e478f5aSAxel Dörflerprivate:
505ebdc799SAdrien Destugues	friend class BCertificate;
510e478f5aSAxel Dörfler			class Private;
520e478f5aSAxel Dörfler			Private*			fPrivate;
530e478f5aSAxel Dörfler};
540e478f5aSAxel Dörfler
550e478f5aSAxel Dörfler
560e478f5aSAxel Dörfler#endif	// _SECURE_SOCKET_H
57