sunos patches, avoid shadowing data members in derived classes, header fixes

SunOS build works, with a few issues:

- no tuntap debugging on Solaris? (TUNSDEBUG ioctl missing)
- regular socket ioctls are not pulled in with #include <sys/ioctl.h>
  even though they're included at the bottom of same (filio.h,
  sockio.h)
- no named threads in any libre fork of solaris

-despair86 (rick)

sun patch
pull/13/head
despair86 6 years ago
parent 72c2231caf
commit 9ad93a0893

@ -165,12 +165,12 @@ if(UNIX)
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-openbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-netbsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-freebsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-freebsd.c ${TT_ROOT}/tuntap-unix-bsd.c)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-darwin.c ${TT_ROOT}/tuntap-unix-bsd.c)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-sunos.c)
else()
message(FATAL_ERROR "Your operating system is not supported yet")
endif()

@ -8,6 +8,26 @@
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
#elif defined(__sun)
#include <sys/byteorder.h>
#define htobe16(x) htons(x)
#define htole16(x) (x)
#define be16toh(x) ntohs(x)
#define le16toh(x) (x)
#define htobe32(x) htonl(x)
#define htole32(x) (x)
#define be32toh(x) ntohl(x)
#define le32toh(x) (x)
#define htobe64(x) \
(((uint64_t)htonl(((uint32_t)(((uint64_t)(x)) >> 32)))) \
| (((uint64_t)htonl(((uint32_t)(x)))) << 32))
#define htole64(x) (x)
#define be64toh(x) \
(((uint64_t)ntohl(((uint32_t)(((uint64_t)(x)) >> 32)))) \
| (((uint64_t)ntohl(((uint32_t)(x)))) << 32))
#define le64toh(x) (x)
#elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GLIBC__)
#include <endian.h>
#elif defined(__APPLE__) && defined(__MACH__)

@ -2,8 +2,15 @@
#define LLARP_IP_HPP
#include <llarp/buffer.h>
#include <llarp/time.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <memory>
#ifdef __sun
// slightly different type names on sunos
#define iphdr ip
#define saddr ip_src.s_addr
#define daddr ip_dst.s_addr
#endif
namespace llarp
{

@ -5,6 +5,12 @@
#include "router.hpp"
#include "session.hpp"
#ifdef __sun
#ifdef saddr
#undef saddr
#endif
#endif
#include <algorithm>
#include <fstream>

@ -56,7 +56,7 @@
*/
#if defined ETH_ALEN /* Linux */
#define ETHER_ADDR_LEN ETH_ALEN
#elif defined Windows
#elif defined Windows || defined __sun__
#define ETHER_ADDR_LEN 6
#endif
@ -86,7 +86,7 @@
*/
#if defined Windows
#include <in6addr.h>
#include <winsock.h>
#include <winsock2.h>
typedef HANDLE t_tun;
typedef IN_ADDR t_tun_in_addr;
typedef IN6_ADDR t_tun_in6_addr;

@ -20,7 +20,7 @@ extern "C" void
SetThreadName(DWORD dwThreadID, LPCSTR szThreadName);
#endif
#ifdef _WIN32
#if _WIN32 || __sun
#define wmin(x, y) (((x) < (y)) ? (x) : (y))
#define MIN wmin
#endif

@ -5,7 +5,7 @@
#define EV_TICK_INTERVAL 100
// apparently current Solaris will emulate epoll.
#if __linux__ || __SunOS_5_11
#if __linux__ || __sun__
#include "ev_epoll.hpp"
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
@ -19,7 +19,7 @@
void
llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
{
#if __linux__ || __SunOS_5_11
#if __linux__ || __sun__
*ev = new llarp_epoll_loop;
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
@ -111,4 +111,4 @@ bool
llarp_ev_tun_async_write(struct llarp_tun_io *tun, const void *pkt, size_t sz)
{
return static_cast< llarp::ev_io * >(tun->impl)->queue_write(pkt, sz);
}
}

@ -54,6 +54,14 @@ namespace llarp
m_writeq.Process([this](const std::unique_ptr< WriteBuffer >& buffer) {
write(fd, buffer->buf, buffer->bufsz);
});
// todo: wtf???
#ifndef _WIN32
#else
#if 0
DWORD bytes_written = 0;
if(::WriteFile((HANDLE)fd, buffer->payload.data(), buffer->payload.size(), &bytes_written, nullptr))
#endif
#endif
/// reset errno
errno = 0;
}

@ -21,13 +21,7 @@ namespace llarp
WSAOVERLAPPED portfds[2] = {0};
size_t iosz;
// the unique completion key that helps us to
// identify the object instance for which we receive data
// Here, we'll use the address of the udp_listener instance, converted to
// its literal int/int64 representation.
ULONG_PTR listener_id = 0;
udp_listener(SOCKET fd, llarp_udp_io* u) : ev_io(fd), udp(u){};
udp_listener(SOCKET fd, llarp_udp_io* u) : ev_io(fd), udp(u){};
~udp_listener()
{

@ -12,7 +12,7 @@
// win32 is the only one that doesn't use cpp17::filesystem
// because cpp17::filesystem is unimplemented for Windows
// -despair86
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__sun)
namespace fs = std::experimental::filesystem;
#else
namespace fs = std::filesystem;

@ -39,7 +39,7 @@
#include "version.h"
#if defined(CPP17) && defined(USE_CXX17_FILESYSTEM)
#if defined(__MINGW32__) || defined(_MSC_VER)
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__sun)
// win32 needs experimental
#include <experimental/filesystem>
#else

Loading…
Cancel
Save