| 80 | } |
| 81 | |
| 82 | CommandResponse RandomSplit::CommandSetGates( |
| 83 | const bess::pb::RandomSplitCommandSetGatesArg &arg) { |
| 84 | if (arg.gates_size() > MAX_SPLIT_GATES) { |
| 85 | return CommandFailure(EINVAL, "no more than %d gates", MAX_SPLIT_GATES); |
| 86 | } |
| 87 | |
| 88 | for (int i = 0; i < arg.gates_size(); i++) { |
| 89 | if (!is_valid_gate(arg.gates(i))) { |
| 90 | return CommandFailure(EINVAL, "Invalid gate %d", gates_[i]); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | ngates_ = arg.gates_size(); |
| 95 | for (int i = 0; i < ngates_; i++) { |
| 96 | gates_[i] = arg.gates(i); |
| 97 | } |
| 98 | |
| 99 | return CommandSuccess(); |
| 100 | } |
| 101 | |
| 102 | void RandomSplit::ProcessBatch(Context *ctx, bess::PacketBatch *batch) { |
| 103 | if (ngates_ <= 0) { |
nothing calls this directly
no test coverage detected