-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayload.h
104 lines (82 loc) · 3.16 KB
/
payload.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <list>
#include "common.h"
class TcpWorker;
class Payload;
////////////////////////////////////////////////////////////////////////////////
// Collection of Payloads
////////////////////////////////////////////////////////////////////////////////
class PayloadList {
private:
TcpWorker &worker;
std::list<Payload*> payloads;
public:
PayloadList(TcpWorker &worker, std::list<PayloadParams*> ¶mslist);
virtual ~PayloadList();
char* peek(size_t maxlen, size_t &len);
size_t advance(size_t len);
};
////////////////////////////////////////////////////////////////////////////////
// Base class Payload
////////////////////////////////////////////////////////////////////////////////
class Payload {
public:
TcpWorker &worker;
PayloadParams ¶ms;
Payload(TcpWorker &worker, PayloadParams ¶ms);
virtual ~Payload();
static Payload* maker(TcpWorker &worker, PayloadParams ¶ms);
virtual char* peek(size_t maxlen, size_t &len) = 0;
virtual size_t advance(size_t len) = 0;
};
////////////////////////////////////////////////////////////////////////////////
// Random data payload
////////////////////////////////////////////////////////////////////////////////
class PayloadRandom : public Payload {
public:
PayloadRandomParams ¶ms;
size_t remaining;
PayloadRandom(TcpWorker &worker, PayloadRandomParams ¶ms);
virtual ~PayloadRandom();
virtual char* peek(size_t maxlen, size_t &len);
virtual size_t advance(size_t len);
};
////////////////////////////////////////////////////////////////////////////////
// Pre allocated buffer based abstract class
////////////////////////////////////////////////////////////////////////////////
class PayloadBufAbstract : public Payload {
public:
PayloadBufAbstractParams ¶ms;
char *payload_ptr;
size_t remaining;
PayloadBufAbstract(TcpWorker &worker, PayloadBufAbstractParams ¶ms);
virtual ~PayloadBufAbstract();
virtual char* peek(size_t maxlen, size_t &len);
virtual size_t advance(size_t len);
};
////////////////////////////////////////////////////////////////////////////////
// String based payload
////////////////////////////////////////////////////////////////////////////////
class PayloadString : public PayloadBufAbstract {
public:
PayloadStringParams ¶ms;
PayloadString(TcpWorker &worker, PayloadStringParams ¶ms);
virtual ~PayloadString();
};
////////////////////////////////////////////////////////////////////////////////
// File based payload
////////////////////////////////////////////////////////////////////////////////
class PayloadFile : public PayloadBufAbstract {
public:
PayloadFileParams ¶ms;
PayloadFile(TcpWorker &worker, PayloadFileParams ¶ms);
virtual ~PayloadFile();
};
////////////////////////////////////////////////////////////////////////////////
// HttpHeaders based payload
////////////////////////////////////////////////////////////////////////////////
class PayloadHttpHeaders : public PayloadBufAbstract {
public:
PayloadHttpHeadersParams ¶ms;
PayloadHttpHeaders(TcpWorker &worker, PayloadHttpHeadersParams ¶ms);
virtual ~PayloadHttpHeaders();
};