Server - Add -a/--address option

Change-Id: Ia9e8d76b9a4ba0aadc567142601a87f0ad0b69e4
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
Cette révision appartient à :
Galantsev, Dmitrii a révisé 2023-12-04 15:26:44 -06:00
1 Parent c661bab06f
révision ed3cfffd7e
4 fichiers modifiés
+36 -3

Aucun fichier ne correspond à votre recherche

+10
Voir le fichier
@@ -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
+1
Voir le fichier
@@ -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