NetBurner 3.5.6
PDF Version
SshSocket.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef _NB_SSH_SOCKET_H_
6#define _NB_SSH_SOCKET_H_
7
8#include <predef.h>
9
10#ifdef NB_SSH_SUPPORTED
11#include <nbrtos.h>
12
13#include <crypto/NetBurner/CryptoSocket.h>
14#include <crypto/wolfssl/wolfcrypt/sha256.h>
15#include <crypto/wolfssl/wolfcrypt/coding.h>
16#include <ssh/wolfssh/ssh.h>
17
18class SshSocket : public CryptoSocket
19{
20 public:
21 SshSocket();
22 ~SshSocket();
23
24 int InitSocket(int tcpFd, WOLFSSH_CTX *ctx, int sockFlags = 0);
25
26 void CleanupTcpClose();
27
28 // Called from wolf ssl loop mostly to handle notifications and
29 // time out stuff for all async process except read
30 void ProcessAsyncStuff() override;
31 int CheckSocketRecv() override;
32 uint32_t SocketRead(char *buf, uint32_t len) override;
33 uint32_t SocketWrite(const char *buf, uint32_t len) override;
34 SocketHasData_t SocketHasData() override;
35
36 // Need to add a GetNewSocket() for each derived type
37 static SshSocket *GetNewSocket(int tcpFd, WOLFSSH_CTX *ctx, int sockFlags = 0);
38
39 WOLFSSH *GetWolfSsh() { return (WOLFSSH *)m_wolfCtx; }
40
41 private:
42 static SshSocket *FindNextEmptySocket();
43 void WriteUnwrittenData() override;
44
45 static SshSocket gSshSockets[];
46 static Pool gSshSocketPool;
47 public:
48 inline static const Pool *GetSocketPool() { return &gSshSocketPool; }
49};
50
51#endif // NB_SSH_SUPPORTED
52#endif // _NB_SSH_SOCKET_H_