summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-09-29peerd: build on non-Linux hostsHEADmasterScott James Remnant
BUG=24073089 TEST=mm on Mac host Change-Id: I623379da12a0601343a4ba8c79cea4197d20979a
2015-08-21Rename .dbus.xml files to .dbus-xmlChristopher Wiley
Bug: 23380180 Change-Id: I92fbca4baaedf0e43b8b2de79a0792015c19571d
2015-08-21Make peerd compile on BrilloAlex Vakulenko
Added Android.mk and made necessary changes to compile peerd on Brillo BUG: 22827642 Change-Id: Iacaeed72f81b145e9a1db3f57c8d55c155b36794
2015-08-21Revert "Make peerd compile on Brillo"Alex Vakulenko
This reverts commit a7831af70009ef3ef544f13a69b6d15bc915ab1a. Change-Id: I4a535b55a8e72c3a6b1a75449fe75c1af427abe6
2015-08-20Make peerd compile on BrilloAlex Vakulenko
Added Android.mk and made necessary changes to compile peerd on Brillo BUG: 22827642 Change-Id: Icf53771ed886bf9d33a8b3ae553e1b38ea5d13b3
2015-08-20peerd: Generate proxy library during compilationChristopher Wiley
For now, this will just include the headers we generate as part of proxy generation. We'll hide this detail from consumers with the included pkg-config file. BUG=chromium:516514 TEST=Compiled buffet/brdebug that consumed this change, and it worked. Change-Id: I3f9c6511f2ad09ca4ec9832ac3f360a9eab3bd0a Reviewed-on: https://chromium-review.googlesource.com/290550 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-08-05Import peerd/ from the chromiumos platform2 repoRobert Ginda
Copy the unchanged source tree from the peerd/ directory of https://chromium.googlesource.com/chromiumos/platform2 At the time, platform2 master was: 14764a942acd7bc4d771745384026e1258e12bae and the most recent commit to the peerd directory was: 744028ba22ada35a82534586b02880fc2ce4f151 Bug: 22979013
2015-07-31Initial empty repositoryBill Yi
2015-05-23platform2: Enforce virtual destructors on base classesAlex Vakulenko
There have been a number of memory leak issues due to absence of virtual destructors on base classes. Swept through the following targets: buffet, libchromeos, webserver. For every class defined, I did one of the following three things: 1. If the class is not meant to be derived from, marked it as 'final'. 2. If classes derived from a particular base class are not meant to be deleted through the base class, marked the base class's destructor as 'protected'. 3. Otherwise made the base class's destructor virtual. BUG=None TEST=`FEATURES=test emerge-link libchromeos webserver buffet` Change-Id: I4d909399896d025c39980c9546b79b145614fc47 Reviewed-on: https://chromium-review.googlesource.com/273000 Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
2015-04-03platform2: Explicitly use base:: namespace with CommandLineAlex Vakulenko
The current revision of libchrome is removing CommandLine class from global namespace and only retain the one in base::. Sweep the code to use the correct namespace in anticpation of libchrome revision roll. BUG=None TEST=./build_packages Change-Id: Ib7ca448dac1204c1e36ab053e775a5a5214997ac Reviewed-on: https://chromium-review.googlesource.com/263785 Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Alex Deymo <deymo@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2015-04-01peerd: Add PeerId field to dbus Service objectsChristopher Wiley
BUG=brillo:683 TEST=unittests, peerd tests continue to pass Change-Id: Ib667a5a0fd2aba25781b02458ab8a2629046cc40 Reviewed-on: https://chromium-review.googlesource.com/262768 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-03-26peerd: Destroy manager before mainloop completely exitsChristopher Wiley
This gives the manager time to unregister DBus watches related to monitoring remote connection health. This prevents a crash on shutdown inside bus.cc when a DCHECK that all watches are removed fails. BUG=brillo:670 TEST=start/stop peerd, observe no crash Change-Id: I5b102b9190cd39e725b034dacd79a1e81ff03e4f Reviewed-on: https://chromium-review.googlesource.com/262438 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-03-24tendo: Fix pre-cq configsChristopher Wiley
The previous configs weren't parsing. The default config gets us no meaningful test coverage. This is better than nothing. BUG=chromium:467939 TEST=None Change-Id: Iefd072f35011f17083a7239ce497803834d064d5 Reviewed-on: https://chromium-review.googlesource.com/262083 Reviewed-by: Aviv Keshet <akeshet@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2015-03-18privetd: Remove context="default" deny ruleVitaly Buka
The default D-Bus policy is to deny method calls, but allow signals and replies. Adding clauses to block messages sent to a daemon has the perverse side effect of blocking signals and message replies unless explicitly noted otherwise in the firewall config. This breaks certain interfaces, for instance, the signals that make object manager and property interfaces work. BUG=brillo:571,brillo:572 TEST=manual, register device using privet and check is privet/info has "online" in gcd.status. Change-Id: I82604ef2b755fda28d8e54984f67380072fb3aa3 Reviewed-on: https://chromium-review.googlesource.com/260301 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org>
2015-03-13libchromeos: Replace char with std::string in string_utils APIVitaly Buka
std::string version of functions is enough to cover char use cases. C library was replaced with STL in Split and SplitAtFirst implementations. Added support of splitting by empty string. Uses but reasonable implementation is simple. BUG=none TEST=unittests Change-Id: I0778722d31a7b06eea2227b4d94991ab194195cb Reviewed-on: https://chromium-review.googlesource.com/258640 Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org>
2015-03-10tendo: Add leaderd/peerd/privetd COMMIT-QUEUE.ini filesChristopher Wiley
These restrict the set of boards we test against to some reasonable boards to get more specific test coverage. BUG=brillo:521 TEST=trybots pass for: amd64-generic-no-vmtest-pre-cq arm-generic-no-vmtest-pre-cq gizmo-pre-cq storm-no-vmtest-pre-cq x86-generic-no-vmtest-pre-cq Change-Id: I800388709c253130011e5345b7682fd9b4edc3c7 Reviewed-on: https://chromium-review.googlesource.com/257111 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Aviv Keshet <akeshet@chromium.org>
2015-02-25peerd: Update existing services rather than recreating themChristopher Wiley
BUG=brillo:14 TEST=Existing integration tests pass. Added more unittests. Change-Id: Ia086b77a1093544fc72a59f64f51cd2069aff5a7 Reviewed-on: https://chromium-review.googlesource.com/253120 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-02-25peerd: Don't use service tokensChristopher Wiley
Remove service tokens from the peerd API in favor of relying on a combination of service IDs and remote DBus connection identifiers. Also allow clients to call ExposeService on previously exposed services, treating following calls as updates rather than errors. This simplifies client implementations dramatically by allowing them to be agnostic to the previous state of their service. To do this, expose the connection_name in libchromeos's DBusServiceWatcher. BUG=brillo:290 TEST=unittests, tendo_experimental suite passes against this change. CQ-DEPEND=CL:252322 Change-Id: I5582223af4c4f54fd6ac7cdde89b28d02953b761 Reviewed-on: https://chromium-review.googlesource.com/252482 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-02-25peerd: Use D-Bus codegen to create correct handler for ExposeServiceAlex Vakulenko
Use the new annotation to mark ExposeService as a handler that takes the raw D-Bus message which it can then use to extract the sender's unique name. BUG=brillo:346 TEST=`FEATURES=test emerge-link peerd` Change-Id: I176864f347eae7b39201bf23f1eadbcc7bbd52f5 Reviewed-on: https://chromium-review.googlesource.com/252322 Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2015-02-21peerd: Remove exposed services on death.Christopher Wiley
Package the logic to add and remove watches on the Bus into a reuseable DBusServiceWatcher so that we can duplicate this effort for requests to monitor technologies. BUG=brillo:13 TEST=unittests, added a new unittest, and added an integration test peerd_MonitorsDBusConnections. Change-Id: I763e6ebce1b0fb78eaa49e733dab25287e33d684 Reviewed-on: https://chromium-review.googlesource.com/251152 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-02-20peerd: Make ExposeService a raw handlerChristopher Wiley
This allows us to grab the sender of the message. We'll use this later to watch for the death of the sender, and remove services exposed by that sender. BUG=brillo:13 TEST=peerd_* tests continue to pass. Change-Id: If2dbd50a5e3cb66618e489c51a1f789412bd1475 Reviewed-on: https://chromium-review.googlesource.com/250673 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-01-23peerd: Reject adding duplicate service ids to a peerChristopher Wiley
This has the effect that multiple calls to ExposeService with the same service ID will be rejected, rather than crashing peerd. BUG=chromium:451142 TEST=unittests, added a new unittest Change-Id: I3a0b64b2205b62db6c92f10aaa00be98fb465600 Reviewed-on: https://chromium-review.googlesource.com/242600 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2015-01-16peerd: ExposeService mdns port parsingDave Tapuska
Allow the mdns.port to be specified as various types that are compatible with integer. This allows the chrome dbus bindings that write it out as a int32_t to work correctly. BUG=chromium:441329 TEST=manual Change-Id: Idc9f15a160417b7c7e20b2f5afabcbe4c6e09413 Reviewed-on: https://chromium-review.googlesource.com/240741 Reviewed-by: Christopher Wiley <wiley@chromium.org> Tested-by: David Tapuska <dtapuska@chromium.org> Commit-Queue: David Tapuska <dtapuska@chromium.org>
2014-12-15Update libchrome to r307740 and fix build errorsAlex Vakulenko
Updated libchrome, libchrome_crypto, metrics, feedback to the latest revisions from Chrome (r307740). Fixed build breaks due to the changes in upstream code: - scope_ptr no longer needs explicit PassAs<T>() calls. - scope_ptr<T> no longer has implicit conversion to T*. Must use scope_ptr<T>::get() instead. - base/file_util.h moved to base/files/file_util.h - ARRAYSIZE_UNSAFE() removed in favor of arraysize() - base::AppendToFile() and base::WriteFileDescriptor() now return bool instead of the number of bytes written. - dbus::Bus::AddFilterFunction() now returns void. - C++11 features are enabled in libchromeos, so all targets linking with it now have to support C++11 - OVERRIDE macro is removed in favor of native C++11 'override' keyword. BUG=chromium:416628, chromium:411508 TEST=Build the world on x86, x64, ARM. The following builders were tried: x86-generic-full amd64-generic-full arm-generic-full amd64-generic-asan daisy-full nyan-full pre-cq-group daisy-release-group sandybridge-release-group pineview-release-group CQ-DEPEND=CL:234450,CL:234980 Change-Id: I374bebe2211d533c4431c82efb8be1cdcb1f405d Reviewed-on: https://chromium-review.googlesource.com/234440 Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2014-12-04peerd: Generate D-Bus proxies from AvahiAlex Vakulenko
Generate D-Bus proxies from Avahi instead. A follow-up CL will be for switching to using the proxies instead of calling Avahi manually. BUG=chromium:438685 TEST=FEATURES=test emerge-link peerd Change-Id: I41a2c428c81c95f9077a044264578d2f3663bc48 Reviewed-on: https://chromium-review.googlesource.com/232866 Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2014-12-03peerd: Expose ObjectManager/properties from peerd to clientsAlex Vakulenko
Exposed the ObjectManager from peerd which also makes the D-Bus properties to work on peerd objects. Cleaned up unused dbus constants since they are provided by the code generator. BUG=chromium:438652 TEST=FEATURES=test emerge-link peerd CQ-DEPEND=CL:232883 Change-Id: If13b5dd93f979889e25c2d8cae9904350d03e92e Reviewed-on: https://chromium-review.googlesource.com/232862 Reviewed-by: Christopher Wiley <wiley@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2014-11-27peerd: Grant peerd group access to peerd DBus API.Vitaly Buka
In future changes I am going to put privetd into peerd group. Similar approach is used for chromium:434766. BUG=chromium:437071 TEST=None Change-Id: Iac1770ac9ac999fcfa1930c84df53eca84f30a2f Reviewed-on: https://chromium-review.googlesource.com/232130 Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org> Tested-by: Vitaly Buka <vitalybuka@chromium.org>
2014-11-27chromeos-dbus-bindings: Use object path and service name in generated codeAlex Vakulenko
To eliminate unnecessary dependencies on string constants from D-Bus service providers, allow generated proxies extract fixed object paths from the 'name' attribute of <node> in the XML file (if available) and be able to pass in additional the D-Bus service configuration parameters (such as D-Bus service name) as input to the generator, so that the proxy code knows these values too and the caller doesn't have to provide this information. With these changes the object path and/or service names become embedded into the generated proxies and are no longer required to be provided as parameters to the constructors. If there are multiple instances of D-Bus objects with the same interface are available (or the object could appear at different bus paths), the path cannot be embedded into the proxy and must still be provided in the constructor of the generated class. The service config can now be provided in --service-config=... argument to the generator which is expected to be a JSON file. If the service name it is not specified, the generated proxy code will require this parameter in the constructor call, as before. Also updated other targets that use the proxy generator to follow the new constructor syntax (buffet, peerd, privetd). BUG=chromium:431737 TEST=FEATURES=test emerge-link chromeos-dbus-bindings peerd buffet privetd Change-Id: I4bb8387a9b21b75e3508fa13d14b79fbe653c929 Reviewed-on: https://chromium-review.googlesource.com/231920 Reviewed-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org>
2014-11-26peerd: Use generated DBus bindingsChristopher Wiley
BUG=chromium:435773 TEST=integration tests, unittests continue to pass. Change-Id: Iabaf747d9d22665b367402d2afb377fe7e8576a4 Reviewed-on: https://chromium-review.googlesource.com/231716 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-11-12Include the implemented header first in all projects.Alex Deymo
The Google C++ style guide dictates that foo.cc and foo_unittest.cc should include foo.h in the first place, so missing headers in foo.h are detected with a compile error of the module implementing them and not when another module uses them. This CL sweeps across all the .cc file in platform2 enforcing this. BUG=None TEST=cbuildbot amd64-generic Change-Id: I41835835caba13f54c3c844ecf552eb0e47efa9d Reviewed-on: https://chromium-review.googlesource.com/228894 Tested-by: Alex Deymo <deymo@chromium.org> Reviewed-by: Alex Deymo <deymo@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
2014-11-12libchromeos: Add error location informaion to chromeos::ErrorAlex Vakulenko
The error information logged always appears to come from error.cc file in libchormeos since that's where LOG(ERROR) statement is. Added the ability to pass in the actual source of the error by using tracked_objects::Location parameter and "FROM_HERE" macros used in base::TaskRunner-based classes. While all the system log messages looked like this: [ERROR:error.cc(15)] Domain=peerd, Code=service.info, Message=Invalid service key. Now they appear as this: ERROR:service.cc(155)] IsValidServiceInfo(...): Domain=peerd, Code=service.info, Message=Invalid service key. We report the actual source file and line number where the error is coming from, as well as the function name. BUG=None TEST=FEATURES=test emerge-link libchromeos buffet lorgnette peerd privetd Change-Id: I647997c24d61a03f3b481e4c9ca336c90e99e9a3 Reviewed-on: https://chromium-review.googlesource.com/229071 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org>
2014-11-11peerd: Parse remote IP addresses from avahiChristopher Wiley
With this patch, peerd now correctly publishes the IP/port of services discovered on remote peers. This information is exposed via an existing DBus property on the service object. BUG=chromium:425542 TEST=unittests, integration tests Change-Id: I8914416530c79fcae6d80b46fac453a4bc87b499 Reviewed-on: https://chromium-review.googlesource.com/228651 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-11-11peerd: Use optional port in mDNS advertisementsChristopher Wiley
BUG=chromium:425542 TEST=unittests, modified integration tests Change-Id: I76371a6a92e4a60df1793b29f789796b412830f9 Reviewed-on: https://chromium-review.googlesource.com/228301 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-11-11peerd: Add options to Manager.ExposeServiceChristopher Wiley
This allows us to pass optional configuration information that particular technologies may parse for use later. For now, we just pass the port of an IP style service here. BUG=chromium:425542 TEST=unittests, integration tests continue to pass (with patches) Change-Id: If5bc5b97ccc7aa006bea1a32616243b4985d6857 Reviewed-on: https://chromium-review.googlesource.com/228300 Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Christopher Wiley <wiley@chromium.org>
2014-11-11peerd: Correct Manager.StartMonitoring signatureChristopher Wiley
Change the list of technologies to be a list of rather than magic numbers. This is more legible for debugging. Add a dictionary of string to variant values to enable future passing of options to StartMonitoring. Currently we support no options. Add a property org.chromium.peerd.Manager.MonitoredTechnologies that exposes of a list of the supported technologies we're currently monitoring for peers to interested parties. BUG=chromium:430185 TEST=unittests, updated integration tests pass. Change-Id: I593ec8480d11c290c5a3e37670f849b24c289715 Reviewed-on: https://chromium-review.googlesource.com/227463 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-11-11libchromeos: Fix DBus data serialization to work with custom typesAlex Vakulenko
The previous implementation suffered from C++ binding rules for non-dependent names in templates. Template functions such as AppendValueToWriter and PopValueFromReader for template types such as std::vector<T> and std::map<K,V> are limited to the types defined in libchromeos because the implementations calling the inner overloads for types such as T would only select functions defined before the overloads for vector and map are defined. This forced the custom implementations of user-provided types to be included before chromeos/dbus/data_serialization.h and having the code depend on the order of includes is a very dangerous thing. To make the problem worse, generic AppendValueToWriter<T> is always a default fall-back for any unknown types and it simply fails at run-time which makes it very difficult to detect unintended problems. The reason why the generic AppendValueToWriter<T>() was provided is to allow chromeos::Any to contain any C++ type but still be able to use with D-Bus subset of types to implement the D-Bus's VARIANT type. This change addresses the above problems as follows: - The template functionality depending on custom overloads of AppendValueToWriter and PopValueFromReader now call them indirectly through DBusType<T>::Write and DBusType<T>::Read helpers that delay binding to the correct overload of Append... and Pop... until the template instantiation. - Marked the generic AppendValueToWriter<T> and PopValueFromReader<T> as "deleted" functions so the compilation would break as soon as these functions are called with an unsupported types. - Provided IsTypeSupported<T...> type trait to help specialize the implementation for only supported D-Bus types. This allows, for example, specialization of vector<T> to work for supported types T and fail immediately for T that are not supported by D-Bus. - Used IsTypeSupported<T> in chromeos::Any to disable calls to AppendValueToWriter at compile time for unsupported types. - Made AppendValueToWriter() a void function. Now it doesn't fail. The internal implementation inside chromeos::Any uses CHECK() to ensure the contained class which will abort as soon as Any, containing datat of an unsupported type, is being written to D-Bus message buffer. BUG=chromium:431744 TEST=FEATURES=test emerge-link libchromeos attestation buffet peerd Change-Id: I13431f74797b8b92082f172a067ea1515a7aa73e Reviewed-on: https://chromium-review.googlesource.com/228731 Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org>
2014-11-06libchromeos: Add support for async D-Bus method handlersAlex Vakulenko
Changed DBusObject implementation infrastructure in libchromeos to add support for registering asynchronous D-Bus method handlers. Also changed the simple synchronous method handler signature to eliminate the confusion when a handler returning a value throws an error. Currently, there are four kinds of D-Bus method handlers: - SimpleMethodHandler - has one of the following signatures: RetVal Handler(Args... args) void Handler(Args... args) The first one takes only input parameters (by value or const reference) and returns a single value as a function return. The second handler can mix both input (value/const reference) and output (pointer) values. This handler is synchronous (response is sent as soon as the handler returns) and does not provide any error returns (it always succeeds). - SimpleMethodHanderWithError This is similar to SimpleMethodHandler but provides a way to return an error. The handler signature is as follows: bool Handler(ErrorPtr* error, Args... args) The parameters can include both IN and OUT arguments. If the handler succeeds, it must return true. On failures, it returns false and provides error details in |error|. - MethodHandler - a generic (possibly asynchronous) handler that has the following signature: void Handler(scoped_ptr<DBusMethodResponse> response, Args... args) The parameters include only IN arguments and the method sends back any return values using the |response| object. The handler owns the |response| so it can start an asynchronous operation (that holds on to the response) and exit immediately. The D-Bus method response is sent only when the handler provides the reply using the response object. - RawMethodHandler This is the low-level method handler that does not go through any of the parameter/return value parsing. It is provided with the raw method call D-Bus message and is expected to provide the response manually. The handler signtaure is: void Handler(dbus::MethodCall* method_call, ResponseSender sender) This type of handler is useful to implement D-Bus methods with variable number of parameters or those which can accept a number of different types of arguments. BUG=chromium:428390 TEST=FEATURES=test emerge-link libchromeos peerd buffet attestation CQ-DEPEND=CL:227281 Change-Id: I1dde6b279ada9d350a4d0e6743c56d3b12cc38cf Reviewed-on: https://chromium-review.googlesource.com/226666 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org>
2014-11-04peerd: Allow setting the initial mDNS prefix via the commandlineChristopher Wiley
This allows us to test our behavior when we encounter prefix collisions. We need to set this to a known value, because mDNS lets existing services continue to use a conflicting name, and specifies that the newcomer must change their own name. This means to cause a conflict we had to have set up a service with a known prefix before starting peerd. BUG=chromium:426173 TEST=Integration tests validate that this works as intended. Change-Id: Ie3f3d25adf003e33c561b48765e075acb90f18c0 Reviewed-on: https://chromium-review.googlesource.com/226642 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-11-04peerd: Pick a random unique prefix for DNS recordsChristopher Wiley
Repick the prefix if we encounter collisions. BUG=chromium:426173 TEST=Integration tests Change-Id: I1fb94aa65af26bde0b0e79204256614bae262a81 Reviewed-on: https://chromium-review.googlesource.com/226641 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-11-03peerd: Ignore local services in discoveryChristopher Wiley
Previously, we were discovering our own records, since apparently Avahi advertises them back to us. BUG=None TEST=Integration tests pass. peerd can be observed no longer advertising itself. Change-Id: I19ec4722aaf85b34d987ef1403c9a0fdfc35715e Reviewed-on: https://chromium-review.googlesource.com/226631 Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-10-30peerd: Actually set the logging verbosity in init scriptsChristopher Wiley
BUG=None TEST=start peerd PEERD_LOG_LEVEL=2 now increases log verbosity. Change-Id: I95bbc5ac52912346c7d78416bfe24ff323764339 Reviewed-on: https://chromium-review.googlesource.com/226341 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-29peerd: Remove name/note from serbus recordChristopher Wiley
Rather than duplicate book keeping between Privet and Serbus, for friendly names/notes, just rely on privet. BUG=chromium:425535 TEST=unittests, integration tests continue to pass. Change-Id: If6c88ff22949fa6c121ff4f99de2d0af01438d85 Reviewed-on: https://chromium-review.googlesource.com/226096 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-28peerd: Start as the peerd userChristopher Wiley
TEST=start peerd on a image with a peerd user and this change. BUG=chromium:402672 CQ-DEPEND=CL:225238 Change-Id: Ibe98787f3acdd1e3fdb664a7d328cd96499dda03 Reviewed-on: https://chromium-review.googlesource.com/225290 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Kees Cook <keescook@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-21peerd: Complete service discoveryChristopher Wiley
TEST=An integration test reveals that we can now correctly discover peers across mDNS. BUG=chromium:418736 Change-Id: Ib7fb18fa2eb38b8575a818f0dc3020b0d963b5d4 Reviewed-on: https://chromium-review.googlesource.com/224314 Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-10-21peerd: Add skeleton for AvahiServiceDiscovererChristopher Wiley
This object can discover and log that new services exist, but doesn't do anything with that information yet. BUG=chromium:418736 TEST=A pending integration test proves that this code correctly discovers new serbus records advertised by peers. Unittests verify the lifetime of the AvahiServiceDiscoverer matches expectations. CQ-DEPEND=CL:224312 Change-Id: Ie53574e4cb0f2da74739327b6d95a4e8d3740c5a Reviewed-on: https://chromium-review.googlesource.com/224313 Reviewed-by: Christopher Wiley <wiley@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org> Tested-by: Christopher Wiley <wiley@chromium.org>
2014-10-21peerd: Add constants related to mDNS service discoveryChristopher Wiley
Also move some constants we reuse in a couple different places out of service.h and into constants.h. While there, expose the logic to check if service info is valid. We use this when validating mDNS records. BUG=chromium:418736 TEST=Exiting unittests pass. Change-Id: Idcdf87b76efb4d61387e34cc24d5adb7de4106e4 Reviewed-on: https://chromium-review.googlesource.com/224312 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-21peerd: Actually set peer idsChristopher Wiley
BUG=None TEST=An exiting unittest now makes assertions that initialization works. Change-Id: I9eca4d5d8625742a45e31a0c0a6242bad412dab6 Reviewed-on: https://chromium-review.googlesource.com/224311 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-09peerd: Complete PeerManagerImplChristopher Wiley
PeerManagerInterface instances allow technology specific objects to publish discovered knowledge of peers and their supported services. BUG=chromium:418736 TEST=unittests Change-Id: I62d5a75fd9681bc154adf05924010d2408401e2d Reviewed-on: https://chromium-review.googlesource.com/222431 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-09peerd: Add DiscoveredPeerChristopher Wiley
This object represents a peer we've discovered over one or more technlogies. It has logic to accept or reject updates to itself and child services based on the timestamps and validity of the updates. A PeerManager may have many DiscoveredPeer instances. BUG=chromium:418736 TEST=unittests Change-Id: Iaa8e70c315fe096d6586c2ab2e2acaeda0ce7fe4 Reviewed-on: https://chromium-review.googlesource.com/222430 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
2014-10-09peerd: Allow atomic updates for peers and servicesChristopher Wiley
When we receive advertisements for peers or services on peers we're going to want to decide to discard or accept the advertisement in its entirety. This means validating it before applying it field by field. BUG=chromium:418736 TEST=unittests Change-Id: I89226daef95fab195e7afe39c86175405dedb9ee Reviewed-on: https://chromium-review.googlesource.com/222409 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Alex Vakulenko <avakulenko@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>