mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-11-19 04:08:45 +00:00
6a5ea92a4e
Uthernet II: add extended feature to virtualise DNS requests. . This allows pure TCP/UDP sockets to run *without* MACRAW requests (and so without libpcap). . Raw sockets will not work. . Add configuration for Virtual DNS. libpcap: ensure all functions check if the library is loaded before using it. Uthernet 1: do NOT overwrite tfe_cannot_use as it should only reflect the availability of npcap on *this* system. Add Copyright notice, and mention Virtual DNS in html.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
/*
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
Copyright (C) 2022, Andrea Odetti
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with AppleWin; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "DNS.h"
|
|
|
|
#ifndef _MSC_VER
|
|
#include <arpa/inet.h>
|
|
#include <netdb.h>
|
|
#endif
|
|
|
|
uint32_t getHostByName(const std::string & name)
|
|
{
|
|
const hostent * host = gethostbyname(name.c_str());
|
|
if (host && host->h_addrtype == AF_INET && host->h_length == sizeof(uint32_t))
|
|
{
|
|
const in_addr * addr = (const in_addr *)host->h_addr_list[0];
|
|
if (addr)
|
|
{
|
|
return addr->s_addr;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
const char * formatIP(const uint32_t address)
|
|
{
|
|
in_addr in;
|
|
in.s_addr = address;
|
|
return inet_ntoa(in);
|
|
}
|