diff --git a/CMakeLists.txt b/CMakeLists.txt index d4954f0..0a1d690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.30) +cmake_minimum_required(VERSION 3.28) project(netkit LANGUAGES C CXX) option(NETKIT_ENABLE_OPENSSL "Enable OpenSSL support in netkit" ON) @@ -226,4 +226,4 @@ if (NETKIT_ENABLE_C_BINDINGS) endif() else() message(STATUS "C bindings disabled") -endif() \ No newline at end of file +endif() diff --git a/include/netkit-c/sock/sock_types.h b/include/netkit-c/sock/sock_types.h index 7569f48..d7220b4 100644 --- a/include/netkit-c/sock/sock_types.h +++ b/include/netkit-c/sock/sock_types.h @@ -17,7 +17,7 @@ typedef enum netkit_sock_type { SOCK_NONE, SOCK_TCP, SOCK_UDP, - SOCK_UNIX + SOCK_UDS } netkit_sock_type_t; typedef enum netkit_sock_status { @@ -52,4 +52,4 @@ typedef struct netkit_recv_result { } #endif #endif -#endif \ No newline at end of file +#endif diff --git a/include/netkit/sock/addr_type.hpp b/include/netkit/sock/addr_type.hpp index 455c8c2..ffb77cb 100644 --- a/include/netkit/sock/addr_type.hpp +++ b/include/netkit/sock/addr_type.hpp @@ -44,7 +44,7 @@ namespace netkit::sock { enum class type { tcp, /* TCP socket */ udp, /* UDP socket */ - unix, /* UNIX domain socket */ + uds, /* UNIX domain socket */ }; /** * @brief Socket options. @@ -89,4 +89,4 @@ namespace netkit::sock { using T = std::underlying_type_t; return static_cast(lhs) & static_cast(rhs); } -} \ No newline at end of file +} diff --git a/src/c/sock/sync_sock.cpp b/src/c/sock/sync_sock.cpp index 59b0b29..07d7c5f 100644 --- a/src/c/sock/sync_sock.cpp +++ b/src/c/sock/sync_sock.cpp @@ -12,8 +12,8 @@ struct netkit_sync_sock { switch (type) { case SOCK_UDP: return netkit::sock::type::udp; - case SOCK_UNIX: - return netkit::sock::type::unix; + case SOCK_UDS: + return netkit::sock::type::uds; default: return netkit::sock::type::tcp; } @@ -356,4 +356,4 @@ extern "C" NETKIT_C_API netkit_sock_addr_t* netkit_sync_sock_get_peer(netkit_syn } catch (...) { return nullptr; } -} \ No newline at end of file +} diff --git a/src/sock/sync_sock.cpp b/src/sock/sync_sock.cpp index 3f2bf35..ac9715c 100644 --- a/src/sock/sync_sock.cpp +++ b/src/sock/sync_sock.cpp @@ -186,7 +186,7 @@ netkit::sock::sync_sock::sync_sock(const sock::addr& addr, sock::type t, opt opt } } - if (t != type::unix) { + if (t != type::uds) { this->sockfd = ::socket(addr.is_ipv6() ? AF_INET6 : AF_INET, t == type::tcp ? SOCK_STREAM : SOCK_DGRAM, 0); } else { @@ -230,7 +230,7 @@ netkit::sock::sync_sock::sync_sock(const sock::addr& in_addr, sock::type t, opt int sock_type = SOCK_STREAM; int protocol = 0; - if (t != type::unix) { + if (t != type::uds) { domain = this->addr_.is_ipv6() ? AF_INET6 : AF_INET; sock_type = (t == type::tcp) ? SOCK_STREAM : SOCK_DGRAM; protocol = (t == type::tcp) ? IPPROTO_TCP : IPPROTO_UDP; @@ -365,7 +365,7 @@ std::unique_ptr netkit::sock::sync_sock::accept() throw socket_error("failed to accept connection: " + std::string(strerror(errno))); } - if (this->type_ == type::unix) { + if (this->type_ == type::uds) { return std::make_unique(client_sockfd, sock::addr(reinterpret_cast(&client_addr)->sun_path), this->type_); }