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