mirror of
https://github.com/reswitched/Mephisto.git
synced 2024-06-23 14:43:45 -04:00
passthrough htons/ntohs values on macos for sa_family
This commit is contained in:
parent
a2081b8b62
commit
1f891f27a9
|
@ -14,6 +14,15 @@
|
|||
}
|
||||
*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define fam_ntohs passthru_uint8
|
||||
#define fam_htons passthru_uint8
|
||||
__uint8_t passthru_uint8(__uint8_t a) { return a; }
|
||||
#else
|
||||
#define fam_htons htons
|
||||
#define fam_ntohs ntohs
|
||||
#endif
|
||||
|
||||
nn::socket::sf::IClient::IClient(Ctu *_ctu) : IpcService(_ctu) {
|
||||
passthrough = _ctu->socketsEnabled;
|
||||
}
|
||||
|
@ -26,7 +35,7 @@ uint32_t nn::socket::sf::IClient::Accept(IN uint32_t socket, OUT int32_t& ret, O
|
|||
ret = ::accept(socket, addr, &size);
|
||||
bsd_errno = errno;
|
||||
sockaddr_len = size;
|
||||
addr->sa_family = htons(addr->sa_family);
|
||||
addr->sa_family = fam_htons(addr->sa_family);
|
||||
} else {
|
||||
ret = 888;
|
||||
bsd_errno = 0;
|
||||
|
@ -37,7 +46,7 @@ uint32_t nn::socket::sf::IClient::Bind(IN uint32_t socket, IN sockaddr * _1, gui
|
|||
LOG_DEBUG(IpcStubs, "Stub implementation for nn::socket::sf::IClient::bind");
|
||||
if(passthrough) {
|
||||
struct sockaddr *addr = (struct sockaddr *) _1;
|
||||
addr->sa_family = ntohs(addr->sa_family);
|
||||
addr->sa_family = fam_ntohs(addr->sa_family);
|
||||
ret = ::bind(socket, addr, (uint32_t) _1_size);
|
||||
bsd_errno = errno;
|
||||
} else {
|
||||
|
@ -61,7 +70,7 @@ uint32_t nn::socket::sf::IClient::Connect(IN uint32_t socket, IN sockaddr * _1,
|
|||
LOG_DEBUG(IpcStubs, "Stub implementation for nn::socket::sf::IClient::connect");
|
||||
if(passthrough) {
|
||||
struct sockaddr *addr = (struct sockaddr *) _1;
|
||||
addr->sa_family = ntohs(addr->sa_family); // yes, this is network byte order on the switch and host byte order on linux
|
||||
addr->sa_family = fam_ntohs(addr->sa_family); // yes, this is network byte order on the switch and host byte order on linux
|
||||
ret = ::connect(socket, (struct sockaddr *) addr, (socklen_t) _1_size);
|
||||
bsd_errno = errno;
|
||||
} else {
|
||||
|
@ -78,7 +87,7 @@ uint32_t nn::socket::sf::IClient::GetSockName(IN uint32_t socket, OUT int32_t& r
|
|||
ret = ::getsockname(socket, addr, &addr_len);
|
||||
errno = bsd_errno;
|
||||
sockaddr_len = addr_len;
|
||||
addr->sa_family = htons(addr->sa_family);
|
||||
addr->sa_family = fam_htons(addr->sa_family);
|
||||
} else {
|
||||
sockaddr_len = 0;
|
||||
ret = 0;
|
||||
|
@ -123,7 +132,7 @@ uint32_t nn::socket::sf::IClient::SendTo(IN uint32_t socket, IN uint32_t flags,
|
|||
LOG_DEBUG(IpcStubs, "Stub implementation for nn::socket::sf::IClient::sendto");
|
||||
if(passthrough) {
|
||||
struct sockaddr *addr = (struct sockaddr *) _3;
|
||||
addr->sa_family = ntohs(addr->sa_family);
|
||||
addr->sa_family = fam_ntohs(addr->sa_family);
|
||||
ret = (uint32_t) ::sendto(socket, _2, (size_t) _2_size, flags, (struct sockaddr *) addr, (socklen_t) _3_size);
|
||||
bsd_errno = errno;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue