-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.h
55 lines (48 loc) · 1.69 KB
/
server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <cstdint>
#include <utility>
#if !defined(TEENSY4_1) && !defined(RP2040W)
#include <atomic>
#include <mutex>
#include <thread>
#endif
#include "com.h"
#include "scsi.h"
#include "session.h"
typedef struct
{
uint64_t iscsiSsnCmdPDUs; // 1.3.6.1.2.1.142.1.10.2.1.1
uint64_t iscsiInstSsnFailures; // 1.3.6.1.2.1.142.1.1.1.1.10
uint64_t iscsiInstSsnFormatErrors; // 1.3.6.1.2.1.142.1.1.2.1.3
uint64_t iscsiInstSsnDigestErrors; // 1.3.6.1.2.1.142.1.1.2.1.1
uint64_t iscsiSsnTxDataOctets; // 1.3.6.1.2.1.142.1.10.2.1.3
uint64_t iscsiSsnRxDataOctets; // 1.3.6.1.2.1.142.1.10.2.1.4
uint64_t iscsiTgtLoginAccepts; // 1.3.6.1.2.1.142.1.6.2.1.1
uint64_t iscsiTgtLogoutNormals; // 1.3.6.1.2.1.142.1.6.3.1.1
} iscsi_stats_t;
class server
{
private:
scsi *const s { nullptr };
com *const c { nullptr };
iscsi_stats_t *const is { nullptr };
const std::string target_name;
const bool digest_chk { false };
#if !defined(ARDUINO) && !defined(NDEBUG)
std::atomic_uint64_t cmd_use_count[64] { };
#endif
#if !defined(TEENSY4_1) && !defined(RP2040W)
std::mutex threads_lock;
std::vector<std::pair<std::thread *, std::atomic_bool *> > threads;
#else
bool active { false };
#endif
std::tuple<iscsi_pdu_bhs *, iscsi_fail_reason, uint64_t>
receive_pdu (com_client *const cc, session **const s);
iscsi_fail_reason push_response(com_client *const cc, session *const s, iscsi_pdu_bhs *const pdu);
public:
server(scsi *const s, com *const c, iscsi_stats_t *is, const std::string & target_name, const bool digest_chk);
virtual ~server();
bool begin();
bool is_active();
void handler();
};