NetBurner 3.5.8
PDF Version
Toggle main menu visibility
SslSocket.h
1
/*NB_REVISION*/
2
3
/*NB_COPYRIGHT*/
4
5
#ifndef _SSL_SOCKET_H_
6
#define _SSL_SOCKET_H_
7
8
#ifdef NB_SSL_SUPPORTED
9
10
#include <buffers.h>
11
#include <netinterface.h>
12
13
#include <crypto/wolfssl/ssl.h>
14
#include <crypto/NetBurner/CryptoSocket.h>
15
#include <crypto/ssl.h>
16
17
// Time stuff
18
#define SHUTDOWN_RETRY_INTERVAL_IMMEDIATE \
19
(1)
// Because of our asynchronous connections, we will generally have to try at least twice to completely
20
// shutdown with WolfSSL. However, the time between these calls can be extremely short.
21
#define SHUTDOWN_RETRY_INTERVAL (TICKS_PER_SECOND)
22
#define CONNECT_RETRY_INTERVAL (TICKS_PER_SECOND)
23
24
class
SslSocket :
public
CryptoSocket
25
{
26
public
:
27
SslSocket();
28
~SslSocket();
29
30
uint16_t InitSocket(
int
tcpFd, WOLFSSL_CTX *ctx,
const
char
*commonName, uint32_t sockFlags = 0,
int
verifyPeer = -1);
31
32
void
CleanupTcpClose();
33
34
// Called from wolf ssl loop mostly to handle notifications and
35
// time out stuff for all async process except read
36
void
ProcessAsyncStuff()
override
;
37
int
CheckSocketRecv()
override
;
38
uint32_t SocketRead(
char
*buf, uint32_t len)
override
;
39
uint32_t SocketWrite(
const
char
*buf, uint32_t len)
override
;
40
SocketHasData_t SocketHasData()
override
;
41
42
// Need to add a GetNewSocket() for each derived type
43
static
SslSocket *GetNewSocket(
int
tcpFd, WOLFSSL_CTX *ctx,
const
char
*commonName, uint32_t sockFlags = 0,
int
verifyPeer = -1);
44
45
inline
WOLFSSL *GetWolfSsl() {
return
(WOLFSSL *)m_wolfCtx; }
46
47
static
bool
SocketsAvail();
48
static
int
FreeSockets();
49
50
private
:
51
int
ticketLen;
52
53
void
WriteUnwrittenData()
override
;
54
virtual
bool
PendOnHandshake() {
return
(m_error ==
SSL_ERROR_HANDSHAKE_INCOMPLETE
); }
55
56
static
int
DoTicketCallback(WOLFSSL *ssl,
const
unsigned
char
*ticket,
int
ticketLen,
void
* pvSock);
57
58
static
SslSocket *FindNextEmptySocket();
59
static
SslSocket gSslSockets[];
60
static
Pool gSslSocketPool;
61
friend
void
SSL_DumpSSLSockets
();
62
friend
void
SSL_dumpJSONSockets(
int
fd);
63
public
:
64
inline
static
const
Pool *GetSocketPool() {
return
&gSslSocketPool; }
65
};
66
67
//extern SslSocket gSslSockets[];
68
69
#endif
/* NB_SSL_SUPPORTED */
70
#endif
SSL_DumpSSLSockets
void SSL_DumpSSLSockets()
Prints the current state of all used sockets to stdio.
SSL_ERROR_HANDSHAKE_INCOMPLETE
#define SSL_ERROR_HANDSHAKE_INCOMPLETE
The SSL handshake is not complete yet.
Definition
ssl.h:66
libraries
include
crypto
NetBurner
SslSocket.h
Generated by
1.18.0