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

Method AddAttributes

core/modules/mttest.cc:35–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include <glog/logging.h>
34
35CommandResponse MetadataTest::AddAttributes(
36 const google::protobuf::Map<std::string, int64_t> &attributes,
37 Attribute::AccessMode mode) {
38 for (const auto &kv : attributes) {
39 int ret;
40
41 const char *attr_name = kv.first.c_str();
42 int attr_size = kv.second;
43
44 ret = AddMetadataAttr(attr_name, attr_size, mode);
45 if (ret < 0)
46 return CommandFailure(-ret, "invalid metadata declaration");
47
48 /* check /var/log/syslog for log messages */
49 switch (mode) {
50 case Attribute::AccessMode::kRead:
51 LOG(INFO) << "module " << name() << ": " << attr_name << ", "
52 << attr_size << " bytes, read" << std::endl;
53 break;
54 case Attribute::AccessMode::kWrite:
55 LOG(INFO) << "module " << name() << ": " << attr_name << ", "
56 << attr_size << " bytes, write" << std::endl;
57 break;
58 case Attribute::AccessMode::kUpdate:
59 LOG(INFO) << "module " << name() << ": " << attr_name << ", "
60 << attr_size << " bytes, update" << std::endl;
61 break;
62 }
63 }
64
65 return CommandSuccess();
66}
67
68CommandResponse MetadataTest::Init(const bess::pb::MetadataTestArg &arg) {
69 CommandResponse err;

Callers

nothing calls this directly

Calls 2

CommandFailureFunction · 0.85
CommandSuccessFunction · 0.85

Tested by

no test coverage detected