network_settings.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_PROTOCOL_NETWORK_SETTINGS_H_
  5. #define REMOTING_PROTOCOL_NETWORK_SETTINGS_H_
  6. #include <stdint.h>
  7. #include "base/time/time.h"
  8. #include "remoting/protocol/port_range.h"
  9. namespace remoting {
  10. namespace protocol {
  11. struct NetworkSettings {
  12. // When hosts are configured with NAT traversal disabled they will
  13. // typically also limit their P2P ports to this range, so that
  14. // sessions may be blocked or un-blocked via firewall rules.
  15. static const uint16_t kDefaultMinPort = 12400;
  16. static const uint16_t kDefaultMaxPort = 12409;
  17. enum Flags {
  18. // Don't use STUN or relay servers. Accept incoming P2P connection
  19. // attempts, but don't initiate any. This ensures that the peer is
  20. // on the same network. Note that connection will always fail if
  21. // both ends use this mode.
  22. NAT_TRAVERSAL_DISABLED = 0x0,
  23. // Allow outgoing connections, even when STUN and RELAY are not enabled.
  24. NAT_TRAVERSAL_OUTGOING = 0x1,
  25. // Active NAT traversal using STUN.
  26. NAT_TRAVERSAL_STUN = 0x2,
  27. // Allow the use of relay servers when a direct connection is not available.
  28. NAT_TRAVERSAL_RELAY = 0x4,
  29. // Active NAT traversal using STUN and relay servers.
  30. NAT_TRAVERSAL_FULL = NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY |
  31. NAT_TRAVERSAL_OUTGOING
  32. };
  33. NetworkSettings() {}
  34. explicit NetworkSettings(uint32_t flags) : flags(flags) {}
  35. uint32_t flags = NAT_TRAVERSAL_DISABLED;
  36. // Range of ports used by P2P sessions.
  37. PortRange port_range;
  38. // ICE Timeout.
  39. base::TimeDelta ice_timeout = base::Seconds(15);
  40. // ICE reconnect attempts.
  41. int ice_reconnect_attempts = 2;
  42. };
  43. } // namespace protocol
  44. } // namespace remoting
  45. #endif // REMOTING_PROTOCOL_NETWORK_SETTINGS_H_