Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: remoting/jingle_glue/network_settings.h

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed even more CR comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/logging.h"
12
8 namespace remoting { 13 namespace remoting {
9 14
10 struct NetworkSettings { 15 struct NetworkSettings {
11 16
12 // When hosts are configured with NAT traversal disabled they will 17 // When hosts are configured with NAT traversal disabled they will
13 // typically also limit their P2P ports to this range, so that 18 // typically also limit their P2P ports to this range, so that
14 // sessions may be blocked or un-blocked via firewall rules. 19 // sessions may be blocked or un-blocked via firewall rules.
15 static const int kDefaultMinPort = 12400; 20 static const int kDefaultMinPort = 12400;
16 static const int kDefaultMaxPort = 12409; 21 static const int kDefaultMaxPort = 12409;
17 22
18 enum NatTraversalMode { 23 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 24 // Don't use STUN or relay servers. Accept incoming P2P connection
23 // attempts, but don't initiate any. This ensures that the peer is 25 // attempts, but don't initiate any. This ensures that the peer is
24 // on the same network. Note that connection will always fail if 26 // on the same network. Note that connection will always fail if
25 // both ends use this mode. 27 // both ends use this mode.
26 NAT_TRAVERSAL_DISABLED, 28 NAT_TRAVERSAL_DISABLED = 0x0,
27 29
28 // Don't use STUN or relay servers but make outgoing connections. 30 // Allow outgoing connections, even when STUN and RELAY are not enabled.
29 NAT_TRAVERSAL_OUTGOING, 31 NAT_TRAVERSAL_OUTGOING = 0x1,
32
33 // Active NAT traversal using STUN.
34 NAT_TRAVERSAL_STUN = 0x2,
35
36 // Allow the use of relay servers when a direct connection is not available.
37 NAT_TRAVERSAL_RELAY = 0x4,
38
39 // Active NAT traversal using STUN and relay servers.
40 NAT_TRAVERSAL_FULL = NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY |
41 NAT_TRAVERSAL_OUTGOING
30 }; 42 };
31 43
32 NetworkSettings() 44 NetworkSettings()
33 : nat_traversal_mode(NAT_TRAVERSAL_DISABLED), 45 : flags(NAT_TRAVERSAL_DISABLED),
46 min_port(0),
47 max_port(0) {
48 DCHECK(!(flags & (NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY)) ||
Sergey Ulanov 2014/03/27 23:43:06 nit: maybe comment why this is needed.
49 (flags & NAT_TRAVERSAL_OUTGOING));
50 }
51
52 explicit NetworkSettings(uint32 flags)
53 : flags(flags),
34 min_port(0), 54 min_port(0),
35 max_port(0) { 55 max_port(0) {
36 } 56 }
37 57
38 explicit NetworkSettings(NatTraversalMode nat_traversal_mode) 58 // Parse string in the form "<min_port>-<max_port>". E.g. "12400-12409".
39 : nat_traversal_mode(nat_traversal_mode), 59 // Returns true if string was parsed successfuly.
40 min_port(0), 60 static bool ParsePortRange(const std::string& port_range,
41 max_port(0) { 61 int* out_min_port,
42 } 62 int* out_max_port);
43 63
44 NatTraversalMode nat_traversal_mode; 64 uint32 flags;
45 65
46 // |min_port| and |max_port| specify range (inclusive) of ports used by 66 // |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. 67 // P2P sessions. Any port can be used when both values are set to 0.
48 int min_port; 68 int min_port;
49 int max_port; 69 int max_port;
50 }; 70 };
51 71
52 } // namespace remoting 72 } // namespace remoting
53 73
54 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_ 74 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_
OLDNEW
« no previous file with comments | « remoting/jingle_glue/chromium_port_allocator.cc ('k') | remoting/jingle_glue/network_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698