| 44 | MODULE_CMD_FUNC(&RandomSplit::CommandSetGates), Command::THREAD_UNSAFE}}; |
| 45 | |
| 46 | CommandResponse 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 | |
| 71 | CommandResponse RandomSplit::CommandSetDroprate( |
| 72 | const bess::pb::RandomSplitCommandSetDroprateArg &arg) { |
nothing calls this directly
no test coverage detected