| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 namespace protocol { | 14 namespace protocol { |
| 15 | 15 |
| 16 struct NetworkSettings { | 16 struct NetworkSettings { |
| 17 | 17 |
| 18 // When hosts are configured with NAT traversal disabled they will | 18 // When hosts are configured with NAT traversal disabled they will |
| 19 // typically also limit their P2P ports to this range, so that | 19 // typically also limit their P2P ports to this range, so that |
| 20 // sessions may be blocked or un-blocked via firewall rules. | 20 // sessions may be blocked or un-blocked via firewall rules. |
| 21 static const int kDefaultMinPort = 12400; | 21 static const uint16 kDefaultMinPort = 12400; |
| 22 static const int kDefaultMaxPort = 12409; | 22 static const uint16 kDefaultMaxPort = 12409; |
| 23 | 23 |
| 24 enum Flags { | 24 enum Flags { |
| 25 // Don't use STUN or relay servers. Accept incoming P2P connection | 25 // Don't use STUN or relay servers. Accept incoming P2P connection |
| 26 // attempts, but don't initiate any. This ensures that the peer is | 26 // attempts, but don't initiate any. This ensures that the peer is |
| 27 // on the same network. Note that connection will always fail if | 27 // on the same network. Note that connection will always fail if |
| 28 // both ends use this mode. | 28 // both ends use this mode. |
| 29 NAT_TRAVERSAL_DISABLED = 0x0, | 29 NAT_TRAVERSAL_DISABLED = 0x0, |
| 30 | 30 |
| 31 // Allow outgoing connections, even when STUN and RELAY are not enabled. | 31 // Allow outgoing connections, even when STUN and RELAY are not enabled. |
| 32 NAT_TRAVERSAL_OUTGOING = 0x1, | 32 NAT_TRAVERSAL_OUTGOING = 0x1, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 explicit NetworkSettings(uint32 flags) | 53 explicit NetworkSettings(uint32 flags) |
| 54 : flags(flags), | 54 : flags(flags), |
| 55 min_port(0), | 55 min_port(0), |
| 56 max_port(0) { | 56 max_port(0) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Parse string in the form "<min_port>-<max_port>". E.g. "12400-12409". | 59 // Parse string in the form "<min_port>-<max_port>". E.g. "12400-12409". |
| 60 // Returns true if string was parsed successfuly. | 60 // Returns true if string was parsed successfuly. |
| 61 static bool ParsePortRange(const std::string& port_range, | 61 static bool ParsePortRange(const std::string& port_range, |
| 62 int* out_min_port, | 62 uint16* out_min_port, |
| 63 int* out_max_port); | 63 uint16* out_max_port); |
| 64 | 64 |
| 65 uint32 flags; | 65 uint32 flags; |
| 66 | 66 |
| 67 // |min_port| and |max_port| specify range (inclusive) of ports used by | 67 // |min_port| and |max_port| specify range (inclusive) of ports used by |
| 68 // P2P sessions. Any port can be used when both values are set to 0. | 68 // P2P sessions. Any port can be used when both values are set to 0. |
| 69 int min_port; | 69 uint16 min_port; |
| 70 int max_port; | 70 uint16 max_port; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace protocol | 73 } // namespace protocol |
| 74 } // namespace remoting | 74 } // namespace remoting |
| 75 | 75 |
| 76 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_ | 76 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_ |
| OLD | NEW |