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

Method Init

core/modules/random_split.cc:46–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 MODULE_CMD_FUNC(&RandomSplit::CommandSetGates), Command::THREAD_UNSAFE}};
45
46CommandResponse RandomSplit::Init(const bess::pb::RandomSplitArg &arg) {
47 double drop_rate = arg.drop_rate();
48 if (drop_rate < 0 || drop_rate > 1) {
49 return CommandFailure(EINVAL, "drop rate needs to be between [0, 1]");
50 }
51 drop_rate_ = drop_rate;
52
53 if (arg.gates_size() > MAX_SPLIT_GATES) {
54 return CommandFailure(EINVAL, "no more than %d gates", MAX_SPLIT_GATES);
55 }
56
57 for (int i = 0; i < arg.gates_size(); i++) {
58 if (!is_valid_gate(arg.gates(i))) {
59 return CommandFailure(EINVAL, "Invalid gate %d", gates_[i]);
60 }
61 }
62
63 ngates_ = arg.gates_size();
64 for (int i = 0; i < ngates_; i++) {
65 gates_[i] = arg.gates(i);
66 }
67
68 return CommandSuccess();
69}
70
71CommandResponse RandomSplit::CommandSetDroprate(
72 const bess::pb::RandomSplitCommandSetDroprateArg &arg) {

Callers

nothing calls this directly

Calls 3

CommandFailureFunction · 0.85
CommandSuccessFunction · 0.85
is_valid_gateFunction · 0.70

Tested by

no test coverage detected