From 892d3409f087a2dfb3daafdd5873114c400127a8 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 15 Oct 2015 17:47:26 +0300 Subject: [PATCH] Parse TCP port correctly. --- .../stargazer/plugins/other/radius/config.cpp | 36 +++++++++++++++++-- .../stargazer/plugins/other/radius/config.h | 2 +- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/projects/stargazer/plugins/other/radius/config.cpp b/projects/stargazer/plugins/other/radius/config.cpp index 6a29f002..6742f811 100644 --- a/projects/stargazer/plugins/other/radius/config.cpp +++ b/projects/stargazer/plugins/other/radius/config.cpp @@ -167,6 +167,14 @@ T toInt(const std::vector& values) return 0; } +uint16_t toPort(const std::string& value) +{ + uint16_t res = 0; + if (str2x(value, res) == 0) + return res; + throw ParserError(0, "'" + value + "' is not a valid port number."); +} + typedef std::map Codes; // One-time call to initialize the list of codes. @@ -229,11 +237,31 @@ std::string parseString(const std::string& paramName, const std::vector