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

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

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: policy_templates.json; addressed other CR comments. Created 6 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/jingle_glue/network_settings.h"
6
7 #include <limits.h>
8 #include <stdlib.h>
9
10 namespace remoting {
11
12 bool ParsePortRange(const std::string& port_range,
13 int* out_min_port,
14 int* out_max_port) {
15 size_t separator_index = port_range.find('-');
16 if (separator_index == std::string::npos)
17 return false;
18
19 int min_port = atoi(port_range.substr(0, separator_index).c_str());
Sergey Ulanov 2014/03/27 18:31:20 With atoi() this function will accept strings like
dcaiafa 2014/03/27 19:32:24 Done.
20 int max_port = atoi(port_range.substr(separator_index + 1).c_str());
21
22 if (min_port <= 0 || min_port > max_port || max_port > USHRT_MAX)
23 return false;
24
25 *out_min_port = min_port;
26 *out_max_port = max_port;
27 return true;
28 }
29
30 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698