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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: remoting/jingle_glue/network_settings.cc
diff --git a/remoting/jingle_glue/network_settings.cc b/remoting/jingle_glue/network_settings.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3bde3ee9f911754fc1a3822214824fc0a7a2fc64
--- /dev/null
+++ b/remoting/jingle_glue/network_settings.cc
@@ -0,0 +1,30 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/jingle_glue/network_settings.h"
+
+#include <limits.h>
+#include <stdlib.h>
+
+namespace remoting {
+
+bool ParsePortRange(const std::string& port_range,
+ int* out_min_port,
+ int* out_max_port) {
+ size_t separator_index = port_range.find('-');
+ if (separator_index == std::string::npos)
+ return false;
+
+ 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.
+ int max_port = atoi(port_range.substr(separator_index + 1).c_str());
+
+ if (min_port <= 0 || min_port > max_port || max_port > USHRT_MAX)
+ return false;
+
+ *out_min_port = min_port;
+ *out_max_port = max_port;
+ return true;
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698