mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 23:24:26 -04:00
dns: implement GetHostByName redirection (backend TODO)
This commit is contained in:
parent
8bf8df43e2
commit
400f5142ee
20 changed files with 1251 additions and 5 deletions
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "socket_api.hpp"
|
||||
#include "socket_allocator.hpp"
|
||||
|
||||
namespace ams::socket::impl {
|
||||
|
||||
void *Alloc(size_t size) {
|
||||
/* TODO: expheap, heap generation. */
|
||||
return ams::Malloc(size);
|
||||
}
|
||||
|
||||
void *Calloc(size_t num, size_t size) {
|
||||
if (void *ptr = Alloc(size * num); ptr != nullptr) {
|
||||
std::memset(ptr, 0, size * num);
|
||||
return ptr;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Free(void *ptr) {
|
||||
/* TODO: expheap, heap generation. */
|
||||
return ams::Free(ptr);
|
||||
}
|
||||
|
||||
u32 InetHtonl(u32 host) {
|
||||
if constexpr (util::IsBigEndian()) {
|
||||
return host;
|
||||
} else {
|
||||
return util::SwapBytes(host);
|
||||
}
|
||||
}
|
||||
|
||||
u16 InetHtons(u16 host) {
|
||||
if constexpr (util::IsBigEndian()) {
|
||||
return host;
|
||||
} else {
|
||||
return util::SwapBytes(host);
|
||||
}
|
||||
}
|
||||
|
||||
u32 InetNtohl(u32 net) {
|
||||
if constexpr (util::IsBigEndian()) {
|
||||
return net;
|
||||
} else {
|
||||
return util::SwapBytes(net);
|
||||
}
|
||||
}
|
||||
|
||||
u16 InetNtohs(u16 net) {
|
||||
if constexpr (util::IsBigEndian()) {
|
||||
return net;
|
||||
} else {
|
||||
return util::SwapBytes(net);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue