blob: bcb4de6f704315f5f9c7bac67ff7bb8773bd6c0c [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) {
Austin Schuh40485ed2019-10-26 21:51:44 -0700279 // Store all the channels in a sorted set. This lets us track channels we
Austin Schuhcb108412019-10-13 16:09:54 -0700280 // have seen before and merge the updates in.
Austin Schuh40485ed2019-10-26 21:51:44 -0700281 absl::btree_set<FlatbufferDetachedBuffer<Channel>> channels;
Austin Schuhcb108412019-10-13 16:09:54 -0700282
Austin Schuh40485ed2019-10-26 21:51:44 -0700283 if (config.message().has_channels()) {
284 for (const Channel *c : *config.message().channels()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700285 // Ignore malformed entries.
Austin Schuh40485ed2019-10-26 21:51:44 -0700286 if (!c->has_name()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700287 continue;
288 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700289 if (!c->has_type()) {
Austin Schuhcb108412019-10-13 16:09:54 -0700290 continue;
291 }
292
Austin Schuh40485ed2019-10-26 21:51:44 -0700293 // Attempt to insert the channel.
294 auto result = channels.insert(CopyFlatBuffer(c));
Austin Schuhcb108412019-10-13 16:09:54 -0700295 if (!result.second) {
296 // Already there, so merge the new table into the original.
Austin Schuh40485ed2019-10-26 21:51:44 -0700297 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(c));
Austin Schuhcb108412019-10-13 16:09:54 -0700298 }
299 }
300 }
301
302 // Now repeat this for the application list.
Austin Schuh40485ed2019-10-26 21:51:44 -0700303 absl::btree_set<FlatbufferDetachedBuffer<Application>> applications;
Austin Schuhcb108412019-10-13 16:09:54 -0700304 if (config.message().has_applications()) {
305 for (const Application *a : *config.message().applications()) {
306 if (!a->has_name()) {
307 continue;
308 }
309
310 auto result = applications.insert(CopyFlatBuffer(a));
311 if (!result.second) {
312 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(a));
313 }
314 }
315 }
316
Austin Schuh217a9782019-12-21 23:02:50 -0800317 // Now repeat this for the node list.
318 absl::btree_set<FlatbufferDetachedBuffer<Node>> nodes;
319 if (config.message().has_nodes()) {
320 for (const Node *n : *config.message().nodes()) {
321 if (!n->has_name()) {
322 continue;
323 }
324
325 auto result = nodes.insert(CopyFlatBuffer(n));
326 if (!result.second) {
327 *result.first = MergeFlatBuffers(*result.first, CopyFlatBuffer(n));
328 }
329 }
330 }
331
Austin Schuhcb108412019-10-13 16:09:54 -0700332 flatbuffers::FlatBufferBuilder fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800333 fbb.ForceDefaults(true);
Austin Schuhcb108412019-10-13 16:09:54 -0700334
335 // Start by building the vectors. They need to come before the final table.
Austin Schuh40485ed2019-10-26 21:51:44 -0700336 // Channels
337 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Channel>>>
338 channels_offset;
Austin Schuhcb108412019-10-13 16:09:54 -0700339 {
Austin Schuh40485ed2019-10-26 21:51:44 -0700340 ::std::vector<flatbuffers::Offset<Channel>> channel_offsets;
341 for (const FlatbufferDetachedBuffer<Channel> &c : channels) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700342 channel_offsets.emplace_back(CopyFlatBuffer<Channel>(&c.message(), &fbb));
Austin Schuhcb108412019-10-13 16:09:54 -0700343 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700344 channels_offset = fbb.CreateVector(channel_offsets);
Austin Schuhcb108412019-10-13 16:09:54 -0700345 }
346
347 // Applications
348 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Application>>>
349 applications_offset;
350 {
351 ::std::vector<flatbuffers::Offset<Application>> applications_offsets;
Austin Schuh40485ed2019-10-26 21:51:44 -0700352 for (const FlatbufferDetachedBuffer<Application> &a : applications) {
Austin Schuhcb108412019-10-13 16:09:54 -0700353 applications_offsets.emplace_back(
354 CopyFlatBuffer<Application>(&a.message(), &fbb));
355 }
356 applications_offset = fbb.CreateVector(applications_offsets);
357 }
358
359 // Just copy the maps
360 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Map>>>
361 maps_offset;
362 {
363 ::std::vector<flatbuffers::Offset<Map>> map_offsets;
364 if (config.message().has_maps()) {
365 for (const Map *m : *config.message().maps()) {
366 map_offsets.emplace_back(CopyFlatBuffer<Map>(m, &fbb));
367 }
368 maps_offset = fbb.CreateVector(map_offsets);
369 }
370 }
371
Austin Schuh217a9782019-12-21 23:02:50 -0800372 // Nodes
373 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Node>>>
374 nodes_offset;
375 {
376 ::std::vector<flatbuffers::Offset<Node>> node_offsets;
377 for (const FlatbufferDetachedBuffer<Node> &n : nodes) {
378 node_offsets.emplace_back(CopyFlatBuffer<Node>(&n.message(), &fbb));
379 }
380 nodes_offset = fbb.CreateVector(node_offsets);
381 }
382
Austin Schuhcb108412019-10-13 16:09:54 -0700383 // And then build a Configuration with them all.
384 ConfigurationBuilder configuration_builder(fbb);
Austin Schuh40485ed2019-10-26 21:51:44 -0700385 configuration_builder.add_channels(channels_offset);
Austin Schuhcb108412019-10-13 16:09:54 -0700386 if (config.message().has_maps()) {
387 configuration_builder.add_maps(maps_offset);
388 }
Austin Schuh217a9782019-12-21 23:02:50 -0800389 if (config.message().has_applications()) {
390 configuration_builder.add_applications(applications_offset);
391 }
392 if (config.message().has_nodes()) {
393 configuration_builder.add_nodes(nodes_offset);
394 }
Austin Schuhcb108412019-10-13 16:09:54 -0700395
396 fbb.Finish(configuration_builder.Finish());
Austin Schuh217a9782019-12-21 23:02:50 -0800397
398 // Now, validate that if there is a node list, every channel has a source
399 // node.
400 FlatbufferDetachedBuffer<Configuration> result(fbb.Release());
401
402 // Check that if there is a node list, all the source nodes are filled out and
403 // valid, and all the destination nodes are valid (and not the source). This
404 // is a basic consistency check.
Austin Schuhf1fff282020-03-28 16:57:32 -0700405 if (result.message().has_channels()) {
406 for (const Channel *c : *result.message().channels()) {
407 if (c->name()->string_view().back() == '/') {
408 LOG(FATAL) << "Channel names can't end with '/'";
409 }
410 if(c->name()->string_view().find("//")!= std::string_view::npos) {
411 LOG(FATAL) << ": Invalid channel name " << c->name()->string_view()
412 << ", can't use //.";
413 }
414 for (const char data : c->name()->string_view()) {
415 if (data >= '0' && data <= '9') {
416 continue;
417 }
418 if (data >= 'a' && data <= 'z') {
419 continue;
420 }
421 if (data >= 'A' && data <= 'Z') {
422 continue;
423 }
424 if (data == '-' || data == '_' || data == '/') {
425 continue;
426 }
427 LOG(FATAL) << "Invalid channel name " << c->name()->string_view()
428 << ", can only use [-a-zA-Z0-9_/]";
429 }
430 }
431 }
432
433 if (result.message().has_nodes() && result.message().has_channels()) {
434 for (const Channel *c : *result.message().channels()) {
Austin Schuh217a9782019-12-21 23:02:50 -0800435 CHECK(c->has_source_node()) << ": Channel " << FlatbufferToJson(c)
436 << " is missing \"source_node\"";
437 CHECK(GetNode(&result.message(), c->source_node()->string_view()) !=
438 nullptr)
439 << ": Channel " << FlatbufferToJson(c)
440 << " has an unknown \"source_node\"";
441
442 if (c->has_destination_nodes()) {
Austin Schuh719946b2019-12-28 14:51:01 -0800443 for (const Connection *connection : *c->destination_nodes()) {
444 CHECK(connection->has_name());
445 CHECK(GetNode(&result.message(), connection->name()->string_view()) !=
446 nullptr)
Austin Schuh217a9782019-12-21 23:02:50 -0800447 << ": Channel " << FlatbufferToJson(c)
Austin Schuh719946b2019-12-28 14:51:01 -0800448 << " has an unknown \"destination_nodes\" "
449 << connection->name()->string_view();
Austin Schuh217a9782019-12-21 23:02:50 -0800450
Austin Schuh719946b2019-12-28 14:51:01 -0800451 switch (connection->timestamp_logger()) {
452 case LoggerConfig::LOCAL_LOGGER:
453 case LoggerConfig::NOT_LOGGED:
Austin Schuhda40e472020-03-28 15:15:29 -0700454 CHECK(!connection->has_timestamp_logger_nodes());
Austin Schuh719946b2019-12-28 14:51:01 -0800455 break;
456 case LoggerConfig::REMOTE_LOGGER:
457 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700458 CHECK(connection->has_timestamp_logger_nodes());
459 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
460 for (const flatbuffers::String *timestamp_logger_node :
461 *connection->timestamp_logger_nodes()) {
462 CHECK(GetNode(&result.message(),
463 timestamp_logger_node->string_view()) != nullptr)
464 << ": Channel " << FlatbufferToJson(c)
465 << " has an unknown \"timestamp_logger_node\""
466 << connection->name()->string_view();
467 }
Austin Schuh719946b2019-12-28 14:51:01 -0800468 break;
469 }
470
471 CHECK_NE(connection->name()->string_view(),
472 c->source_node()->string_view())
Austin Schuh217a9782019-12-21 23:02:50 -0800473 << ": Channel " << FlatbufferToJson(c)
474 << " is forwarding data to itself";
475 }
476 }
477 }
478 }
479
480 return result;
Austin Schuhcb108412019-10-13 16:09:54 -0700481}
482
Austin Schuh40485ed2019-10-26 21:51:44 -0700483FlatbufferDetachedBuffer<Configuration> ReadConfig(
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700484 const std::string_view path,
485 const std::vector<std::string_view> &import_paths) {
Austin Schuhcb108412019-10-13 16:09:54 -0700486 // We only want to read a file once. So track the visited files in a set.
487 absl::btree_set<std::string> visited_paths;
James Kuszmaulc0c08da2020-05-10 18:56:07 -0700488 return MergeConfiguration(ReadConfig(path, &visited_paths, import_paths));
Austin Schuhcb108412019-10-13 16:09:54 -0700489}
490
Austin Schuh8d6cea82020-02-28 12:17:16 -0800491FlatbufferDetachedBuffer<Configuration> MergeWithConfig(
Brian Silverman24f5aa82020-06-23 16:21:28 -0700492 const Configuration *config, const Flatbuffer<Configuration> &addition) {
493 return MergeConfiguration(MergeFlatBuffers(config, &addition.message()));
494}
495
496FlatbufferDetachedBuffer<Configuration> MergeWithConfig(
Austin Schuh8d6cea82020-02-28 12:17:16 -0800497 const Configuration *config, std::string_view json) {
498 FlatbufferDetachedBuffer<Configuration> addition =
499 JsonToFlatbuffer(json, Configuration::MiniReflectTypeTable());
500
Brian Silverman24f5aa82020-06-23 16:21:28 -0700501 return MergeWithConfig(config, addition);
Austin Schuh8d6cea82020-02-28 12:17:16 -0800502}
503
James Kuszmaul3ae42262019-11-08 12:33:41 -0800504const Channel *GetChannel(const Configuration *config, std::string_view name,
505 std::string_view type,
Austin Schuhbca6cf02019-12-22 17:28:34 -0800506 std::string_view application_name, const Node *node) {
507 const std::string_view original_name = name;
Austin Schuhf1fff282020-03-28 16:57:32 -0700508 std::string mutable_name;
Austin Schuhcb108412019-10-13 16:09:54 -0700509 VLOG(1) << "Looking up { \"name\": \"" << name << "\", \"type\": \"" << type
510 << "\" }";
511
512 // First handle application specific maps. Only do this if we have a matching
513 // application name, and it has maps.
Austin Schuh40485ed2019-10-26 21:51:44 -0700514 if (config->has_applications()) {
515 auto application_iterator = std::lower_bound(
516 config->applications()->cbegin(), config->applications()->cend(),
517 application_name, CompareApplications);
518 if (application_iterator != config->applications()->cend() &&
Austin Schuhcb108412019-10-13 16:09:54 -0700519 EqualsApplications(*application_iterator, application_name)) {
520 if (application_iterator->has_maps()) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700521 mutable_name = std::string(name);
522 HandleMaps(application_iterator->maps(), &mutable_name, type, node);
523 name = std::string_view(mutable_name);
Austin Schuhcb108412019-10-13 16:09:54 -0700524 }
525 }
526 }
527
528 // Now do global maps.
Austin Schuh40485ed2019-10-26 21:51:44 -0700529 if (config->has_maps()) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700530 mutable_name = std::string(name);
531 HandleMaps(config->maps(), &mutable_name, type, node);
532 name = std::string_view(mutable_name);
Austin Schuhcb108412019-10-13 16:09:54 -0700533 }
534
Austin Schuhbca6cf02019-12-22 17:28:34 -0800535 if (original_name != name) {
536 VLOG(1) << "Remapped to { \"name\": \"" << name << "\", \"type\": \""
537 << type << "\" }";
538 }
Alex Perrycb7da4b2019-08-28 19:35:56 -0700539
Austin Schuh40485ed2019-10-26 21:51:44 -0700540 // Then look for the channel.
541 auto channel_iterator =
Austin Schuhf1fff282020-03-28 16:57:32 -0700542 std::lower_bound(config->channels()->cbegin(), config->channels()->cend(),
Austin Schuh40485ed2019-10-26 21:51:44 -0700543 std::make_pair(name, type), CompareChannels);
Austin Schuhcb108412019-10-13 16:09:54 -0700544
545 // Make sure we actually found it, and it matches.
Austin Schuh40485ed2019-10-26 21:51:44 -0700546 if (channel_iterator != config->channels()->cend() &&
547 EqualsChannels(*channel_iterator, std::make_pair(name, type))) {
Austin Schuhbca6cf02019-12-22 17:28:34 -0800548 if (VLOG_IS_ON(2)) {
549 VLOG(2) << "Found: " << FlatbufferToJson(*channel_iterator);
550 } else if (VLOG_IS_ON(1)) {
551 VLOG(1) << "Found: " << CleanedChannelToString(*channel_iterator);
552 }
Austin Schuh40485ed2019-10-26 21:51:44 -0700553 return *channel_iterator;
Austin Schuhcb108412019-10-13 16:09:54 -0700554 } else {
555 VLOG(1) << "No match for { \"name\": \"" << name << "\", \"type\": \""
556 << type << "\" }";
557 return nullptr;
558 }
559}
560
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800561size_t ChannelIndex(const Configuration *configuration,
562 const Channel *channel) {
563 CHECK(configuration->channels() != nullptr) << ": No channels";
564
565 auto c = std::find(configuration->channels()->begin(),
566 configuration->channels()->end(), channel);
567 CHECK(c != configuration->channels()->end())
568 << ": Channel pointer not found in configuration()->channels()";
569
570 return std::distance(configuration->channels()->begin(), c);
571}
572
Austin Schuhbca6cf02019-12-22 17:28:34 -0800573std::string CleanedChannelToString(const Channel *channel) {
574 FlatbufferDetachedBuffer<Channel> cleaned_channel = CopyFlatBuffer(channel);
575 cleaned_channel.mutable_message()->clear_schema();
576 return FlatbufferToJson(cleaned_channel);
577}
578
Austin Schuha81454b2020-05-12 19:58:36 -0700579std::string StrippedChannelToString(const Channel *channel) {
580 return absl::StrCat("{ \"name\": \"", channel->name()->string_view(),
581 "\", \"type\": \"", channel->type()->string_view(),
582 "\" }");
583}
584
Alex Perrycb7da4b2019-08-28 19:35:56 -0700585FlatbufferDetachedBuffer<Configuration> MergeConfiguration(
586 const Flatbuffer<Configuration> &config,
587 const std::vector<aos::FlatbufferString<reflection::Schema>> &schemas) {
588 flatbuffers::FlatBufferBuilder fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800589 fbb.ForceDefaults(true);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700590
591 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Channel>>>
592 channels_offset;
593 if (config.message().has_channels()) {
594 std::vector<flatbuffers::Offset<Channel>> channel_offsets;
595 for (const Channel *c : *config.message().channels()) {
596 flatbuffers::FlatBufferBuilder channel_fbb;
Austin Schuhd7b15da2020-02-17 15:06:11 -0800597 channel_fbb.ForceDefaults(true);
Alex Perrycb7da4b2019-08-28 19:35:56 -0700598
599 // Search for a schema with a matching type.
600 const aos::FlatbufferString<reflection::Schema> *found_schema = nullptr;
Austin Schuhf1fff282020-03-28 16:57:32 -0700601 for (const aos::FlatbufferString<reflection::Schema> &schema : schemas) {
Alex Perrycb7da4b2019-08-28 19:35:56 -0700602 if (schema.message().root_table() != nullptr) {
603 if (schema.message().root_table()->name()->string_view() ==
604 c->type()->string_view()) {
605 found_schema = &schema;
606 }
607 }
608 }
609
610 CHECK(found_schema != nullptr)
611 << ": Failed to find schema for " << FlatbufferToJson(c);
612
613 // The following is wasteful, but works.
614 //
615 // Copy it into a Channel object by creating an object with only the
616 // schema populated and merge that into the current channel.
617 flatbuffers::Offset<reflection::Schema> schema_offset =
618 CopyFlatBuffer<reflection::Schema>(&found_schema->message(),
619 &channel_fbb);
620 Channel::Builder channel_builder(channel_fbb);
621 channel_builder.add_schema(schema_offset);
622 channel_fbb.Finish(channel_builder.Finish());
623 FlatbufferDetachedBuffer<Channel> channel_schema_flatbuffer(
624 channel_fbb.Release());
625
626 FlatbufferDetachedBuffer<Channel> merged_channel(
627 MergeFlatBuffers(channel_schema_flatbuffer, CopyFlatBuffer(c)));
628
629 channel_offsets.emplace_back(
630 CopyFlatBuffer<Channel>(&merged_channel.message(), &fbb));
631 }
632 channels_offset = fbb.CreateVector(channel_offsets);
633 }
634
635 // Copy the applications and maps unmodified.
636 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Application>>>
637 applications_offset;
638 {
639 ::std::vector<flatbuffers::Offset<Application>> applications_offsets;
640 if (config.message().has_applications()) {
641 for (const Application *a : *config.message().applications()) {
642 applications_offsets.emplace_back(CopyFlatBuffer<Application>(a, &fbb));
643 }
644 }
645 applications_offset = fbb.CreateVector(applications_offsets);
646 }
647
648 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Map>>>
649 maps_offset;
650 {
651 ::std::vector<flatbuffers::Offset<Map>> map_offsets;
652 if (config.message().has_maps()) {
653 for (const Map *m : *config.message().maps()) {
654 map_offsets.emplace_back(CopyFlatBuffer<Map>(m, &fbb));
655 }
656 maps_offset = fbb.CreateVector(map_offsets);
657 }
658 }
659
Austin Schuh217a9782019-12-21 23:02:50 -0800660 flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Node>>>
661 nodes_offset;
662 {
663 ::std::vector<flatbuffers::Offset<Node>> node_offsets;
664 if (config.message().has_nodes()) {
665 for (const Node *n : *config.message().nodes()) {
666 node_offsets.emplace_back(CopyFlatBuffer<Node>(n, &fbb));
667 }
668 nodes_offset = fbb.CreateVector(node_offsets);
669 }
670 }
671
672 // Now insert everything else in unmodified.
Alex Perrycb7da4b2019-08-28 19:35:56 -0700673 ConfigurationBuilder configuration_builder(fbb);
674 if (config.message().has_channels()) {
675 configuration_builder.add_channels(channels_offset);
676 }
677 if (config.message().has_maps()) {
678 configuration_builder.add_maps(maps_offset);
679 }
680 if (config.message().has_applications()) {
681 configuration_builder.add_applications(applications_offset);
682 }
Austin Schuh217a9782019-12-21 23:02:50 -0800683 if (config.message().has_nodes()) {
684 configuration_builder.add_nodes(nodes_offset);
685 }
Alex Perrycb7da4b2019-08-28 19:35:56 -0700686
687 fbb.Finish(configuration_builder.Finish());
688 return fbb.Release();
689}
690
Austin Schuh217a9782019-12-21 23:02:50 -0800691const Node *GetNodeFromHostname(const Configuration *config,
692 std::string_view hostname) {
693 for (const Node *node : *config->nodes()) {
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800694 if (node->has_hostname() && node->hostname()->string_view() == hostname) {
Austin Schuh217a9782019-12-21 23:02:50 -0800695 return node;
696 }
Brian Silvermanaa2633f2020-02-17 21:04:14 -0800697 if (node->has_hostnames()) {
698 for (const auto &candidate : *node->hostnames()) {
699 if (candidate->string_view() == hostname) {
700 return node;
701 }
702 }
703 }
Austin Schuh217a9782019-12-21 23:02:50 -0800704 }
705 return nullptr;
706}
Austin Schuhac0771c2020-01-07 18:36:30 -0800707
Austin Schuh217a9782019-12-21 23:02:50 -0800708const Node *GetMyNode(const Configuration *config) {
709 const std::string hostname = (FLAGS_override_hostname.size() > 0)
710 ? FLAGS_override_hostname
711 : network::GetHostname();
712 const Node *node = GetNodeFromHostname(config, hostname);
713 if (node != nullptr) return node;
714
715 LOG(FATAL) << "Unknown node for host: " << hostname
716 << ". Consider using --override_hostname if hostname detection "
717 "is wrong.";
718 return nullptr;
719}
720
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800721const Node *GetNode(const Configuration *config, const Node *node) {
722 if (!MultiNode(config)) {
723 CHECK(node == nullptr) << ": Provided a node in a single node world.";
724 return nullptr;
725 } else {
726 CHECK(node != nullptr);
727 CHECK(node->has_name());
728 return GetNode(config, node->name()->string_view());
729 }
730}
731
Austin Schuh217a9782019-12-21 23:02:50 -0800732const Node *GetNode(const Configuration *config, std::string_view name) {
Austin Schuhfd960622020-01-01 13:22:55 -0800733 CHECK(config->has_nodes())
734 << ": Asking for a node from a single node configuration.";
Austin Schuh217a9782019-12-21 23:02:50 -0800735 for (const Node *node : *config->nodes()) {
Austin Schuhfd960622020-01-01 13:22:55 -0800736 CHECK(node->has_name()) << ": Malformed node " << FlatbufferToJson(node);
Austin Schuh217a9782019-12-21 23:02:50 -0800737 if (node->name()->string_view() == name) {
738 return node;
739 }
740 }
741 return nullptr;
742}
743
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800744const Node *GetNodeOrDie(const Configuration *config, const Node *node) {
745 if (!MultiNode(config)) {
746 CHECK(node == nullptr) << ": Provided a node in a single node world.";
747 return nullptr;
748 } else {
749 const Node *config_node = GetNode(config, node);
750 if (config_node == nullptr) {
751 LOG(FATAL) << "Couldn't find node matching " << FlatbufferToJson(node);
752 }
753 return config_node;
754 }
755}
756
Austin Schuh8bd96322020-02-13 21:18:22 -0800757namespace {
758int GetNodeIndexFromConfig(const Configuration *config, const Node *node) {
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800759 int node_index = 0;
760 for (const Node *iterated_node : *config->nodes()) {
761 if (iterated_node == node) {
762 return node_index;
763 }
764 ++node_index;
765 }
Austin Schuh8bd96322020-02-13 21:18:22 -0800766 return -1;
767}
768} // namespace
769
770int GetNodeIndex(const Configuration *config, const Node *node) {
771 if (!MultiNode(config)) {
772 return 0;
773 }
774
775 {
776 int node_index = GetNodeIndexFromConfig(config, node);
777 if (node_index != -1) {
778 return node_index;
779 }
780 }
781
782 const Node *result = GetNode(config, node);
783 CHECK(result != nullptr);
784
785 {
Austin Schuh04408fc2020-02-16 21:48:54 -0800786 int node_index = GetNodeIndexFromConfig(config, result);
Austin Schuh8bd96322020-02-13 21:18:22 -0800787 if (node_index != -1) {
788 return node_index;
789 }
790 }
791
792 LOG(FATAL) << "Node " << FlatbufferToJson(node)
793 << " not found in the configuration.";
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800794}
795
Austin Schuh04408fc2020-02-16 21:48:54 -0800796int GetNodeIndex(const Configuration *config, std::string_view name) {
797 if (!MultiNode(config)) {
798 return 0;
799 }
800
801 {
802 int node_index = 0;
803 for (const Node *iterated_node : *config->nodes()) {
804 if (iterated_node->name()->string_view() == name) {
805 return node_index;
806 }
807 ++node_index;
808 }
809 }
810 LOG(FATAL) << "Node " << name << " not found in the configuration.";
811}
812
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800813std::vector<const Node *> GetNodes(const Configuration *config) {
814 std::vector<const Node *> nodes;
Austin Schuh8bd96322020-02-13 21:18:22 -0800815 if (MultiNode(config)) {
Austin Schuhc9e10ec2020-01-26 16:08:28 -0800816 for (const Node *node : *config->nodes()) {
817 nodes.emplace_back(node);
818 }
819 } else {
820 nodes.emplace_back(nullptr);
821 }
822 return nodes;
823}
824
Austin Schuhac0771c2020-01-07 18:36:30 -0800825bool MultiNode(const Configuration *config) { return config->has_nodes(); }
826
Austin Schuh217a9782019-12-21 23:02:50 -0800827bool ChannelIsSendableOnNode(const Channel *channel, const Node *node) {
Austin Schuhca4828c2019-12-28 14:21:35 -0800828 if (node == nullptr) {
829 return true;
830 }
Austin Schuh196a4452020-03-15 23:12:03 -0700831 return (CHECK_NOTNULL(channel)->source_node()->string_view() ==
832 node->name()->string_view());
Austin Schuh217a9782019-12-21 23:02:50 -0800833}
834
835bool ChannelIsReadableOnNode(const Channel *channel, const Node *node) {
Austin Schuhca4828c2019-12-28 14:21:35 -0800836 if (node == nullptr) {
837 return true;
838 }
839
Austin Schuh217a9782019-12-21 23:02:50 -0800840 if (channel->source_node()->string_view() == node->name()->string_view()) {
841 return true;
842 }
843
844 if (!channel->has_destination_nodes()) {
845 return false;
846 }
847
Austin Schuh719946b2019-12-28 14:51:01 -0800848 for (const Connection *connection : *channel->destination_nodes()) {
849 CHECK(connection->has_name());
850 if (connection->name()->string_view() == node->name()->string_view()) {
Austin Schuh217a9782019-12-21 23:02:50 -0800851 return true;
852 }
853 }
854
855 return false;
856}
857
Austin Schuh719946b2019-12-28 14:51:01 -0800858bool ChannelMessageIsLoggedOnNode(const Channel *channel, const Node *node) {
Austin Schuhf1fff282020-03-28 16:57:32 -0700859 switch (channel->logger()) {
Austin Schuh719946b2019-12-28 14:51:01 -0800860 case LoggerConfig::LOCAL_LOGGER:
861 if (node == nullptr) {
862 // Single node world. If there is a local logger, then we want to use
863 // it.
864 return true;
865 }
866 return channel->source_node()->string_view() ==
867 node->name()->string_view();
Austin Schuh719946b2019-12-28 14:51:01 -0800868 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700869 CHECK(channel->has_logger_nodes());
870 CHECK_GT(channel->logger_nodes()->size(), 0u);
Austin Schuh719946b2019-12-28 14:51:01 -0800871
872 if (channel->source_node()->string_view() ==
873 CHECK_NOTNULL(node)->name()->string_view()) {
874 return true;
875 }
Austin Schuhda40e472020-03-28 15:15:29 -0700876
877 [[fallthrough]];
878 case LoggerConfig::REMOTE_LOGGER:
879 CHECK(channel->has_logger_nodes());
880 CHECK_GT(channel->logger_nodes()->size(), 0u);
881 for (const flatbuffers::String *logger_node : *channel->logger_nodes()) {
882 if (logger_node->string_view() ==
883 CHECK_NOTNULL(node)->name()->string_view()) {
884 return true;
885 }
Austin Schuh719946b2019-12-28 14:51:01 -0800886 }
887
888 return false;
889 case LoggerConfig::NOT_LOGGED:
890 return false;
891 }
892
893 LOG(FATAL) << "Unknown logger config " << static_cast<int>(channel->logger());
894}
895
896const Connection *ConnectionToNode(const Channel *channel, const Node *node) {
897 if (!channel->has_destination_nodes()) {
898 return nullptr;
899 }
900 for (const Connection *connection : *channel->destination_nodes()) {
901 if (connection->name()->string_view() == node->name()->string_view()) {
902 return connection;
903 }
904 }
905 return nullptr;
906}
907
908bool ConnectionDeliveryTimeIsLoggedOnNode(const Channel *channel,
909 const Node *node,
910 const Node *logger_node) {
911 const Connection *connection = ConnectionToNode(channel, node);
912 if (connection == nullptr) {
913 return false;
914 }
915 return ConnectionDeliveryTimeIsLoggedOnNode(connection, logger_node);
916}
917
918bool ConnectionDeliveryTimeIsLoggedOnNode(const Connection *connection,
919 const Node *node) {
920 switch (connection->timestamp_logger()) {
921 case LoggerConfig::LOCAL_AND_REMOTE_LOGGER:
Austin Schuhda40e472020-03-28 15:15:29 -0700922 CHECK(connection->has_timestamp_logger_nodes());
923 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
Austin Schuh719946b2019-12-28 14:51:01 -0800924 if (connection->name()->string_view() == node->name()->string_view()) {
925 return true;
926 }
927
Austin Schuhda40e472020-03-28 15:15:29 -0700928 [[fallthrough]];
929 case LoggerConfig::REMOTE_LOGGER:
930 CHECK(connection->has_timestamp_logger_nodes());
931 CHECK_GT(connection->timestamp_logger_nodes()->size(), 0u);
932 for (const flatbuffers::String *timestamp_logger_node :
933 *connection->timestamp_logger_nodes()) {
934 if (timestamp_logger_node->string_view() ==
935 node->name()->string_view()) {
936 return true;
937 }
Austin Schuh719946b2019-12-28 14:51:01 -0800938 }
939
940 return false;
941 case LoggerConfig::LOCAL_LOGGER:
942 return connection->name()->string_view() == node->name()->string_view();
Austin Schuh719946b2019-12-28 14:51:01 -0800943 case LoggerConfig::NOT_LOGGED:
944 return false;
945 }
946
947 LOG(FATAL) << "Unknown logger config "
948 << static_cast<int>(connection->timestamp_logger());
949}
950
Austin Schuhe84c3ed2019-12-14 15:29:48 -0800951std::vector<std::string_view> SourceNodeNames(const Configuration *config,
952 const Node *my_node) {
953 std::set<std::string_view> result_set;
954
955 for (const Channel *channel : *config->channels()) {
956 if (channel->has_destination_nodes()) {
957 for (const Connection *connection : *channel->destination_nodes()) {
958 if (connection->name()->string_view() ==
959 my_node->name()->string_view()) {
960 result_set.insert(channel->source_node()->string_view());
961 }
962 }
963 }
964 }
965
966 std::vector<std::string_view> result;
967 for (const std::string_view source : result_set) {
968 VLOG(1) << "Found a source node of " << source;
969 result.emplace_back(source);
970 }
971 return result;
972}
973
974std::vector<std::string_view> DestinationNodeNames(const Configuration *config,
975 const Node *my_node) {
976 std::vector<std::string_view> result;
977
978 for (const Channel *channel : *config->channels()) {
979 if (channel->has_source_node() && channel->source_node()->string_view() ==
980 my_node->name()->string_view()) {
981 if (!channel->has_destination_nodes()) continue;
982
983 if (channel->source_node()->string_view() !=
984 my_node->name()->string_view()) {
985 continue;
986 }
987
988 for (const Connection *connection : *channel->destination_nodes()) {
989 if (std::find(result.begin(), result.end(),
990 connection->name()->string_view()) == result.end()) {
991 result.emplace_back(connection->name()->string_view());
992 }
993 }
994 }
995 }
996
997 for (const std::string_view destination : result) {
998 VLOG(1) << "Found a destination node of " << destination;
999 }
1000 return result;
1001}
1002
Brian Silverman66f079a2013-08-26 16:24:30 -07001003} // namespace configuration
1004} // namespace aos