p2p: Use p2p for updates

This is the main patch for enabling use of p2p for consuming and/or
sharing updates via p2p. Refer to the ddoc and other documentation for
how this works.

BUG=chromium:260426,chromium:273110
TEST=New unit tests + unit tests pass + manual testing
Change-Id: I6bc3bddae1e041ccc176969a651396e8e89cb3f0
Reviewed-on: https://chromium-review.googlesource.com/64829
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/constants.h b/constants.h
index e114956..f3e7450 100644
--- a/constants.h
+++ b/constants.h
@@ -26,6 +26,10 @@
 // Path to the stateful partition on the root filesystem.
 extern const char kStatefulPartition[];
 
+// Path to the marker file to allow p2p on interactive update attempts.
+// See utils::IsP2PAllowedForInteractiveChecks().
+extern const char kP2PAllowInteractiveMarkerFile[];
+
 // Constants related to preferences.
 extern const char kPrefsBackoffExpiryTime[];
 extern const char kPrefsCertificateReportToSendDownload[];
@@ -92,12 +96,16 @@
   kNumPayloadTypes
 } PayloadType;
 
-// Maximum number of attempts using p2p.
+// Maximum number of times we'll allow using p2p for the same update payload.
 const int kMaxP2PAttempts = 10;
 
-// Maximum wallclock time we allow attempting to update using p2p -
-// two days.
-const int kMaxP2PAttemptTimeSeconds = 2*24*60*60;
+// Maximum wallclock time we allow attempting to update using p2p for
+// the same update payload - two days.
+const int kMaxP2PAttemptTimeSeconds = 2 * 24 * 60 * 60;
+
+// The maximum amount of time to spend waiting for p2p-client(1) to
+// return while waiting in line to use the LAN - six hours.
+const int kMaxP2PNetworkWaitTimeSeconds = 6 * 60 * 60;
 
 // The maximum number of payload files to keep in /var/cache/p2p.
 const int kMaxP2PFilesToKeep = 3;