Server - Add -a/--address option
Change-Id: Ia9e8d76b9a4ba0aadc567142601a87f0ad0b69e4 Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
This commit is contained in:
1 parent
c661bab06f
commit
ed3cfffd7e
4 files changed
+36
-3
No files matched your search
@@ -20,9 +20,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#include <netinet/in.h>
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -77,5 +80,12 @@ bool IsNumber(const std::string &s) {
|
||||
return !s.empty() && std::all_of(s.begin(), s.end(), ::isdigit);
|
||||
}
|
||||
|
||||
bool IsIP(const std::string &s) {
|
||||
struct sockaddr_in sa;
|
||||
int result = inet_pton(AF_INET, s.c_str(), &sa);
|
||||
// inet_pton returns 1 on success
|
||||
return result == 1;
|
||||
}
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
@@ -49,6 +49,7 @@ int
|
||||
ReadFile(const char *path, std::string *retStr, bool chop_newline = false);
|
||||
|
||||
bool IsNumber(const std::string &s);
|
||||
bool IsIP(const std::string &s);
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
Reference in new issue
Block a user