MCPcopy Create free account
hub / github.com/NetSys/bess / ProcessArguments

Method ProcessArguments

core/modules/flowgen.cc:183–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183CommandResponse FlowGen::ProcessArguments(const bess::pb::FlowGenArg &arg) {
184 if (arg.template_().length() == 0) {
185 return CommandFailure(EINVAL, "must specify 'template'");
186 }
187
188 if (arg.template_().length() > MAX_TEMPLATE_SIZE) {
189 return CommandFailure(EINVAL, "'template' is too big");
190 }
191
192 template_size_ = arg.template_().length();
193
194 memset(templ_, 0, MAX_TEMPLATE_SIZE);
195 bess::utils::Copy(templ_, arg.template_().c_str(), template_size_);
196 CommandResponse err = UpdateBaseAddresses();
197 if (err.error().code() != 0) {
198 return err;
199 }
200
201 total_pps_ = arg.pps();
202 if (std::isnan(total_pps_) || total_pps_ < 0.0) {
203 return CommandFailure(EINVAL, "invalid 'pps'");
204 }
205
206 flow_rate_ = arg.flow_rate();
207 if (std::isnan(flow_rate_) || flow_rate_ < 0.0) {
208 return CommandFailure(EINVAL, "invalid 'flow_rate'");
209 }
210
211 flow_duration_ = arg.flow_duration();
212 if (std::isnan(flow_duration_) || flow_duration_ < 0.0) {
213 return CommandFailure(EINVAL, "invalid 'flow_duration'");
214 }
215
216 if (arg.arrival() == "uniform") {
217 arrival_ = Arrival::kUniform;
218 } else if (arg.arrival() == "exponential") {
219 arrival_ = Arrival::kExponential;
220 } else {
221 return CommandFailure(
222 EINVAL, "'arrival' must be either 'uniform' or 'exponential'");
223 }
224
225 if (arg.duration() == "uniform") {
226 duration_ = Duration::kUniform;
227 } else if (arg.duration() == "pareto") {
228 duration_ = Duration::kPareto;
229 } else {
230 return CommandFailure(EINVAL,
231 "'duration' must be either 'uniform' or 'pareto'");
232 }
233
234 if (arg.quick_rampup()) {
235 quick_rampup_ = 1;
236 }
237
238 ip_src_range_ = arg.ip_src_range();
239 ip_dst_range_ = arg.ip_dst_range();
240

Callers

nothing calls this directly

Calls 3

CommandFailureFunction · 0.85
CopyFunction · 0.85
CommandSuccessFunction · 0.85

Tested by

no test coverage detected