| 91 | } |
| 92 | |
| 93 | CommandResponse ExactMatch::Init(const bess::pb::ExactMatchArg &arg) { |
| 94 | empty_masks_ = arg.masks_size() == 0; |
| 95 | if (arg.fields_size() != arg.masks_size() && !empty_masks_) { |
| 96 | return CommandFailure(EINVAL, |
| 97 | "must provide masks for all fields (or no masks for " |
| 98 | "default match on all bits on all fields)"); |
| 99 | } |
| 100 | |
| 101 | for (auto i = 0; i < arg.fields_size(); ++i) { |
| 102 | CommandResponse err; |
| 103 | |
| 104 | if (empty_masks_) { |
| 105 | bess::pb::FieldData emptymask; |
| 106 | err = AddFieldOne(arg.fields(i), emptymask, i); |
| 107 | } else { |
| 108 | err = AddFieldOne(arg.fields(i), arg.masks(i), i); |
| 109 | } |
| 110 | |
| 111 | if (err.error().code() != 0) { |
| 112 | return err; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | default_gate_ = DROP_GATE; |
| 117 | |
| 118 | return CommandSuccess(); |
| 119 | } |
| 120 | |
| 121 | // Retrieves an ExactMatchArg that would reconstruct this module. |
| 122 | CommandResponse ExactMatch::GetInitialArg(const bess::pb::EmptyArg &) { |
nothing calls this directly
no test coverage detected