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

Unified Diff: remoting/base/util.cc

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/base/util.cc
diff --git a/remoting/base/util.cc b/remoting/base/util.cc
index 8102cb9bf5bdd7b3c1f3b8c6591f9619b0c3955f..42674bee4e304312e1ecde3770ff814e9be7a1f9 100644
--- a/remoting/base/util.cc
+++ b/remoting/base/util.cc
@@ -4,7 +4,9 @@
#include "remoting/base/util.h"
+#include <limits.h>
#include <math.h>
+#include <stdlib.h>
#include "base/logging.h"
#include "base/strings/stringprintf.h"
@@ -314,4 +316,21 @@ bool DoesRectContain(const webrtc::DesktopRect& a,
return intersection.equals(b);
}
+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());
+ 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