Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_JINGLE_GLUE_NETWORK_SETTINGS_H_ | 5 #ifndef REMOTING_JINGLE_GLUE_NETWORK_SETTINGS_H_ |
| 6 #define REMOTING_JINGLE_GLUE_NETWORK_SETTINGS_H_ | 6 #define REMOTING_JINGLE_GLUE_NETWORK_SETTINGS_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 | |
| 8 namespace remoting { | 12 namespace remoting { |
| 9 | 13 |
| 10 struct NetworkSettings { | 14 struct NetworkSettings { |
| 11 | 15 |
| 12 // When hosts are configured with NAT traversal disabled they will | 16 // When hosts are configured with NAT traversal disabled they will |
| 13 // typically also limit their P2P ports to this range, so that | 17 // typically also limit their P2P ports to this range, so that |
| 14 // sessions may be blocked or un-blocked via firewall rules. | 18 // sessions may be blocked or un-blocked via firewall rules. |
| 15 static const int kDefaultMinPort = 12400; | 19 static const int kDefaultMinPort = 12400; |
| 16 static const int kDefaultMaxPort = 12409; | 20 static const int kDefaultMaxPort = 12409; |
| 17 | 21 |
| 18 enum NatTraversalMode { | 22 enum Flags { |
| 19 // Active NAT traversal using STUN and relay servers. | |
| 20 NAT_TRAVERSAL_ENABLED, | |
| 21 | |
| 22 // Don't use STUN or relay servers. Accept incoming P2P connection | 23 // Don't use STUN or relay servers. Accept incoming P2P connection |
| 23 // attempts, but don't initiate any. This ensures that the peer is | 24 // attempts, but don't initiate any. This ensures that the peer is |
| 24 // on the same network. Note that connection will always fail if | 25 // on the same network. Note that connection will always fail if |
| 25 // both ends use this mode. | 26 // both ends use this mode. |
| 26 NAT_TRAVERSAL_DISABLED, | 27 NAT_TRAVERSAL_DISABLED = 0x0, |
| 27 | 28 |
| 28 // Don't use STUN or relay servers but make outgoing connections. | 29 // Allow outgoing connections, even when STUN and RELAY are not enabled. |
| 29 NAT_TRAVERSAL_OUTGOING, | 30 NAT_TRAVERSAL_OUTGOING = 0x1, |
| 31 | |
| 32 // Active NAT traversal using STUN. | |
| 33 NAT_TRAVERSAL_STUN = 0x1 | NAT_TRAVERSAL_OUTGOING, | |
|
Sergey Ulanov
2014/03/27 19:52:26
this should be 2, not 1.
I'd still prefer separate
dcaiafa
2014/03/27 23:36:21
Ugh! Done.
| |
| 34 | |
| 35 // Allow the use of relay servers when a direct connection is not available. | |
| 36 NAT_TRAVERSAL_RELAY = 0x2 | NAT_TRAVERSAL_OUTGOING, | |
|
Sergey Ulanov
2014/03/27 19:52:26
4
dcaiafa
2014/03/27 23:36:21
Done.
| |
| 37 | |
| 38 // Active NAT traversal using STUN and relay servers. | |
| 39 NAT_TRAVERSAL_FULL = NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY | |
| 30 }; | 40 }; |
| 31 | 41 |
| 32 NetworkSettings() | 42 NetworkSettings() |
| 33 : nat_traversal_mode(NAT_TRAVERSAL_DISABLED), | 43 : flags(NAT_TRAVERSAL_DISABLED), |
| 34 min_port(0), | 44 min_port(0), |
| 35 max_port(0) { | 45 max_port(0) { |
| 36 } | 46 } |
| 37 | 47 |
| 38 explicit NetworkSettings(NatTraversalMode nat_traversal_mode) | 48 explicit NetworkSettings(uint32 flags) |
| 39 : nat_traversal_mode(nat_traversal_mode), | 49 : flags(flags), |
| 40 min_port(0), | 50 min_port(0), |
| 41 max_port(0) { | 51 max_port(0) { |
| 42 } | 52 } |
| 43 | 53 |
| 44 NatTraversalMode nat_traversal_mode; | 54 uint32 flags; |
| 45 | 55 |
| 46 // |min_port| and |max_port| specify range (inclusive) of ports used by | 56 // |min_port| and |max_port| specify range (inclusive) of ports used by |
| 47 // P2P sessions. Any port can be used when both values are set to 0. | 57 // P2P sessions. Any port can be used when both values are set to 0. |
| 48 int min_port; | 58 int min_port; |
| 49 int max_port; | 59 int max_port; |
| 60 | |
| 61 // Parse string in the form "<min_port>-<max_port>". E.g. "12400-12409". | |
| 62 // Returns true if string was parsed successfuly. | |
| 63 static bool ParsePortRange(const std::string& port_range, | |
|
Sergey Ulanov
2014/03/27 19:52:26
nit: this should be declared before |flags|. http:
dcaiafa
2014/03/27 23:36:21
Done.
| |
| 64 int* out_min_port, | |
| 65 int* out_max_port); | |
| 50 }; | 66 }; |
| 51 | 67 |
| 52 } // namespace remoting | 68 } // namespace remoting |
| 53 | 69 |
| 54 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_ | 70 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_ |
| OLD | NEW |