-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.h
216 lines (164 loc) · 6.69 KB
/
params.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef PARAMS_H
#define PARAMS_H
#include <string>
#include <list>
#include <map>
#include <boost/property_tree/ptree_fwd.hpp>
////////////////////////////////////////////////////////////////////////////////
// Params base class
////////////////////////////////////////////////////////////////////////////////
struct Params {
Params(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
// Payloads
////////////////////////////////////////////////////////////////////////////////
struct PayloadParams : Params {
enum class PayloadType {
RANDOM,
STRING,
FILE,
HTTP_HEADERS
} type;
PayloadParams(boost::property_tree::ptree &ptree);
static PayloadParams* maker(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct PayloadRandomParams : PayloadParams {
static const size_t RANDOM_BUF_SIZE = 1024*1024;
char random_buf[RANDOM_BUF_SIZE];
size_t payload_len;
PayloadRandomParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct PayloadBufAbstractParams : PayloadParams {
char *payload_ptr;
size_t payload_len;
PayloadBufAbstractParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct PayloadStringParams : PayloadBufAbstractParams {
PayloadStringParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct PayloadFileParams : PayloadBufAbstractParams {
PayloadFileParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct PayloadHttpHeadersParams : PayloadBufAbstractParams {
PayloadHttpHeadersParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
// Workers
////////////////////////////////////////////////////////////////////////////////
struct TcpWorkerParams : public Params {
bool initiate_close;
float delay_close;
int tcp_linger; // tcp linger as set via SO_LINGER
TcpWorkerParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpServerWorkerParams : public TcpWorkerParams {
enum class WorkerType {
NONE,
ECHO,
RAW,
HTTP
} type;
TcpServerWorkerParams(boost::property_tree::ptree &ptree);
static TcpServerWorkerParams* maker(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpClientWorkerParams : public TcpWorkerParams {
enum class WorkerType {
NONE,
ECHO,
RAW,
HTTP
} type;
TcpClientWorkerParams(boost::property_tree::ptree &ptree);
static TcpClientWorkerParams* maker(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpServerEchoParams : public TcpServerWorkerParams {
TcpServerEchoParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpClientEchoParams : public TcpClientWorkerParams {
TcpClientEchoParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpServerRawParams : public TcpServerWorkerParams {
std::list<PayloadParams*> payloads;
TcpServerRawParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpClientRawParams : public TcpClientWorkerParams {
std::list<PayloadParams*> payloads;
TcpClientRawParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpServerHttpParams : public TcpServerWorkerParams {
std::list<PayloadParams*> firstline_payloads;
std::list<PayloadParams*> header_payloads;
std::list<PayloadParams*> body_payloads;
TcpServerHttpParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpClientHttpParams : public TcpClientWorkerParams {
std::list<PayloadParams*> firstline_payloads;
std::list<PayloadParams*> header_payloads;
std::list<PayloadParams*> body_payloads;
TcpClientHttpParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
// Factories
////////////////////////////////////////////////////////////////////////////////
struct FactoryParams : public Params {
enum class FactoryType {
NONE,
TCP_SERVER,
TCP_CLIENT
} type;
FactoryParams(boost::property_tree::ptree &ptree);
static FactoryParams* maker(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpFactoryParams : public FactoryParams {
uint32_t bind_addr; // htonl(INADDR_ANY)
uint16_t bind_port; // htons(9999)
uint32_t concurrency;
uint64_t count;
TcpFactoryParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpServerFactoryParams : public TcpFactoryParams {
uint32_t accept_backlog;
TcpServerWorkerParams *worker;
TcpServerFactoryParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
struct TcpClientFactoryParams : public TcpFactoryParams {
uint32_t server_addr; // htonl or inet_addr("1.2.3.4")
uint16_t server_port; // htons(12345)
float connect_timeout; // 5.0
TcpClientWorkerParams *worker;
TcpClientFactoryParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
// Stats
////////////////////////////////////////////////////////////////////////////////
struct StatsParams : Params {
std::string listener;
StatsParams(boost::property_tree::ptree &ptree);
};
////////////////////////////////////////////////////////////////////////////////
// Main flamethrower parameters
////////////////////////////////////////////////////////////////////////////////
struct FlamethrowerParams : public Params{
uint32_t version;
StatsParams *stats;
std::list<FactoryParams*> factories;
FlamethrowerParams(boost::property_tree::ptree &ptree);
};
#endif