blob: 927e9d33683d9e9761e05054df893b19ff5d0a4f [file] [log] [blame]
John Park398c74a2018-10-20 21:17:39 -07001#include "aos/configuration.h"
Brian Silverman66f079a2013-08-26 16:24:30 -07002
Brian Silverman66f079a2013-08-26 16:24:30 -07003#include <arpa/inet.h>
4#include <ifaddrs.h>
Austin Schuhf1fff282020-03-28 16:57:32 -07005#include <netinet/in.h>
6#include <stdlib.h>
7#include <string.h>
8#include <sys/types.h>
Brian Silverman66f079a2013-08-26 16:24:30 -07009#include <unistd.h>
Austin Schuhe84c3ed2019-12-14 15:29:48 -080010
11#include <set>
James Kuszmaul3ae42262019-11-08 12:33:41 -080012#include <string_view>
Brian Silverman66f079a2013-08-26 16:24:30 -070013
Austin Schuhcb108412019-10-13 16:09:54 -070014#include "absl/container/btree_set.h"
Austin Schuha81454b2020-05-12 19:58:36 -070015#include "absl/strings/str_cat.h"
Austin Schuhcb108412019-10-13 16:09:54 -070016#include "aos/configuration_generated.h"
17#include "aos/flatbuffer_merge.h"
18#include "aos/json_to_flatbuffer.h"
Austin Schuh217a9782019-12-21 23:02:50 -080019#include "aos/network/team_number.h"
Austin Schuhcb108412019-10-13 16:09:54 -070020#include "aos/unique_malloc_ptr.h"
21#include "aos/util/file.h"
Austin Schuh217a9782019-12-21 23:02:50 -080022#include "gflags/gflags.h"
Austin Schuhcb108412019-10-13 16:09:54 -070023#include "glog/logging.h"
Austin Schuh217a9782019-12-21 23:02:50 -080024
Brian Silverman66f079a2013-08-26 16:24:30 -070025namespace aos {
Austin Schuhcb108412019-10-13 16:09:54 -070026
Austin Schuh40485ed2019-10-26 21:51:44 -070027// Define the compare and equal operators for Channel and Application so we can
Austin Schuhcb108412019-10-13 16:09:54 -070028// insert them in the btree below.
Austin Schuh40485ed2019-10-26 21:51:44 -070029bool operator<(const FlatbufferDetachedBuffer<Channel> &lhs,
30 const FlatbufferDetachedBuffer<Channel> &rhs) {
Austin Schuhcb108412019-10-13 16:09:54 -070031 int name_compare = lhs.message().name()->string_view().compare(
32 rhs.message().name()->string_view());
33 if (name_compare == 0) {
34 return lhs.message().type()->string_view() <
35 rhs.message().type()->string_view();
36 } else if (name_compare < 0) {
37 return true;
38 } else {
39 return false;
40 }
41}
42
Austin Schuh40485ed2019-10-26 21:51:44 -070043bool operator==(const FlatbufferDetachedBuffer<Channel> &lhs,
44 const FlatbufferDetachedBuffer<Channel> &rhs) {
Austin Schuhcb108412019-10-13 16:09:54 -070045 return lhs.message().name()->string_view() ==
46 rhs.message().name()->string_view() &&
47 lhs.message().type()->string_view() ==
48 rhs.message().type()->string_view();
49}
50
Austin Schuh40485ed2019-10-26 21:51:44 -070051bool operator==(const FlatbufferDetachedBuffer<Application> &lhs,
52 const FlatbufferDetachedBuffer<Application> &rhs) {
Austin Schuhcb108412019-10-13 16:09:54 -070053 return lhs.message().name()->string_view() ==
54 rhs.message().name()->string_view();
55}
56
Austin Schuh40485ed2019-10-26 21:51:44 -070057bool operator<(const FlatbufferDetachedBuffer<Application> &lhs,
58 const FlatbufferDetachedBuffer<Application> &rhs) {
Austin Schuhcb108412019-10-13 16:09:54 -070059 return lhs.message().name()->string_view() <
60 rhs.message().name()->string_view();
61}
62
Austin Schuh217a9782019-12-21 23:02:50 -080063bool operator==(const FlatbufferDetachedBuffer<Node> &lhs,
64 const FlatbufferDetachedBuffer<Node> &rhs) {
65 return lhs.message().name()->string_view() ==
66 rhs.message().name()->string_view();
67}
68
69bool operator<(const FlatbufferDetachedBuffer<Node> &lhs,
70 const FlatbufferDetachedBuffer<Node> &rhs) {
71 return lhs.message().name()->string_view() <
72 rhs.message().name()->string_view();
73}
74
Brian Silverman66f079a2013-08-26 16:24:30 -070075namespace configuration {
76namespace {
77
Austin Schuhcb108412019-10-13 16:09:54 -070078// Extracts the folder part of a path. Returns ./ if there is no path.
Austin Schuhf1fff282020-03-28 16:57:32 -070079std::string_view ExtractFolder(const std::string_view filename) {
Austin Schuhcb108412019-10-13 16:09:54 -070080 auto last_slash_pos = filename.find_last_of("/\\");
81
James Kuszmaul3ae42262019-11-08 12:33:41 -080082 return last_slash_pos == std::string_view::npos
83 ? std::string_view("./")
Austin Schuhcb108412019-10-13 16:09:54 -070084 : filename.substr(0, last_slash_pos + 1);
85}
86
James Kuszmaulc0c08da2020-05-10 18:56:07 -070087std::string AbsolutePath(const std::string_view filename) {
88 // Uses an std::string so that we know the input will be null-terminated.
89 const std::string terminated_file(filename);
90 char buffer[PATH_MAX];
91 PCHECK(NULL != realpath(terminated_file.c_str(), buffer));
92 return buffer;
93}
94
Austin Schuh40485ed2019-10-26 21:51:44 -070095FlatbufferDetachedBuffer<Configuration> ReadConfig(
James Kuszmaulc0c08da2020-05-10 18:56:07 -070096 const std::string_view path, absl::btree_set<std::string> *visited_paths,
97 const std::vector<std::string_view> &extra_import_paths) {
98 std::string raw_path(path);
99 if (!util::PathExists(path)) {
100 const bool path_is_absolute = path.size() > 0 && path[0] == '/';
101 if (path_is_absolute) {
102 CHECK(extra_import_paths.empty())
103 << "Can't specify extra import paths if attempting to read a config "
104 "file from an absolute path (path is "
105 << path << ").";
106 }
107
108 bool found_path = false;
109 for (const auto &import_path : extra_import_paths) {
110 raw_path = std::string(import_path) + "/" + std::string(path);
111 if (util::PathExists(raw_path)) {
112 found_path = true;
113 break;
114 }
115 }
116 CHECK(found_path) << ": Failed to find file " << path << ".";
117 }
Alex Perrycb7da4b2019-08-28 19:35:56 -0700118 flatbuffers::DetachedBuffer buffer = JsonToFlatbuffer(
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700119 util::ReadFileToStringOrDie(raw_path), ConfigurationTypeTable());
Alex Perrycb7da4b2019-08-28 19:35:56 -0700120
121 CHECK_GT(buffer.size(), 0u) << ": Failed to parse JSON file";
122
123 FlatbufferDetachedBuffer<Configuration> config(std::move(buffer));
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700124
Austin Schuhcb108412019-10-13 16:09:54 -0700125 // Depth first. Take the following example:
126 //
127 // config1.json:
128 // {
Austin Schuh40485ed2019-10-26 21:51:44 -0700129 // "channels": [
Austin Schuhcb108412019-10-13 16:09:54 -0700130 // {
131 // "name": "/foo",
132 // "type": ".aos.bar",
133 // "max_size": 5
134 // }
135 // ],
136 // "imports": [
137 // "config2.json",
138 // ]
139 // }
140 //
141 // config2.json:
142 // {
Austin Schuh40485ed2019-10-26 21:51:44 -0700143 // "channels": [
Austin Schuhcb108412019-10-13 16:09:54 -0700144 // {
145 // "name": "/foo",
146 // "type": ".aos.bar",
147 // "max_size": 7
148 // }
149 // ],
150 // }
151 //
152 // We want the main config (config1.json) to be able to override the imported
153 // config. That means that it needs to be merged into the imported configs,
154 // not the other way around.
155
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700156 const std::string absolute_path = AbsolutePath(raw_path);
Austin Schuhcb108412019-10-13 16:09:54 -0700157 // Track that we have seen this file before recursing.
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700158 if (!visited_paths->insert(absolute_path).second) {
159 for (const auto &visited_path : *visited_paths) {
160 LOG(INFO) << "Already visited: " << visited_path;
161 }
162 LOG(FATAL)
163 << "Already imported " << path << " (i.e. " << absolute_path
164 << "). See above for the files that have already been processed.";
165 }
Austin Schuhcb108412019-10-13 16:09:54 -0700166
167 if (config.message().has_imports()) {
168 // Capture the imports.
169 const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *v =
170 config.message().imports();
171
172 // And then wipe them. This gets GCed when we merge later.
173 config.mutable_message()->clear_imports();
174
175 // Start with an empty configuration to merge into.
Austin Schuh40485ed2019-10-26 21:51:44 -0700176 FlatbufferDetachedBuffer<Configuration> merged_config =
177 FlatbufferDetachedBuffer<Configuration>::Empty();
Austin Schuhcb108412019-10-13 16:09:54 -0700178
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700179 const std::string path_folder(ExtractFolder(path));
Austin Schuhcb108412019-10-13 16:09:54 -0700180 for (const flatbuffers::String *str : *v) {
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700181 const std::string included_config =
182 path_folder + "/" + std::string(str->string_view());
Austin Schuhcb108412019-10-13 16:09:54 -0700183
184 // And them merge everything in.
185 merged_config = MergeFlatBuffers(
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700186 merged_config,
187 ReadConfig(included_config, visited_paths, extra_import_paths));
Austin Schuhcb108412019-10-13 16:09:54 -0700188 }
189
190 // Finally, merge this file in.
191 config = MergeFlatBuffers(merged_config, config);
192 }
193 return config;
194}
195
Alex Perrycb7da4b2019-08-28 19:35:56 -0700196// Compares (c < p) a channel, and a name, type tuple.
197bool CompareChannels(const Channel *c,
James Kuszmaul3ae42262019-11-08 12:33:41 -0800198 ::std::pair<std::string_view, std::string_view> p) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700199 int name_compare = c->name()->string_view().compare(p.first);
200 if (name_compare == 0) {
201 return c->type()->string_view() < p.second;
202 } else if (name_compare < 0) {
203 return true;
204 } else {
205 return false;
206 }
207};
208
209// Compares for equality (c == p) a channel, and a name, type tuple.
210bool EqualsChannels(const Channel *c,
Austin Schuhf1fff282020-03-28 16:57:32 -0700211 ::std::pair<std::string_view, std::string_view> p) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700212 return c->name()->string_view() == p.first &&
213 c->type()->string_view() == p.second;
214}
215
216// Compares (c < p) an application, and a name;
James Kuszmaul3ae42262019-11-08 12:33:41 -0800217bool CompareApplications(const Application *a, std::string_view name) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700218 return a->name()->string_view() < name;
219};
220
221// Compares for equality (c == p) an application, and a name;
James Kuszmaul3ae42262019-11-08 12:33:41 -0800222bool EqualsApplications(const Application *a, std::string_view name) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700223 return a->name()->string_view() == name;
224}
225
226// Maps name for the provided maps. Modifies name.
227void HandleMaps(const flatbuffers::Vector<flatbuffers::Offset<aos::Map>> *maps,
Austin Schuhf1fff282020-03-28 16:57:32 -0700228 std::string *name, std::string_view type, const Node *node) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700229 // For the same reason we merge configs in reverse order, we want to process
230 // maps in reverse order. That lets the outer config overwrite channels from
231 // the inner configs.
232 for (auto i = maps->rbegin(); i != maps->rend(); ++i) {
Austin Schuhbca6cf02019-12-22 17:28:34 -0800233 if (!i->has_match() || !i->match()->has_name()) {
234 continue;
Alex Perrycb7da4b2019-08-28 19:35:56 -0700235 }
Austin Schuhbca6cf02019-12-22 17:28:34 -0800236 if (!i->has_rename() || !i->rename()->has_name()) {
237 continue;
238 }
239
240 // Handle normal maps (now that we know that match and rename are filled
241 // out).
Austin Schuhf1fff282020-03-28 16:57:32 -0700242 const std::string_view match_name = i->match()->name()->string_view();
243 if (match_name != *name) {
244 if (match_name.back() == '*' &&
245 std::string_view(*name).substr(
246 0, std::min(name->size(), match_name.size() - 1)) ==
247 match_name.substr(0, match_name.size() - 1)) {
248 CHECK_EQ(match_name.find('*'), match_name.size() - 1);
249 } else {
250 continue;
251 }
Austin Schuhbca6cf02019-12-22 17:28:34 -0800252 }
253
254 // Handle type specific maps.
255 if (i->match()->has_type() && i->match()->type()->string_view() != type) {
256 continue;
257 }
258
Austin Schuhf1fff282020-03-28 16:57:32 -0700259 // Now handle node specific maps.
Austin Schuhbca6cf02019-12-22 17:28:34 -0800260 if (node != nullptr && i->match()->has_source_node() &&
261 i->match()->source_node()->string_view() !=
262 node->name()->string_view()) {
263 continue;
264 }
265
Austin Schuhf1fff282020-03-28 16:57:32 -0700266 std::string new_name(i->rename()->name()->string_view());
267 if (match_name.back() == '*') {
268 new_name += std::string(name->substr(match_name.size() - 1));
269 }
270 VLOG(1) << "Renamed \"" << *name << "\" to \"" << new_name << "\"";
271 *name = std::move(new_name);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700272 }
273}
274
275} // namespace
276
Austin Schuh40485ed2019-10-26 21:51:44 -0700277FlatbufferDetachedBuffer<Configuration> MergeConfiguration(
Austin Schuhcb108412019-10-13 16:09:54 -0700278 const Flatbuffer<Configuration> &config) {
James Kuszmaul3c998592020-07-27 21:04:47 -0700279 // auto_merge_config will contain all the fields of the Configuration that are
280 // to be passed through unmodified to the result of MergeConfiguration().
281 // In the processing below, we mutate auto_merge_config to remove any fields
282 // which we do need to alter (hence why we can't use the input config
283 // directly), and then merge auto_merge_config back in at the end.
284 aos::FlatbufferDetachedBuffer<aos::Configuration> auto_merge_config =
285 aos::CopyFlatBuffer(&config.message());
286
Austin Schuh40485ed2019-10-26 21:51:44 -0700287 // Store all the channels in a sorted set. This lets us track channels we
Austin Schuhcb108412019-10-13 16:09:54 -0700288 // have seen before and merge the updates in.
Austin Schuh40485ed2019-10-26 21:51:44 -0700289 absl::btree_set<FlatbufferDetachedBuffer<Channel>> channels;
Austin Schuhcb108412019-10-13 16:09:54 -0700290
Austin Schuh40485ed2019-10-26 21:51:44 -0700291 if (config.message().has_channels()) {
James Kuszmaul3c998592020-07-27 21:04:47 -0700292 auto_merge_config.mutable_message()->clear_channels();
Austin Schuh40485ed2019-10-26 21:51:44 -0700293 for (const Channel *c : *config.message().channels()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700294 // Ignore malformed entries.
Austin Schuh40485ed2019-10-26 21:51:44 -0700295 if (!c->has_name()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700296 continue;
297 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700298 if (!c->has_type()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700299 continue;
300 }
301
Austin Schuh40485ed2019-10-26 21:51:44 -0700302 // Attempt to insert the channel.
303 auto result = channels.insert(CopyFlatBuffer(c));
Austin Schuhcb108412019-10-13 16:09:54 -0700304 if (!result.second) {
305 // Already there, so merge the new table into the original.
Austin Schuh40485ed2019-10-26 21:51:44 -0700306 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(c));
Austin Schuhcb108412019-10-13 16:09:54 -0700307 }
308 }
309 }
310
311 // Now repeat this for the application list.
Austin Schuh40485ed2019-10-26 21:51:44 -0700312 absl::btree_set<FlatbufferDetachedBuffer<Application>> applications;
Austin Schuhcb108412019-10-13 16:09:54 -0700313 if (config.message().has_applications()) {
James Kuszmaul3c998592020-07-27 21:04:47 -0700314 auto_merge_config.mutable_message()->clear_applications();
Austin Schuhcb108412019-10-13 16:09:54 -0700315 for (const Application *a : *config.message().applications()) {
316 if (!a->has_name()) {
317 continue;
318 }
319
320 auto result = applications.insert(CopyFlatBuffer(a));
321 if (!result.second) {
322 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(a));
323 }
324 }
325 }
326
Austin Schuh217a9782019-12-21 23:02:50 -0800327 // Now repeat this for the node list.
328 absl::btree_set<FlatbufferDetachedBuffer<Node>> nodes;
329 if (config.message().has_nodes()) {
James Kuszmaul3c998592020-07-27 21:04:47 -0700330 auto_merge_config.mutable_message()->clear_nodes();
Austin Schuh217a9782019-12-21 23:02:50 -0800331 for (const Node *n : *config.message().nodes()) {
332 if (!n->has_name()) {
333 continue;
334 }
335
336 auto result = nodes.insert(CopyFlatBuffer(n));
337 if (!result.second) {
338 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(n));
339 }
340 }
341 }
342
Austin Schuhcb108412019-10-13 16:09:54 -0700343 flatbuffers::FlatBufferBuilder fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800344 fbb.ForceDefaults(true);
Austin Schuhcb108412019-10-13 16:09:54 -0700345
346 // Start by building the vectors. They need to come before the final table.
Austin Schuh40485ed2019-10-26 21:51:44 -0700347 // Channels
348 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Channel>>>
349 channels_offset;
Austin Schuhcb108412019-10-13 16:09:54 -0700350 {
Austin Schuh40485ed2019-10-26 21:51:44 -0700351 ::std::vector<flatbuffers::Offset<Channel>> channel_offsets;
352 for (const FlatbufferDetachedBuffer<Channel> &c : channels) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700353 channel_offsets.emplace_back(CopyFlatBuffer<Channel>(&c.message(), &fbb));
Austin Schuhcb108412019-10-13 16:09:54 -0700354 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700355 channels_offset = fbb.CreateVector(channel_offsets);
Austin Schuhcb108412019-10-13 16:09:54 -0700356 }
357
358 // Applications
359 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Application>>>
360 applications_offset;
361 {
362 ::std::vector<flatbuffers::Offset<Application>> applications_offsets;
Austin Schuh40485ed2019-10-26 21:51:44 -0700363 for (const FlatbufferDetachedBuffer<Application> &a : applications) {
Austin Schuhcb108412019-10-13 16:09:54 -0700364 applications_offsets.emplace_back(
365 CopyFlatBuffer<Application>(&a.message(), &fbb));
366 }
367 applications_offset = fbb.CreateVector(applications_offsets);
368 }
369
Austin Schuh217a9782019-12-21 23:02:50 -0800370 // Nodes
371 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Node>>>
372 nodes_offset;
373 {
374 ::std::vector<flatbuffers::Offset<Node>> node_offsets;
375 for (const FlatbufferDetachedBuffer<Node> &n : nodes) {
376 node_offsets.emplace_back(CopyFlatBuffer<Node>(&n.message(), &fbb));
377 }
378 nodes_offset = fbb.CreateVector(node_offsets);
379 }
380
Austin Schuhcb108412019-10-13 16:09:54 -0700381 // And then build a Configuration with them all.
382 ConfigurationBuilder configuration_builder(fbb);
Austin Schuh40485ed2019-10-26 21:51:44 -0700383 configuration_builder.add_channels(channels_offset);
Austin Schuh217a9782019-12-21 23:02:50 -0800384 if (config.message().has_applications()) {
385 configuration_builder.add_applications(applications_offset);
386 }
387 if (config.message().has_nodes()) {
388 configuration_builder.add_nodes(nodes_offset);
389 }
Austin Schuhcb108412019-10-13 16:09:54 -0700390
391 fbb.Finish(configuration_builder.Finish());
Austin Schuh217a9782019-12-21 23:02:50 -0800392
James Kuszmaul3c998592020-07-27 21:04:47 -0700393 aos::FlatbufferDetachedBuffer<aos::Configuration> modified_config(
394 fbb.Release());
395
Austin Schuh217a9782019-12-21 23:02:50 -0800396 // Now, validate that if there is a node list, every channel has a source
397 // node.
James Kuszmaul3c998592020-07-27 21:04:47 -0700398 FlatbufferDetachedBuffer<Configuration> result =
399 MergeFlatBuffers(modified_config, auto_merge_config);
Austin Schuh217a9782019-12-21 23:02:50 -0800400
401 // Check that if there is a node list, all the source nodes are filled out and
402 // valid, and all the destination nodes are valid (and not the source). This
403 // is a basic consistency check.
Austin Schuhf1fff282020-03-28 16:57:32 -0700404 if (result.message().has_channels()) {
405 for (const Channel *c : *result.message().channels()) {
406 if (c->name()->string_view().back() == '/') {
407 LOG(FATAL) << "Channel names can't end with '/'";
408 }
409 if(c->name()->string_view().find("//")!= std::string_view::npos) {
410 LOG(FATAL) << ": Invalid channel name " << c->name()->string_view()
411 << ", can't use //.";
412 }
413 for (const char data : c->name()->string_view()) {
414 if (data >= '0' && data <= '9') {
415 continue;
416 }
417 if (data >= 'a' && data <= 'z') {
418 continue;
419 }
420 if (data >= 'A' && data <= 'Z') {
421 continue;
422 }
423 if (data == '-' || data == '_' || data == '/') {
424 continue;
425 }
426 LOG(FATAL) << "Invalid channel name " << c->name()->string_view()
427 << ", can only use [-a-zA-Z0-9_/]";
428 }
429 }
430 }
431
432 if (result.message().has_nodes() && result.message().has_channels()) {
433 for (const Channel *c : *result.message().channels()) {
Austin Schuh217a9782019-12-21 23:02:50 -0800434 CHECK(c->has_source_node()) << ": Channel " << FlatbufferToJson(c)
435 << " is missing \"source_node\"";
436 CHECK(GetNode(&result.message(), c->source_node()->string_view()) !=
437 nullptr)
438 << ": Channel " << FlatbufferToJson(c)
439 << " has an unknown \"source_node\"";
440
441 if (c->has_destination_nodes()) {
Austin Schuh719946b2019-12-28 14:51:01 -0800442 for (const Connection *connection : *c->destination_nodes()) {
443 CHECK(connection->has_name());
444 CHECK(GetNode(&result.message(), connection->name()->string_view()) !=
445 nullptr)
Austin Schuh217a9782019-12-21 23:02:50 -0800446 << ": Channel " << FlatbufferToJson(c)
Austin Schuh719946b2019-12-28 14:51:01 -0800447 << " has an unknown \"destination_nodes\" "
448 << connection->name()->string_view();
Austin Schuh217a9782019-12-21 23:02:50 -0800449
Austin Schuh719946b2019-12-28 14:51:01 -0800450 switch (connection->timestamp_logger()) {
451 case LoggerConfig::LOCAL_LOGGER:
452 case LoggerConfig::NOT_LOGGED:
Austin Schuhda40e472020-03-28 15:15:29 -0700453 CHECK(!connection->has_timestamp_logger_nodes());
Austin Schuh719946b2019-12-28 14:51:01 -0800454 break;
455 case LoggerConfig::REMOTE_LOGGER:
456 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700457 CHECK(connection->has_timestamp_logger_nodes());
458 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
459 for (const flatbuffers::String *timestamp_logger_node :
460 *connection->timestamp_logger_nodes()) {
461 CHECK(GetNode(&result.message(),
462 timestamp_logger_node->string_view()) != nullptr)
463 << ": Channel " << FlatbufferToJson(c)
464 << " has an unknown \"timestamp_logger_node\""
465 << connection->name()->string_view();
466 }
Austin Schuh719946b2019-12-28 14:51:01 -0800467 break;
468 }
469
470 CHECK_NE(connection->name()->string_view(),
471 c->source_node()->string_view())
Austin Schuh217a9782019-12-21 23:02:50 -0800472 << ": Channel " << FlatbufferToJson(c)
473 << " is forwarding data to itself";
474 }
475 }
476 }
477 }
478
479 return result;
Austin Schuhcb108412019-10-13 16:09:54 -0700480}
481
Austin Schuh40485ed2019-10-26 21:51:44 -0700482FlatbufferDetachedBuffer<Configuration> ReadConfig(
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700483 const std::string_view path,
484 const std::vector<std::string_view> &import_paths) {
Austin Schuhcb108412019-10-13 16:09:54 -0700485 // We only want to read a file once. So track the visited files in a set.
486 absl::btree_set<std::string> visited_paths;
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700487 return MergeConfiguration(ReadConfig(path, &visited_paths, import_paths));
Austin Schuhcb108412019-10-13 16:09:54 -0700488}
489
Austin Schuh8d6cea82020-02-28 12:17:16 -0800490FlatbufferDetachedBuffer<Configuration> MergeWithConfig(
Brian Silverman24f5aa82020-06-23 16:21:28 -0700491 const Configuration *config, const Flatbuffer<Configuration> &addition) {
492 return MergeConfiguration(MergeFlatBuffers(config, &addition.message()));
493}
494
495FlatbufferDetachedBuffer<Configuration> MergeWithConfig(
Austin Schuh8d6cea82020-02-28 12:17:16 -0800496 const Configuration *config, std::string_view json) {
497 FlatbufferDetachedBuffer<Configuration> addition =
498 JsonToFlatbuffer(json, Configuration::MiniReflectTypeTable());
499
Brian Silverman24f5aa82020-06-23 16:21:28 -0700500 return MergeWithConfig(config, addition);
Austin Schuh8d6cea82020-02-28 12:17:16 -0800501}
502
James Kuszmaul3ae42262019-11-08 12:33:41 -0800503const Channel *GetChannel(const Configuration *config, std::string_view name,
504 std::string_view type,
Austin Schuhbca6cf02019-12-22 17:28:34 -0800505 std::string_view application_name, const Node *node) {
506 const std::string_view original_name = name;
Austin Schuhf1fff282020-03-28 16:57:32 -0700507 std::string mutable_name;
Austin Schuhcb108412019-10-13 16:09:54 -0700508 VLOG(1) << "Looking up { \"name\": \"" << name << "\", \"type\": \"" << type
509 << "\" }";
510
511 // First handle application specific maps. Only do this if we have a matching
512 // application name, and it has maps.
Austin Schuh40485ed2019-10-26 21:51:44 -0700513 if (config->has_applications()) {
514 auto application_iterator = std::lower_bound(
515 config->applications()->cbegin(), config->applications()->cend(),
516 application_name, CompareApplications);
517 if (application_iterator != config->applications()->cend() &&
Austin Schuhcb108412019-10-13 16:09:54 -0700518 EqualsApplications(*application_iterator, application_name)) {
519 if (application_iterator->has_maps()) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700520 mutable_name = std::string(name);
521 HandleMaps(application_iterator->maps(), &mutable_name, type, node);
522 name = std::string_view(mutable_name);
Austin Schuhcb108412019-10-13 16:09:54 -0700523 }
524 }
525 }
526
527 // Now do global maps.
Austin Schuh40485ed2019-10-26 21:51:44 -0700528 if (config->has_maps()) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700529 mutable_name = std::string(name);
530 HandleMaps(config->maps(), &mutable_name, type, node);
531 name = std::string_view(mutable_name);
Austin Schuhcb108412019-10-13 16:09:54 -0700532 }
533
Austin Schuhbca6cf02019-12-22 17:28:34 -0800534 if (original_name != name) {
535 VLOG(1) << "Remapped to { \"name\": \"" << name << "\", \"type\": \""
536 << type << "\" }";
537 }
Alex Perrycb7da4b2019-08-28 19:35:56 -0700538
Austin Schuh40485ed2019-10-26 21:51:44 -0700539 // Then look for the channel.
540 auto channel_iterator =
Austin Schuhf1fff282020-03-28 16:57:32 -0700541 std::lower_bound(config->channels()->cbegin(), config->channels()->cend(),
Austin Schuh40485ed2019-10-26 21:51:44 -0700542 std::make_pair(name, type), CompareChannels);
Austin Schuhcb108412019-10-13 16:09:54 -0700543
544 // Make sure we actually found it, and it matches.
Austin Schuh40485ed2019-10-26 21:51:44 -0700545 if (channel_iterator != config->channels()->cend() &&
546 EqualsChannels(*channel_iterator, std::make_pair(name, type))) {
Austin Schuhbca6cf02019-12-22 17:28:34 -0800547 if (VLOG_IS_ON(2)) {
548 VLOG(2) << "Found: " << FlatbufferToJson(*channel_iterator);
549 } else if (VLOG_IS_ON(1)) {
550 VLOG(1) << "Found: " << CleanedChannelToString(*channel_iterator);
551 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700552 return *channel_iterator;
Austin Schuhcb108412019-10-13 16:09:54 -0700553 } else {
554 VLOG(1) << "No match for { \"name\": \"" << name << "\", \"type\": \""
555 << type << "\" }";
556 return nullptr;
557 }
558}
559
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800560size_t ChannelIndex(const Configuration *configuration,
561 const Channel *channel) {
562 CHECK(configuration->channels() != nullptr) << ": No channels";
563
564 auto c = std::find(configuration->channels()->begin(),
565 configuration->channels()->end(), channel);
566 CHECK(c != configuration->channels()->end())
567 << ": Channel pointer not found in configuration()->channels()";
568
569 return std::distance(configuration->channels()->begin(), c);
570}
571
Austin Schuhbca6cf02019-12-22 17:28:34 -0800572std::string CleanedChannelToString(const Channel *channel) {
573 FlatbufferDetachedBuffer<Channel> cleaned_channel = CopyFlatBuffer(channel);
574 cleaned_channel.mutable_message()->clear_schema();
575 return FlatbufferToJson(cleaned_channel);
576}
577
Austin Schuha81454b2020-05-12 19:58:36 -0700578std::string StrippedChannelToString(const Channel *channel) {
579 return absl::StrCat("{ \"name\": \"", channel->name()->string_view(),
580 "\", \"type\": \"", channel->type()->string_view(),
581 "\" }");
582}
583
Alex Perrycb7da4b2019-08-28 19:35:56 -0700584FlatbufferDetachedBuffer<Configuration> MergeConfiguration(
585 const Flatbuffer<Configuration> &config,
586 const std::vector<aos::FlatbufferString<reflection::Schema>> &schemas) {
587 flatbuffers::FlatBufferBuilder fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800588 fbb.ForceDefaults(true);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700589
James Kuszmaul3c998592020-07-27 21:04:47 -0700590 // auto_merge_config will contain all the fields of the Configuration that are
591 // to be passed through unmodified to the result of MergeConfiguration().
592 // In the processing below, we mutate auto_merge_config to remove any fields
593 // which we do need to alter (hence why we can't use the input config
594 // directly), and then merge auto_merge_config back in at the end.
595 aos::FlatbufferDetachedBuffer<aos::Configuration> auto_merge_config =
596 aos::CopyFlatBuffer(&config.message());
597
Alex Perrycb7da4b2019-08-28 19:35:56 -0700598 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Channel>>>
599 channels_offset;
600 if (config.message().has_channels()) {
James Kuszmaul3c998592020-07-27 21:04:47 -0700601 auto_merge_config.mutable_message()->clear_channels();
Alex Perrycb7da4b2019-08-28 19:35:56 -0700602 std::vector<flatbuffers::Offset<Channel>> channel_offsets;
603 for (const Channel *c : *config.message().channels()) {
604 flatbuffers::FlatBufferBuilder channel_fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800605 channel_fbb.ForceDefaults(true);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700606
607 // Search for a schema with a matching type.
608 const aos::FlatbufferString<reflection::Schema> *found_schema = nullptr;
Austin Schuhf1fff282020-03-28 16:57:32 -0700609 for (const aos::FlatbufferString<reflection::Schema> &schema : schemas) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700610 if (schema.message().root_table() != nullptr) {
611 if (schema.message().root_table()->name()->string_view() ==
612 c->type()->string_view()) {
613 found_schema = &schema;
614 }
615 }
616 }
617
618 CHECK(found_schema != nullptr)
619 << ": Failed to find schema for " << FlatbufferToJson(c);
620
621 // The following is wasteful, but works.
622 //
623 // Copy it into a Channel object by creating an object with only the
624 // schema populated and merge that into the current channel.
625 flatbuffers::Offset<reflection::Schema> schema_offset =
626 CopyFlatBuffer<reflection::Schema>(&found_schema->message(),
627 &channel_fbb);
628 Channel::Builder channel_builder(channel_fbb);
629 channel_builder.add_schema(schema_offset);
630 channel_fbb.Finish(channel_builder.Finish());
631 FlatbufferDetachedBuffer<Channel> channel_schema_flatbuffer(
632 channel_fbb.Release());
633
634 FlatbufferDetachedBuffer<Channel> merged_channel(
635 MergeFlatBuffers(channel_schema_flatbuffer, CopyFlatBuffer(c)));
636
637 channel_offsets.emplace_back(
638 CopyFlatBuffer<Channel>(&merged_channel.message(), &fbb));
639 }
640 channels_offset = fbb.CreateVector(channel_offsets);
641 }
642
Austin Schuh217a9782019-12-21 23:02:50 -0800643
644 // Now insert everything else in unmodified.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700645 ConfigurationBuilder configuration_builder(fbb);
646 if (config.message().has_channels()) {
647 configuration_builder.add_channels(channels_offset);
648 }
Alex Perrycb7da4b2019-08-28 19:35:56 -0700649 fbb.Finish(configuration_builder.Finish());
James Kuszmaul3c998592020-07-27 21:04:47 -0700650 aos::FlatbufferDetachedBuffer<aos::Configuration> modified_config(
651 fbb.Release());
652
653 return MergeFlatBuffers(modified_config, auto_merge_config);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700654}
655
Austin Schuh217a9782019-12-21 23:02:50 -0800656const Node *GetNodeFromHostname(const Configuration *config,
657 std::string_view hostname) {
658 for (const Node *node : *config->nodes()) {
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800659 if (node->has_hostname() && node->hostname()->string_view() == hostname) {
Austin Schuh217a9782019-12-21 23:02:50 -0800660 return node;
661 }
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800662 if (node->has_hostnames()) {
663 for (const auto &candidate : *node->hostnames()) {
664 if (candidate->string_view() == hostname) {
665 return node;
666 }
667 }
668 }
Austin Schuh217a9782019-12-21 23:02:50 -0800669 }
670 return nullptr;
671}
Austin Schuhac0771c2020-01-07 18:36:30 -0800672
Austin Schuh217a9782019-12-21 23:02:50 -0800673const Node *GetMyNode(const Configuration *config) {
674 const std::string hostname = (FLAGS_override_hostname.size() > 0)
675 ? FLAGS_override_hostname
676 : network::GetHostname();
677 const Node *node = GetNodeFromHostname(config, hostname);
678 if (node != nullptr) return node;
679
680 LOG(FATAL) << "Unknown node for host: " << hostname
681 << ". Consider using --override_hostname if hostname detection "
682 "is wrong.";
683 return nullptr;
684}
685
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800686const Node *GetNode(const Configuration *config, const Node *node) {
687 if (!MultiNode(config)) {
688 CHECK(node == nullptr) << ": Provided a node in a single node world.";
689 return nullptr;
690 } else {
691 CHECK(node != nullptr);
692 CHECK(node->has_name());
693 return GetNode(config, node->name()->string_view());
694 }
695}
696
Austin Schuh217a9782019-12-21 23:02:50 -0800697const Node *GetNode(const Configuration *config, std::string_view name) {
Austin Schuhfd960622020-01-01 13:22:55 -0800698 CHECK(config->has_nodes())
699 << ": Asking for a node from a single node configuration.";
Austin Schuh217a9782019-12-21 23:02:50 -0800700 for (const Node *node : *config->nodes()) {
Austin Schuhfd960622020-01-01 13:22:55 -0800701 CHECK(node->has_name()) << ": Malformed node " << FlatbufferToJson(node);
Austin Schuh217a9782019-12-21 23:02:50 -0800702 if (node->name()->string_view() == name) {
703 return node;
704 }
705 }
706 return nullptr;
707}
708
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800709const Node *GetNodeOrDie(const Configuration *config, const Node *node) {
710 if (!MultiNode(config)) {
711 CHECK(node == nullptr) << ": Provided a node in a single node world.";
712 return nullptr;
713 } else {
714 const Node *config_node = GetNode(config, node);
715 if (config_node == nullptr) {
716 LOG(FATAL) << "Couldn't find node matching " << FlatbufferToJson(node);
717 }
718 return config_node;
719 }
720}
721
Austin Schuh8bd96322020-02-13 21:18:22 -0800722namespace {
723int GetNodeIndexFromConfig(const Configuration *config, const Node *node) {
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800724 int node_index = 0;
725 for (const Node *iterated_node : *config->nodes()) {
726 if (iterated_node == node) {
727 return node_index;
728 }
729 ++node_index;
730 }
Austin Schuh8bd96322020-02-13 21:18:22 -0800731 return -1;
732}
733} // namespace
734
735int GetNodeIndex(const Configuration *config, const Node *node) {
736 if (!MultiNode(config)) {
737 return 0;
738 }
739
740 {
741 int node_index = GetNodeIndexFromConfig(config, node);
742 if (node_index != -1) {
743 return node_index;
744 }
745 }
746
747 const Node *result = GetNode(config, node);
748 CHECK(result != nullptr);
749
750 {
Austin Schuh04408fc2020-02-16 21:48:54 -0800751 int node_index = GetNodeIndexFromConfig(config, result);
Austin Schuh8bd96322020-02-13 21:18:22 -0800752 if (node_index != -1) {
753 return node_index;
754 }
755 }
756
757 LOG(FATAL) << "Node " << FlatbufferToJson(node)
758 << " not found in the configuration.";
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800759}
760
Austin Schuh04408fc2020-02-16 21:48:54 -0800761int GetNodeIndex(const Configuration *config, std::string_view name) {
762 if (!MultiNode(config)) {
763 return 0;
764 }
765
766 {
767 int node_index = 0;
768 for (const Node *iterated_node : *config->nodes()) {
769 if (iterated_node->name()->string_view() == name) {
770 return node_index;
771 }
772 ++node_index;
773 }
774 }
775 LOG(FATAL) << "Node " << name << " not found in the configuration.";
776}
777
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800778std::vector<const Node *> GetNodes(const Configuration *config) {
779 std::vector<const Node *> nodes;
Austin Schuh8bd96322020-02-13 21:18:22 -0800780 if (MultiNode(config)) {
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800781 for (const Node *node : *config->nodes()) {
782 nodes.emplace_back(node);
783 }
784 } else {
785 nodes.emplace_back(nullptr);
786 }
787 return nodes;
788}
789
Austin Schuhac0771c2020-01-07 18:36:30 -0800790bool MultiNode(const Configuration *config) { return config->has_nodes(); }
791
Austin Schuh217a9782019-12-21 23:02:50 -0800792bool ChannelIsSendableOnNode(const Channel *channel, const Node *node) {
Austin Schuhca4828c2019-12-28 14:21:35 -0800793 if (node == nullptr) {
794 return true;
795 }
Austin Schuh196a4452020-03-15 23:12:03 -0700796 return (CHECK_NOTNULL(channel)->source_node()->string_view() ==
797 node->name()->string_view());
Austin Schuh217a9782019-12-21 23:02:50 -0800798}
799
800bool ChannelIsReadableOnNode(const Channel *channel, const Node *node) {
Austin Schuhca4828c2019-12-28 14:21:35 -0800801 if (node == nullptr) {
802 return true;
803 }
804
Austin Schuh217a9782019-12-21 23:02:50 -0800805 if (channel->source_node()->string_view() == node->name()->string_view()) {
806 return true;
807 }
808
809 if (!channel->has_destination_nodes()) {
810 return false;
811 }
812
Austin Schuh719946b2019-12-28 14:51:01 -0800813 for (const Connection *connection : *channel->destination_nodes()) {
814 CHECK(connection->has_name());
815 if (connection->name()->string_view() == node->name()->string_view()) {
Austin Schuh217a9782019-12-21 23:02:50 -0800816 return true;
817 }
818 }
819
820 return false;
821}
822
Austin Schuh719946b2019-12-28 14:51:01 -0800823bool ChannelMessageIsLoggedOnNode(const Channel *channel, const Node *node) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700824 switch (channel->logger()) {
Austin Schuh719946b2019-12-28 14:51:01 -0800825 case LoggerConfig::LOCAL_LOGGER:
826 if (node == nullptr) {
827 // Single node world. If there is a local logger, then we want to use
828 // it.
829 return true;
830 }
831 return channel->source_node()->string_view() ==
832 node->name()->string_view();
Austin Schuh719946b2019-12-28 14:51:01 -0800833 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700834 CHECK(channel->has_logger_nodes());
835 CHECK_GT(channel->logger_nodes()->size(), 0u);
Austin Schuh719946b2019-12-28 14:51:01 -0800836
837 if (channel->source_node()->string_view() ==
838 CHECK_NOTNULL(node)->name()->string_view()) {
839 return true;
840 }
Austin Schuhda40e472020-03-28 15:15:29 -0700841
842 [[fallthrough]];
843 case LoggerConfig::REMOTE_LOGGER:
844 CHECK(channel->has_logger_nodes());
845 CHECK_GT(channel->logger_nodes()->size(), 0u);
846 for (const flatbuffers::String *logger_node : *channel->logger_nodes()) {
847 if (logger_node->string_view() ==
848 CHECK_NOTNULL(node)->name()->string_view()) {
849 return true;
850 }
Austin Schuh719946b2019-12-28 14:51:01 -0800851 }
852
853 return false;
854 case LoggerConfig::NOT_LOGGED:
855 return false;
856 }
857
858 LOG(FATAL) << "Unknown logger config " << static_cast<int>(channel->logger());
859}
860
861const Connection *ConnectionToNode(const Channel *channel, const Node *node) {
862 if (!channel->has_destination_nodes()) {
863 return nullptr;
864 }
865 for (const Connection *connection : *channel->destination_nodes()) {
866 if (connection->name()->string_view() == node->name()->string_view()) {
867 return connection;
868 }
869 }
870 return nullptr;
871}
872
873bool ConnectionDeliveryTimeIsLoggedOnNode(const Channel *channel,
874 const Node *node,
875 const Node *logger_node) {
876 const Connection *connection = ConnectionToNode(channel, node);
877 if (connection == nullptr) {
878 return false;
879 }
880 return ConnectionDeliveryTimeIsLoggedOnNode(connection, logger_node);
881}
882
883bool ConnectionDeliveryTimeIsLoggedOnNode(const Connection *connection,
884 const Node *node) {
885 switch (connection->timestamp_logger()) {
886 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700887 CHECK(connection->has_timestamp_logger_nodes());
888 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
Austin Schuh719946b2019-12-28 14:51:01 -0800889 if (connection->name()->string_view() == node->name()->string_view()) {
890 return true;
891 }
892
Austin Schuhda40e472020-03-28 15:15:29 -0700893 [[fallthrough]];
894 case LoggerConfig::REMOTE_LOGGER:
895 CHECK(connection->has_timestamp_logger_nodes());
896 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
897 for (const flatbuffers::String *timestamp_logger_node :
898 *connection->timestamp_logger_nodes()) {
899 if (timestamp_logger_node->string_view() ==
900 node->name()->string_view()) {
901 return true;
902 }
Austin Schuh719946b2019-12-28 14:51:01 -0800903 }
904
905 return false;
906 case LoggerConfig::LOCAL_LOGGER:
907 return connection->name()->string_view() == node->name()->string_view();
Austin Schuh719946b2019-12-28 14:51:01 -0800908 case LoggerConfig::NOT_LOGGED:
909 return false;
910 }
911
912 LOG(FATAL) << "Unknown logger config "
913 << static_cast<int>(connection->timestamp_logger());
914}
915
Austin Schuhe84c3ed2019-12-14 15:29:48 -0800916std::vector<std::string_view> SourceNodeNames(const Configuration *config,
917 const Node *my_node) {
918 std::set<std::string_view> result_set;
919
920 for (const Channel *channel : *config->channels()) {
921 if (channel->has_destination_nodes()) {
922 for (const Connection *connection : *channel->destination_nodes()) {
923 if (connection->name()->string_view() ==
924 my_node->name()->string_view()) {
925 result_set.insert(channel->source_node()->string_view());
926 }
927 }
928 }
929 }
930
931 std::vector<std::string_view> result;
932 for (const std::string_view source : result_set) {
933 VLOG(1) << "Found a source node of " << source;
934 result.emplace_back(source);
935 }
936 return result;
937}
938
939std::vector<std::string_view> DestinationNodeNames(const Configuration *config,
940 const Node *my_node) {
941 std::vector<std::string_view> result;
942
943 for (const Channel *channel : *config->channels()) {
944 if (channel->has_source_node() && channel->source_node()->string_view() ==
945 my_node->name()->string_view()) {
946 if (!channel->has_destination_nodes()) continue;
947
948 if (channel->source_node()->string_view() !=
949 my_node->name()->string_view()) {
950 continue;
951 }
952
953 for (const Connection *connection : *channel->destination_nodes()) {
954 if (std::find(result.begin(), result.end(),
955 connection->name()->string_view()) == result.end()) {
956 result.emplace_back(connection->name()->string_view());
957 }
958 }
959 }
960 }
961
962 for (const std::string_view destination : result) {
963 VLOG(1) << "Found a destination node of " << destination;
964 }
965 return result;
966}
967
Brian Silverman66f079a2013-08-26 16:24:30 -0700968} // namespace configuration
969} // namespace aos