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

Method Init

core/modules/generic_encap.cc:104–126  ·  view source on GitHub ↗

Takes a list of fields. Each field is either: * * 1. {'size': X, 'value': Y} (for constant values) * 2. {'size': X, 'attribute': Y} (for metadata attributes) * * e.g.: GenericEncap([{'size': 4, 'value': 0xdeadbeef}, * {'size': 2, 'attribute': 'foo'}, * {'size': 2, 'value': 0x1234}]) * will prepend a 8-byte header: * de ad be ef 12 34

Source from the content-addressed store, hash-verified

102 * for each packet.
103 */
104CommandResponse GenericEncap::Init(const bess::pb::GenericEncapArg &arg) {
105 int size_acc = 0;
106
107 for (int i = 0; i < arg.fields_size(); i++) {
108 const auto &field = arg.fields(i);
109 CommandResponse err;
110 struct Field *f = &fields_[i];
111
112 f->pos = size_acc;
113
114 err = AddFieldOne(field, f, i);
115 if (err.error().code() != 0) {
116 return err;
117 }
118
119 size_acc += f->size;
120 }
121
122 encap_size_ = size_acc;
123 num_fields_ = arg.fields_size();
124
125 return CommandSuccess();
126}
127
128void GenericEncap::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
129 int cnt = batch->cnt();

Callers

nothing calls this directly

Calls 1

CommandSuccessFunction · 0.85

Tested by

no test coverage detected