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
3 // found in the LICENSE file.
5 #ifndef REMOTING_JINGLE_GLUE_NETWORK_SETTINGS_H_
6 #define REMOTING_JINGLE_GLUE_NETWORK_SETTINGS_H_
10 #include "base/basictypes.h"
11 #include "base/logging.h"
15 struct NetworkSettings {
17 // When hosts are configured with NAT traversal disabled they will
18 // typically also limit their P2P ports to this range, so that
19 // sessions may be blocked or un-blocked via firewall rules.
20 static const int kDefaultMinPort = 12400;
21 static const int kDefaultMaxPort = 12409;
24 // Don't use STUN or relay servers. Accept incoming P2P connection
25 // attempts, but don't initiate any. This ensures that the peer is
26 // on the same network. Note that connection will always fail if
27 // both ends use this mode.
28 NAT_TRAVERSAL_DISABLED = 0x0,
30 // Allow outgoing connections, even when STUN and RELAY are not enabled.
31 NAT_TRAVERSAL_OUTGOING = 0x1,
33 // Active NAT traversal using STUN.
34 NAT_TRAVERSAL_STUN = 0x2,
36 // Allow the use of relay servers when a direct connection is not available.
37 NAT_TRAVERSAL_RELAY = 0x4,
39 // Active NAT traversal using STUN and relay servers.
40 NAT_TRAVERSAL_FULL = NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY |
41 NAT_TRAVERSAL_OUTGOING
45 : flags(NAT_TRAVERSAL_DISABLED),
48 DCHECK(!(flags & (NAT_TRAVERSAL_STUN | NAT_TRAVERSAL_RELAY)) ||
49 (flags & NAT_TRAVERSAL_OUTGOING));
52 explicit NetworkSettings(uint32 flags)
58 // Parse string in the form "<min_port>-<max_port>". E.g. "12400-12409".
59 // Returns true if string was parsed successfuly.
60 static bool ParsePortRange(const std::string& port_range,
66 // |min_port| and |max_port| specify range (inclusive) of ports used by
67 // P2P sessions. Any port can be used when both values are set to 0.
72 } // namespace remoting
74 #endif // REMOTING_HOST_NETWORK_SETTINGS_H_